Gainput  v1.0.0
Public Member Functions | Protected Member Functions | List of all members
gainput::InputDeviceTouch Class Reference

A touch input device. More...

#include <GainputInputDeviceTouch.h>

Inheritance diagram for gainput::InputDeviceTouch:
gainput::InputDevice

Public Member Functions

 InputDeviceTouch (InputManager &manager, DeviceId device, unsigned index, DeviceVariant variant)
 Initializes the device. More...
 
 ~InputDeviceTouch ()
 Shuts down the device.
 
DeviceType GetType () const
 Returns DT_TOUCH.
 
DeviceVariant GetVariant () const
 Returns the device variant.
 
const char * GetTypeName () const
 Returns the device type's name.
 
bool IsValidButtonId (DeviceButtonId deviceButton) const
 Returns if the given button is valid for this device.
 
size_t GetAnyButtonDown (DeviceButtonSpec *outButtons, size_t maxButtonCount) const
 Checks if any button on this device is down. More...
 
size_t GetButtonName (DeviceButtonId deviceButton, char *buffer, size_t bufferLength) const
 Gets the name of the given button. More...
 
ButtonType GetButtonType (DeviceButtonId deviceButton) const
 Returns the type of the given button.
 
DeviceButtonId GetButtonByName (const char *name) const
 Returns the button's ID if the name is of this device's buttons. More...
 
InputStateGetNextInputState ()
 Returns the device's state that is currently being determined, may be 0 if not available.
 
InputDeviceTouchImpl * GetPimpl ()
 Returns the platform-specific implementation of this device.
 
- Public Member Functions inherited from gainput::InputDevice
 InputDevice (InputManager &manager, DeviceId device, unsigned index)
 Initializes the input device. More...
 
virtual ~InputDevice ()
 Empty virtual destructor.
 
void Update (InputDeltaState *delta)
 Update this device, internally called by InputManager. More...
 
DeviceId GetDeviceId () const
 Returns this device's ID.
 
unsigned GetIndex () const
 Returns the device's index among devices of the same type.
 
virtual bool IsLateUpdate () const
 Returns if this device should be updated after other devices.
 
DeviceState GetState () const
 Returns the device state.
 
virtual bool IsAvailable () const
 Returns if this device is available.
 
bool GetBool (DeviceButtonId deviceButton) const
 Returns the current state of the given button.
 
bool GetBoolPrevious (DeviceButtonId deviceButton) const
 Returns the previous state of the given button.
 
float GetFloat (DeviceButtonId deviceButton) const
 Returns the current state of the given button.
 
float GetFloatPrevious (DeviceButtonId deviceButton) const
 Returns the previous state of the given button.
 
InputStateGetInputState ()
 Returns the device's state, probably best if only used internally.
 
const InputStateGetInputState () const
 Returns the device's state, probably best if only used internally.
 
InputStateGetPreviousInputState ()
 Returns the device's previous state, probably best if only used internally.
 
float GetDeadZone (DeviceButtonId buttonId) const
 Returns the previously set dead zone for the given button or 0.0f if none was set yet.
 
void SetDeadZone (DeviceButtonId buttonId, float value)
 Sets the dead zone for the given button.
 
void SetDebugRenderingEnabled (bool enabled)
 Enable/disable debug rendering of this device.
 
bool IsDebugRenderingEnabled () const
 Returns true if debug rendering is enabled, false otherwise.
 
bool IsSynced () const
 
void SetSynced (bool synced)
 Sets if this device is being controlled remotely or from a recording. More...
 

Protected Member Functions

void InternalUpdate (InputDeltaState *delta)
 Implementation of the device's Update function. More...
 
DeviceState InternalGetState () const
 Implementation of the device's GetState function. More...
 
- Protected Member Functions inherited from gainput::InputDevice
size_t CheckAllButtonsDown (DeviceButtonSpec *outButtons, size_t maxButtonCount, unsigned start, unsigned end) const
 Checks which buttons are down. More...
 

Additional Inherited Members

