Skip to content

Commit

Permalink
Merge pull request qmk#1342 from priyadi/adafruit-mouse-buttons
Browse files Browse the repository at this point in the history
Adafruit Feather BLE / BLE Friend mouse buttons support
  • Loading branch information
jackhumbert authored May 30, 2017
2 parents 3a1a7d6 + f0fc2db commit 4549b04
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion tmk_core/protocol/lufa/adafruit_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct queue_item {
uint16_t consumer;
struct __attribute__((packed)) {
int8_t x, y, scroll, pan;
uint8_t buttons;
} mousemove;
};
};
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -757,14 +774,15 @@ 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;
item.mousemove.x = x;
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();
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/protocol/lufa/adafruit_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4549b04

Please sign in to comment.