From 0f596881b36587a298568192078f9b467c51c109 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 25 Aug 2020 19:03:45 +1000 Subject: Remove support for Adafruit EZ-Key (#10103) * Remove support for Adafruit EZ-Key * Update docs/ja/feature_bluetooth.md Co-authored-by: Takeshi ISHII <2170248+mtei@users.noreply.github.com> Co-authored-by: Takeshi ISHII <2170248+mtei@users.noreply.github.com> --- tmk_core/protocol/lufa.mk | 12 +---- tmk_core/protocol/lufa/bluetooth.c | 38 -------------- tmk_core/protocol/lufa/bluetooth.h | 96 --------------------------------- tmk_core/protocol/lufa/lufa.c | 105 ++++++++++++++++++++++--------------- 4 files changed, 64 insertions(+), 187 deletions(-) delete mode 100644 tmk_core/protocol/lufa/bluetooth.c delete mode 100644 tmk_core/protocol/lufa/bluetooth.h (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 9bc972c266..1cc1fa04e5 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -23,8 +23,7 @@ ifeq ($(strip $(MIDI_ENABLE)), yes) endif ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) - LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - outputselect.c \ + LUFA_SRC += outputselect.c \ $(TMK_DIR)/protocol/serial_uart.c endif @@ -35,15 +34,8 @@ ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) $(LUFA_DIR)/adafruit_ble.cpp endif -ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) - LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - outputselect.c \ - $(TMK_DIR)/protocol/serial_uart.c -endif - ifeq ($(strip $(BLUETOOTH)), RN42) - LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ - outputselect.c \ + LUFA_SRC += outputselect.c \ $(TMK_DIR)/protocol/serial_uart.c endif diff --git a/tmk_core/protocol/lufa/bluetooth.c b/tmk_core/protocol/lufa/bluetooth.c deleted file mode 100644 index 5eb52860b1..0000000000 --- a/tmk_core/protocol/lufa/bluetooth.c +++ /dev/null @@ -1,38 +0,0 @@ -/* -Bluefruit Protocol for TMK firmware -Author: Benjamin Gould, 2013 - Jack Humbert, 2015 -Based on code Copyright 2011 Jun Wako -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include -#include "report.h" -#include "print.h" -#include "debug.h" -#include "bluetooth.h" - -void bluefruit_keyboard_print_report(report_keyboard_t *report) { - if (!debug_keyboard) return; - dprintf("keys: "); - for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - debug_hex8(report->keys[i]); - dprintf(" "); - } - dprintf(" mods: "); - debug_hex8(report->mods); - dprintf(" reserved: "); - debug_hex8(report->reserved); - dprintf("\n"); -} - -void bluefruit_serial_send(uint8_t data) { serial_send(data); } \ No newline at end of file diff --git a/tmk_core/protocol/lufa/bluetooth.h b/tmk_core/protocol/lufa/bluetooth.h deleted file mode 100644 index 67f031439e..0000000000 --- a/tmk_core/protocol/lufa/bluetooth.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -Bluefruit Protocol for TMK firmware -Author: Benjamin Gould, 2013 - Jack Humbert, 2015 -Based on code Copyright 2011 Jun Wako -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#pragma once - -#include "../serial.h" - -void bluefruit_serial_send(uint8_t data); - -// https://learn.adafruit.com/introducing-bluefruit-ez-key-diy-bluetooth-hid-keyboard/sending-keys-via-serial#raw-hid-consumer-reports-8-14 -static inline uint16_t CONSUMER2BLUEFRUIT(uint16_t usage) { - switch (usage) { - case AC_HOME: - return 0x0001; - case AL_KEYBOARD_LAYOUT: - return 0x0002; - case AC_SEARCH: - return 0x0004; - case SNAPSHOT: - return 0x0008; - case AUDIO_VOL_UP: - return 0x0010; - case AUDIO_VOL_DOWN: - return 0x0020; - case TRANSPORT_PLAY_PAUSE: - return 0x0040; - case TRANSPORT_FAST_FORWARD: - return 0x0080; - case TRANSPORT_REWIND: - return 0x0100; - case TRANSPORT_NEXT_TRACK: - return 0x0200; - case TRANSPORT_PREV_TRACK: - return 0x0400; - case TRANSPORT_RANDOM_PLAY: - return 0x0800; - case TRANSPORT_STOP: - return 0x1000; - default: - return 0; - } -} - -// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734 -static inline uint16_t CONSUMER2RN42(uint16_t usage) { - switch (usage) { - case AC_HOME: - return 0x0001; - case AL_EMAIL: - return 0x0002; - case AC_SEARCH: - return 0x0004; - case AL_KEYBOARD_LAYOUT: - return 0x0008; - case AUDIO_VOL_UP: - return 0x0010; - case AUDIO_VOL_DOWN: - return 0x0020; - case AUDIO_MUTE: - return 0x0040; - case TRANSPORT_PLAY_PAUSE: - return 0x0080; - case TRANSPORT_NEXT_TRACK: - return 0x0100; - case TRANSPORT_PREV_TRACK: - return 0x0200; - case TRANSPORT_STOP: - return 0x0400; - case TRANSPORT_EJECT: - return 0x0800; - case TRANSPORT_FAST_FORWARD: - return 0x1000; - case TRANSPORT_REWIND: - return 0x2000; - case TRANSPORT_STOP_EJECT: - return 0x4000; - case AL_LOCAL_BROWSER: - return 0x8000; - default: - return 0; - } -} diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 8410eb483f..09ba0bacf7 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -69,7 +69,7 @@ extern keymap_config_t keymap_config; # ifdef MODULE_ADAFRUIT_BLE # include "adafruit_ble.h" # else -# include "bluetooth.h" +# include "../serial.h" # endif #endif @@ -89,6 +89,46 @@ extern keymap_config_t keymap_config; # include "joystick.h" #endif +// https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734 +static inline uint16_t CONSUMER2RN42(uint16_t usage) { + switch (usage) { + case AC_HOME: + return 0x0001; + case AL_EMAIL: + return 0x0002; + case AC_SEARCH: + return 0x0004; + case AL_KEYBOARD_LAYOUT: + return 0x0008; + case AUDIO_VOL_UP: + return 0x0010; + case AUDIO_VOL_DOWN: + return 0x0020; + case AUDIO_MUTE: + return 0x0040; + case TRANSPORT_PLAY_PAUSE: + return 0x0080; + case TRANSPORT_NEXT_TRACK: + return 0x0100; + case TRANSPORT_PREV_TRACK: + return 0x0200; + case TRANSPORT_STOP: + return 0x0400; + case TRANSPORT_EJECT: + return 0x0800; + case TRANSPORT_FAST_FORWARD: + return 0x1000; + case TRANSPORT_REWIND: + return 0x2000; + case TRANSPORT_STOP_EJECT: + return 0x4000; + case AL_LOCAL_BROWSER: + return 0x8000; + default: + return 0; + } +} + uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; @@ -631,20 +671,13 @@ static void send_keyboard(report_keyboard_t *report) { # ifdef MODULE_ADAFRUIT_BLE adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); # elif MODULE_RN42 - bluefruit_serial_send(0xFD); - bluefruit_serial_send(0x09); - bluefruit_serial_send(0x01); - bluefruit_serial_send(report->mods); - bluefruit_serial_send(report->reserved); - for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - bluefruit_serial_send(report->keys[i]); - } -# else - bluefruit_serial_send(0xFD); - bluefruit_serial_send(report->mods); - bluefruit_serial_send(report->reserved); + serial_send(0xFD); + serial_send(0x09); + serial_send(0x01); + serial_send(report->mods); + serial_send(report->reserved); for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { - bluefruit_serial_send(report->keys[i]); + serial_send(report->keys[i]); } # endif } @@ -697,15 +730,15 @@ static void send_mouse(report_mouse_t *report) { // FIXME: mouse buttons adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); # else - bluefruit_serial_send(0xFD); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x03); - bluefruit_serial_send(report->buttons); - bluefruit_serial_send(report->x); - bluefruit_serial_send(report->y); - bluefruit_serial_send(report->v); // should try sending the wheel v here - bluefruit_serial_send(report->h); // should try sending the wheel h here - bluefruit_serial_send(0x00); + serial_send(0xFD); + serial_send(0x00); + serial_send(0x03); + serial_send(report->buttons); + serial_send(report->x); + serial_send(report->y); + serial_send(report->v); // should try sending the wheel v here + serial_send(report->h); // should try sending the wheel h here + serial_send(0x00); # endif } @@ -778,25 +811,11 @@ static void send_consumer(uint16_t data) { if (data == last_data) return; last_data = data; uint16_t bitmap = CONSUMER2RN42(data); - bluefruit_serial_send(0xFD); - bluefruit_serial_send(0x03); - bluefruit_serial_send(0x03); - bluefruit_serial_send(bitmap & 0xFF); - bluefruit_serial_send((bitmap >> 8) & 0xFF); -# else - static uint16_t last_data = 0; - if (data == last_data) return; - last_data = data; - uint16_t bitmap = CONSUMER2BLUEFRUIT(data); - bluefruit_serial_send(0xFD); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x02); - bluefruit_serial_send(bitmap & 0xFF); - bluefruit_serial_send((bitmap >> 8) & 0xFF); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x00); + serial_send(0xFD); + serial_send(0x03); + serial_send(0x03); + serial_send(bitmap & 0xFF); + serial_send((bitmap >> 8) & 0xFF); # endif } @@ -1018,7 +1037,7 @@ int main(void) { setup_usb(); sei(); -#if defined(MODULE_ADAFRUIT_EZKEY) || defined(MODULE_RN42) +#if defined(MODULE_RN42) serial_init(); #endif -- cgit v1.2.3