diff --git a/docs/feature_mouse_keys.md b/docs/feature_mouse_keys.md index 992849313755..eed4f4f4aaaf 100644 --- a/docs/feature_mouse_keys.md +++ b/docs/feature_mouse_keys.md @@ -29,6 +29,9 @@ In your keymap you can use the following keycodes to map key presses to mouse ac |`KC_MS_BTN3` |`KC_BTN3`|Press button 3 | |`KC_MS_BTN4` |`KC_BTN4`|Press button 4 | |`KC_MS_BTN5` |`KC_BTN5`|Press button 5 | +|`KC_MS_BTN6` |`KC_BTN6`|Press button 6 | +|`KC_MS_BTN7` |`KC_BTN7`|Press button 7 | +|`KC_MS_BTN8` |`KC_BTN8`|Press button 8 | |`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up | |`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down | |`KC_MS_WH_LEFT` |`KC_WH_L`|Move wheel left | diff --git a/docs/feature_pointing_device.md b/docs/feature_pointing_device.md index dd7d5fae0be9..909eff826de1 100644 --- a/docs/feature_pointing_device.md +++ b/docs/feature_pointing_device.md @@ -382,7 +382,7 @@ The report_mouse_t (here "mouseReport") has the following properties: * `mouseReport.y` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing movement (+ upward, - downward) on the y axis. * `mouseReport.v` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing vertical scrolling (+ upward, - downward). * `mouseReport.h` - this is a signed int from -127 to 127 (not 128, this is defined in USB HID spec) representing horizontal scrolling (+ right, - left). -* `mouseReport.buttons` - this is a uint8_t in which the last 5 bits are used. These bits represent the mouse button state - bit 3 is mouse button 5, and bit 7 is mouse button 1. +* `mouseReport.buttons` - this is a uint8_t in which all 8 bits are used. These bits represent the mouse button state - bit 0 is mouse button 1, and bit 7 is mouse button 8. To manually manipulate the mouse reports outside of the `pointing_device_task_*` functions, you can use: diff --git a/docs/ja/feature_mouse_keys.md b/docs/ja/feature_mouse_keys.md index 74b09e939b73..e4fa9dfb456a 100644 --- a/docs/ja/feature_mouse_keys.md +++ b/docs/ja/feature_mouse_keys.md @@ -34,6 +34,9 @@ MOUSEKEY_ENABLE = yes | `KC_MS_BTN3` | `KC_BTN3` | ボタン3を押す | | `KC_MS_BTN4` | `KC_BTN4` | ボタン4を押す | | `KC_MS_BTN5` | `KC_BTN5` | ボタン5を押す | +| `KC_MS_BTN6` | `KC_BTN6` | ボタン6を押す | +| `KC_MS_BTN7` | `KC_BTN7` | ボタン7を押す | +| `KC_MS_BTN8` | `KC_BTN8` | ボタン8を押す | | `KC_MS_WH_UP` | `KC_WH_U` | ホイールを向こう側に回転 | | `KC_MS_WH_DOWN` | `KC_WH_D` | ホイールを手前側に回転 | | `KC_MS_WH_LEFT` | `KC_WH_L` | ホイールを左に倒す | diff --git a/quantum/mousekey.c b/quantum/mousekey.c index db7b69b7a113..735a6e45ba85 100644 --- a/quantum/mousekey.c +++ b/quantum/mousekey.c @@ -410,16 +410,8 @@ void mousekey_on(uint8_t code) { mouse_report.h = wheel_unit() * -1; else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit(); - else if (code == KC_MS_BTN1) - mouse_report.buttons |= MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons |= MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons |= MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons |= MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons |= MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons |= 1 << (code - KC_MS_BTN1); else if (code == KC_MS_ACCEL0) mousekey_accel |= (1 << 0); else if (code == KC_MS_ACCEL1) @@ -462,16 +454,8 @@ void mousekey_off(uint8_t code) { mouse_report.h = 0; else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0; - else if (code == KC_MS_BTN1) - mouse_report.buttons &= ~MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons &= ~MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons &= ~MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons &= ~MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons &= ~MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1)); else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1 << 0); else if (code == KC_MS_ACCEL1) @@ -574,16 +558,8 @@ void mousekey_on(uint8_t code) { mouse_report.h = w_offset * -1; else if (code == KC_MS_WH_RIGHT) mouse_report.h = w_offset; - else if (code == KC_MS_BTN1) - mouse_report.buttons |= MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons |= MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons |= MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons |= MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons |= MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons |= 1 << (code - KC_MS_BTN1); else if (code == KC_MS_ACCEL0) mk_speed = mkspd_0; else if (code == KC_MS_ACCEL1) @@ -613,16 +589,8 @@ void mousekey_off(uint8_t code) { mouse_report.h = 0; else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0; - else if (code == KC_MS_BTN1) - mouse_report.buttons &= ~MOUSE_BTN1; - else if (code == KC_MS_BTN2) - mouse_report.buttons &= ~MOUSE_BTN2; - else if (code == KC_MS_BTN3) - mouse_report.buttons &= ~MOUSE_BTN3; - else if (code == KC_MS_BTN4) - mouse_report.buttons &= ~MOUSE_BTN4; - else if (code == KC_MS_BTN5) - mouse_report.buttons &= ~MOUSE_BTN5; + else if (IS_MOUSEKEY_BUTTON(code)) + mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1)); # ifdef MK_MOMENTARY_ACCEL else if (code == KC_MS_ACCEL0) mk_speed = mkspd_DEFAULT; diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index b61531580970..9d415a3bfd7c 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -38,11 +38,14 @@ enum hid_report_ids { /* Mouse buttons */ #define MOUSE_BTN_MASK(n) (1 << (n)) enum mouse_buttons { - MOUSE_BTN1 = (1 << 0), - MOUSE_BTN2 = (1 << 1), - MOUSE_BTN3 = (1 << 2), - MOUSE_BTN4 = (1 << 3), - MOUSE_BTN5 = (1 << 4) + MOUSE_BTN1 = MOUSE_BTN_MASK(0), + MOUSE_BTN2 = MOUSE_BTN_MASK(1), + MOUSE_BTN3 = MOUSE_BTN_MASK(2), + MOUSE_BTN4 = MOUSE_BTN_MASK(3), + MOUSE_BTN5 = MOUSE_BTN_MASK(4), + MOUSE_BTN6 = MOUSE_BTN_MASK(5), + MOUSE_BTN7 = MOUSE_BTN_MASK(6), + MOUSE_BTN8 = MOUSE_BTN_MASK(7) }; /* Consumer Page (0x0C) diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index bc8d36cf3a2e..5ab9e3ff4f56 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -120,19 +120,15 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { # endif HID_RI_USAGE(8, 0x01), // Pointer HID_RI_COLLECTION(8, 0x00), // Physical - // Buttons (5 bits) + // Buttons (8 bits) HID_RI_USAGE_PAGE(8, 0x09), // Button HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1 - HID_RI_USAGE_MAXIMUM(8, 0x05), // Button 5 + HID_RI_USAGE_MAXIMUM(8, 0x08), // Button 8 HID_RI_LOGICAL_MINIMUM(8, 0x00), HID_RI_LOGICAL_MAXIMUM(8, 0x01), - HID_RI_REPORT_COUNT(8, 0x05), + HID_RI_REPORT_COUNT(8, 0x08), HID_RI_REPORT_SIZE(8, 0x01), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), - // Button padding (3 bits) - HID_RI_REPORT_COUNT(8, 0x01), - HID_RI_REPORT_SIZE(8, 0x03), - HID_RI_INPUT(8, HID_IOF_CONSTANT), # ifdef MOUSE_EXTENDED_REPORT // Boot protocol XY ignored in Report protocol