| 5 | #include "xsm3/xsm3.h" |
| 6 | |
| 7 | void XInputAuth::initialize() { |
| 8 | if ( !available() ) { |
| 9 | return; |
| 10 | } |
| 11 | |
| 12 | listener = nullptr; |
| 13 | if (authType == InputModeAuthType::INPUT_MODE_AUTH_TYPE_USB ) { |
| 14 | listener = new XInputAuthUSBListener(); |
| 15 | xinputAuthData.xinputState = auth_idle_state; |
| 16 | xinputAuthData.authCompleted = false; |
| 17 | ((XInputAuthUSBListener*)listener)->setup(); |
| 18 | ((XInputAuthUSBListener*)listener)->setAuthData(&xinputAuthData); |
| 19 | } else { |
| 20 | // Generate a serial number from the pico's unique ID |
| 21 | uint8_t serial[0x0C]; |
| 22 | pico_unique_board_id_t id; |
| 23 | pico_get_unique_board_id(&id); |
| 24 | for(int i = 0; i < 0x0C; i++) { |
| 25 | serial[i] = 'A' + (id.id[i]%25); // some alphanumeric from 'A' to 'Z' |
| 26 | } |
| 27 | xsm3_set_vid_pid(serial, 0x045E, 0x028E); |
| 28 | xsm3_initialise_state(); |
| 29 | xsm3_set_identification_data(xsm3_id_data_ms_controller); |
| 30 | xinputAuthData.xinputState = auth_idle_state; |
| 31 | xinputAuthData.authCompleted = false; |
| 32 | xinputAuthData.dongle_ready = true; |
| 33 | memcpy(xinputAuthData.dongleSerial, xsm3_id_data_ms_controller, X360_AUTHLEN_DONGLE_SERIAL); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | bool XInputAuth::available() { |
| 38 | // Move options over to their own ps4 data structure or gamepad? |
nothing calls this directly
no test coverage detected