back up of work during May 2019
Dependencies: microbit
MouseService Class Reference
HID-over-Gatt mouse service. More...
#include <MouseService.h>
Inherits HIDServiceBase.
Public Member Functions | |
int | setSpeed (int8_t x, int8_t y, int8_t wheel) |
Set X, Y, Z speed of the mouse. | |
int | setButton (MouseButton button, ButtonState state) |
Toggle the state of one button. | |
virtual void | sendCallback (void) |
Called by the report ticker. | |
virtual ble_error_t | send (const report_t report) |
Send Report. | |
virtual ble_error_t | read (report_t report) |
Read Report. | |
Protected Member Functions | |
virtual void | onDataSent (unsigned count) |
Called by BLE API when data has been successfully sent. | |
virtual void | startReportTicker (void) |
Start the ticker that sends input reports at regular interval. | |
virtual void | stopReportTicker (void) |
Stop the input report ticker. | |
GattAttribute ** | inputReportDescriptors () |
Create the Gatt descriptor for a report characteristic. | |
HID_information_t * | HIDInformation () |
Create the HID information structure. |
Detailed Description
HID-over-Gatt mouse service.
Send mouse moves and button informations over BLE.
BLE ble; MouseService mouse(ble); Timeout timeout; void stop_mouse_move(void) { // Set mouse state to immobile mouse.setButton(MOUSE_BUTTON_LEFT, MOUSE_UP); mouse.setSpeed(0, 0, 0); } void start_mouse_move(void) { // Move left with a left button down. If the focus is on a drawing // software, for instance, this should draw a line. mouse.setButton(MOUSE_BUTTON_LEFT, MOUSE_DOWN); mouse.setSpeed(1, 0, 0); timeout.attach(stop_mouse_move, 0.2); }
Definition at line 100 of file MouseService.h.
Member Function Documentation
HID_information_t * HIDInformation | ( | ) | [protected, inherited] |
Create the HID information structure.
Definition at line 202 of file HIDServiceBase.cpp.
GattAttribute ** inputReportDescriptors | ( | ) | [protected, inherited] |
Create the Gatt descriptor for a report characteristic.
Definition at line 171 of file HIDServiceBase.cpp.
void onDataSent | ( | unsigned | count ) | [protected, virtual, inherited] |
Called by BLE API when data has been successfully sent.
- Parameters:
-
count Number of reports sent
- Note:
- Subclasses can override this to avoid starting the report ticker when there is nothing to send
Definition at line 167 of file HIDServiceBase.cpp.
ble_error_t read | ( | report_t | report ) | [virtual, inherited] |
Read Report.
- Parameters:
-
report Report to fill. Must be of size outputReportLength
- Returns:
- The read status
Definition at line 215 of file HIDServiceBase.cpp.
ble_error_t send | ( | const report_t | report ) | [virtual, inherited] |
Send Report.
- Parameters:
-
report Report to send. Must be of size inputReportLength
- Returns:
- The write status
- Note:
- Don't call send() directly for multiple reports! Use reportTicker for that, in order to avoid overloading the BLE stack, and let it handle events between each report.
Definition at line 209 of file HIDServiceBase.cpp.
virtual void sendCallback | ( | void | ) | [virtual] |
Called by the report ticker.
Definition at line 182 of file MouseService.h.
int setButton | ( | MouseButton | button, |
ButtonState | state | ||
) |
Toggle the state of one button.
- Returns:
- A status code
Definition at line 167 of file MouseService.h.
int setSpeed | ( | int8_t | x, |
int8_t | y, | ||
int8_t | wheel | ||
) |
Set X, Y, Z speed of the mouse.
Parameters are sticky and will be transmitted on every tick. Users should therefore reset them to 0 when the device is immobile.
- Parameters:
-
x Speed on hoizontal axis y Speed on vertical axis wheel Scroll speed
- Returns:
- A status code
- Note:
- Directions depend on the operating system's configuration. It is customary to increase values on the X axis from left to right, and on the Y axis from top to bottom. Wheel is less standard, although positive values will usually scroll up.
Definition at line 151 of file MouseService.h.
void startReportTicker | ( | void | ) | [protected, virtual, inherited] |
Start the ticker that sends input reports at regular interval.
- Note:
- reportTickerIsActive describes the state of the ticker and can be used by HIDS implementations.
Definition at line 155 of file HIDServiceBase.cpp.
void stopReportTicker | ( | void | ) | [protected, virtual, inherited] |
Stop the input report ticker.
Definition at line 162 of file HIDServiceBase.cpp.
Generated on Mon Jul 18 2022 14:25:12 by 1.7.2