Arduino Universal Inputs
A collection of libraries for managing/processing input devices on Arduino.
All Classes Files Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | List of all members
UniversalInputManager Class Reference

Handles the storage, polling and event handling for multiple input devices. More...

#include <UniversalInputManager.h>

Public Member Functions

 UniversalInputManager ()
 Create a new input manager.
 
size_t deviceCount ()
 Returns the number of devices that have been added. More...
 
size_t poll ()
 Polls all input devices for change. More...
 
bool setCallback (IUniversalInputCallback *callback)
 Sets the callback class for this manager. More...
 
bool setCallback (UniversalInputCallbackFunctionHandler::UniversalInputCallbackFunction callback)
 Sets the callback function for this manager. More...
 
bool addDevice (IInputDevice *device)
 Adds a new input device to the manager. More...
 
IInputDevicegetDevice (inputid_t id)
 Gets an input device given its ID. More...
 
bool deviceExists (inputid_t id)
 Determines if a given device ID exists in the manager. More...
 
bool setButtonDefaults (bool activeLow, bool pullUp, inputtime_t debounce)
 Sets the default button configuraton for buttons created with UniversalInputManager::addNewButton. More...
 
bool addNewButton (inputpin_t pin)
 Adds a new button with default configuration. More...
 
bool addNewButton (inputid_t id, inputpin_t pin)
 Adds a new button with default configuration. More...
 
bool addNewJoystick (inputpin_t pin)
 Adds a new joystick. More...
 
bool addNewJoystick (inputid_t id, inputpin_t pin)
 Adds a new joystick. More...
 

Detailed Description

Handles the storage, polling and event handling for multiple input devices.

Member Function Documentation

bool UniversalInputManager::addDevice ( IInputDevice device)

Adds a new input device to the manager.

Parameters
devicePointer to input device
Returns
True if device was added

Note that the device ID must be unique, if a device with the same ID already exists this call will return false.

bool UniversalInputManager::addNewButton ( inputpin_t  pin)

Adds a new button with default configuration.

Parameters
pinPin button is attached to
Returns
True if button was added
See Also
UniversalInputManager::setButtonDefaults
UniversalInputManager::addNewButton(inputid_t, inputpin_t)

Note that pin number becomes device ID.

bool UniversalInputManager::addNewButton ( inputid_t  id,
inputpin_t  pin 
)

Adds a new button with default configuration.

Parameters
idID of new button
pinPin button is attached to
Returns
True if button was added
See Also
UniversalInputManager::setButtonDefaults
UniversalInputManager::addNewButton(inputpin_t)
bool UniversalInputManager::addNewJoystick ( inputpin_t  pin)

Adds a new joystick.

Parameters
pinPin joystick is attached to
Returns
True if joystick was added
See Also
UniversalInputManager::addNewJoystick(inputid_t, inputpin_t)

Note that pin number becomes device ID.

bool UniversalInputManager::addNewJoystick ( inputid_t  id,
inputpin_t  pin 
)

Adds a new joystick.

Parameters
idID of new joystick
pinPin joystick is attached to
Returns
True if joystick was added
See Also
UniversalInputManager::addNewJoystick(inputpin_t)
size_t UniversalInputManager::deviceCount ( )
inline

Returns the number of devices that have been added.

Returns
Number of devices
bool UniversalInputManager::deviceExists ( inputid_t  id)

Determines if a given device ID exists in the manager.

Parameters
idID of device
Returns
True if device exists in this manager
IInputDevice * UniversalInputManager::getDevice ( inputid_t  id)

Gets an input device given its ID.

Parameters
idDevice ID
Returns
Pointer to input device, NULL if not found
size_t UniversalInputManager::poll ( )

Polls all input devices for change.

Returns
Number of devices with changed state
bool UniversalInputManager::setButtonDefaults ( bool  activeLow,
bool  pullUp,
inputtime_t  debounce 
)

Sets the default button configuraton for buttons created with UniversalInputManager::addNewButton.

Parameters
activeLowTrue if active low by default
pullUpTrue of pull up by default
debounceDefault debounce time
Returns
True if all values are valid and have been set
See Also
UniversalInputManager::addNewButton(inputpin_t)
UniversalInputManager::addNewButton(inputid_t, inputpin_t)
bool UniversalInputManager::setCallback ( IUniversalInputCallback callback)

Sets the callback class for this manager.

Parameters
callbackPointer to the callback handler
Returns
True if the callback was set
bool UniversalInputManager::setCallback ( UniversalInputCallbackFunctionHandler::UniversalInputCallbackFunction  callback)

Sets the callback function for this manager.

Parameters
callbackPointer to the callback function
Returns
True if the callback was set

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