Files
xone_macos/include/app/xone_api.h
T
portersky 4f5f16e43f feat: expose dongle debug info through the C API
Add an opaque xone_dongle session handle to the C ABI bridge:
xone_open() probes, resets, and loads the firmware (path optional),
and xone_pid/xone_chip_id/xone_mac_address/xone_firmware_build return
debug info for the open session. chip captures the firmware build
string from the image header during load.

The Swift app opens a session when the dongle appears and shows PID,
chip ID, MAC address, and firmware build string in a debug section.

Co-Authored-By: qwen3.8-27b@q2_k_xl: added C API session handle and debug UI
2026-08-17 16:44:02 +02:00

52 lines
1.8 KiB
C

#pragma once
// ==============================================================================
// C ABI bridge between the C++ protocol stack and the Swift app layer
// ==============================================================================
// This header is imported into Swift via -import-objc-header, so it must stay
// pure C (no C++ types). The C++ modules implement these entry points.
// ==============================================================================
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Human-readable version string of the protocol stack.
const char *xone_version(void);
// TRUE if an Xbox Wireless Dongle is connected, FALSE otherwise.
bool xone_dongle_present(void);
// Opaque handle to an open dongle session (probe + firmware load).
// Create with xone_open(); call the getters from the thread that opened
// it, and before xone_close(). Only one session may be open at a time.
typedef struct xone_dongle xone_dongle;
// Open a dongle session: probe, USB reset, and (if firmware_path is not
// NULL) load the firmware image from that file. Returns NULL if no dongle
// is present or opening fails.
xone_dongle *xone_open(const char *firmware_path);
// Close the session and release the dongle.
void xone_close(xone_dongle *d);
// Product ID of the connected dongle (e.g. 0x02E6).
uint16_t xone_pid(const xone_dongle *d);
// Chip ID from EFUSE (e.g. 0x7612 for MT7612). 0 if unknown.
uint16_t xone_chip_id(const xone_dongle *d);
// MAC address from EFUSE as "xx:xx:xx:xx:xx:xx". Valid until xone_close().
const char *xone_mac_address(const xone_dongle *d);
// Build string of the loaded firmware image (e.g. "201703281033____").
// Empty string if the firmware was not loaded. Valid until xone_close().
const char *xone_firmware_build(const xone_dongle *d);
#ifdef __cplusplus
}
#endif