Add UHID gamepad rumble WIP
This commit is contained in:
parent
7828bb2dbd
commit
3ade819cef
@ -709,6 +709,7 @@ aoa_complete:
|
||||
#endif
|
||||
|
||||
struct sc_keyboard_uhid *uhid_keyboard = NULL;
|
||||
struct sc_gamepad_uhid *uhid_gamepad = NULL;
|
||||
|
||||
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_SDK) {
|
||||
sc_keyboard_sdk_init(&s->keyboard_sdk, &s->controller,
|
||||
@ -743,8 +744,8 @@ aoa_complete:
|
||||
}
|
||||
|
||||
struct sc_uhid_devices *uhid_devices = NULL;
|
||||
if (uhid_keyboard) {
|
||||
sc_uhid_devices_init(&s->uhid_devices, uhid_keyboard);
|
||||
if (uhid_keyboard || uhid_gamepad) {
|
||||
sc_uhid_devices_init(&s->uhid_devices, uhid_keyboard, uhid_gamepad);
|
||||
uhid_devices = &s->uhid_devices;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "hid/hid_gamepad.h"
|
||||
#include "input_events.h"
|
||||
#include "util/log.h"
|
||||
#include "util/str.h"
|
||||
|
||||
/** Downcast gamepad processor to sc_gamepad_uhid */
|
||||
#define DOWNCAST(GP) container_of(GP, struct sc_gamepad_uhid, gamepad_processor)
|
||||
@ -99,6 +100,22 @@ sc_gamepad_processor_process_gamepad_button(struct sc_gamepad_processor *gp,
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
sc_gamepad_uhid_process_hid_output(struct sc_gamepad_uhid *gamepad,
|
||||
uint16_t hid_id, const uint8_t *data,
|
||||
size_t size) {
|
||||
(void) gamepad;
|
||||
char *hex = sc_str_to_hex_string(data, size);
|
||||
if (hex) {
|
||||
LOGI("==== HID output [%" PRIu16 "] %s", hid_id, hex);
|
||||
free(hex);
|
||||
} else {
|
||||
LOGI("==== HID output [%" PRIu16 "]", hid_id);
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void
|
||||
sc_gamepad_uhid_init(struct sc_gamepad_uhid *gamepad,
|
||||
struct sc_controller *controller) {
|
||||
|
@ -20,4 +20,9 @@ void
|
||||
sc_gamepad_uhid_init(struct sc_gamepad_uhid *mouse,
|
||||
struct sc_controller *controller);
|
||||
|
||||
void
|
||||
sc_gamepad_uhid_process_hid_output(struct sc_gamepad_uhid *gamepad,
|
||||
uint16_t hid_id, const uint8_t *data,
|
||||
size_t size);
|
||||
|
||||
#endif
|
||||
|
@ -4,12 +4,15 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "uhid/keyboard_uhid.h"
|
||||
#include "uhid/gamepad_uhid.h"
|
||||
#include "util/log.h"
|
||||
|
||||
void
|
||||
sc_uhid_devices_init(struct sc_uhid_devices *devices,
|
||||
struct sc_keyboard_uhid *keyboard) {
|
||||
struct sc_keyboard_uhid *keyboard,
|
||||
struct sc_gamepad_uhid *gamepad) {
|
||||
devices->keyboard = keyboard;
|
||||
devices->gamepad = gamepad;
|
||||
}
|
||||
|
||||
void
|
||||
@ -21,6 +24,13 @@ sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id,
|
||||
} else {
|
||||
LOGW("Unexpected keyboard HID output without UHID keyboard");
|
||||
}
|
||||
} else if (id >= SC_HID_ID_GAMEPAD_FIRST && id <= SC_HID_ID_GAMEPAD_LAST) {
|
||||
if (devices->gamepad) {
|
||||
sc_gamepad_uhid_process_hid_output(devices->gamepad, id, data,
|
||||
size);
|
||||
} else {
|
||||
LOGW("Unexpected gamepad HID output without UHID gamepad");
|
||||
}
|
||||
} else {
|
||||
LOGW("HID output ignored for id %" PRIu16, id);
|
||||
}
|
||||
|
@ -14,11 +14,13 @@
|
||||
|
||||
struct sc_uhid_devices {
|
||||
struct sc_keyboard_uhid *keyboard;
|
||||
struct sc_gamepad_uhid *gamepad;
|
||||
};
|
||||
|
||||
void
|
||||
sc_uhid_devices_init(struct sc_uhid_devices *devices,
|
||||
struct sc_keyboard_uhid *keyboard);
|
||||
struct sc_keyboard_uhid *keyboard,
|
||||
struct sc_gamepad_uhid *gamepad);
|
||||
|
||||
void
|
||||
sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user