Game Development Reference
In-Depth Information
Value
Description
S3E_POINTER_STATE_PRESSED
The button or touch screen has just been pressed.
S3E_POINTER_STATE_RELEASED The button or touch screen has just been released.
S3E_POINTER_STATE_UNKNOWN
Current status of this button is not known.
For example, the middle mouse button status
was requested but there is no middle mouse
button present on the hardware.
With this information we now have the ability to track the pointer or touch screen
position and determine when the user has touched or released the touch screen or
pressed a mouse button.
Detecting single touch input using callbacks
It is also possible to keep track of pointer events using a callback-based system. For
single touch input, there are two event types that we can register callback functions
for; these are button and motion events.
We can start receiving pointer events by calling the s3ePointerRegister function,
and we can stop them by calling s3ePointerUnRegister . Both functions take
a value to identify the type of event we are concerned with, and a pointer to a
callback function.
When registering a callback function, we can also provide a pointer to our own
custom data structure that will be passed into the callback function whenever an
event occurs.
The following code snippet shows how we can register a callback function that will
be executed whenever the touch screen or a mouse button is pressed or released:
// Callback function that will receive pointer button notifications
int32 ButtonEventCallback(s3ePointerEvent* apButtonEvent,
void* apUserData)
{
if (apButtonEvent->m_Button == S3E_POINTER_BUTTON_SELECT)
{
if (apButtonEvent->m_Pressed)
{
// Left mouse button or touch screen pressed
}
else
Search WWH ::




Custom Search