Class BLEHIDGamepad
BLEHIDGamepad Class
Description
A class used for creating and managing a BLE HID Gamepad.
Syntax
class BLEHIDGamepad
Members
Public Constructors |
|
---|---|
BLEHIDGamepad::BLEHIDG amepad |
Constructs a BLEHIDGamepad object |
Public Methods |
|
BLEHIDGamepad::setReportID |
Set HID report ID for the HID Gamepad |
BLEHIDGamepad::gamepad Report |
Send a HID Gamepad report |
BLEHIDGamepad::buttonPress |
Send a HID Gamepad report indicating buttons pressed |
BLEHIDGamepad:: buttonRelease |
Send a HID Gamepad report indicating buttons released |
BLEHIDGamepad:: buttonReleaseAll |
Send a HID Gamepad report indicating no buttons pressed |
BLEHIDGamepad::setHat |
Send a HID Gamepad report indicating hat switch position |
BLEHIDGamepad::setAxes |
Send a HID Gamepad report indicating position of all axes |
BLEHIDGamepad::setLeftStick |
Send a HID Gamepad report indicating position of axes corresponding to left analog stick |
BLEHIDGamepad:: setRightStick |
Send a HID Gamepad report indicating position of axes corresponding to right analog stick |
BLEHIDGamepad::setTriggers |
Send a HID Gamepad report indicating position of axes corresponding to triggers |
BLEHIDGamepad::BLEHIDGamepad
Description
Constructs a BLEHIDGamepad object.
Syntax
BLEHIDGamepad(void);
Parameters
NA
Returns
NA
Example Code
Example: BLEHIDGamepad
Note
By default, the BLEHIDGamepad class assumes the HID report descriptor implements a gamepad device with 16 buttons, 6 16-bit axes and an 8-direction hat switch. This class will not work if a different gamepad report descriptor is implemented. “BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setReportID
Description
Set HID report ID for the HID Gamepad.
Syntax
void setReportID (uint8_t reportID);
Parameters
reportID: The report ID for the gamepad device, corresponding to the HID report descriptor.
Returns
NA
Example Code
Example: BLEHIDGamepad
Note
HID report ID should start at 1. Some systems may consider a report ID of 0 as invalid. “BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::gamepadReport
Description
Send a HID Gamepad report.
Syntax
void gamepadReport (hid_gamepad_report_t* report);
void gamepadReport (uint16_t buttons, uint8_t hat, int16_t x, int16_t y, int16_t z, int16_t Rz, int16_t Rx, int16_t Ry);
Parameters
report: pointer to gamepad report structure containing data on all inputs.
buttons: bitmap indicating state of each button.
1 (pressed)
0 (released)
hat: position of hat switch.
GAMEPAD_HAT_CENTERED (0)
GAMEPAD_HAT_UP (1)
GAMEPAD_HAT_UP_RIGHT (2)
GAMEPAD_HAT_RIGHT (3)
GAMEPAD_HAT_DOWN_RIGHT (4)
GAMEPAD_HAT_DOWN (5)
GAMEPAD_HAT_DOWN_LEFT (6)
GAMEPAD_HAT_LEFT (7)
GAMEPAD_HAT_UP_LEFT (8)
x: position of x axis in integer.
-32767 to 32767.
y: position of y axis in integer.
-32767 to 32767.
z: position of z axis in integer.
-32767 to 32767.
Rz: position of Rz axis in integer.
-32767 to 32767.
Rx: position of Rx axis in integer.
-32767 to 32767.
Ry: position of Ry axis in integer.
-32767 to 32767.
Returns
NA
Example Code
Example: BLEHIDGamepad
Note
“BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setHat
Description
Send a HID Gamepad report indicating hat switch position.
Syntax
void setHat (uint8_t hat);
Parameters
hat: position of hat switch.
GAMEPAD_HAT_CENTERED (0)
GAMEPAD_HAT_UP (1)
GAMEPAD_HAT_UP_RIGHT (2)
GAMEPAD_HAT_RIGHT (3)
GAMEPAD_HAT_DOWN_RIGHT (4)
GAMEPAD_HAT_DOWN (5)
GAMEPAD_HAT_DOWN_LEFT (6)
GAMEPAD_HAT_LEFT (7)
GAMEPAD_HAT_UP_LEFT (8)
Returns
NA
Example Code
NA
Note
“BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setAxes
Description
Send a HID Gamepad report indicating position of all axes.
Syntax
void setAxes (int16_t x, int16_t y, int16_t z, int16_t Rz, int16_t Rx, int16_t Ry);
Parameters
x: position of x axis in integer.
-32767 to 32767.
y: position of y axis in integer.
-32767 to 32767.
z: position of z axis in integer.
-32767 to 32767.
Rz: position of Rz axis in integer.
-32767 to 32767.
Rx: position of Rx axis in integer.
-32767 to 32767.
Ry: position of Ry axis in integer.
-32767 to 32767.
Returns
NA
Example Code
Example: BLEHIDGamepad
Note
“BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setLeftStick
Description
Send a HID Gamepad report indicating position of axes corresponding to left analog stick.
Syntax
void setLeftStick (int16_t x, int16_t y);
Parameters
x: position of x axis in integer.
-32767 to 32767.
y: position of y axis in integer.
-32767 to 32767.
Returns
NA
Example Code
NA
Note
“BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setRightStick
Description
Send a HID Gamepad report indicating position of axes corresponding to right analog stick.
Syntax
void setLeftStick (int16_t z, int16_t Rz);
Parameters
z: position of z axis in integer.
-32767 to 32767.
Rz: position of Rz axis in integer.
-32767 to 32767.
Returns
NA
Example Code
NA
Note
“BLEHIDGamepad.h” must be included to use the class function.
BLEHIDGamepad::setTriggers
Description
Send a HID Gamepad report indicating position of axes corresponding to triggers.
Syntax
void setTriggers (int16_t Rx, int16_t Ry);
Parameters
Rx: position of Rx axis in integer.
-32767 to 32767.
Ry: position of Ry axis in integer.
-32767 to 32767.
Returns
NA
Example Code
NA
Note
“BLEHIDGamepad.h” must be included to use the class function.