1
0
Fork 0

Merge branch 'master' into to_push

This commit is contained in:
Zay950 2017-03-29 12:00:38 -07:00 committed by GitHub
commit 2366ebfbbd
743 changed files with 63747 additions and 7067 deletions

View file

@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nodebug.h"
#endif
#ifdef FAUXCLICKY_ENABLE
#include <fauxclicky.h>
#endif
void action_exec(keyevent_t event)
{
@ -41,6 +44,16 @@ void action_exec(keyevent_t event)
dprint("EVENT: "); debug_event(event); dprintln();
}
#ifdef FAUXCLICKY_ENABLE
if (IS_PRESSED(event)) {
FAUXCLICKY_ACTION_PRESS;
}
if (IS_RELEASED(event)) {
FAUXCLICKY_ACTION_RELEASE;
}
fauxclicky_check();
#endif
#ifdef ONEHAND_ENABLE
if (!IS_NOEVENT(event)) {
process_hand_swap(&event);
@ -49,6 +62,13 @@ void action_exec(keyevent_t event)
keyrecord_t record = { .event = event };
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
if (has_oneshot_layer_timed_out()) {
dprintf("Oneshot layer: timeout\n");
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
}
#endif
#ifndef NO_ACTION_TAPPING
action_tapping_process(record);
#else
@ -100,7 +120,7 @@ bool process_record_quantum(keyrecord_t *record) {
return true;
}
void process_record(keyrecord_t *record)
void process_record(keyrecord_t *record)
{
if (IS_NOEVENT(record->event)) { return; }
@ -126,13 +146,6 @@ void process_action(keyrecord_t *record, action_t action)
uint8_t tap_count = record->tap.count;
#endif
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
if (has_oneshot_layer_timed_out()) {
dprintf("Oneshot layer: timeout\n");
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
}
#endif
if (event.pressed) {
// clear the potential weak mods left by previously pressed keys
clear_weak_mods();

View file

@ -47,10 +47,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* 0100|10| usage(10) (reserved)
* 0100|11| usage(10) (reserved)
*
* ACT_MOUSEKEY(0110): TODO: Not needed?
*
* ACT_MOUSEKEY(0101): TODO: Merge these two actions to conserve space?
* 0101|xxxx| keycode Mouse key
*
* 011x|xxxx xxxx xxxx (reseved)
* ACT_SWAP_HANDS(0110):
* 0110|xxxx| keycode Swap hands (keycode on tap, or options)
*
*
* 0111|xxxx xxxx xxxx (reserved)
*
*
* Layer Actions(10xx)
@ -67,7 +72,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* ee: on event(01:press, 10:release, 11:both)
*
* 1001|xxxx|xxxx xxxx (reserved)
* 1001|oopp|BBBB BBBB 8-bit Bitwise Operation???
*
* ACT_LAYER_TAP(101x):
* 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP]

View file

@ -16,8 +16,14 @@
*/
uint32_t default_layer_state = 0;
__attribute__((weak))
uint32_t default_layer_state_set_kb(uint32_t state) {
return state;
}
static void default_layer_state_set(uint32_t state)
{
state = default_layer_state_set_kb(state);
debug("default_layer_state: ");
default_layer_debug(); debug(" to ");
default_layer_state = state;
@ -57,8 +63,14 @@ void default_layer_xor(uint32_t state)
*/
uint32_t layer_state = 0;
__attribute__((weak))
uint32_t layer_state_set_kb(uint32_t state) {
return state;
}
static void layer_state_set(uint32_t state)
{
state = layer_state_set_kb(state);
dprint("layer_state: ");
layer_debug(); dprint(" to ");
layer_state = state;

View file

@ -29,6 +29,9 @@ extern uint32_t default_layer_state;
void default_layer_debug(void);
void default_layer_set(uint32_t state);
__attribute__((weak))
uint32_t default_layer_state_set_kb(uint32_t state);
#ifndef NO_ACTION_LAYER
/* bitwise operation */
void default_layer_or(uint32_t state);
@ -69,6 +72,8 @@ void layer_xor(uint32_t state);
#define layer_xor(state)
#define layer_debug()
__attribute__((weak))
uint32_t layer_state_set_kb(uint32_t state);
#endif
/* pressed actions cache */

View file

@ -20,11 +20,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "progmem.h"
#define MACRO_NONE 0
typedef uint8_t macro_t;
#define MACRO_NONE (macro_t*)0
#define MACRO(...) ({ static const macro_t __m[] PROGMEM = { __VA_ARGS__ }; &__m[0]; })
#define MACRO_GET(p) pgm_read_byte(p)
typedef uint8_t macro_t;
// Sends press when the macro key is pressed, release when release, or tap_macro when the key has been tapped
#define MACRO_TAP_HOLD(record, press, release, tap_macro) ( ((record)->event.pressed) ? \
( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? (press) : MACRO_NONE ) : \
( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (tap_macro) : (release) ) )
// Holds down the modifier mod when the macro key is held, or sends macro instead when tapped
#define MACRO_TAP_HOLD_MOD(record, macro, mod) MACRO_TAP_HOLD(record, (MACRO(D(mod), END)), MACRO(U(mod), END), macro)
// Holds down the modifier mod when the macro key is held, or pressed a shifted key when tapped (eg: shift+3 for #)
#define MACRO_TAP_SHFT_KEY_HOLD_MOD(record, key, mod) MACRO_TAP_HOLD_MOD(record, (MACRO(I(10), D(LSFT), T(key), U(LSFT), END)), mod)
// Momentary switch layer when held, sends macro if tapped
#define MACRO_TAP_HOLD_LAYER(record, macro, layer) ( ((record)->event.pressed) ? \
( ((record)->tap.count <= 0 || (record)->tap.interrupted) ? ({layer_on((layer)); MACRO_NONE; }) : MACRO_NONE ) : \
( ((record)->tap.count > 0 && !((record)->tap.interrupted)) ? (macro) : ({layer_off((layer)); MACRO_NONE; }) ) )
// Momentary switch layer when held, presses a shifted key when tapped (eg: shift+3 for #)
#define MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, key, layer) MACRO_TAP_HOLD_LAYER(record, MACRO(I(10), D(LSFT), T(key), U(LSFT), END), layer)
#ifndef NO_ACTION_MACRO

View file

@ -228,6 +228,7 @@ bool process_tapping(keyrecord_t *keyp)
if (WITHIN_TAPPING_TERM(event)) {
if (event.pressed) {
if (IS_TAPPING_KEY(event.key)) {
#ifndef TAPPING_FORCE_HOLD
if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap.
keyp->tap = tapping_key.tap;
@ -237,11 +238,11 @@ bool process_tapping(keyrecord_t *keyp)
tapping_key = *keyp;
debug_tapping_key();
return true;
} else {
// FIX: start new tap again
tapping_key = *keyp;
return true;
}
#endif
// FIX: start new tap again
tapping_key = *keyp;
return true;
} else if (is_tap_key(event.key)) {
// Sequential tap can be interfered with other tap key.
debug("Tapping: Start with interfering other tap.\n");
@ -257,7 +258,7 @@ bool process_tapping(keyrecord_t *keyp)
return true;
}
} else {
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {};
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
process_record(keyp);
return true;
}

View file

@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
@ -89,6 +90,12 @@ void bootloader_jump(void) {
_delay_ms(5);
#endif
#ifdef BOOTLOADHID_BOOTLOADER
// force bootloadHID to stay in bootloader mode, so that it waits
// for a new firmware to be flashed
eeprom_write_byte((uint8_t *)1, 0x00);
#endif
// watchdog reset
reset_key = BOOTLOADER_RESET_KEY;
wdt_enable(WDTO_250MS);
@ -114,6 +121,11 @@ void bootloader_jump(void) {
#endif
}
#ifdef __AVR_ATmega32A__
// MCUSR is actually called MCUCSR in ATmega32A
#define MCUSR MCUCSR
#endif
/* this runs before main() */
void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
void bootloader_jump_after_watchdog_reset(void)

View file

@ -47,6 +47,7 @@ void suspend_idle(uint8_t time)
sleep_disable();
}
#ifndef NO_SUSPEND_POWER_DOWN
/* Power down MCU with watchdog timer
* wdto: watchdog timer timeout defined in <avr/wdt.h>
* WDTO_15MS
@ -61,6 +62,7 @@ void suspend_idle(uint8_t time)
* WDTO_8S
*/
static uint8_t wdt_timeout = 0;
static void power_down(uint8_t wdto)
{
#ifdef PROTOCOL_LUFA
@ -98,19 +100,19 @@ static void power_down(uint8_t wdto)
// Disable watchdog after sleep
wdt_disable();
}
#endif
void suspend_power_down(void)
{
#ifndef NO_SUSPEND_POWER_DOWN
power_down(WDTO_15MS);
#endif
}
__attribute__ ((weak)) void matrix_power_up(void) {}
__attribute__ ((weak)) void matrix_power_down(void) {}
bool suspend_wakeup_condition(void)
{
#ifdef BACKLIGHT_ENABLE
backlight_set(0);
#endif
matrix_power_up();
matrix_scan();
matrix_power_down();
@ -126,10 +128,9 @@ void suspend_wakeup_init(void)
// clear keyboard state
clear_keyboard();
#ifdef BACKLIGHT_ENABLE
backlight_set(0);
backlight_init();
#endif
led_set(host_keyboard_leds());
led_set(host_keyboard_leds());
}
#ifndef NO_SUSPEND_POWER_DOWN

View file

@ -17,6 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/atomic.h>
#include <stdint.h>
#include "timer_avr.h"
#include "timer.h"
@ -24,38 +25,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// counter resolution 1ms
// NOTE: union { uint32_t timer32; struct { uint16_t dummy; uint16_t timer16; }}
volatile uint32_t timer_count = 0;
volatile uint32_t timer_count;
void timer_init(void)
{
// Timer0 CTC mode
TCCR0A = 0x02;
#if TIMER_PRESCALER == 1
TCCR0B = 0x01;
uint8_t prescaler = 0x01;
#elif TIMER_PRESCALER == 8
TCCR0B = 0x02;
uint8_t prescaler = 0x02;
#elif TIMER_PRESCALER == 64
TCCR0B = 0x03;
uint8_t prescaler = 0x03;
#elif TIMER_PRESCALER == 256
TCCR0B = 0x04;
uint8_t prescaler = 0x04;
#elif TIMER_PRESCALER == 1024
TCCR0B = 0x05;
uint8_t prescaler = 0x05;
#else
# error "Timer prescaler value is NOT vaild."
#endif
#ifndef __AVR_ATmega32A__
// Timer0 CTC mode
TCCR0A = 0x02;
TCCR0B = prescaler;
OCR0A = TIMER_RAW_TOP;
TIMSK0 = (1<<OCIE0A);
#else
// Timer0 CTC mode
TCCR0 = (1 << WGM01) | prescaler;
OCR0 = TIMER_RAW_TOP;
TIMSK = (1 << OCIE0);
#endif
}
inline
void timer_clear(void)
{
uint8_t sreg = SREG;
cli();
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
timer_count = 0;
SREG = sreg;
}
}
inline
@ -63,10 +73,9 @@ uint16_t timer_read(void)
{
uint32_t t;
uint8_t sreg = SREG;
cli();
t = timer_count;
SREG = sreg;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
t = timer_count;
}
return (t & 0xFFFF);
}
@ -76,10 +85,9 @@ uint32_t timer_read32(void)
{
uint32_t t;
uint8_t sreg = SREG;
cli();
t = timer_count;
SREG = sreg;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
t = timer_count;
}
return t;
}
@ -89,10 +97,9 @@ uint16_t timer_elapsed(uint16_t last)
{
uint32_t t;
uint8_t sreg = SREG;
cli();
t = timer_count;
SREG = sreg;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
t = timer_count;
}
return TIMER_DIFF_16((t & 0xFFFF), last);
}
@ -102,16 +109,20 @@ uint32_t timer_elapsed32(uint32_t last)
{
uint32_t t;
uint8_t sreg = SREG;
cli();
t = timer_count;
SREG = sreg;
ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
t = timer_count;
}
return TIMER_DIFF_32(t, last);
}
// excecuted once per 1ms.(excess for just timer count?)
ISR(TIMER0_COMPA_vect)
#ifndef __AVR_ATmega32A__
#define TIMER_INTERRUPT_VECTOR TIMER0_COMPA_vect
#else
#define TIMER_INTERRUPT_VECTOR TIMER0_COMP_vect
#endif
ISR(TIMER_INTERRUPT_VECTOR, ISR_NOBLOCK)
{
timer_count++;
}

