- Dual-Core Architecture: Dedicated 1000Hz USB gaming pipeline on Core 1 and BLE/Wi-Fi/Web telemetry on Core 0. - Multi-Input BLE Host: Parsers for Xbox Wireless, Google Stadia, 8BitDo (Ultimate/Pro2/SN30), and Generic HOGP gamepads. - Multi-Console USB Emulation: Nintendo Switch, PC DirectInput, PS3, PS4, Xbox 360 (libxsm3 cryptographic challenge-response), Original Xbox, and Couch Mouse/Keyboard. - Onboard Web Portal & Captive Portal: Real-time SVG gamepad visualizer, stick deadzone calibration, button combo remapping, and Wi-Fi manager. - Low-Latency Radio Management: Interactive SoftAP toggle to drop to 0-latency gaming mode. - Dual OTA Firmware Flashing: Browser-based wireless firmware updater and automated Python OTA script. - Strict Build Quality: Clean build under -Wall -Wextra with zero warnings or errors. - Versioning & Licensing: Semantic Versioning v1.0.0 and GNU GPLv3 with Commercial Restrictions.
75 lines
2.3 KiB
C
75 lines
2.3 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "controller_state.h"
|
|
#include "tusb.h"
|
|
#include "device/usbd_pvt.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define XINPUT_VID 0x045E /* Microsoft Corp. */
|
|
#define XINPUT_PID 0x028E /* Xbox 360 Controller */
|
|
|
|
/* Buttons 0 Bitmask */
|
|
#define XINPUT_BTN_DPAD_UP (1U << 0)
|
|
#define XINPUT_BTN_DPAD_DOWN (1U << 1)
|
|
#define XINPUT_BTN_DPAD_LEFT (1U << 2)
|
|
#define XINPUT_BTN_DPAD_RIGHT (1U << 3)
|
|
#define XINPUT_BTN_START (1U << 4)
|
|
#define XINPUT_BTN_BACK (1U << 5)
|
|
#define XINPUT_BTN_L3 (1U << 6)
|
|
#define XINPUT_BTN_R3 (1U << 7)
|
|
|
|
/* Buttons 1 Bitmask */
|
|
#define XINPUT_BTN_LB (1U << 0)
|
|
#define XINPUT_BTN_RB (1U << 1)
|
|
#define XINPUT_BTN_GUIDE (1U << 2)
|
|
#define XINPUT_BTN_A (1U << 4)
|
|
#define XINPUT_BTN_B (1U << 5)
|
|
#define XINPUT_BTN_X (1U << 6)
|
|
#define XINPUT_BTN_Y (1U << 7)
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
uint8_t report_id; /* Always 0x00 */
|
|
uint8_t report_size; /* Always 0x14 (20 bytes) */
|
|
uint8_t buttons0; /* D-pad, Start, Back, L3, R3 */
|
|
uint8_t buttons1; /* LB, RB, Guide, A, B, X, Y */
|
|
uint8_t trigger_l; /* 0..255 */
|
|
uint8_t trigger_r; /* 0..255 */
|
|
int16_t joystick_lx; /* -32768..32767 */
|
|
int16_t joystick_ly; /* -32768..32767 (Up is positive) */
|
|
int16_t joystick_rx; /* -32768..32767 */
|
|
int16_t joystick_ry; /* -32768..32767 (Up is positive) */
|
|
uint8_t reserved[6];
|
|
} xinput_in_report_t;
|
|
|
|
typedef struct __attribute__((packed)) {
|
|
uint8_t report_id; /* 0x00 = Rumble, 0x01 = LED */
|
|
uint8_t report_size; /* 0x08 */
|
|
uint8_t led;
|
|
uint8_t rumble_l; /* Heavy motor */
|
|
uint8_t rumble_r; /* Light motor */
|
|
uint8_t reserved[3];
|
|
} xinput_out_report_t;
|
|
|
|
extern const tusb_desc_device_t xinput_device_desc;
|
|
extern const uint8_t xinput_config_desc[153];
|
|
extern const char *xinput_string_desc[5];
|
|
|
|
void xinput_device_init(void);
|
|
void xinput_device_build_report(const controller_state_t *state, xinput_in_report_t *rep);
|
|
bool xinput_device_send_report(const xinput_in_report_t *rep);
|
|
|
|
void ogx_device_init(void);
|
|
bool ogx_device_send_report(const void *rep, uint16_t len);
|
|
|
|
/* TinyUSB Application Class Driver for XInput & XSM3 Security Handshake */
|
|
usbd_class_driver_t const *xinput_device_get_class_driver(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|