Files
MimiCon/main/parsers/parser_generic_hogp.c
T
dark98 69ebdb4331 Initial commit: MimiCon v1.0.0 - Universal Gamepad Mimic & Console Bridge
- 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.
2026-10-17 20:21:09 +01:00

55 lines
1.8 KiB
C

#include "parser_generic_hogp.h"
bool parser_generic_hogp_parse(const uint8_t *report, size_t len, controller_state_t *out_state)
{
if (!report || !out_state || len < 6) {
return false;
}
controller_state_reset(out_state);
const uint8_t *data = report;
/* If first byte is Report ID, skip it */
if (len > 6 && (data[0] <= 0x05)) {
data++;
len--;
}
/* Standard 8-bit axis mapping (0..255, 128 center) */
uint8_t raw_lx = data[0];
uint8_t raw_ly = data[1];
uint8_t raw_rx = (len > 2) ? data[2] : 128;
uint8_t raw_ry = (len > 3) ? data[3] : 128;
out_state->lx = scale_axis_8bit(raw_lx, false);
out_state->ly = scale_axis_8bit(raw_ly, true);
out_state->rx = scale_axis_8bit(raw_rx, false);
out_state->ry = scale_axis_8bit(raw_ry, true);
/* Hat switch & buttons */
if (len >= 6) {
parse_hat_switch_8way(data[4], out_state);
uint8_t btn1 = (data[4] >> 4) | ((data[5] & 0x0F) << 4);
out_state->btn_a = (btn1 & (1 << 0)) ? 1 : 0;
out_state->btn_b = (btn1 & (1 << 1)) ? 1 : 0;
out_state->btn_x = (btn1 & (1 << 2)) ? 1 : 0;
out_state->btn_y = (btn1 & (1 << 3)) ? 1 : 0;
out_state->btn_lb = (btn1 & (1 << 4)) ? 1 : 0;
out_state->btn_rb = (btn1 & (1 << 5)) ? 1 : 0;
out_state->btn_lt = (btn1 & (1 << 6)) ? 1 : 0;
out_state->btn_rt = (btn1 & (1 << 7)) ? 1 : 0;
if (len >= 7) {
uint8_t btn2 = data[6];
out_state->btn_select = (btn2 & (1 << 0)) ? 1 : 0;
out_state->btn_start = (btn2 & (1 << 1)) ? 1 : 0;
out_state->btn_l3 = (btn2 & (1 << 2)) ? 1 : 0;
out_state->btn_r3 = (btn2 & (1 << 3)) ? 1 : 0;
out_state->btn_system = (btn2 & (1 << 4)) ? 1 : 0;
}
}
return true;
}