Cross-Platform Game Programming with gameplay3d/Getting Some Input

Handling input in your gameplay3d game is easy - the  class, from which your game inherits, contains a number of   methods which are called whenever there is any input to be handled, so all you need to do is to override these methods in your game.

Mouse
is called when a mouse event occurs. The function signature for the mouseEvent method is as follows:

where:
 * represents the mouse event that occurred and is one of the following  values defined in Mouse.h:
 * is the x position of the mouse in pixels. (Left edge is zero.)
 * is the y position of the mouse in pixels. (Top edge is zero.)
 * is the number of mouse wheel ticks. (Positive is up/forward, negative is down/backward.)
 * is the x position of the mouse in pixels. (Left edge is zero.)
 * is the y position of the mouse in pixels. (Top edge is zero.)
 * is the number of mouse wheel ticks. (Positive is up/forward, negative is down/backward.)
 * is the x position of the mouse in pixels. (Left edge is zero.)
 * is the y position of the mouse in pixels. (Top edge is zero.)
 * is the number of mouse wheel ticks. (Positive is up/forward, negative is down/backward.)
 * is the y position of the mouse in pixels. (Top edge is zero.)
 * is the number of mouse wheel ticks. (Positive is up/forward, negative is down/backward.)

Mouse events that are not consumed will be interpreted as a touch event. You can consume a mouse event by overriding  and returning true. This gives you the option to uniquely handle mouse events from touch events. returns false by default.

Note that some mobile devices can use a Bluetooth mouse.

You can enable or disable "mouse capture" using the  method, which takes a boolean value as an argument. On platforms that support a mouse, when mouse capture is enabled, the platform cursor will be hidden and the mouse will be warped to the center of the screen. While mouse capture is enabled, all mouse move events will then be delivered as deltas instead of absolute positions.

, which also takes a boolean value, can be used to show (true) or hide (false) the mouse cursor.

Keyboard
is called when a keyboard event occurs. The function signature for the  method is as follows:

where:
 * represents the key event that occurred and is one of the following enum values defined in Keyboard.h:
 * - this is used for textual characters and is therefore not triggered by pressing keys such as,  , the arrow keys,  ,   etc.
 * - If  is   or   then key is the key code from  . If evt is   then key is the unicode value of the character.
 * - this is used for textual characters and is therefore not triggered by pressing keys such as,  , the arrow keys,  ,   etc.
 * - If  is   or   then key is the key code from  . If evt is   then key is the unicode value of the character.

A full list of the different key codes in the  enum can be found at this page in the gameplay3d API reference, or in the Keyboard.h source file.

You can call, which takes a boolean value, to show (true) or hide (false) a virtual keyboard for platforms that support it.

Basics
is called when a touch event occurs. The function signature for the  method is as follows:

where:
 * represents the touch event that occurred and is one of the following enum values defined in Touch.h:
 * is the x position of the touch in pixels. (Left edge is zero.)
 * is the y position of the touch in pixels. (Top edge is zero.)
 * is used to differentiate multiple touch contacts where multi-touch is enabled, and represents the order of occurrence for multiple touch contacts starting at zero. However, do not assume that the  values are sequential.
 * is the x position of the touch in pixels. (Left edge is zero.)
 * is the y position of the touch in pixels. (Top edge is zero.)
 * is used to differentiate multiple touch contacts where multi-touch is enabled, and represents the order of occurrence for multiple touch contacts starting at zero. However, do not assume that the  values are sequential.

Some platforms may allow you to touch outside the bounds of the screen, so negative  and   values are possible.

You can enable multi-touch using, which takes a boolean value. The default is disabled (false).

Gestures
Some platforms support gestures. can be used to determine which gestures are supported.

The gestures you can check for are defined in the  enum in Gesture.h and are as follows:

, which takes a GestureEvent value as an argument, is used to register for a type of gesture.

Once a gesture is registered, you will receive callbacks via the following virtual methods. See the function declarations in Game.h for details of the parameters: