SurgSim::Devices::InputDeviceHandle Class Reference

Access to an input/HID device using the Input API in Linux. More...

`#include <SurgSim/Devices/MultiAxis/linux/InputDeviceHandle.h>`

Inheritance diagram for SurgSim::Devices::InputDeviceHandle:

## Classes

struct | State

## Public Member Functions

| ~InputDeviceHandle ()
| Destructor. More...
std::string | getDeviceName () const override
| Gets the name returned by the operating system for this device. More...
bool | getDeviceIds (int *vendorId, int *productId) const override
| Gets the device identifiers. More...
bool | hasTranslationAndRotationAxes () const override
| Queries if this device has 3 translation and 3 rotation axes. More...
bool | updateStates (AxisStates *axisStates, ButtonStates *buttonStates, bool *updated) override
| Updates the axis and states from the device input, if any. More...
Public Member Functions inherited from SurgSim::Devices::SystemInputDeviceHandle
virtual | ~SystemInputDeviceHandle ()
| Destructor. More...
virtual void | prepareForShutdown ()
| Prepares the handle for sampling thread shutdown. More...

## Static Public Member Functions

static std::vector< std::string > | enumeratePaths (SurgSim::Framework::Logger *logger)
| Enumerates input devices. More...
static std::unique_ptr< InputDeviceHandle > | open (const std::string &path, std::shared_ptr< SurgSim::Framework::Logger > logger)
| Opens the given path and creates an access wrapper for the device. More...

## Private Member Functions

| InputDeviceHandle (std::shared_ptr< SurgSim::Framework::Logger > &&logger)
| Constructor. More...
| InputDeviceHandle (const InputDeviceHandle &other)=delete
InputDeviceHandle & | operator= (const InputDeviceHandle &other)=delete
std::vector< int > | getDeviceButtonsAndKeys ()
| Gets the indices of the available device buttons. More...
bool | hasAbsoluteTranslationAndRotationAxes () const
| Query if this device has 3 translation and 3 rotation {absolute} axes. More...
bool | hasRelativeTranslationAndRotationAxes () const
| Query if this device has 3 translation and 3 rotation {relative} axes. More...

## Private Attributes

std::unique_ptr< State > | m_state

## Additional Inherited Members

Public Types inherited from SurgSim::Devices::SystemInputDeviceHandle
typedef std::array< int, MAX_NUM_AXES > | AxisStates
| Type used to store axis states. More...
typedef std::array< bool, MAX_NUM_BUTTONS > | ButtonStates
| Type used to store button states. More...
Static Public Attributes inherited from SurgSim::Devices::SystemInputDeviceHandle
static const size_t | MAX_NUM_AXES = 6
| The maximum number of axes supported by any device object. More...
static const size_t | MAX_NUM_BUTTONS = 4
| The maximum number of buttons supported by any device object. More...
Protected Member Functions inherited from SurgSim::Devices::SystemInputDeviceHandle
| SystemInputDeviceHandle ()
| Default constructor. More...

## Detailed Description

Access to an input/HID device using the Input API in Linux.

See also
  SystemInputDeviceHandle

## Constructor & Destructor Documentation

## ~InputDeviceHandle()

SurgSim::Devices::InputDeviceHandle::~InputDeviceHandle | ( |  | ) |

Destructor.

## InputDeviceHandle() [1/2]

SurgSim::Devices::InputDeviceHandle::InputDeviceHandle | ( | std::shared_ptr< SurgSim::Framework::Logger > && | logger | ) |

explicit private

Constructor.

Cannot be called directly.

See also
  open

## InputDeviceHandle() [2/2]

SurgSim::Devices::InputDeviceHandle::InputDeviceHandle | ( | const InputDeviceHandle & | other | ) |

private delete

## Member Function Documentation

## enumeratePaths()

std::vector< std::string > SurgSim::Devices::InputDeviceHandle::enumeratePaths | ( | SurgSim::Framework::Logger * | logger | ) |

static

Enumerates input devices.

Parameters

  logger | The logger to be used during enumeration.

Returns
  A list of device paths.

## getDeviceButtonsAndKeys()

std::vector< int > SurgSim::Devices::InputDeviceHandle::getDeviceButtonsAndKeys | ( |  | ) |

private

Gets the indices of the available device buttons.

Returns
  a vector of indices.

## getDeviceIds()

bool SurgSim::Devices::InputDeviceHandle::getDeviceIds | ( | int * | vendorId,
|  | int * | productId
| ) |  | const

override virtual

Gets the device identifiers.

Parameters

  [out] | vendorId | The USB or PCI vendor identifier.
  [out] | productId | The USB or PCI product identifier.

Returns
  true if it succeeds.

Implements SurgSim::Devices::SystemInputDeviceHandle.

## getDeviceName()

std::string SurgSim::Devices::InputDeviceHandle::getDeviceName | ( |  | ) | const

override virtual

Gets the name returned by the operating system for this device.

Returns
  The reported name, or "???" if no name information could be found.

Implements SurgSim::Devices::SystemInputDeviceHandle.

## hasAbsoluteTranslationAndRotationAxes()

bool SurgSim::Devices::InputDeviceHandle::hasAbsoluteTranslationAndRotationAxes | ( |  | ) | const

private

Query if this device has 3 translation and 3 rotation {absolute} axes.

Returns
  true if the desired axes are present.

## hasRelativeTranslationAndRotationAxes()

bool SurgSim::Devices::InputDeviceHandle::hasRelativeTranslationAndRotationAxes | ( |  | ) | const

private

Query if this device has 3 translation and 3 rotation {relative} axes.

Returns
  true if the desired axes are present.

## hasTranslationAndRotationAxes()

bool SurgSim::Devices::InputDeviceHandle::hasTranslationAndRotationAxes | ( |  | ) | const

override virtual

Queries if this device has 3 translation and 3 rotation axes.

Returns
  true if the desired axes are present.

Implements SurgSim::Devices::SystemInputDeviceHandle.

## open()

std::unique_ptr< InputDeviceHandle > SurgSim::Devices::InputDeviceHandle::open | ( | const std::string & | path,
|  | std::shared_ptr< SurgSim::Framework::Logger > | logger
| ) |  |

static

Opens the given path and creates an access wrapper for the device.

Parameters

  path | Full pathname for the device.
  logger | The logger to be used by the device.

Returns
  The created device object, or an empty unique_ptr on failure.

## operator=()

InputDeviceHandle& SurgSim::Devices::InputDeviceHandle::operator= | ( | const InputDeviceHandle & | other | ) |

private delete

## updateStates()

bool SurgSim::Devices::InputDeviceHandle::updateStates | ( | AxisStates * | axisStates,
|  | ButtonStates * | buttonStates,
|  | bool * | updated
| ) |  |

override virtual

Updates the axis and states from the device input, if any.

Parameters

  [in,out] | axisStates | The states for each axis of the device.
  [in,out] | buttonStates | The states for each device button.
  [out] | updated | True if any states were actually updated. (Note that even if this value is true, the states may not have changed value; one or more states could have been updated to the same value.)

Returns
  true if the operation was successful; false if the device is no longer in a usable state.

Implements SurgSim::Devices::SystemInputDeviceHandle.

## Member Data Documentation

## m_state

std::unique_ptr<State> SurgSim::Devices::InputDeviceHandle::m_state

private

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

- SurgSim/Devices/MultiAxis/linux/InputDeviceHandle.h
- SurgSim/Devices/MultiAxis/linux/InputDeviceHandle.cpp