From 098f982673cd18ce7f4a367a9796ae4259df02a0 Mon Sep 17 00:00:00 2001 From: Jacques Gagnon Date: Sun, 15 Dec 2024 21:54:43 -0500 Subject: [PATCH] [BT] Add support for Atari VCS rumble --- main/adapter/hid_parser.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/main/adapter/hid_parser.c b/main/adapter/hid_parser.c index 0ba99e58..1be87498 100644 --- a/main/adapter/hid_parser.c +++ b/main/adapter/hid_parser.c @@ -189,7 +189,33 @@ static int32_t hid_report_fingerprint(struct hid_report *report) { return type; } +static void hid_patch_report(struct bt_data *bt_data, struct hid_report *report) { + switch (bt_data->base.vid) { + case 0x3250: /* Atari VCS */ + switch (bt_data->base.pid) { + case 0x1001: /* Classic Controller */ + case 0x1002: /* Modern Controller */ + /* Rumble report */ + if (report->id == 1 && report->tag == 1) { + uint8_t usages[] = { + 0x70, 0x50, 0xA7, 0x7C, /* LF (left) */ + 0x70, 0x50, 0xA7, 0x7C, /* HF (right) */ + }; + for (uint32_t i = 0; i < report->usage_cnt; i++) { + report->usages[i].usage_page = USAGE_GEN_PHYS_INPUT; + report->usages[i].usage = usages[i]; + report->usages[i].logical_min = 0; + report->usages[i].logical_max = 0xFF; + } + } + break; + } + break; + } +} + static void hid_process_report(struct bt_data *bt_data, struct hid_report *report) { + hid_patch_report(bt_data, report); report->type = hid_report_fingerprint(report); #ifdef CONFIG_BLUERETRO_JSON_DBG printf("{\"log_type\": \"parsed_hid_report\", \"report_id\": %ld, \"report_tag\": %ld, \"usages\": [", report->id, report->tag);