diff --git a/app/src/uhid/gamepad_uhid.c b/app/src/uhid/gamepad_uhid.c index 5f19a9d0..ffce0ed7 100644 --- a/app/src/uhid/gamepad_uhid.c +++ b/app/src/uhid/gamepad_uhid.c @@ -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 diff --git a/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java b/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java index 408dbf5d..2db043bc 100644 --- a/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java +++ b/server/src/main/java/com/genymobile/scrcpy/control/UhidManager.java @@ -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);