1
\$\begingroup\$

I'm building a custom Bluetooth mouse using an ESP32 with a proximity sensor for the Y coordinates and a gyroscope for the X coordinates and was wondering if setting the X axis as relative and Y axis as absolute was possible.

I can make my mouse work using both coordinates as relative or both coordinates as absolute; but having them as different settings would help me get much better pointing accuracy with filtering, which I cannot implement if both X and Y have the same settings.

However, when I try having X as relative and Y as absolute by modifying the HID device descriptor, the settings for Y coordinates get ignored.

This is my HID descriptor

const uint8_t kMouseHidDescriptor[] = {
  0x05, 0x01,                         // USAGE_PAGE (Generic Desktop)     0
  0x09, 0x02,                         // USAGE (Mouse)                    2
  0xa1, 0x01,                         // COLLECTION (Application)         4
  0x85, 0x01,                         //   REPORT_ID (Mouse)              6
  0x09, 0x01,                         //   USAGE (Pointer)                8
  0xa1, 0x00,                         //   COLLECTION (Physical)          10

  0x05, 0x09,                         //     USAGE_PAGE (Button)          12
  0x19, 0x01,                         //     USAGE_MINIMUM (Button 1)     14
  0x29, 0x03,                         //     USAGE_MAXIMUM (Button 3)     16
  0x15, 0x00,                         //     LOGICAL_MINIMUM (0)          18
  0x25, 0x01,                         //     LOGICAL_MAXIMUM (1)          20
  0x75, 0x01,                         //     REPORT_SIZE (1)              22
  0x95, 0x03,                         //     REPORT_COUNT (3)             24
  0x81, 0x02,                         //     INPUT (Data,Var,Abs)         26
  0x95, 0x05,                         //     REPORT_COUNT (5)             28
  0x81, 0x03,                         //     INPUT (Cnst,Var,Abs)         30

  0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop) 32
  0x09, 0x30,                         //     USAGE (X)                    34
  0x15, 0x81,                         //     LOGICAL_MINIMUM (-127)       36
  0x25, 0x7f,                         //     LOGICAL_MAXIMUM (127)        38
  0x75, 0x08,                         //     REPORT_SIZE (8)              40
  0x95, 0x01,                         //     REPORT_COUNT (1)             42
  0x81, 0x06,                         //     INPUT (Data,Var,Rel)         44

  0x05, 0x01,                         //     USAGE_PAGE (Generic Desktop) 46
  0x09, 0x31,                         //     USAGE (Y)                    48
  0x16, 0x01, 0xf8,                   //     LOGICAL_MINIMUM (-2047)      50
  0x26, 0xff, 0x07,                   //     LOGICAL_MAXIMUM (2047)       53
  0x75, 0x10,                         //     REPORT_SIZE (16)             56
  0x95, 0x01,                         //     REPORT_COUNT (1)             58
  0x81, 0x02,                         //     INPUT (Data,Var,Abs)         60

  0xc0,                               //   END_COLLECTION                 62
  0xc0                                // END_COLLECTION                 63/64
};

I expected X data to be interpreted as relative values and Y data to be interpreted as absolute values, but I get both X and Y interpreted as relative values. Would anyone have an idea of how to implement this better?

\$\endgroup\$
  • \$\begingroup\$ Can you instead present this as a composite device and treat the two-axis separately? \$\endgroup\$ – Gonzik007 Apr 9 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.