-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There was a registration mechanism to listen to HID outputs with a specific HID id. However, the UHID gamepad processor handles several ids, so it will not work. We could complexify the registration mechanism, but instead, directly dispatch to the expected processor based on the UHID id. Concretely, instead of passing a sc_uhid_devices instance to construct a sc_keyboard_uhid, so that it can register itself, construct the sc_uhid_devices with all the UHID instances (currently only sc_keyboard_uhid) so that it can dispatch HID outputs directly.
- Loading branch information
Showing
6 changed files
with
45 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
#include "uhid_output.h" | ||
|
||
#include <assert.h> | ||
#include <inttypes.h> | ||
|
||
void | ||
sc_uhid_devices_init(struct sc_uhid_devices *devices) { | ||
devices->count = 0; | ||
} | ||
#include "uhid/keyboard_uhid.h" | ||
#include "util/log.h" | ||
|
||
void | ||
sc_uhid_devices_add_receiver(struct sc_uhid_devices *devices, | ||
struct sc_uhid_receiver *receiver) { | ||
assert(devices->count < SC_UHID_MAX_RECEIVERS); | ||
devices->receivers[devices->count++] = receiver; | ||
sc_uhid_devices_init(struct sc_uhid_devices *devices, | ||
struct sc_keyboard_uhid *keyboard) { | ||
devices->keyboard = keyboard; | ||
} | ||
|
||
struct sc_uhid_receiver * | ||
sc_uhid_devices_get_receiver(struct sc_uhid_devices *devices, uint16_t id) { | ||
for (size_t i = 0; i < devices->count; ++i) { | ||
if (devices->receivers[i]->id == id) { | ||
return devices->receivers[i]; | ||
void | ||
sc_uhid_devices_process_hid_output(struct sc_uhid_devices *devices, uint16_t id, | ||
const uint8_t *data, size_t size) { | ||
if (id == SC_HID_ID_KEYBOARD) { | ||
if (devices->keyboard) { | ||
sc_keyboard_uhid_process_hid_output(devices->keyboard, data, size); | ||
} else { | ||
LOGW("Unexpected keyboard HID output without UHID keyboard"); | ||
} | ||
} else { | ||
LOGW("HID output ignored for id %" PRIu16, id); | ||
} | ||
return NULL; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters