Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Absolute Mouse movement missing (IEC-237) #90

Open
2 tasks done
Jackolix opened this issue Nov 22, 2024 · 1 comment
Open
2 tasks done

Absolute Mouse movement missing (IEC-237) #90

Jackolix opened this issue Nov 22, 2024 · 1 comment
Assignees
Labels
Status: In Progress Issue is being worked on

Comments

@Jackolix
Copy link

Jackolix commented Nov 22, 2024

Answers checklist.

  • I have read the documentation of the component in question and the issue is not addressed there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

Description

I noticed that the absolute mouse movement functionality appears to be missing from this fork, despite being present in the original TinyUSB library. The following code exists in the original hathach/tinyusb source files but seems to be uncommitted or excluded:

In hid_device.h:

TU_ATTR_ALWAYS_INLINE static inline bool tud_hid_abs_mouse_report(uint8_t report_id, 
    uint8_t buttons, int16_t x, int16_t y, int8_t vertical, int8_t horizontal) {
    return tud_hid_n_abs_mouse_report(0, report_id, buttons, x, y, vertical, horizontal);
}
// Absolute Mouse Report Descriptor Template
#define TUD_HID_REPORT_DESC_ABSMOUSE(...) \
  HID_USAGE_PAGE ( HID_USAGE_PAGE_DESKTOP      )                   ,\
  HID_USAGE      ( HID_USAGE_DESKTOP_MOUSE     )                   ,\
  HID_COLLECTION ( HID_COLLECTION_APPLICATION  )                   ,\
    /* Report ID if any */\
    __VA_ARGS__ \
    HID_USAGE      ( HID_USAGE_DESKTOP_POINTER )                   ,\
    HID_COLLECTION ( HID_COLLECTION_PHYSICAL   )                   ,\
      HID_USAGE_PAGE  ( HID_USAGE_PAGE_BUTTON  )                   ,\
        HID_USAGE_MIN   ( 1                                      ) ,\
        HID_USAGE_MAX   ( 5                                      ) ,\
        HID_LOGICAL_MIN ( 0                                      ) ,\
        HID_LOGICAL_MAX ( 1                                      ) ,\
        /* Left, Right, Middle, Backward, Forward buttons */ \
        HID_REPORT_COUNT( 5                                      ) ,\
        HID_REPORT_SIZE ( 1                                      ) ,\
        HID_INPUT       ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
        /* 3 bit padding */ \
        HID_REPORT_COUNT( 1                                      ) ,\
        HID_REPORT_SIZE ( 3                                      ) ,\
        HID_INPUT       ( HID_CONSTANT                           ) ,\
      HID_USAGE_PAGE  ( HID_USAGE_PAGE_DESKTOP )                   ,\
        /* X, Y absolute position [0, 32767] */ \
        HID_USAGE       ( HID_USAGE_DESKTOP_X                    ) ,\
        HID_USAGE       ( HID_USAGE_DESKTOP_Y                    ) ,\
        HID_LOGICAL_MIN  ( 0x00                                ) ,\
        HID_LOGICAL_MAX_N( 0x7FFF, 2                           ) ,\
        HID_REPORT_SIZE  ( 16                                  ) ,\
        HID_REPORT_COUNT ( 2                                   ) ,\
        HID_INPUT       ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE ) ,\
        /* Vertical wheel scroll [-127, 127] */ \
        HID_USAGE       ( HID_USAGE_DESKTOP_WHEEL                )  ,\
        HID_LOGICAL_MIN ( 0x81                                   )  ,\
        HID_LOGICAL_MAX ( 0x7f                                   )  ,\
        HID_REPORT_COUNT( 1                                      )  ,\
        HID_REPORT_SIZE ( 8                                      )  ,\
        HID_INPUT       ( HID_DATA | HID_VARIABLE | HID_RELATIVE )  ,\
      HID_USAGE_PAGE  ( HID_USAGE_PAGE_CONSUMER ), \
       /* Horizontal wheel scroll [-127, 127] */ \
        HID_USAGE_N     ( HID_USAGE_CONSUMER_AC_PAN, 2           ), \
        HID_LOGICAL_MIN ( 0x81                                   ), \
        HID_LOGICAL_MAX ( 0x7f                                   ), \
        HID_REPORT_COUNT( 1                                      ), \
        HID_REPORT_SIZE ( 8                                      ), \
        HID_INPUT       ( HID_DATA | HID_VARIABLE | HID_RELATIVE ), \
    HID_COLLECTION_END                                            , \
  HID_COLLECTION_END \

In hid_device.c:

bool tud_hid_n_abs_mouse_report(uint8_t instance, uint8_t report_id,
    uint8_t buttons, int16_t x, int16_t y, int8_t vertical, int8_t horizontal) {
    hid_abs_mouse_report_t report = {
        .buttons = buttons,
        .x = x,
        .y = y,
        .wheel = vertical,
        .pan = horizontal
    };
    return tud_hid_n_report(instance, report_id, &report, sizeof(report));
}

In hid.h:

typedef struct TU_ATTR_PACKED {
    uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
    int16_t x;       /**< Current x position of the mouse. */
    int16_t y;       /**< Current y position of the mouse. */
    int8_t wheel;    /**< Current delta wheel movement on the mouse. */
    int8_t pan;      // using AC Pan
} hid_abs_mouse_report_t;

Questions

  1. Was this functionality intentionally excluded from this fork?
  2. If not, could it be added back to maintain feature parity with the original TinyUSB library?
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 22, 2024
@github-actions github-actions bot changed the title Absolute Mouse movement missing Absolute Mouse movement missing (IEC-237) Nov 22, 2024
@roma-jam
Copy link
Collaborator

Hi @Jackolix,

Currently, the esp_tinyusb is using the tinyusb-based espressif component (https://github.com/espressif/tinyusb) which in it turn based on the v0.15.0 of upstream tinyusb.

The API that were mentioned was implemented only in v0.17.0 (it is not implemented in v0.15.0: https://github.com/hathach/tinyusb/blob/0.15.0/src/class/hid/hid_device.h)

We are in the process of preparing the update and we will synchronize the tinyusb component with upstream v0.17.x. shortly.

@espressif-bot espressif-bot added Status: In Progress Issue is being worked on and removed Status: Opened Issue is new labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: In Progress Issue is being worked on
Projects
None yet
Development

No branches or pull requests

4 participants