View file

@ -36,9 +36,9 @@ void backlight_increase(void)
if(backlight_config.level < BACKLIGHT_LEVELS)
{
backlight_config.level++;
backlight_config.enable = 1;
eeconfig_update_backlight(backlight_config.raw);
}
backlight_config.enable = 1;
eeconfig_update_backlight(backlight_config.raw);
dprintf("backlight increase: %u\n", backlight_config.level);
backlight_set(backlight_config.level);
}

View file

@ -235,8 +235,11 @@ static void print_status(void)
print("\n\t- Status -\n");
print_val_hex8(host_keyboard_leds());
#ifndef PROTOCOL_VUSB
// these aren't set on the V-USB protocol, so we just ignore them for now
print_val_hex8(keyboard_protocol);
print_val_hex8(keyboard_idle);
#endif
#ifdef NKRO_ENABLE
print_val_hex8(keymap_config.nkro);
#endif
@ -379,11 +382,11 @@ static bool command_common(uint8_t code)
debug_enable = !debug_enable;
if (debug_enable) {
print("\ndebug: on\n");
debug_matrix = true;
debug_keyboard = true;
debug_mouse = true;
} else {
print("\ndebug: off\n");
debug_matrix = false;
debug_keyboard = false;
debug_mouse = false;
}
break;

