Skip to content

Commit e0e9426

Browse files
committed
print addres of mouse input
1 parent 4586d8f commit e0e9426

File tree

1 file changed

+8
-7
lines changed
  • examples/dual/host_hid_to_device_cdc/src

1 file changed

+8
-7
lines changed

examples/dual/host_hid_to_device_cdc/src/main.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
156156
tuh_vid_pid_get(dev_addr, &vid, &pid);
157157

158158
char tempbuf[256];
159-
int count = sprintf(tempbuf, "[%04x:%04x][%u] HID Interface instance = %d, Protocol = %s\r\n", vid, pid, dev_addr, instance, protocol_str[itf_protocol]);
159+
int count = sprintf(tempbuf, "[%04x:%04x][%u] HID Interface%u, Protocol = %s\r\n", vid, pid, dev_addr, instance, protocol_str[itf_protocol]);
160160

161161
tud_cdc_write(tempbuf, count);
162162
tud_cdc_write_flush();
@@ -176,7 +176,7 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
176176
void tuh_hid_umount_cb(uint8_t dev_addr, uint8_t instance)
177177
{
178178
char tempbuf[256];
179-
int count = sprintf(tempbuf, "[%u] HID Interface instance = %d is unmounted\r\n", dev_addr, instance);
179+
int count = sprintf(tempbuf, "[%u] HID Interface%u is unmounted\r\n", dev_addr, instance);
180180
tud_cdc_write(tempbuf, count);
181181
tud_cdc_write_flush();
182182
}
@@ -194,8 +194,9 @@ static inline bool find_key_in_report(hid_keyboard_report_t const *report, uint8
194194

195195

196196
// convert hid keycode to ascii and print via usb device CDC (ignore non-printable)
197-
static void process_kbd_report(hid_keyboard_report_t const *report)
197+
static void process_kbd_report(uint8_t dev_addr, hid_keyboard_report_t const *report)
198198
{
199+
(void) dev_addr;
199200
static hid_keyboard_report_t prev_report = { 0, 0, {0} }; // previous report to check key released
200201
bool flush = false;
201202

@@ -237,7 +238,7 @@ static void process_kbd_report(hid_keyboard_report_t const *report)
237238
}
238239

239240
// send mouse report to usb device CDC
240-
static void process_mouse_report(hid_mouse_report_t const * report)
241+
static void process_mouse_report(uint8_t dev_addr, hid_mouse_report_t const * report)
241242
{
242243
//------------- button state -------------//
243244
//uint8_t button_changed_mask = report->buttons ^ prev_report.buttons;
@@ -246,7 +247,7 @@ static void process_mouse_report(hid_mouse_report_t const * report)
246247
char r = report->buttons & MOUSE_BUTTON_RIGHT ? 'R' : '-';
247248

248249
char tempbuf[32];
249-
int count = sprintf(tempbuf, "%c%c%c %d %d %d\r\n", l, m, r, report->x, report->y, report->wheel);
250+
int count = sprintf(tempbuf, "[%u] %c%c%c %d %d %d\r\n", dev_addr, l, m, r, report->x, report->y, report->wheel);
250251

251252
tud_cdc_write(tempbuf, count);
252253
tud_cdc_write_flush();
@@ -261,11 +262,11 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
261262
switch(itf_protocol)
262263
{
263264
case HID_ITF_PROTOCOL_KEYBOARD:
264-
process_kbd_report( (hid_keyboard_report_t const*) report );
265+
process_kbd_report(dev_addr, (hid_keyboard_report_t const*) report );
265266
break;
266267

267268
case HID_ITF_PROTOCOL_MOUSE:
268-
process_mouse_report( (hid_mouse_report_t const*) report );
269+
process_mouse_report(dev_addr, (hid_mouse_report_t const*) report );
269270
break;
270271

271272
default: break;

0 commit comments

Comments
 (0)