aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_mouse_keys.md3
-rw-r--r--docs/feature_pointing_device.md2
-rw-r--r--docs/ja/feature_mouse_keys.md3
-rw-r--r--tmk_core/common/action.c18
-rw-r--r--tmk_core/common/keycode.h14
-rw-r--r--tmk_core/common/mousekey.c48
-rw-r--r--tmk_core/common/report.h5
-rw-r--r--tmk_core/protocol/usb_descriptor.c12
-rw-r--r--tmk_core/protocol/vusb/vusb.c10
9 files changed, 54 insertions, 61 deletions
diff --git a/docs/feature_mouse_keys.md b/docs/feature_mouse_keys.md
index a0d02416f..8e2a3a4cd 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
29|`KC_MS_BTN3` |`KC_BTN3`|Press button 3 | 29|`KC_MS_BTN3` |`KC_BTN3`|Press button 3 |
30|`KC_MS_BTN4` |`KC_BTN4`|Press button 4 | 30|`KC_MS_BTN4` |`KC_BTN4`|Press button 4 |
31|`KC_MS_BTN5` |`KC_BTN5`|Press button 5 | 31|`KC_MS_BTN5` |`KC_BTN5`|Press button 5 |
32|`KC_MS_BTN6` |`KC_BTN6`|Press button 6 |
33|`KC_MS_BTN7` |`KC_BTN7`|Press button 7 |
34|`KC_MS_BTN8` |`KC_BTN8`|Press button 8 |
32|`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up | 35|`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up |
33|`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down | 36|`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down |
34|`KC_MS_WH_LEFT` |`KC_WH_L`|Move wheel left | 37|`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 c9309d697..c6d3560f3 100644
--- a/docs/feature_pointing_device.md
+++ b/docs/feature_pointing_device.md
@@ -19,7 +19,7 @@ Keep in mind that a report_mouse_t (here "mouseReport") has the following proper
19* `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. 19* `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.
20* `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). 20* `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).
21* `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). 21* `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).
22* `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. 22* `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.
23 23
24Once you have made the necessary changes to the mouse report, you need to send it: 24Once you have made the necessary changes to the mouse report, you need to send it:
25 25
diff --git a/docs/ja/feature_mouse_keys.md b/docs/ja/feature_mouse_keys.md
index 74b09e939..e4fa9dfb4 100644
--- a/docs/ja/feature_mouse_keys.md
+++ b/docs/ja/feature_mouse_keys.md
@@ -34,6 +34,9 @@ MOUSEKEY_ENABLE = yes
34| `KC_MS_BTN3` | `KC_BTN3` | ボタン3を押す | 34| `KC_MS_BTN3` | `KC_BTN3` | ボタン3を押す |
35| `KC_MS_BTN4` | `KC_BTN4` | ボタン4を押す | 35| `KC_MS_BTN4` | `KC_BTN4` | ボタン4を押す |
36| `KC_MS_BTN5` | `KC_BTN5` | ボタン5を押す | 36| `KC_MS_BTN5` | `KC_BTN5` | ボタン5を押す |
37| `KC_MS_BTN6` | `KC_BTN6` | ボタン6を押す |
38| `KC_MS_BTN7` | `KC_BTN7` | ボタン7を押す |
39| `KC_MS_BTN8` | `KC_BTN8` | ボタン8を押す |
37| `KC_MS_WH_UP` | `KC_WH_U` | ホイールを向こう側に回転 | 40| `KC_MS_WH_UP` | `KC_WH_U` | ホイールを向こう側に回転 |
38| `KC_MS_WH_DOWN` | `KC_WH_D` | ホイールを手前側に回転 | 41| `KC_MS_WH_DOWN` | `KC_WH_D` | ホイールを手前側に回転 |
39| `KC_MS_WH_LEFT` | `KC_WH_L` | ホイールを左に倒す | 42| `KC_MS_WH_LEFT` | `KC_WH_L` | ホイールを左に倒す |
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index a7432bae5..a3830abbf 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -443,6 +443,15 @@ void process_action(keyrecord_t *record, action_t action) {
443 case KC_MS_BTN5: 443 case KC_MS_BTN5:
444 register_button(true, MOUSE_BTN5); 444 register_button(true, MOUSE_BTN5);
445 break; 445 break;
446 case KC_MS_BTN6:
447 register_button(true, MOUSE_BTN6);
448 break;
449 case KC_MS_BTN7:
450 register_button(true, MOUSE_BTN7);
451 break;
452 case KC_MS_BTN8:
453 register_button(true, MOUSE_BTN8);
454 break;
446# endif 455# endif
447 default: 456 default:
448 mousekey_send(); 457 mousekey_send();
@@ -469,6 +478,15 @@ void process_action(keyrecord_t *record, action_t action) {
469 case KC_MS_BTN5: 478 case KC_MS_BTN5:
470 register_button(false, MOUSE_BTN5); 479 register_button(false, MOUSE_BTN5);
471 break; 480 break;
481 case KC_MS_BTN6:
482 register_button(false, MOUSE_BTN6);
483 break;
484 case KC_MS_BTN7:
485 register_button(false, MOUSE_BTN7);
486 break;
487 case KC_MS_BTN8:
488 register_button(false, MOUSE_BTN8);
489 break;
472# endif 490# endif
473 default: 491 default:
474 mousekey_send(); 492 mousekey_send();
diff --git a/tmk_core/common/keycode.h b/tmk_core/common/keycode.h
index d35e44d8d..efad92b23 100644
--- a/tmk_core/common/keycode.h
+++ b/tmk_core/common/keycode.h
@@ -39,7 +39,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39 39
40#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2) 40#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
41#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT) 41#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
42#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5) 42#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN8)
43#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT) 43#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
44#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2) 44#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
45 45
@@ -205,6 +205,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
205#define KC_BTN3 KC_MS_BTN3 205#define KC_BTN3 KC_MS_BTN3
206#define KC_BTN4 KC_MS_BTN4 206#define KC_BTN4 KC_MS_BTN4
207#define KC_BTN5 KC_MS_BTN5 207#define KC_BTN5 KC_MS_BTN5
208#define KC_BTN6 KC_MS_BTN6
209#define KC_BTN7 KC_MS_BTN7
210#define KC_BTN8 KC_MS_BTN8
208#define KC_WH_U KC_MS_WH_UP 211#define KC_WH_U KC_MS_WH_UP
209#define KC_WH_D KC_MS_WH_DOWN 212#define KC_WH_D KC_MS_WH_DOWN
210#define KC_WH_L KC_MS_WH_LEFT 213#define KC_WH_L KC_MS_WH_LEFT
@@ -521,15 +524,18 @@ enum internal_special_keycodes {
521 524
522enum mouse_keys { 525enum mouse_keys {
523 /* Mouse Buttons */ 526 /* Mouse Buttons */
524 KC_MS_UP = 0xF0, 527 KC_MS_UP = 0xED,
525 KC_MS_DOWN, 528 KC_MS_DOWN,
526 KC_MS_LEFT, 529 KC_MS_LEFT,
527 KC_MS_RIGHT, 530 KC_MS_RIGHT, // 0xF0
528 KC_MS_BTN1, 531 KC_MS_BTN1,
529 KC_MS_BTN2, 532 KC_MS_BTN2,
530 KC_MS_BTN3, 533 KC_MS_BTN3,
531 KC_MS_BTN4, 534 KC_MS_BTN4,
532 KC_MS_BTN5, 535 KC_MS_BTN5,
536 KC_MS_BTN6,
537 KC_MS_BTN7,
538 KC_MS_BTN8,
533 539
534 /* Mouse Wheel */ 540 /* Mouse Wheel */
535 KC_MS_WH_UP, 541 KC_MS_WH_UP,
@@ -540,5 +546,5 @@ enum mouse_keys {
540 /* Acceleration */ 546 /* Acceleration */
541 KC_MS_ACCEL0, 547 KC_MS_ACCEL0,
542 KC_MS_ACCEL1, 548 KC_MS_ACCEL1,
543 KC_MS_ACCEL2 549 KC_MS_ACCEL2 // 0xFF
544}; 550};
diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c
index 6c9df6723..d8cf63f77 100644
--- a/tmk_core/common/mousekey.c
+++ b/tmk_core/common/mousekey.c
@@ -278,16 +278,8 @@ void mousekey_on(uint8_t code) {
278 mouse_report.h = wheel_unit() * -1; 278 mouse_report.h = wheel_unit() * -1;
279 else if (code == KC_MS_WH_RIGHT) 279 else if (code == KC_MS_WH_RIGHT)
280 mouse_report.h = wheel_unit(); 280 mouse_report.h = wheel_unit();
281 else if (code == KC_MS_BTN1) 281 else if (IS_MOUSEKEY_BUTTON(code))
282 mouse_report.buttons |= MOUSE_BTN1; 282 mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
283 else if (code == KC_MS_BTN2)
284 mouse_report.buttons |= MOUSE_BTN2;
285 else if (code == KC_MS_BTN3)
286 mouse_report.buttons |= MOUSE_BTN3;
287 else if (code == KC_MS_BTN4)
288 mouse_report.buttons |= MOUSE_BTN4;
289 else if (code == KC_MS_BTN5)
290 mouse_report.buttons |= MOUSE_BTN5;
291 else if (code == KC_MS_ACCEL0) 283 else if (code == KC_MS_ACCEL0)
292 mousekey_accel |= (1 << 0); 284 mousekey_accel |= (1 << 0);
293 else if (code == KC_MS_ACCEL1) 285 else if (code == KC_MS_ACCEL1)
@@ -313,16 +305,8 @@ void mousekey_off(uint8_t code) {
313 mouse_report.h = 0; 305 mouse_report.h = 0;
314 else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) 306 else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
315 mouse_report.h = 0; 307 mouse_report.h = 0;
316 else if (code == KC_MS_BTN1) 308 else if (IS_MOUSEKEY_BUTTON(code))
317 mouse_report.buttons &= ~MOUSE_BTN1; 309 mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
318 else if (code == KC_MS_BTN2)
319 mouse_report.buttons &= ~MOUSE_BTN2;
320 else if (code == KC_MS_BTN3)
321 mouse_report.buttons &= ~MOUSE_BTN3;
322 else if (code == KC_MS_BTN4)
323 mouse_report.buttons &= ~MOUSE_BTN4;
324 else if (code == KC_MS_BTN5)
325 mouse_report.buttons &= ~MOUSE_BTN5;
326 else if (code == KC_MS_ACCEL0) 310 else if (code == KC_MS_ACCEL0)
327 mousekey_accel &= ~(1 << 0); 311 mousekey_accel &= ~(1 << 0);
328 else if (code == KC_MS_ACCEL1) 312 else if (code == KC_MS_ACCEL1)
@@ -423,16 +407,8 @@ void mousekey_on(uint8_t code) {
423 mouse_report.h = w_offset * -1; 407 mouse_report.h = w_offset * -1;
424 else if (code == KC_MS_WH_RIGHT) 408 else if (code == KC_MS_WH_RIGHT)
425 mouse_report.h = w_offset; 409 mouse_report.h = w_offset;
426 else if (code == KC_MS_BTN1) 410 else if (IS_MOUSEKEY_BUTTON(code))
427 mouse_report.buttons |= MOUSE_BTN1; 411 mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
428 else if (code == KC_MS_BTN2)
429 mouse_report.buttons |= MOUSE_BTN2;
430 else if (code == KC_MS_BTN3)
431 mouse_report.buttons |= MOUSE_BTN3;
432 else if (code == KC_MS_BTN4)
433 mouse_report.buttons |= MOUSE_BTN4;
434 else if (code == KC_MS_BTN5)
435 mouse_report.buttons |= MOUSE_BTN5;
436 else if (code == KC_MS_ACCEL0) 412 else if (code == KC_MS_ACCEL0)
437 mk_speed = mkspd_0; 413 mk_speed = mkspd_0;
438 else if (code == KC_MS_ACCEL1) 414 else if (code == KC_MS_ACCEL1)
@@ -462,16 +438,8 @@ void mousekey_off(uint8_t code) {
462 mouse_report.h = 0; 438 mouse_report.h = 0;
463 else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) 439 else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
464 mouse_report.h = 0; 440 mouse_report.h = 0;
465 else if (code == KC_MS_BTN1) 441 else if (IS_MOUSEKEY_BUTTON(code))
466 mouse_report.buttons &= ~MOUSE_BTN1; 442 mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
467 else if (code == KC_MS_BTN2)
468 mouse_report.buttons &= ~MOUSE_BTN2;
469 else if (code == KC_MS_BTN3)
470 mouse_report.buttons &= ~MOUSE_BTN3;
471 else if (code == KC_MS_BTN4)
472 mouse_report.buttons &= ~MOUSE_BTN4;
473 else if (code == KC_MS_BTN5)
474 mouse_report.buttons &= ~MOUSE_BTN5;
475# ifdef MK_MOMENTARY_ACCEL 443# ifdef MK_MOMENTARY_ACCEL
476 else if (code == KC_MS_ACCEL0) 444 else if (code == KC_MS_ACCEL0)
477 mk_speed = mkspd_DEFAULT; 445 mk_speed = mkspd_DEFAULT;
diff --git a/tmk_core/common/report.h b/tmk_core/common/report.h
index 5d7c5b3b2..bcf5cab38 100644
--- a/tmk_core/common/report.h
+++ b/tmk_core/common/report.h
@@ -39,7 +39,10 @@ enum mouse_buttons {
39 MOUSE_BTN2 = (1 << 1), 39 MOUSE_BTN2 = (1 << 1),
40 MOUSE_BTN3 = (1 << 2), 40 MOUSE_BTN3 = (1 << 2),
41 MOUSE_BTN4 = (1 << 3), 41 MOUSE_BTN4 = (1 << 3),
42 MOUSE_BTN5 = (1 << 4) 42 MOUSE_BTN5 = (1 << 4),
43 MOUSE_BTN6 = (1 << 5),
44 MOUSE_BTN7 = (1 << 6),
45 MOUSE_BTN8 = (1 << 7)
43}; 46};
44 47
45/* Consumer Page (0x0C) 48/* Consumer Page (0x0C)
diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c
index 7ea4b2e37..ba7760f28 100644
--- a/tmk_core/protocol/usb_descriptor.c
+++ b/tmk_core/protocol/usb_descriptor.c
@@ -116,19 +116,15 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = {
116# endif 116# endif
117 HID_RI_USAGE(8, 0x01), // Pointer 117 HID_RI_USAGE(8, 0x01), // Pointer
118 HID_RI_COLLECTION(8, 0x00), // Physical 118 HID_RI_COLLECTION(8, 0x00), // Physical
119 // Buttons (5 bits) 119 // Buttons (8 bits)
120 HID_RI_USAGE_PAGE(8, 0x09), // Button 120 HID_RI_USAGE_PAGE(8, 0x09), // Button
121 HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1 121 HID_RI_USAGE_MINIMUM(8, 0x01), // Button 1
122 HID_RI_USAGE_MAXIMUM(8, 0x05), // Button 5 122 HID_RI_USAGE_MAXIMUM(8, 0x08), // Button 8
123 HID_RI_LOGICAL_MINIMUM(8, 0x00), 123 HID_RI_LOGICAL_MINIMUM(8, 0x00),
124 HID_RI_LOGICAL_MAXIMUM(8, 0x01), 124 HID_RI_LOGICAL_MAXIMUM(8, 0x01),
125 HID_RI_REPORT_COUNT(8, 0x05), 125 HID_RI_REPORT_COUNT(8, 0x08),
126 HID_RI_REPORT_SIZE(8, 0x01), 126 HID_RI_REPORT_SIZE(8, 0x01),
127 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), 127 HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
128 // Button padding (3 bits)
129 HID_RI_REPORT_COUNT(8, 0x01),
130 HID_RI_REPORT_SIZE(8, 0x03),
131 HID_RI_INPUT(8, HID_IOF_CONSTANT),
132 128
133 // X/Y position (2 bytes) 129 // X/Y position (2 bytes)
134 HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop 130 HID_RI_USAGE_PAGE(8, 0x01), // Generic Desktop
@@ -356,7 +352,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
356 .Type = DTYPE_Device 352 .Type = DTYPE_Device
357 }, 353 },
358 .USBSpecification = VERSION_BCD(1, 1, 0), 354 .USBSpecification = VERSION_BCD(1, 1, 0),
359 355
360#if VIRTSER_ENABLE 356#if VIRTSER_ENABLE
361 .Class = USB_CSCP_IADDeviceClass, 357 .Class = USB_CSCP_IADDeviceClass,
362 .SubClass = USB_CSCP_IADDeviceSubclass, 358 .SubClass = USB_CSCP_IADDeviceSubclass,
diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c
index a422903cc..9362fbde7 100644
--- a/tmk_core/protocol/vusb/vusb.c
+++ b/tmk_core/protocol/vusb/vusb.c
@@ -444,19 +444,15 @@ const PROGMEM uchar shared_hid_report[] = {
444 0x85, REPORT_ID_MOUSE, // Report ID 444 0x85, REPORT_ID_MOUSE, // Report ID
445 0x09, 0x01, // Usage (Pointer) 445 0x09, 0x01, // Usage (Pointer)
446 0xA1, 0x00, // Collection (Physical) 446 0xA1, 0x00, // Collection (Physical)
447 // Buttons (5 bits) 447 // Buttons (8 bits)
448 0x05, 0x09, // Usage Page (Button) 448 0x05, 0x09, // Usage Page (Button)
449 0x19, 0x01, // Usage Minimum (Button 1) 449 0x19, 0x01, // Usage Minimum (Button 1)
450 0x29, 0x05, // Usage Maximum (Button 5) 450 0x29, 0x08, // Usage Maximum (Button 8)
451 0x15, 0x00, // Logical Minimum (0) 451 0x15, 0x00, // Logical Minimum (0)
452 0x25, 0x01, // Logical Maximum (1) 452 0x25, 0x01, // Logical Maximum (1)
453 0x95, 0x05, // Report Count (5) 453 0x95, 0x08, // Report Count (8)
454 0x75, 0x01, // Report Size (1) 454 0x75, 0x01, // Report Size (1)
455 0x81, 0x02, // Input (Data, Variable, Absolute) 455 0x81, 0x02, // Input (Data, Variable, Absolute)
456 // Button padding (3 bits)
457 0x95, 0x01, // Report Count (1)
458 0x75, 0x03, // Report Size (3)
459 0x81, 0x03, // Input (Constant)
460 456
461 // X/Y position (2 bytes) 457 // X/Y position (2 bytes)
462 0x05, 0x01, // Usage Page (Generic Desktop) 458 0x05, 0x01, // Usage Page (Generic Desktop)