summaryrefslogtreecommitdiff
path: root/src/class/hid/hid_device.c
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-02-08 19:08:16 +0700
committerhathach <[email protected]>2021-02-08 19:08:16 +0700
commit72bcc0685c142c512f1d04ff18eaa13b99f62e93 (patch)
treeb36872f041eaf75cda5dc4723745f01938fc729b /src/class/hid/hid_device.c
parentb2019e4d719a8b4560714081e5764525308b2924 (diff)
add tud_hid_n_gamepad_report() helper for gamepad report
- Add gamepad to hid_composite example. Though it needs a bit of extra work but it will come later as separated PR.
Diffstat (limited to 'src/class/hid/hid_device.c')
-rw-r--r--src/class/hid/hid_device.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c
index 1f03f8862..5b9735071 100644
--- a/src/class/hid/hid_device.c
+++ b/src/class/hid/hid_device.c
@@ -107,9 +107,6 @@ bool tud_hid_n_boot_mode(uint8_t itf)
return _hidd_itf[itf].boot_mode;
}
-//--------------------------------------------------------------------+
-// KEYBOARD API
-//--------------------------------------------------------------------+
bool tud_hid_n_keyboard_report(uint8_t itf, uint8_t report_id, uint8_t modifier, uint8_t keycode[6])
{
hid_keyboard_report_t report;
@@ -127,10 +124,8 @@ bool tud_hid_n_keyboard_report(uint8_t itf, uint8_t report_id, uint8_t modifier,
return tud_hid_n_report(itf, report_id, &report, sizeof(report));
}
-//--------------------------------------------------------------------+
-// MOUSE APPLICATION API
-//--------------------------------------------------------------------+
-bool tud_hid_n_mouse_report(uint8_t itf, uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal)
+bool tud_hid_n_mouse_report(uint8_t itf, uint8_t report_id,
+ uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal)
{
hid_mouse_report_t report =
{
@@ -144,6 +139,24 @@ bool tud_hid_n_mouse_report(uint8_t itf, uint8_t report_id, uint8_t buttons, int
return tud_hid_n_report(itf, report_id, &report, sizeof(report));
}
+bool tud_hid_n_gamepad_report(uint8_t itf, uint8_t report_id,
+ int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint16_t buttons)
+{
+ hid_gamepad_report_t report =
+ {
+ .x = x,
+ .y = y,
+ .z = z,
+ .rz = rz,
+ .rx = rx,
+ .ry = ry,
+ .hat = hat,
+ .buttons = buttons,
+ };
+
+ return tud_hid_n_report(itf, report_id, &report, sizeof(report));
+}
+
//--------------------------------------------------------------------+
// USBD-CLASS API
//--------------------------------------------------------------------+