Gestion de la manette en mode 8bitPro
This commit is contained in:
parent
15d9064e69
commit
30b6c220f9
@ -4,11 +4,6 @@
|
||||
|
||||
#define INPUT_ELEMENT_NAME_LENGTH 30
|
||||
|
||||
struct input_element_t{
|
||||
uint16_t first_bit_position;
|
||||
uint16_t mask;
|
||||
char name[INPUT_ELEMENT_NAME_LENGTH];
|
||||
};
|
||||
|
||||
struct input_element_t create_input_element( uint16_t first_bit_position, uint16_t mask, char name[]){
|
||||
struct input_element_t input_element;
|
||||
|
||||
98
hid_app.c
98
hid_app.c
@ -44,6 +44,7 @@ static struct
|
||||
{
|
||||
uint8_t report_count;
|
||||
tuh_hid_report_info_t report_info[MAX_REPORT];
|
||||
uint16_t vid, pid;
|
||||
}hid_info[CFG_TUH_HID];
|
||||
|
||||
static void process_kbd_report(hid_keyboard_report_t const *report);
|
||||
@ -52,6 +53,36 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c
|
||||
|
||||
// HID report from 8bitPro
|
||||
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t report_id;
|
||||
uint b1:1; // Bouton A
|
||||
uint b2:1; // Bouton B
|
||||
uint b3:1; // 4 : ???
|
||||
uint b4:1; // Bouton X
|
||||
uint b5:1; // Bouton Y
|
||||
uint b6:1; // 32 : ???
|
||||
uint b7:1; // Bouton L
|
||||
uint b8:1; // Bouton R
|
||||
uint b9:1; // Bouton L2
|
||||
uint b10:1; // Bouton R2
|
||||
uint b11:1; // Start
|
||||
uint b12:1; // Select
|
||||
uint b13:1;
|
||||
uint b14:1; // Click joystick gauche
|
||||
uint b15:1; // Click joystick droit
|
||||
uint b16:1; // 16 bits
|
||||
uint8_t hat_switch; // OK
|
||||
uint8_t x, y; // joystick Xg, Yg
|
||||
uint8_t z, rz; // joystick Xd, Yd
|
||||
|
||||
uint8_t gachette_droite; // ok
|
||||
uint8_t gachette_gauche; // ok
|
||||
|
||||
|
||||
} _8bitpro_report_t ;
|
||||
|
||||
|
||||
typedef struct TU_ATTR_PACKED
|
||||
{
|
||||
uint8_t report_id;
|
||||
@ -79,7 +110,10 @@ typedef struct TU_ATTR_PACKED
|
||||
uint gachette_droite:8;
|
||||
|
||||
|
||||
} _8bitpro_report_t ;
|
||||
} _SonyDualShock_report_t ;
|
||||
|
||||
|
||||
|
||||
|
||||
void hid_app_task(void)
|
||||
{
|
||||
@ -113,6 +147,8 @@ void tuh_hid_mount_cb(uint8_t dev_addr, uint8_t instance, uint8_t const* desc_re
|
||||
uint16_t vid, pid;
|
||||
tuh_vid_pid_get(dev_addr, &vid, &pid);
|
||||
printf("VID = %04x, PID = %04x\r\n", vid, pid);
|
||||
hid_info[instance].vid = vid;
|
||||
hid_info[instance].pid = pid;
|
||||
|
||||
|
||||
hid_info[instance].report_count = tuh_hid_parse_report_descriptor(hid_info[instance].report_info, MAX_REPORT, desc_report, desc_len);
|
||||
@ -163,9 +199,9 @@ void tuh_hid_report_received_cb(uint8_t dev_addr, uint8_t instance, uint8_t cons
|
||||
|
||||
default:
|
||||
// Generic report requires matching ReportID and contents with previous parsed report info
|
||||
// printf("Generic report recieved\n");
|
||||
|
||||
// process_generic_report(dev_addr, instance, report, len);
|
||||
if(hid_info[instance].vid == 0x2dc8 && hid_info[instance].pid == 0x6002){
|
||||
process_generic_report(dev_addr, instance, report, len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -291,33 +327,39 @@ static void process_generic_report(uint8_t dev_addr, uint8_t instance, uint8_t c
|
||||
tuh_hid_report_info_t* rpt_info_arr = hid_info[instance].report_info;
|
||||
tuh_hid_report_info_t* rpt_info = NULL;
|
||||
|
||||
printf("VID, PID:%x:%x\n", hid_info[instance].vid, hid_info[instance].pid);
|
||||
// Supposons que ce soit notre manette !
|
||||
_8bitpro_report_t _8bitpro_report;
|
||||
memcpy(&_8bitpro_report, report, sizeof(_8bitpro_report));
|
||||
printf(">j1:%d\n", _8bitpro_report.x);
|
||||
printf(">j2:%d\n", _8bitpro_report.y);
|
||||
printf(">j3:%d\n", _8bitpro_report.z);
|
||||
printf(">j4:%d\n", _8bitpro_report.rz);
|
||||
printf(">hat:%d\n", _8bitpro_report.hat_switch);
|
||||
//_SonyDualShock_report_t _gamepad_report;
|
||||
_8bitpro_report_t _gamepad_report;
|
||||
memcpy(&_gamepad_report, report, sizeof(_gamepad_report));
|
||||
|
||||
printf(">b1:%d\n", _8bitpro_report.b1);
|
||||
printf(">b2:%d\n", _8bitpro_report.b2);
|
||||
printf(">b3:%d\n", _8bitpro_report.b3);
|
||||
printf(">b4:%d\n", _8bitpro_report.b4);
|
||||
printf(">b5:%d\n", _8bitpro_report.b5);
|
||||
printf(">b6:%d\n", _8bitpro_report.b6);
|
||||
printf(">b7:%d\n", _8bitpro_report.b7);
|
||||
printf(">b8:%d\n", _8bitpro_report.b8);
|
||||
printf(">b9:%d\n", _8bitpro_report.b9);
|
||||
printf(">b10:%d\n", _8bitpro_report.b10);
|
||||
printf(">b11:%d\n", _8bitpro_report.b11);
|
||||
printf(">b12:%d\n", _8bitpro_report.b12);
|
||||
printf(">b13:%d\n", _8bitpro_report.b13);
|
||||
printf(">b14:%d\n", _8bitpro_report.b14);
|
||||
printf(">data1:%d\n", _8bitpro_report.data_1);
|
||||
|
||||
printf(">g1:%d\n", _8bitpro_report.gachette_droite);
|
||||
printf(">g2:%d\n", _8bitpro_report.gachette_gauche);
|
||||
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");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user