libsdl-org / SDL-1.2

Simple Directmedia Layer, 1.2 branch ... ***DEPRECATED***, please use https://github.com/libsdl-org/SDL for new projects!
https://libsdl.org
GNU Lesser General Public License v2.1
98 stars 81 forks source link

[WINCE] Cannot rotate screen Portrait<->Landscape #847

Closed carlo-bramini closed 3 years ago

carlo-bramini commented 3 years ago

From README.Wince, we can read this information:

- Landscape mode and automatic rotation of buttons and stylus coordinates.
  To enable landscape mode make width of video screen bigger than height.
  For example: 
    SDL_SetVideoMode(320,240,16,SDL_FULLSCREEN)

However, this does not seem to be true, at least with the source into the repo at the time of writing. Making Width > Height does not rotate the screen. I don't know if:

...but at the moment the library does not change from portrait to landscape when you follow the instructions written into the readme file. Instead, if you create a 320x240 screen on a 240x320 device, it simply overflows the space on the display.

VirtualBox_windows xp_26_08_2021_19_53_33

sezero commented 3 years ago

Patches are welcome.

ccawley2011 commented 3 years ago

It appears that the code for this in the windib video driver is disabled when targeting Windows CE versions older than 4.2.

https://github.com/libsdl-org/SDL-1.2/blob/main/src/video/windib/SDL_dibvideo.c#L695

Alternatively, the gapi driver looks like it would handle screen rotation.

carlo-bramini commented 3 years ago

It appears that the code for this in the windib video driver is disabled when targeting Windows CE versions older than 4.2.

Talking about the windib driver, probably there is a bug in this line:

https://github.com/libsdl-org/SDL-1.2/blob/main/src/video/windib/SDL_dibvideo.c#L362

Correct way for handling the detection of the feature should be:

if (ChangeDisplaySettingsEx(NULL, &settings, NULL, CDS_TEST, NULL) == DISP_CHANGE_SUCCESSFUL)
    this->hidden->supportRotation = (settings.dmDisplayOrientation != DMDO_0);
sezero commented 3 years ago

If you tested it well, please send a pull request for it. (Also, do you not need an else case in there?)

carlo-bramini commented 3 years ago

If you tested it well, please send a pull request for it. (Also, do you not need an else case in there?)

There is an SDL_memset() inside DIB_CreateDevice() that clears the structure, so I thought that adding also an "else" statement was not strictly required, but it can be added if it improves the readability of the code if someone wants.

sezero commented 3 years ago

There is an SDL_memset() inside DIB_CreateDevice() that clears the structure, so I thought that adding also an "else" statement was not strictly required

OK

carlo-bramini commented 3 years ago

After some debugging, I think that I have discovered the causes of the problem: 1) actually, the GAPI driver was missing in my build because it must be explicitely activated with --enable-gapi option to configure. By reversing width and height dimensions, you are able to display graphics in portrait. This has been tested on a real device with Windows Mobile 2003. 2) So, the windib driver was the only one that I was using. The rotation made with ChangeDisplaySettingsEx() is not supported in both the emulator and on my ASUS MyPal A620, but because the bug that I described in a previous comment, libSDL thinks that the device is able to do it. As result, it registers also the 320x240 resolution in addition to 240x320 and that's why I'm getting the output the you can see in my screenshot. PR #848 fixes this issue.

sezero commented 3 years ago

Fixed by PR #848