clan::InputDevice Class Reference - ClanLib SDK
Description: clan::InputDevice Class Reference

Public Types | Public Member Functions | List of all members
clan::InputDevice Class Reference
clanDisplay Input

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.
| InputDevice (InputDeviceProvider *provider)
| Constructs a InputDevice.
| InputDevice (std::weak_ptr< InputDevice_Impl > impl)
| Constructs a InputDevice.
| ~InputDevice ()
float | get_axis (int axisid) const
| Returns the the current position of a joystick axis. (Joysticks only)
std::vector< int > | get_axis_ids () const
| Returns the number of axes available on this device. (Joysticks only)
int | get_button_count () const
| Returns the number of buttons available on this device. \warn If used on a keyboard or mouse, this function returns -1.
std::string | get_device_name () const
| Return the hardware id/device for this device (i.e. /dev/input/js0)
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.
int | get_hat (int index) const
| Returns the current position of a joystick hat. (Joysticks only)
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, ...).
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.
std::string | get_name () const
| Returns the human readable name of the device (i.e. 'Microsoft Sidewinder 3D').
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.
InputDeviceProvider * | get_provider () const
| Returns the provider for this input device.
Type | get_type () const
| Returns the input device type.
bool | is_null () const
| Returns true if this object is invalid.
std::string | keyid_to_string (int keycode) const
| Returns a generic string name for the specified key code.
| operator bool () const
InputDevice & | operator= (const InputDevice &copy)
void | set_device_position (int x, int y)
| Sets the actual position of the device. (Pointing devices only)
void | set_position (float x, float y)
| Sets the display-independent position of the device. (Pointing devices only)
Signal< void(const InputEvent &)> & | sig_axis_move ()
| Signal emitted when axis is moved.
Signal< void(const InputEvent &)> & | sig_key_dblclk ()
| Signal emitted when the mouse is double-clicked.
Signal< void(const InputEvent &)> & | sig_key_down ()
| Signal emitted when key is pressed.
Signal< void(const InputEvent &)> & | sig_key_up ()
| Signal emitted when key is released.
Signal< void(const InputEvent &)> & | sig_pointer_move ()
| Signal emitted when pointer is moved (absolute movement).
Signal< void(const InputEvent &)> & | sig_proximity_change ()
| Signal emitted when proximity is entered or exited.
int | string_to_keyid (const std::string &str) const
| Returns the key code for the specified generic string key name.
void | throw_if_null () const
| Throw an exception if this object is invalid.

## Detailed Description

InputDevice.

## Member Enumeration Documentation

## ◆ Type

enum clan::InputDevice::Type

Input device types.

Enumerator
keyboard |
pointer |
joystick |
unknown |

## Constructor & Destructor Documentation

## ◆ InputDevice() [1/3]

clan::InputDevice::InputDevice | ( |  | ) |

Constructs a null instance.

## ◆ InputDevice() [2/3]

clan::InputDevice::InputDevice | ( | InputDeviceProvider * | provider | ) |

Constructs a InputDevice.

Parameters

  provider | = Input Device Provider

## ◆ InputDevice() [3/3]

clan::InputDevice::InputDevice | ( | std::weak_ptr< InputDevice_Impl > | impl | ) |

Constructs a InputDevice.

Parameters

  impl | = Weak Ptr

## ◆ ~InputDevice()

clan::InputDevice::~InputDevice | ( |  | ) |

## Member Function Documentation

## ◆ get_axis()

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

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

## ◆ get_axis_ids()

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

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

## ◆ get_button_count()

int clan::InputDevice::get_button_count | ( |  | ) | const

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

## ◆ get_device_name()

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

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

## ◆ get_device_position()

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.

## ◆ get_hat()

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.

## ◆ get_key_name()

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

## ◆ get_keycode()

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.

## ◆ get_name()

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

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

## ◆ get_position()

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.

## ◆ get_provider()

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

Returns the provider for this input device.

## ◆ get_type()

Type clan::InputDevice::get_type | ( |  | ) | const

Returns the input device type.

## ◆ is_null()

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

Returns true if this object is invalid.

## ◆ keyid_to_string()

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

Returns a generic string name for the specified key code.

## ◆ operator bool()

clan::InputDevice::operator bool | ( |  | ) | const
| inlineexplicit

## ◆ operator=()

InputDevice & clan::InputDevice::operator= | ( | const InputDevice & | copy | ) |

## ◆ set_device_position()

void clan::InputDevice::set_device_position | ( | int | x,
|  | int | y )

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

## ◆ set_position()

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

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

## ◆ sig_axis_move()

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

Signal emitted when axis is moved.

## ◆ sig_key_dblclk()

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

Signal emitted when the mouse is double-clicked.

## ◆ sig_key_down()

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

Signal emitted when key is pressed.

## ◆ sig_key_up()

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

Signal emitted when key is released.

## ◆ sig_pointer_move()

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

Signal emitted when pointer is moved (absolute movement).

## ◆ sig_proximity_change()

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

Signal emitted when proximity is entered or exited.

## ◆ string_to_keyid()

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

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

## ◆ throw_if_null()

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:

- input_device.h