From 11f50b4010d850248e049d86b935bdba28c3d705 Mon Sep 17 00:00:00 2001 From: dnaq Date: Sat, 18 Sep 2021 12:28:36 +0200 Subject: [PATCH 01/13] Add support for plover hid --- builddefs/common_features.mk | 5 ++ builddefs/show_options.mk | 1 + tmk_core/protocol/chibios/usb_main.c | 9 ++++ tmk_core/protocol/lufa/lufa.c | 5 ++ tmk_core/protocol/usb_descriptor.c | 79 ++++++++++++++++++++++++++++ tmk_core/protocol/usb_descriptor.h | 16 ++++++ 6 files changed, 115 insertions(+) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index c976b8296d..2f8a184bf6 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -92,6 +92,11 @@ ifeq ($(MUSIC_ENABLE), yes) SRC += $(QUANTUM_DIR)/process_keycode/process_music.c endif +ifeq ($(strip $(PLOVER_ENABLE)), yes) + OPT_DEFS += -DPLOVER_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_plover.c +endif + ifeq ($(strip $(STENO_ENABLE)), yes) OPT_DEFS += -DSTENO_ENABLE VIRTSER_ENABLE ?= yes diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk index f67d009191..173e74cbc6 100644 --- a/builddefs/show_options.mk +++ b/builddefs/show_options.mk @@ -66,6 +66,7 @@ OTHER_OPTION_NAMES = \ KEYLOGGER_ENABLE \ LCD_BACKLIGHT_ENABLE \ MACROS_ENABLED \ + PLOVER_ENABLE \ PS2_MOUSE_ENABLE \ RAW_ENABLE \ SWAP_HANDS_ENABLE \ diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 19e2e858fc..f2bb3a1ba7 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -313,6 +313,9 @@ typedef struct { #ifdef RAW_ENABLE usb_driver_config_t raw_driver; #endif +#ifdef PLOVER_ENABLE + usb_driver_config_t plover_driver; +#endif #ifdef MIDI_ENABLE usb_driver_config_t midi_driver; #endif @@ -350,6 +353,12 @@ static usb_driver_configs_t drivers = { .raw_driver = QMK_USB_DRIVER_CONFIG(RAW, 0, false), #endif +#ifdef PLOVER_ENABLE +# define PLOVER_IN_CAPACITY 4 +# define PLOVER_IN_MODE USB_EP_MODE_TYPE_INTR + .plover_driver = QMK_USB_DRIVER_CONFIG(PLOVER, 0, false), +#endif + #ifdef MIDI_ENABLE # define MIDI_STREAM_IN_CAPACITY 4 # define MIDI_STREAM_OUT_CAPACITY 4 diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index b4b03357a3..307ba27465 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -471,6 +471,11 @@ void EVENT_USB_Device_ConfigurationChanged(void) { ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); #endif +#ifdef PLOVER_ENABLE + /* Setup raw HID endpoints */ + ConfigSuccess &= Endpoint_ConfigureEndpoint((PLOVER_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, PLOVER_EPSIZE, 1); +#endif + #ifdef CONSOLE_ENABLE /* Setup console endpoint */ ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 063bd2c3f1..2734d8d5c0 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -322,6 +322,29 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { }; #endif +#ifdef PLOVER_ENABLE +const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { + 0x06, 0x50, 0xff, // UsagePage (65360) + 0x0a, 0x56, 0x4c, // Usage (19542) + 0xa1, 0x02, // Collection (Logical) + 0x85, 0x01, // ReportID (1) + 0x25, 0x01, // LogicalMaximum (1) + 0x75, 0x01, // ReportSize (1) + 0x95, 0x40, // ReportCount (64) + 0x05, 0x09, // UsagePage (button) + 0x19, 0x00, // UsageMinimum (Button(0)) + 0x29, 0x3f, // UsageMaximum (Button(63)) + 0x81, 0x02, // Input (Variable) + 0x85, 0x02, // ReportID (2) + 0x26, 0xff, 0x00, // LogicalMaximum (255) + 0x75, 0x08, // ReportSize (8) + 0x19, 0x00, // UsageMinimum (Button(0)) + 0x29, 0x3f, // UsageMaximum (Button(63)) + 0x81, 0x02, // Input (Variable) + 0xc0, // EndCollection +}; +#endif + #ifdef CONSOLE_ENABLE const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = { HID_RI_USAGE_PAGE(16, 0xFF31), // Vendor Defined (PJRC Teensy compatible) @@ -554,6 +577,46 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { }, #endif +#ifdef PLOVER_ENABLE + /* + * Plover HID + */ + .Plover_Interface = { + .Header = { + .Size = sizeof(USB_Descriptor_Interface_t), + .Type = DTYPE_Interface + }, + .InterfaceNumber = PLOVER_INTERFACE, + .AlternateSetting = 0x00, + .TotalEndpoints = 1, + .Class = HID_CSCP_HIDClass, + .SubClass = HID_CSCP_NonBootSubclass, + .Protocol = HID_CSCP_NonBootProtocol, + .InterfaceStrIndex = NO_DESCRIPTOR + }, + .Plover_HID = { + .Header = { + .Size = sizeof(USB_HID_Descriptor_HID_t), + .Type = HID_DTYPE_HID + }, + .HIDSpec = VERSION_BCD(1, 1, 1), + .CountryCode = 0x00, + .TotalReportDescriptors = 1, + .HIDReportType = HID_DTYPE_Report, + .HIDReportLength = sizeof(PloverReport) + }, + .Plover_INEndpoint = { + .Header = { + .Size = sizeof(USB_Descriptor_Endpoint_t), + .Type = DTYPE_Endpoint + }, + .EndpointAddress = (ENDPOINT_DIR_IN | PLOVER_IN_EPNUM), + .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), + .EndpointSize = RAW_EPSIZE, + .PollingIntervalMS = 0x01 + }, +#endif + #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) /* * Mouse @@ -1148,6 +1211,14 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif +#ifdef PLOVER_ENABLE + case PLOVER_INTERFACE: + Address = &ConfigurationDescriptor.Plover_HID; + Size = sizeof(USB_HID_Descriptor_HID_t); + + break; +#endif + #ifdef CONSOLE_ENABLE case CONSOLE_INTERFACE: Address = &ConfigurationDescriptor.Console_HID; @@ -1205,6 +1276,14 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif +#ifdef PLOVER_ENABLE + case PLOVER_INTERFACE: + Address = &PloverReport; + Size = sizeof(PloverReport); + + break; +#endif + #ifdef CONSOLE_ENABLE case CONSOLE_INTERFACE: Address = &ConsoleReport; diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 6c3424145c..7bb0bf8c2d 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -75,6 +75,13 @@ typedef struct { USB_Descriptor_Endpoint_t Raw_OUTEndpoint; #endif +#ifdef PLOVER_ENABLE + // Plover HID Interface + USB_Descriptor_Interface_t Plover_Interface; + USB_HID_Descriptor_HID_t Plover_HID; + USB_Descriptor_Endpoint_t Plover_INEndpoint; +#endif + #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) // Mouse HID Interface USB_Descriptor_Interface_t Mouse_Interface; @@ -162,6 +169,10 @@ enum usb_interfaces { RAW_INTERFACE, #endif +#ifdef PLOVER_ENABLE + PLOVER_INTERFACE, +#endif + #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) MOUSE_INTERFACE, #endif @@ -223,6 +234,10 @@ enum usb_endpoints { # endif #endif +#ifdef PLOVER_ENABLE + PLOVER_IN_EPNUM = NEXT_EPNUM, +#endif + #ifdef SHARED_EP_ENABLE SHARED_IN_EPNUM = NEXT_EPNUM, #endif @@ -303,6 +318,7 @@ enum usb_endpoints { #define SHARED_EPSIZE 32 #define MOUSE_EPSIZE 8 #define RAW_EPSIZE 32 +#define PLOVER_EPSIZE 32 #define CONSOLE_EPSIZE 32 #define MIDI_STREAM_EPSIZE 64 #define CDC_NOTIFICATION_EPSIZE 8 From 0f6d6af2576f260096304d5cef074fc86b70a0aa Mon Sep 17 00:00:00 2001 From: dnaq Date: Sun, 19 Sep 2021 16:39:02 +0200 Subject: [PATCH 02/13] Add plover hid support for LUFA and hopefully ChibiOS Still no support for chibios. --- builddefs/common_features.mk | 6 +- builddefs/show_options.mk | 2 +- quantum/keymap_extras/keymap_plover_hid.h | 89 ++++++++++++++++++++ quantum/plover_hid.h | 4 + quantum/process_keycode/process_plover_hid.c | 23 +++++ quantum/process_keycode/process_plover_hid.h | 20 +++++ quantum/quantum.c | 3 + quantum/quantum.h | 4 + quantum/quantum_keycodes.h | 2 + tmk_core/protocol/chibios/usb_main.c | 18 ++-- tmk_core/protocol/lufa/lufa.c | 30 ++++++- tmk_core/protocol/usb_descriptor.c | 16 ++-- tmk_core/protocol/usb_descriptor.h | 12 +-- 13 files changed, 203 insertions(+), 26 deletions(-) create mode 100644 quantum/keymap_extras/keymap_plover_hid.h create mode 100644 quantum/plover_hid.h create mode 100644 quantum/process_keycode/process_plover_hid.c create mode 100644 quantum/process_keycode/process_plover_hid.h diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 2f8a184bf6..d6f84a2b6d 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -92,9 +92,9 @@ ifeq ($(MUSIC_ENABLE), yes) SRC += $(QUANTUM_DIR)/process_keycode/process_music.c endif -ifeq ($(strip $(PLOVER_ENABLE)), yes) - OPT_DEFS += -DPLOVER_ENABLE - SRC += $(QUANTUM_DIR)/process_keycode/process_plover.c +ifeq ($(strip $(PLOVER_HID_ENABLE)), yes) + OPT_DEFS += -DPLOVER_HID_ENABLE + SRC += $(QUANTUM_DIR)/process_keycode/process_plover_hid.c endif ifeq ($(strip $(STENO_ENABLE)), yes) diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk index 173e74cbc6..8aa2f42ee2 100644 --- a/builddefs/show_options.mk +++ b/builddefs/show_options.mk @@ -66,7 +66,7 @@ OTHER_OPTION_NAMES = \ KEYLOGGER_ENABLE \ LCD_BACKLIGHT_ENABLE \ MACROS_ENABLED \ - PLOVER_ENABLE \ + PLOVER_HID_ENABLE \ PS2_MOUSE_ENABLE \ RAW_ENABLE \ SWAP_HANDS_ENABLE \ diff --git a/quantum/keymap_extras/keymap_plover_hid.h b/quantum/keymap_extras/keymap_plover_hid.h new file mode 100644 index 0000000000..4792f5d1f3 --- /dev/null +++ b/quantum/keymap_extras/keymap_plover_hid.h @@ -0,0 +1,89 @@ +/* Copyright 2017 Joseph Wasson + * + * 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 "keymap.h" + +// List of keycodes for the plover HID. +enum steno_keycodes { + PLV__MIN = QK_PLOVER_HID, + PLV_N1 = PLV__MIN, + PLV_N2, + PLV_N3, + PLV_N4, + PLV_N5, + PLV_N6, + PLV_N7, + PLV_N8, + PLV_N9, + PLV_NA, + PLV_NB, + PLV_NC, + PLV_X1, + PLV_S1, + PLV_TL, + PLV_PL, + PLV_HL, + PLV_ST1, + PLV_ST3, + PLV_FR, + PLV_PR, + PLV_LR, + PLV_TR, + PLV_DR, + PLV_X2, + PLV_S2, + PLV_KL, + PLV_WL, + PLV_RL, + PLV_ST2, + PLV_ST4, + PLV_RR, + PLV_BR, + PLV_GR, + PLV_SR, + PLV_ZR, + PLV_X3, + PLV_A, + PLV_O, + PLV_E, + PLV_U, + PLV_X4, + PLV_X5, + PLV_X6, + PLV_X7, + PLV_X8, + PLV_X9, + PLV_X10, + PLV_X11, + PLV_X12, + PLV_X13, + PLV_X14, + PLV_X15, + PLV_X16, + PLV_X17, + PLV_X18, + PLV_X19, + PLV_X20, + PLV_X21, + PLV_X22, + PLV_X23, + PLV_X24, + PLV_X25, + PLV_X26, + PLV__MAX = PLV_X26, +}; diff --git a/quantum/plover_hid.h b/quantum/plover_hid.h new file mode 100644 index 0000000000..e12c2fc630 --- /dev/null +++ b/quantum/plover_hid.h @@ -0,0 +1,4 @@ +#pragma once + +#define PLOVER_HID_SIMPLE_REPORT_SIZE 9 +void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]); diff --git a/quantum/process_keycode/process_plover_hid.c b/quantum/process_keycode/process_plover_hid.c new file mode 100644 index 0000000000..ad0c1196c3 --- /dev/null +++ b/quantum/process_keycode/process_plover_hid.c @@ -0,0 +1,23 @@ +#include "process_plover_hid.h" +#include "keymap_plover_hid.h" +#include "plover_hid.h" + +// Simple report consists of a single byte set to one +// followed by one bit for each of the 64 buttons defined +// in the report type. +static uint8_t report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1}; + +bool process_plover_hid(uint16_t keycode, keyrecord_t *record) { + if (keycode < PLV__MIN || keycode > PLV__MAX) { + return true; + } + keycode = keycode - PLV__MIN; + if (record->event.pressed) { + report[1 + keycode/8] |= (1 << (7 - (keycode % 8))); + } else { + report[1 + keycode/8] &= ~(1 << (7 - (keycode % 8))); + } + + plover_hid_send(report); + return false; +} diff --git a/quantum/process_keycode/process_plover_hid.h b/quantum/process_keycode/process_plover_hid.h new file mode 100644 index 0000000000..dd9bdb353a --- /dev/null +++ b/quantum/process_keycode/process_plover_hid.h @@ -0,0 +1,20 @@ +/* Copyright 2021 The QMK Project + * + * 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 "quantum.h" + +bool process_plover_hid(uint16_t keycode, keyrecord_t *record); diff --git a/quantum/quantum.c b/quantum/quantum.c index 33121f6b95..bdd14f4622 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -277,6 +277,9 @@ bool process_record_quantum(keyrecord_t *record) { #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) process_backlight(keycode, record) && #endif +#ifdef PLOVER_HID_ENABLE + process_plover_hid(keycode, record) && +#endif #ifdef STENO_ENABLE process_steno(keycode, record) && #endif diff --git a/quantum/quantum.h b/quantum/quantum.h index 92e1af1c40..fc11c3491b 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -81,6 +81,10 @@ extern layer_state_t layer_state; # endif #endif +#ifdef PLOVER_HID_ENABLE +# include "process_plover_hid.h" +#endif + #ifdef STENO_ENABLE # include "process_steno.h" #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 40355d799a..3527de5950 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -65,6 +65,8 @@ enum quantum_keycodes { QK_STENO_COMB = 0x5A32, QK_STENO_COMB_MAX = 0x5A3C, QK_STENO_MAX = 0x5A3F, + QK_PLOVER_HID = 0x5A40, + QK_PLOVER_HID_MAX = 0x5A80, // 0x5C00 - 0x5FFF are reserved, see below QK_MOD_TAP = 0x6000, QK_MOD_TAP_MAX = 0x7FFF, diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index f2bb3a1ba7..0ff7dc0f3d 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -313,8 +313,8 @@ typedef struct { #ifdef RAW_ENABLE usb_driver_config_t raw_driver; #endif -#ifdef PLOVER_ENABLE - usb_driver_config_t plover_driver; +#ifdef PLOVER_HID_ENABLE + usb_driver_config_t plover_hid_driver; #endif #ifdef MIDI_ENABLE usb_driver_config_t midi_driver; @@ -353,10 +353,10 @@ static usb_driver_configs_t drivers = { .raw_driver = QMK_USB_DRIVER_CONFIG(RAW, 0, false), #endif -#ifdef PLOVER_ENABLE -# define PLOVER_IN_CAPACITY 4 -# define PLOVER_IN_MODE USB_EP_MODE_TYPE_INTR - .plover_driver = QMK_USB_DRIVER_CONFIG(PLOVER, 0, false), +#ifdef PLOVER_HID_ENABLE +# define PLOVER_HID_IN_CAPACITY 4 +# define PLOVER_HID_IN_MODE USB_EP_MODE_TYPE_INTR + .plover_hid_driver = QMK_USB_DRIVER_CONFIG(PLOVER_HID, 0, false), #endif #ifdef MIDI_ENABLE @@ -1096,6 +1096,12 @@ void console_task(void) { #endif /* CONSOLE_ENABLE */ +#ifdef PLOVER_HID_ENABLE +void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]) { + chnWrite(&drivers.plover_hid_driver.driver, data, PLOVER_HID_SIMPLE_REPORT_SIZE); +} +#endif + #ifdef RAW_ENABLE void raw_hid_send(uint8_t *data, uint8_t length) { // TODO: implement variable size packet diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 307ba27465..7f59edf1e8 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -86,6 +86,10 @@ extern keymap_config_t keymap_config; # include "raw_hid.h" #endif +#ifdef PLOVER_HID_ENABLE +# include "plover_hid.h" +#endif + #ifdef JOYSTICK_ENABLE # include "joystick.h" #endif @@ -209,6 +213,28 @@ static void raw_hid_task(void) { } #endif +#ifdef PLOVER_HID_ENABLE +void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]) { + if (USB_DeviceState != DEVICE_STATE_Configured) { + return; + } + + uint8_t ep = Endpoint_GetCurrentEndpoint(); + + Endpoint_SelectEndpoint(PLOVER_HID_IN_EPNUM); + + // Check to see if the host is ready to accept another packet + if (Endpoint_IsINReady()) { + // Write data + Endpoint_Write_Stream_LE(data, PLOVER_HID_SIMPLE_REPORT_SIZE, NULL); + // Finalize The stream transfer to send the last packet + Endpoint_ClearIN(); + } + + Endpoint_SelectEndpoint(ep); +} +#endif + /******************************************************************************* * Console ******************************************************************************/ @@ -471,9 +497,9 @@ void EVENT_USB_Device_ConfigurationChanged(void) { ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); #endif -#ifdef PLOVER_ENABLE +#ifdef PLOVER_HID_ENABLE /* Setup raw HID endpoints */ - ConfigSuccess &= Endpoint_ConfigureEndpoint((PLOVER_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, PLOVER_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((PLOVER_HID_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, PLOVER_HID_EPSIZE, 1); #endif #ifdef CONSOLE_ENABLE diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 2734d8d5c0..962b849ac5 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -322,7 +322,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { }; #endif -#ifdef PLOVER_ENABLE +#ifdef PLOVER_HID_ENABLE const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { 0x06, 0x50, 0xff, // UsagePage (65360) 0x0a, 0x56, 0x4c, // Usage (19542) @@ -577,7 +577,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { }, #endif -#ifdef PLOVER_ENABLE +#ifdef PLOVER_HID_ENABLE /* * Plover HID */ @@ -586,7 +586,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface }, - .InterfaceNumber = PLOVER_INTERFACE, + .InterfaceNumber = PLOVER_HID_INTERFACE, .AlternateSetting = 0x00, .TotalEndpoints = 1, .Class = HID_CSCP_HIDClass, @@ -610,7 +610,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { .Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint }, - .EndpointAddress = (ENDPOINT_DIR_IN | PLOVER_IN_EPNUM), + .EndpointAddress = (ENDPOINT_DIR_IN | PLOVER_HID_IN_EPNUM), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .EndpointSize = RAW_EPSIZE, .PollingIntervalMS = 0x01 @@ -1211,8 +1211,8 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif -#ifdef PLOVER_ENABLE - case PLOVER_INTERFACE: +#ifdef PLOVER_HID_ENABLE + case PLOVER_HID_INTERFACE: Address = &ConfigurationDescriptor.Plover_HID; Size = sizeof(USB_HID_Descriptor_HID_t); @@ -1276,8 +1276,8 @@ uint16_t get_usb_descriptor(const uint16_t wValue, const uint16_t wIndex, const break; #endif -#ifdef PLOVER_ENABLE - case PLOVER_INTERFACE: +#ifdef PLOVER_HID_ENABLE + case PLOVER_HID_INTERFACE: Address = &PloverReport; Size = sizeof(PloverReport); diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 7bb0bf8c2d..39b5ccc59d 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -75,7 +75,7 @@ typedef struct { USB_Descriptor_Endpoint_t Raw_OUTEndpoint; #endif -#ifdef PLOVER_ENABLE +#ifdef PLOVER_HID_ENABLE // Plover HID Interface USB_Descriptor_Interface_t Plover_Interface; USB_HID_Descriptor_HID_t Plover_HID; @@ -169,8 +169,8 @@ enum usb_interfaces { RAW_INTERFACE, #endif -#ifdef PLOVER_ENABLE - PLOVER_INTERFACE, +#ifdef PLOVER_HID_ENABLE + PLOVER_HID_INTERFACE, #endif #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) @@ -234,8 +234,8 @@ enum usb_endpoints { # endif #endif -#ifdef PLOVER_ENABLE - PLOVER_IN_EPNUM = NEXT_EPNUM, +#ifdef PLOVER_HID_ENABLE + PLOVER_HID_IN_EPNUM = NEXT_EPNUM, #endif #ifdef SHARED_EP_ENABLE @@ -318,7 +318,7 @@ enum usb_endpoints { #define SHARED_EPSIZE 32 #define MOUSE_EPSIZE 8 #define RAW_EPSIZE 32 -#define PLOVER_EPSIZE 32 +#define PLOVER_HID_EPSIZE 9 #define CONSOLE_EPSIZE 32 #define MIDI_STREAM_EPSIZE 64 #define CDC_NOTIFICATION_EPSIZE 8 From ae191ab099ffc5d81d74fe2bdb9735ef2b6cbd60 Mon Sep 17 00:00:00 2001 From: dnaq Date: Fri, 24 Sep 2021 22:48:12 +0200 Subject: [PATCH 03/13] plover hid changes, bunch the reports up and send --- quantum/plover_hid.h | 3 ++- quantum/process_keycode/process_plover_hid.c | 14 +------------- tmk_core/protocol/lufa/lufa.c | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/quantum/plover_hid.h b/quantum/plover_hid.h index e12c2fc630..84b05af4e7 100644 --- a/quantum/plover_hid.h +++ b/quantum/plover_hid.h @@ -1,4 +1,5 @@ #pragma once #define PLOVER_HID_SIMPLE_REPORT_SIZE 9 -void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]); +void plover_hid_update(uint8_t button, bool pressed); +void plover_hid_task(void); diff --git a/quantum/process_keycode/process_plover_hid.c b/quantum/process_keycode/process_plover_hid.c index ad0c1196c3..2cd5c9d0a7 100644 --- a/quantum/process_keycode/process_plover_hid.c +++ b/quantum/process_keycode/process_plover_hid.c @@ -2,22 +2,10 @@ #include "keymap_plover_hid.h" #include "plover_hid.h" -// Simple report consists of a single byte set to one -// followed by one bit for each of the 64 buttons defined -// in the report type. -static uint8_t report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1}; - bool process_plover_hid(uint16_t keycode, keyrecord_t *record) { if (keycode < PLV__MIN || keycode > PLV__MAX) { return true; } - keycode = keycode - PLV__MIN; - if (record->event.pressed) { - report[1 + keycode/8] |= (1 << (7 - (keycode % 8))); - } else { - report[1 + keycode/8] &= ~(1 << (7 - (keycode % 8))); - } - - plover_hid_send(report); + plover_hid_update((uint8_t)(keycode - PLV__MIN), record->event.pressed); return false; } diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 7f59edf1e8..02c6cd15e2 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -214,7 +214,16 @@ static void raw_hid_task(void) { #endif #ifdef PLOVER_HID_ENABLE -void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]) { +static uint8_t plover_hid_current_report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1}; +void plover_hid_update(uint8_t button, bool pressed) { + if (pressed) { + plover_hid_current_report[1 + button/8] |= (1 << (7 - (button % 8))); + } else { + plover_hid_current_report[1 + button/8] &= (1 << (7 - (button % 8))); + } +} + +void plover_hid_task(void) { if (USB_DeviceState != DEVICE_STATE_Configured) { return; } @@ -226,7 +235,7 @@ void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]) { // Check to see if the host is ready to accept another packet if (Endpoint_IsINReady()) { // Write data - Endpoint_Write_Stream_LE(data, PLOVER_HID_SIMPLE_REPORT_SIZE, NULL); + Endpoint_Write_Stream_LE(plover_hid_current_report, sizeof(plover_hid_current_report), NULL); // Finalize The stream transfer to send the last packet Endpoint_ClearIN(); } @@ -462,6 +471,7 @@ void EVENT_USB_Device_StartOfFrame(void) { if (!console_flush) return; Console_Task(); console_flush = false; + } #endif @@ -1127,6 +1137,10 @@ void protocol_post_task(void) { raw_hid_task(); #endif +#ifdef PLOVER_HID_ENABLE + plover_hid_task(); +#endif + #if !defined(INTERRUPT_CONTROL_ENDPOINT) USB_USBTask(); #endif From de1688389d28ff41b7bf70b1bfefe456744a6a4a Mon Sep 17 00:00:00 2001 From: dnaq Date: Fri, 24 Sep 2021 23:30:30 +0200 Subject: [PATCH 04/13] try not sending chord state when no updates have happened --- quantum/process_keycode/process_plover_hid.c | 2 +- tmk_core/protocol/lufa/lufa.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/quantum/process_keycode/process_plover_hid.c b/quantum/process_keycode/process_plover_hid.c index 2cd5c9d0a7..7d7f97cfc2 100644 --- a/quantum/process_keycode/process_plover_hid.c +++ b/quantum/process_keycode/process_plover_hid.c @@ -6,6 +6,6 @@ bool process_plover_hid(uint16_t keycode, keyrecord_t *record) { if (keycode < PLV__MIN || keycode > PLV__MAX) { return true; } - plover_hid_update((uint8_t)(keycode - PLV__MIN), record->event.pressed); + plover_hid_update(keycode - PLV__MIN, record->event.pressed); return false; } diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 02c6cd15e2..c15aa68dbf 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -214,19 +214,24 @@ static void raw_hid_task(void) { #endif #ifdef PLOVER_HID_ENABLE -static uint8_t plover_hid_current_report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1}; +static bool plover_hid_report_updated = false; +static uint8_t plover_hid_current_report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1, 0}; void plover_hid_update(uint8_t button, bool pressed) { if (pressed) { plover_hid_current_report[1 + button/8] |= (1 << (7 - (button % 8))); } else { - plover_hid_current_report[1 + button/8] &= (1 << (7 - (button % 8))); + plover_hid_current_report[1 + button/8] &= ~(1 << (7 - (button % 8))); } + plover_hid_report_updated = true; } void plover_hid_task(void) { if (USB_DeviceState != DEVICE_STATE_Configured) { return; } + if (!plover_hid_report_updated) { + return; + } uint8_t ep = Endpoint_GetCurrentEndpoint(); @@ -235,12 +240,14 @@ void plover_hid_task(void) { // Check to see if the host is ready to accept another packet if (Endpoint_IsINReady()) { // Write data - Endpoint_Write_Stream_LE(plover_hid_current_report, sizeof(plover_hid_current_report), NULL); + Endpoint_Write_Stream_LE(plover_hid_current_report, PLOVER_HID_SIMPLE_REPORT_SIZE, NULL); // Finalize The stream transfer to send the last packet Endpoint_ClearIN(); } Endpoint_SelectEndpoint(ep); + + plover_hid_report_updated = false; } #endif From 3c45934a1d83ecc8b678d71299d2c76d2f7253e2 Mon Sep 17 00:00:00 2001 From: dnaq Date: Fri, 24 Sep 2021 23:30:47 +0200 Subject: [PATCH 05/13] georgi changes to be able to build it with plover-hid --- keyboards/gboards/georgi/georgi.c | 2 ++ keyboards/gboards/georgi/sten.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/keyboards/gboards/georgi/georgi.c b/keyboards/gboards/georgi/georgi.c index 8866886ce7..0574d1da7c 100644 --- a/keyboards/gboards/georgi/georgi.c +++ b/keyboards/gboards/georgi/georgi.c @@ -4,7 +4,9 @@ bool i2c_initialized = 0; i2c_status_t mcp23018_status = 0x20; void matrix_init_kb(void) { +#ifdef STENO_ENABLE steno_set_mode(STENO_MODE_GEMINI); // or STENO_MODE_BOLT +#endif // (tied to Vcc for hardware convenience) //DDRB &= ~(1<<4); // set B(4) as input diff --git a/keyboards/gboards/georgi/sten.c b/keyboards/gboards/georgi/sten.c index c7469b6394..46d8103e0b 100644 --- a/keyboards/gboards/georgi/sten.c +++ b/keyboards/gboards/georgi/sten.c @@ -50,6 +50,7 @@ uint16_t repTimer = 0; bool inMouse = false; int8_t mousePress; +#ifdef STENO_ENABLE // All processing done at chordUp goes through here bool send_steno_chord_user(steno_mode_t mode, uint8_t chord[6]) { // Check for mousekeys, this is release @@ -146,6 +147,7 @@ out: return false; } +#endif // Update Chord State bool process_steno_user(uint16_t keycode, keyrecord_t *record) { From 7103b01bc7bb2333db95c97992d6cef35ade3ad3 Mon Sep 17 00:00:00 2001 From: dnaq Date: Sat, 25 Sep 2021 00:05:39 +0200 Subject: [PATCH 06/13] fix plover hid updates --- tmk_core/protocol/lufa/lufa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index c15aa68dbf..62ef1d7a25 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -237,17 +237,16 @@ void plover_hid_task(void) { Endpoint_SelectEndpoint(PLOVER_HID_IN_EPNUM); - // Check to see if the host is ready to accept another packet if (Endpoint_IsINReady()) { // Write data Endpoint_Write_Stream_LE(plover_hid_current_report, PLOVER_HID_SIMPLE_REPORT_SIZE, NULL); // Finalize The stream transfer to send the last packet Endpoint_ClearIN(); + plover_hid_report_updated = false; } Endpoint_SelectEndpoint(ep); - plover_hid_report_updated = false; } #endif From 957d30f398a027da44596d5e01dbef07bc8dbed4 Mon Sep 17 00:00:00 2001 From: dnaq Date: Sat, 25 Sep 2021 11:44:02 +0200 Subject: [PATCH 07/13] remove report id from plover hid endpoint --- quantum/plover_hid.h | 1 - tmk_core/protocol/lufa/lufa.c | 8 ++++---- tmk_core/protocol/usb_descriptor.c | 7 ------- tmk_core/protocol/usb_descriptor.h | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/quantum/plover_hid.h b/quantum/plover_hid.h index 84b05af4e7..c21487ead2 100644 --- a/quantum/plover_hid.h +++ b/quantum/plover_hid.h @@ -1,5 +1,4 @@ #pragma once -#define PLOVER_HID_SIMPLE_REPORT_SIZE 9 void plover_hid_update(uint8_t button, bool pressed); void plover_hid_task(void); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 62ef1d7a25..83385197e7 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -215,12 +215,12 @@ static void raw_hid_task(void) { #ifdef PLOVER_HID_ENABLE static bool plover_hid_report_updated = false; -static uint8_t plover_hid_current_report[PLOVER_HID_SIMPLE_REPORT_SIZE] = {1, 0}; +static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0}; void plover_hid_update(uint8_t button, bool pressed) { if (pressed) { - plover_hid_current_report[1 + button/8] |= (1 << (7 - (button % 8))); + plover_hid_current_report[button/8] |= (1 << (7 - (button % 8))); } else { - plover_hid_current_report[1 + button/8] &= ~(1 << (7 - (button % 8))); + plover_hid_current_report[button/8] &= ~(1 << (7 - (button % 8))); } plover_hid_report_updated = true; } @@ -239,7 +239,7 @@ void plover_hid_task(void) { if (Endpoint_IsINReady()) { // Write data - Endpoint_Write_Stream_LE(plover_hid_current_report, PLOVER_HID_SIMPLE_REPORT_SIZE, NULL); + Endpoint_Write_Stream_LE(plover_hid_current_report, PLOVER_HID_EPSIZE, NULL); // Finalize The stream transfer to send the last packet Endpoint_ClearIN(); plover_hid_report_updated = false; diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 962b849ac5..34d205b1f3 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -327,7 +327,6 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { 0x06, 0x50, 0xff, // UsagePage (65360) 0x0a, 0x56, 0x4c, // Usage (19542) 0xa1, 0x02, // Collection (Logical) - 0x85, 0x01, // ReportID (1) 0x25, 0x01, // LogicalMaximum (1) 0x75, 0x01, // ReportSize (1) 0x95, 0x40, // ReportCount (64) @@ -335,12 +334,6 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { 0x19, 0x00, // UsageMinimum (Button(0)) 0x29, 0x3f, // UsageMaximum (Button(63)) 0x81, 0x02, // Input (Variable) - 0x85, 0x02, // ReportID (2) - 0x26, 0xff, 0x00, // LogicalMaximum (255) - 0x75, 0x08, // ReportSize (8) - 0x19, 0x00, // UsageMinimum (Button(0)) - 0x29, 0x3f, // UsageMaximum (Button(63)) - 0x81, 0x02, // Input (Variable) 0xc0, // EndCollection }; #endif diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 39b5ccc59d..1bc9622977 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -318,7 +318,7 @@ enum usb_endpoints { #define SHARED_EPSIZE 32 #define MOUSE_EPSIZE 8 #define RAW_EPSIZE 32 -#define PLOVER_HID_EPSIZE 9 +#define PLOVER_HID_EPSIZE 8 #define CONSOLE_EPSIZE 32 #define MIDI_STREAM_EPSIZE 64 #define CDC_NOTIFICATION_EPSIZE 8 From d9c23ecdd9f23e07fddb4886a926aabd601a8419 Mon Sep 17 00:00:00 2001 From: dnaq Date: Sat, 25 Sep 2021 12:02:47 +0200 Subject: [PATCH 08/13] add plover-hid firmware for the georgi --- .../georgi/keymaps/plover-hid/keymap.c | 51 +++++++++++++++++++ .../georgi/keymaps/plover-hid/readme.md | 14 +++++ .../georgi/keymaps/plover-hid/rules.mk | 46 +++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 keyboards/gboards/georgi/keymaps/plover-hid/keymap.c create mode 100644 keyboards/gboards/georgi/keymaps/plover-hid/readme.md create mode 100644 keyboards/gboards/georgi/keymaps/plover-hid/rules.mk diff --git a/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c b/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c new file mode 100644 index 0000000000..c83b64c8f9 --- /dev/null +++ b/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c @@ -0,0 +1,51 @@ +/* + * Good on you for modifying your layout, this is the most nonQMK layout you will come across + * There are three modes, Steno (the default), QWERTY (Toggleable) and a Momentary symbol layer + * + * Don't modify the steno layer directly, instead add chords using the keycodes and macros + * from sten.h to the layout you want to modify. + * + * Observe the comment above processQWERTY! + * + * http://docs.gboards.ca + */ + +#include QMK_KEYBOARD_H +//#include "sten.h" +#include "keymap_plover_hid.h" + +// Proper Layers +#define FUNCT (LSD | LK | LP | LH) +#define MEDIA (LSD | LK | LW | LR) +#define MOVE (ST1 | ST2) + +// QMK Layers +#define STENO_LAYER 0 + +/* Keyboard Layout + * ,---------------------------------. ,------------------------------. + * | FN | LSU | LFT | LP | LH | ST1 | | ST3 | RF | RP | RL | RT | RD | + * |-----+-----+-----+----+----|-----| |-----|----+----+----+----+----| + * | PWR | LSD | LK | LW | LR | ST2 | | ST4 | RR | BB | RG | RS | RZ | + * `---------------------------------' `------------------------------' + * ,---------------, .---------------. + * | LNO | LA | LO | | RE | RU | RNO | + * `---------------' `---------------' + */ + +// "Layers" +// Steno layer should be first in your map. +// When PWR | FN | ST3 | ST4 is pressed, the layer is increased to the next map. You must return to STENO_LAYER at the end. +// If you need more space for chords, remove the two gaming layers. +// Note: If using NO_ACTION_TAPPING, LT will not work! + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + // Main layer, everything goes through here + [0] = LAYOUT_georgi( + PLV_X1, PLV_S1, PLV_TL, PLV_PL, PLV_HL, PLV_ST1, PLV_ST3, PLV_FR, PLV_PR, PLV_LR, PLV_TR, PLV_DR, + PLV_X2, PLV_S2, PLV_KL, PLV_WL, PLV_RL, PLV_ST2, PLV_ST4, PLV_RR, PLV_BR, PLV_GR, PLV_SR, PLV_ZR, + PLV_N1, PLV_A, PLV_O, PLV_E, PLV_U, PLV_N7 + ) +}; +// Don't fuck with this, thanks. +size_t keymapsCount = sizeof(keymaps)/sizeof(keymaps[0]); diff --git a/keyboards/gboards/georgi/keymaps/plover-hid/readme.md b/keyboards/gboards/georgi/keymaps/plover-hid/readme.md new file mode 100644 index 0000000000..0bfdd79b4a --- /dev/null +++ b/keyboards/gboards/georgi/keymaps/plover-hid/readme.md @@ -0,0 +1,14 @@ +# Georgi Plover HID firmware + +This is a steno-only firmware for the Georgi using the (as of now) experimental Plover HID protocol +instead of a serial steno protocol. + +This firmware only defines a keymap of the form: + +``` +X1 S1- T- P- H- S1 S3 -F -P -L -T -D +X2 S2- X- W- R- S2 S4 -R -B -G -S -Z + #1 A O E U #7 +``` + +and is meant to be used with the [plover-machine-hid](https://github.com/dnaq/plover-machine-hid) plugin. diff --git a/keyboards/gboards/georgi/keymaps/plover-hid/rules.mk b/keyboards/gboards/georgi/keymaps/plover-hid/rules.mk new file mode 100644 index 0000000000..666b7be058 --- /dev/null +++ b/keyboards/gboards/georgi/keymaps/plover-hid/rules.mk @@ -0,0 +1,46 @@ +#---------------------------------------------------------------------------- +# make georgi:default:dfu +# Make sure you have dfu-programmer installed! +#---------------------------------------------------------------------------- + +NO_REPEAT = no +VERBOSE = yes +KEYBOARD_SHARED_EP = yes +CUSTOM_MATRIX = yes + +#Firmware reduction options +MOUSEKEY_ENABLE = no # 1500 bytes +NO_TAPPING = yes # 2000 bytes +NO_PRINT = yes + +#Debug options +CONSOLE_ENABLE = no +DEBUG_MATRIX_SCAN_RATE = no +DEBUG_MATRIX = no +ONLY_QWERTY = no + +# A bunch of stuff that you shouldn't touch unless you +# know what you're doing. +# +# No touchy, capiche? +SRC += matrix.c i2c_master.c +ifeq ($(strip $(DEBUG_MATRIX)), yes) + OPT_DEFS += -DDEBUG_MATRIX +endif +ifeq ($(strip $(NO_REPEAT)), yes) + OPT_DEFS += -DNO_REPEAT +endif +ifeq ($(strip $(NO_PRINT)), yes) + OPT_DEFS += -DNO_PRINT -DNO_DEBUG +endif +ifeq ($(strip $(ONLY_QWERTY)), yes) + OPT_DEFS += -DONLYQWERTY +endif +ifeq ($(strip $(NO_TAPPING)), yes) + OPT_DEFS += -DNO_ACTION_TAPPING +endif + +USER_NAME := notexisting + +PLOVER_HID_ENABLE := yes +STENO_ENABLE := no From 71d7f67efd4e55d96907bb979d8a746f9f514feb Mon Sep 17 00:00:00 2001 From: dnaq Date: Sat, 25 Sep 2021 13:13:38 +0200 Subject: [PATCH 09/13] something that might work on chibios, but it's completely untested --- tmk_core/protocol/chibios/chibios.c | 7 +++++++ tmk_core/protocol/chibios/usb_main.c | 20 ++++++++++++++++++-- tmk_core/protocol/usb_descriptor.h | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index c9a480c325..3b2e21c6f6 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -74,6 +74,10 @@ void virtser_task(void); void raw_hid_task(void); #endif +#ifdef PLOVER_HID_ENABLE +void plover_hid_task(void); +#endif + #ifdef CONSOLE_ENABLE void console_task(void); #endif @@ -218,4 +222,7 @@ void protocol_post_task(void) { #ifdef RAW_ENABLE raw_hid_task(); #endif +#ifdef PLOVER_HID_ENABLE + plover_hid_task(); +#endif } diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 0ff7dc0f3d..00ef935a8e 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -355,7 +355,9 @@ static usb_driver_configs_t drivers = { #ifdef PLOVER_HID_ENABLE # define PLOVER_HID_IN_CAPACITY 4 +# define PLOVER_HID_OUT_CAPACITY 4 # define PLOVER_HID_IN_MODE USB_EP_MODE_TYPE_INTR +# define PLOVER_HID_OUT_MODE USB_EP_MODE_TYPE_INTR .plover_hid_driver = QMK_USB_DRIVER_CONFIG(PLOVER_HID, 0, false), #endif @@ -1097,8 +1099,22 @@ void console_task(void) { #endif /* CONSOLE_ENABLE */ #ifdef PLOVER_HID_ENABLE -void plover_hid_send(uint8_t data[PLOVER_HID_SIMPLE_REPORT_SIZE]) { - chnWrite(&drivers.plover_hid_driver.driver, data, PLOVER_HID_SIMPLE_REPORT_SIZE); +static bool plover_hid_report_updated = false; +static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0}; +void plover_hid_update(uint8_t button, bool pressed) { + if (pressed) { + plover_hid_current_report[button/8] |= (1 << (7 - (button % 8))); + } else { + plover_hid_current_report[button/8] &= ~(1 << (7 - (button % 8))); + } + plover_hid_report_updated = true; +} + +void plover_hid_task(void) { + if (plover_hid_report_updated) { + chnWrite(&drivers.plover_hid_driver.driver, plover_hid_current_report, PLOVER_HID_EPSIZE); + plover_hid_report_updated = false; + } } #endif diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index 1bc9622977..d3a1bfab0a 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -236,6 +236,7 @@ enum usb_endpoints { #ifdef PLOVER_HID_ENABLE PLOVER_HID_IN_EPNUM = NEXT_EPNUM, + PLOVER_HID_OUT_EPNUM = NEXT_EPNUM, #endif #ifdef SHARED_EP_ENABLE From 8dc4d2a9ea687e7fb258c6cb118b115f3bc19b7b Mon Sep 17 00:00:00 2001 From: dnaq Date: Mon, 27 Sep 2021 21:06:15 +0200 Subject: [PATCH 10/13] descriptor changes + always force report id --- tmk_core/protocol/chibios/usb_main.c | 8 ++++---- tmk_core/protocol/lufa/lufa.c | 8 ++++---- tmk_core/protocol/usb_descriptor.c | 7 ++++--- tmk_core/protocol/usb_descriptor.h | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 00ef935a8e..9100092b7d 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -1100,19 +1100,19 @@ void console_task(void) { #ifdef PLOVER_HID_ENABLE static bool plover_hid_report_updated = false; -static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0}; +static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0x50}; void plover_hid_update(uint8_t button, bool pressed) { if (pressed) { - plover_hid_current_report[button/8] |= (1 << (7 - (button % 8))); + plover_hid_current_report[1 + button/8] |= (1 << (7 - (button % 8))); } else { - plover_hid_current_report[button/8] &= ~(1 << (7 - (button % 8))); + plover_hid_current_report[1 + button/8] &= ~(1 << (7 - (button % 8))); } plover_hid_report_updated = true; } void plover_hid_task(void) { if (plover_hid_report_updated) { - chnWrite(&drivers.plover_hid_driver.driver, plover_hid_current_report, PLOVER_HID_EPSIZE); + chnWrite(&drivers.plover_hid_driver.driver, plover_hid_current_report, sizeof(plover_hid_current_report)); plover_hid_report_updated = false; } } diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 83385197e7..f20c253fec 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -215,12 +215,12 @@ static void raw_hid_task(void) { #ifdef PLOVER_HID_ENABLE static bool plover_hid_report_updated = false; -static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0}; +static uint8_t plover_hid_current_report[PLOVER_HID_EPSIZE] = {0x50}; void plover_hid_update(uint8_t button, bool pressed) { if (pressed) { - plover_hid_current_report[button/8] |= (1 << (7 - (button % 8))); + plover_hid_current_report[1 + button/8] |= (1 << (7 - (button % 8))); } else { - plover_hid_current_report[button/8] &= ~(1 << (7 - (button % 8))); + plover_hid_current_report[1 + button/8] &= ~(1 << (7 - (button % 8))); } plover_hid_report_updated = true; } @@ -239,7 +239,7 @@ void plover_hid_task(void) { if (Endpoint_IsINReady()) { // Write data - Endpoint_Write_Stream_LE(plover_hid_current_report, PLOVER_HID_EPSIZE, NULL); + Endpoint_Write_Stream_LE(plover_hid_current_report, sizeof(plover_hid_current_report), NULL); // Finalize The stream transfer to send the last packet Endpoint_ClearIN(); plover_hid_report_updated = false; diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 34d205b1f3..f3275e07d8 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -327,12 +327,13 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { 0x06, 0x50, 0xff, // UsagePage (65360) 0x0a, 0x56, 0x4c, // Usage (19542) 0xa1, 0x02, // Collection (Logical) + 0x85, 0x50, // ReportID (80) 0x25, 0x01, // LogicalMaximum (1) 0x75, 0x01, // ReportSize (1) 0x95, 0x40, // ReportCount (64) - 0x05, 0x09, // UsagePage (button) - 0x19, 0x00, // UsageMinimum (Button(0)) - 0x29, 0x3f, // UsageMaximum (Button(63)) + 0x05, 0x0a, // UsagePage (ordinal) + 0x19, 0x00, // UsageMinimum (Ordinal(0)) + 0x29, 0x3f, // UsageMaximum (Ordinal(63)) 0x81, 0x02, // Input (Variable) 0xc0, // EndCollection }; diff --git a/tmk_core/protocol/usb_descriptor.h b/tmk_core/protocol/usb_descriptor.h index d3a1bfab0a..229dd3c2be 100644 --- a/tmk_core/protocol/usb_descriptor.h +++ b/tmk_core/protocol/usb_descriptor.h @@ -319,7 +319,7 @@ enum usb_endpoints { #define SHARED_EPSIZE 32 #define MOUSE_EPSIZE 8 #define RAW_EPSIZE 32 -#define PLOVER_HID_EPSIZE 8 +#define PLOVER_HID_EPSIZE 9 #define CONSOLE_EPSIZE 32 #define MIDI_STREAM_EPSIZE 64 #define CDC_NOTIFICATION_EPSIZE 8 From 6ee8f1215e295e7609cdea4508b299613f5f2f21 Mon Sep 17 00:00:00 2001 From: dnaq Date: Wed, 29 Sep 2021 13:12:49 +0200 Subject: [PATCH 11/13] fix doc comment --- tmk_core/protocol/lufa/lufa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index f20c253fec..9a0549f6ec 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -514,7 +514,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) { #endif #ifdef PLOVER_HID_ENABLE - /* Setup raw HID endpoints */ + /* Setup Plover HID endpoint */ ConfigSuccess &= Endpoint_ConfigureEndpoint((PLOVER_HID_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, PLOVER_HID_EPSIZE, 1); #endif From 3cadcc0cd9fabb7f43b8a0c1ebed28a1a0f8fe49 Mon Sep 17 00:00:00 2001 From: Antonius Frie Date: Sun, 10 Oct 2021 17:35:53 +0200 Subject: [PATCH 12/13] convert plover hid descriptor to the HI macros --- tmk_core/protocol/usb_descriptor.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index f3275e07d8..10f6c39dc0 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -324,18 +324,19 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM RawReport[] = { #ifdef PLOVER_HID_ENABLE const USB_Descriptor_HIDReport_Datatype_t PROGMEM PloverReport[] = { - 0x06, 0x50, 0xff, // UsagePage (65360) - 0x0a, 0x56, 0x4c, // Usage (19542) - 0xa1, 0x02, // Collection (Logical) - 0x85, 0x50, // ReportID (80) - 0x25, 0x01, // LogicalMaximum (1) - 0x75, 0x01, // ReportSize (1) - 0x95, 0x40, // ReportCount (64) - 0x05, 0x0a, // UsagePage (ordinal) - 0x19, 0x00, // UsageMinimum (Ordinal(0)) - 0x29, 0x3f, // UsageMaximum (Ordinal(63)) - 0x81, 0x02, // Input (Variable) - 0xc0, // EndCollection + HID_RI_USAGE_PAGE(16, 0xff50), // + HID_RI_USAGE(16, 0x4c56), // Vendor Defined (0xff P L V) + HID_RI_COLLECTION(8, 0x01), // Application + HID_RI_REPORT_ID(8, 80), + HID_RI_LOGICAL_MINIMUM(8, 0), + HID_RI_LOGICAL_MAXIMUM(8, 1), + HID_RI_REPORT_SIZE(8, 1), + HID_RI_REPORT_COUNT(8, 64), + HID_RI_USAGE_PAGE(8, 0x0a), // Usage Page: Ordinal + HID_RI_USAGE_MINIMUM(8, 0), + HID_RI_USAGE_MAXIMUM(8, 63), + HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_END_COLLECTION(0), }; #endif From 859b73ef3e05b919932e1746aa98fb959d6a339f Mon Sep 17 00:00:00 2001 From: dnaq Date: Wed, 15 Jun 2022 20:38:23 +0200 Subject: [PATCH 13/13] Change to non-insane keycodes for plover-hid Previously we had an idea to stick to the geminipr keycodes as far as possible, but that only made implementing this protocol much harder than it needed to be, so switch to a sequential numbering scheme, and add all keys outside of the standard steno keys as `X`-keys instead. The ordering of the standard steno keys now corresponds to the ordering of the TXBolt protocol. --- .../georgi/keymaps/plover-hid/keymap.c | 6 +- quantum/keymap_extras/keymap_plover_hid.h | 68 +++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c b/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c index c83b64c8f9..66ba17c7f1 100644 --- a/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c +++ b/keyboards/gboards/georgi/keymaps/plover-hid/keymap.c @@ -42,9 +42,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // Main layer, everything goes through here [0] = LAYOUT_georgi( - PLV_X1, PLV_S1, PLV_TL, PLV_PL, PLV_HL, PLV_ST1, PLV_ST3, PLV_FR, PLV_PR, PLV_LR, PLV_TR, PLV_DR, - PLV_X2, PLV_S2, PLV_KL, PLV_WL, PLV_RL, PLV_ST2, PLV_ST4, PLV_RR, PLV_BR, PLV_GR, PLV_SR, PLV_ZR, - PLV_N1, PLV_A, PLV_O, PLV_E, PLV_U, PLV_N7 + PLV_X1, PLV_SL, PLV_TL, PLV_PL, PLV_HL, PLV_STR, PLV_STR, PLV_FR, PLV_PR, PLV_LR, PLV_TR, PLV_DR, + PLV_X2, PLV_SL, PLV_KL, PLV_WL, PLV_RL, PLV_STR, PLV_STR, PLV_RR, PLV_BR, PLV_GR, PLV_SR, PLV_ZR, + PLV_NUM, PLV_A, PLV_O, PLV_E, PLV_U, PLV_NUM ) }; // Don't fuck with this, thanks. diff --git a/quantum/keymap_extras/keymap_plover_hid.h b/quantum/keymap_extras/keymap_plover_hid.h index 4792f5d1f3..6a8d52d087 100644 --- a/quantum/keymap_extras/keymap_plover_hid.h +++ b/quantum/keymap_extras/keymap_plover_hid.h @@ -21,47 +21,32 @@ // List of keycodes for the plover HID. enum steno_keycodes { PLV__MIN = QK_PLOVER_HID, - PLV_N1 = PLV__MIN, - PLV_N2, - PLV_N3, - PLV_N4, - PLV_N5, - PLV_N6, - PLV_N7, - PLV_N8, - PLV_N9, - PLV_NA, - PLV_NB, - PLV_NC, - PLV_X1, - PLV_S1, + PLV_SL = PLV__MIN, PLV_TL, - PLV_PL, - PLV_HL, - PLV_ST1, - PLV_ST3, - PLV_FR, - PLV_PR, - PLV_LR, - PLV_TR, - PLV_DR, - PLV_X2, - PLV_S2, PLV_KL, + PLV_PL, PLV_WL, + PLV_HL, PLV_RL, - PLV_ST2, - PLV_ST4, - PLV_RR, - PLV_BR, - PLV_GR, - PLV_SR, - PLV_ZR, - PLV_X3, PLV_A, PLV_O, + PLV_STR, PLV_E, PLV_U, + PLV_FR, + PLV_RR, + PLV_PR, + PLV_BR, + PLV_LR, + PLV_GR, + PLV_TR, + PLV_SR, + PLV_DR, + PLV_ZR, + PLV_NUM, + PLV_X1, + PLV_X2, + PLV_X3, PLV_X4, PLV_X5, PLV_X6, @@ -85,5 +70,20 @@ enum steno_keycodes { PLV_X24, PLV_X25, PLV_X26, - PLV__MAX = PLV_X26, + PLV_X27, + PLV_X28, + PLV_X29, + PLV_X30, + PLV_X31, + PLV_X32, + PLV_X33, + PLV_X34, + PLV_X35, + PLV_X36, + PLV_X37, + PLV_X38, + PLV_X39, + PLV_X40, + PLV_X41, + PLV__MAX = PLV_X41, };