Is it possible with PocketHAL to not automatically have the screen and keys rotated when orientation is changed by sliding out the keyboard? I need to be able to accept the orientation change on some screens, but force it to remain portrait on other screens that haven't been designed to cope with landscape orientation.
If I understand correctly, you do not want PocketHAL to "rotate" directional keys and mouse positions when the display orientation changes?
The problem is how does one detect that a screen hasn't been designed to cope with landscape orientation... The functionality could easily be added and activated with a flag at initialization time, but I wouldn't know how to detect that a phone has a sliding keyboard...
The control needs to be defined in application logic, so the application must let PocketHAL know whether it is acceptable to change the orientation and remap keys.
Don't worry about the sliding keyboard - just assume any orientation change as reported through WM_SETTINGCHANGE. In fact, probably don't even need to worry about that - just if device reports back different orientation different to last frame then there needs to be a way for the application to say whether it should allow PocketHAL to auto adjust according to the change as well.
The issue I'm trying to work around is that some screens in the application are designed for only landscape and don't make sense changing orientation even if the user slides the keyboard out - just want to keep it in portrait as if nothing happened.
At the moment I have my code responding to a WM_SETTINGCHANGE message to check if the shell orientation has changed, and if so I recreate the Display object with the currently reported orientation. I can't remember why I do that - it might have been for pre-1.03 when keys weren't auto remapped? Is there actually a need to recreate the Display object on orientation change? Perhaps if I didn't do that it would just carry on as per normal anyhow?
Does that sound right? Could I just ignore WM_SETTINGCHANGE and not recreate the Display for when I want orientation preserved, but leave current functionality for when I want auto orientation awareness? In which case PHAL doesn't need any change, just the way I'm working with it.
Yes, I think that would work for you.
And yes, you did it that way because PocketHAL didn't support auto-rotation of keys / stylus before.
Although all this makes me feel that rotation shouldn't be in PocketHAL. Perhaps I could move it out to the samples framework.
Ok, just done a test and it works. By not recreating the display object it stays in the correct orientation, keys are fine, everything is ok.
I'm happy with key mapping being where it is. What I'm going to do with the WM_SETTINGSCHANGE handler is rather than immediately create a Display object I will pass it back to my Application class to request if the orientation change should be allowed. If it is allowed then as per existing code, if not, skip the call to create new display.
Only tested this on one device but am assuming this should be consistent.
Thanks Thierry.
This approach definetely works! We use it in our iwindowsmobile.com software.
