Page 1 of 1

Screen rotation not sending correct keycodes

PostPosted: Apr 30, 2008 @ 12:50am
by mm40
I am testing on a HTC Tilt. When the OS Screen Rotaiton is set to portrait everything works fine, but when I set it to Landscape1 or Landscape2 then things don't work correctly.

To test I put the OS in Landscape2 (270) and the keyboard closed, I then pressed the down directional key (down relative to the device in portrait mode).

app started
pressing down generates keycode 40 (incorrect)
keyboard opened
pressing down generates keycode 37
keyboard closed
pressing down generates keycode 39

so even though the device is in the exact same configurations in keypress 1 and 3, they generate different keycodes!

further testing, I start the app with the keyboard already open.

app started
pressing down generates keycode 40 (incorrect)
keyboard closed
pressing down generates keycode 39
keyboard open
pressing down generates keycode 37

and again keypresses 1 and 3 are different but they should match. does anyone know what is going on here?

PostPosted: Apr 30, 2008 @ 1:51am
by Kzinti
Assuming you are using GAPI, the behaviour is explained as follow:

1) GAPI will restore the screen to portrait mode when you call GXOpenDIsplay. So when you press down, you get VK_DOWN (ie: 40)
2) You open the keyboard. The screen/shell is rotated (landscape 90) and pressing down sends VK_LEFT (37).
3) You close the kayboard. The screen/shell is restored to the user's settings (ie: landscape 270). You get VK_RIGHT (39).

Similar reasoning for your second test case.

PostPosted: Apr 30, 2008 @ 4:47am
by mm40
Should I make a system call to set the screen/shell to the user rotation immediately after calling GXOpenDIsplay?

PostPosted: Apr 30, 2008 @ 7:09am
by Kzinti
It probably would work, but changing the screen orientation is a slow operation.

In PocketHAL, I decided to do it differently: I query for the current screen orientation vs the one specified at initialization time. If they are different, I simply rotate the arrow keys.