gamepad_hid_output

This commit is contained in:
Romain Vimont 2024-09-08 09:41:42 +02:00
parent 995d069d35
commit 25470a5a16
2 changed files with 12 additions and 4 deletions

View File

@ -119,7 +119,14 @@ sc_gamepad_uhid_process_hid_output(struct sc_gamepad_uhid *gamepad,
LOGI("==== HID output [%" PRIu16 "]", hid_id);
}
// TODO
struct sc_hid_gamepad *gp = &gamepad->hid;
struct sc_hid_gamepad_slot* slot = &gp->slots[hid_id - SC_HID_ID_GAMEPAD_FIRST];
SDL_GameController *gc = SDL_GameControllerFromInstanceID(slot->gamepad_id);
// | | HID Report | SDL Parameter |
// |-----------|------------|---------------|
// | Intensity | 0 - 100 | 0 - 65535 |
// | Duration | 0 - 255 | 0 - 1000 |
SDL_GameControllerRumble(gc, data[4] * 0xFFFF / 100, data[5] * 0xFFFF / 100, data[6] * 1000 / 0xFF);
}
void

View File

@ -25,6 +25,7 @@ public final class UhidManager {
private static final int UHID_INPUT2 = 12;
// Linux: include/uapi/linux/input.h
private static final short BUS_BLUETOOTH = 0x05;
private static final short BUS_VIRTUAL = 0x06;
private static final int SIZE_OF_UHID_EVENT = 4380; // sizeof(struct uhid_event)
@ -174,9 +175,9 @@ public final class UhidManager {
buf.put("scrcpy".getBytes(StandardCharsets.US_ASCII));
buf.put(empty, 0, 256 - "scrcpy".length());
buf.putShort((short) reportDesc.length);
buf.putShort(BUS_VIRTUAL);
buf.putInt(0); // vendor id
buf.putInt(0); // product id
buf.putShort(BUS_BLUETOOTH);
buf.putInt(0x045e); // product id
buf.putInt(0x02fd); // vendor id
buf.putInt(0); // version
buf.putInt(0); // country;
buf.put(reportDesc);