aboutsummaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
authorfauxpark <fauxpark@gmail.com>2021-01-15 18:34:12 +1100
committerfauxpark <fauxpark@gmail.com>2021-01-15 18:34:12 +1100
commitca7da3866d8a7a80e5c932ebac40fe0061d00c7f (patch)
tree5686046b1f73ed22253fc74bd4851c77e638a615 /tmk_core
parentab375d3d075c105f09a1ddd0e155f178225518bc (diff)
parent8cf5f72aadc7f287b2716a174730a4b2cc26c900 (diff)
downloadqmk_firmware-ca7da3866d8a7a80e5c932ebac40fe0061d00c7f.tar.gz
qmk_firmware-ca7da3866d8a7a80e5c932ebac40fe0061d00c7f.zip
Merge remote-tracking branch 'upstream/master' into develop
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h2
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.cpp45
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.h11
-rw-r--r--tmk_core/protocol/lufa/lufa.c2
4 files changed, 27 insertions, 33 deletions
diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
index 65339bffe..09de47546 100644
--- a/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
+++ b/tmk_core/protocol/arm_atsam/usb/udi_device_epsize.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
21#define KEYBOARD_EPSIZE 8 21#define KEYBOARD_EPSIZE 8
22#define MOUSE_EPSIZE 8 22#define MOUSE_EPSIZE 8
23#define EXTRAKEY_EPSIZE 8 23#define EXTRAKEY_EPSIZE 8
24#define RAW_EPSIZE 64 24#define RAW_EPSIZE 32
25#define CONSOLE_EPSIZE 32 25#define CONSOLE_EPSIZE 32
26#define NKRO_EPSIZE 32 26#define NKRO_EPSIZE 32
27#define MIDI_STREAM_EPSIZE 64 27#define MIDI_STREAM_EPSIZE 64
diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp
index 79b35fca3..3f2cc3573 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.cpp
+++ b/tmk_core/protocol/lufa/adafruit_ble.cpp
@@ -11,6 +11,7 @@
11#include "spi_master.h" 11#include "spi_master.h"
12#include "wait.h" 12#include "wait.h"
13#include "analog.h" 13#include "analog.h"
14#include "progmem.h"
14 15
15// These are the pin assignments for the 32u4 boards. 16// These are the pin assignments for the 32u4 boards.
16// You may define them to something else in your config.h 17// You may define them to something else in your config.h
@@ -36,10 +37,8 @@
36#define SAMPLE_BATTERY 37#define SAMPLE_BATTERY
37#define ConnectionUpdateInterval 1000 /* milliseconds */ 38#define ConnectionUpdateInterval 1000 /* milliseconds */
38 39
39#ifdef SAMPLE_BATTERY 40#ifndef BATTERY_LEVEL_PIN
40# ifndef BATTERY_LEVEL_PIN 41# define BATTERY_LEVEL_PIN B5
41# define BATTERY_LEVEL_PIN B5
42# endif
43#endif 42#endif
44 43
45static struct { 44static struct {
@@ -118,15 +117,15 @@ enum sdep_type {
118 SdepResponse = 0x20, 117 SdepResponse = 0x20,
119 SdepAlert = 0x40, 118 SdepAlert = 0x40,
120 SdepError = 0x80, 119 SdepError = 0x80,
121 SdepSlaveNotReady = 0xfe, // Try again later 120 SdepSlaveNotReady = 0xFE, // Try again later
122 SdepSlaveOverflow = 0xff, // You read more data than is available 121 SdepSlaveOverflow = 0xFF, // You read more data than is available
123}; 122};
124 123
125enum ble_cmd { 124enum ble_cmd {
126 BleInitialize = 0xbeef, 125 BleInitialize = 0xBEEF,
127 BleAtWrapper = 0x0a00, 126 BleAtWrapper = 0x0A00,
128 BleUartTx = 0x0a01, 127 BleUartTx = 0x0A01,
129 BleUartRx = 0x0a02, 128 BleUartRx = 0x0A02,
130}; 129};
131 130
132enum ble_system_event_bits { 131enum ble_system_event_bits {
@@ -176,7 +175,7 @@ static bool sdep_send_pkt(const struct sdep_msg *msg, uint16_t timeout) {
176 175
177static inline void sdep_build_pkt(struct sdep_msg *msg, uint16_t command, const uint8_t *payload, uint8_t len, bool moredata) { 176static inline void sdep_build_pkt(struct sdep_msg *msg, uint16_t command, const uint8_t *payload, uint8_t len, bool moredata) {
178 msg->type = SdepCommand; 177 msg->type = SdepCommand;
179 msg->cmd_low = command & 0xff; 178 msg->cmd_low = command & 0xFF;
180 msg->cmd_high = command >> 8; 179 msg->cmd_high = command >> 8;
181 msg->len = len; 180 msg->len = len;
182 msg->more = (moredata && len == SdepMaxPayload) ? 1 : 0; 181 msg->more = (moredata && len == SdepMaxPayload) ? 1 : 0;
@@ -407,11 +406,11 @@ static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbo
407 } 406 }
408 407
409 if (resp == NULL) { 408 if (resp == NULL) {
410 auto now = timer_read(); 409 uint16_t now = timer_read();
411 while (!resp_buf.enqueue(now)) { 410 while (!resp_buf.enqueue(now)) {
412 resp_buf_read_one(false); 411 resp_buf_read_one(false);
413 } 412 }
414 auto later = timer_read(); 413 uint16_t later = timer_read();
415 if (TIMER_DIFF_16(later, now) > 0) { 414 if (TIMER_DIFF_16(later, now) > 0) {
416 dprintf("waited %dms for resp_buf\n", TIMER_DIFF_16(later, now)); 415 dprintf("waited %dms for resp_buf\n", TIMER_DIFF_16(later, now));
417 } 416 }
@@ -422,7 +421,7 @@ static bool at_command(const char *cmd, char *resp, uint16_t resplen, bool verbo
422} 421}
423 422
424bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) { 423bool at_command_P(const char *cmd, char *resp, uint16_t resplen, bool verbose) {
425 auto cmdbuf = (char *)alloca(strlen_P(cmd) + 1); 424 char *cmdbuf = (char *)alloca(strlen_P(cmd) + 1);
426 strcpy_P(cmdbuf, cmd); 425 strcpy_P(cmdbuf, cmd);
427 return at_command(cmdbuf, resp, resplen, verbose); 426 return at_command(cmdbuf, resp, resplen, verbose);
428} 427}
@@ -484,9 +483,9 @@ fail:
484static void set_connected(bool connected) { 483static void set_connected(bool connected) {
485 if (connected != state.is_connected) { 484 if (connected != state.is_connected) {
486 if (connected) { 485 if (connected) {
487 print("****** BLE CONNECT!!!!\n"); 486 dprint("BLE connected\n");
488 } else { 487 } else {
489 print("****** BLE DISCONNECT!!!!\n"); 488 dprint("BLE disconnected\n");
490 } 489 }
491 state.is_connected = connected; 490 state.is_connected = connected;
492 491
@@ -612,7 +611,7 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) {
612 } 611 }
613} 612}
614 613
615bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) { 614void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys) {
616 struct queue_item item; 615 struct queue_item item;
617 bool didWait = false; 616 bool didWait = false;
618 617
@@ -638,30 +637,27 @@ bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nk
638 } 637 }
639 638
640 if (nkeys <= 6) { 639 if (nkeys <= 6) {
641 return true; 640 return;
642 } 641 }
643 642
644 nkeys -= 6; 643 nkeys -= 6;
645 keys += 6; 644 keys += 6;
646 } 645 }
647
648 return true;
649} 646}
650 647
651bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration) { 648void adafruit_ble_send_consumer_key(uint16_t usage) {
652 struct queue_item item; 649 struct queue_item item;
653 650
654 item.queue_type = QTConsumer; 651 item.queue_type = QTConsumer;
655 item.consumer = keycode; 652 item.consumer = usage;
656 653
657 while (!send_buf.enqueue(item)) { 654 while (!send_buf.enqueue(item)) {
658 send_buf_send_one(); 655 send_buf_send_one();
659 } 656 }
660 return true;
661} 657}
662 658
663#ifdef MOUSE_ENABLE 659#ifdef MOUSE_ENABLE
664bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) { 660void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) {
665 struct queue_item item; 661 struct queue_item item;
666 662
667 item.queue_type = QTMouseMove; 663 item.queue_type = QTMouseMove;
@@ -674,7 +670,6 @@ bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan,
674 while (!send_buf.enqueue(item)) { 670 while (!send_buf.enqueue(item)) {
675 send_buf_send_one(); 671 send_buf_send_one();
676 } 672 }
677 return true;
678} 673}
679#endif 674#endif
680 675
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h
index 9dfc9b435..b43e0771d 100644
--- a/tmk_core/protocol/lufa/adafruit_ble.h
+++ b/tmk_core/protocol/lufa/adafruit_ble.h
@@ -10,7 +10,6 @@
10#include <string.h> 10#include <string.h>
11 11
12#include "config_common.h" 12#include "config_common.h"
13#include "progmem.h"
14 13
15#ifdef __cplusplus 14#ifdef __cplusplus
16extern "C" { 15extern "C" {
@@ -35,17 +34,17 @@ extern void adafruit_ble_task(void);
35 * this set of keys. 34 * this set of keys.
36 * Also sends a key release indicator, so that the keys do not remain 35 * Also sends a key release indicator, so that the keys do not remain
37 * held down. */ 36 * held down. */
38extern bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys); 37extern void adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uint8_t nkeys);
39 38
40/* Send a consumer keycode, holding it down for the specified duration 39/* Send a consumer usage.
41 * (milliseconds) */ 40 * (milliseconds) */
42extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); 41extern void adafruit_ble_send_consumer_key(uint16_t usage);
43 42
44#ifdef MOUSE_ENABLE 43#ifdef MOUSE_ENABLE
45/* Send a mouse/wheel movement report. 44/* Send a mouse/wheel movement report.
46 * The parameters are signed and indicate positive of negative direction 45 * The parameters are signed and indicate positive or negative direction
47 * change. */ 46 * change. */
48extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); 47extern void adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons);
49#endif 48#endif
50 49
51/* Compute battery voltage by reading an analog pin. 50/* 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 8fd4be8af..623aa33ff 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -809,7 +809,7 @@ static void send_consumer(uint16_t data) {
809 809
810 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { 810 if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
811# ifdef MODULE_ADAFRUIT_BLE 811# ifdef MODULE_ADAFRUIT_BLE
812 adafruit_ble_send_consumer_key(data, 0); 812 adafruit_ble_send_consumer_key(data);
813# elif MODULE_RN42 813# elif MODULE_RN42
814 static uint16_t last_data = 0; 814 static uint16_t last_data = 0;
815 if (data == last_data) return; 815 if (data == last_data) return;