aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-05-30 12:10:45 -0400
committerGitHub <noreply@github.com>2017-05-30 12:10:45 -0400
commit4549b0417e7ac99bff36f130f3d7642ec24c2956 (patch)
treebc1bfb3b2bf95a52999290d24d9f4050a82888cd /tmk_core
parent3a1a7d647283681be4681990619061249717a99a (diff)
parentf0fc2db4e291dc7584c3cb81994ae14b9749fc62 (diff)
downloadqmk_firmware-4549b0417e7ac99bff36f130f3d7642ec24c2956.tar.gz
qmk_firmware-4549b0417e7ac99bff36f130f3d7642ec24c2956.zip
Merge pull request #1342 from priyadi/adafruit-mouse-buttons
Adafruit Feather BLE / BLE Friend mouse buttons support
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.cpp20
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.h2
-rw-r--r--tmk_core/protocol/lufa/lufa.c2
3 files changed, 21 insertions, 3 deletions
diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp
index fd6edd42c..bee6bb2c1 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.cpp
+++ b/tmk_core/protocol/lufa/adafruit_ble.cpp
@@ -87,6 +87,7 @@ struct queue_item {
87 uint16_t consumer; 87 uint16_t consumer;
88 struct __attribute__((packed)) { 88 struct __attribute__((packed)) {
89 int8_t x, y, scroll, pan; 89 int8_t x, y, scroll, pan;
90 uint8_t buttons;
90 } mousemove; 91 } mousemove;
91 }; 92 };
92}; 93};
@@ -699,6 +700,22 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
699 strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d")); 700 strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d"));
700 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, 701 snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x,
701 item->mousemove.y, item->mousemove.scroll, item->mousemove.pan); 702 item->mousemove.y, item->mousemove.scroll, item->mousemove.pan);
703 if (!at_command(cmdbuf, NULL, 0, true, timeout)) {
704 return false;
705 }
706 strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON="));
707 if (item->mousemove.buttons & MOUSE_BTN1) {
708 strcat(cmdbuf, "L");
709 }
710 if (item->mousemove.buttons & MOUSE_BTN2) {
711 strcat(cmdbuf, "R");
712 }
713 if (item->mousemove.buttons & MOUSE_BTN3) {
714 strcat(cmdbuf, "M");
715 }
716 if (item->mousemove.buttons == 0) {
717 strcat(cmdbuf, "0");
718 }
702 return at_command(cmdbuf, NULL, 0, true, timeout); 719 return at_command(cmdbuf, NULL, 0, true, timeout);
703#endif 720#endif
704 default: 721 default:
@@ -757,7 +774,7 @@ bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration) {
757 774
758#ifdef MOUSE_ENABLE 775#ifdef MOUSE_ENABLE
759bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, 776bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll,
760 int8_t pan) { 777 int8_t pan, uint8_t buttons) {
761 struct queue_item item; 778 struct queue_item item;
762 779
763 item.queue_type = QTMouseMove; 780 item.queue_type = QTMouseMove;
@@ -765,6 +782,7 @@ bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll,
765 item.mousemove.y = y; 782 item.mousemove.y = y;
766 item.mousemove.scroll = scroll; 783 item.mousemove.scroll = scroll;
767 item.mousemove.pan = pan; 784 item.mousemove.pan = pan;
785 item.mousemove.buttons = buttons;
768 786
769 while (!send_buf.enqueue(item)) { 787 while (!send_buf.enqueue(item)) {
770 send_buf_send_one(); 788 send_buf_send_one();
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h
index b3bab3ca0..036b7d14e 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.h
+++ b/tmk_core/protocol/lufa/adafruit_ble.h
@@ -43,7 +43,7 @@ extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration);
43 * The parameters are signed and indicate positive of negative direction 43 * The parameters are signed and indicate positive of negative direction
44 * change. */ 44 * change. */
45extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, 45extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll,
46 int8_t pan); 46 int8_t pan, uint8_t buttons);
47#endif 47#endif
48 48
49/* Compute battery voltage by reading an analog pin. 49/* Compute battery voltage by reading an analog pin.
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 3c4ad4b4d..e3f8724e8 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -669,7 +669,7 @@ static void send_mouse(report_mouse_t *report)
669 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { 669 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
670 #ifdef MODULE_ADAFRUIT_BLE 670 #ifdef MODULE_ADAFRUIT_BLE
671 // FIXME: mouse buttons 671 // FIXME: mouse buttons
672 adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); 672 adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons);
673 #else 673 #else
674 bluefruit_serial_send(0xFD); 674 bluefruit_serial_send(0xFD);
675 bluefruit_serial_send(0x00); 675 bluefruit_serial_send(0x00);