I have received an Ultrabook™ 2 in 1 Convertible from Intel® to implement support for both Laptop-mode and touch/tablet/slate-mode for our game Desert Stormfront. It’s quite a nice device. Thanks to Intel for providing the Ultrabook for development.
Desert Stormfront is running using libGDX over OpenGL. If your game or application isn’t using mouse-specific features such as scrolling when the mouse is at the edges of the screen and uses libGDX’s input processor to listen for events no changes are generally necessary to support tablet-mode. The game will work out of the box. If you are polling the mouse things don’t work as smoothly. If you poll mouse buttons for clicks you will not receive any mouse down information at all. The mouse buttons will not report anything and will always appear as non-pressed. Again, this is for polling only. On Windows 8, due to gestures being enabled by default, touch down events will not be reported until just right before the touch up event. If you poll the mouse/touch-screen, due to the down & up event being sent right after each other, no mouse presses are detectable. I haven’t found a way to disable gestures on Windows 8 so make sure you listen for events via libGDX’s input processor rather than polling for changes. And yes, I tried some solutions to disable gestures, but unfortunately none of them worked.
In any case, if you want to optimize your game or application for tablet mode on Windows 8, Intel has provided documentation for Detecting Slate/Clamshell Mode & Screen Orientation in a 2 in 1 Device. The code samples are available in C++. If you are like me, you need to get things to work for Java/libGDX. If you’d like to use my source code below (SystemHook.java), you will also need to download the jna.jar file (from JNA on GitHub) and run in together with SystemHook.java. You don’t need the jna-platform.jar. What can you do:
- If you have created a game, you might want to set the preferred screen orientation (e.g. landscape):
SystemHook.setDisplayOrientation(SystemHook.ORIENTATION_LANDSCAPE | SystemHook.ORIENTATION_LANDSCAPE_FLIPPED);
I believe the call should be made before the actual window is being created, i.e. before you create the LwjglApplication and the window thereafter if you are using LWJGL.
- Detect if a device is in touch/tablet/slate mode:
boolean touchMode = SystemHook.hasDisplayTouch(); ...
This has to be called periodically to detect what mode the screen is in. Please note when the screen has been converted to touch-based input, the keyboard will stop reporting key events and an on-screen keyboard will have to be displayed if you are planning on using text input.
Feel free to post questions. If you’d like to see the game in action, please download the demo version of Tropical/Desert Stormfront from the official web site. Here is a demo video (sorry for the low quality):
- SystemHook.java (to detect screen mode and set preferred screen orientation)
- obtain jna.jar via JNA on GitHub
- Tropical/Desert Stormfront – Demo Download
- Intel® – Detecting Slate/Clamshell Mode & Screen Orientation in a 2 in 1 Device
- Intel® – Ultrabook™ 2 in 1 Convertible
- LibGDX – http://libgdx.badlogicgames.com/
All the code I have provided is released under the WTFPL – Do What the Fuck You Want to Public License.