diff options
author | Jack Humbert <jack.humb@gmail.com> | 2017-05-30 12:49:38 -0400 |
---|---|---|
committer | Jack Humbert <jack.humb@gmail.com> | 2017-05-30 12:49:38 -0400 |
commit | cb791cf6cdbcd9fd1291f36f6b1a6840753db97f (patch) | |
tree | 8bad7ccd276d8e83b9a4b288ef683caa57f79b3e | |
parent | 9ecfc2329295b572bc4c5a6f4569f6d0fc2840aa (diff) | |
parent | 4549b0417e7ac99bff36f130f3d7642ec24c2956 (diff) | |
download | qmk_firmware-cb791cf6cdbcd9fd1291f36f6b1a6840753db97f.tar.gz qmk_firmware-cb791cf6cdbcd9fd1291f36f6b1a6840753db97f.zip |
Merge branch 'master' of https://github.com/qmk/qmk_firmware
-rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.cpp | 20 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 2 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 2 |
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 fd6edd42cf..bee6bb2c19 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp @@ -87,6 +87,7 @@ struct queue_item { uint16_t consumer; struct __attribute__((packed)) { int8_t x, y, scroll, pan; + uint8_t buttons; } mousemove; }; }; @@ -699,6 +700,22 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) { strcpy_P(fmtbuf, PSTR("AT+BLEHIDMOUSEMOVE=%d,%d,%d,%d")); snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->mousemove.x, item->mousemove.y, item->mousemove.scroll, item->mousemove.pan); + if (!at_command(cmdbuf, NULL, 0, true, timeout)) { + return false; + } + strcpy_P(cmdbuf, PSTR("AT+BLEHIDMOUSEBUTTON=")); + if (item->mousemove.buttons & MOUSE_BTN1) { + strcat(cmdbuf, "L"); + } + if (item->mousemove.buttons & MOUSE_BTN2) { + strcat(cmdbuf, "R"); + } + if (item->mousemove.buttons & MOUSE_BTN3) { + strcat(cmdbuf, "M"); + } + if (item->mousemove.buttons == 0) { + strcat(cmdbuf, "0"); + } return at_command(cmdbuf, NULL, 0, true, timeout); #endif default: @@ -757,7 +774,7 @@ bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration) { #ifdef MOUSE_ENABLE bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, - int8_t pan) { + int8_t pan, uint8_t buttons) { struct queue_item item; item.queue_type = QTMouseMove; @@ -765,6 +782,7 @@ bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, item.mousemove.y = y; item.mousemove.scroll = scroll; item.mousemove.pan = pan; + item.mousemove.buttons = buttons; while (!send_buf.enqueue(item)) { send_buf_send_one(); diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index b3bab3ca09..036b7d14ea 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); * The parameters are signed and indicate positive of negative direction * change. */ extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, - int8_t pan); + int8_t pan, uint8_t buttons); #endif /* 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 3c4ad4b4d2..e3f8724e81 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) if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { #ifdef MODULE_ADAFRUIT_BLE // FIXME: mouse buttons - adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); + adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); #else bluefruit_serial_send(0xFD); bluefruit_serial_send(0x00); |