View file

@ -20,7 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdint.h>
#include "report.h"
#ifdef MIDI_ENABLE
#include "midi.h"
#endif
typedef struct {
uint8_t (*keyboard_leds)(void);
@ -28,6 +30,11 @@ typedef struct {
void (*send_mouse)(report_mouse_t *);
void (*send_system)(uint16_t);
void (*send_consumer)(uint16_t);
#ifdef MIDI_ENABLE
void (*usb_send_func)(MidiDevice *, uint16_t, uint8_t, uint8_t, uint8_t);
void (*usb_get_midi)(MidiDevice *);
void (*midi_usb_init)(MidiDevice *);
#endif
} host_driver_t;
#endif

View file

@ -14,6 +14,7 @@ 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 <stdint.h>
#include "keyboard.h"
#include "matrix.h"
@ -50,6 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
#ifdef FAUXCLICKY_ENABLE
# include "fauxclicky.h"
#endif
#ifdef SERIAL_LINK_ENABLE
# include "serial_link/system/serial_link.h"
#endif
@ -107,6 +111,9 @@ void keyboard_init(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_init();
#endif
#ifdef FAUXCLICKY_ENABLE
fauxclicky_init();
#endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
#endif
@ -188,7 +195,7 @@ MATRIX_LOOP_END:
#endif
#ifdef VISUALIZER_ENABLE
visualizer_update(default_layer_state, layer_state, host_keyboard_leds());
visualizer_update(default_layer_state, layer_state, visualizer_get_mods(), host_keyboard_leds());
#endif
// update LED

View file

@ -85,7 +85,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define KC_LCAP KC_LOCKING_CAPS
#define KC_LNUM KC_LOCKING_NUM
#define KC_LSCR KC_LOCKING_SCROLL
#define KC_ERAS KC_ALT_ERASE,
#define KC_ERAS KC_ALT_ERASE
#define KC_CLR KC_CLEAR
/* Japanese specific */
#define KC_ZKHK KC_GRAVE

View file

@ -50,7 +50,7 @@ void matrix_init(void);
uint8_t matrix_scan(void);
/* whether modified from previous scan. used after matrix_scan. */
bool matrix_is_modified(void) __attribute__ ((deprecated));
/* whether a swtich is on */
/* whether a switch is on */
bool matrix_is_on(uint8_t row, uint8_t col);
/* matrix state on row */
matrix_row_t matrix_get_row(uint8_t row);

View file

@ -0,0 +1,8 @@
#ifndef _RAW_HID_H_
#define _RAW_HID_H_
void raw_hid_receive( uint8_t *data, uint8_t length );
void raw_hid_send( uint8_t *data, uint8_t length );
#endif

View file

@ -134,13 +134,6 @@ typedef union {
} nkro;
#endif
} __attribute__ ((packed)) report_keyboard_t;
/*
typedef struct {
uint8_t mods;
uint8_t reserved;
uint8_t keys[REPORT_KEYS];
} __attribute__ ((packed)) report_keyboard_t;
*/
typedef struct {
uint8_t buttons;