Skip to content

Commit

Permalink
Remove support for Adafruit EZ-Key (qmk#10103)
Browse files Browse the repository at this point in the history
* Remove support for Adafruit EZ-Key

* Update docs/ja/feature_bluetooth.md

Co-authored-by: Takeshi ISHII <[email protected]>

Co-authored-by: Takeshi ISHII <[email protected]>
  • Loading branch information
2 people authored and drashna committed Sep 30, 2020
1 parent 7b4d9fc commit e232f1f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 193 deletions.
6 changes: 0 additions & 6 deletions tmk_core/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ ifeq ($(strip $(BLUETOOTH)), AdafruitBLE)
TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
endif

ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey)
TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE
TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY
TMK_COMMON_DEFS += -DNO_USB_STARTUP_CHECK
endif

ifeq ($(strip $(BLUETOOTH)), RN42)
TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE
TMK_COMMON_DEFS += -DMODULE_RN42
Expand Down
12 changes: 2 additions & 10 deletions tmk_core/protocol/lufa.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
38 changes: 0 additions & 38 deletions tmk_core/protocol/lufa/bluetooth.c

This file was deleted.

96 changes: 0 additions & 96 deletions tmk_core/protocol/lufa/bluetooth.h

This file was deleted.

105 changes: 62 additions & 43 deletions tmk_core/protocol/lufa/lufa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -92,6 +92,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;
Expand Down Expand Up @@ -742,20 +782,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
}
Expand Down Expand Up @@ -808,15 +841,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
}

Expand Down Expand Up @@ -889,25 +922,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
}

Expand Down Expand Up @@ -1129,7 +1148,7 @@ int main(void) {
setup_usb();
sei();

#if defined(MODULE_ADAFRUIT_EZKEY) || defined(MODULE_RN42)
#if defined(MODULE_RN42)
serial_init();
#endif

Expand Down

0 comments on commit e232f1f

Please sign in to comment.