- Public Types inherited from gainput::InputDevice
enum  DeviceType {
  DT_MOUSE, DT_KEYBOARD, DT_PAD, DT_TOUCH,
  DT_BUILTIN, DT_REMOTE, DT_GESTURE, DT_CUSTOM,
  DT_COUNT
}
 Type of an input device. More...
 
enum  DeviceVariant { DV_STANDARD, DV_RAW, DV_NULL }
 Variant of an input device type. More...
 
enum  DeviceState { DS_OK, DS_LOW_BATTERY, DS_UNAVAILABLE }
 State of an input device. More...
 
- Static Public Attributes inherited from gainput::InputDevice
static const unsigned AutoIndex = unsigned(-1)
 
- Protected Attributes inherited from gainput::InputDevice
InputManagermanager_
 The manager this device belongs to.
 
DeviceId deviceId_
 The ID of this device.
 
unsigned index_
 Index of this device among devices of the same type.
 
InputStatestate_
 The current state of this device.
 
InputStatepreviousState_
 The previous state of this device.
 
float * deadZones_
 
bool debugRenderingEnabled_
 Specifies if this device is currently rendering debug information.
 
bool synced_
 

Detailed Description

A touch input device.

This input device provides support for touch screen/surface devices. The valid device buttons are defined in the TouchButton enum. For each touch point, there is a boolean input (Touch*Down) showing if the touch point is active, two float inputs (Touch*X, Touch*Y) showing the touch point's position, and a float input (Touch*Pressure) showing the touch's pressure.

Not all touch points must be numbered consecutively, i.e. point #2 may be down even though #0 and #1 are not.

The number of simultaneously possible touch points is implementaion-dependent.

This device is implemented on Android NDK.

Examples:
/samples/basic/basicsample_android.cpp, /samples/dynamic/dynamicsample.cpp, /samples/gesture/gesturesample.cpp, /samples/listener/listenersample.cpp, /samples/recording/recordingsample.cpp, and /samples/sync/syncsample.cpp.

Constructor & Destructor Documentation

◆ InputDeviceTouch()

gainput::InputDeviceTouch::InputDeviceTouch ( InputManager manager,
DeviceId  device,
unsigned  index,
DeviceVariant  variant 
)

Initializes the device.

Instantiate the device using InputManager::CreateDevice().

Parameters
managerThe input manager this device is managed by.
deviceThe ID of this device.

Member Function Documentation

◆ GetAnyButtonDown()

size_t gainput::InputDeviceTouch::GetAnyButtonDown ( DeviceButtonSpec outButtons,
size_t  maxButtonCount 
) const
virtual

Checks if any button on this device is down.

Parameters
[out]outButtonsAn array with maxButtonCount fields to receive the device buttons that are down.
maxButtonCountThe number of fields in outButtons.
Returns
The number of device buttons written to outButtons.

Reimplemented from gainput::InputDevice.

◆ GetButtonByName()

DeviceButtonId gainput::InputDeviceTouch::GetButtonByName ( const char *  name) const
virtual

Returns the button's ID if the name is of this device's buttons.

Parameters
nameName of the device button to look for.
Returns
The device button ID.

Reimplemented from gainput::InputDevice.

◆ GetButtonName()

size_t gainput::InputDeviceTouch::GetButtonName ( DeviceButtonId  deviceButton,
char *  buffer,
size_t  bufferLength 
) const
virtual

Gets the name of the given button.

Parameters
deviceButtonID of the button.
bufferA char-buffer to receive the button name.
bufferLengthLength of the buffer receiving the button name in bytes.
Returns
The number of bytes written to buffer (includes the trailing \0).

Reimplemented from gainput::InputDevice.

◆ InternalGetState()

DeviceState gainput::InputDeviceTouch::InternalGetState ( ) const
protectedvirtual

Implementation of the device's GetState function.

Returns
The device's state.

Implements gainput::InputDevice.

◆ InternalUpdate()

void gainput::InputDeviceTouch::InternalUpdate ( InputDeltaState delta)
protectedvirtual

Implementation of the device's Update function.

Parameters
deltaThe delta state to add changes to. May be 0.

Implements gainput::InputDevice.


The documentation for this class was generated from the following file: