bluehid icon indicating copy to clipboard operation
bluehid copied to clipboard

Converting app in remote mouse

Open allinonezucchelli opened this issue 4 years ago • 2 comments

Hi ralismark, great job. I'm trying to convert your code in a remote mouse (with android P). these are my changes: 1-I convert all InputHost in BluetoothHidDevice 2- Change descriptor in:

       // HID descriptor
        0x09, // bLength
        0x21, // bDescriptorType - HID
        0x11, 0x01, // bcdHID (little endian - 1.11)
        0x00, // bCountryCode
        0x01, // bNumDescriptors (min 1)
        0x22, // bDescriptorType - Report
        0x32, 0x00, // wDescriptorLength (48)

        // Report descriptor
        0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
        0x09, 0x02,                    // USAGE (Mouse)
        (byte)0xa1, 0x01,                    // COLLECTION (Application)
        0x09, 0x01,                    //   USAGE (Pointer)
        (byte)0xa1, 0x00,                    //   COLLECTION (Physical)
        0x05, 0x09,                    //     USAGE_PAGE (Button)
        0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
        0x29, 0x03,                    //     USAGE_MAXIMUM (Button 3)
        0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
        (byte) 0x95, 0x03,                    //     REPORT_COUNT (3)
        0x75, 0x01,                    //     REPORT_SIZE (1)
        (byte)0x81, 0x02,                    //     INPUT (Data,Var,Abs)
        (byte)0x95, 0x01,                    //     REPORT_COUNT (1)
        0x75, 0x05,                    //     REPORT_SIZE (5)
        (byte)0x81, 0x03,                    //     INPUT (Cnst,Var,Abs)
        0x05, 0x01,                    //     USAGE_PAGE (Generic Desktop)
        0x09, 0x30,                    //     USAGE (X)
        0x09, 0x31,                    //     USAGE (Y)
        0x15, (byte)0x81,                    //     LOGICAL_MINIMUM (-127)
        0x25, 0x7f,                    //     LOGICAL_MAXIMUM (127)
        0x75, 0x08,                    //     REPORT_SIZE (8)
        (byte)0x95, 0x02,                    //     REPORT_COUNT (2)
        (byte)0x81, 0x06,                    //     INPUT (Data,Var,Rel)
        (byte)0xc0,                          //   END_COLLECTION
        (byte)0xc0

3-line of registerApp in

mBtHidDevice.registerApp(sdp, null, null, Executors.newSingleThreadExecutor(), new BluetoothHidDevice.Callback() {

4-and use only 3 button:

byte state = 0;
        for (int i = 0; i < 3; ++i) {
            if ((boolean) buttons[i].getTag(R.id.tag_pressed)) {
                state |= (1 << i);
            }
        }

For me it is all Ok, i receive Got HID device and i can connect to host and sendreport but unfortunately the mouse doesn't want to work

Can you help me please?!?!

I don't know where to bang my head :)

allinonezucchelli avatar Apr 10 '20 11:04 allinonezucchelli

add main activity MainActivity.zip

allinonezucchelli avatar Apr 10 '20 12:04 allinonezucchelli

I don't see any obvious issues with your code. If the app actually says "Connected" instead of "Connecting...", then in my experience it'll always work. However, I'm not too sure if your HID descriptor is correct (though I don't have much knowledge in this matter) - try looking at other mouse HID descriptors, there might be some entries you're missing.

ralismark avatar Apr 11 '20 03:04 ralismark