Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
65006cc376 | ||
|
|
fc01b29823 | ||
|
|
462595ef03 | ||
|
|
b0d85795f4 | ||
|
|
2c91ef51db | ||
|
|
a54e7ac0a8 | ||
|
|
64f54c268b | ||
|
|
d889d51a7d | ||
|
|
b284e9fa58 | ||
|
|
1a0da7971a | ||
|
|
53a82a5f57 | ||
|
|
10985abcdb | ||
|
|
e60a282742 | ||
|
|
a691b16ebe | ||
|
|
c38114648a | ||
|
|
3fc4419f4f | ||
|
|
033bdf6491 | ||
|
|
18e3ba9558 | ||
|
|
3fb552cc55 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
|
and this project adheres to the [UHK Versioning](VERSIONING.md) conventions.
|
||||||
|
|
||||||
|
## [8.3.1] - 2018-06-07
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.1.0 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Fix media key repetition bug on Windows.
|
||||||
|
- Fix bug that made Windows unable to sleep when the UHK was plugged in.
|
||||||
|
- Fix bug that made Chrome Remote Desktop blocked from interacting on Windows.
|
||||||
|
- Fix bug that made locked layers not release. This bug was introduced in the previous release.
|
||||||
|
|
||||||
|
## [8.3.0] - 2018-06-03
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.**1.0** | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Make the config parser handle switch layer actions with hold on double tap disabled. `USERCONFIG:MINOR`
|
||||||
|
- Set key debounce timeout from 80ms to 100ms. This should further reduce key chattering.
|
||||||
|
|
||||||
|
## [8.2.5] - 2018-05-27
|
||||||
|
|
||||||
|
Device Protocol: 4.3.1 | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
||||||
|
|
||||||
|
- Now really fix the bug that made the hardware and user configuration not load from the EEPROM on some hosts right after firmware update.
|
||||||
|
|
||||||
## [8.2.4] - 2018-05-21
|
## [8.2.4] - 2018-05-21
|
||||||
|
|
||||||
Device Protocol: 4.3.**1** | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
Device Protocol: 4.3.**1** | Module Protocol: 4.0.0 | User Config: 4.0.1 | Hardware Config: 1.0.0
|
||||||
|
|||||||
Submodule lib/agent updated: ab8ae31324...81a83994ab
@@ -48,7 +48,7 @@ static parser_error_t parseKeyStrokeAction(key_action_t *keyAction, uint8_t keyS
|
|||||||
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer)
|
static parser_error_t parseSwitchLayerAction(key_action_t *KeyAction, config_buffer_t *buffer)
|
||||||
{
|
{
|
||||||
uint8_t layer = ReadUInt8(buffer) + 1;
|
uint8_t layer = ReadUInt8(buffer) + 1;
|
||||||
uint8_t mode = ReadBool(buffer) ? SwitchLayerMode_Toggle : SwitchLayerMode_HoldAndDoubleTapToggle;
|
switch_layer_mode_t mode = ReadUInt8(buffer);
|
||||||
|
|
||||||
KeyAction->type = KeyActionType_SwitchLayer;
|
KeyAction->type = KeyActionType_SwitchLayer;
|
||||||
KeyAction->switchLayer.layer = layer;
|
KeyAction->switchLayer.layer = layer;
|
||||||
|
|||||||
@@ -35,10 +35,12 @@
|
|||||||
#define I2C_EEPROM_BUS_BAUD_RATE 1000000 // 1 Mhz is the maximum speed of the EEPROM.
|
#define I2C_EEPROM_BUS_BAUD_RATE 1000000 // 1 Mhz is the maximum speed of the EEPROM.
|
||||||
#define I2C_EEPROM_BUS_MUX kPORT_MuxAlt2
|
#define I2C_EEPROM_BUS_MUX kPORT_MuxAlt2
|
||||||
|
|
||||||
|
#define I2C_EEPROM_BUS_SDA_GPIO GPIOC
|
||||||
#define I2C_EEPROM_BUS_SDA_PORT PORTC
|
#define I2C_EEPROM_BUS_SDA_PORT PORTC
|
||||||
#define I2C_EEPROM_BUS_SDA_CLOCK kCLOCK_PortC
|
#define I2C_EEPROM_BUS_SDA_CLOCK kCLOCK_PortC
|
||||||
#define I2C_EEPROM_BUS_SDA_PIN 11
|
#define I2C_EEPROM_BUS_SDA_PIN 11
|
||||||
|
|
||||||
|
#define I2C_EEPROM_BUS_SCL_GPIO GPIOC
|
||||||
#define I2C_EEPROM_BUS_SCL_PORT PORTC
|
#define I2C_EEPROM_BUS_SCL_PORT PORTC
|
||||||
#define I2C_EEPROM_BUS_SCL_CLOCK kCLOCK_PortC
|
#define I2C_EEPROM_BUS_SCL_CLOCK kCLOCK_PortC
|
||||||
#define I2C_EEPROM_BUS_SCL_PIN 10
|
#define I2C_EEPROM_BUS_SCL_PIN 10
|
||||||
|
|||||||
@@ -21,6 +21,38 @@ bool IsBusPalOn;
|
|||||||
volatile uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE;
|
volatile uint32_t I2cMainBusRequestedBaudRateBps = I2C_MAIN_BUS_NORMAL_BAUD_RATE;
|
||||||
volatile uint32_t I2cMainBusActualBaudRateBps;
|
volatile uint32_t I2cMainBusActualBaudRateBps;
|
||||||
|
|
||||||
|
static i2c_bus_t i2cMainBus = {
|
||||||
|
.baseAddr = I2C_MAIN_BUS_BASEADDR,
|
||||||
|
.clockSrc = I2C_MAIN_BUS_CLK_SRC,
|
||||||
|
.mux = I2C_MAIN_BUS_MUX,
|
||||||
|
|
||||||
|
.sdaClock = I2C_MAIN_BUS_SDA_CLOCK,
|
||||||
|
.sdaGpio = I2C_MAIN_BUS_SDA_GPIO,
|
||||||
|
.sdaPort = I2C_MAIN_BUS_SDA_PORT,
|
||||||
|
.sdaPin = I2C_MAIN_BUS_SDA_PIN,
|
||||||
|
|
||||||
|
.sclClock = I2C_MAIN_BUS_SCL_CLOCK,
|
||||||
|
.sclGpio = I2C_MAIN_BUS_SCL_GPIO,
|
||||||
|
.sclPort = I2C_MAIN_BUS_SCL_PORT,
|
||||||
|
.sclPin = I2C_MAIN_BUS_SCL_PIN,
|
||||||
|
};
|
||||||
|
|
||||||
|
static i2c_bus_t i2cEepromBus = {
|
||||||
|
.baseAddr = I2C_EEPROM_BUS_BASEADDR,
|
||||||
|
.clockSrc = I2C_EEPROM_BUS_CLK_SRC,
|
||||||
|
.mux = I2C_EEPROM_BUS_MUX,
|
||||||
|
|
||||||
|
.sdaClock = I2C_EEPROM_BUS_SDA_CLOCK,
|
||||||
|
.sdaGpio = I2C_EEPROM_BUS_SDA_GPIO,
|
||||||
|
.sdaPort = I2C_EEPROM_BUS_SDA_PORT,
|
||||||
|
.sdaPin = I2C_EEPROM_BUS_SDA_PIN,
|
||||||
|
|
||||||
|
.sclClock = I2C_EEPROM_BUS_SCL_CLOCK,
|
||||||
|
.sclGpio = I2C_EEPROM_BUS_SCL_GPIO,
|
||||||
|
.sclPort = I2C_EEPROM_BUS_SCL_PORT,
|
||||||
|
.sclPin = I2C_EEPROM_BUS_SCL_PIN,
|
||||||
|
};
|
||||||
|
|
||||||
static void initBusPalState(void) {
|
static void initBusPalState(void) {
|
||||||
IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal;
|
IsBusPalOn = Wormhole.magicNumber == WORMHOLE_MAGIC_NUMBER && Wormhole.enumerationMode == EnumerationMode_BusPal;
|
||||||
if (IsBusPalOn) {
|
if (IsBusPalOn) {
|
||||||
@@ -32,12 +64,12 @@ static void initBusPalState(void) {
|
|||||||
static void initInterruptPriorities(void)
|
static void initInterruptPriorities(void)
|
||||||
{
|
{
|
||||||
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
|
NVIC_SetPriority(PIT_I2C_WATCHDOG_IRQ_ID, 1);
|
||||||
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 2);
|
NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 0);
|
||||||
NVIC_SetPriority(I2C_EEPROM_BUS_IRQ_ID, 2);
|
NVIC_SetPriority(PIT_TIMER_IRQ_ID, 3);
|
||||||
NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 3);
|
NVIC_SetPriority(PIT_KEY_SCANNER_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 3);
|
NVIC_SetPriority(PIT_KEY_DEBOUNCER_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 3);
|
NVIC_SetPriority(I2C_MAIN_BUS_IRQ_ID, 4);
|
||||||
NVIC_SetPriority(USB_IRQ_ID, 3);
|
NVIC_SetPriority(USB_IRQ_ID, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void delay(void)
|
static void delay(void)
|
||||||
@@ -45,91 +77,73 @@ static void delay(void)
|
|||||||
for (volatile uint32_t i=0; i<62; i++);
|
for (volatile uint32_t i=0; i<62; i++);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recoverI2c(void)
|
static void recoverI2cBus(i2c_bus_t *i2cBus)
|
||||||
{
|
{
|
||||||
PORT_SetPinMux(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, kPORT_MuxAsGpio);
|
PORT_SetPinMux(i2cBus->sdaPort, i2cBus->sdaPin, kPORT_MuxAsGpio);
|
||||||
PORT_SetPinMux(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, kPORT_MuxAsGpio);
|
PORT_SetPinMux(i2cBus->sclPort, i2cBus->sclPin, kPORT_MuxAsGpio);
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
GPIO_PinInit(i2cBus->sclGpio, i2cBus->sclPin, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
||||||
|
|
||||||
bool isOn = true;
|
bool isOn = true;
|
||||||
for (int i=0; i<20; i++) {
|
for (int i=0; i<20; i++) {
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, &(gpio_pin_config_t){kGPIO_DigitalInput});
|
GPIO_PinInit(i2cBus->sdaGpio, i2cBus->sdaPin, &(gpio_pin_config_t){kGPIO_DigitalInput});
|
||||||
bool isSdaHigh = GPIO_ReadPinInput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN);
|
bool isSdaHigh = GPIO_ReadPinInput(i2cBus->sdaGpio, i2cBus->sdaPin);
|
||||||
GPIO_PinInit(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
GPIO_PinInit(i2cBus->sdaGpio, i2cBus->sdaPin, &(gpio_pin_config_t){kGPIO_DigitalOutput, 1});
|
||||||
|
|
||||||
if (isSdaHigh) {
|
if (isSdaHigh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, isOn);
|
GPIO_WritePinOutput(i2cBus->sclGpio, i2cBus->sclPin, isOn);
|
||||||
delay();
|
delay();
|
||||||
isOn = !isOn;
|
isOn = !isOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, 0);
|
GPIO_WritePinOutput(i2cBus->sdaGpio, i2cBus->sdaPin, 0);
|
||||||
delay();
|
delay();
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SCL_GPIO, I2C_MAIN_BUS_SCL_PIN, 1);
|
GPIO_WritePinOutput(i2cBus->sclGpio, i2cBus->sclPin, 1);
|
||||||
delay();
|
delay();
|
||||||
GPIO_WritePinOutput(I2C_MAIN_BUS_SDA_GPIO, I2C_MAIN_BUS_SDA_PIN, 1);
|
GPIO_WritePinOutput(i2cBus->sdaGpio, i2cBus->sdaPin, 1);
|
||||||
delay();
|
delay();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initI2cMainBus(void)
|
static void initI2cBus(i2c_bus_t *i2cBus)
|
||||||
{
|
{
|
||||||
CLOCK_EnableClock(I2C_MAIN_BUS_SDA_CLOCK);
|
CLOCK_EnableClock(i2cBus->sdaClock);
|
||||||
CLOCK_EnableClock(I2C_MAIN_BUS_SCL_CLOCK);
|
CLOCK_EnableClock(i2cBus->sclClock);
|
||||||
|
|
||||||
recoverI2c();
|
recoverI2cBus(i2cBus);
|
||||||
|
|
||||||
port_pin_config_t pinConfig = {
|
port_pin_config_t pinConfig = {
|
||||||
.pullSelect = kPORT_PullUp,
|
.pullSelect = kPORT_PullUp,
|
||||||
.openDrainEnable = kPORT_OpenDrainEnable,
|
.openDrainEnable = kPORT_OpenDrainEnable,
|
||||||
.mux = I2C_MAIN_BUS_MUX,
|
.mux = i2cBus->mux,
|
||||||
};
|
};
|
||||||
|
|
||||||
PORT_SetPinConfig(I2C_MAIN_BUS_SDA_PORT, I2C_MAIN_BUS_SDA_PIN, &pinConfig);
|
PORT_SetPinConfig(i2cBus->sdaPort, i2cBus->sdaPin, &pinConfig);
|
||||||
PORT_SetPinConfig(I2C_MAIN_BUS_SCL_PORT, I2C_MAIN_BUS_SCL_PIN, &pinConfig);
|
PORT_SetPinConfig(i2cBus->sclPort, i2cBus->sclPin, &pinConfig);
|
||||||
|
|
||||||
i2c_master_config_t masterConfig;
|
i2c_master_config_t masterConfig;
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
I2C_MasterGetDefaultConfig(&masterConfig);
|
||||||
masterConfig.baudRate_Bps = I2cMainBusRequestedBaudRateBps;
|
masterConfig.baudRate_Bps = i2cBus == &i2cMainBus ? I2cMainBusRequestedBaudRateBps : I2C_EEPROM_BUS_BAUD_RATE;
|
||||||
uint32_t sourceClock = CLOCK_GetFreq(I2C_MAIN_BUS_CLK_SRC);
|
uint32_t sourceClock = CLOCK_GetFreq(i2cBus->clockSrc);
|
||||||
I2C_MasterInit(I2C_MAIN_BUS_BASEADDR, &masterConfig, sourceClock);
|
I2C_MasterInit(i2cBus->baseAddr, &masterConfig, sourceClock);
|
||||||
|
|
||||||
|
if (i2cBus == &i2cMainBus) {
|
||||||
I2cMainBusActualBaudRateBps = I2C_ActualBaudRate;
|
I2cMainBusActualBaudRateBps = I2C_ActualBaudRate;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ReinitI2cMainBus(void)
|
void ReinitI2cMainBus(void)
|
||||||
{
|
{
|
||||||
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
I2C_MasterDeinit(I2C_MAIN_BUS_BASEADDR);
|
||||||
initI2cMainBus();
|
initI2cBus(&i2cMainBus);
|
||||||
InitSlaveScheduler();
|
InitSlaveScheduler();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initI2cEepromBus(void)
|
|
||||||
{
|
|
||||||
port_pin_config_t pinConfig = {
|
|
||||||
.pullSelect = kPORT_PullUp,
|
|
||||||
.openDrainEnable = kPORT_OpenDrainEnable,
|
|
||||||
.mux = I2C_EEPROM_BUS_MUX,
|
|
||||||
};
|
|
||||||
|
|
||||||
CLOCK_EnableClock(I2C_EEPROM_BUS_SDA_CLOCK);
|
|
||||||
CLOCK_EnableClock(I2C_EEPROM_BUS_SCL_CLOCK);
|
|
||||||
|
|
||||||
PORT_SetPinConfig(I2C_EEPROM_BUS_SDA_PORT, I2C_EEPROM_BUS_SDA_PIN, &pinConfig);
|
|
||||||
PORT_SetPinConfig(I2C_EEPROM_BUS_SCL_PORT, I2C_EEPROM_BUS_SCL_PIN, &pinConfig);
|
|
||||||
|
|
||||||
i2c_master_config_t masterConfig;
|
|
||||||
I2C_MasterGetDefaultConfig(&masterConfig);
|
|
||||||
masterConfig.baudRate_Bps = I2C_EEPROM_BUS_BAUD_RATE;
|
|
||||||
uint32_t sourceClock = CLOCK_GetFreq(I2C_EEPROM_BUS_CLK_SRC);
|
|
||||||
I2C_MasterInit(I2C_EEPROM_BUS_BASEADDR, &masterConfig, sourceClock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void initI2c(void)
|
static void initI2c(void)
|
||||||
{
|
{
|
||||||
initI2cMainBus();
|
initI2cBus(&i2cMainBus);
|
||||||
initI2cEepromBus();
|
initI2cBus(&i2cEepromBus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitPeripherals(void)
|
void InitPeripherals(void)
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
#ifndef __INIT_PERIPHERALS_H__
|
#ifndef __INIT_PERIPHERALS_H__
|
||||||
#define __INIT_PERIPHERALS_H__
|
#define __INIT_PERIPHERALS_H__
|
||||||
|
|
||||||
// Includes
|
// Includes:
|
||||||
|
|
||||||
#include "fsl_common.h"
|
#include "fsl_common.h"
|
||||||
|
|
||||||
|
// Typedefs:
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
clock_name_t clockSrc;
|
||||||
|
I2C_Type *baseAddr;
|
||||||
|
uint16_t mux;
|
||||||
|
|
||||||
|
clock_ip_name_t sdaClock;
|
||||||
|
GPIO_Type *sdaGpio;
|
||||||
|
PORT_Type *sdaPort;
|
||||||
|
uint32_t sdaPin;
|
||||||
|
|
||||||
|
clock_ip_name_t sclClock;
|
||||||
|
GPIO_Type *sclGpio;
|
||||||
|
PORT_Type *sclPort;
|
||||||
|
uint32_t sclPin;
|
||||||
|
} i2c_bus_t;
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern bool IsBusPalOn;
|
extern bool IsBusPalOn;
|
||||||
|
|||||||
@@ -28,9 +28,9 @@
|
|||||||
} keystroke_type_t;
|
} keystroke_type_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SwitchLayerMode_Hold,
|
|
||||||
SwitchLayerMode_HoldAndDoubleTapToggle,
|
SwitchLayerMode_HoldAndDoubleTapToggle,
|
||||||
SwitchLayerMode_Toggle,
|
SwitchLayerMode_Toggle,
|
||||||
|
SwitchLayerMode_Hold,
|
||||||
} switch_layer_mode_t;
|
} switch_layer_mode_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
#define KEY_DEBOUNCER_INTERVAL_MSEC 1
|
||||||
#define KEY_DEBOUNCER_TIMEOUT_MSEC 80
|
#define KEY_DEBOUNCER_TIMEOUT_MSEC 100
|
||||||
|
|
||||||
// Functions:
|
// Functions:
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
#include "keymap.h"
|
#include "keymap.h"
|
||||||
|
|
||||||
static bool heldLayers[LAYER_COUNT];
|
static bool heldLayers[LAYER_COUNT];
|
||||||
static switch_layer_mode_t pressedLayers[LAYER_COUNT];
|
static bool toggledLayers[LAYER_COUNT];
|
||||||
|
|
||||||
void updateLayerStates(void)
|
void updateLayerStates(void)
|
||||||
{
|
{
|
||||||
memset(heldLayers, false, LAYER_COUNT);
|
memset(heldLayers, false, LAYER_COUNT);
|
||||||
memset(pressedLayers, false, LAYER_COUNT);
|
memset(toggledLayers, false, LAYER_COUNT);
|
||||||
|
|
||||||
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
|
||||||
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
|
||||||
@@ -20,9 +20,8 @@ void updateLayerStates(void)
|
|||||||
if (action.type == KeyActionType_SwitchLayer) {
|
if (action.type == KeyActionType_SwitchLayer) {
|
||||||
if (action.switchLayer.mode != SwitchLayerMode_Toggle) {
|
if (action.switchLayer.mode != SwitchLayerMode_Toggle) {
|
||||||
heldLayers[action.switchLayer.layer] = true;
|
heldLayers[action.switchLayer.layer] = true;
|
||||||
}
|
} else if (!keyState->previous) {
|
||||||
if (action.switchLayer.mode != SwitchLayerMode_Hold && !keyState->previous && keyState->current) {
|
toggledLayers[action.switchLayer.layer] = true;
|
||||||
pressedLayers[action.switchLayer.layer] = action.switchLayer.mode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,11 +39,11 @@ layer_id_t GetActiveLayer()
|
|||||||
// Handle toggled layers
|
// Handle toggled layers
|
||||||
|
|
||||||
for (layer_id_t layerId=LayerId_Mod; layerId<=LayerId_Mouse; layerId++) {
|
for (layer_id_t layerId=LayerId_Mod; layerId<=LayerId_Mouse; layerId++) {
|
||||||
if (pressedLayers[layerId]) {
|
if (toggledLayers[layerId]) {
|
||||||
if (ToggledLayer == layerId) {
|
if (ToggledLayer == layerId) {
|
||||||
ToggledLayer = LayerId_Base;
|
ToggledLayer = LayerId_Base;
|
||||||
break;
|
break;
|
||||||
} else if (ToggledLayer == LayerId_Base && pressedLayers[layerId] == SwitchLayerMode_Toggle) {
|
} else if (ToggledLayer == LayerId_Base && toggledLayers[layerId] == SwitchLayerMode_Toggle) {
|
||||||
ToggledLayer = layerId;
|
ToggledLayer = layerId;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
|
static usb_basic_keyboard_report_t usbBasicKeyboardReports[2];
|
||||||
uint32_t UsbBasicKeyboardActionCounter;
|
uint32_t UsbBasicKeyboardActionCounter;
|
||||||
usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport = usbBasicKeyboardReports;
|
usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport = usbBasicKeyboardReports;
|
||||||
volatile bool IsUsbBasicKeyboardReportSent = false;
|
|
||||||
static uint8_t usbBasicKeyboardInBuffer[USB_BASIC_KEYBOARD_REPORT_LENGTH];
|
static uint8_t usbBasicKeyboardInBuffer[USB_BASIC_KEYBOARD_REPORT_LENGTH];
|
||||||
|
|
||||||
static usb_basic_keyboard_report_t* getInactiveUsbBasicKeyboardReport(void)
|
static usb_basic_keyboard_report_t* getInactiveUsbBasicKeyboardReport(void)
|
||||||
@@ -22,14 +21,12 @@ void ResetActiveUsbBasicKeyboardReport(void)
|
|||||||
bzero(ActiveUsbBasicKeyboardReport, USB_BASIC_KEYBOARD_REPORT_LENGTH);
|
bzero(ActiveUsbBasicKeyboardReport, USB_BASIC_KEYBOARD_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_status_t UsbBasicKeyboardAction(void)
|
usb_status_t UsbBasicKeyboardAction(void)
|
||||||
{
|
{
|
||||||
usb_status_t status = USB_DeviceHidSend(
|
UsbBasicKeyboardActionCounter++;
|
||||||
|
return USB_DeviceHidSend(
|
||||||
UsbCompositeDevice.basicKeyboardHandle, USB_BASIC_KEYBOARD_ENDPOINT_INDEX,
|
UsbCompositeDevice.basicKeyboardHandle, USB_BASIC_KEYBOARD_ENDPOINT_INDEX,
|
||||||
(uint8_t*)getInactiveUsbBasicKeyboardReport(), USB_BASIC_KEYBOARD_REPORT_LENGTH);
|
(uint8_t*)getInactiveUsbBasicKeyboardReport(), USB_BASIC_KEYBOARD_REPORT_LENGTH);
|
||||||
IsUsbBasicKeyboardReportSent = true;
|
|
||||||
UsbBasicKeyboardActionCounter++;
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
||||||
@@ -38,10 +35,6 @@ usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, voi
|
|||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case kUSB_DeviceHidEventSendResponse:
|
case kUSB_DeviceHidEventSendResponse:
|
||||||
if (UsbCompositeDevice.attach) {
|
|
||||||
return UsbBasicKeyboardAction();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kUSB_DeviceHidEventGetReport:
|
case kUSB_DeviceHidEventGetReport:
|
||||||
error = kStatus_USB_InvalidRequest;
|
error = kStatus_USB_InvalidRequest;
|
||||||
break;
|
break;
|
||||||
@@ -80,7 +73,7 @@ usb_status_t UsbBasicKeyboardCallback(class_handle_t handle, uint32_t event, voi
|
|||||||
usb_status_t UsbBasicKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
usb_status_t UsbBasicKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
||||||
{
|
{
|
||||||
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
||||||
return UsbBasicKeyboardAction();
|
//return UsbBasicKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
@@ -88,7 +81,7 @@ usb_status_t UsbBasicKeyboardSetConfiguration(class_handle_t handle, uint8_t con
|
|||||||
usb_status_t UsbBasicKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
usb_status_t UsbBasicKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||||
{
|
{
|
||||||
if (USB_BASIC_KEYBOARD_INTERFACE_INDEX == interface) {
|
if (USB_BASIC_KEYBOARD_INTERFACE_INDEX == interface) {
|
||||||
return UsbBasicKeyboardAction();
|
//return UsbBasicKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern volatile bool IsUsbBasicKeyboardReportSent;
|
|
||||||
extern uint32_t UsbBasicKeyboardActionCounter;
|
extern uint32_t UsbBasicKeyboardActionCounter;
|
||||||
extern usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport;
|
extern usb_basic_keyboard_report_t* ActiveUsbBasicKeyboardReport;
|
||||||
|
|
||||||
@@ -43,5 +42,6 @@
|
|||||||
|
|
||||||
void ResetActiveUsbBasicKeyboardReport(void);
|
void ResetActiveUsbBasicKeyboardReport(void);
|
||||||
void SwitchActiveUsbBasicKeyboardReport(void);
|
void SwitchActiveUsbBasicKeyboardReport(void);
|
||||||
|
usb_status_t UsbBasicKeyboardAction(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
uint32_t UsbMediaKeyboardActionCounter;
|
uint32_t UsbMediaKeyboardActionCounter;
|
||||||
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
|
static usb_media_keyboard_report_t usbMediaKeyboardReports[2];
|
||||||
usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports;
|
usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport = usbMediaKeyboardReports;
|
||||||
volatile bool IsUsbMediaKeyboardReportSent = false;
|
|
||||||
|
|
||||||
static usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void)
|
static usb_media_keyboard_report_t* getInactiveUsbMediaKeyboardReport(void)
|
||||||
{
|
{
|
||||||
@@ -20,14 +19,12 @@ void ResetActiveUsbMediaKeyboardReport(void)
|
|||||||
bzero(ActiveUsbMediaKeyboardReport, USB_MEDIA_KEYBOARD_REPORT_LENGTH);
|
bzero(ActiveUsbMediaKeyboardReport, USB_MEDIA_KEYBOARD_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_status_t UsbMediaKeyboardAction(void)
|
usb_status_t UsbMediaKeyboardAction()
|
||||||
{
|
{
|
||||||
usb_status_t status = USB_DeviceHidSend(
|
UsbMediaKeyboardActionCounter++;
|
||||||
|
return USB_DeviceHidSend(
|
||||||
UsbCompositeDevice.mediaKeyboardHandle, USB_MEDIA_KEYBOARD_ENDPOINT_INDEX,
|
UsbCompositeDevice.mediaKeyboardHandle, USB_MEDIA_KEYBOARD_ENDPOINT_INDEX,
|
||||||
(uint8_t*)getInactiveUsbMediaKeyboardReport(), USB_MEDIA_KEYBOARD_REPORT_LENGTH);
|
(uint8_t*)getInactiveUsbMediaKeyboardReport(), USB_MEDIA_KEYBOARD_REPORT_LENGTH);
|
||||||
IsUsbMediaKeyboardReportSent = true;
|
|
||||||
UsbMediaKeyboardActionCounter++;
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
||||||
@@ -36,10 +33,6 @@ usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, voi
|
|||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case kUSB_DeviceHidEventSendResponse:
|
case kUSB_DeviceHidEventSendResponse:
|
||||||
if (UsbCompositeDevice.attach) {
|
|
||||||
return UsbMediaKeyboardAction();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kUSB_DeviceHidEventGetReport:
|
case kUSB_DeviceHidEventGetReport:
|
||||||
case kUSB_DeviceHidEventSetReport:
|
case kUSB_DeviceHidEventSetReport:
|
||||||
case kUSB_DeviceHidEventRequestReportBuffer:
|
case kUSB_DeviceHidEventRequestReportBuffer:
|
||||||
@@ -60,7 +53,7 @@ usb_status_t UsbMediaKeyboardCallback(class_handle_t handle, uint32_t event, voi
|
|||||||
usb_status_t UsbMediaKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
usb_status_t UsbMediaKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
||||||
{
|
{
|
||||||
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
||||||
return UsbMediaKeyboardAction();
|
//return UsbMediaKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
@@ -68,7 +61,7 @@ usb_status_t UsbMediaKeyboardSetConfiguration(class_handle_t handle, uint8_t con
|
|||||||
usb_status_t UsbMediaKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
usb_status_t UsbMediaKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||||
{
|
{
|
||||||
if (USB_MEDIA_KEYBOARD_INTERFACE_INDEX == interface) {
|
if (USB_MEDIA_KEYBOARD_INTERFACE_INDEX == interface) {
|
||||||
return UsbMediaKeyboardAction();
|
//return UsbMediaKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern volatile bool IsUsbMediaKeyboardReportSent;
|
|
||||||
extern uint32_t UsbMediaKeyboardActionCounter;
|
extern uint32_t UsbMediaKeyboardActionCounter;
|
||||||
extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport;
|
extern usb_media_keyboard_report_t* ActiveUsbMediaKeyboardReport;
|
||||||
|
|
||||||
@@ -40,5 +39,6 @@
|
|||||||
|
|
||||||
void ResetActiveUsbMediaKeyboardReport(void);
|
void ResetActiveUsbMediaKeyboardReport(void);
|
||||||
void SwitchActiveUsbMediaKeyboardReport(void);
|
void SwitchActiveUsbMediaKeyboardReport(void);
|
||||||
|
usb_status_t UsbMediaKeyboardAction();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
uint32_t UsbMouseActionCounter;
|
uint32_t UsbMouseActionCounter;
|
||||||
static usb_mouse_report_t usbMouseReports[2];
|
static usb_mouse_report_t usbMouseReports[2];
|
||||||
usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports;
|
usb_mouse_report_t* ActiveUsbMouseReport = usbMouseReports;
|
||||||
volatile bool IsUsbMouseReportSent = false;
|
|
||||||
|
|
||||||
static usb_mouse_report_t* getInactiveUsbMouseReport(void)
|
static usb_mouse_report_t* getInactiveUsbMouseReport(void)
|
||||||
{
|
{
|
||||||
@@ -20,25 +19,31 @@ void ResetActiveUsbMouseReport(void)
|
|||||||
bzero(ActiveUsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
bzero(ActiveUsbMouseReport, USB_MOUSE_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static volatile usb_status_t usbMouseAction(void)
|
usb_status_t usbMouseAction(void)
|
||||||
{
|
{
|
||||||
usb_mouse_report_t *mouseReport = getInactiveUsbMouseReport();
|
UsbMouseActionCounter++;
|
||||||
IsUsbMouseReportSent = true;
|
return USB_DeviceHidSend(
|
||||||
return USB_DeviceHidSend(UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_INDEX,
|
UsbCompositeDevice.mouseHandle, USB_MOUSE_ENDPOINT_INDEX,
|
||||||
(uint8_t*)mouseReport, USB_MOUSE_REPORT_LENGTH);
|
(uint8_t*)getInactiveUsbMouseReport(), USB_MOUSE_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
||||||
{
|
{
|
||||||
UsbMouseActionCounter++;
|
static bool usbMouseActionActive = false;
|
||||||
usb_status_t error = kStatus_USB_Error;
|
usb_status_t error = kStatus_USB_Error;
|
||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case kUSB_DeviceHidEventSendResponse:
|
case kUSB_DeviceHidEventSendResponse:
|
||||||
if (UsbCompositeDevice.attach) {
|
if (UsbCompositeDevice.attach) {
|
||||||
|
// Send out the report continuously if the report is not zeros
|
||||||
|
usb_mouse_report_t *report = getInactiveUsbMouseReport();
|
||||||
|
uint8_t zeroBuf[sizeof(usb_mouse_report_t)] = { 0 };
|
||||||
|
bool reportChanged = memcmp(report, zeroBuf, sizeof(usb_mouse_report_t)) != 0;
|
||||||
|
if (usbMouseActionActive || reportChanged) {
|
||||||
|
usbMouseActionActive = reportChanged; // Used to send out all zeros once after a report has been sent
|
||||||
return usbMouseAction();
|
return usbMouseAction();
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case kUSB_DeviceHidEventGetReport:
|
case kUSB_DeviceHidEventGetReport:
|
||||||
case kUSB_DeviceHidEventSetReport:
|
case kUSB_DeviceHidEventSetReport:
|
||||||
case kUSB_DeviceHidEventRequestReportBuffer:
|
case kUSB_DeviceHidEventRequestReportBuffer:
|
||||||
@@ -59,7 +64,7 @@ usb_status_t UsbMouseCallback(class_handle_t handle, uint32_t event, void *param
|
|||||||
usb_status_t UsbMouseSetConfiguration(class_handle_t handle, uint8_t configuration)
|
usb_status_t UsbMouseSetConfiguration(class_handle_t handle, uint8_t configuration)
|
||||||
{
|
{
|
||||||
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
||||||
return usbMouseAction();
|
//return usbMouseAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
@@ -67,7 +72,7 @@ usb_status_t UsbMouseSetConfiguration(class_handle_t handle, uint8_t configurati
|
|||||||
usb_status_t UsbMouseSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
usb_status_t UsbMouseSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||||
{
|
{
|
||||||
if (USB_MOUSE_INTERFACE_INDEX == interface) {
|
if (USB_MOUSE_INTERFACE_INDEX == interface) {
|
||||||
return usbMouseAction();
|
//return usbMouseAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern volatile bool IsUsbMouseReportSent;
|
|
||||||
extern uint32_t UsbMouseActionCounter;
|
extern uint32_t UsbMouseActionCounter;
|
||||||
extern usb_mouse_report_t* ActiveUsbMouseReport;
|
extern usb_mouse_report_t* ActiveUsbMouseReport;
|
||||||
|
|
||||||
@@ -43,5 +42,6 @@
|
|||||||
|
|
||||||
void ResetActiveUsbMouseReport(void);
|
void ResetActiveUsbMouseReport(void);
|
||||||
void SwitchActiveUsbMouseReport(void);
|
void SwitchActiveUsbMouseReport(void);
|
||||||
|
usb_status_t usbMouseAction(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
uint32_t UsbSystemKeyboardActionCounter;
|
uint32_t UsbSystemKeyboardActionCounter;
|
||||||
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
|
static usb_system_keyboard_report_t usbSystemKeyboardReports[2];
|
||||||
usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports;
|
usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport = usbSystemKeyboardReports;
|
||||||
volatile bool IsUsbSystemKeyboardReportSent = false;
|
|
||||||
|
|
||||||
static usb_system_keyboard_report_t* getInactiveUsbSystemKeyboardReport()
|
static usb_system_keyboard_report_t* getInactiveUsbSystemKeyboardReport()
|
||||||
{
|
{
|
||||||
@@ -20,14 +19,12 @@ void ResetActiveUsbSystemKeyboardReport(void)
|
|||||||
bzero(ActiveUsbSystemKeyboardReport, USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
bzero(ActiveUsbSystemKeyboardReport, USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_status_t UsbSystemKeyboardAction(void)
|
usb_status_t UsbSystemKeyboardAction(void)
|
||||||
{
|
{
|
||||||
usb_status_t status = USB_DeviceHidSend(
|
UsbSystemKeyboardActionCounter++;
|
||||||
|
return USB_DeviceHidSend(
|
||||||
UsbCompositeDevice.systemKeyboardHandle, USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX,
|
UsbCompositeDevice.systemKeyboardHandle, USB_SYSTEM_KEYBOARD_ENDPOINT_INDEX,
|
||||||
(uint8_t*)getInactiveUsbSystemKeyboardReport(), USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
(uint8_t*)getInactiveUsbSystemKeyboardReport(), USB_SYSTEM_KEYBOARD_REPORT_LENGTH);
|
||||||
IsUsbSystemKeyboardReportSent = true;
|
|
||||||
UsbSystemKeyboardActionCounter++;
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
||||||
@@ -36,10 +33,6 @@ usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, vo
|
|||||||
|
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case kUSB_DeviceHidEventSendResponse:
|
case kUSB_DeviceHidEventSendResponse:
|
||||||
if (UsbCompositeDevice.attach) {
|
|
||||||
return UsbSystemKeyboardAction();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case kUSB_DeviceHidEventGetReport:
|
case kUSB_DeviceHidEventGetReport:
|
||||||
case kUSB_DeviceHidEventSetReport:
|
case kUSB_DeviceHidEventSetReport:
|
||||||
case kUSB_DeviceHidEventRequestReportBuffer:
|
case kUSB_DeviceHidEventRequestReportBuffer:
|
||||||
@@ -60,7 +53,7 @@ usb_status_t UsbSystemKeyboardCallback(class_handle_t handle, uint32_t event, vo
|
|||||||
usb_status_t UsbSystemKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
usb_status_t UsbSystemKeyboardSetConfiguration(class_handle_t handle, uint8_t configuration)
|
||||||
{
|
{
|
||||||
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
if (USB_COMPOSITE_CONFIGURATION_INDEX == configuration) {
|
||||||
return UsbSystemKeyboardAction();
|
//return UsbSystemKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
@@ -68,7 +61,7 @@ usb_status_t UsbSystemKeyboardSetConfiguration(class_handle_t handle, uint8_t co
|
|||||||
usb_status_t UsbSystemKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
usb_status_t UsbSystemKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting)
|
||||||
{
|
{
|
||||||
if (USB_SYSTEM_KEYBOARD_INTERFACE_INDEX == interface) {
|
if (USB_SYSTEM_KEYBOARD_INTERFACE_INDEX == interface) {
|
||||||
return UsbSystemKeyboardAction();
|
//return UsbSystemKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern volatile bool IsUsbSystemKeyboardReportSent;
|
|
||||||
extern uint32_t UsbSystemKeyboardActionCounter;
|
extern uint32_t UsbSystemKeyboardActionCounter;
|
||||||
extern usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport;
|
extern usb_system_keyboard_report_t* ActiveUsbSystemKeyboardReport;
|
||||||
|
|
||||||
@@ -41,5 +40,6 @@
|
|||||||
|
|
||||||
void ResetActiveUsbSystemKeyboardReport(void);
|
void ResetActiveUsbSystemKeyboardReport(void);
|
||||||
void SwitchActiveUsbSystemKeyboardReport(void);
|
void SwitchActiveUsbSystemKeyboardReport(void);
|
||||||
|
usb_status_t UsbSystemKeyboardAction(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -191,23 +191,56 @@ static void processMouseActions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static layer_id_t previousLayer = LayerId_Base;
|
static layer_id_t previousLayer = LayerId_Base;
|
||||||
|
|
||||||
|
static void handleSwitchLayerAction(key_state_t *keyState, key_action_t *action)
|
||||||
|
{
|
||||||
|
static key_state_t *doubleTapSwitchLayerKey;
|
||||||
|
static uint32_t doubleTapSwitchLayerStartTime;
|
||||||
|
static uint32_t doubleTapSwitchLayerTriggerTime;
|
||||||
|
static bool isLayerDoubleTapToggled;
|
||||||
|
|
||||||
|
if (doubleTapSwitchLayerKey && doubleTapSwitchLayerKey != keyState && !keyState->previous) {
|
||||||
|
doubleTapSwitchLayerKey = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyState->previous && isLayerDoubleTapToggled && ToggledLayer == action->switchLayer.layer) {
|
||||||
|
ToggledLayer = LayerId_Base;
|
||||||
|
isLayerDoubleTapToggled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action->type != KeyActionType_SwitchLayer) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyState->previous && doubleTapSwitchLayerKey == keyState &&
|
||||||
|
Timer_GetElapsedTime(&doubleTapSwitchLayerTriggerTime) > DoubleTapSwitchLayerReleaseTimeout)
|
||||||
|
{
|
||||||
|
ToggledLayer = LayerId_Base;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
||||||
|
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
||||||
|
ToggledLayer = action->switchLayer.layer;
|
||||||
|
isLayerDoubleTapToggled = true;
|
||||||
|
doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
|
||||||
|
} else {
|
||||||
|
doubleTapSwitchLayerKey = keyState;
|
||||||
|
}
|
||||||
|
doubleTapSwitchLayerStartTime = Timer_GetCurrentTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static uint8_t basicScancodeIndex = 0;
|
static uint8_t basicScancodeIndex = 0;
|
||||||
static uint8_t mediaScancodeIndex = 0;
|
static uint8_t mediaScancodeIndex = 0;
|
||||||
static uint8_t systemScancodeIndex = 0;
|
static uint8_t systemScancodeIndex = 0;
|
||||||
|
|
||||||
static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||||
{
|
{
|
||||||
static key_state_t *doubleTapSwitchLayerKey;
|
|
||||||
static uint32_t doubleTapSwitchLayerStartTime;
|
|
||||||
static uint32_t doubleTapSwitchLayerTriggerTime;
|
|
||||||
|
|
||||||
if (keyState->suppressed) {
|
if (keyState->suppressed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doubleTapSwitchLayerKey && doubleTapSwitchLayerKey != keyState && !keyState->previous) {
|
handleSwitchLayerAction(keyState, action);
|
||||||
doubleTapSwitchLayerKey = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (action->type) {
|
switch (action->type) {
|
||||||
case KeyActionType_Keystroke:
|
case KeyActionType_Keystroke:
|
||||||
@@ -238,21 +271,7 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
|||||||
activeMouseStates[action->mouseAction] = true;
|
activeMouseStates[action->mouseAction] = true;
|
||||||
break;
|
break;
|
||||||
case KeyActionType_SwitchLayer:
|
case KeyActionType_SwitchLayer:
|
||||||
if (keyState->previous && doubleTapSwitchLayerKey == keyState &&
|
// Handled by handleSwitchLayerAction()
|
||||||
Timer_GetElapsedTime(&doubleTapSwitchLayerTriggerTime) > DoubleTapSwitchLayerReleaseTimeout)
|
|
||||||
{
|
|
||||||
ToggledLayer = LayerId_Base;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
|
||||||
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
|
||||||
ToggledLayer = action->switchLayer.layer;
|
|
||||||
doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
|
|
||||||
} else {
|
|
||||||
doubleTapSwitchLayerKey = keyState;
|
|
||||||
}
|
|
||||||
doubleTapSwitchLayerStartTime = Timer_GetCurrentTime();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case KeyActionType_SwitchKeymap:
|
case KeyActionType_SwitchKeymap:
|
||||||
if (!keyState->previous) {
|
if (!keyState->previous) {
|
||||||
@@ -389,8 +408,6 @@ void UpdateUsbReports(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Timer_SetCurrentTime(&lastMouseUpdateTime);
|
Timer_SetCurrentTime(&lastMouseUpdateTime);
|
||||||
} else if (!IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetActiveUsbBasicKeyboardReport();
|
ResetActiveUsbBasicKeyboardReport();
|
||||||
@@ -401,34 +418,42 @@ void UpdateUsbReports(void)
|
|||||||
updateActiveUsbReports();
|
updateActiveUsbReports();
|
||||||
|
|
||||||
static usb_basic_keyboard_report_t last_basic_report = { .scancodes[0] = 0xFF };
|
static usb_basic_keyboard_report_t last_basic_report = { .scancodes[0] = 0xFF };
|
||||||
|
bool HasUsbBasicKeyboardReportChanged = false;
|
||||||
if (memcmp(ActiveUsbBasicKeyboardReport, &last_basic_report, sizeof(usb_basic_keyboard_report_t)) != 0) {
|
if (memcmp(ActiveUsbBasicKeyboardReport, &last_basic_report, sizeof(usb_basic_keyboard_report_t)) != 0) {
|
||||||
last_basic_report = *ActiveUsbBasicKeyboardReport;
|
last_basic_report = *ActiveUsbBasicKeyboardReport;
|
||||||
SwitchActiveUsbBasicKeyboardReport();
|
SwitchActiveUsbBasicKeyboardReport();
|
||||||
IsUsbBasicKeyboardReportSent = false;
|
HasUsbBasicKeyboardReportChanged = true;
|
||||||
|
UsbBasicKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_media_keyboard_report_t last_media_report = { .scancodes[0] = 0xFF };
|
static usb_media_keyboard_report_t last_media_report = { .scancodes[0] = 0xFF };
|
||||||
|
bool HasUsbMediaKeyboardReportChanged = false;
|
||||||
if (memcmp(ActiveUsbMediaKeyboardReport, &last_media_report, sizeof(usb_media_keyboard_report_t)) != 0) {
|
if (memcmp(ActiveUsbMediaKeyboardReport, &last_media_report, sizeof(usb_media_keyboard_report_t)) != 0) {
|
||||||
last_media_report = *ActiveUsbMediaKeyboardReport;
|
last_media_report = *ActiveUsbMediaKeyboardReport;
|
||||||
|
HasUsbMediaKeyboardReportChanged = true;
|
||||||
SwitchActiveUsbMediaKeyboardReport();
|
SwitchActiveUsbMediaKeyboardReport();
|
||||||
IsUsbMediaKeyboardReportSent = false;
|
UsbMediaKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_system_keyboard_report_t last_system_report = { .scancodes[0] = 0xFF };
|
static usb_system_keyboard_report_t last_system_report = { .scancodes[0] = 0xFF };
|
||||||
|
bool HasUsbSystemKeyboardReportChanged = false;
|
||||||
if (memcmp(ActiveUsbSystemKeyboardReport, &last_system_report, sizeof(usb_system_keyboard_report_t)) != 0) {
|
if (memcmp(ActiveUsbSystemKeyboardReport, &last_system_report, sizeof(usb_system_keyboard_report_t)) != 0) {
|
||||||
last_system_report = *ActiveUsbSystemKeyboardReport;
|
last_system_report = *ActiveUsbSystemKeyboardReport;
|
||||||
|
HasUsbSystemKeyboardReportChanged = true;
|
||||||
SwitchActiveUsbSystemKeyboardReport();
|
SwitchActiveUsbSystemKeyboardReport();
|
||||||
IsUsbSystemKeyboardReportSent = false;
|
UsbSystemKeyboardAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_mouse_report_t last_mouse_report = { .buttons = 0xFF };
|
static usb_mouse_report_t last_mouse_report = { .buttons = 0xFF };
|
||||||
|
bool HasUsbMouseReportChanged = false;
|
||||||
if (memcmp(ActiveUsbMouseReport, &last_mouse_report, sizeof(usb_mouse_report_t)) != 0) {
|
if (memcmp(ActiveUsbMouseReport, &last_mouse_report, sizeof(usb_mouse_report_t)) != 0) {
|
||||||
last_mouse_report = *ActiveUsbMouseReport;
|
last_mouse_report = *ActiveUsbMouseReport;
|
||||||
|
HasUsbMouseReportChanged = true;
|
||||||
SwitchActiveUsbMouseReport();
|
SwitchActiveUsbMouseReport();
|
||||||
IsUsbMouseReportSent = false;
|
usbMouseAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((previousLayer != LayerId_Base || !IsUsbBasicKeyboardReportSent || !IsUsbMediaKeyboardReportSent || !IsUsbSystemKeyboardReportSent || !IsUsbMouseReportSent) && IsHostSleeping) {
|
if ((previousLayer != LayerId_Base || HasUsbBasicKeyboardReportChanged || HasUsbMediaKeyboardReportChanged || HasUsbSystemKeyboardReportChanged || HasUsbMouseReportChanged) && IsHostSleeping) {
|
||||||
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
|
WakeUpHost(true); // Wake up the host if any key is pressed and the computer is sleeping.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,10 @@
|
|||||||
"commander": "^2.11.0",
|
"commander": "^2.11.0",
|
||||||
"shelljs": "^0.7.8"
|
"shelljs": "^0.7.8"
|
||||||
},
|
},
|
||||||
"firmwareVersion": "8.2.4",
|
"firmwareVersion": "8.3.1",
|
||||||
"deviceProtocolVersion": "4.3.1",
|
"deviceProtocolVersion": "4.3.1",
|
||||||
"moduleProtocolVersion": "4.0.0",
|
"moduleProtocolVersion": "4.0.0",
|
||||||
"userConfigVersion": "4.0.1",
|
"userConfigVersion": "4.1.0",
|
||||||
"hardwareConfigVersion": "1.0.0",
|
"hardwareConfigVersion": "1.0.0",
|
||||||
"devices": [
|
"devices": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,8 +19,8 @@
|
|||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
#define FIRMWARE_MAJOR_VERSION 8
|
#define FIRMWARE_MAJOR_VERSION 8
|
||||||
#define FIRMWARE_MINOR_VERSION 2
|
#define FIRMWARE_MINOR_VERSION 3
|
||||||
#define FIRMWARE_PATCH_VERSION 4
|
#define FIRMWARE_PATCH_VERSION 1
|
||||||
|
|
||||||
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
#define DEVICE_PROTOCOL_MAJOR_VERSION 4
|
||||||
#define DEVICE_PROTOCOL_MINOR_VERSION 3
|
#define DEVICE_PROTOCOL_MINOR_VERSION 3
|
||||||
@@ -31,8 +31,8 @@
|
|||||||
#define MODULE_PROTOCOL_PATCH_VERSION 0
|
#define MODULE_PROTOCOL_PATCH_VERSION 0
|
||||||
|
|
||||||
#define USER_CONFIG_MAJOR_VERSION 4
|
#define USER_CONFIG_MAJOR_VERSION 4
|
||||||
#define USER_CONFIG_MINOR_VERSION 0
|
#define USER_CONFIG_MINOR_VERSION 1
|
||||||
#define USER_CONFIG_PATCH_VERSION 1
|
#define USER_CONFIG_PATCH_VERSION 0
|
||||||
|
|
||||||
#define HARDWARE_CONFIG_MAJOR_VERSION 1
|
#define HARDWARE_CONFIG_MAJOR_VERSION 1
|
||||||
#define HARDWARE_CONFIG_MINOR_VERSION 0
|
#define HARDWARE_CONFIG_MINOR_VERSION 0
|
||||||
|
|||||||
Reference in New Issue
Block a user