adafruit / Adafruit_CircuitPython_HID

USB Human Interface Device drivers.
MIT License
364 stars 106 forks source link

Add constants for mouse back and forward #124

Closed pythonmcpi closed 5 months ago

pythonmcpi commented 5 months ago

The current Mouse class already supports sending the back and forward buttons (also known as mouse buttons 4 and 5) by passing in the button constants manually. The constants currently included in the library are:

LEFT_BUTTON = 1 # 1 << 0
RIGHT_BUTTON = 2 # 1 << 1
MIDDLE_BUTTON = 4 # 1 << 2

This pull request adds the following constants:

BACK_BUTTON = 8 # 1 << 3
FORWARD_BUTTON = 16 # 1 << 4

Many mice include these buttons, and applications (such as browsers) support these for forward and backward navigation.

Partially resolves #94

pythonmcpi commented 5 months ago

The USB HID specification (version 1.11, found here) notes in the boot interface protocol that bits 4 to 7 are "Device-specific" and specifically says that bits 0, 1, and 2 correspond to Buttons 1, 2, and 3, respectively. However, the behaviors of the forward and back buttons appear to be consistent between different mice.