Ajout de la manette BNA NSW (Animal Crossing)
This commit is contained in:
parent
e5b55e420d
commit
6734142f03
96
hid_app.c
96
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
|
||||
//--------------------------------------------------------------------+
|
||||
@ -426,41 +485,8 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c
|
||||
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]);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user