- 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.
101 lines
2.8 KiB
C
101 lines
2.8 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "esp_err.h"
|
|
#include "controller_state.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef void (*ble_report_cb_t)(const controller_state_t *state);
|
|
|
|
/**
|
|
* @brief Initialize BLE Central stack and start scanning for wireless gamepads.
|
|
*/
|
|
esp_err_t ble_hid_host_init(ble_report_cb_t callback);
|
|
|
|
/**
|
|
* @brief Check if a BLE gamepad is currently connected.
|
|
*/
|
|
bool ble_hid_host_is_connected(void);
|
|
|
|
/**
|
|
* @brief Get the connected device name.
|
|
*/
|
|
const char *ble_hid_host_get_device_name(void);
|
|
|
|
/**
|
|
* @brief Disconnect currently connected BLE gamepad.
|
|
*/
|
|
void ble_hid_host_disconnect(void);
|
|
|
|
/**
|
|
* @brief Clear all stored BLE bonds/pairings and restart scan.
|
|
*/
|
|
void ble_hid_host_clear_bonds(void);
|
|
|
|
/**
|
|
* @brief Send force-feedback / rumble commands to the connected wireless controller.
|
|
* @param strong_magnitude Heavy / low-frequency motor intensity (0 - 255).
|
|
* @param weak_magnitude Light / high-frequency motor intensity (0 - 255).
|
|
*/
|
|
void ble_hid_host_send_rumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
|
|
|
/**
|
|
* @brief Trigger a short test rumble vibration on the connected controller.
|
|
* @param duration_ms Duration in milliseconds (e.g. 500ms).
|
|
*/
|
|
void ble_hid_host_test_rumble(uint16_t duration_ms);
|
|
|
|
/**
|
|
* @brief Pulse rumble with custom strength and duration (ideal for quick haptic clicks/confirmation).
|
|
* @param strong_magnitude Heavy motor intensity (0 - 255).
|
|
* @param weak_magnitude Light motor intensity (0 - 255).
|
|
* @param duration_ms Pulse duration in milliseconds.
|
|
*/
|
|
void ble_hid_host_pulse_rumble(uint8_t strong_magnitude, uint8_t weak_magnitude, uint16_t duration_ms);
|
|
|
|
/**
|
|
* @brief Get the battery level of the connected wireless controller.
|
|
* @return Battery percentage (0 - 100), or -1 if unknown / disconnected.
|
|
*/
|
|
int8_t ble_hid_host_get_battery_level(void);
|
|
|
|
/**
|
|
* @brief Refresh battery level from device if connected.
|
|
*/
|
|
void ble_hid_host_refresh_battery(void);
|
|
|
|
#define BLE_MAX_PEERS 8
|
|
|
|
typedef struct {
|
|
char name[32];
|
|
char mac_str[18]; /* "aa:bb:cc:dd:ee:ff" */
|
|
uint8_t addr_val[6];
|
|
uint8_t addr_type;
|
|
uint8_t controller_type; /* 0: Generic, 1: Xbox, 2: Stadia */
|
|
bool is_connected;
|
|
int8_t battery;
|
|
} ble_peer_info_t;
|
|
|
|
/**
|
|
* @brief Get list of bonded / remembered BLE controllers.
|
|
* @param out_peers Array of ble_peer_info_t.
|
|
* @param max_peers Max elements to write into out_peers.
|
|
* @return Number of peers written.
|
|
*/
|
|
int ble_hid_host_get_peers(ble_peer_info_t *out_peers, int max_peers);
|
|
|
|
/**
|
|
* @brief Forget / unpair a specific controller by MAC address string.
|
|
* @param mac_str "aa:bb:cc:dd:ee:ff"
|
|
* @return ESP_OK on success, ESP_ERR_NOT_FOUND if not found.
|
|
*/
|
|
esp_err_t ble_hid_host_unpair_device(const char *mac_str);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|