From 6734142f0328638db34d1dee9cf271630fd50768 Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 17 Nov 2025 22:28:09 +0100 Subject: [PATCH] Ajout de la manette BNA NSW (Animal Crossing) --- hid_app.c | 96 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 35 deletions(-) diff --git a/hid_app.c b/hid_app.c index 44cf582..2bc2827 100644 --- a/hid_app.c +++ b/hid_app.c @@ -75,6 +75,7 @@ static void process_mouse_report(hid_mouse_report_t const * report); static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len); void process_8bitpro_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len); void process_SonyDualShock4_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len); +void process_BDA_NSW_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len); void affiche_gamepad_data(struct gamepad_data_t _gamepad_report); // HID report from 8bitPro @@ -138,7 +139,29 @@ typedef struct TU_ATTR_PACKED } SonyDualShock4_report_t ; +typedef struct TU_ATTR_PACKED +{ + uint b1:1; // Bouton Y + uint b2:1; // Bouton B + uint b3:1; // Bouton A + uint b4:1; // Bouton X + uint b5:1; // Bouton L + uint b6:1; // Bouton R + uint b7:1; // Bouton L2 + uint b8:1; // Bouton R2 + uint b9:1; // Bouton - + uint b10:1; // Bouton + + uint b11:1; // Bouton joystick droit + uint b12:1; // Bouton joystick gauche + uint b13:1; // Bouton Start + uint b14:1; // Bouton Select + uint b15:1; // -- + uint b16:1; // -- + uint8_t hat_switch; // OK + uint8_t x, y; // joystick Xg, Yg + uint8_t z, rz; // joystick Xd, Yd +} BDA_NSW_report_t ; void hid_app_task(void) @@ -230,8 +253,9 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons process_8bitpro_report(dev_addr, instance, report, len); }else if(hid_info[instance].vid == 0x054c && hid_info[instance].pid == 0x05c4){ process_SonyDualShock4_report(dev_addr, instance, report, len); + }else if(hid_info[instance].vid == 0x20d6 && hid_info[instance].pid == 0xa713){ + process_BDA_NSW_report(dev_addr, instance, report, len); }else{ - printf("Generic report\n"); process_generic_report(dev_addr, instance, report, len); } break; @@ -414,6 +438,41 @@ void process_SonyDualShock4_report(uint8_t dev_addr, uint8_t instance, uint8_t c } +//--------------------------------------------------------------------+ +// Report - 20d6:a713 BDA NSW wired controller +//--------------------------------------------------------------------+ +void process_BDA_NSW_report(uint8_t dev_addr, uint8_t instance, uint8_t const* report, uint16_t len){ + struct gamepad_data_t gamepad_data; + BDA_NSW_report_t gamepad_report; + memcpy(&gamepad_report, report, sizeof(gamepad_report)); + + // Copie des données du rapport vers la structure standard + gamepad_data.joystick_x_gauche = gamepad_report.x; + gamepad_data.joystick_y_gauche = gamepad_report.y; + gamepad_data.joystick_x_droit = gamepad_report.z; + gamepad_data.joystick_y_droit = gamepad_report.rz; + gamepad_data.bouton_Y = gamepad_report.b1; + gamepad_data.bouton_B = gamepad_report.b2; + gamepad_data.bouton_A = gamepad_report.b3; + gamepad_data.bouton_X = gamepad_report.b4; + gamepad_data.bouton_L = gamepad_report.b5; + gamepad_data.bouton_R = gamepad_report.b6; + gamepad_data.bouton_L2 = gamepad_report.b7; + gamepad_data.bouton_R2 = gamepad_report.b8; + + + gamepad_data.bouton_joystick_gauche = gamepad_report.b12; + gamepad_data.bouton_joystick_droit = gamepad_report.b11; + + gamepad_data.bouton_Start = gamepad_report.b13; + gamepad_data.bouton_Select = gamepad_report.b14; + + gamepad_data.dpad = gamepad_report.hat_switch; + + affiche_gamepad_data(gamepad_data); + +} + //--------------------------------------------------------------------+ // Generic Report //--------------------------------------------------------------------+ @@ -424,43 +483,10 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c uint8_t const rpt_count = hid_info[instance].report_count; tuh_hid_report_info_t* rpt_info_arr = hid_info[instance].report_info; tuh_hid_report_info_t* rpt_info = NULL; - - - // Supposons que ce soit notre manette ! - //_SonyDualShock_report_t _gamepad_report; - _8bitpro_report_t _gamepad_report; - memcpy(&_gamepad_report, report, sizeof(_gamepad_report)); - - /*printf(">j1:%d\n", _gamepad_report.x); - printf(">j2:%d\n", _gamepad_report.y); - printf(">j3:%d\n", _gamepad_report.z); - printf(">j4:%d\n", _gamepad_report.rz); - printf(">hat:%d\n", _gamepad_report.hat_switch); - - printf(">b1:%d\n", _gamepad_report.b1); - printf(">b2:%d\n", _gamepad_report.b2); - printf(">b3:%d\n", _gamepad_report.b3); - printf(">b4:%d\n", _gamepad_report.b4); - printf(">b5:%d\n", _gamepad_report.b5); - printf(">b6:%d\n", _gamepad_report.b6); - printf(">b7:%d\n", _gamepad_report.b7); - printf(">b8:%d\n", _gamepad_report.b8); - printf(">b9:%d\n", _gamepad_report.b9); - printf(">b10:%d\n", _gamepad_report.b10); - printf(">b11:%d\n", _gamepad_report.b11); - printf(">b12:%d\n", _gamepad_report.b12); - printf(">b13:%d\n", _gamepad_report.b13); - printf(">b14:%d\n", _gamepad_report.b14); - printf(">b15:%d\n", _gamepad_report.b15); - printf(">b16:%d\n", _gamepad_report.b16); - //printf(">data1:%d\n", _gamepad_report.data_1); - - printf(">g1:%d\n", _gamepad_report.gachette_droite); - printf(">g2:%d\n", _gamepad_report.gachette_gauche);*/ - //printf("HID Report brut\n"); + printf(">a:1\n"); for(int i=0; i< len; i++){ printf("0x%X ", report[i]); }