Merge branch 'master' into keymap_in_eeprom
This commit is contained in:
commit
b461564744
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@
|
|||||||
*.map
|
*.map
|
||||||
*.sym
|
*.sym
|
||||||
tags
|
tags
|
||||||
|
*.swp
|
||||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +1,6 @@
|
|||||||
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
|
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
|
||||||
path = protocol/usb_hid/USB_Host_Shield_2.0
|
path = protocol/usb_hid/USB_Host_Shield_2.0
|
||||||
url = git@github.com:tmk/USB_Host_Shield_2.0.git
|
url = git@github.com:tmk/USB_Host_Shield_2.0.git
|
||||||
|
[submodule "protocol/lufa/LUFA-git"]
|
||||||
|
path = protocol/lufa/LUFA-git
|
||||||
|
url = https://github.com/abcminiuser/lufa.git
|
||||||
|
@ -52,6 +52,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
|
|||||||
* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung)
|
* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung)
|
||||||
* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired]
|
* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired]
|
||||||
* [KMAC](keyboard/kmac/) - Korean custom keyboard
|
* [KMAC](keyboard/kmac/) - Korean custom keyboard
|
||||||
|
* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard
|
||||||
|
|
||||||
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
|
[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930
|
||||||
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
|
[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047
|
||||||
|
12
common.mk
12
common.mk
@ -22,7 +22,7 @@ ifdef BOOTMAGIC_ENABLE
|
|||||||
OPT_DEFS += -DBOOTMAGIC_ENABLE
|
OPT_DEFS += -DBOOTMAGIC_ENABLE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef MOUSEKEY_ENABLE
|
ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
|
||||||
SRC += $(COMMON_DIR)/mousekey.c
|
SRC += $(COMMON_DIR)/mousekey.c
|
||||||
OPT_DEFS += -DMOUSEKEY_ENABLE
|
OPT_DEFS += -DMOUSEKEY_ENABLE
|
||||||
OPT_DEFS += -DMOUSE_ENABLE
|
OPT_DEFS += -DMOUSE_ENABLE
|
||||||
@ -54,6 +54,11 @@ ifdef SLEEP_LED_ENABLE
|
|||||||
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
|
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef BREATHING_LED_ENABLE
|
||||||
|
SRC += $(COMMON_DIR)/breathing_led.c
|
||||||
|
OPT_DEFS += -DBREATHING_LED_ENABLE
|
||||||
|
endif
|
||||||
|
|
||||||
ifdef BACKLIGHT_ENABLE
|
ifdef BACKLIGHT_ENABLE
|
||||||
SRC += $(COMMON_DIR)/backlight.c
|
SRC += $(COMMON_DIR)/backlight.c
|
||||||
OPT_DEFS += -DBACKLIGHT_ENABLE
|
OPT_DEFS += -DBACKLIGHT_ENABLE
|
||||||
@ -69,6 +74,11 @@ ifdef KEYMAP_IN_EEPROM_ENABLE
|
|||||||
OPT_DEFS += -DKEYMAP_IN_EEPROM_ENABLE
|
OPT_DEFS += -DKEYMAP_IN_EEPROM_ENABLE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef LED_MATRIX_ENABLE
|
||||||
|
SRC += $(COMMON_DIR)/led_matrix.c
|
||||||
|
OPT_DEFS += -DLED_MATRIX_ENABLE
|
||||||
|
endif
|
||||||
|
|
||||||
# Version string
|
# Version string
|
||||||
OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
|
OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ void process_action(keyrecord_t *record)
|
|||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
case ACT_BACKLIGHT:
|
case ACT_BACKLIGHT:
|
||||||
if (!event.pressed) {
|
if (!event.pressed) {
|
||||||
switch (action.backlight.id) {
|
switch (action.backlight.opt) {
|
||||||
case BACKLIGHT_INCREASE:
|
case BACKLIGHT_INCREASE:
|
||||||
backlight_increase();
|
backlight_increase();
|
||||||
break;
|
break;
|
||||||
@ -307,6 +307,9 @@ void process_action(keyrecord_t *record)
|
|||||||
case BACKLIGHT_STEP:
|
case BACKLIGHT_STEP:
|
||||||
backlight_step();
|
backlight_step();
|
||||||
break;
|
break;
|
||||||
|
case BACKLIGHT_LEVEL:
|
||||||
|
backlight_level(action.backlight.level);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -87,7 +87,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
* 1100|1111| id(8) Macro record?
|
* 1100|1111| id(8) Macro record?
|
||||||
*
|
*
|
||||||
* ACT_BACKLIGHT(1101):
|
* ACT_BACKLIGHT(1101):
|
||||||
* 1101|xxxx| id(8) Backlight commands
|
* 1101|opt |level(8) Backlight commands
|
||||||
*
|
*
|
||||||
* ACT_COMMAND(1110):
|
* ACT_COMMAND(1110):
|
||||||
* 1110|opt | id(8) Built-in Command exec
|
* 1110|opt | id(8) Built-in Command exec
|
||||||
@ -163,7 +163,9 @@ typedef union {
|
|||||||
uint8_t kind :4;
|
uint8_t kind :4;
|
||||||
} usage;
|
} usage;
|
||||||
struct action_backlight {
|
struct action_backlight {
|
||||||
uint8_t id :8;
|
uint8_t level :8;
|
||||||
|
uint8_t opt :4;
|
||||||
|
uint8_t kind :4;
|
||||||
} backlight;
|
} backlight;
|
||||||
struct action_command {
|
struct action_command {
|
||||||
uint8_t id :8;
|
uint8_t id :8;
|
||||||
@ -282,21 +284,23 @@ enum layer_pram_tap_op {
|
|||||||
/*
|
/*
|
||||||
* Extensions
|
* Extensions
|
||||||
*/
|
*/
|
||||||
enum backlight_id {
|
enum backlight_opt {
|
||||||
BACKLIGHT_INCREASE = 0,
|
BACKLIGHT_INCREASE = 0,
|
||||||
BACKLIGHT_DECREASE = 1,
|
BACKLIGHT_DECREASE = 1,
|
||||||
BACKLIGHT_TOGGLE = 2,
|
BACKLIGHT_TOGGLE = 2,
|
||||||
BACKLIGHT_STEP = 3,
|
BACKLIGHT_STEP = 3,
|
||||||
|
BACKLIGHT_LEVEL = 4,
|
||||||
};
|
};
|
||||||
/* Macro */
|
/* Macro */
|
||||||
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
|
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (id))
|
||||||
#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id))
|
#define ACTION_MACRO_TAP(id) ACTION(ACT_MACRO, FUNC_TAP<<8 | (id))
|
||||||
#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
|
#define ACTION_MACRO_OPT(id, opt) ACTION(ACT_MACRO, (opt)<<8 | (id))
|
||||||
/* Backlight */
|
/* Backlight */
|
||||||
#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE)
|
#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
|
||||||
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE)
|
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
|
||||||
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE)
|
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
|
||||||
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP)
|
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
|
||||||
|
#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level)
|
||||||
/* Command */
|
/* Command */
|
||||||
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
|
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
|
||||||
/* Function */
|
/* Function */
|
||||||
|
@ -33,6 +33,16 @@ void backlight_init(void)
|
|||||||
|
|
||||||
void backlight_increase(void)
|
void backlight_increase(void)
|
||||||
{
|
{
|
||||||
|
#ifdef BACKLIGHT_CUSTOM
|
||||||
|
if (backlight_config.enable) {
|
||||||
|
if (backlight_config.level < BACKLIGHT_LEVELS) {
|
||||||
|
backlight_config.level++;
|
||||||
|
eeconfig_write_backlight(backlight_config.raw);
|
||||||
|
}
|
||||||
|
dprintf("backlight custom increase: %u\n", backlight_config.level);
|
||||||
|
backlight_set(backlight_config.level);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if(backlight_config.level < BACKLIGHT_LEVELS)
|
if(backlight_config.level < BACKLIGHT_LEVELS)
|
||||||
{
|
{
|
||||||
backlight_config.level++;
|
backlight_config.level++;
|
||||||
@ -41,10 +51,22 @@ void backlight_increase(void)
|
|||||||
}
|
}
|
||||||
dprintf("backlight increase: %u\n", backlight_config.level);
|
dprintf("backlight increase: %u\n", backlight_config.level);
|
||||||
backlight_set(backlight_config.level);
|
backlight_set(backlight_config.level);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlight_decrease(void)
|
void backlight_decrease(void)
|
||||||
{
|
{
|
||||||
|
#ifdef BACKLIGHT_CUSTOM
|
||||||
|
if (backlight_config.enable) {
|
||||||
|
if(backlight_config.level > 1)
|
||||||
|
{
|
||||||
|
backlight_config.level--;
|
||||||
|
eeconfig_write_backlight(backlight_config.raw);
|
||||||
|
}
|
||||||
|
dprintf("backlight custom decrease: %u\n", backlight_config.level);
|
||||||
|
backlight_set(backlight_config.level);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if(backlight_config.level > 0)
|
if(backlight_config.level > 0)
|
||||||
{
|
{
|
||||||
backlight_config.level--;
|
backlight_config.level--;
|
||||||
@ -53,11 +75,18 @@ void backlight_decrease(void)
|
|||||||
}
|
}
|
||||||
dprintf("backlight decrease: %u\n", backlight_config.level);
|
dprintf("backlight decrease: %u\n", backlight_config.level);
|
||||||
backlight_set(backlight_config.level);
|
backlight_set(backlight_config.level);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void backlight_toggle(void)
|
void backlight_toggle(void)
|
||||||
{
|
{
|
||||||
backlight_config.enable ^= 1;
|
backlight_config.enable ^= 1;
|
||||||
|
if (backlight_config.enable)
|
||||||
|
{
|
||||||
|
if (backlight_config.level == 0) {
|
||||||
|
backlight_config.level = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
eeconfig_write_backlight(backlight_config.raw);
|
eeconfig_write_backlight(backlight_config.raw);
|
||||||
dprintf("backlight toggle: %u\n", backlight_config.enable);
|
dprintf("backlight toggle: %u\n", backlight_config.enable);
|
||||||
backlight_set(backlight_config.enable ? backlight_config.level : 0);
|
backlight_set(backlight_config.enable ? backlight_config.level : 0);
|
||||||
@ -75,3 +104,11 @@ void backlight_step(void)
|
|||||||
dprintf("backlight step: %u\n", backlight_config.level);
|
dprintf("backlight step: %u\n", backlight_config.level);
|
||||||
backlight_set(backlight_config.level);
|
backlight_set(backlight_config.level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void backlight_level(uint8_t level)
|
||||||
|
{
|
||||||
|
backlight_config.level ^= level;
|
||||||
|
backlight_config.enable = !!backlight_config.level;
|
||||||
|
eeconfig_write_backlight(backlight_config.raw);
|
||||||
|
backlight_set(backlight_config.level);
|
||||||
|
}
|
||||||
|
@ -24,18 +24,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
typedef union {
|
typedef union {
|
||||||
uint8_t raw;
|
uint8_t raw;
|
||||||
struct {
|
struct {
|
||||||
bool enable:1;
|
bool enable :1;
|
||||||
uint8_t level:7;
|
uint8_t level :7;
|
||||||
};
|
};
|
||||||
} backlight_config_t;
|
} backlight_config_t;
|
||||||
|
|
||||||
void backlight_init(void);
|
void backlight_init(void);
|
||||||
|
|
||||||
void backlight_increase(void);
|
void backlight_increase(void);
|
||||||
void backlight_decrease(void);
|
void backlight_decrease(void);
|
||||||
void backlight_toggle(void);
|
void backlight_toggle(void);
|
||||||
void backlight_step(void);
|
void backlight_step(void);
|
||||||
|
|
||||||
void backlight_set(uint8_t level);
|
void backlight_set(uint8_t level);
|
||||||
|
void backlight_level(uint8_t level);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,6 +31,7 @@ void bootmagic(void)
|
|||||||
|
|
||||||
/* eeconfig clear */
|
/* eeconfig clear */
|
||||||
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) {
|
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) {
|
||||||
|
eeconfig_disable();
|
||||||
eeconfig_init();
|
eeconfig_init();
|
||||||
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
write_keymap_to_eeprom();
|
write_keymap_to_eeprom();
|
||||||
|
73
common/breathing_led.c
Normal file
73
common/breathing_led.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include "led.h"
|
||||||
|
#include "breathing_led.h"
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
|
#define BREATHING_LED_TIMER_TOP F_CPU/256
|
||||||
|
|
||||||
|
static uint8_t breathing_led_duration = 0;
|
||||||
|
|
||||||
|
void breathing_led_init(void)
|
||||||
|
{
|
||||||
|
/* Timer3 setup */
|
||||||
|
/* CTC mode */
|
||||||
|
TCCR3B |= (1<<WGM32);
|
||||||
|
/* Clock selelct: clk/8 */
|
||||||
|
TCCR3B |= (1<<CS30);
|
||||||
|
/* Set TOP value */
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
OCR3AH = (BREATHING_LED_TIMER_TOP>>8)&0xff;
|
||||||
|
OCR3AL = BREATHING_LED_TIMER_TOP&0xff;
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void breathing_led_enable(void)
|
||||||
|
{
|
||||||
|
/* Enable Compare Match Interrupt */
|
||||||
|
TIMSK3 |= (1<<OCIE3A);
|
||||||
|
dprintf("breathing led on: %u\n", TIMSK3 & (1<<OCIE3A));
|
||||||
|
}
|
||||||
|
|
||||||
|
void breathing_led_disable(void)
|
||||||
|
{
|
||||||
|
/* Disable Compare Match Interrupt */
|
||||||
|
TIMSK3 &= ~(1<<OCIE3A);
|
||||||
|
dprintf("breathing led off: %u\n", TIMSK3 & (1<<OCIE3A));
|
||||||
|
}
|
||||||
|
|
||||||
|
void breathing_led_toggle(void)
|
||||||
|
{
|
||||||
|
/* Disable Compare Match Interrupt */
|
||||||
|
TIMSK3 ^= (1<<OCIE3A);
|
||||||
|
dprintf("breathing led toggle: %u\n", TIMSK3 & (1<<OCIE3A));
|
||||||
|
}
|
||||||
|
|
||||||
|
void breathing_led_set_duration(uint8_t dur)
|
||||||
|
{
|
||||||
|
breathing_led_duration = dur;
|
||||||
|
dprintf("breathing led set duration: %u\n", breathing_led_duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Breathing LED brighness(PWM On period) table
|
||||||
|
*
|
||||||
|
* http://www.wolframalpha.com/input/?i=Table%5Bfloor%28%28exp%28sin%28x%2F256*2*pi%2B3%2F2*pi%29%29-1%2Fe%29*%28256%2F%28e-1%2Fe%29%29%29%2C+%7Bx%2C0%2C255%2C1%7D%5D
|
||||||
|
* Table[floor((exp(sin(x/256*2*pi+3/2*pi))-1/e)*(256/(e-1/e))), {x,0,255,1}]
|
||||||
|
* (0..255).each {|x| print ((exp(sin(x/256.0*2*PI+3.0/2*PI))-1/E)*(256/(E-1/E))).to_i, ', ' }
|
||||||
|
*/
|
||||||
|
static const uint8_t breathing_table[256] PROGMEM = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, 30, 32, 34, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 56, 58, 61, 63, 66, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 102, 105, 108, 112, 116, 119, 123, 126, 130, 134, 138, 142, 145, 149, 153, 157, 161, 165, 169, 173, 176, 180, 184, 188, 192, 195, 199, 203, 206, 210, 213, 216, 219, 223, 226, 228, 231, 234, 236, 239, 241, 243, 245, 247, 248, 250, 251, 252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 254, 253, 252, 251, 250, 248, 247, 245, 243, 241, 239, 236, 234, 231, 228, 226, 223, 219, 216, 213, 210, 206, 203, 199, 195, 192, 188, 184, 180, 176, 173, 169, 165, 161, 157, 153, 149, 145, 142, 138, 134, 130, 126, 123, 119, 116, 112, 108, 105, 102, 98, 95, 92, 89, 86, 83, 80, 77, 74, 71, 68, 66, 63, 61, 58, 56, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 34, 32, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 16, 15, 14, 13, 12, 11, 11, 10, 9, 8, 8, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
ISR(TIMER3_COMPA_vect)
|
||||||
|
{
|
||||||
|
static uint8_t index = 0;
|
||||||
|
static uint8_t step = 0;
|
||||||
|
step++;
|
||||||
|
if (step > breathing_led_duration) {
|
||||||
|
step = 0;
|
||||||
|
breathing_led_set_raw(pgm_read_byte(&breathing_table[index]));
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
25
common/breathing_led.h
Normal file
25
common/breathing_led.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef BREATHING_LED_H
|
||||||
|
#define BREATHING_LED_H
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef BREATHING_LED_ENABLE
|
||||||
|
|
||||||
|
void breathing_led_init(void);
|
||||||
|
void breathing_led_enable(void);
|
||||||
|
void breathing_led_disable(void);
|
||||||
|
void breathing_led_toggle(void);
|
||||||
|
void breathing_led_set_duration(uint8_t dur);
|
||||||
|
void breathing_led_set_raw(uint8_t raw);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define breathing_led_init()
|
||||||
|
#define breathing_led_enable()
|
||||||
|
#define breathing_led_disable()
|
||||||
|
#define breathing_led_toggle()
|
||||||
|
#define breathing_led_set_duration()
|
||||||
|
#define breathing_led_set_raw()
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -301,13 +301,13 @@ static bool command_common(uint8_t code)
|
|||||||
case KC_S:
|
case KC_S:
|
||||||
print("\n\n----- Status -----\n");
|
print("\n\n----- Status -----\n");
|
||||||
print_val_hex8(host_keyboard_leds());
|
print_val_hex8(host_keyboard_leds());
|
||||||
|
print_val_hex8(keyboard_protocol);
|
||||||
|
print_val_hex8(keyboard_idle);
|
||||||
#ifdef PROTOCOL_PJRC
|
#ifdef PROTOCOL_PJRC
|
||||||
print_val_hex8(UDCON);
|
print_val_hex8(UDCON);
|
||||||
print_val_hex8(UDIEN);
|
print_val_hex8(UDIEN);
|
||||||
print_val_hex8(UDINT);
|
print_val_hex8(UDINT);
|
||||||
print_val_hex8(usb_keyboard_leds);
|
print_val_hex8(usb_keyboard_leds);
|
||||||
print_val_hex8(usb_keyboard_protocol);
|
|
||||||
print_val_hex8(usb_keyboard_idle_config);
|
|
||||||
print_val_hex8(usb_keyboard_idle_count);
|
print_val_hex8(usb_keyboard_idle_count);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
#include "eeconfig.h"
|
#include "eeconfig.h"
|
||||||
|
#include "keymap_ex.h"
|
||||||
|
|
||||||
void eeconfig_init(void)
|
void eeconfig_init(void)
|
||||||
{
|
{
|
||||||
@ -13,6 +14,9 @@ void eeconfig_init(void)
|
|||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
|
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
keymap_ex_init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void eeconfig_enable(void)
|
void eeconfig_enable(void)
|
||||||
@ -22,6 +26,9 @@ void eeconfig_enable(void)
|
|||||||
|
|
||||||
void eeconfig_disable(void)
|
void eeconfig_disable(void)
|
||||||
{
|
{
|
||||||
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
keymap_ex_disable();
|
||||||
|
#endif
|
||||||
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
|
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
|
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
bool keyboard_nkro = false;
|
bool keyboard_nkro = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static host_driver_t *driver;
|
static host_driver_t *driver;
|
||||||
|
@ -32,6 +32,9 @@ extern "C" {
|
|||||||
extern bool keyboard_nkro;
|
extern bool keyboard_nkro;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint8_t keyboard_idle;
|
||||||
|
uint8_t keyboard_protocol;
|
||||||
|
|
||||||
|
|
||||||
/* host driver */
|
/* host driver */
|
||||||
void host_set_driver(host_driver_t *driver);
|
void host_set_driver(host_driver_t *driver);
|
||||||
|
@ -31,6 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#include "bootmagic.h"
|
#include "bootmagic.h"
|
||||||
#include "eeconfig.h"
|
#include "eeconfig.h"
|
||||||
#include "backlight.h"
|
#include "backlight.h"
|
||||||
|
#include "breathing_led.h"
|
||||||
#include "keymap_in_eeprom.h"
|
#include "keymap_in_eeprom.h"
|
||||||
#ifdef MOUSEKEY_ENABLE
|
#ifdef MOUSEKEY_ENABLE
|
||||||
# include "mousekey.h"
|
# include "mousekey.h"
|
||||||
@ -62,8 +63,15 @@ void keyboard_init(void)
|
|||||||
{
|
{
|
||||||
timer_init();
|
timer_init();
|
||||||
matrix_init();
|
matrix_init();
|
||||||
|
|
||||||
|
#ifdef LED_MATRIX_ENABLE
|
||||||
|
led_matrix_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
ps2_mouse_init();
|
if (ps2_enabled()) {
|
||||||
|
ps2_mouse_init();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
#ifdef BOOTMAGIC_ENABLE
|
||||||
@ -74,6 +82,10 @@ void keyboard_init(void)
|
|||||||
backlight_init();
|
backlight_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BREATHING_LED_ENABLE
|
||||||
|
breathing_led_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
#ifdef KEYMAP_IN_EEPROM_ENABLE
|
||||||
keymap_in_eeprom_init();
|
keymap_in_eeprom_init();
|
||||||
#endif
|
#endif
|
||||||
@ -128,7 +140,9 @@ MATRIX_LOOP_END:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
#ifdef PS2_MOUSE_ENABLE
|
||||||
ps2_mouse_task();
|
if (ps2_enabled()) {
|
||||||
|
ps2_mouse_task();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// update LED
|
// update LED
|
||||||
|
91
common/led_matrix.c
Normal file
91
common/led_matrix.c
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <avr/interrupt.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "led_matrix.h"
|
||||||
|
|
||||||
|
#define LED_MATRIX_TIMER_TOP F_CPU/(256*64)/LED_MATRIX_ROWS
|
||||||
|
|
||||||
|
static led_matrix_element_t led_matrix[LED_MATRIX_ROWS][LED_MATRIX_COLS];
|
||||||
|
|
||||||
|
void led_matrix_init(void)
|
||||||
|
{
|
||||||
|
led_matrix_unselect_rows();
|
||||||
|
led_matrix_write_cols(0);
|
||||||
|
/* Timer1 setup */
|
||||||
|
/* CTC mode */
|
||||||
|
TCCR1B |= (1<<WGM12);
|
||||||
|
/* Clock selelct: clk/1 */
|
||||||
|
TCCR1B |= (1<<CS10);
|
||||||
|
/* Set TOP value */
|
||||||
|
uint8_t sreg = SREG;
|
||||||
|
cli();
|
||||||
|
OCR1AH = (LED_MATRIX_TIMER_TOP >> 8) & 0xFF;
|
||||||
|
OCR1AL = LED_MATRIX_TIMER_TOP & 0xFF;
|
||||||
|
SREG = sreg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void led_matrix_enable(void)
|
||||||
|
{
|
||||||
|
/* Enable Compare Match Interrupt */
|
||||||
|
TIMSK1 |= _BV(OCIE1A);
|
||||||
|
}
|
||||||
|
|
||||||
|
void led_matrix_disable(void)
|
||||||
|
{
|
||||||
|
/* Disable Compare Match Interrupt */
|
||||||
|
TIMSK1 &= ~_BV(OCIE1A);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm)
|
||||||
|
{
|
||||||
|
led_matrix_row_t cols = 0;
|
||||||
|
for (uint8_t i = 0; i < LED_MATRIX_COLS; i++) {
|
||||||
|
cols |= ((led_matrix[row][i].value < pwm ? 1 : 0) << i);
|
||||||
|
}
|
||||||
|
return cols;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value)
|
||||||
|
{
|
||||||
|
led_matrix[row][col].value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta)
|
||||||
|
{
|
||||||
|
led_matrix[row][col].delta = delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISR(TIMER1_COMPA_vect)
|
||||||
|
{
|
||||||
|
static uint8_t row = 0;
|
||||||
|
static uint8_t pwm = 0;
|
||||||
|
|
||||||
|
row = (row + 1) % LED_MATRIX_ROWS;
|
||||||
|
pwm++;
|
||||||
|
|
||||||
|
led_matrix_select_row(row);
|
||||||
|
_delay_us(10);
|
||||||
|
led_matrix_write_cols(led_matrix_make_cols(row, pwm));
|
||||||
|
_delay_us(10);
|
||||||
|
led_matrix_unselect_rows();
|
||||||
|
}
|
65
common/led_matrix.h
Normal file
65
common/led_matrix.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef LED_MATRIX_H
|
||||||
|
#define LED_MATRIX_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#if (LED_MATRIX_COLS <= 8)
|
||||||
|
typedef uint8_t led_matrix_row_t;
|
||||||
|
#elif (LED_MATRIX_COLS <= 16)
|
||||||
|
typedef uint16_t led_matrix_row_t;
|
||||||
|
#elif (LED_MATRIX_COLS <= 32)
|
||||||
|
typedef uint32_t led_matrix_row_t;
|
||||||
|
#else
|
||||||
|
#error "LED_MATRIX_COLS: invalid value"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
union {
|
||||||
|
int8_t delta;
|
||||||
|
struct {
|
||||||
|
bool direction:1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
uint8_t value;
|
||||||
|
} led_matrix_element_t;
|
||||||
|
|
||||||
|
#ifdef LED_MATRIX_ENABLE
|
||||||
|
void led_matrix_init(void);
|
||||||
|
void led_matrix_enable(void);
|
||||||
|
void led_matrix_disable(void);
|
||||||
|
void led_matrix_init_cols(void);
|
||||||
|
led_matrix_row_t led_matrix_make_cols(uint8_t row, uint8_t pwm);
|
||||||
|
void led_matrix_set_value(uint8_t row, uint8_t col, uint8_t value);
|
||||||
|
void led_matrix_set_delta(uint8_t row, uint8_t col, int8_t delta);
|
||||||
|
extern void led_matrix_write_cols(led_matrix_row_t cols);
|
||||||
|
extern void led_matrix_unselect_rows(void);
|
||||||
|
extern void led_matrix_select_row(uint8_t row);
|
||||||
|
#else
|
||||||
|
#define led_matrix_init()
|
||||||
|
#define led_matrix_enable()
|
||||||
|
#define led_matrix_disable()
|
||||||
|
#define led_matrix_init_cols()
|
||||||
|
#define led_matrix_write_cols()
|
||||||
|
#define led_matrix_unselect_rows()
|
||||||
|
#define led_matrix_select_row()
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -269,7 +269,7 @@ Default Layer is a layer which always is valid and referred to when actions is n
|
|||||||
|
|
||||||
This sets Default Layer to given parameter `layer` and activate it.
|
This sets Default Layer to given parameter `layer` and activate it.
|
||||||
|
|
||||||
ACTION_DEFAULT_LAYER(layer)
|
ACTION_DEFAULT_LAYER_SET(layer)
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.2 Momentary
|
#### 2.2.2 Momentary
|
||||||
@ -444,6 +444,10 @@ Step through backlight levels.
|
|||||||
|
|
||||||
ACTION_BACKLIGHT_STEP()
|
ACTION_BACKLIGHT_STEP()
|
||||||
|
|
||||||
|
Turn a specific backlight level on or off.
|
||||||
|
|
||||||
|
ACTION_BACKLIGHT_LEVEL(1)
|
||||||
|
|
||||||
#### 2.5.2 Turn on / off backlight
|
#### 2.5.2 Turn on / off backlight
|
||||||
Turn the backlight on and off without changing level.
|
Turn the backlight on and off without changing level.
|
||||||
|
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
LUFA_DIR = protocol/lufa
|
LUFA_DIR = protocol/lufa
|
||||||
|
|
||||||
# Path to the LUFA library
|
# Path to the LUFA library
|
||||||
LUFA_PATH ?= protocol/lufa/LUFA-120730
|
ifeq (, $(wildcard $(TOP_DIR)/$(LUFA_DIR)/LUFA-git/LUFA/Version.h))
|
||||||
|
LUFA_PATH ?= $(LUFA_DIR)/LUFA-120730
|
||||||
|
else
|
||||||
|
LUFA_PATH ?= $(LUFA_DIR)/LUFA-git
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# Create the LUFA source path variables by including the LUFA makefile
|
# Create the LUFA source path variables by including the LUFA makefile
|
||||||
ifneq (, $(wildcard $(TOP_DIR)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk))
|
ifneq (, $(wildcard $(TOP_DIR)/$(LUFA_PATH)/LUFA/Build/lufa_sources.mk))
|
||||||
@ -30,9 +35,12 @@ VPATH += $(TOP_DIR)/$(LUFA_PATH)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
# LUFA library compile-time options and predefined tokens
|
# LUFA library compile-time options and predefined tokens
|
||||||
LUFA_OPTS = -D USB_DEVICE_ONLY
|
LUFA_OPTS = -DUSB_DEVICE_ONLY
|
||||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS
|
||||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||||
|
#LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||||
|
LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8
|
||||||
|
LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1
|
||||||
|
|
||||||
OPT_DEFS += -DF_USB=$(F_USB)UL
|
OPT_DEFS += -DF_USB=$(F_USB)UL
|
||||||
OPT_DEFS += -DARCH=ARCH_$(ARCH)
|
OPT_DEFS += -DARCH=ARCH_$(ARCH)
|
||||||
|
1
protocol/lufa/LUFA-git
Submodule
1
protocol/lufa/LUFA-git
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b6c18b2a7c544653efbe12a1d4e8ba65e7d83c35
|
@ -230,12 +230,12 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(1,1,0),
|
||||||
.Class = USB_CSCP_NoDeviceClass,
|
.Class = USB_CSCP_NoDeviceClass,
|
||||||
.SubClass = USB_CSCP_NoDeviceSubclass,
|
.SubClass = USB_CSCP_NoDeviceSubclass,
|
||||||
.Protocol = USB_CSCP_NoDeviceProtocol,
|
.Protocol = USB_CSCP_NoDeviceProtocol,
|
||||||
|
|
||||||
.Endpoint0Size = 8,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
/* specified in config.h */
|
/* specified in config.h */
|
||||||
.VendorID = VENDOR_ID,
|
.VendorID = VENDOR_ID,
|
||||||
@ -246,7 +246,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = 1
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -292,7 +292,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(1,1,1),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
@ -306,7 +306,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
.EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
|
.EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = KEYBOARD_EPSIZE,
|
.EndpointSize = KEYBOARD_EPSIZE,
|
||||||
.PollingIntervalMS = 0x01
|
.PollingIntervalMS = 0x0A
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -333,7 +333,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(1,1,1),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
@ -347,7 +347,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
.EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
|
.EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = MOUSE_EPSIZE,
|
.EndpointSize = MOUSE_EPSIZE,
|
||||||
.PollingIntervalMS = 0x01
|
.PollingIntervalMS = 0x0A
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(1,1,1),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
@ -389,7 +389,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
.EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM),
|
.EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = EXTRAKEY_EPSIZE,
|
.EndpointSize = EXTRAKEY_EPSIZE,
|
||||||
.PollingIntervalMS = 0x01
|
.PollingIntervalMS = 0x0A
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -417,7 +417,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(1,1,1),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
@ -469,7 +469,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(1,1,1),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
|
@ -137,13 +137,17 @@ typedef struct
|
|||||||
|
|
||||||
#ifdef CONSOLE_ENABLE
|
#ifdef CONSOLE_ENABLE
|
||||||
# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
|
# define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1)
|
||||||
# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
|
# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 1)
|
||||||
|
//# define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2)
|
||||||
#else
|
#else
|
||||||
# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM
|
# define CONSOLE_OUT_EPNUM EXTRAKEY_IN_EPNUM
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
|
# define NKRO_IN_EPNUM (CONSOLE_OUT_EPNUM + 1)
|
||||||
|
# if defined(__AVR_ATmega32U2__) && NKRO_IN_EPNUM > 4
|
||||||
|
# error "Endpoints are not available enough to support all functions. Remove some in Makefile.(MOUSEKEY, EXTRAKEY, CONSOLE, NKRO)"
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -159,4 +163,14 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||||||
const void** const DescriptorAddress)
|
const void** const DescriptorAddress)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
|
|
||||||
|
/* new API */
|
||||||
|
#if LUFA_VERSION_INTEGER < 0x140302
|
||||||
|
#undef VERSION_BCD
|
||||||
|
#define VERSION_BCD(Major, Minor, Revision) \
|
||||||
|
CPU_TO_LE16( ((Major & 0xFF) << 8) | \
|
||||||
|
((Minor & 0x0F) << 4) | \
|
||||||
|
(Revision & 0x0F) )
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -52,8 +52,8 @@
|
|||||||
#include "descriptor.h"
|
#include "descriptor.h"
|
||||||
#include "lufa.h"
|
#include "lufa.h"
|
||||||
|
|
||||||
static uint8_t idle_duration = 0;
|
uint8_t keyboard_idle = 0;
|
||||||
static uint8_t protocol_report = 1;
|
uint8_t keyboard_protocol = 1;
|
||||||
static uint8_t keyboard_led_stats = 0;
|
static uint8_t keyboard_led_stats = 0;
|
||||||
|
|
||||||
static report_keyboard_t keyboard_report_sent;
|
static report_keyboard_t keyboard_report_sent;
|
||||||
@ -184,15 +184,6 @@ void EVENT_USB_Device_StartOfFrame(void)
|
|||||||
/** Event handler for the USB_ConfigurationChanged event.
|
/** Event handler for the USB_ConfigurationChanged event.
|
||||||
* This is fired when the host sets the current configuration of the USB device after enumeration.
|
* This is fired when the host sets the current configuration of the USB device after enumeration.
|
||||||
*/
|
*/
|
||||||
#if LUFA_VERSION_INTEGER < 0x120730
|
|
||||||
/* old API 120219 */
|
|
||||||
#define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank)
|
|
||||||
#else
|
|
||||||
/* new API >= 120730 */
|
|
||||||
#define ENDPOINT_BANK_SINGLE 1
|
|
||||||
#define ENDPOINT_BANK_DOUBLE 2
|
|
||||||
#define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank)
|
|
||||||
#endif
|
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void)
|
void EVENT_USB_Device_ConfigurationChanged(void)
|
||||||
{
|
{
|
||||||
bool ConfigSuccess = true;
|
bool ConfigSuccess = true;
|
||||||
@ -217,9 +208,11 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
|||||||
/* Setup Console HID Report Endpoints */
|
/* Setup Console HID Report Endpoints */
|
||||||
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
|
||||||
CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE);
|
CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE);
|
||||||
|
#if 0
|
||||||
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
|
ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
|
||||||
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
/* Setup NKRO HID Report Endpoints */
|
/* Setup NKRO HID Report Endpoints */
|
||||||
@ -279,6 +272,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||||||
// Interface
|
// Interface
|
||||||
switch (USB_ControlRequest.wIndex) {
|
switch (USB_ControlRequest.wIndex) {
|
||||||
case KEYBOARD_INTERFACE:
|
case KEYBOARD_INTERFACE:
|
||||||
|
case NKRO_INTERFACE:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
while (!(Endpoint_IsOUTReceived())) {
|
while (!(Endpoint_IsOUTReceived())) {
|
||||||
@ -299,21 +293,29 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||||||
case HID_REQ_GetProtocol:
|
case HID_REQ_GetProtocol:
|
||||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||||
{
|
{
|
||||||
Endpoint_ClearSETUP();
|
if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) {
|
||||||
while (!(Endpoint_IsINReady()));
|
Endpoint_ClearSETUP();
|
||||||
Endpoint_Write_8(protocol_report);
|
while (!(Endpoint_IsINReady()));
|
||||||
Endpoint_ClearIN();
|
Endpoint_Write_8(keyboard_protocol);
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearIN();
|
||||||
|
Endpoint_ClearStatusStage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_REQ_SetProtocol:
|
case HID_REQ_SetProtocol:
|
||||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||||
{
|
{
|
||||||
Endpoint_ClearSETUP();
|
if (USB_ControlRequest.wIndex == KEYBOARD_INTERFACE) {
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearSETUP();
|
||||||
|
Endpoint_ClearStatusStage();
|
||||||
|
|
||||||
protocol_report = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
|
keyboard_protocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
|
||||||
|
#ifdef NKRO_ENABLE
|
||||||
|
keyboard_nkro = !!keyboard_protocol;
|
||||||
|
#endif
|
||||||
|
clear_keyboard();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -323,7 +325,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearStatusStage();
|
||||||
|
|
||||||
idle_duration = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
|
keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -332,7 +334,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||||||
{
|
{
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
while (!(Endpoint_IsINReady()));
|
while (!(Endpoint_IsINReady()));
|
||||||
Endpoint_Write_8(idle_duration);
|
Endpoint_Write_8(keyboard_idle);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearStatusStage();
|
||||||
}
|
}
|
||||||
@ -351,7 +353,7 @@ static uint8_t keyboard_leds(void)
|
|||||||
|
|
||||||
static void send_keyboard(report_keyboard_t *report)
|
static void send_keyboard(report_keyboard_t *report)
|
||||||
{
|
{
|
||||||
uint8_t timeout = 0;
|
uint8_t timeout = 255;
|
||||||
|
|
||||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||||
return;
|
return;
|
||||||
@ -359,26 +361,27 @@ static void send_keyboard(report_keyboard_t *report)
|
|||||||
/* Select the Keyboard Report Endpoint */
|
/* Select the Keyboard Report Endpoint */
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
if (keyboard_nkro) {
|
if (keyboard_nkro) {
|
||||||
|
/* Report protocol - NKRO */
|
||||||
Endpoint_SelectEndpoint(NKRO_IN_EPNUM);
|
Endpoint_SelectEndpoint(NKRO_IN_EPNUM);
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if Keyboard Endpoint Ready for Read/Write */
|
/* Check if write ready for a polling interval around 1ms */
|
||||||
while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
|
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(4);
|
||||||
|
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||||
|
|
||||||
/* Write Keyboard Report Data */
|
/* Write Keyboard Report Data */
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_nkro) {
|
|
||||||
Endpoint_Write_Stream_LE(report, NKRO_EPSIZE, NULL);
|
Endpoint_Write_Stream_LE(report, NKRO_EPSIZE, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* boot mode */
|
/* Boot protocol */
|
||||||
|
Endpoint_SelectEndpoint(KEYBOARD_IN_EPNUM);
|
||||||
|
|
||||||
|
/* Check if write ready for a polling interval around 10ms */
|
||||||
|
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||||
|
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||||
|
|
||||||
|
/* Write Keyboard Report Data */
|
||||||
Endpoint_Write_Stream_LE(report, KEYBOARD_EPSIZE, NULL);
|
Endpoint_Write_Stream_LE(report, KEYBOARD_EPSIZE, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,7 +394,7 @@ static void send_keyboard(report_keyboard_t *report)
|
|||||||
static void send_mouse(report_mouse_t *report)
|
static void send_mouse(report_mouse_t *report)
|
||||||
{
|
{
|
||||||
#ifdef MOUSE_ENABLE
|
#ifdef MOUSE_ENABLE
|
||||||
uint8_t timeout = 0;
|
uint8_t timeout = 255;
|
||||||
|
|
||||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||||
return;
|
return;
|
||||||
@ -399,8 +402,9 @@ static void send_mouse(report_mouse_t *report)
|
|||||||
/* Select the Mouse Report Endpoint */
|
/* Select the Mouse Report Endpoint */
|
||||||
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
|
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
|
||||||
|
|
||||||
/* Check if Mouse Endpoint Ready for Read/Write */
|
/* Check if write ready for a polling interval around 10ms */
|
||||||
while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
|
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||||
|
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||||
|
|
||||||
/* Write Mouse Report Data */
|
/* Write Mouse Report Data */
|
||||||
Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL);
|
Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL);
|
||||||
@ -412,7 +416,7 @@ static void send_mouse(report_mouse_t *report)
|
|||||||
|
|
||||||
static void send_system(uint16_t data)
|
static void send_system(uint16_t data)
|
||||||
{
|
{
|
||||||
uint8_t timeout = 0;
|
uint8_t timeout = 255;
|
||||||
|
|
||||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||||
return;
|
return;
|
||||||
@ -422,14 +426,18 @@ static void send_system(uint16_t data)
|
|||||||
.usage = data
|
.usage = data
|
||||||
};
|
};
|
||||||
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
|
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
|
||||||
while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
|
|
||||||
|
/* Check if write ready for a polling interval around 10ms */
|
||||||
|
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||||
|
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_consumer(uint16_t data)
|
static void send_consumer(uint16_t data)
|
||||||
{
|
{
|
||||||
uint8_t timeout = 0;
|
uint8_t timeout = 255;
|
||||||
|
|
||||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||||
return;
|
return;
|
||||||
@ -439,7 +447,11 @@ static void send_consumer(uint16_t data)
|
|||||||
.usage = data
|
.usage = data
|
||||||
};
|
};
|
||||||
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
|
Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM);
|
||||||
while (--timeout && !Endpoint_IsReadWriteAllowed()) ;
|
|
||||||
|
/* Check if write ready for a polling interval around 10ms */
|
||||||
|
while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40);
|
||||||
|
if (!Endpoint_IsReadWriteAllowed()) return;
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,15 @@ typedef struct {
|
|||||||
uint16_t usage;
|
uint16_t usage;
|
||||||
} __attribute__ ((packed)) report_extra_t;
|
} __attribute__ ((packed)) report_extra_t;
|
||||||
|
|
||||||
|
|
||||||
|
#if LUFA_VERSION_INTEGER < 0x120730
|
||||||
|
/* old API 120219 */
|
||||||
|
#define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint(epnum, eptype, epdir, epsize, epbank)
|
||||||
|
#else
|
||||||
|
/* new API >= 120730 */
|
||||||
|
#define ENDPOINT_BANK_SINGLE 1
|
||||||
|
#define ENDPOINT_BANK_DOUBLE 2
|
||||||
|
#define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum) , eptype, epsize, epbank)
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "sleep_led.h"
|
#include "sleep_led.h"
|
||||||
#endif
|
#endif
|
||||||
#include "suspend.h"
|
#include "suspend.h"
|
||||||
|
#include "action.h"
|
||||||
#include "action_util.h"
|
#include "action_util.h"
|
||||||
|
|
||||||
|
|
||||||
@ -628,6 +629,7 @@ uint8_t usb_configured(void)
|
|||||||
void usb_remote_wakeup(void)
|
void usb_remote_wakeup(void)
|
||||||
{
|
{
|
||||||
UDCON |= (1<<RMWKUP);
|
UDCON |= (1<<RMWKUP);
|
||||||
|
while (UDCON & (1<<RMWKUP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -692,20 +694,20 @@ ISR(USB_GEN_vect)
|
|||||||
}
|
}
|
||||||
/* TODO: should keep IDLE rate on each keyboard interface */
|
/* TODO: should keep IDLE rate on each keyboard interface */
|
||||||
#ifdef NKRO_ENABLE
|
#ifdef NKRO_ENABLE
|
||||||
if (!keyboard_nkro && usb_keyboard_idle_config && (++div4 & 3) == 0) {
|
if (!keyboard_nkro && keyboard_idle && (++div4 & 3) == 0) {
|
||||||
#else
|
#else
|
||||||
if (usb_keyboard_idle_config && (++div4 & 3) == 0) {
|
if (keyboard_idle && (++div4 & 3) == 0) {
|
||||||
#endif
|
#endif
|
||||||
UENUM = KBD_ENDPOINT;
|
UENUM = KBD_ENDPOINT;
|
||||||
if (UEINTX & (1<<RWAL)) {
|
if (UEINTX & (1<<RWAL)) {
|
||||||
usb_keyboard_idle_count++;
|
usb_keyboard_idle_count++;
|
||||||
if (usb_keyboard_idle_count == usb_keyboard_idle_config) {
|
if (usb_keyboard_idle_count == keyboard_idle) {
|
||||||
usb_keyboard_idle_count = 0;
|
usb_keyboard_idle_count = 0;
|
||||||
/* TODO: fix keyboard_report inconsistency */
|
/* TODO: fix keyboard_report inconsistency */
|
||||||
/* To avoid Mac SET_IDLE behaviour.
|
/* To avoid Mac SET_IDLE behaviour.
|
||||||
UEDATX = keyboard_report_prev->mods;
|
UEDATX = keyboard_report_prev->mods;
|
||||||
UEDATX = 0;
|
UEDATX = 0;
|
||||||
uint8_t keys = usb_keyboard_protocol ? KBD_REPORT_KEYS : 6;
|
uint8_t keys = keyboard_protocol ? KBD_REPORT_KEYS : 6;
|
||||||
for (uint8_t i=0; i<keys; i++) {
|
for (uint8_t i=0; i<keys; i++) {
|
||||||
UEDATX = keyboard_report_prev->keys[i];
|
UEDATX = keyboard_report_prev->keys[i];
|
||||||
}
|
}
|
||||||
@ -901,13 +903,13 @@ ISR(USB_COM_vect)
|
|||||||
}
|
}
|
||||||
if (bRequest == HID_GET_IDLE) {
|
if (bRequest == HID_GET_IDLE) {
|
||||||
usb_wait_in_ready();
|
usb_wait_in_ready();
|
||||||
UEDATX = usb_keyboard_idle_config;
|
UEDATX = keyboard_idle;
|
||||||
usb_send_in();
|
usb_send_in();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bRequest == HID_GET_PROTOCOL) {
|
if (bRequest == HID_GET_PROTOCOL) {
|
||||||
usb_wait_in_ready();
|
usb_wait_in_ready();
|
||||||
UEDATX = usb_keyboard_protocol;
|
UEDATX = keyboard_protocol;
|
||||||
usb_send_in();
|
usb_send_in();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -921,14 +923,18 @@ ISR(USB_COM_vect)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bRequest == HID_SET_IDLE) {
|
if (bRequest == HID_SET_IDLE) {
|
||||||
usb_keyboard_idle_config = (wValue >> 8);
|
keyboard_idle = (wValue >> 8);
|
||||||
usb_keyboard_idle_count = 0;
|
usb_keyboard_idle_count = 0;
|
||||||
//usb_wait_in_ready();
|
//usb_wait_in_ready();
|
||||||
usb_send_in();
|
usb_send_in();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (bRequest == HID_SET_PROTOCOL) {
|
if (bRequest == HID_SET_PROTOCOL) {
|
||||||
usb_keyboard_protocol = wValue;
|
keyboard_protocol = wValue;
|
||||||
|
#ifdef NKRO_ENABLE
|
||||||
|
keyboard_nkro = !!keyboard_protocol;
|
||||||
|
#endif
|
||||||
|
clear_keyboard();
|
||||||
//usb_wait_in_ready();
|
//usb_wait_in_ready();
|
||||||
usb_send_in();
|
usb_send_in();
|
||||||
return;
|
return;
|
||||||
|
@ -34,12 +34,12 @@
|
|||||||
// protocol setting from the host. We use exactly the same report
|
// protocol setting from the host. We use exactly the same report
|
||||||
// either way, so this variable only stores the setting since we
|
// either way, so this variable only stores the setting since we
|
||||||
// are required to be able to report which setting is in use.
|
// are required to be able to report which setting is in use.
|
||||||
uint8_t usb_keyboard_protocol=1;
|
uint8_t keyboard_protocol=1;
|
||||||
|
|
||||||
// the idle configuration, how often we send the report to the
|
// the idle configuration, how often we send the report to the
|
||||||
// host (ms * 4) even when it hasn't changed
|
// host (ms * 4) even when it hasn't changed
|
||||||
// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request.
|
// Windows and Linux set 0 while OS X sets 6(24ms) by SET_IDLE request.
|
||||||
uint8_t usb_keyboard_idle_config=125;
|
uint8_t keyobard_idle=125;
|
||||||
|
|
||||||
// count until idle timeout
|
// count until idle timeout
|
||||||
uint8_t usb_keyboard_idle_count=0;
|
uint8_t usb_keyboard_idle_count=0;
|
||||||
@ -61,10 +61,7 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (usb_keyboard_protocol)
|
result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
|
||||||
result = send_report(report, KBD_ENDPOINT, 0, KBD_SIZE);
|
|
||||||
else
|
|
||||||
result = send_report(report, KBD_ENDPOINT, 0, 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result) return result;
|
if (result) return result;
|
||||||
|
@ -30,8 +30,6 @@
|
|||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
|
||||||
|
|
||||||
extern uint8_t usb_keyboard_protocol;
|
|
||||||
extern uint8_t usb_keyboard_idle_config;
|
|
||||||
extern uint8_t usb_keyboard_idle_count;
|
extern uint8_t usb_keyboard_idle_count;
|
||||||
extern volatile uint8_t usb_keyboard_leds;
|
extern volatile uint8_t usb_keyboard_leds;
|
||||||
|
|
||||||
|
@ -90,6 +90,7 @@ uint8_t ps2_host_send(uint8_t data);
|
|||||||
uint8_t ps2_host_recv_response(void);
|
uint8_t ps2_host_recv_response(void);
|
||||||
uint8_t ps2_host_recv(void);
|
uint8_t ps2_host_recv(void);
|
||||||
void ps2_host_set_led(uint8_t usb_led);
|
void ps2_host_set_led(uint8_t usb_led);
|
||||||
|
uint8_t ps2_enabled(void);
|
||||||
|
|
||||||
|
|
||||||
/* Check port settings for clock and data line */
|
/* Check port settings for clock and data line */
|
||||||
|
Reference in New Issue
Block a user