InputDevice. More...

#include <input_device.h>

Public Types

enum  Type { keyboard, pointer, joystick, unknown }
 Input device types. More...
 

Public Member Functions

 InputDevice ()
 Constructs a null instance. More...
 
 InputDevice (InputDeviceProvider *provider)
 Constructs a InputDevice. More...
 
 InputDevice (std::weak_ptr< InputDevice_Impl > impl)
 Constructs a InputDevice. More...
 
 ~InputDevice ()
 
float get_axis (int axisid) const
 Returns the the current position of a joystick axis. (Joysticks only) More...
 
std::vector< int > get_axis_ids () const
 Returns the number of axes available on this device. (Joysticks only) More...
 
int get_button_count () const
 Returns the number of buttons available on this device. If used on a keyboard or mouse, this function returns -1. More...
 
std::string get_device_name () const
 Return the hardware id/device for this device (i.e. /dev/input/js0) More...
 
Point get_device_position () const
 Returns the current devicesice-supplied x and y position of the device. (Pointing devices only) The returned positional value is in the scale of the physical pixel on the screen. More...
 
int get_hat (int index) const
 Returns the current position of a joystick hat. (Joysticks only) More...
 
std::string get_key_name (int id) const
 Retrieves the localized friendly key name for specified identifier (i.e. A, B, Leertaste, Backspace, Mouse Left, ...). More...
 
bool get_keycode (int keycode) const
 Returns true if the passed key code is down for this device. See keys.h for list of key codes. More...
 
std::string get_name () const
 Returns the human readable name of the device (i.e. 'Microsoft Sidewinder 3D'). More...
 
Pointf get_position () const
 Returns the current device-independent x and y position (DIP) of the device. (Pointing devices only) The returned positional value is scaled to the pixel ratio of the display. More...
 
InputDeviceProviderget_provider () const
 Returns the provider for this input device. More...
 
Type get_type () const
 Returns the input device type. More...
 
bool is_null () const
 Returns true if this object is invalid. More...
 
std::string keyid_to_string (int keycode) const
 Returns a generic string name for the specified key code. More...
 
 operator bool () const
 
InputDeviceoperator= (const InputDevice &copy)
 
void set_device_position (int x, int y)
 Sets the actual position of the device. (Pointing devices only) More...
 
void set_position (float x, float y)
 Sets the display-independent position of the device. (Pointing devices only) More...
 
Signal< void(const InputEvent &)> & sig_axis_move ()
 Signal emitted when axis is moved. More...
 
Signal< void(const InputEvent &)> & sig_key_dblclk ()
 Signal emitted when the mouse is double-clicked. More...
 
Signal< void(const InputEvent &)> & sig_key_down ()
 Signal emitted when key is pressed. More...
 
Signal< void(const InputEvent &)> & sig_key_up ()
 Signal emitted when key is released. More...
 
Signal< void(const InputEvent &)> & sig_pointer_move ()
 Signal emitted when pointer is moved (absolute movement). More...
 
Signal< void(const InputEvent &)> & sig_proximity_change ()
 Signal emitted when proximity is entered or exited. More...
 
int string_to_keyid (const std::string &str) const
 Returns the key code for the specified generic string key name. More...
 
void throw_if_null () const
 Throw an exception if this object is invalid. More...
 

Detailed Description

Constructor & Destructor Documentation

clan::InputDevice::InputDevice ( )

Constructs a null instance.

clan::InputDevice::InputDevice ( InputDeviceProvider provider)

Constructs a InputDevice.

Parameters
provider= Input Device Provider
clan::InputDevice::InputDevice ( std::weak_ptr< InputDevice_Impl >  impl)

Constructs a InputDevice.

Parameters
impl= Weak Ptr
clan::InputDevice::~InputDevice ( )

Member Function Documentation

float clan::InputDevice::get_axis ( int  axisid) const

Returns the the current position of a joystick axis. (Joysticks only)

std::vector<int> clan::InputDevice::get_axis_ids ( ) const

Returns the number of axes available on this device. (Joysticks only)

int clan::InputDevice::get_button_count ( ) const

Returns the number of buttons available on this device. If used on a keyboard or mouse, this function returns -1.

std::string clan::InputDevice::get_device_name ( ) const

Return the hardware id/device for this device (i.e. /dev/input/js0)

Point clan::InputDevice::get_device_position ( ) const

Returns the current devicesice-supplied x and y position of the device. (Pointing devices only) The returned positional value is in the scale of the physical pixel on the screen.

int clan::InputDevice::get_hat ( int  index) const

Returns the current position of a joystick hat. (Joysticks only)

Returns
Hat direction in degrees (0-360), or -1 if the hat is centered.
std::string clan::InputDevice::get_key_name ( int  id) const

Retrieves the localized friendly key name for specified identifier (i.e. A, B, Leertaste, Backspace, Mouse Left, ...).

Note
The returned name for the key may be localized by the system; it
bool clan::InputDevice::get_keycode ( int  keycode) const

Returns true if the passed key code is down for this device. See keys.h for list of key codes.

std::string clan::InputDevice::get_name ( ) const

Returns the human readable name of the device (i.e. 'Microsoft Sidewinder 3D').

Pointf clan::InputDevice::get_position ( ) const

Returns the current device-independent x and y position (DIP) of the device. (Pointing devices only) The returned positional value is scaled to the pixel ratio of the display.

InputDeviceProvider* clan::InputDevice::get_provider ( ) const

Returns the provider for this input device.

Type clan::InputDevice::get_type ( ) const

Returns the input device type.

bool clan::InputDevice::is_null ( ) const
inline

Returns true if this object is invalid.

std::string clan::InputDevice::keyid_to_string ( int  keycode) const

Returns a generic string name for the specified key code.

clan::InputDevice::operator bool ( ) const
inlineexplicit
InputDevice& clan::InputDevice::operator= ( const InputDevice copy)
void clan::InputDevice::set_device_position ( int  x,
int  y 
)

Sets the actual position of the device. (Pointing devices only)

void clan::InputDevice::set_position ( float  x,
float  y 
)

Sets the display-independent position of the device. (Pointing devices only)

Signal<void(const InputEvent &)>& clan::InputDevice::sig_axis_move ( )

Signal emitted when axis is moved.

Signal<void(const InputEvent &)>& clan::InputDevice::sig_key_dblclk ( )

Signal emitted when the mouse is double-clicked.

Signal<void(const InputEvent &)>& clan::InputDevice::sig_key_down ( )

Signal emitted when key is pressed.

Signal<void(const InputEvent &)>& clan::InputDevice::sig_key_up ( )

Signal emitted when key is released.

Signal<void(const InputEvent &)>& clan::InputDevice::sig_pointer_move ( )

Signal emitted when pointer is moved (absolute movement).

Signal<void(const InputEvent &)>& clan::InputDevice::sig_proximity_change ( )

Signal emitted when proximity is entered or exited.

int clan::InputDevice::string_to_keyid ( const std::string str) const

Returns the key code for the specified generic string key name.

void clan::InputDevice::throw_if_null ( ) const

Throw an exception if this object is invalid.


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