Skip to content

Commit

Permalink
[BUILD] Add Generic HID debug to Kconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Feb 21, 2021
1 parent a295aa8 commit 9f00402
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ menu "BlueRetro"
help
Select this to enable Bluetooth H4 tracing.

config BLUERETRO_GENERIC_HID_DEBUG
bool "Enable Generic HID report debug"
help
Select this to enable Generic HID report debug.

config BLUERETRO_WIRED_TRACE
bool "Enable wired trace"
help
Expand Down
13 changes: 6 additions & 7 deletions main/adapter/hid_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,8 @@ static void hid_pad_to_generic(struct bt_data *bt_data, struct generic_ctrl *ctr
}
}

//#define HID_DEBUG
void hid_to_generic(struct bt_data *bt_data, struct generic_ctrl *ctrl_data) {
#ifdef HID_DEBUG
#ifdef CONFIG_BLUERETRO_GENERIC_HID_DEBUG
struct hid_report *report = &bt_data->reports[bt_data->report_type];
for (uint32_t i = 0; i < report->usage_cnt; i++) {
int32_t len = report->usages[i].bit_size;
Expand All @@ -479,19 +478,19 @@ void hid_to_generic(struct bt_data *bt_data, struct generic_ctrl *ctrl_data) {
uint32_t bit_shift = offset % 8;
uint32_t value = ((*(uint32_t *)(bt_data->input + byte_offset)) >> bit_shift) & mask;
if (report->usages[i].bit_size <= 4) {
printf("%02X%02X: %s%X%s, ", report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
printf("R%d %02X%02X: %s%X%s, ", bt_data->report_type, report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
}
else if (report->usages[i].bit_size <= 8) {
printf("%02X%02X: %s%02X%s, ", report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
printf("R%d %02X%02X: %s%02X%s, ", bt_data->report_type, report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
}
else if (report->usages[i].bit_size <= 12) {
printf("%02X%02X: %s%03X%s, ", report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
printf("R%d %02X%02X: %s%03X%s, ", bt_data->report_type, report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
}
else if (report->usages[i].bit_size <= 16) {
printf("%02X%02X: %s%04X%s, ", report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
printf("R%d %02X%02X: %s%04X%s, ", bt_data->report_type, report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
}
else if (report->usages[i].bit_size <= 32) {
printf("%02X%02X: %s%08X%s, ", report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
printf("R%d %02X%02X: %s%08X%s, ", bt_data->report_type, report->usages[i].usage_page, report->usages[i].usage, BOLD, value, RESET);
}
}
printf("\n");
Expand Down
1 change: 1 addition & 0 deletions sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ CONFIG_BLUERETRO_SYSTEM_UNIVERSAL=y
#
# CONFIG_BLUERETRO_BT_DISABLE is not set
# CONFIG_BLUERETRO_BT_H4_TRACE is not set
# CONFIG_BLUERETRO_GENERIC_HID_DEBUG is not set
# CONFIG_BLUERETRO_WIRED_TRACE is not set
# CONFIG_BLUERETRO_BT_TIMING_TESTS is not set
# end of Debug
Expand Down

0 comments on commit 9f00402

Please sign in to comment.