Add dual-controller AIO USB transport
This commit is contained in:
parent
7941294a8d
commit
edf6ecaae1
19 changed files with 1007 additions and 116 deletions
22
tests/bluepad32_native_stubs/btstack_run_loop.h
Normal file
22
tests/bluepad32_native_stubs/btstack_run_loop.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct btstack_timer_source_t {
|
||||
void (*handler)(btstack_timer_source_t*);
|
||||
uint32_t timeout_ms;
|
||||
};
|
||||
|
||||
inline void btstack_run_loop_set_timer_handler(
|
||||
btstack_timer_source_t* timer,
|
||||
void (*handler)(btstack_timer_source_t*)) {
|
||||
timer->handler = handler;
|
||||
}
|
||||
|
||||
inline void btstack_run_loop_set_timer(btstack_timer_source_t* timer,
|
||||
uint32_t timeout_ms) {
|
||||
timer->timeout_ms = timeout_ms;
|
||||
}
|
||||
|
||||
inline void btstack_run_loop_add_timer(btstack_timer_source_t*) {}
|
||||
inline void btstack_run_loop_execute() {}
|
||||
7
tests/bluepad32_native_stubs/pico/critical_section.h
Normal file
7
tests/bluepad32_native_stubs/pico/critical_section.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
struct critical_section_t {};
|
||||
|
||||
inline void critical_section_init(critical_section_t*) {}
|
||||
inline void critical_section_enter_blocking(critical_section_t*) {}
|
||||
inline void critical_section_exit(critical_section_t*) {}
|
||||
6
tests/bluepad32_native_stubs/pico/cyw43_arch.h
Normal file
6
tests/bluepad32_native_stubs/pico/cyw43_arch.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#define CYW43_WL_GPIO_LED_PIN 0
|
||||
|
||||
int cyw43_arch_init();
|
||||
void cyw43_arch_gpio_put(int pin, bool value);
|
||||
3
tests/bluepad32_native_stubs/pico/multicore.h
Normal file
3
tests/bluepad32_native_stubs/pico/multicore.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void multicore_launch_core1(void (*entry)());
|
||||
3
tests/bluepad32_native_stubs/pico/stdlib.h
Normal file
3
tests/bluepad32_native_stubs/pico/stdlib.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
inline void tight_loop_contents() {}
|
||||
98
tests/bluepad32_native_stubs/uni.h
Normal file
98
tests/bluepad32_native_stubs/uni.h
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint8_t bd_addr_t[6];
|
||||
typedef int uni_property_idx_t;
|
||||
typedef int uni_platform_oob_event_t;
|
||||
struct uni_property_t {};
|
||||
|
||||
enum uni_error_t {
|
||||
UNI_ERROR_SUCCESS = 0,
|
||||
UNI_ERROR_IGNORE_DEVICE = 1,
|
||||
UNI_ERROR_INVALID_CONTROLLER = 2,
|
||||
UNI_ERROR_NO_SLOTS = 3,
|
||||
};
|
||||
|
||||
enum {
|
||||
UNI_CONTROLLER_CLASS_GAMEPAD = 1,
|
||||
DPAD_UP = 1 << 0,
|
||||
DPAD_DOWN = 1 << 1,
|
||||
DPAD_LEFT = 1 << 2,
|
||||
DPAD_RIGHT = 1 << 3,
|
||||
BUTTON_A = 1 << 0,
|
||||
BUTTON_B = 1 << 1,
|
||||
BUTTON_X = 1 << 2,
|
||||
BUTTON_Y = 1 << 3,
|
||||
BUTTON_SHOULDER_L = 1 << 4,
|
||||
BUTTON_SHOULDER_R = 1 << 5,
|
||||
BUTTON_TRIGGER_L = 1 << 6,
|
||||
BUTTON_TRIGGER_R = 1 << 7,
|
||||
BUTTON_THUMB_L = 1 << 8,
|
||||
BUTTON_THUMB_R = 1 << 9,
|
||||
MISC_BUTTON_SELECT = 1 << 0,
|
||||
MISC_BUTTON_START = 1 << 1,
|
||||
MISC_BUTTON_SYSTEM = 1 << 2,
|
||||
MISC_BUTTON_CAPTURE = 1 << 3,
|
||||
};
|
||||
|
||||
struct uni_gamepad_t {
|
||||
uint32_t dpad;
|
||||
uint32_t buttons;
|
||||
uint32_t misc_buttons;
|
||||
int32_t axis_x;
|
||||
int32_t axis_y;
|
||||
int32_t axis_rx;
|
||||
int32_t axis_ry;
|
||||
int32_t brake;
|
||||
int32_t throttle;
|
||||
int32_t accel[3];
|
||||
int32_t gyro[3];
|
||||
};
|
||||
|
||||
struct uni_controller_t {
|
||||
int klass;
|
||||
uni_gamepad_t gamepad;
|
||||
};
|
||||
|
||||
struct uni_hid_device_t;
|
||||
typedef void (*uni_play_dual_rumble_t)(uni_hid_device_t*, uint16_t,
|
||||
uint16_t, uint8_t, uint8_t);
|
||||
|
||||
struct uni_report_parser_t {
|
||||
uni_play_dual_rumble_t play_dual_rumble;
|
||||
};
|
||||
|
||||
struct uni_hid_device_t {
|
||||
int idx;
|
||||
bool gamepad;
|
||||
uni_report_parser_t report_parser;
|
||||
int rumble_calls;
|
||||
uint8_t last_high;
|
||||
uint8_t last_low;
|
||||
};
|
||||
|
||||
struct uni_platform {
|
||||
const char* name;
|
||||
void (*init)(int, const char**);
|
||||
void (*on_init_complete)();
|
||||
uni_error_t (*on_device_discovered)(bd_addr_t, const char*, uint16_t,
|
||||
uint8_t);
|
||||
void (*on_device_connected)(uni_hid_device_t*);
|
||||
void (*on_device_disconnected)(uni_hid_device_t*);
|
||||
uni_error_t (*on_device_ready)(uni_hid_device_t*);
|
||||
void* on_device_oob_event;
|
||||
void (*on_controller_data)(uni_hid_device_t*, uni_controller_t*);
|
||||
const uni_property_t* (*get_property)(uni_property_idx_t);
|
||||
void (*on_oob_event)(uni_platform_oob_event_t, void*);
|
||||
void* on_device_dump;
|
||||
void* on_gamepad_seat;
|
||||
};
|
||||
|
||||
bool uni_hid_device_is_gamepad(const uni_hid_device_t* device);
|
||||
int uni_hid_device_get_idx_for_instance(const uni_hid_device_t* device);
|
||||
void uni_bt_allow_incoming_connections(bool enabled);
|
||||
void uni_bt_start_scanning_and_autoconnect_unsafe();
|
||||
void uni_bt_stop_scanning_unsafe();
|
||||
void uni_platform_set_custom(uni_platform* platform);
|
||||
int uni_init(int argc, const char** argv);
|
||||
Loading…
Add table
Add a link
Reference in a new issue