Add UHID gamepad rumble WIP
This commit is contained in:
parent
246b708757
commit
82660c25a0
@ -724,6 +724,7 @@ aoa_complete:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct sc_keyboard_uhid *uhid_keyboard = NULL;
|
struct sc_keyboard_uhid *uhid_keyboard = NULL;
|
||||||
|
struct sc_gamepad_uhid *uhid_gamepad = NULL;
|
||||||
|
|
||||||
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_SDK) {
|
if (options->keyboard_input_mode == SC_KEYBOARD_INPUT_MODE_SDK) {
|
||||||
sc_keyboard_sdk_init(&s->keyboard_sdk, &s->controller,
|
sc_keyboard_sdk_init(&s->keyboard_sdk, &s->controller,
|
||||||
@ -758,8 +759,8 @@ aoa_complete:
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct sc_uhid_devices *uhid_devices = NULL;
|
struct sc_uhid_devices *uhid_devices = NULL;
|
||||||
if (uhid_keyboard) {
|
if (uhid_keyboard || uhid_gamepad) {
|
||||||
sc_uhid_devices_init(&s->uhid_devices, uhid_keyboard);
|
sc_uhid_devices_init(&s->uhid_devices, uhid_keyboard, uhid_gamepad);
|
||||||
uhid_devices = &s->uhid_devices;
|
uhid_devices = &s->uhid_devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "hid/hid_gamepad.h"
|
#include "hid/hid_gamepad.h"
|
||||||
#include "input_events.h"
|
#include "input_events.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
#include "util/str.h"
|
||||||
|
|
||||||
/** Downcast gamepad processor to sc_gamepad_uhid */
|
/** Downcast gamepad processor to sc_gamepad_uhid */
|
||||||
#define DOWNCAST(GP) container_of(GP, struct sc_gamepad_uhid, gamepad_processor)
|
#define DOWNCAST(GP) container_of(GP, struct sc_gamepad_uhid, gamepad_processor)
|
||||||
@ -105,6 +106,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
|
void
|
||||||
sc_gamepad_uhid_init(struct sc_gamepad_uhid *gamepad,
|
sc_gamepad_uhid_init(struct sc_gamepad_uhid *gamepad,
|
||||||
struct sc_controller *controller) {
|
struct sc_controller *controller) {
|
||||||
|
@ -20,4 +20,9 @@ void
|
|||||||
sc_gamepad_uhid_init(struct sc_gamepad_uhid *mouse,
|
sc_gamepad_uhid_init(struct sc_gamepad_uhid *mouse,
|
||||||
struct sc_controller *controller);
|
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
|
#endif
|
||||||
|
@ -4,12 +4,15 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "uhid/keyboard_uhid.h"
|
#include "uhid/keyboard_uhid.h"
|
||||||
|
#include "uhid/gamepad_uhid.h"
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_uhid_devices_init(struct sc_uhid_devices *devices,
|
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->keyboard = keyboard;
|
||||||
|
devices->gamepad = gamepad;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -21,6 +24,13 @@ sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id,
|
|||||||
} else {
|
} else {
|
||||||
LOGW("Unexpected keyboard HID output without UHID keyboard");
|
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 {
|
} else {
|
||||||
LOGW("HID output ignored for id %" PRIu16, id);
|
LOGW("HID output ignored for id %" PRIu16, id);
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,13 @@
|
|||||||
|
|
||||||
struct sc_uhid_devices {
|
struct sc_uhid_devices {
|
||||||
struct sc_keyboard_uhid *keyboard;
|
struct sc_keyboard_uhid *keyboard;
|
||||||
|
struct sc_gamepad_uhid *gamepad;
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_uhid_devices_init(struct sc_uhid_devices *devices,
|
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
|
void
|
||||||
sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id,
|
sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user