Merge pull request #34 from jackhumbert/tmk-master
merging from tmk, new_project script and templateexample_keyboards
commit
d311fd8d1a
@ -1,6 +0,0 @@
|
|||||||
[submodule "protocol/lufa/LUFA-git"]
|
|
||||||
path = protocol/lufa/LUFA-git
|
|
||||||
url = https://github.com/abcminiuser/lufa.git
|
|
||||||
[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
|
|
||||||
path = protocol/usb_hid/USB_Host_Shield_2.0
|
|
||||||
url = https://github.com/felis/USB_Host_Shield_2.0.git
|
|
@ -1,85 +0,0 @@
|
|||||||
COMMON_DIR = common
|
|
||||||
SRC += $(COMMON_DIR)/host.c \
|
|
||||||
$(COMMON_DIR)/keyboard.c \
|
|
||||||
$(COMMON_DIR)/action.c \
|
|
||||||
$(COMMON_DIR)/action_tapping.c \
|
|
||||||
$(COMMON_DIR)/action_macro.c \
|
|
||||||
$(COMMON_DIR)/action_layer.c \
|
|
||||||
$(COMMON_DIR)/action_util.c \
|
|
||||||
$(COMMON_DIR)/keymap.c \
|
|
||||||
$(COMMON_DIR)/print.c \
|
|
||||||
$(COMMON_DIR)/debug.c \
|
|
||||||
$(COMMON_DIR)/util.c \
|
|
||||||
$(COMMON_DIR)/avr/suspend.c \
|
|
||||||
$(COMMON_DIR)/avr/xprintf.S \
|
|
||||||
$(COMMON_DIR)/avr/timer.c \
|
|
||||||
$(COMMON_DIR)/avr/bootloader.c
|
|
||||||
|
|
||||||
|
|
||||||
# Option modules
|
|
||||||
ifdef BOOTMAGIC_ENABLE
|
|
||||||
SRC += $(COMMON_DIR)/bootmagic.c
|
|
||||||
SRC += $(COMMON_DIR)/avr/eeconfig.c
|
|
||||||
OPT_DEFS += -DBOOTMAGIC_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef MOUSEKEY_ENABLE
|
|
||||||
SRC += $(COMMON_DIR)/mousekey.c
|
|
||||||
OPT_DEFS += -DMOUSEKEY_ENABLE
|
|
||||||
OPT_DEFS += -DMOUSE_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef EXTRAKEY_ENABLE
|
|
||||||
OPT_DEFS += -DEXTRAKEY_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef CONSOLE_ENABLE
|
|
||||||
OPT_DEFS += -DCONSOLE_ENABLE
|
|
||||||
else
|
|
||||||
OPT_DEFS += -DNO_PRINT
|
|
||||||
OPT_DEFS += -DNO_DEBUG
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef COMMAND_ENABLE
|
|
||||||
SRC += $(COMMON_DIR)/command.c
|
|
||||||
OPT_DEFS += -DCOMMAND_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef NKRO_ENABLE
|
|
||||||
OPT_DEFS += -DNKRO_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef MIDI_ENABLE
|
|
||||||
OPT_DEFS += -DMIDI_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef USB_6KRO_ENABLE
|
|
||||||
OPT_DEFS += -DUSB_6KRO_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef SLEEP_LED_ENABLE
|
|
||||||
SRC += $(COMMON_DIR)/sleep_led.c
|
|
||||||
OPT_DEFS += -DSLEEP_LED_ENABLE
|
|
||||||
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef BACKLIGHT_ENABLE
|
|
||||||
SRC += $(COMMON_DIR)/backlight.c
|
|
||||||
OPT_DEFS += -DBACKLIGHT_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef BLUETOOTH_ENABLE
|
|
||||||
OPT_DEFS += -DBLUETOOTH_ENABLE
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef KEYMAP_SECTION_ENABLE
|
|
||||||
OPT_DEFS += -DKEYMAP_SECTION_ENABLE
|
|
||||||
EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Version string
|
|
||||||
OPT_DEFS += -DVERSION=$(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
|
|
||||||
|
|
||||||
|
|
||||||
# Search Path
|
|
||||||
VPATH += $(TOP_DIR)/common
|
|
@ -1,565 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2012,2013 Jun Wako <wakojun@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 "host.h"
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "keyboard.h"
|
|
||||||
#include "mousekey.h"
|
|
||||||
#include "command.h"
|
|
||||||
#include "led.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
#include "action_layer.h"
|
|
||||||
#include "action_tapping.h"
|
|
||||||
#include "action_macro.h"
|
|
||||||
#include "action_util.h"
|
|
||||||
#include "action.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
|
||||||
#include "debug.h"
|
|
||||||
#else
|
|
||||||
#include "nodebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void action_exec(keyevent_t event)
|
|
||||||
{
|
|
||||||
if (!IS_NOEVENT(event)) {
|
|
||||||
dprint("\n---- action_exec: start -----\n");
|
|
||||||
dprint("EVENT: "); debug_event(event); dprintln();
|
|
||||||
}
|
|
||||||
|
|
||||||
keyrecord_t record = { .event = event };
|
|
||||||
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
|
||||||
action_tapping_process(record);
|
|
||||||
#else
|
|
||||||
process_action(&record);
|
|
||||||
if (!IS_NOEVENT(record.event)) {
|
|
||||||
dprint("processed: "); debug_record(record); dprintln();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void process_action(keyrecord_t *record)
|
|
||||||
{
|
|
||||||
keyevent_t event = record->event;
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
|
||||||
uint8_t tap_count = record->tap.count;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (IS_NOEVENT(event)) { return; }
|
|
||||||
|
|
||||||
action_t action = layer_switch_get_action(event.key);
|
|
||||||
dprint("ACTION: "); debug_action(action);
|
|
||||||
#ifndef NO_ACTION_LAYER
|
|
||||||
dprint(" layer_state: "); layer_debug();
|
|
||||||
dprint(" default_layer_state: "); default_layer_debug();
|
|
||||||
#endif
|
|
||||||
dprintln();
|
|
||||||
|
|
||||||
switch (action.kind.id) {
|
|
||||||
/* Key and Mods */
|
|
||||||
case ACT_LMODS:
|
|
||||||
case ACT_RMODS:
|
|
||||||
{
|
|
||||||
uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods :
|
|
||||||
action.key.mods<<4;
|
|
||||||
if (event.pressed) {
|
|
||||||
if (mods) {
|
|
||||||
add_weak_mods(mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
register_code(action.key.code);
|
|
||||||
} else {
|
|
||||||
unregister_code(action.key.code);
|
|
||||||
if (mods) {
|
|
||||||
del_weak_mods(mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
|
||||||
case ACT_LMODS_TAP:
|
|
||||||
case ACT_RMODS_TAP:
|
|
||||||
{
|
|
||||||
uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
|
|
||||||
action.key.mods<<4;
|
|
||||||
switch (action.layer_tap.code) {
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
case MODS_ONESHOT:
|
|
||||||
// Oneshot modifier
|
|
||||||
if (event.pressed) {
|
|
||||||
if (tap_count == 0) {
|
|
||||||
register_mods(mods);
|
|
||||||
}
|
|
||||||
else if (tap_count == 1) {
|
|
||||||
dprint("MODS_TAP: Oneshot: start\n");
|
|
||||||
set_oneshot_mods(mods);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
register_mods(mods);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tap_count == 0) {
|
|
||||||
clear_oneshot_mods();
|
|
||||||
unregister_mods(mods);
|
|
||||||
}
|
|
||||||
else if (tap_count == 1) {
|
|
||||||
// Retain Oneshot mods
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clear_oneshot_mods();
|
|
||||||
unregister_mods(mods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case MODS_TAP_TOGGLE:
|
|
||||||
if (event.pressed) {
|
|
||||||
if (tap_count <= TAPPING_TOGGLE) {
|
|
||||||
register_mods(mods);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tap_count < TAPPING_TOGGLE) {
|
|
||||||
unregister_mods(mods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (event.pressed) {
|
|
||||||
if (tap_count > 0) {
|
|
||||||
if (record->tap.interrupted) {
|
|
||||||
dprint("MODS_TAP: Tap: Cancel: add_mods\n");
|
|
||||||
// ad hoc: set 0 to cancel tap
|
|
||||||
record->tap.count = 0;
|
|
||||||
register_mods(mods);
|
|
||||||
} else {
|
|
||||||
dprint("MODS_TAP: Tap: register_code\n");
|
|
||||||
register_code(action.key.code);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dprint("MODS_TAP: No tap: add_mods\n");
|
|
||||||
register_mods(mods);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tap_count > 0) {
|
|
||||||
dprint("MODS_TAP: Tap: unregister_code\n");
|
|
||||||
unregister_code(action.key.code);
|
|
||||||
} else {
|
|
||||||
dprint("MODS_TAP: No tap: add_mods\n");
|
|
||||||
unregister_mods(mods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef EXTRAKEY_ENABLE
|
|
||||||
/* other HID usage */
|
|
||||||
case ACT_USAGE:
|
|
||||||
switch (action.usage.page) {
|
|
||||||
case PAGE_SYSTEM:
|
|
||||||
if (event.pressed) {
|
|
||||||
host_system_send(action.usage.code);
|
|
||||||
} else {
|
|
||||||
host_system_send(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PAGE_CONSUMER:
|
|
||||||
if (event.pressed) {
|
|
||||||
host_consumer_send(action.usage.code);
|
|
||||||
} else {
|
|
||||||
host_consumer_send(0);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
/* Mouse key */
|
|
||||||
case ACT_MOUSEKEY:
|
|
||||||
if (event.pressed) {
|
|
||||||
mousekey_on(action.key.code);
|
|
||||||
mousekey_send();
|
|
||||||
} else {
|
|
||||||
mousekey_off(action.key.code);
|
|
||||||
mousekey_send();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifndef NO_ACTION_LAYER
|
|
||||||
case ACT_LAYER:
|
|
||||||
if (action.layer_bitop.on == 0) {
|
|
||||||
/* Default Layer Bitwise Operation */
|
|
||||||
if (!event.pressed) {
|
|
||||||
uint8_t shift = action.layer_bitop.part*4;
|
|
||||||
uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
|
|
||||||
uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
|
|
||||||
switch (action.layer_bitop.op) {
|
|
||||||
case OP_BIT_AND: default_layer_and(bits | mask); break;
|
|
||||||
case OP_BIT_OR: default_layer_or(bits | mask); break;
|
|
||||||
case OP_BIT_XOR: default_layer_xor(bits | mask); break;
|
|
||||||
case OP_BIT_SET: default_layer_and(mask); default_layer_or(bits); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Layer Bitwise Operation */
|
|
||||||
if (event.pressed ? (action.layer_bitop.on & ON_PRESS) :
|
|
||||||
(action.layer_bitop.on & ON_RELEASE)) {
|
|
||||||
uint8_t shift = action.layer_bitop.part*4;
|
|
||||||
uint32_t bits = ((uint32_t)action.layer_bitop.bits)<<shift;
|
|
||||||
uint32_t mask = (action.layer_bitop.xbit) ? ~(((uint32_t)0xf)<<shift) : 0;
|
|
||||||
switch (action.layer_bitop.op) {
|
|
||||||
case OP_BIT_AND: layer_and(bits | mask); break;
|
|
||||||
case OP_BIT_OR: layer_or(bits | mask); break;
|
|
||||||
case OP_BIT_XOR: layer_xor(bits | mask); break;
|
|
||||||
case OP_BIT_SET: layer_and(mask); layer_or(bits); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
|
||||||
case ACT_LAYER_TAP:
|
|
||||||
case ACT_LAYER_TAP_EXT:
|
|
||||||
switch (action.layer_tap.code) {
|
|
||||||
case 0xe0 ... 0xef:
|
|
||||||
/* layer On/Off with modifiers(left only) */
|
|
||||||
if (event.pressed) {
|
|
||||||
layer_on(action.layer_tap.val);
|
|
||||||
register_mods(action.layer_tap.code & 0x0f);
|
|
||||||
} else {
|
|
||||||
layer_off(action.layer_tap.val);
|
|
||||||
unregister_mods(action.layer_tap.code & 0x0f);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OP_TAP_TOGGLE:
|
|
||||||
/* tap toggle */
|
|
||||||
if (event.pressed) {
|
|
||||||
if (tap_count < TAPPING_TOGGLE) {
|
|
||||||
layer_invert(action.layer_tap.val);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tap_count <= TAPPING_TOGGLE) {
|
|
||||||
layer_invert(action.layer_tap.val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case OP_ON_OFF:
|
|
||||||
event.pressed ? layer_on(action.layer_tap.val) :
|
|
||||||
layer_off(action.layer_tap.val);
|
|
||||||
break;
|
|
||||||
case OP_OFF_ON:
|
|
||||||
event.pressed ? layer_off(action.layer_tap.val) :
|
|
||||||
layer_on(action.layer_tap.val);
|
|
||||||
break;
|
|
||||||
case OP_SET_CLEAR:
|
|
||||||
event.pressed ? layer_move(action.layer_tap.val) :
|
|
||||||
layer_clear();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* tap key */
|
|
||||||
if (event.pressed) {
|
|
||||||
if (tap_count > 0) {
|
|
||||||
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
|
|
||||||
register_code(action.layer_tap.code);
|
|
||||||
} else {
|
|
||||||
dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
|
|
||||||
layer_on(action.layer_tap.val);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (tap_count > 0) {
|
|
||||||
dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
|
|
||||||
unregister_code(action.layer_tap.code);
|
|
||||||
} else {
|
|
||||||
dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
|
|
||||||
layer_off(action.layer_tap.val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
/* Extentions */
|
|
||||||
#ifndef NO_ACTION_MACRO
|
|
||||||
case ACT_MACRO:
|
|
||||||
action_macro_play(action_get_macro(record, action.func.id, action.func.opt));
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
|
||||||
case ACT_BACKLIGHT:
|
|
||||||
if (!event.pressed) {
|
|
||||||
switch (action.backlight.opt) {
|
|
||||||
case BACKLIGHT_INCREASE:
|
|
||||||
backlight_increase();
|
|
||||||
break;
|
|
||||||
case BACKLIGHT_DECREASE:
|
|
||||||
backlight_decrease();
|
|
||||||
break;
|
|
||||||
case BACKLIGHT_TOGGLE:
|
|
||||||
backlight_toggle();
|
|
||||||
break;
|
|
||||||
case BACKLIGHT_STEP:
|
|
||||||
backlight_step();
|
|
||||||
break;
|
|
||||||
case BACKLIGHT_LEVEL:
|
|
||||||
backlight_level(action.backlight.level);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case ACT_COMMAND:
|
|
||||||
break;
|
|
||||||
#ifndef NO_ACTION_FUNCTION
|
|
||||||
case ACT_FUNCTION:
|
|
||||||
action_function(record, action.func.id, action.func.opt);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Utilities for actions.
|
|
||||||
*/
|
|
||||||
void register_code(uint8_t code)
|
|
||||||
{
|
|
||||||
if (code == KC_NO) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOCKING_SUPPORT_ENABLE
|
|
||||||
else if (KC_LOCKING_CAPS == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
// Resync: ignore if caps lock already is on
|
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_CAPSLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_CAPSLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_NUM == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_NUMLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_NUMLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_SCROLL == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_SCROLLLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_SCROLLLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
else if IS_KEY(code) {
|
|
||||||
// TODO: should push command_proc out of this block?
|
|
||||||
if (command_proc(code)) return;
|
|
||||||
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
/* TODO: remove
|
|
||||||
if (oneshot_state.mods && !oneshot_state.disabled) {
|
|
||||||
uint8_t tmp_mods = get_mods();
|
|
||||||
add_mods(oneshot_state.mods);
|
|
||||||
|
|
||||||
add_key(code);
|
|
||||||
send_keyboard_report();
|
|
||||||
|
|
||||||
set_mods(tmp_mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
oneshot_cancel();
|
|
||||||
} else
|
|
||||||
*/
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
add_key(code);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if IS_MOD(code) {
|
|
||||||
add_mods(MOD_BIT(code));
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
else if IS_SYSTEM(code) {
|
|
||||||
host_system_send(KEYCODE2SYSTEM(code));
|
|
||||||
}
|
|
||||||
else if IS_CONSUMER(code) {
|
|
||||||
host_consumer_send(KEYCODE2CONSUMER(code));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void unregister_code(uint8_t code)
|
|
||||||
{
|
|
||||||
if (code == KC_NO) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LOCKING_SUPPORT_ENABLE
|
|
||||||
else if (KC_LOCKING_CAPS == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
// Resync: ignore if caps lock already is off
|
|
||||||
if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_CAPSLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_CAPSLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_NUM == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_NUMLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_NUMLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (KC_LOCKING_SCROLL == code) {
|
|
||||||
#ifdef LOCKING_RESYNC_ENABLE
|
|
||||||
if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return;
|
|
||||||
#endif
|
|
||||||
add_key(KC_SCROLLLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
del_key(KC_SCROLLLOCK);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
else if IS_KEY(code) {
|
|
||||||
del_key(code);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
else if IS_MOD(code) {
|
|
||||||
del_mods(MOD_BIT(code));
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
else if IS_SYSTEM(code) {
|
|
||||||
host_system_send(0);
|
|
||||||
}
|
|
||||||
else if IS_CONSUMER(code) {
|
|
||||||
host_consumer_send(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void register_mods(uint8_t mods)
|
|
||||||
{
|
|
||||||
if (mods) {
|
|
||||||
add_mods(mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void unregister_mods(uint8_t mods)
|
|
||||||
{
|
|
||||||
if (mods) {
|
|
||||||
del_mods(mods);
|
|
||||||
send_keyboard_report();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_keyboard(void)
|
|
||||||
{
|
|
||||||
clear_mods();
|
|
||||||
clear_keyboard_but_mods();
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_keyboard_but_mods(void)
|
|
||||||
{
|
|
||||||
clear_weak_mods();
|
|
||||||
clear_keys();
|
|
||||||
send_keyboard_report();
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
mousekey_clear();
|
|
||||||
mousekey_send();
|
|
||||||
#endif
|
|
||||||
#ifdef EXTRAKEY_ENABLE
|
|
||||||
host_system_send(0);
|
|
||||||
host_consumer_send(0);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_tap_key(keypos_t key)
|
|
||||||
{
|
|
||||||
action_t action = layer_switch_get_action(key);
|
|
||||||
|
|
||||||
switch (action.kind.id) {
|
|
||||||
case ACT_LMODS_TAP:
|
|
||||||
case ACT_RMODS_TAP:
|
|
||||||
case ACT_LAYER_TAP:
|
|
||||||
case ACT_LAYER_TAP_EXT:
|
|
||||||
return true;
|
|
||||||
case ACT_MACRO:
|
|
||||||
case ACT_FUNCTION:
|
|
||||||
if (action.func.opt & FUNC_TAP) { return true; }
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* debug print
|
|
||||||
*/
|
|
||||||
void debug_event(keyevent_t event)
|
|
||||||
{
|
|
||||||
dprintf("%04X%c(%u)", (event.key.row<<8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_record(keyrecord_t record)
|
|
||||||
{
|
|
||||||
debug_event(record.event);
|
|
||||||
#ifndef NO_ACTION_TAPPING
|
|
||||||
dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void debug_action(action_t action)
|
|
||||||
{
|
|
||||||
switch (action.kind.id) {
|
|
||||||
case ACT_LMODS: dprint("ACT_LMODS"); break;
|
|
||||||
case ACT_RMODS: dprint("ACT_RMODS"); break;
|
|
||||||
case ACT_LMODS_TAP: dprint("ACT_LMODS_TAP"); break;
|
|
||||||
case ACT_RMODS_TAP: dprint("ACT_RMODS_TAP"); break;
|
|
||||||
case ACT_USAGE: dprint("ACT_USAGE"); break;
|
|
||||||
case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break;
|
|
||||||
case ACT_LAYER: dprint("ACT_LAYER"); break;
|
|
||||||
case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break;
|
|
||||||
case ACT_LAYER_TAP_EXT: dprint("ACT_LAYER_TAP_EXT"); break;
|
|
||||||
case ACT_MACRO: dprint("ACT_MACRO"); break;
|
|
||||||
case ACT_COMMAND: dprint("ACT_COMMAND"); break;
|
|
||||||
case ACT_FUNCTION: dprint("ACT_FUNCTION"); break;
|
|
||||||
default: dprint("UNKNOWN"); break;
|
|
||||||
}
|
|
||||||
dprintf("[%X:%02X]", action.kind.param>>8, action.kind.param&0xff);
|
|
||||||
}
|
|
@ -1,315 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013 Jun Wako <wakojun@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 ACTION_CODE_H
|
|
||||||
#define ACTION_CODE_H
|
|
||||||
|
|
||||||
/* Action codes
|
|
||||||
* ============
|
|
||||||
* 16bit code: action_kind(4bit) + action_parameter(12bit)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Key Actions(00xx)
|
|
||||||
* -----------------
|
|
||||||
* ACT_MODS(000r):
|
|
||||||
* 000r|0000|0000 0000 No action code
|
|
||||||
* 000r|0000|0000 0001 Transparent code
|
|
||||||
* 000r|0000| keycode Key
|
|
||||||
* 000r|mods|0000 0000 Modifiers
|
|
||||||
* 000r|mods| keycode Modifiers+Key(Modified key)
|
|
||||||
* r: Left/Right flag(Left:0, Right:1)
|
|
||||||
*
|
|
||||||
* ACT_MODS_TAP(001r):
|
|
||||||
* 001r|mods|0000 0000 Modifiers with OneShot
|
|
||||||
* 001r|mods|0000 0001 Modifiers with tap toggle
|
|
||||||
* 001r|mods|0000 00xx (reserved)
|
|
||||||
* 001r|mods| keycode Modifiers with Tap Key(Dual role)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Other Keys(01xx)
|
|
||||||
* ----------------
|
|
||||||
* ACT_USAGE(0100): TODO: Not needed?
|
|
||||||
* 0100|00| usage(10) System control(0x80) - General Desktop page(0x01)
|
|
||||||
* 0100|01| usage(10) Consumer control(0x01) - Consumer page(0x0C)
|
|
||||||
* 0100|10| usage(10) (reserved)
|
|
||||||
* 0100|11| usage(10) (reserved)
|
|
||||||
*
|
|
||||||
* ACT_MOUSEKEY(0110): TODO: Not needed?
|
|
||||||
* 0101|xxxx| keycode Mouse key
|
|
||||||
*
|
|
||||||
* 011x|xxxx xxxx xxxx (reseved)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Layer Actions(10xx)
|
|
||||||
* -------------------
|
|
||||||
* ACT_LAYER(1000):
|
|
||||||
* 1000|oo00|pppE BBBB Default Layer Bitwise operation
|
|
||||||
* oo: operation(00:AND, 01:OR, 10:XOR, 11:SET)
|
|
||||||
* ppp: 4-bit chunk part(0-7)
|
|
||||||
* EBBBB: bits and extra bit
|
|
||||||
* 1000|ooee|pppE BBBB Layer Bitwise Operation
|
|
||||||
* oo: operation(00:AND, 01:OR, 10:XOR, 11:SET)
|
|
||||||
* ppp: 4-bit chunk part(0-7)
|
|
||||||
* EBBBB: bits and extra bit
|
|
||||||
* 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
|
|
||||||
* 101E|LLLL|1110 mods On/Off with modifiers(0xE0-EF)
|
|
||||||
* 101E|LLLL|1111 0000 Invert with tap toggle(0xF0)
|
|
||||||
* 101E|LLLL|1111 0001 On/Off
|
|
||||||
* 101E|LLLL|1111 0010 Off/On
|
|
||||||
* 101E|LLLL|1111 0011 Set/Clear
|
|
||||||
* 101E|LLLL|1111 xxxx Reserved(0xF4-FF)
|
|
||||||
* ELLLL: layer 0-31(E: extra bit for layer 16-31)
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Extensions(11xx)
|
|
||||||
* ----------------
|
|
||||||
* ACT_MACRO(1100):
|
|
||||||
* 1100|opt | id(8) Macro play?
|
|
||||||
* 1100|1111| id(8) Macro record?
|
|
||||||
*
|
|
||||||
* ACT_BACKLIGHT(1101):
|
|
||||||
* 1101|opt |level(8) Backlight commands
|
|
||||||
*
|
|
||||||
* ACT_COMMAND(1110):
|
|
||||||
* 1110|opt | id(8) Built-in Command exec
|
|
||||||
*
|
|
||||||
* ACT_FUNCTION(1111):
|
|
||||||
* 1111| address(12) Function?
|
|
||||||
* 1111|opt | id(8) Function?
|
|
||||||
*/
|
|
||||||
enum action_kind_id {
|
|
||||||
/* Key Actions */
|
|
||||||
ACT_MODS = 0b0000,
|
|
||||||
ACT_LMODS = 0b0000,
|
|
||||||
ACT_RMODS = 0b0001,
|
|
||||||
ACT_MODS_TAP = 0b0010,
|
|
||||||
ACT_LMODS_TAP = 0b0010,
|
|
||||||
ACT_RMODS_TAP = 0b0011,
|
|
||||||
/* Other Keys */
|
|
||||||
ACT_USAGE = 0b0100,
|
|
||||||
ACT_MOUSEKEY = 0b0101,
|
|
||||||
/* Layer Actions */
|
|
||||||
ACT_LAYER = 0b1000,
|
|
||||||
ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
|
|
||||||
ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
|
|
||||||
/* Extensions */
|
|
||||||
ACT_MACRO = 0b1100,
|
|
||||||
ACT_BACKLIGHT = 0b1101,
|
|
||||||
ACT_COMMAND = 0b1110,
|
|
||||||
ACT_FUNCTION = 0b1111
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* Action Code Struct
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* In avr-gcc bit field seems to be assigned from LSB(bit0) to MSB(bit15).
|
|
||||||
* AVR looks like a little endian in avr-gcc.
|
|
||||||
* Not portable across compiler/endianness?
|
|
||||||
*
|
|
||||||
* Byte order and bit order of 0x1234:
|
|
||||||
* Big endian: Little endian:
|
|
||||||
* -------------------- --------------------
|
|
||||||
* FEDC BA98 7654 3210 0123 4567 89AB CDEF
|
|
||||||
* 0001 0010 0011 0100 0010 1100 0100 1000
|
|
||||||
* 0x12 0x34 0x34 0x12
|
|
||||||
*/
|
|
||||||
typedef union {
|
|
||||||
uint16_t code;
|
|
||||||
struct action_kind {
|
|
||||||
uint16_t param :12;
|
|
||||||
uint8_t id :4;
|
|
||||||
} kind;
|
|
||||||
struct action_key {
|
|
||||||
uint8_t code :8;
|
|
||||||
uint8_t mods :4;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} key;
|
|
||||||
struct action_layer_bitop {
|
|
||||||
uint8_t bits :4;
|
|
||||||
uint8_t xbit :1;
|
|
||||||
uint8_t part :3;
|
|
||||||
uint8_t on :2;
|
|
||||||
uint8_t op :2;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} layer_bitop;
|
|
||||||
struct action_layer_tap {
|
|
||||||
uint8_t code :8;
|
|
||||||
uint8_t val :5;
|
|
||||||
uint8_t kind :3;
|
|
||||||
} layer_tap;
|
|
||||||
struct action_usage {
|
|
||||||
uint16_t code :10;
|
|
||||||
uint8_t page :2;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} usage;
|
|
||||||
struct action_backlight {
|
|
||||||
uint8_t level :8;
|
|
||||||
uint8_t opt :4;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} backlight;
|
|
||||||
struct action_command {
|
|
||||||
uint8_t id :8;
|
|
||||||
uint8_t opt :4;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} command;
|
|
||||||
struct action_function {
|
|
||||||
uint8_t id :8;
|
|
||||||
uint8_t opt :4;
|
|
||||||
uint8_t kind :4;
|
|
||||||
} func;
|
|
||||||
} action_t;
|
|
||||||
|
|
||||||
|
|
||||||
/* action utility */
|
|
||||||
#define ACTION_NO 0
|
|
||||||
#define ACTION_TRANSPARENT 1
|
|
||||||
#define ACTION(kind, param) ((kind)<<12 | (param))
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Key Actions
|
|
||||||
*/
|
|
||||||
/* Mod bits: 43210
|
|
||||||
* bit 0 ||||+- Control
|
|
||||||
* bit 1 |||+-- Shift
|
|
||||||
* bit 2 ||+--- Alt
|
|
||||||
* bit 3 |+---- Gui
|
|
||||||
* bit 4 +----- LR flag(Left:0, Right:1)
|
|
||||||
*/
|
|
||||||
enum mods_bit {
|
|
||||||
MOD_LCTL = 0x01,
|
|
||||||
MOD_LSFT = 0x02,
|
|
||||||
MOD_LALT = 0x04,
|
|
||||||
MOD_LGUI = 0x08,
|
|
||||||
MOD_RCTL = 0x11,
|
|
||||||
MOD_RSFT = 0x12,
|
|
||||||
MOD_RALT = 0x14,
|
|
||||||
MOD_RGUI = 0x18,
|
|
||||||
};
|
|
||||||
enum mods_codes {
|
|
||||||
MODS_ONESHOT = 0x00,
|
|
||||||
MODS_TAP_TOGGLE = 0x01,
|
|
||||||
};
|
|
||||||
#define ACTION_KEY(key) ACTION(ACT_MODS, (key))
|
|
||||||
#define ACTION_MODS(mods) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | 0)
|
|
||||||
#define ACTION_MODS_KEY(mods, key) ACTION(ACT_MODS, ((mods)&0x1f)<<8 | (key))
|
|
||||||
#define ACTION_MODS_TAP_KEY(mods, key) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | (key))
|
|
||||||
#define ACTION_MODS_ONESHOT(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_ONESHOT)
|
|
||||||
#define ACTION_MODS_TAP_TOGGLE(mods) ACTION(ACT_MODS_TAP, ((mods)&0x1f)<<8 | MODS_TAP_TOGGLE)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Other Keys
|
|
||||||
*/
|
|
||||||
enum usage_pages {
|
|
||||||
PAGE_SYSTEM,
|
|
||||||
PAGE_CONSUMER
|
|
||||||
};
|
|
||||||
#define ACTION_USAGE_SYSTEM(id) ACTION(ACT_USAGE, PAGE_SYSTEM<<10 | (id))
|
|
||||||
#define ACTION_USAGE_CONSUMER(id) ACTION(ACT_USAGE, PAGE_CONSUMER<<10 | (id))
|
|
||||||
#define ACTION_MOUSEKEY(key) ACTION(ACT_MOUSEKEY, key)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Layer Actions
|
|
||||||
*/
|
|
||||||
enum layer_param_on {
|
|
||||||
ON_PRESS = 1,
|
|
||||||
ON_RELEASE = 2,
|
|
||||||
ON_BOTH = 3,
|
|
||||||
};
|
|
||||||
enum layer_param_bit_op {
|
|
||||||
OP_BIT_AND = 0,
|
|
||||||
OP_BIT_OR = 1,
|
|
||||||
OP_BIT_XOR = 2,
|
|
||||||
OP_BIT_SET = 3,
|
|
||||||
};
|
|
||||||
enum layer_pram_tap_op {
|
|
||||||
OP_TAP_TOGGLE = 0xF0,
|
|
||||||
OP_ON_OFF,
|
|
||||||
OP_OFF_ON,
|
|
||||||
OP_SET_CLEAR,
|
|
||||||
};
|
|
||||||
#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
|
|
||||||
#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key))
|
|
||||||
/* Default Layer */
|
|
||||||
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4))
|
|
||||||
/* Layer Operation */
|
|
||||||
#define ACTION_LAYER_CLEAR(on) ACTION_LAYER_BIT_AND(0, 0, (on))
|
|
||||||
#define ACTION_LAYER_MOMENTARY(layer) ACTION_LAYER_ON_OFF(layer)
|
|
||||||
#define ACTION_LAYER_TOGGLE(layer) ACTION_LAYER_INVERT(layer, ON_RELEASE)
|
|
||||||
#define ACTION_LAYER_INVERT(layer, on) ACTION_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4), (on))
|
|
||||||
#define ACTION_LAYER_ON(layer, on) ACTION_LAYER_BIT_OR( (layer)/4, 1<<((layer)%4), (on))
|
|
||||||
#define ACTION_LAYER_OFF(layer, on) ACTION_LAYER_BIT_AND((layer)/4, ~(1<<((layer)%4)), (on))
|
|
||||||
#define ACTION_LAYER_SET(layer, on) ACTION_LAYER_BIT_SET((layer)/4, 1<<((layer)%4), (on))
|
|
||||||
#define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF)
|
|
||||||
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
|
|
||||||
#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
|
|
||||||
#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | (mods)&0x0f)
|
|
||||||
/* With Tapping */
|
|
||||||
#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
|
|
||||||
#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
|
|
||||||
/* Bitwise Operation */
|
|
||||||
#define ACTION_LAYER_BIT_AND(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), (on))
|
|
||||||
#define ACTION_LAYER_BIT_OR( part, bits, on) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), (on))
|
|
||||||
#define ACTION_LAYER_BIT_XOR(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), (on))
|
|
||||||
#define ACTION_LAYER_BIT_SET(part, bits, on) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), (on))
|
|
||||||
/* Default Layer Bitwise Operation */
|
|
||||||
#define ACTION_DEFAULT_LAYER_BIT_AND(part, bits) ACTION_LAYER_BITOP(OP_BIT_AND, (part), (bits), 0)
|
|
||||||
#define ACTION_DEFAULT_LAYER_BIT_OR( part, bits) ACTION_LAYER_BITOP(OP_BIT_OR, (part), (bits), 0)
|
|
||||||
#define ACTION_DEFAULT_LAYER_BIT_XOR(part, bits) ACTION_LAYER_BITOP(OP_BIT_XOR, (part), (bits), 0)
|
|
||||||
#define ACTION_DEFAULT_LAYER_BIT_SET(part, bits) ACTION_LAYER_BITOP(OP_BIT_SET, (part), (bits), 0)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Extensions
|
|
||||||
*/
|
|
||||||
enum backlight_opt {
|
|
||||||
BACKLIGHT_INCREASE = 0,
|
|
||||||
BACKLIGHT_DECREASE = 1,
|
|
||||||
BACKLIGHT_TOGGLE = 2,
|
|
||||||
BACKLIGHT_STEP = 3,
|
|
||||||
BACKLIGHT_LEVEL = 4,
|
|
||||||
};
|
|
||||||
/* Macro */
|
|
||||||
#define ACTION_MACRO(id) ACTION(ACT_MACRO, (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))
|
|
||||||
/* Backlight */
|
|
||||||
#define ACTION_BACKLIGHT_INCREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_INCREASE << 8)
|
|
||||||
#define ACTION_BACKLIGHT_DECREASE() ACTION(ACT_BACKLIGHT, BACKLIGHT_DECREASE << 8)
|
|
||||||
#define ACTION_BACKLIGHT_TOGGLE() ACTION(ACT_BACKLIGHT, BACKLIGHT_TOGGLE << 8)
|
|
||||||
#define ACTION_BACKLIGHT_STEP() ACTION(ACT_BACKLIGHT, BACKLIGHT_STEP << 8)
|
|
||||||
#define ACTION_BACKLIGHT_LEVEL(level) ACTION(ACT_BACKLIGHT, BACKLIGHT_LEVEL << 8 | level)
|
|
||||||
/* Command */
|
|
||||||
#define ACTION_COMMAND(id, opt) ACTION(ACT_COMMAND, (opt)<<8 | (addr))
|
|
||||||
/* Function */
|
|
||||||
enum function_opts {
|
|
||||||
FUNC_TAP = 0x8, /* indciates function is tappable */
|
|
||||||
};
|
|
||||||
#define ACTION_FUNCTION(id) ACTION(ACT_FUNCTION, (id))
|
|
||||||
#define ACTION_FUNCTION_TAP(id) ACTION(ACT_FUNCTION, FUNC_TAP<<8 | (id))
|
|
||||||
#define ACTION_FUNCTION_OPT(id, opt) ACTION(ACT_FUNCTION, (opt)<<8 | (id))
|
|
||||||
|
|
||||||
#endif /* ACTION_CODE_H */
|
|
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013 Jun Wako <wakojun@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 "action.h"
|
|
||||||
#include "action_util.h"
|
|
||||||
#include "action_macro.h"
|
|
||||||
#include "wait.h"
|
|
||||||
|
|
||||||
#ifdef DEBUG_ACTION
|
|
||||||
#include "debug.h"
|
|
||||||
#else
|
|
||||||
#include "nodebug.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_ACTION_MACRO
|
|
||||||
|
|
||||||
#define MACRO_READ() (macro = MACRO_GET(macro_p++))
|
|
||||||
void action_macro_play(const macro_t *macro_p)
|
|
||||||
{
|
|
||||||
macro_t macro = END;
|
|
||||||
uint8_t interval = 0;
|
|
||||||
|
|
||||||
if (!macro_p) return;
|
|
||||||
while (true) {
|
|
||||||
switch (MACRO_READ()) {
|
|
||||||
case KEY_DOWN:
|
|
||||||
MACRO_READ();
|
|
||||||
dprintf("KEY_DOWN(%02X)\n", macro);
|
|
||||||
if (IS_MOD(macro)) {
|
|
||||||
add_weak_mods(MOD_BIT(macro));
|
|
||||||
} else {
|
|
||||||
register_code(macro);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KEY_UP:
|
|
||||||
MACRO_READ();
|
|
||||||
dprintf("KEY_UP(%02X)\n", macro);
|
|
||||||
if (IS_MOD(macro)) {
|
|
||||||
del_weak_mods(MOD_BIT(macro));
|
|
||||||
} else {
|
|
||||||
unregister_code(macro);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case WAIT:
|
|
||||||
MACRO_READ();
|
|
||||||
dprintf("WAIT(%u)\n", macro);
|
|
||||||
{ uint8_t ms = macro; while (ms--) wait_ms(1); }
|
|
||||||
break;
|
|
||||||
case INTERVAL:
|
|
||||||
interval = MACRO_READ();
|
|
||||||
dprintf("INTERVAL(%u)\n", interval);
|
|
||||||
break;
|
|
||||||
case 0x04 ... 0x73:
|
|
||||||
dprintf("DOWN(%02X)\n", macro);
|
|
||||||
register_code(macro);
|
|
||||||
break;
|
|
||||||
case 0x84 ... 0xF3:
|
|
||||||
dprintf("UP(%02X)\n", macro);
|
|
||||||
unregister_code(macro&0x7F);
|
|
||||||
break;
|
|
||||||
case END:
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// interval
|
|
||||||
{ uint8_t ms = interval; while (ms--) wait_ms(1); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,307 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013 Jun Wako <wakojun@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 "host.h"
|
|
||||||
#include "report.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "action_util.h"
|
|
||||||
#include "timer.h"
|
|
||||||
|
|
||||||
static inline void add_key_byte(uint8_t code);
|
|
||||||
static inline void del_key_byte(uint8_t code);
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
static inline void add_key_bit(uint8_t code);
|
|
||||||
static inline void del_key_bit(uint8_t code);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t real_mods = 0;
|
|
||||||
static uint8_t weak_mods = 0;
|
|
||||||
|
|
||||||
#ifdef USB_6KRO_ENABLE
|
|
||||||
#define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS)
|
|
||||||
#define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS)
|
|
||||||
#define RO_INC(a) RO_ADD(a, 1)
|
|
||||||
#define RO_DEC(a) RO_SUB(a, 1)
|
|
||||||
static int8_t cb_head = 0;
|
|
||||||
static int8_t cb_tail = 0;
|
|
||||||
static int8_t cb_count = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: pointer variable is not needed
|
|
||||||
//report_keyboard_t keyboard_report = {};
|
|
||||||
report_keyboard_t *keyboard_report = &(report_keyboard_t){};
|
|
||||||
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
static int8_t oneshot_mods = 0;
|
|
||||||
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
|
||||||
static int16_t oneshot_time = 0;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void send_keyboard_report(void) {
|
|
||||||
keyboard_report->mods = real_mods;
|
|
||||||
keyboard_report->mods |= weak_mods;
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
if (oneshot_mods) {
|
|
||||||
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
|
||||||
if (TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT) {
|
|
||||||
dprintf("Oneshot: timeout\n");
|
|
||||||
clear_oneshot_mods();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
keyboard_report->mods |= oneshot_mods;
|
|
||||||
if (has_anykey()) {
|
|
||||||
clear_oneshot_mods();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
host_keyboard_send(keyboard_report);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* key */
|
|
||||||
void add_key(uint8_t key)
|
|
||||||
{
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_nkro) {
|
|
||||||
add_key_bit(key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
add_key_byte(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void del_key(uint8_t key)
|
|
||||||
{
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_nkro) {
|
|
||||||
del_key_bit(key);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
del_key_byte(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_keys(void)
|
|
||||||
{
|
|
||||||
// not clear mods
|
|
||||||
for (int8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
|
|
||||||
keyboard_report->raw[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* modifier */
|
|
||||||
uint8_t get_mods(void) { return real_mods; }
|
|
||||||
void add_mods(uint8_t mods) { real_mods |= mods; }
|
|
||||||
void del_mods(uint8_t mods) { real_mods &= ~mods; }
|
|
||||||
void set_mods(uint8_t mods) { real_mods = mods; }
|
|
||||||
void clear_mods(void) { real_mods = 0; }
|
|
||||||
|
|
||||||
/* weak modifier */
|
|
||||||
uint8_t get_weak_mods(void) { return weak_mods; }
|
|
||||||
void add_weak_mods(uint8_t mods) { weak_mods |= mods; }
|
|
||||||
void del_weak_mods(uint8_t mods) { weak_mods &= ~mods; }
|
|
||||||
void set_weak_mods(uint8_t mods) { weak_mods = mods; }
|
|
||||||
void clear_weak_mods(void) { weak_mods = 0; }
|
|
||||||
|
|
||||||
/* Oneshot modifier */
|
|
||||||
#ifndef NO_ACTION_ONESHOT
|
|
||||||
void set_oneshot_mods(uint8_t mods)
|
|
||||||
{
|
|
||||||
oneshot_mods = mods;
|
|
||||||
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
|
||||||
oneshot_time = timer_read();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
void clear_oneshot_mods(void)
|
|
||||||
{
|
|
||||||
oneshot_mods = 0;
|
|
||||||
#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
|
|
||||||
oneshot_time = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* inspect keyboard state
|
|
||||||
*/
|
|
||||||
uint8_t has_anykey(void)
|
|
||||||
{
|
|
||||||
uint8_t cnt = 0;
|
|
||||||
for (uint8_t i = 1; i < KEYBOARD_REPORT_SIZE; i++) {
|
|
||||||
if (keyboard_report->raw[i])
|
|
||||||
cnt++;
|
|
||||||
}
|
|
||||||
return cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t has_anymod(void)
|
|
||||||
{
|
|
||||||
return bitpop(real_mods);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t get_first_key(void)
|
|
||||||
{
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
if (keyboard_nkro) {
|
|
||||||
uint8_t i = 0;
|
|
||||||
for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
|
|
||||||
;
|
|
||||||
return i<<3 | biton(keyboard_report->nkro.bits[i]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef USB_6KRO_ENABLE
|
|
||||||
uint8_t i = cb_head;
|
|
||||||
do {
|
|
||||||
if (keyboard_report->keys[i] != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i = RO_INC(i);
|
|
||||||
} while (i != cb_tail);
|
|
||||||
return keyboard_report->keys[i];
|
|
||||||
#else
|
|
||||||
return keyboard_report->keys[0];
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* local functions */
|
|
||||||
static inline void add_key_byte(uint8_t code)
|
|
||||||
{
|
|
||||||
#ifdef USB_6KRO_ENABLE
|
|
||||||
int8_t i = cb_head;
|
|
||||||
int8_t empty = -1;
|
|
||||||
if (cb_count) {
|
|
||||||
do {
|
|
||||||
if (keyboard_report->keys[i] == code) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (empty == -1 && keyboard_report->keys[i] == 0) {
|
|
||||||
empty = i;
|
|
||||||
}
|
|
||||||
i = RO_INC(i);
|
|
||||||
} while (i != cb_tail);
|
|
||||||
if (i == cb_tail) {
|
|
||||||
if (cb_tail == cb_head) {
|
|
||||||
// buffer is full
|
|
||||||
if (empty == -1) {
|
|
||||||
// pop head when has no empty space
|
|
||||||
cb_head = RO_INC(cb_head);
|
|
||||||
cb_count--;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// left shift when has empty space
|
|
||||||
uint8_t offset = 1;
|
|
||||||
i = RO_INC(empty);
|
|
||||||
do {
|
|
||||||
if (keyboard_report->keys[i] != 0) {
|
|
||||||
keyboard_report->keys[empty] = keyboard_report->keys[i];
|
|
||||||
keyboard_report->keys[i] = 0;
|
|
||||||
empty = RO_INC(empty);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
offset++;
|
|
||||||
}
|
|
||||||
i = RO_INC(i);
|
|
||||||
} while (i != cb_tail);
|
|
||||||
cb_tail = RO_SUB(cb_tail, offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// add to tail
|
|
||||||
keyboard_report->keys[cb_tail] = code;
|
|
||||||
cb_tail = RO_INC(cb_tail);
|
|
||||||
cb_count++;
|
|
||||||
#else
|
|
||||||
int8_t i = 0;
|
|
||||||
int8_t empty = -1;
|
|
||||||
for (; i < KEYBOARD_REPORT_KEYS; i++) {
|
|
||||||
if (keyboard_report->keys[i] == code) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (empty == -1 && keyboard_report->keys[i] == 0) {
|
|
||||||
empty = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == KEYBOARD_REPORT_KEYS) {
|
|
||||||
if (empty != -1) {
|
|
||||||
keyboard_report->keys[empty] = code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void del_key_byte(uint8_t code)
|
|
||||||
{
|
|
||||||
#ifdef USB_6KRO_ENABLE
|
|
||||||
uint8_t i = cb_head;
|
|
||||||
if (cb_count) {
|
|
||||||
do {
|
|
||||||
if (keyboard_report->keys[i] == code) {
|
|
||||||
keyboard_report->keys[i] = 0;
|
|
||||||
cb_count--;
|
|
||||||
if (cb_count == 0) {
|
|
||||||
// reset head and tail
|
|
||||||
cb_tail = cb_head = 0;
|
|
||||||
}
|
|
||||||
if (i == RO_DEC(cb_tail)) {
|
|
||||||
// left shift when next to tail
|
|
||||||
do {
|
|
||||||
cb_tail = RO_DEC(cb_tail);
|
|
||||||
if (keyboard_report->keys[RO_DEC(cb_tail)] != 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (cb_tail != cb_head);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
i = RO_INC(i);
|
|
||||||
} while (i != cb_tail);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
|
|
||||||
if (keyboard_report->keys[i] == code) {
|
|
||||||
keyboard_report->keys[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
static inline void add_key_bit(uint8_t code)
|
|
||||||
{
|
|
||||||
if ((code>>3) < KEYBOARD_REPORT_BITS) {
|
|
||||||
keyboard_report->nkro.bits[code>>3] |= 1<<(code&7);
|
|
||||||
} else {
|
|
||||||
dprintf("add_key_bit: can't add: %02X\n", code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void del_key_bit(uint8_t code)
|
|
||||||
{
|
|
||||||
if ((code>>3) < KEYBOARD_REPORT_BITS) {
|
|
||||||
keyboard_report->nkro.bits[code>>3] &= ~(1<<(code&7));
|
|
||||||
} else {
|
|
||||||
dprintf("del_key_bit: can't del: %02X\n", code);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,148 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <avr/io.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
#include "bootloader.h"
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* Boot Section Size in *BYTEs*
|
|
||||||
* Teensy halfKay 512
|
|
||||||
* Teensy++ halfKay 1024
|
|
||||||
* Atmel DFU loader 4096
|
|
||||||
* LUFA bootloader 4096
|
|
||||||
* USBaspLoader 2048
|
|
||||||
*/
|
|
||||||
#ifndef BOOTLOADER_SIZE
|
|
||||||
#warning To use bootloader_jump() you need to define BOOTLOADER_SIZE in config.h.
|
|
||||||
#define BOOTLOADER_SIZE 4096
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FLASH_SIZE (FLASHEND + 1L)
|
|
||||||
#define BOOTLOADER_START (FLASH_SIZE - BOOTLOADER_SIZE)
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Entering the Bootloader via Software
|
|
||||||
* http://www.fourwalledcubicle.com/files/LUFA/Doc/120730/html/_page__software_bootloader_start.html
|
|
||||||
*/
|
|
||||||
#define BOOTLOADER_RESET_KEY 0xB007B007
|
|
||||||
uint32_t reset_key __attribute__ ((section (".noinit")));
|
|
||||||
|
|
||||||
/* initialize MCU status by watchdog reset */
|
|
||||||
void bootloader_jump(void) {
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
USB_Disable();
|
|
||||||
cli();
|
|
||||||
_delay_ms(2000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
cli();
|
|
||||||
UDCON = 1;
|
|
||||||
USBCON = (1<<FRZCLK);
|
|
||||||
UCSR1B = 0;
|
|
||||||
_delay_ms(5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// watchdog reset
|
|
||||||
reset_key = BOOTLOADER_RESET_KEY;
|
|
||||||
wdt_enable(WDTO_250MS);
|
|
||||||
for (;;);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* this runs before main() */
|
|
||||||
void bootloader_jump_after_watchdog_reset(void) __attribute__ ((used, naked, section (".init3")));
|
|
||||||
void bootloader_jump_after_watchdog_reset(void)
|
|
||||||
{
|
|
||||||
if ((MCUSR & (1<<WDRF)) && reset_key == BOOTLOADER_RESET_KEY) {
|
|
||||||
reset_key = 0;
|
|
||||||
|
|
||||||
// My custom USBasploader requires this to come up.
|
|
||||||
MCUSR = 0;
|
|
||||||
|
|
||||||
// Seems like Teensy halfkay loader requires clearing WDRF and disabling watchdog.
|
|
||||||
MCUSR &= ~(1<<WDRF);
|
|
||||||
wdt_disable();
|
|
||||||
|
|
||||||
// This is compled into 'icall', address should be in word unit, not byte.
|
|
||||||
((void (*)(void))(BOOTLOADER_START/2))();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Jumping To The Bootloader
|
|
||||||
* http://www.pjrc.com/teensy/jump_to_bootloader.html
|
|
||||||
*
|
|
||||||
* This method doen't work when using LUFA. idk why.
|
|
||||||
* - needs to initialize more regisers or interrupt setting?
|
|
||||||
*/
|
|
||||||
void bootloader_jump(void) {
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
USB_Disable();
|
|
||||||
cli();
|
|
||||||
_delay_ms(2000);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
cli();
|
|
||||||
UDCON = 1;
|
|
||||||
USBCON = (1<<FRZCLK);
|
|
||||||
UCSR1B = 0;
|
|
||||||
_delay_ms(5);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize
|
|
||||||
*/
|
|
||||||
#if defined(__AVR_AT90USB162__)
|
|
||||||
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0;
|
|
||||||
TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0;
|
|
||||||
DDRB = 0; DDRC = 0; DDRD = 0;
|
|
||||||
PORTB = 0; PORTC = 0; PORTD = 0;
|
|
||||||
#elif defined(__AVR_ATmega32U4__)
|
|
||||||
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
|
|
||||||
TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0;
|
|
||||||
DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0;
|
|
||||||
PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
|
|
||||||
#elif defined(__AVR_AT90USB646__)
|
|
||||||
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
|
|
||||||
TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
|
|
||||||
DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
|
|
||||||
PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
|
|
||||||
#elif defined(__AVR_AT90USB1286__)
|
|
||||||
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
|
|
||||||
TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
|
|
||||||
DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
|
|
||||||
PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* USBaspLoader
|
|
||||||
*/
|
|
||||||
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
|
|
||||||
// This makes custom USBasploader come up.
|
|
||||||
MCUSR = 0;
|
|
||||||
|
|
||||||
// initialize ports
|
|
||||||
PORTB = 0; PORTC= 0; PORTD = 0;
|
|
||||||
DDRB = 0; DDRC= 0; DDRD = 0;
|
|
||||||
|
|
||||||
// disable interrupts
|
|
||||||
EIMSK = 0; EECR = 0; SPCR = 0;
|
|
||||||
ACSR = 0; SPMCSR = 0; WDTCSR = 0; PCICR = 0;
|
|
||||||
TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0;
|
|
||||||
ADCSRA = 0; TWCR = 0; UCSR0B = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This is compled into 'icall', address should be in word unit, not byte.
|
|
||||||
((void (*)(void))(BOOTLOADER_START/2))();
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,122 +0,0 @@
|
|||||||
#include <stdbool.h>
|
|
||||||
#include <avr/sleep.h>
|
|
||||||
#include <avr/wdt.h>
|
|
||||||
#include <avr/interrupt.h>
|
|
||||||
#include "matrix.h"
|
|
||||||
#include "action.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
#include "suspend_avr.h"
|
|
||||||
#include "suspend.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
#include "lufa.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define wdt_intr_enable(value) \
|
|
||||||
__asm__ __volatile__ ( \
|
|
||||||
"in __tmp_reg__,__SREG__" "\n\t" \
|
|
||||||
"cli" "\n\t" \
|
|
||||||
"wdr" "\n\t" \
|
|
||||||
"sts %0,%1" "\n\t" \
|
|
||||||
"out __SREG__,__tmp_reg__" "\n\t" \
|
|
||||||
"sts %0,%2" "\n\t" \
|
|
||||||
: /* no outputs */ \
|
|
||||||
: "M" (_SFR_MEM_ADDR(_WD_CONTROL_REG)), \
|
|
||||||
"r" (_BV(_WD_CHANGE_BIT) | _BV(WDE)), \
|
|
||||||
"r" ((uint8_t) ((value & 0x08 ? _WD_PS3_MASK : 0x00) | \
|
|
||||||
_BV(WDIE) | (value & 0x07)) ) \
|
|
||||||
: "r0" \
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
void suspend_idle(uint8_t time)
|
|
||||||
{
|
|
||||||
cli();
|
|
||||||
set_sleep_mode(SLEEP_MODE_IDLE);
|
|
||||||
sleep_enable();
|
|
||||||
sei();
|
|
||||||
sleep_cpu();
|
|
||||||
sleep_disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Power down MCU with watchdog timer
|
|
||||||
* wdto: watchdog timer timeout defined in <avr/wdt.h>
|
|
||||||
* WDTO_15MS
|
|
||||||
* WDTO_30MS
|
|
||||||
* WDTO_60MS
|
|
||||||
* WDTO_120MS
|
|
||||||
* WDTO_250MS
|
|
||||||
* WDTO_500MS
|
|
||||||
* WDTO_1S
|
|
||||||
* WDTO_2S
|
|
||||||
* WDTO_4S
|
|
||||||
* WDTO_8S
|
|
||||||
*/
|
|
||||||
static uint8_t wdt_timeout = 0;
|
|
||||||
static void power_down(uint8_t wdto)
|
|
||||||
{
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
if (USB_DeviceState == DEVICE_STATE_Configured) return;
|
|
||||||
#endif
|
|
||||||
wdt_timeout = wdto;
|
|
||||||
|
|
||||||
// Watchdog Interrupt Mode
|
|
||||||
wdt_intr_enable(wdto);
|
|
||||||
|
|
||||||
// TODO: more power saving
|
|
||||||
// See PicoPower application note
|
|
||||||
// - I/O port input with pullup
|
|
||||||
// - prescale clock
|
|
||||||
// - BOD disable
|
|
||||||
// - Power Reduction Register PRR
|
|
||||||
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
|
|
||||||
sleep_enable();
|
|
||||||
sei();
|
|
||||||
sleep_cpu();
|
|
||||||
sleep_disable();
|
|
||||||
|
|
||||||
// Disable watchdog after sleep
|
|
||||||
wdt_disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
void suspend_power_down(void)
|
|
||||||
{
|
|
||||||
power_down(WDTO_15MS);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool suspend_wakeup_condition(void)
|
|
||||||
{
|
|
||||||
matrix_power_up();
|
|
||||||
matrix_scan();
|
|
||||||
matrix_power_down();
|
|
||||||
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
|
|
||||||
if (matrix_get_row(r)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// run immediately after wakeup
|
|
||||||
void suspend_wakeup_init(void)
|
|
||||||
{
|
|
||||||
// clear keyboard state
|
|
||||||
clear_keyboard();
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
|
||||||
backlight_init();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef NO_SUSPEND_POWER_DOWN
|
|
||||||
/* watchdog timeout */
|
|
||||||
ISR(WDT_vect)
|
|
||||||
{
|
|
||||||
// compensate timer for sleep
|
|
||||||
switch (wdt_timeout) {
|
|
||||||
case WDTO_15MS:
|
|
||||||
timer_count += 15 + 2; // WDTO_15MS + 2(from observation)
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,644 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011 Jun Wako <wakojun@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 <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <util/delay.h>
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "keymap.h"
|
|
||||||
#include "print.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#include "keyboard.h"
|
|
||||||
#include "bootloader.h"
|
|
||||||
#include "action_layer.h"
|
|
||||||
#include "action_util.h"
|
|
||||||
#include "eeconfig.h"
|
|
||||||
#include "sleep_led.h"
|
|
||||||
#include "led.h"
|
|
||||||
#include "command.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
#include "mousekey.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
# include "usb_keyboard.h"
|
|
||||||
# ifdef EXTRAKEY_ENABLE
|
|
||||||
# include "usb_extra.h"
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_VUSB
|
|
||||||
# include "usbdrv.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static bool command_common(uint8_t code);
|
|
||||||
static void command_common_help(void);
|
|
||||||
static bool command_console(uint8_t code);
|
|
||||||
static void command_console_help(void);
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
static bool mousekey_console(uint8_t code);
|
|
||||||
static void mousekey_console_help(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static uint8_t numkey2num(uint8_t code);
|
|
||||||
static void switch_default_layer(uint8_t layer);
|
|
||||||
|
|
||||||
|
|
||||||
command_state_t command_state = ONESHOT;
|
|
||||||
|
|
||||||
|
|
||||||
bool command_proc(uint8_t code)
|
|
||||||
{
|
|
||||||
switch (command_state) {
|
|
||||||
case ONESHOT:
|
|
||||||
if (!IS_COMMAND())
|
|
||||||
return false;
|
|
||||||
return (command_extra(code) || command_common(code));
|
|
||||||
break;
|
|
||||||
case CONSOLE:
|
|
||||||
if (IS_COMMAND())
|
|
||||||
return (command_extra(code) || command_common(code));
|
|
||||||
else
|
|
||||||
return (command_console_extra(code) || command_console(code));
|
|
||||||
break;
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
case MOUSEKEY:
|
|
||||||
mousekey_console(code);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
command_state = ONESHOT;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: Refactoring is needed. */
|
|
||||||
/* This allows to define extra commands. return false when not processed. */
|
|
||||||
bool command_extra(uint8_t code) __attribute__ ((weak));
|
|
||||||
bool command_extra(uint8_t code)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool command_console_extra(uint8_t code) __attribute__ ((weak));
|
|
||||||
bool command_console_extra(uint8_t code)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Command common
|
|
||||||
***********************************************************/
|
|
||||||
static void command_common_help(void)
|
|
||||||
{
|
|
||||||
print("\n\n----- Command Help -----\n");
|
|
||||||
print("c: enter console mode\n");
|
|
||||||
print("d: toggle debug enable\n");
|
|
||||||
print("x: toggle matrix debug\n");
|
|
||||||
print("k: toggle keyboard debug\n");
|
|
||||||
print("m: toggle mouse debug\n");
|
|
||||||
#ifdef SLEEP_LED_ENABLE
|
|
||||||
print("z: toggle sleep LED test\n");
|
|
||||||
#endif
|
|
||||||
print("v: print device version & info\n");
|
|
||||||
print("t: print timer count\n");
|
|
||||||
print("s: print status\n");
|
|
||||||
print("e: print eeprom config\n");
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
print("n: toggle NKRO\n");
|
|
||||||
#endif
|
|
||||||
print("0/F10: switch to Layer0 \n");
|
|
||||||
print("1/F1: switch to Layer1 \n");
|
|
||||||
print("2/F2: switch to Layer2 \n");
|
|
||||||
print("3/F3: switch to Layer3 \n");
|
|
||||||
print("4/F4: switch to Layer4 \n");
|
|
||||||
print("PScr: power down/remote wake-up\n");
|
|
||||||
print("Caps: Lock Keyboard(Child Proof)\n");
|
|
||||||
print("Paus: jump to bootloader\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
|
||||||
static void print_eeconfig(void)
|
|
||||||
{
|
|
||||||
print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n");
|
|
||||||
|
|
||||||
debug_config_t dc;
|
|
||||||
dc.raw = eeconfig_read_debug();
|
|
||||||
print("debug_config.raw: "); print_hex8(dc.raw); print("\n");
|
|
||||||
print(".enable: "); print_dec(dc.enable); print("\n");
|
|
||||||
print(".matrix: "); print_dec(dc.matrix); print("\n");
|
|
||||||
print(".keyboard: "); print_dec(dc.keyboard); print("\n");
|
|
||||||
print(".mouse: "); print_dec(dc.mouse); print("\n");
|
|
||||||
|
|
||||||
keymap_config_t kc;
|
|
||||||
kc.raw = eeconfig_read_keymap();
|
|
||||||
print("keymap_config.raw: "); print_hex8(kc.raw); print("\n");
|
|
||||||
print(".swap_control_capslock: "); print_dec(kc.swap_control_capslock); print("\n");
|
|
||||||
print(".capslock_to_control: "); print_dec(kc.capslock_to_control); print("\n");
|
|
||||||
print(".swap_lalt_lgui: "); print_dec(kc.swap_lalt_lgui); print("\n");
|
|
||||||
print(".swap_ralt_rgui: "); print_dec(kc.swap_ralt_rgui); print("\n");
|
|
||||||
print(".no_gui: "); print_dec(kc.no_gui); print("\n");
|
|
||||||
print(".swap_grave_esc: "); print_dec(kc.swap_grave_esc); print("\n");
|
|
||||||
print(".swap_backslash_backspace: "); print_dec(kc.swap_backslash_backspace); print("\n");
|
|
||||||
print(".nkro: "); print_dec(kc.nkro); print("\n");
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
|
||||||
backlight_config_t bc;
|
|
||||||
bc.raw = eeconfig_read_backlight();
|
|
||||||
print("backlight_config.raw: "); print_hex8(bc.raw); print("\n");
|
|
||||||
print(".enable: "); print_dec(bc.enable); print("\n");
|
|
||||||
print(".level: "); print_dec(bc.level); print("\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool command_common(uint8_t code)
|
|
||||||
{
|
|
||||||
static host_driver_t *host_driver = 0;
|
|
||||||
switch (code) {
|
|
||||||
#ifdef SLEEP_LED_ENABLE
|
|
||||||
case KC_Z:
|
|
||||||
// test breathing sleep LED
|
|
||||||
print("Sleep LED test\n");
|
|
||||||
sleep_led_toggle();
|
|
||||||
led_set(host_keyboard_leds());
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
|
||||||
case KC_E:
|
|
||||||
print("eeconfig:\n");
|
|
||||||
print_eeconfig();
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case KC_CAPSLOCK:
|
|
||||||
if (host_get_driver()) {
|
|
||||||
host_driver = host_get_driver();
|
|
||||||
clear_keyboard();
|
|
||||||
host_set_driver(0);
|
|
||||||
print("Locked.\n");
|
|
||||||
} else {
|
|
||||||
host_set_driver(host_driver);
|
|
||||||
print("Unlocked.\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_H:
|
|
||||||
case KC_SLASH: /* ? */
|
|
||||||
command_common_help();
|
|
||||||
break;
|
|
||||||
case KC_C:
|
|
||||||
debug_matrix = false;
|
|
||||||
debug_keyboard = false;
|
|
||||||
debug_mouse = false;
|
|
||||||
debug_enable = false;
|
|
||||||
command_console_help();
|
|
||||||
print("\nEnter Console Mode\n");
|
|
||||||
print("C> ");
|
|
||||||
command_state = CONSOLE;
|
|
||||||
break;
|
|
||||||
case KC_PAUSE:
|
|
||||||
clear_keyboard();
|
|
||||||
print("\n\nJump to bootloader... ");
|
|
||||||
_delay_ms(1000);
|
|
||||||
bootloader_jump(); // not return
|
|
||||||
print("not supported.\n");
|
|
||||||
break;
|
|
||||||
case KC_D:
|
|
||||||
if (debug_enable) {
|
|
||||||
print("\nDEBUG: disabled.\n");
|
|
||||||
debug_matrix = false;
|
|
||||||
debug_keyboard = false;
|
|
||||||
debug_mouse = false;
|
|
||||||
debug_enable = false;
|
|
||||||
} else {
|
|
||||||
print("\nDEBUG: enabled.\n");
|
|
||||||
debug_enable = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_X: // debug matrix toggle
|
|
||||||
debug_matrix = !debug_matrix;
|
|
||||||
if (debug_matrix) {
|
|
||||||
print("\nDEBUG: matrix enabled.\n");
|
|
||||||
debug_enable = true;
|
|
||||||
} else {
|
|
||||||
print("\nDEBUG: matrix disabled.\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_K: // debug keyboard toggle
|
|
||||||
debug_keyboard = !debug_keyboard;
|
|
||||||
if (debug_keyboard) {
|
|
||||||
print("\nDEBUG: keyboard enabled.\n");
|
|
||||||
debug_enable = true;
|
|
||||||
} else {
|
|
||||||
print("\nDEBUG: keyboard disabled.\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_M: // debug mouse toggle
|
|
||||||
debug_mouse = !debug_mouse;
|
|
||||||
if (debug_mouse) {
|
|
||||||
print("\nDEBUG: mouse enabled.\n");
|
|
||||||
debug_enable = true;
|
|
||||||
} else {
|
|
||||||
print("\nDEBUG: mouse disabled.\n");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KC_V: // print version & information
|
|
||||||
print("\n\n----- Version -----\n");
|
|
||||||
print("DESC: " STR(DESCRIPTION) "\n");
|
|
||||||
print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") "
|
|
||||||
"PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") "
|
|
||||||
"VER: " STR(DEVICE_VER) "\n");
|
|
||||||
print("BUILD: " STR(VERSION) " (" __TIME__ " " __DATE__ ")\n");
|
|
||||||
/* build options */
|
|
||||||
print("OPTIONS:"
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
" PJRC"
|
|
||||||
#endif
|
|
||||||
#ifdef PROTOCOL_LUFA
|
|
||||||
" LUFA"
|
|
||||||
#endif
|
|
||||||
#ifdef PROTOCOL_VUSB
|
|
||||||
" VUSB"
|
|
||||||
#endif
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
|
||||||
" BOOTMAGIC"
|
|
||||||
#endif
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
" MOUSEKEY"
|
|
||||||
#endif
|
|
||||||
#ifdef EXTRAKEY_ENABLE
|
|
||||||
" EXTRAKEY"
|
|
||||||
#endif
|
|
||||||
#ifdef CONSOLE_ENABLE
|
|
||||||
" CONSOLE"
|
|
||||||
#endif
|
|
||||||
#ifdef COMMAND_ENABLE
|
|
||||||
" COMMAND"
|
|
||||||
#endif
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
" NKRO"
|
|
||||||
#endif
|
|
||||||
#ifdef KEYMAP_SECTION_ENABLE
|
|
||||||
" KEYMAP_SECTION"
|
|
||||||
#endif
|
|
||||||
" " STR(BOOTLOADER_SIZE) "\n");
|
|
||||||
|
|
||||||
print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
|
|
||||||
" AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
|
|
||||||
" AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
|
|
||||||
break;
|
|
||||||
case KC_T: // print timer
|
|
||||||
print_val_hex32(timer_count);
|
|
||||||
break;
|
|
||||||
case KC_S:
|
|
||||||
print("\n\n----- Status -----\n");
|
|
||||||
print_val_hex8(host_keyboard_leds());
|
|
||||||
print_val_hex8(keyboard_protocol);
|
|
||||||
print_val_hex8(keyboard_idle);
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
print_val_hex8(UDCON);
|
|
||||||
print_val_hex8(UDIEN);
|
|
||||||
print_val_hex8(UDINT);
|
|
||||||
print_val_hex8(usb_keyboard_leds);
|
|
||||||
print_val_hex8(usb_keyboard_idle_count);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
# if USB_COUNT_SOF
|
|
||||||
print_val_hex8(usbSofCount);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
#ifdef NKRO_ENABLE
|
|
||||||
case KC_N:
|
|
||||||
clear_keyboard(); //Prevents stuck keys.
|
|
||||||
keyboard_nkro = !keyboard_nkro;
|
|
||||||
if (keyboard_nkro)
|
|
||||||
print("NKRO: enabled\n");
|
|
||||||
else
|
|
||||||
print("NKRO: disabled\n");
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef EXTRAKEY_ENABLE
|
|
||||||
case KC_PSCREEN:
|
|
||||||
// TODO: Power key should take this feature? otherwise any key during suspend.
|
|
||||||
#ifdef PROTOCOL_PJRC
|
|
||||||
if (suspend && remote_wakeup) {
|
|
||||||
usb_remote_wakeup();
|
|
||||||
} else {
|
|
||||||
host_system_send(SYSTEM_POWER_DOWN);
|
|
||||||
host_system_send(0);
|
|
||||||
_delay_ms(500);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
host_system_send(SYSTEM_POWER_DOWN);
|
|
||||||
_delay_ms(100);
|
|
||||||
host_system_send(0);
|
|
||||||
_delay_ms(500);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case KC_ESC:
|
|
||||||
case KC_GRV:
|
|
||||||
case KC_0:
|
|
||||||
switch_default_layer(0);
|
|
||||||
break;
|
|
||||||
case KC_1 ... KC_9:
|
|
||||||
switch_default_layer((code - KC_1) + 1);
|
|
||||||
break;
|
|
||||||
case KC_F1 ... KC_F12:
|
|
||||||
switch_default_layer((code - KC_F1) + 1);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
print("?");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Command console
|
|
||||||
***********************************************************/
|
|
||||||
static void command_console_help(void)
|
|
||||||
{
|
|
||||||
print("\n\n----- Console Help -----\n");
|
|
||||||
print("ESC/q: quit\n");
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
print("m: mousekey\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool command_console(uint8_t code)
|
|
||||||
{
|
|
||||||
switch (code) {
|
|
||||||
case KC_H:
|
|
||||||
case KC_SLASH: /* ? */
|
|
||||||
command_console_help();
|
|
||||||
break;
|
|
||||||
case KC_Q:
|
|
||||||
case KC_ESC:
|
|
||||||
print("\nQuit Console Mode\n");
|
|
||||||
command_state = ONESHOT;
|
|
||||||
return false;
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
case KC_M:
|
|
||||||
mousekey_console_help();
|
|
||||||
print("\nEnter Mousekey Console\n");
|
|
||||||
print("M0>");
|
|
||||||
command_state = MOUSEKEY;
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
print("?");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
print("C> ");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
/***********************************************************
|
|
||||||
* Mousekey console
|
|
||||||
***********************************************************/
|
|
||||||
static uint8_t mousekey_param = 0;
|
|
||||||
|
|
||||||
static void mousekey_param_print(void)
|
|
||||||
{
|
|
||||||
print("\n\n----- Mousekey Parameters -----\n");
|
|
||||||
print("1: mk_delay(*10ms): "); pdec(mk_delay); print("\n");
|
|
||||||
print("2: mk_interval(ms): "); pdec(mk_interval); print("\n");
|
|
||||||
print("3: mk_max_speed: "); pdec(mk_max_speed); print("\n");
|
|
||||||
print("4: mk_time_to_max: "); pdec(mk_time_to_max); print("\n");
|
|
||||||
print("5: mk_wheel_max_speed: "); pdec(mk_wheel_max_speed); print("\n");
|
|
||||||
print("6: mk_wheel_time_to_max: "); pdec(mk_wheel_time_to_max); print("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#define PRINT_SET_VAL(v) print(#v " = "); print_dec(v); print("\n");
|
|
||||||
static void mousekey_param_inc(uint8_t param, uint8_t inc)
|
|
||||||
{
|
|
||||||
switch (param) {
|
|
||||||
case 1:
|
|
||||||
if (mk_delay + inc < UINT8_MAX)
|
|
||||||
mk_delay += inc;
|
|
||||||
else
|
|
||||||
mk_delay = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_delay);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (mk_interval + inc < UINT8_MAX)
|
|
||||||
mk_interval += inc;
|
|
||||||
else
|
|
||||||
mk_interval = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_interval);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (mk_max_speed + inc < UINT8_MAX)
|
|
||||||
mk_max_speed += inc;
|
|
||||||
else
|
|
||||||
mk_max_speed = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_max_speed);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (mk_time_to_max + inc < UINT8_MAX)
|
|
||||||
mk_time_to_max += inc;
|
|
||||||
else
|
|
||||||
mk_time_to_max = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_time_to_max);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (mk_wheel_max_speed + inc < UINT8_MAX)
|
|
||||||
mk_wheel_max_speed += inc;
|
|
||||||
else
|
|
||||||
mk_wheel_max_speed = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_wheel_max_speed);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (mk_wheel_time_to_max + inc < UINT8_MAX)
|
|
||||||
mk_wheel_time_to_max += inc;
|
|
||||||
else
|
|
||||||
mk_wheel_time_to_max = UINT8_MAX;
|
|
||||||
PRINT_SET_VAL(mk_wheel_time_to_max);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mousekey_param_dec(uint8_t param, uint8_t dec)
|
|
||||||
{
|
|
||||||
switch (param) {
|
|
||||||
case 1:
|
|
||||||
if (mk_delay > dec)
|
|
||||||
mk_delay -= dec;
|
|
||||||
else
|
|
||||||
mk_delay = 0;
|
|
||||||
PRINT_SET_VAL(mk_delay);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (mk_interval > dec)
|
|
||||||
mk_interval -= dec;
|
|
||||||
else
|
|
||||||
mk_interval = 0;
|
|
||||||
PRINT_SET_VAL(mk_interval);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (mk_max_speed > dec)
|
|
||||||
mk_max_speed -= dec;
|
|
||||||
else
|
|
||||||
mk_max_speed = 0;
|
|
||||||
PRINT_SET_VAL(mk_max_speed);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
if (mk_time_to_max > dec)
|
|
||||||
mk_time_to_max -= dec;
|
|
||||||
else
|
|
||||||
mk_time_to_max = 0;
|
|
||||||
PRINT_SET_VAL(mk_time_to_max);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
if (mk_wheel_max_speed > dec)
|
|
||||||
mk_wheel_max_speed -= dec;
|
|
||||||
else
|
|
||||||
mk_wheel_max_speed = 0;
|
|
||||||
PRINT_SET_VAL(mk_wheel_max_speed);
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
if (mk_wheel_time_to_max > dec)
|
|
||||||
mk_wheel_time_to_max -= dec;
|
|
||||||
else
|
|
||||||
mk_wheel_time_to_max = 0;
|
|
||||||
PRINT_SET_VAL(mk_wheel_time_to_max);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mousekey_console_help(void)
|
|
||||||
{
|
|
||||||
print("\n\n----- Mousekey Parameters Help -----\n");
|
|
||||||
print("ESC/q: quit\n");
|
|
||||||
print("1: select mk_delay(*10ms)\n");
|
|
||||||
print("2: select mk_interval(ms)\n");
|
|
||||||
print("3: select mk_max_speed\n");
|
|
||||||
print("4: select mk_time_to_max\n");
|
|
||||||
print("5: select mk_wheel_max_speed\n");
|
|
||||||
print("6: select mk_wheel_time_to_max\n");
|
|
||||||
print("p: print parameters\n");
|
|
||||||
print("d: set default values\n");
|
|
||||||
print("up: increase parameters(+1)\n");
|
|
||||||
print("down: decrease parameters(-1)\n");
|
|
||||||
print("pgup: increase parameters(+10)\n");
|
|
||||||
print("pgdown: decrease parameters(-10)\n");
|
|
||||||
print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
|
|
||||||
print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
|
|
||||||
print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");
|
|
||||||
print("See http://en.wikipedia.org/wiki/Mouse_keys\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool mousekey_console(uint8_t code)
|
|
||||||
{
|
|
||||||
switch (code) {
|
|
||||||
case KC_H:
|
|
||||||
case KC_SLASH: /* ? */
|
|
||||||
mousekey_console_help();
|
|
||||||
break;
|
|
||||||
case KC_Q:
|
|
||||||
case KC_ESC:
|
|
||||||
mousekey_param = 0;
|
|
||||||
print("\nQuit Mousekey Console\n");
|
|
||||||
print("C> ");
|
|
||||||
command_state = CONSOLE;
|
|
||||||
return false;
|
|
||||||
case KC_P:
|
|
||||||
mousekey_param_print();
|
|
||||||
break;
|
|
||||||
case KC_1:
|
|
||||||
case KC_2:
|
|
||||||
case KC_3:
|
|
||||||
case KC_4:
|
|
||||||
case KC_5:
|
|
||||||
case KC_6:
|
|
||||||
case KC_7:
|
|
||||||
case KC_8:
|
|
||||||
case KC_9:
|
|
||||||
case KC_0:
|
|
||||||
mousekey_param = numkey2num(code);
|
|
||||||
print("selected parameter: "); pdec(mousekey_param); print("\n");
|
|
||||||
break;
|
|
||||||
case KC_UP:
|
|
||||||
mousekey_param_inc(mousekey_param, 1);
|
|
||||||
break;
|
|
||||||
case KC_DOWN:
|
|
||||||
mousekey_param_dec(mousekey_param, 1);
|
|
||||||
break;
|
|
||||||
case KC_PGUP:
|
|
||||||
mousekey_param_inc(mousekey_param, 10);
|
|
||||||
break;
|
|
||||||
case KC_PGDN:
|
|
||||||
mousekey_param_dec(mousekey_param, 10);
|
|
||||||
break;
|
|
||||||
case KC_D:
|
|
||||||
mk_delay = MOUSEKEY_DELAY/10;
|
|
||||||
mk_interval = MOUSEKEY_INTERVAL;
|
|
||||||
mk_max_speed = MOUSEKEY_MAX_SPEED;
|
|
||||||
mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
|
|
||||||
mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
|
|
||||||
mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
|
|
||||||
print("set default values.\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
print("?");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
print("M"); pdec(mousekey_param); print("> ");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************
|
|
||||||
* Utilities
|
|
||||||
***********************************************************/
|
|
||||||
static uint8_t numkey2num(uint8_t code)
|
|
||||||
{
|
|
||||||
switch (code) {
|
|
||||||
case KC_1: return 1;
|
|
||||||
case KC_2: return 2;
|
|
||||||
case KC_3: return 3;
|
|
||||||
case KC_4: return 4;
|
|
||||||
case KC_5: return 5;
|
|
||||||
case KC_6: return 6;
|
|
||||||
case KC_7: return 7;
|
|
||||||
case KC_8: return 8;
|
|
||||||
case KC_9: return 9;
|
|
||||||
case KC_0: return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void switch_default_layer(uint8_t layer)
|
|
||||||
{
|
|
||||||
print("switch_default_layer: "); print_dec(biton32(default_layer_state));
|
|
||||||
print(" to "); print_dec(layer); print("\n");
|
|
||||||
default_layer_set(1UL<<layer);
|
|
||||||
clear_keyboard();
|
|
||||||
}
|
|
@ -1,150 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011,2012,2013 Jun Wako <wakojun@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 <stdint.h>
|
|
||||||
#include "keyboard.h"
|
|
||||||
#include "matrix.h"
|
|
||||||
#include "keymap.h"
|
|
||||||
#include "host.h"
|
|
||||||
#include "led.h"
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "timer.h"
|
|
||||||
#include "print.h"
|
|
||||||
#include "debug.h"
|
|
||||||
#include "command.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "sendchar.h"
|
|
||||||
#include "bootmagic.h"
|
|
||||||
#include "eeconfig.h"
|
|
||||||
#include "backlight.h"
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
# include "mousekey.h"
|
|
||||||
#endif
|
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
|
||||||
# include "ps2_mouse.h"
|
|
||||||
#endif
|
|
||||||
#ifdef SERIAL_MOUSE_ENABLE
|
|
||||||
#include "serial_mouse.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MATRIX_HAS_GHOST
|
|
||||||
static bool has_ghost_in_row(uint8_t row)
|
|
||||||
{
|
|
||||||
matrix_row_t matrix_row = matrix_get_row(row);
|
|
||||||
// No ghost exists when less than 2 keys are down on the row
|
|
||||||
if (((matrix_row - 1) & matrix_row) == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Ghost occurs when the row shares column line with other row
|
|
||||||
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
|
||||||
if (i != row && (matrix_get_row(i) & matrix_row))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
void keyboard_init(void)
|
|
||||||
{
|
|
||||||
timer_init();
|
|
||||||
matrix_init();
|
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
|
||||||
ps2_mouse_init();
|
|
||||||
#endif
|
|
||||||
#ifdef SERIAL_MOUSE_ENABLE
|
|
||||||
serial_mouse_init();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
|
||||||
bootmagic();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BACKLIGHT_ENABLE
|
|
||||||
backlight_init();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Do keyboard routine jobs: scan mantrix, light LEDs, ...
|
|
||||||
* This is repeatedly called as fast as possible.
|
|
||||||
*/
|
|
||||||
void keyboard_task(void)
|
|
||||||
{
|
|
||||||
static matrix_row_t matrix_prev[MATRIX_ROWS];
|
|
||||||
static uint8_t led_status = 0;
|
|
||||||
matrix_row_t matrix_row = 0;
|
|
||||||
matrix_row_t matrix_change = 0;
|
|
||||||
|
|
||||||
matrix_scan();
|
|
||||||
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
|
|
||||||
matrix_row = matrix_get_row(r);
|
|
||||||
matrix_change = matrix_row ^ matrix_prev[r];
|
|
||||||
if (matrix_change) {
|
|
||||||
if (debug_matrix) matrix_print();
|
|
||||||
#ifdef MATRIX_HAS_GHOST
|
|
||||||
if (has_ghost_in_row(r)) {
|
|
||||||
matrix_prev[r] = matrix_row;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
|
|
||||||
if (matrix_change & ((matrix_row_t)1<<c)) {
|
|
||||||
action_exec((keyevent_t){
|
|
||||||
.key = (keypos_t){ .row = r, .col = c },
|
|
||||||
.pressed = (matrix_row & ((matrix_row_t)1<<c)),
|
|
||||||
.time = (timer_read() | 1) /* time should not be 0 */
|
|
||||||
});
|
|
||||||
// record a processed key
|
|
||||||
matrix_prev[r] ^= ((matrix_row_t)1<<c);
|
|
||||||
// process a key per task call
|
|
||||||
goto MATRIX_LOOP_END;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// call with pseudo tick event when no real key event.
|
|
||||||
action_exec(TICK);
|
|
||||||
|
|
||||||
MATRIX_LOOP_END:
|
|
||||||
|
|
||||||
#ifdef MOUSEKEY_ENABLE
|
|
||||||
// mousekey repeat & acceleration
|
|
||||||
mousekey_task();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PS2_MOUSE_ENABLE
|
|
||||||
ps2_mouse_task();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SERIAL_MOUSE_ENABLE
|
|
||||||
serial_mouse_task();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// update LED
|
|
||||||
if (led_status != host_keyboard_leds()) {
|
|
||||||
led_status = host_keyboard_leds();
|
|
||||||
keyboard_set_leds(led_status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void keyboard_set_leds(uint8_t leds)
|
|
||||||
{
|
|
||||||
if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); }
|
|
||||||
led_set(leds);
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011,2012,2013 Jun Wako <wakojun@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 KEYBOARD_H
|
|
||||||
#define KEYBOARD_H
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* key matrix position */
|
|
||||||
typedef struct {
|
|
||||||
uint8_t col;
|
|
||||||
uint8_t row;
|
|
||||||
} keypos_t;
|
|
||||||
|
|
||||||
/* key event */
|
|
||||||
typedef struct {
|
|
||||||
keypos_t key;
|
|
||||||
bool pressed;
|
|
||||||
uint16_t time;
|
|
||||||
} keyevent_t;
|
|
||||||
|
|
||||||
/* equivalent test of keypos_t */
|
|
||||||
#define KEYEQ(keya, keyb) ((keya).row == (keyb).row && (keya).col == (keyb).col)
|
|
||||||
|
|
||||||
/* Rules for No Event:
|
|
||||||
* 1) (time == 0) to handle (keyevent_t){} as empty event
|
|
||||||
* 2) Matrix(255, 255) to make TICK event available
|
|
||||||
*/
|
|
||||||
static inline bool IS_NOEVENT(keyevent_t event) { return event.time == 0 || (event.key.row == 255 && event.key.col == 255); }
|
|
||||||
static inline bool IS_PRESSED(keyevent_t event) { return (!IS_NOEVENT(event) && event.pressed); }
|
|
||||||
static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && !event.pressed); }
|
|
||||||
|
|
||||||
/* Tick event */
|
|
||||||
#define TICK (keyevent_t){ \
|
|
||||||
.key = (keypos_t){ .row = 255, .col = 255 }, \
|
|
||||||
.pressed = false, \
|
|
||||||
.time = (timer_read() | 1) \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void keyboard_init(void);
|
|
||||||
void keyboard_task(void);
|
|
||||||
void keyboard_set_leds(uint8_t leds);
|
|
||||||
|
|
||||||
__attribute__ ((weak)) void matrix_power_up(void) {}
|
|
||||||
__attribute__ ((weak)) void matrix_power_down(void) {}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,489 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011,2012 Jun Wako <wakojun@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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes
|
|
||||||
* http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
|
|
||||||
*/
|
|
||||||
#ifndef KEYCODE_H
|
|
||||||
#define KEYCODE_H
|
|
||||||
|
|
||||||
|
|
||||||
#define IS_ERROR(code) (KC_ROLL_OVER <= (code) && (code) <= KC_UNDEFINED)
|
|
||||||
#define IS_ANY(code) (KC_A <= (code) && (code) <= 0xFF)
|
|
||||||
#define IS_KEY(code) (KC_A <= (code) && (code) <= KC_EXSEL)
|
|
||||||
#define IS_MOD(code) (KC_LCTRL <= (code) && (code) <= KC_RGUI)
|
|
||||||
|
|
||||||
|
|
||||||
#define IS_SPECIAL(code) ((0xA5 <= (code) && (code) <= 0xDF) || (0xE8 <= (code) && (code) <= 0xFF))
|
|
||||||
#define IS_SYSTEM(code) (KC_PWR <= (code) && (code) <= KC_WAKE)
|
|
||||||
#define IS_CONSUMER(code) (KC_MUTE <= (code) && (code) <= KC_WFAV)
|
|
||||||
#define IS_FN(code) (KC_FN0 <= (code) && (code) <= KC_FN31)
|
|
||||||
#define IS_MOUSEKEY(code) (KC_MS_UP <= (code) && (code) <= KC_MS_ACCEL2)
|
|
||||||
#define IS_MOUSEKEY_MOVE(code) (KC_MS_UP <= (code) && (code) <= KC_MS_RIGHT)
|
|
||||||
#define IS_MOUSEKEY_BUTTON(code) (KC_MS_BTN1 <= (code) && (code) <= KC_MS_BTN5)
|
|
||||||
#define IS_MOUSEKEY_WHEEL(code) (KC_MS_WH_UP <= (code) && (code) <= KC_MS_WH_RIGHT)
|
|
||||||
#define IS_MOUSEKEY_ACCEL(code) (KC_MS_ACCEL0 <= (code) && (code) <= KC_MS_ACCEL2)
|
|
||||||
|
|
||||||
#define MOD_BIT(code) (1<<MOD_INDEX(code))
|
|
||||||
#define MOD_INDEX(code) ((code) & 0x07)
|
|
||||||
#define FN_BIT(code) (1<<FN_INDEX(code))
|
|
||||||
#define FN_INDEX(code) ((code) - KC_FN0)
|
|
||||||
#define FN_MIN KC_FN0
|
|
||||||
#define FN_MAX KC_FN31
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Short names for ease of definition of keymap
|
|
||||||
*/
|
|
||||||
#define KC_LCTL KC_LCTRL
|
|
||||||
#define KC_RCTL KC_RCTRL
|
|
||||||
#define KC_LSFT KC_LSHIFT
|
|
||||||
#define KC_RSFT KC_RSHIFT
|
|
||||||
#define KC_ESC KC_ESCAPE
|
|
||||||
#define KC_BSPC KC_BSPACE
|
|
||||||
#define KC_ENT KC_ENTER
|
|
||||||
#define KC_DEL KC_DELETE
|
|
||||||
#define KC_INS KC_INSERT
|
|
||||||
#define KC_CAPS KC_CAPSLOCK
|
|
||||||
#define KC_CLCK KC_CAPSLOCK
|
|
||||||
#define KC_RGHT KC_RIGHT
|
|
||||||
#define KC_PGDN KC_PGDOWN
|
|
||||||
#define KC_PSCR KC_PSCREEN
|
|
||||||
#define KC_SLCK KC_SCROLLLOCK
|
|
||||||
#define KC_PAUS KC_PAUSE
|
|
||||||
#define KC_BRK KC_PAUSE
|
|
||||||
#define KC_NLCK KC_NUMLOCK
|
|
||||||
#define KC_SPC KC_SPACE
|
|
||||||
#define KC_MINS KC_MINUS
|
|
||||||
#define KC_EQL KC_EQUAL
|
|
||||||
#define KC_GRV KC_GRAVE
|
|
||||||
#define KC_RBRC KC_RBRACKET
|
|
||||||
#define KC_LBRC KC_LBRACKET
|
|
||||||
#define KC_COMM KC_COMMA
|
|
||||||
#define KC_BSLS KC_BSLASH
|
|
||||||
#define KC_SLSH KC_SLASH
|
|
||||||
#define KC_SCLN KC_SCOLON
|
|
||||||
#define KC_QUOT KC_QUOTE
|
|
||||||
#define KC_APP KC_APPLICATION
|
|
||||||
#define KC_NUHS KC_NONUS_HASH
|
|
||||||
#define KC_NUBS KC_NONUS_BSLASH
|
|
||||||
#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_CLR KC_CLEAR
|
|
||||||
/* Japanese specific */
|
|
||||||
#define KC_ZKHK KC_GRAVE
|
|
||||||
#define KC_RO KC_INT1
|
|
||||||
#define KC_KANA KC_INT2
|
|
||||||
#define KC_JYEN KC_INT3
|
|
||||||
#define KC_HENK KC_INT4
|
|
||||||
#define KC_MHEN KC_INT5
|
|
||||||
/* Keypad */
|
|
||||||
#define KC_P1 KC_KP_1
|
|
||||||
#define KC_P2 KC_KP_2
|
|
||||||
#define KC_P3 KC_KP_3
|
|
||||||
#define KC_P4 KC_KP_4
|
|
||||||
#define KC_P5 KC_KP_5
|
|
||||||
#define KC_P6 KC_KP_6
|
|
||||||
#define KC_P7 KC_KP_7
|
|
||||||
#define KC_P8 KC_KP_8
|
|
||||||
#define KC_P9 KC_KP_9
|
|
||||||
#define KC_P0 KC_KP_0
|
|
||||||
#define KC_PDOT KC_KP_DOT
|
|
||||||
#define KC_PCMM KC_KP_COMMA
|
|
||||||
#define KC_PSLS KC_KP_SLASH
|
|
||||||
#define KC_PAST KC_KP_ASTERISK
|
|
||||||
#define KC_PMNS KC_KP_MINUS
|
|
||||||
#define KC_PPLS KC_KP_PLUS
|
|
||||||
#define KC_PEQL KC_KP_EQUAL
|
|
||||||
#define KC_PENT KC_KP_ENTER
|
|
||||||
/* Mousekey */
|
|
||||||
#define KC_MS_U KC_MS_UP
|
|
||||||
#define KC_MS_D KC_MS_DOWN
|
|
||||||
#define KC_MS_L KC_MS_LEFT
|
|
||||||
#define KC_MS_R KC_MS_RIGHT
|
|
||||||
#define KC_BTN1 KC_MS_BTN1
|
|
||||||
#define KC_BTN2 KC_MS_BTN2
|
|
||||||
#define KC_BTN3 KC_MS_BTN3
|
|
||||||
#define KC_BTN4 KC_MS_BTN4
|
|
||||||
#define KC_BTN5 KC_MS_BTN5
|
|
||||||
#define KC_WH_U KC_MS_WH_UP
|
|
||||||
#define KC_WH_D KC_MS_WH_DOWN
|
|
||||||
#define KC_WH_L KC_MS_WH_LEFT
|
|
||||||
#define KC_WH_R KC_MS_WH_RIGHT
|
|
||||||
#define KC_ACL0 KC_MS_ACCEL0
|
|
||||||
#define KC_ACL1 KC_MS_ACCEL1
|
|
||||||
#define KC_ACL2 KC_MS_ACCEL2
|
|
||||||
/* Sytem Control */
|
|
||||||
#define KC_PWR KC_SYSTEM_POWER
|
|
||||||
#define KC_SLEP KC_SYSTEM_SLEEP
|
|
||||||
#define KC_WAKE KC_SYSTEM_WAKE
|
|
||||||
/* Consumer Page */
|
|
||||||
#define KC_MUTE KC_AUDIO_MUTE
|
|
||||||
#define KC_VOLU KC_AUDIO_VOL_UP
|
|
||||||
#define KC_VOLD KC_AUDIO_VOL_DOWN
|
|
||||||
#define KC_MNXT KC_MEDIA_NEXT_TRACK
|
|
||||||
#define KC_MPRV KC_MEDIA_PREV_TRACK
|
|
||||||
#define KC_MFFD KC_MEDIA_FAST_FORWARD
|
|
||||||
#define KC_MRWD KC_MEDIA_REWIND
|
|
||||||
#define KC_MSTP KC_MEDIA_STOP
|
|
||||||
#define KC_MPLY KC_MEDIA_PLAY_PAUSE
|
|
||||||
#define KC_MSEL KC_MEDIA_SELECT
|
|
||||||
#define KC_EJCT KC_MEDIA_EJECT
|
|
||||||
#define KC_MAIL KC_MAIL
|
|
||||||
#define KC_CALC KC_CALCULATOR
|
|
||||||
#define KC_MYCM KC_MY_COMPUTER
|
|
||||||
#define KC_WSCH KC_WWW_SEARCH
|
|
||||||
#define KC_WHOM KC_WWW_HOME
|
|
||||||
#define KC_WBAK KC_WWW_BACK
|
|
||||||
#define KC_WFWD KC_WWW_FORWARD
|
|
||||||
#define KC_WSTP KC_WWW_STOP
|
|
||||||
#define KC_WREF KC_WWW_REFRESH
|
|
||||||
#define KC_WFAV KC_WWW_FAVORITES
|
|
||||||
/* Transparent */
|
|
||||||
#define KC_TRANSPARENT 1
|
|
||||||
#define KC_TRNS KC_TRANSPARENT
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USB HID Keyboard/Keypad Usage(0x07) */
|
|
||||||
enum hid_keyboard_keypad_usage {
|
|
||||||
KC_NO = 0x00,
|
|
||||||
KC_ROLL_OVER,
|
|
||||||
KC_POST_FAIL,
|
|
||||||
KC_UNDEFINED,
|
|
||||||
KC_A,
|
|
||||||
KC_B,
|
|
||||||
KC_C,
|
|
||||||
KC_D,
|
|
||||||
KC_E,
|
|
||||||
KC_F,
|
|
||||||
KC_G,
|
|
||||||
KC_H,
|
|
||||||
KC_I,
|
|
||||||
KC_J,
|
|
||||||
KC_K,
|
|
||||||
KC_L,
|
|
||||||
KC_M, /* 0x10 */
|
|
||||||
KC_N,
|
|
||||||
KC_O,
|
|
||||||
KC_P,
|
|
||||||
KC_Q,
|
|
||||||
KC_R,
|
|
||||||
KC_S,
|
|
||||||
KC_T,
|
|
||||||
KC_U,
|
|
||||||
KC_V,
|
|
||||||
KC_W,
|
|
||||||
KC_X,
|
|
||||||
KC_Y,
|
|
||||||
KC_Z,
|
|
||||||
KC_1,
|
|
||||||
KC_2,
|
|
||||||
KC_3, /* 0x20 */
|
|
||||||
KC_4,
|
|
||||||
KC_5,
|
|
||||||
KC_6,
|
|
||||||
KC_7,
|
|
||||||
KC_8,
|
|
||||||
KC_9,
|
|
||||||
KC_0,
|
|
||||||
KC_ENTER,
|
|
||||||
KC_ESCAPE,
|
|
||||||
KC_BSPACE,
|
|
||||||
KC_TAB,
|
|
||||||
KC_SPACE,
|
|
||||||
KC_MINUS,
|
|
||||||
KC_EQUAL,
|
|
||||||
KC_LBRACKET,
|
|
||||||
KC_RBRACKET, /* 0x30 */
|
|
||||||
KC_BSLASH, /* \ (and |) */
|
|
||||||
KC_NONUS_HASH, /* Non-US # and ~ */
|
|
||||||
KC_SCOLON, /* ; (and :) */
|
|
||||||
KC_QUOTE, /* ' and " */
|
|
||||||
KC_GRAVE, /* Grave accent and tilde */
|
|
||||||
KC_COMMA, /* , and < */
|
|
||||||
KC_DOT, /* . and > */
|
|
||||||
KC_SLASH, /* / and ? */
|
|
||||||
KC_CAPSLOCK,
|
|
||||||
KC_F1,
|
|
||||||
KC_F2,
|
|
||||||
KC_F3,
|
|
||||||
KC_F4,
|
|
||||||
KC_F5,
|
|
||||||
KC_F6,
|
|
||||||
KC_F7, /* 0x40 */
|
|
||||||
KC_F8,
|
|
||||||
KC_F9,
|
|
||||||
KC_F10,
|
|
||||||
KC_F11,
|
|
||||||
KC_F12,
|
|
||||||
KC_PSCREEN,
|
|
||||||
KC_SCROLLLOCK,
|
|
||||||
KC_PAUSE,
|
|
||||||
KC_INSERT,
|
|
||||||
KC_HOME,
|
|
||||||
KC_PGUP,
|
|
||||||
KC_DELETE,
|
|
||||||
KC_END,
|
|
||||||
KC_PGDOWN,
|
|
||||||
KC_RIGHT,
|
|
||||||
KC_LEFT, /* 0x50 */
|
|
||||||
KC_DOWN,
|
|
||||||
KC_UP,
|
|
||||||
KC_NUMLOCK,
|
|
||||||
KC_KP_SLASH,
|
|
||||||
KC_KP_ASTERISK,
|
|
||||||
KC_KP_MINUS,
|
|
||||||
KC_KP_PLUS,
|
|
||||||
KC_KP_ENTER,
|
|
||||||
KC_KP_1,
|
|
||||||
KC_KP_2,
|
|
||||||
KC_KP_3,
|
|
||||||
KC_KP_4,
|
|
||||||
KC_KP_5,
|
|
||||||
KC_KP_6,
|
|
||||||
KC_KP_7,
|
|
||||||
KC_KP_8, /* 0x60 */
|
|
||||||
KC_KP_9,
|
|
||||||
KC_KP_0,
|
|
||||||
KC_KP_DOT,
|
|
||||||
KC_NONUS_BSLASH, /* Non-US \ and | */
|
|
||||||
KC_APPLICATION,
|
|
||||||
KC_POWER,
|
|
||||||
KC_KP_EQUAL,
|
|
||||||
KC_F13,
|
|
||||||
KC_F14,
|
|
||||||
KC_F15,
|
|
||||||
KC_F16,
|
|
||||||
KC_F17,
|
|
||||||
KC_F18,
|
|
||||||
KC_F19,
|
|
||||||
KC_F20,
|
|
||||||
KC_F21, /* 0x70 */
|
|
||||||
KC_F22,
|
|
||||||
KC_F23,
|
|
||||||
KC_F24,
|
|
||||||
KC_EXECUTE,
|
|
||||||
KC_HELP,
|
|
||||||
KC_MENU,
|
|
||||||
KC_SELECT,
|
|
||||||
KC_STOP,
|
|
||||||
KC_AGAIN,
|
|
||||||
KC_UNDO,
|
|
||||||
KC_CUT,
|
|
||||||
KC_COPY,
|
|
||||||
KC_PASTE,
|
|
||||||
KC_FIND,
|
|
||||||
KC__MUTE,
|
|
||||||
KC__VOLUP, /* 0x80 */
|
|
||||||
KC__VOLDOWN,
|
|
||||||
KC_LOCKING_CAPS, /* locking Caps Lock */
|
|
||||||
KC_LOCKING_NUM, /* locking Num Lock */
|
|
||||||
KC_LOCKING_SCROLL, /* locking Scroll Lock */
|
|
||||||
KC_KP_COMMA,
|
|
||||||
KC_KP_EQUAL_AS400, /* equal sign on AS/400 */
|
|
||||||
KC_INT1,
|
|
||||||
KC_INT2,
|
|
||||||
KC_INT3,
|
|
||||||
KC_INT4,
|
|
||||||
KC_INT5,
|
|
||||||
KC_INT6,
|
|
||||||
KC_INT7,
|
|
||||||
KC_INT8,
|
|
||||||
KC_INT9,
|
|
||||||
KC_LANG1, /* 0x90 */
|
|
||||||
KC_LANG2,
|
|
||||||
KC_LANG3,
|
|
||||||
KC_LANG4,
|
|
||||||
KC_LANG5,
|
|
||||||
KC_LANG6,
|
|
||||||
KC_LANG7,
|
|
||||||
KC_LANG8,
|
|
||||||
KC_LANG9,
|
|
||||||
KC_ALT_ERASE,
|
|
||||||
KC_SYSREQ,
|
|
||||||
KC_CANCEL,
|
|
||||||
KC_CLEAR,
|
|
||||||
KC_PRIOR,
|
|
||||||
KC_RETURN,
|
|
||||||
KC_SEPARATOR,
|
|
||||||
KC_OUT, /* 0xA0 */
|
|
||||||
KC_OPER,
|
|
||||||
KC_CLEAR_AGAIN,
|
|
||||||
KC_CRSEL,
|
|
||||||
KC_EXSEL, /* 0xA4 */
|
|
||||||
|
|
||||||
/* NOTE: 0xA5-DF are used for internal special purpose */
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* NOTE: Following codes(0xB0-DD) are not used. Leave them for reference. */
|
|
||||||
KC_KP_00 = 0xB0,
|
|
||||||
KC_KP_000,
|
|
||||||
KC_THOUSANDS_SEPARATOR,
|
|
||||||
KC_DECIMAL_SEPARATOR,
|
|
||||||
KC_CURRENCY_UNIT,
|
|
||||||
KC_CURRENCY_SUB_UNIT,
|
|
||||||
KC_KP_LPAREN,
|
|
||||||
KC_KP_RPAREN,
|
|
||||||
KC_KP_LCBRACKET, /* { */
|
|
||||||
KC_KP_RCBRACKET, /* } */
|
|
||||||
KC_KP_TAB,
|
|
||||||
KC_KP_BSPACE,
|
|
||||||
KC_KP_A,
|
|
||||||
KC_KP_B,
|
|
||||||
KC_KP_C,
|
|
||||||
KC_KP_D,
|
|
||||||
KC_KP_E, /* 0xC0 */
|
|
||||||
KC_KP_F,
|
|
||||||
KC_KP_XOR,
|
|
||||||
KC_KP_HAT,
|
|
||||||
KC_KP_PERC,
|
|
||||||
KC_KP_LT,
|
|
||||||
KC_KP_GT,
|
|
||||||
KC_KP_AND,
|
|
||||||
KC_KP_LAZYAND,
|
|
||||||
KC_KP_OR,
|
|
||||||
KC_KP_LAZYOR,
|
|
||||||
KC_KP_COLON,
|
|
||||||
KC_KP_HASH,
|
|
||||||
KC_KP_SPACE,
|
|
||||||
KC_KP_ATMARK,
|
|
||||||
KC_KP_EXCLAMATION,
|
|
||||||
KC_KP_MEM_STORE, /* 0xD0 */
|
|
||||||
KC_KP_MEM_RECALL,
|
|
||||||
KC_KP_MEM_CLEAR,
|
|
||||||
KC_KP_MEM_ADD,
|
|
||||||
KC_KP_MEM_SUB,
|
|
||||||
KC_KP_MEM_MUL,
|
|
||||||
KC_KP_MEM_DIV,
|
|
||||||
KC_KP_PLUS_MINUS,
|
|
||||||
KC_KP_CLEAR,
|
|
||||||
KC_KP_CLEAR_ENTRY,
|
|
||||||
KC_KP_BINARY,
|
|
||||||
KC_KP_OCTAL,
|
|
||||||
KC_KP_DECIMAL,
|
|
||||||
KC_KP_HEXADECIMAL, /* 0xDD */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Modifiers */
|
|
||||||
KC_LCTRL = 0xE0,
|
|
||||||
KC_LSHIFT,
|
|
||||||
KC_LALT,
|
|
||||||
KC_LGUI,
|
|
||||||
KC_RCTRL,
|
|
||||||
KC_RSHIFT,
|
|
||||||
KC_RALT,
|
|
||||||
KC_RGUI,
|
|
||||||
|
|
||||||
/* NOTE: 0xE8-FF are used for internal special purpose */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Special keycodes */
|
|
||||||
/* NOTE: 0xA5-DF and 0xE8-FF are used for internal special purpose */
|
|
||||||
enum internal_special_keycodes {
|
|
||||||
/* System Control */
|
|
||||||
KC_SYSTEM_POWER = 0xA5,
|
|
||||||
KC_SYSTEM_SLEEP,
|
|
||||||
KC_SYSTEM_WAKE,
|
|
||||||
|
|
||||||
/* Media Control */
|
|
||||||
KC_AUDIO_MUTE,
|
|
||||||
KC_AUDIO_VOL_UP,
|
|
||||||
KC_AUDIO_VOL_DOWN,
|
|
||||||
KC_MEDIA_NEXT_TRACK,
|
|
||||||
KC_MEDIA_PREV_TRACK,
|
|
||||||
KC_MEDIA_STOP,
|
|
||||||
KC_MEDIA_PLAY_PAUSE,
|
|
||||||
KC_MEDIA_SELECT,
|
|
||||||
KC_MEDIA_EJECT,
|
|
||||||
KC_MAIL,
|
|
||||||
KC_CALCULATOR,
|
|
||||||
KC_MY_COMPUTER,
|
|
||||||
KC_WWW_SEARCH,
|
|
||||||
KC_WWW_HOME,
|
|
||||||
KC_WWW_BACK,
|
|
||||||
KC_WWW_FORWARD,
|
|
||||||
KC_WWW_STOP,
|
|
||||||
KC_WWW_REFRESH,
|
|
||||||
KC_WWW_FAVORITES,
|
|
||||||
KC_MEDIA_FAST_FORWARD,
|
|
||||||
KC_MEDIA_REWIND, /* 0xBC */
|
|
||||||
|
|
||||||
/* Fn key */
|
|
||||||
KC_FN0 = 0xC0,
|
|
||||||
KC_FN1,
|
|
||||||
KC_FN2,
|
|
||||||
KC_FN3,
|
|
||||||
KC_FN4,
|
|
||||||
KC_FN5,
|
|
||||||
KC_FN6,
|
|
||||||
KC_FN7,
|
|
||||||
KC_FN8,
|
|
||||||
KC_FN9,
|
|
||||||
KC_FN10,
|
|
||||||
KC_FN11,
|
|
||||||
KC_FN12,
|
|
||||||
KC_FN13,
|
|
||||||
KC_FN14,
|
|
||||||
KC_FN15,
|
|
||||||
|
|
||||||
KC_FN16 = 0xD0,
|
|
||||||
KC_FN17,
|
|
||||||
KC_FN18,
|
|
||||||
KC_FN19,
|
|
||||||
KC_FN20,
|
|
||||||
KC_FN21,
|
|
||||||
KC_FN22,
|
|
||||||
KC_FN23,
|
|
||||||
KC_FN24,
|
|
||||||
KC_FN25,
|
|
||||||
KC_FN26,
|
|
||||||
KC_FN27,
|
|
||||||
KC_FN28,
|
|
||||||
KC_FN29,
|
|
||||||
KC_FN30,
|
|
||||||
KC_FN31, /* 0xDF */
|
|
||||||
|
|
||||||
/**************************************/
|
|
||||||
/* 0xE0-E7 for Modifiers. DO NOT USE. */
|
|
||||||
/**************************************/
|
|
||||||
|
|
||||||
/* Mousekey */
|
|
||||||
KC_MS_UP = 0xF0,
|
|
||||||
KC_MS_DOWN,
|
|
||||||
KC_MS_LEFT,
|
|
||||||
KC_MS_RIGHT,
|
|
||||||
KC_MS_BTN1,
|
|
||||||
KC_MS_BTN2,
|
|
||||||
KC_MS_BTN3,
|
|
||||||
KC_MS_BTN4,
|
|
||||||
KC_MS_BTN5, /* 0xF8 */
|
|
||||||
/* Mousekey wheel */
|
|
||||||
KC_MS_WH_UP,
|
|
||||||
KC_MS_WH_DOWN,
|
|
||||||
KC_MS_WH_LEFT,
|
|
||||||
KC_MS_WH_RIGHT, /* 0xFC */
|
|
||||||
/* Mousekey accel */
|
|
||||||
KC_MS_ACCEL0,
|
|
||||||
KC_MS_ACCEL1,
|
|
||||||
KC_MS_ACCEL2 /* 0xFF */
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* KEYCODE_H */
|
|
@ -1,184 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2013 Jun Wako <wakojun@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 "keymap.h"
|
|
||||||
#include "report.h"
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "action_layer.h"
|
|
||||||
#include "action.h"
|
|
||||||
#include "action_macro.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
|
|
||||||
static action_t keycode_to_action(uint8_t keycode);
|
|
||||||
|
|
||||||
|
|
||||||
/* converts key to action */
|
|
||||||
__attribute__ ((weak))
|
|
||||||
action_t action_for_key(uint8_t layer, keypos_t key)
|
|
||||||
{
|
|
||||||
uint8_t keycode = keymap_key_to_keycode(layer, key);
|
|
||||||
switch (keycode) {
|
|
||||||
case KC_FN0 ... KC_FN31:
|
|
||||||
return keymap_fn_to_action(keycode);
|
|
||||||
#ifdef BOOTMAGIC_ENABLE
|
|
||||||
case KC_CAPSLOCK:
|
|
||||||
case KC_LOCKING_CAPS:
|
|
||||||
if (keymap_config.swap_control_capslock || keymap_config.capslock_to_control) {
|
|
||||||
return keycode_to_action(KC_LCTL);
|
|
||||||
}
|
|
||||||
return keycode_to_action(keycode);
|
|
||||||
case KC_LCTL:
|
|
||||||
if (keymap_config.swap_control_capslock) {
|
|
||||||
return keycode_to_action(KC_CAPSLOCK);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_LCTL);
|
|
||||||
case KC_LALT:
|
|
||||||
if (keymap_config.swap_lalt_lgui) {
|
|
||||||
if (keymap_config.no_gui) {
|
|
||||||
return keycode_to_action(ACTION_NO);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_LGUI);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_LALT);
|
|
||||||
case KC_LGUI:
|
|
||||||
if (keymap_config.swap_lalt_lgui) {
|
|
||||||
return keycode_to_action(KC_LALT);
|
|
||||||
}
|
|
||||||
if (keymap_config.no_gui) {
|
|
||||||
return keycode_to_action(ACTION_NO);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_LGUI);
|
|
||||||
case KC_RALT:
|
|
||||||
if (keymap_config.swap_ralt_rgui) {
|
|
||||||
if (keymap_config.no_gui) {
|
|
||||||
return keycode_to_action(ACTION_NO);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_RGUI);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_RALT);
|
|
||||||
case KC_RGUI:
|
|
||||||
if (keymap_config.swap_ralt_rgui) {
|
|
||||||
return keycode_to_action(KC_RALT);
|
|
||||||
}
|
|
||||||
if (keymap_config.no_gui) {
|
|
||||||
return keycode_to_action(ACTION_NO);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_RGUI);
|
|
||||||
case KC_GRAVE:
|
|
||||||
if (keymap_config.swap_grave_esc) {
|
|
||||||
return keycode_to_action(KC_ESC);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_GRAVE);
|
|
||||||
case KC_ESC:
|
|
||||||
if (keymap_config.swap_grave_esc) {
|
|
||||||
return keycode_to_action(KC_GRAVE);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_ESC);
|
|
||||||
case KC_BSLASH:
|
|
||||||
if (keymap_config.swap_backslash_backspace) {
|
|
||||||
return keycode_to_action(KC_BSPACE);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_BSLASH);
|
|
||||||
case KC_BSPACE:
|
|
||||||
if (keymap_config.swap_backslash_backspace) {
|
|
||||||
return keycode_to_action(KC_BSLASH);
|
|
||||||
}
|
|
||||||
return keycode_to_action(KC_BSPACE);
|
|
||||||
#endif
|
|
||||||
default:
|
|
||||||
return keycode_to_action(keycode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Macro */
|
|
||||||
__attribute__ ((weak))
|
|
||||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|
||||||
{
|
|
||||||
return MACRO_NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Function */
|
|
||||||
__attribute__ ((weak))
|
|
||||||
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/* translates keycode to action */
|
|
||||||
static action_t keycode_to_action(uint8_t keycode)
|
|
||||||
{
|
|
||||||
action_t action;
|
|
||||||
switch (keycode) {
|
|
||||||
case KC_A ... KC_EXSEL:
|
|
||||||
case KC_LCTRL ... KC_RGUI:
|
|
||||||
action.code = ACTION_KEY(keycode);
|
|
||||||
break;
|
|
||||||
case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
|
|
||||||
action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
|
|
||||||
break;
|
|
||||||
case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
|
|
||||||
action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode));
|
|
||||||
break;
|
|
||||||
case KC_MS_UP ... KC_MS_ACCEL2:
|
|
||||||
action.code = ACTION_MOUSEKEY(keycode);
|
|
||||||
break;
|
|
||||||
case KC_TRNS:
|
|
||||||
action.code = ACTION_TRANSPARENT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
action.code = ACTION_NO;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_LEGACY_KEYMAP
|
|
||||||
/*
|
|
||||||
* Legacy keymap support
|
|
||||||
* Consider using new keymap API instead.
|
|
||||||
*/
|
|
||||||
__attribute__ ((weak))
|
|
||||||
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
|
||||||
{
|
|
||||||
return keymap_get_keycode(layer, key.row, key.col);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Legacy keymap support */
|
|
||||||
__attribute__ ((weak))
|
|
||||||
action_t keymap_fn_to_action(uint8_t keycode)
|
|
||||||
{
|
|
||||||
action_t action = { .code = ACTION_NO };
|
|
||||||
switch (keycode) {
|
|
||||||
case KC_FN0 ... KC_FN31:
|
|
||||||
{
|
|
||||||
uint8_t layer = keymap_fn_layer(FN_INDEX(keycode));
|
|
||||||
uint8_t key = keymap_fn_keycode(FN_INDEX(keycode));
|
|
||||||
if (key) {
|
|
||||||
action.code = ACTION_LAYER_TAP_KEY(layer, key);
|
|
||||||
} else {
|
|
||||||
action.code = ACTION_LAYER_MOMENTARY(layer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return action;
|
|
||||||
default:
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011 Jun Wako <wakojun@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_H
|
|
||||||
#define LED_H
|
|
||||||
#include "stdint.h"
|
|
||||||
|
|
||||||
|
|
||||||
/* keyboard LEDs */
|
|
||||||
#define USB_LED_NUM_LOCK 0
|
|
||||||
#define USB_LED_CAPS_LOCK 1
|
|
||||||
#define USB_LED_SCROLL_LOCK 2
|
|
||||||
#define USB_LED_COMPOSE 3
|
|
||||||
#define USB_LED_KANA 4
|
|
||||||
#define USB_LED_FUNCTION 5
|
|
||||||
|
|
||||||
|
|
||||||
void led_set(uint8_t usb_led);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2011 Jun Wako <wakojun@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 MATRIX_H
|
|
||||||
#define MATRIX_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if (MATRIX_COLS <= 8)
|
|
||||||
typedef uint8_t matrix_row_t;
|
|
||||||
#elif (MATRIX_COLS <= 16)
|
|
||||||
typedef uint16_t matrix_row_t;
|
|
||||||
#elif (MATRIX_COLS <= 32)
|
|
||||||
typedef uint32_t matrix_row_t;
|
|
||||||
#else
|
|
||||||
#error "MATRIX_COLS: invalid value"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<<col))
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* number of matrix rows */
|
|
||||||
uint8_t matrix_rows(void);
|
|
||||||
/* number of matrix columns */
|
|
||||||
uint8_t matrix_cols(void);
|
|
||||||
/* intialize matrix for scaning. should be called once. */
|
|
||||||
void matrix_init(void);
|
|
||||||
/* scan all key states on matrix */
|
|
||||||
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 */
|
|
||||||
bool matrix_is_on(uint8_t row, uint8_t col);
|
|
||||||
/* matrix state on row */
|
|
||||||
matrix_row_t matrix_get_row(uint8_t row);
|
|
||||||
/* print matrix for debug */
|
|
||||||
void matrix_print(void);
|
|
||||||
|
|
||||||
|
|
||||||
/* power control */
|
|
||||||
void matrix_power_up(void);
|
|
||||||
void matrix_power_down(void);
|
|
||||||
|
|
||||||
void *matrix_init_kb(void);
|
|
||||||
void *matrix_scan_kb(void);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -0,0 +1,17 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
KEYMAP_50(
|
||||||
|
F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, \
|
||||||
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 0, \
|
||||||
|
Q, W, E, R, T, Y, U, I, O, P, \
|
||||||
|
A, S, D, F, G, H, J, K, L, SCLN, \
|
||||||
|
Z, X, C, V, B, N, M, COMM,DOT, SLSH \
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* Layer 0:
|
||||||
|
* ,---------------------------------------------------------------. ,-----------. ,---------------.
|
||||||
|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|BS |BS |F21| |PSC|SLK|PAU| |F1 |F2 |F3 |F4 |
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|F22| |Ins|Hom|PgU| |F5 |F6 |F7 |F8 |
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Ret|Ret |F23| |Del|End|PgD| |F9 |F10|F11|F12|
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shf|Shift |F24| | |Up | | |F13|F14|F15|F16|
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Fn0 |Gui|Alt | Space |Alt* |Gui|Fn0 | |Lef|Dow|Rig| |F17|F18|F19|F20|
|
||||||
|
* `---------------------------------------------------------------' `-----------' `---------------'
|
||||||
|
*/
|
||||||
|
KEYMAP_ALPS102(
|
||||||
|
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,BSPC,F21, PSCR,SLCK,PAUS, F1, F2, F3, F4, \
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, F22, INS, HOME,PGUP, F5, F6, F7, F8, \
|
||||||
|
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, F23, DEL, END, PGDN, F9, F10, F11, F12, \
|
||||||
|
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,RSFT, F24, NO, UP, NO, F13, F14, F15, F16, \
|
||||||
|
FN0, LGUI,LALT, SPC, RALT,RGUI, FN0, LEFT,DOWN,RGHT, F17, F18, F19, F20 \
|
||||||
|
),
|
||||||
|
|
||||||
|
/* Layer 1:
|
||||||
|
* ,---------------------------------------------------------------. ,-----------. ,---------------.
|
||||||
|
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|BS |BS |F21| |VoD|VoU|Mut| |F1 |F2 |F3 |F4 |
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|F22| |Ins|Hom|PgU| |F5 |F6 |F7 |F8 |
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Ret|Ret |F23| |Del|End|PgD| |F9 |F10|F11|F12|
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shf|Shift |F24| | |PgU| | |F13|F14|F15|F16|
|
||||||
|
* |---------------------------------------------------------------| |-----------| |---------------|
|
||||||
|
* |Fn0 |Gui|Alt | Space |Alt* |Gui|Fn0 | |Hom|PgD|End| |F17|F18|F19|F20|
|
||||||
|
* `---------------------------------------------------------------' `-----------' `---------------'
|
||||||
|
*/
|
||||||
|
KEYMAP_ALPS102(
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, VOLD,VOLU,MUTE, TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,PGUP,TRNS, TRNS,TRNS,TRNS,TRNS, \
|
||||||
|
TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, TRNS, HOME,PGDN,END, TRNS,TRNS,TRNS,TRNS \
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
[0] = ACTION_LAYER_MOMENTARY(1),
|
||||||
|
};
|
@ -1,73 +0,0 @@
|
|||||||
# Target file name (without extension).
|
|
||||||
TARGET = m0110_pjrc
|
|
||||||
|
|
||||||
# Directory common source filess exist
|
|
||||||
TOP_DIR = ../..
|
|
||||||
|
|
||||||
# Directory keyboard dependent files exist
|
|
||||||
TARGET_DIR = .
|
|
||||||
|
|
||||||
# keyboard dependent files
|
|
||||||
SRC = matrix.c \
|
|
||||||
led.c \
|
|
||||||
m0110.c
|
|
||||||
|
|
||||||
# To use own keymap file run make like: make keymap=hasu
|
|
||||||
ifdef keymap
|
|
||||||
SRC += keymap_$(keymap).c
|
|
||||||
else
|
|
||||||
SRC += keymap.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
CONFIG_H = config.h
|
|
||||||
|
|
||||||
|
|
||||||
# MCU name, you MUST set this to match the board you are using
|
|
||||||
# type "make clean" after changing this, so all files will be rebuilt
|
|
||||||
#MCU = at90usb162 # Teensy 1.0
|
|
||||||
MCU = atmega32u4 # Teensy 2.0
|
|
||||||
#MCU = at90usb646 # Teensy++ 1.0
|
|
||||||
#MCU = at90usb1286 # Teensy++ 2.0
|
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
|
||||||
# Normally the first thing your program should do is set the clock prescaler,
|
|
||||||
# so your program will run at the correct speed. You should also set this
|
|
||||||
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
|
||||||
# examples use this variable to calculate timings. Do not add a "UL" here.
|
|
||||||
F_CPU = 16000000
|
|
||||||
|
|
||||||
|
|
||||||
# Boot Section Size in bytes
|
|
||||||
# Teensy halfKay 512
|
|
||||||
# Atmel DFU loader 4096
|
|
||||||
# LUFA bootloader 4096
|
|
||||||
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
|
||||||
|
|
||||||
|
|
||||||
# Build Options
|
|
||||||
# *Comment out* to disable the options.
|
|
||||||
#
|
|
||||||
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
|
||||||
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
|
||||||
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
|
||||||
CONSOLE_ENABLE = yes # Console for debug(+400)
|
|
||||||
COMMAND_ENABLE = yes # Commands for debug and configuration
|
|
||||||
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
|
||||||
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#---------------- Programming Options --------------------------
|
|
||||||
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
|
||||||
|
|
||||||
|
|
||||||
# Search Path
|
|
||||||
VPATH += $(TARGET_DIR)
|
|
||||||
VPATH += $(TOP_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
include $(TOP_DIR)/protocol/pjrc.mk
|
|
||||||
include $(TOP_DIR)/protocol.mk
|
|
||||||
include $(TOP_DIR)/common.mk
|
|
||||||
include $(TOP_DIR)/rules.mk
|
|
@ -0,0 +1,96 @@
|
|||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = m0110_lufa
|
||||||
|
|
||||||
|
# Directory common source filess exist
|
||||||
|
TMK_DIR = ../../tmk_core
|
||||||
|
|
||||||
|
# Directory keyboard dependent files exist
|
||||||
|
TARGET_DIR = .
|
||||||
|
|
||||||
|
# keyboard dependent files
|
||||||
|
SRC = matrix.c \
|
||||||
|
led.c \
|
||||||
|
keymap_common.c \
|
||||||
|
m0110.c
|
||||||
|
|
||||||
|
# To use own keymap file run make like: make keymap=hasu
|
||||||
|
ifdef KEYMAP
|
||||||
|
SRC += keymap_$(KEYMAP).c
|
||||||
|
else
|
||||||
|
SRC += keymap_default.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
CONFIG_H = config.h
|
||||||
|
|
||||||
|
|
||||||
|
# MCU name, you MUST set this to match the board you are using
|
||||||
|
# type "make clean" after changing this, so all files will be rebuilt
|
||||||
|
#MCU = atmega32u2 # TMK converter rev2
|
||||||
|
MCU = atmega32u4 # TMK converter rev1
|
||||||
|
|
||||||
|
|
||||||
|
# Processor frequency.
|
||||||
|
# Normally the first thing your program should do is set the clock prescaler,
|
||||||
|
# so your program will run at the correct speed. You should also set this
|
||||||
|
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||||
|
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||||
|
F_CPU = 16000000
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# LUFA specific
|
||||||
|
#
|
||||||
|
# Target architecture (see library "Board Types" documentation).
|
||||||
|
ARCH = AVR8
|
||||||
|
|
||||||
|
# Input clock frequency.
|
||||||
|
# This will define a symbol, F_USB, in all source code files equal to the
|
||||||
|
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||||
|
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||||
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||||
|
# at the end, this will be done automatically to create a 32-bit value in your
|
||||||
|
# source code.
|
||||||
|
#
|
||||||
|
# If no clock division is performed on the input clock inside the AVR (via the
|
||||||
|
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||||
|
F_USB = $(F_CPU)
|
||||||
|
|
||||||
|
# Interrupt driven control endpoint task
|
||||||
|
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||||
|
|
||||||
|
|
||||||
|
# Boot Section Size in bytes
|
||||||
|
# Teensy halfKay 512
|
||||||
|
# Atmel DFU loader 4096
|
||||||
|
# LUFA bootloader 4096
|
||||||
|
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||||
|
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# *Comment out* to disable the options.
|
||||||
|
#
|
||||||
|
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
|
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||||
|
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------- Programming Options --------------------------
|
||||||
|
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
||||||
|
|
||||||
|
|
||||||
|
# Search Path
|
||||||
|
VPATH += $(TARGET_DIR)
|
||||||
|
VPATH += $(TMK_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TMK_DIR)/protocol/lufa.mk
|
||||||
|
include $(TMK_DIR)/protocol.mk
|
||||||
|
include $(TMK_DIR)/common.mk
|
||||||
|
include $(TMK_DIR)/rules.mk
|
@ -0,0 +1,96 @@
|
|||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = m0110_lufa
|
||||||
|
|
||||||
|
# Directory common source filess exist
|
||||||
|
TMK_DIR = ../../tmk_core
|
||||||
|
|
||||||
|
# Directory keyboard dependent files exist
|
||||||
|
TARGET_DIR = .
|
||||||
|
|
||||||
|
# keyboard dependent files
|
||||||
|
SRC = matrix.c \
|
||||||
|
led.c \
|
||||||
|
keymap_common.c \
|
||||||
|
m0110.c
|
||||||
|
|
||||||
|
# To use own keymap file run make like: make keymap=hasu
|
||||||
|
ifdef KEYMAP
|
||||||
|
SRC += keymap_$(KEYMAP).c
|
||||||
|
else
|
||||||
|
SRC += keymap_default.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
CONFIG_H = config.h
|
||||||
|
|
||||||
|
|
||||||
|
# MCU name, you MUST set this to match the board you are using
|
||||||
|
# type "make clean" after changing this, so all files will be rebuilt
|
||||||
|
MCU = atmega32u2 # TMK converter rev2
|
||||||
|
#MCU = atmega32u4 # TMK converter rev1
|
||||||
|
|
||||||
|
|
||||||
|
# Processor frequency.
|
||||||
|
# Normally the first thing your program should do is set the clock prescaler,
|
||||||
|
# so your program will run at the correct speed. You should also set this
|
||||||
|
# variable to same clock speed. The _delay_ms() macro uses this, and many
|
||||||
|
# examples use this variable to calculate timings. Do not add a "UL" here.
|
||||||
|
F_CPU = 16000000
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# LUFA specific
|
||||||
|
#
|
||||||
|
# Target architecture (see library "Board Types" documentation).
|
||||||
|
ARCH = AVR8
|
||||||
|
|
||||||
|
# Input clock frequency.
|
||||||
|
# This will define a symbol, F_USB, in all source code files equal to the
|
||||||
|
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||||
|
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||||
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||||
|
# at the end, this will be done automatically to create a 32-bit value in your
|
||||||
|
# source code.
|
||||||
|
#
|
||||||
|
# If no clock division is performed on the input clock inside the AVR (via the
|
||||||
|
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||||
|
F_USB = $(F_CPU)
|
||||||
|
|
||||||
|
# Interrupt driven control endpoint task
|
||||||
|
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||||
|
|
||||||
|
|
||||||
|
# Boot Section Size in bytes
|
||||||
|
# Teensy halfKay 512
|
||||||
|
# Atmel DFU loader 4096
|
||||||
|
# LUFA bootloader 4096
|
||||||
|
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||||
|
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# *Comment out* to disable the options.
|
||||||
|
#
|
||||||
|
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
|
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||||
|
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#---------------- Programming Options --------------------------
|
||||||
|
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
|
||||||
|
|
||||||
|
|
||||||
|
# Search Path
|
||||||
|
VPATH += $(TARGET_DIR)
|
||||||
|
VPATH += $(TMK_DIR)
|
||||||
|
|
||||||
|
|
||||||
|
include $(TMK_DIR)/protocol/lufa.mk
|
||||||
|
include $(TMK_DIR)/protocol.mk
|
||||||
|
include $(TMK_DIR)/common.mk
|
||||||
|
include $(TMK_DIR)/rules.mk
|
@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 Jun Wako <wakojun@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 <stdint.h>
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "keymap_common.h"
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef KEYMAP_SECTION_ENABLE
|
|
||||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
|
|
||||||
#else
|
|
||||||
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
|
|
||||||
#endif
|
|
||||||
/* Default:
|
|
||||||
* ,---------------------------------------------------------. ,---------------.
|
|
||||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| =| /| *|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
|
|
||||||
* |-----------------------------------------------------' | |---------------|
|
|
||||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | | 4| 5| 6| +|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
|
|
||||||
* |---------------------------------------------------------| |-----------|Ent|
|
|
||||||
* |Ctl |Gui | Space |Alt| \|Lft|Rgt|Dn | | 0| .| |
|
|
||||||
* `---------------------------------------------------------' `---------------'
|
|
||||||
*/
|
|
||||||
[0] = KEYMAP(
|
|
||||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, CLR, EQL, PSLS,PAST,
|
|
||||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS,
|
|
||||||
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, FN15, P4, P5, P6, PPLS,
|
|
||||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT,
|
|
||||||
LCTL,LGUI, FN16, LALT,FN31,LEFT,RGHT,DOWN, P0, PDOT
|
|
||||||
),
|
|
||||||
/* Cursor Layer(WASD, IJKL)
|
|
||||||
* ,---------------------------------------------------------. ,---------------.
|
|
||||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |Ins| | | 7| 8| 9| -|
|
|
||||||
* |-----------------------------------------------------' | |---------------|
|
|
||||||
* |Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| +|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Shift |End| |PgD| | | | |End|PgD|Dow|Shif|PgU| | 1| 2| 3| |
|
|
||||||
* |---------------------------------------------------------| |-----------|Ent|
|
|
||||||
* |Ctl |Gui | Space |Alt | \|Hom|End|PgD| | 0| .| |
|
|
||||||
* `---------------------------------------------------------' `---------------'
|
|
||||||
*/
|
|
||||||
[3] = KEYMAP(
|
|
||||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST,
|
|
||||||
CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, INS, P7, P8, P9, PMNS,
|
|
||||||
LCAP,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, FN15, P4, P5, P6, PPLS,
|
|
||||||
LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT,
|
|
||||||
LCTL,LGUI, FN16, LALT,FN31,HOME,END, PGDN, P0, PDOT
|
|
||||||
),
|
|
||||||
[4] = KEYMAP(
|
|
||||||
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST,
|
|
||||||
CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, INS, P7, P8, P9, PMNS,
|
|
||||||
LCAP,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, FN15, P4, P5, P6, PPLS,
|
|
||||||
LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT,
|
|
||||||
LCTL,LGUI, FN16, LALT,FN31,HOME,END, PGDN, P0, PDOT
|
|
||||||
),
|
|
||||||
[7] = {},
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fn action definition
|
|
||||||
*/
|
|
||||||
#ifdef KEYMAP_SECTION_ENABLE
|
|
||||||
const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
|
|
||||||
#else
|
|
||||||
const uint16_t fn_actions[] PROGMEM = {
|
|
||||||
#endif
|
|
||||||
[0] = ACTION_LAYER_MOMENTARY(1),
|
|
||||||
[1] = ACTION_LAYER_MOMENTARY(2),
|
|
||||||
[2] = ACTION_LAYER_MOMENTARY(3),
|
|
||||||
[3] = ACTION_LAYER_MOMENTARY(4),
|
|
||||||
[4] = ACTION_LAYER_MOMENTARY(5),
|
|
||||||
[5] = ACTION_LAYER_MOMENTARY(6),
|
|
||||||
[6] = ACTION_LAYER_MOMENTARY(7),
|
|
||||||
[7] = ACTION_LAYER_TOGGLE(1),
|
|
||||||
[8] = ACTION_LAYER_TOGGLE(2),
|
|
||||||
[9] = ACTION_LAYER_TOGGLE(3),
|
|
||||||
[10] = ACTION_LAYER_TAP_TOGGLE(1),
|
|
||||||
[11] = ACTION_LAYER_TAP_TOGGLE(2),
|
|
||||||
[12] = ACTION_LAYER_TAP_TOGGLE(3),
|
|
||||||
[13] = ACTION_LAYER_TAP_KEY(1, KC_F),
|
|
||||||
[14] = ACTION_LAYER_TAP_KEY(2, KC_J),
|
|
||||||
[15] = ACTION_LAYER_TAP_KEY(3, KC_ENTER),
|
|
||||||
[16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE),
|
|
||||||
[17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON),
|
|
||||||
[18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE),
|
|
||||||
[19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH),
|
|
||||||
[20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE),
|
|
||||||
[21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE),
|
|
||||||
[22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE),
|
|
||||||
[23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER),
|
|
||||||
[24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC),
|
|
||||||
[25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE),
|
|
||||||
[26] = ACTION_MODS_ONESHOT(MOD_LCTL),
|
|
||||||
[27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC),
|
|
||||||
[28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE),
|
|
||||||
[29] = ACTION_MODS_ONESHOT(MOD_LSFT),
|
|
||||||
[30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRAVE),
|
|
||||||
[31] = ACTION_MODS_TAP_KEY(MOD_RALT, KC_BSLASH),
|
|
||||||
};
|
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2014 Jun Wako <wakojun@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 <stdint.h>
|
|
||||||
#include "keycode.h"
|
|
||||||
#include "keymap_common.h"
|
|
||||||
|
|
||||||
|
|
||||||
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
||||||
/* Default:
|
|
||||||
* M0110 M0120
|
|
||||||
* ,---------------------------------------------------------. ,---------------.
|
|
||||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Nlk| -| +| *|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9| /|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| ,|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| |
|
|
||||||
* `---------------------------------------------------------' |-----------|Ent|
|
|
||||||
* |Opt|Mac | Space |Mac |Opt| | 0| .| |
|
|
||||||
* `-----------------------------------------------' `---------------'
|
|
||||||
* M0110A
|
|
||||||
* ,---------------------------------------------------------. ,---------------.
|
|
||||||
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Nlk| =| /| *|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -|
|
|
||||||
* |-----------------------------------------------------' | |---------------|
|
|
||||||
* |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +|
|
|
||||||
* |---------------------------------------------------------| |---------------|
|
|
||||||
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
|
|
||||||
* |---------------------------------------------------------' |-----------|Ent|
|
|
||||||
* |Opt |Mac | Space | \|Lft|Rgt|Dn | | 0| .| |
|
|
||||||
* `---------------------------------------------------------' `---------------'
|
|
||||||
*/
|
|
||||||
[0] = KEYMAP(
|
|
||||||
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,PEQL,PSLS,PAST,
|
|
||||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS,
|
|
||||||
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
|
|
||||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT,
|
|
||||||
LALT,LGUI, SPC, RGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fn action definition
|
|
||||||
*/
|
|
||||||
const uint16_t fn_actions[] PROGMEM = {
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,173 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@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 <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "keycode.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "keymap.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Sun type 3 keyboard
|
||||||
|
,-------. ,-----------------------------------------------------------. ,-----------.
|
||||||
|
| 01| 03| | 05| 06| 08| 0A| 0C| 0E| 10| 11| 12| 2B| | 15| 16| 17|
|
||||||
|
|-------| |-----------------------------------------------------------| |-----------|
|
||||||
|
| 19| 1A| | 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 58| 2A| | 2D| 2E| 2F|
|
||||||
|
|-------| |-----------------------------------------------------------| |-----------|
|
||||||
|
| 31| 33| | 35 | 36| 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 42 | | 44| 45| 46|
|
||||||
|
|-------| |-----------------------------------------------------------| |-----------|
|
||||||
|
| 48| 49| | 4C | 4D| 4E| 4F| 50| 51| 52| 53| 54| 55| 56| 57| 59 | | 5B| 5C| 5D|
|
||||||
|
|-------| |-----------------------------------------------------------| |-----------|
|
||||||
|
| 5F| 61| | 63 | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D| 6E| 6F| | 70| 71| 72|
|
||||||
|
`-------' |-----------------------------------------------------------| `-----------'
|
||||||
|
| 77 | 78 | 79 | 7A | 13 |
|
||||||
|
`-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define KEYMAP( \
|
||||||
|
K01,K03, K05,K06, K08, K0A, K0C, K0E, K10,K11,K12,K2B, K15,K16,K17, \
|
||||||
|
K19,K1A, K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A, K2D,K2E,K2F, \
|
||||||
|
K31,K33, K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K42, K44,K45,K46, \
|
||||||
|
K48,K49, K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, K5B,K5C,K5D, \
|
||||||
|
K5F,K61, K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K6E,K6F, K70,K71,K72, \
|
||||||
|
K77,K78, K79, K7A,K13 \
|
||||||
|
) { \
|
||||||
|
{ KC_NO, KC_##K01, KC_NO, KC_##K03, KC_NO, KC_##K05, KC_##K06, KC_NO }, \
|
||||||
|
{ KC_##K08, KC_NO, KC_##K0A, KC_NO, KC_##K0C, KC_NO, KC_##K0E, KC_NO }, \
|
||||||
|
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_NO, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||||
|
{ KC_NO, KC_##K19, KC_##K1A, KC_NO, KC_NO, KC_##K1D, KC_##K1E, KC_##K1F }, \
|
||||||
|
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
|
||||||
|
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, KC_##K2D, KC_##K2E, KC_##K2F }, \
|
||||||
|
{ KC_NO, KC_##K31, KC_NO, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||||
|
{ KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
|
||||||
|
{ KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
|
||||||
|
{ KC_##K48, KC_##K49, KC_NO, KC_NO, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \
|
||||||
|
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||||
|
{ KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_##K5D, KC_NO, KC_##K5F }, \
|
||||||
|
{ KC_NO, KC_##K61, KC_NO, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
|
||||||
|
{ KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \
|
||||||
|
{ KC_##K70, KC_##K71, KC_##K72, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K77 }, \
|
||||||
|
{ KC_##K78, KC_##K79, KC_##K7A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
|
||||||
|
static const uint8_t PROGMEM fn_layer[] = {
|
||||||
|
2, // Fn0
|
||||||
|
3, // Fn1
|
||||||
|
4, // Fn2
|
||||||
|
0, // Fn3
|
||||||
|
0, // Fn4
|
||||||
|
0, // Fn5
|
||||||
|
0, // Fn6
|
||||||
|
0 // Fn7
|
||||||
|
};
|
||||||
|
|
||||||
|
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
|
||||||
|
// See layer.c for details.
|
||||||
|
static const uint8_t PROGMEM fn_keycode[] = {
|
||||||
|
KC_NO, // Fn0
|
||||||
|
KC_SCLN, // Fn1
|
||||||
|
KC_SLSH, // Fn2
|
||||||
|
KC_NO, // Fn3
|
||||||
|
KC_NO, // Fn4
|
||||||
|
KC_NO, // Fn5
|
||||||
|
KC_NO, // Fn6
|
||||||
|
KC_NO // Fn7
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
|
KEYMAP(
|
||||||
|
F10, F11, F1, F2, F3, F4, F5, F6, F7, F8, F9, BSPC, VOLD, MUTE, VOLU,
|
||||||
|
F12, F13, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,MINS, EQL, BSLS, GRV, MPRV, MPLY, MNXT,
|
||||||
|
F14, F15, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, HOME, UP, PGUP,
|
||||||
|
F16, F17, LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, LEFT, INSERT, RIGHT,
|
||||||
|
F18, F19, LSFT, Z, X, C, V, B, N, M, COMM,DOT,SLSH, RSFT,RCTL, END, DOWN, PGDOWN,
|
||||||
|
LGUI, LALT, SPC, RALT,RGUI
|
||||||
|
),
|
||||||
|
/*
|
||||||
|
// 0: default
|
||||||
|
SHORT_TYPE(
|
||||||
|
STOP, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP,
|
||||||
|
F7,F8,F9,F10,F11,F12, DEL, END, PGDN,
|
||||||
|
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV,
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC,
|
||||||
|
LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT,
|
||||||
|
LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RALT,UP, RSFT,
|
||||||
|
CAPS,LALT,LGUI, SPC, RGUI,APP, NLCK,LEFT,DOWN,RGHT
|
||||||
|
),
|
||||||
|
// 1: with layer keys
|
||||||
|
SHORT_TYPE(
|
||||||
|
ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP,
|
||||||
|
F7,F8,F9,F10,F11,F12, DEL, END, PGDN,
|
||||||
|
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV,
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC,
|
||||||
|
LCTL, A, S, D, F, G, H, J, K, L, FN1, QUOT, ENT,
|
||||||
|
LSFT, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,UP, FN0,
|
||||||
|
CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, LEFT,DOWN,RGHT
|
||||||
|
),
|
||||||
|
// 2: HHKB
|
||||||
|
SHORT_TYPE(
|
||||||
|
ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP,
|
||||||
|
F7,F8,F9,F10,F11,F12, DEL, END, PGDN,
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
|
||||||
|
CAPS, NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, BSPC,
|
||||||
|
LCTL, VOLD,VOLU,MUTE,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT,
|
||||||
|
LSFT, Z, X, C, V, B, NO, NO, END, PGDN,DOWN, RSFT,PGUP,FN0,
|
||||||
|
CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, HOME,PGDN,END
|
||||||
|
),
|
||||||
|
// 3: Mousekey
|
||||||
|
SHORT_TYPE(
|
||||||
|
ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP,
|
||||||
|
F7,F8,F9,F10,F11,F12, DEL, END, PGDN,
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
|
||||||
|
CAPS, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC,
|
||||||
|
LCTL, NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN1, NO, ENT,
|
||||||
|
LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, RSFT,UP, NO,
|
||||||
|
CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT
|
||||||
|
),
|
||||||
|
// 4: Cursor
|
||||||
|
SHORT_TYPE(
|
||||||
|
ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP,
|
||||||
|
F7,F8,F9,F10,F11,F12, DEL, END, PGDN,
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL,
|
||||||
|
CAPS, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC,
|
||||||
|
LCTL, NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT,
|
||||||
|
LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,UP, NO,
|
||||||
|
CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT
|
||||||
|
),
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
|
||||||
|
{
|
||||||
|
return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t keymap_fn_layer(uint8_t index)
|
||||||
|
{
|
||||||
|
return pgm_read_byte(&fn_layer[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t keymap_fn_keycode(uint8_t index)
|
||||||
|
{
|
||||||
|
return pgm_read_byte(&fn_keycode[index]);
|
||||||
|
}
|
@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2012 Jun Wako <wakojun@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 "stdint.h"
|
|
||||||
#include "led.h"
|
|
||||||
|
|
||||||
|
|
||||||
void led_set(uint8_t usb_led)
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,593 +0,0 @@
|
|||||||
Keymap framework - how to define your keymap
|
|
||||||
============================================
|
|
||||||
***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.***
|
|
||||||
|
|
||||||
## 0. Keymap and layers
|
|
||||||
**Keymap** is comprised of multiple layers of key layout, you can define **32 layers** at most.
|
|
||||||
**Layer** is an array of **keycodes** to define **actions** for each physical keys.
|
|
||||||
respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence.
|
|
||||||
|
|
||||||
Keymap: 32 Layers Layer: Keycode matrix
|
|
||||||
----------------- ---------------------
|
|
||||||
stack of layers array_of_keycode[row][column]
|
|
||||||
____________ precedence _______________________
|
|
||||||
/ / | high / ESC / F1 / F2 / F3 ....
|
|
||||||
31 /___________// | /-----/-----/-----/-----
|
|
||||||
30 /___________// | / TAB / Q / W / E ....
|
|
||||||
29 /___________/ | /-----/-----/-----/-----
|
|
||||||
: _:_:_:_:_:__ | : /LCtrl/ A / S / D ....
|
|
||||||
: / : : : : : / | : / : : : :
|
|
||||||
2 /___________// | 2 `--------------------------
|
|
||||||
1 /___________// | 1 `--------------------------
|
|
||||||
0 /___________/ V low 0 `--------------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 0.1 Keymap status
|
|
||||||
Keymap has its state in two parameters:
|
|
||||||
**`default_layer`** indicates a base keymap layer(0-31) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit.
|
|
||||||
|
|
||||||
Keymap layer '0' is usually `default_layer` and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in `config.h`.
|
|
||||||
To change `default_layer` will be useful when you switch key layout completely, say you want Colmak instead of Qwerty.
|
|
||||||
|
|
||||||
Initial state of Keymap Change base layout
|
|
||||||
----------------------- ------------------
|
|
||||||
|
|
||||||
31 31
|
|
||||||
30 30
|
|
||||||
29 29
|
|
||||||
: :
|
|
||||||
: : ____________
|
|
||||||
2 ____________ 2 / /
|
|
||||||
1 / / ,->1 /___________/
|
|
||||||
,->0 /___________/ | 0
|
|
||||||
| |
|
|
||||||
`--- default_layer = 0 `--- default_layer = 1
|
|
||||||
layer_state = 0x00000001 layer_state = 0x00000002
|
|
||||||
|
|
||||||
On the other hand, you shall change `layer_state` to overlay base layer with some layers for feature such as navigation keys, function key(F1-F12), media keys or special actions.
|
|
||||||
|
|
||||||
Overlay feature layer
|
|
||||||
--------------------- bit|status
|
|
||||||
____________ ---+------
|
|
||||||
31 / / 31 | 0
|
|
||||||
30 /___________// -----> 30 | 1
|
|
||||||
29 /___________/ -----> 29 | 1
|
|
||||||
: : | :
|
|
||||||
: ____________ : | :
|
|
||||||
2 / / 2 | 0
|
|
||||||
,->1 /___________/ -----> 1 | 1
|
|
||||||
| 0 0 | 0
|
|
||||||
| +
|
|
||||||
`--- default_layer = 1 |
|
|
||||||
layer_state = 0x60000002 <-'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 0.2 Layer Precedence and Transparency
|
|
||||||
Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred.
|
|
||||||
|
|
||||||
You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
|
|
||||||
Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead.
|
|
||||||
See example below.
|
|
||||||
|
|
||||||
|
|
||||||
### 0.3 Keymap Example
|
|
||||||
Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array.
|
|
||||||
|
|
||||||
This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard.
|
|
||||||
This example has three layers, 'Qwerty' as base layer, 'Cursor' and 'Mousekey'.
|
|
||||||
In this example,
|
|
||||||
|
|
||||||
`Fn0` is a **momentary layer switching** key, you can use keys on Cursor layer while holding the key.
|
|
||||||
|
|
||||||
`Fn1` is a momentary layer switching key with tapping feature, you can get semicolon **';'** with taping the key and switch layers while holding the key. The word **'tap'** or **'tapping'** mean to press and release a key quickly.
|
|
||||||
|
|
||||||
`Fn2` is a **toggle layer switch** key, you can stay switched layer after releasing the key unlike momentary switching.
|
|
||||||
|
|
||||||
You can find other keymap definitions in file `keymap.c` located on project directories.
|
|
||||||
|
|
||||||
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
||||||
/* 0: Qwerty
|
|
||||||
* ,-----------------------------------------------------------.
|
|
||||||
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Contro| A| S| D| F| G| H| J| K| L|Fn1| '|Enter |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
|
|
||||||
* `-----------------------------------------------------------'
|
|
||||||
* |Gui|Alt |Space |Alt |Fn2|
|
|
||||||
* `-------------------------------------------'
|
|
||||||
*/
|
|
||||||
KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \
|
|
||||||
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
|
||||||
LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT,ENT, \
|
|
||||||
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
|
|
||||||
LGUI,LALT, SPC, RALT,FN2),
|
|
||||||
/* 1: Cursor(HHKB mode)
|
|
||||||
* ,-----------------------------------------------------------.
|
|
||||||
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Shift | | | | | | +| -|End|PgD|Dow|Shift | |
|
|
||||||
* `-----------------------------------------------------------'
|
|
||||||
* |Gui |Alt |Space |Alt |Gui|
|
|
||||||
* `--------------------------------------------'
|
|
||||||
*/
|
|
||||||
KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
|
||||||
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,BSPC, \
|
|
||||||
LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
|
|
||||||
LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
|
|
||||||
LGUI,LALT, SPC, RALT,RGUI),
|
|
||||||
/* 2: Mousekey
|
|
||||||
* ,-----------------------------------------------------------.
|
|
||||||
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs|
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Contro| | | | | |McL|McD|McU|McR| | |Return |
|
|
||||||
* |-----------------------------------------------------------|
|
|
||||||
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
|
||||||
* `-----------------------------------------------------------'
|
|
||||||
* |Gui |Alt |Mb1 |Alt | |
|
|
||||||
* `--------------------------------------------'
|
|
||||||
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
|
||||||
*/
|
|
||||||
KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
|
|
||||||
TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,BSPC, \
|
|
||||||
LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
|
|
||||||
LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,TRNS, \
|
|
||||||
LGUI,LALT, BTN1, RALT,TRNS),
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint16_t PROGMEM fn_actions[] = {
|
|
||||||
ACTION_LAYER_MOMENTARY(1), // FN0
|
|
||||||
ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN1
|
|
||||||
ACTION_LAYER_TOGGLE(2), // FN2
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 1. Keycode
|
|
||||||
See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to indicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media control keys, System control keys and Mousekeys.
|
|
||||||
|
|
||||||
***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`.
|
|
||||||
|
|
||||||
### 1.0 Other key
|
|
||||||
- `KC_NO` for no action
|
|
||||||
- `KC_TRNS` for layer transparency (See above)
|
|
||||||
|
|
||||||
### 1.1 Normal key
|
|
||||||
- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key
|
|
||||||
- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT`
|
|
||||||
- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS`
|
|
||||||
- `KC_UP`, `KC_DOWN`, `KC_RGHT`, `KC_LEFT`, `KC_PGUP`, `KC_PGDN`, `KC_HOME`, `KC_END`
|
|
||||||
- `KC_CAPS`, `KC_NLCK`, `KC_SLCK`, `KC_PSCR`, `KC_PAUS`, `KC_APP`, `KC_F1` to `KC_F24`
|
|
||||||
- `KC_P1` to `KC_P0`, `KC_PDOT`, `KC_PCMM`, `KC_PSLS`, `KC_PAST`, `KC_PMNS`, `KC_PPLS`, `KC_PEQL`, `KC_PENT` for keypad.
|
|
||||||
|
|
||||||
### 1.2 Modifier
|
|
||||||
There are 8 modifiers which has discrimination between left and right.
|
|
||||||
|
|
||||||
- `KC_LCTL` and `KC_RCTL` for Control
|
|
||||||
- `KC_LSFT` and `KC_RSFT` for Shift
|
|
||||||
- `KC_LALT` and `KC_RALT` for Alt
|
|
||||||
- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac
|
|
||||||
|
|
||||||
### 1.3 Mousekey
|
|
||||||
- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor
|
|
||||||
- `KC_WH_U`, `KC_WH_D`, `KC_WH_L`, `KC_WH_R` for mouse wheel
|
|
||||||
- `KC_BTN1`, `KC_BTN2`, `KC_BTN3`, `KC_BTN4`, `KC_BTN5` for mouse buttons
|
|
||||||
|
|
||||||
### 1.4 System & Media key
|
|
||||||
- `KC_PWR`, `KC_SLEP`, `KC_WAKE` for Power, Sleep, Wake
|
|
||||||
- `KC_MUTE`, `KC_VOLU`, `KC_VOLD` for audio volume control
|
|
||||||
- `KC_MNXT`, `KC_MPRV`, `KC_MSTP`, `KC_MPLY`, `KC_MSEL` for media control
|
|
||||||
- `KC_MAIL`, `KC_CALC`, `KC_MYCM` for application launch
|
|
||||||
- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation
|
|
||||||
|
|
||||||
### 1.5 Fn key
|
|
||||||
`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.***
|
|
||||||
|
|
||||||
### 1.6 Keycode Table
|
|
||||||
See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.
|
|
||||||
|
|
||||||
In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions.
|
|
||||||
[HID_usage]: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 2. Action
|
|
||||||
See [`common/action_code.h`](../common/action_code.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping.
|
|
||||||
|
|
||||||
Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using just keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes.
|
|
||||||
|
|
||||||
***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.***
|
|
||||||
|
|
||||||
|
|
||||||
### 2.1 Key Action
|
|
||||||
This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
+ **mods**: { ` MOD_LCTL`, ` MOD_LSFT`, ` MOD_LALT`, ` MOD_LGUI`,
|
|
||||||
` MOD_RCTL`, ` MOD_RSFT`, ` MOD_RALT`, ` MOD_RGUI` }
|
|
||||||
+ **key**: keycode
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.1.1 Normal key and Modifier
|
|
||||||
***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead.
|
|
||||||
|
|
||||||
You can define these actions on *'A'* key and *'left shift'* modifier with:
|
|
||||||
|
|
||||||
ACTION_KEY(KC_A)
|
|
||||||
ACTION_KEY(KC_LSFT)
|
|
||||||
|
|
||||||
#### 2.1.2 Modified key
|
|
||||||
This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes.
|
|
||||||
|
|
||||||
Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows.
|
|
||||||
|
|
||||||
ACTION_MODS_KEY(MOD_LSFT, KC_1)
|
|
||||||
ACTION_MODS_KEY(MOD_LALT, KC_TAB)
|
|
||||||
|
|
||||||
Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro.
|
|
||||||
|
|
||||||
ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB)
|
|
||||||
|
|
||||||
#### 2.1.3 Multiple Modifiers
|
|
||||||
Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`.
|
|
||||||
|
|
||||||
ACTION_MODS(MOD_ALT | MOD_LSFT)
|
|
||||||
|
|
||||||
#### 2.1.3 Modifier with Tap key([Dual role][dual_role])
|
|
||||||
Works as a modifier key while holding, but registers a key on tap(press and release quickly).
|
|
||||||
|
|
||||||
|
|
||||||
ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2.2 Layer Action
|
|
||||||
These actions operate layers of keymap.
|
|
||||||
|
|
||||||
#### Parameters
|
|
||||||
You can specify a **target layer** of action and **when the action is executed**. Some actions take a **bit value** for bitwise operation.
|
|
||||||
|
|
||||||
|
|
||||||
+ **layer**: `0`-`31`
|
|
||||||
+ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` }
|
|
||||||
+ **bits**: 4-bit value and 1-bit mask bit
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.1 Default Layer
|
|
||||||
Default Layer is a layer which always is valid and referred to when actions is not defined on other overlay layers.
|
|
||||||
|
|
||||||
This sets Default Layer to given parameter `layer` and activate it.
|
|
||||||
|
|
||||||
ACTION_DEFAULT_LAYER_SET(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.2 Momentary
|
|
||||||
Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released.
|
|
||||||
|
|
||||||
ACTION_LAYER_MOMENTARY(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.3 Toggle Switch
|
|
||||||
Turns on `layer` with first type(press and release) and turns off with next.
|
|
||||||
|
|
||||||
ACTION_LAYER_TOGGLE(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.4 Momentary Switch with tap key
|
|
||||||
Turns on `layer` momentary while holding, but registers key on tap(press and release quickly).
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_KEY(layer, key)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.5 Momentary Switch with tap toggle
|
|
||||||
Turns on `layer` momentary while holding and toggles it with serial taps.
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_TOGGLE(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.6 Invert state of layer
|
|
||||||
Inverts current state of `layer`. If the layer is on it becomes off with this action.
|
|
||||||
|
|
||||||
ACTION_LAYER_INVERT(layer, on)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.7 Turn On layer
|
|
||||||
Turns on layer state.
|
|
||||||
|
|
||||||
ACTION_LAYER_ON(layer, on)
|
|
||||||
|
|
||||||
Turns on layer state on press and turns off on release.
|
|
||||||
|
|
||||||
ACTION_LAYER_ON_OFF(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.8 Turn Off layer
|
|
||||||
Turns off layer state.
|
|
||||||
|
|
||||||
ACTION_LAYER_OFF(layer, on)
|
|
||||||
|
|
||||||
Turns off layer state on press and activates on release.
|
|
||||||
|
|
||||||
ACTION_LAYER_OFF_ON(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.9 Set layer
|
|
||||||
Turn on layer only.
|
|
||||||
`layer_state = (1<<layer) [layer: 0-31]`
|
|
||||||
|
|
||||||
ACTION_LAYER_SET(layer, on)
|
|
||||||
|
|
||||||
Turns on layer only and clear all layer on release..
|
|
||||||
|
|
||||||
ACTION_LAYER_SET_CLEAR(layer)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.2.10 Bitwise operation
|
|
||||||
|
|
||||||
**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed.
|
|
||||||
|
|
||||||
ACTION_LAYER_BIT_AND(part, bits, on)
|
|
||||||
ACTION_LAYER_BIT_OR(part, bits, on)
|
|
||||||
ACTION_LAYER_BIT_XOR(part, bits, on)
|
|
||||||
ACTION_LAYER_BIT_SET(part, bits, on)
|
|
||||||
|
|
||||||
These actions works with parameters as following code.
|
|
||||||
|
|
||||||
uint8_t shift = part*4;
|
|
||||||
uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
|
|
||||||
uint32_t layer_state = layer_state <bitop> ((bits<<shift)|mask);
|
|
||||||
|
|
||||||
|
|
||||||
Default Layer also has bitwise operations, they are executed when key is released.
|
|
||||||
|
|
||||||
ACTION_DEFAULT_LAYER_BIT_AND(part, bits)
|
|
||||||
ACTION_DEFAULT_LAYER_BIT_OR(part, bits)
|
|
||||||
ACTION_DEFAULT_LAYER_BIT_XOR(part, bits)
|
|
||||||
ACTION_DEFAULT_LAYER_BIT_SET(part, bits)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2.3 Macro action
|
|
||||||
***TBD***
|
|
||||||
|
|
||||||
`Macro` action indicates complex key strokes.
|
|
||||||
|
|
||||||
MACRO( D(LSHIFT), D(D), END )
|
|
||||||
MACRO( U(D), U(LSHIFT), END )
|
|
||||||
MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )
|
|
||||||
|
|
||||||
#### 2.3.1 Macro Commands
|
|
||||||
- **I()** change interval of stroke.
|
|
||||||
- **D()** press key
|
|
||||||
- **U()** release key
|
|
||||||
- **T()** type key(press and release)
|
|
||||||
- **W()** wait
|
|
||||||
- **END** end mark
|
|
||||||
|
|
||||||
#### 2.3.2 Examples
|
|
||||||
|
|
||||||
***TODO: sample implementation***
|
|
||||||
See `keyboard/hhkb/keymap.c` for sample.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2.4 Function action
|
|
||||||
***TBD***
|
|
||||||
|
|
||||||
There are two type of action, normal `Function` and tappable `Function`.
|
|
||||||
These actions call user defined function with `id`, `opt`, and key event information as arguments.
|
|
||||||
|
|
||||||
#### 2.4.1 Function
|
|
||||||
To define normal `Function` action in keymap use this.
|
|
||||||
|
|
||||||
ACTION_FUNCTION(id, opt)
|
|
||||||
|
|
||||||
#### 2.4.2 Function with tap
|
|
||||||
To define tappable `Function` action in keymap use this.
|
|
||||||
|
|
||||||
ACTION_FUNCTION_TAP(id, opt)
|
|
||||||
|
|
||||||
#### 2.4.3 Implement user function
|
|
||||||
`Function` actions can be defined freely with C by user in callback function:
|
|
||||||
|
|
||||||
void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt)
|
|
||||||
|
|
||||||
This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Function `id` can be 0-255 and `opt` can be 0-15.
|
|
||||||
|
|
||||||
`keyrecord_t` is comprised of key event and tap count. `keyevent_t` indicates which and when key is pressed or released. From `tap_count` you can know tap state, 0 means no tap. These information will be used in user function to decide how action of key is performed.
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
keyevent_t event;
|
|
||||||
uint8_t tap_count;
|
|
||||||
} keyrecord_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
key_t key;
|
|
||||||
bool pressed;
|
|
||||||
uint16_t time;
|
|
||||||
} keyevent_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t col;
|
|
||||||
uint8_t row;
|
|
||||||
} key_t;
|
|
||||||
|
|
||||||
***TODO: sample implementation***
|
|
||||||
See `keyboard/hhkb/keymap.c` for sample.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 2.5 Backlight Action
|
|
||||||
These actions control the backlight.
|
|
||||||
|
|
||||||
#### 2.5.1 Change backlight level
|
|
||||||
Increase backlight level.
|
|
||||||
|
|
||||||
ACTION_BACKLIGHT_INCREASE()
|
|
||||||
|
|
||||||
Decrease backlight level.
|
|
||||||
|
|
||||||
ACTION_BACKLIGHT_DECREASE()
|
|
||||||
|
|
||||||
Step through backlight levels.
|
|
||||||
|
|
||||||
ACTION_BACKLIGHT_STEP()
|
|
||||||
|
|
||||||
Turn a specific backlight level on or off.
|
|
||||||
|
|
||||||
ACTION_BACKLIGHT_LEVEL(1)
|
|
||||||
|
|
||||||
#### 2.5.2 Turn on / off backlight
|
|
||||||
Turn the backlight on and off without changing level.
|
|
||||||
|
|
||||||
ACTION_BACKLIGHT_TOGGLE()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 3. Layer switching Example
|
|
||||||
There are some ways to switch layer with 'Layer' actions.
|
|
||||||
|
|
||||||
### 3.1 Momentary switching
|
|
||||||
Momentary switching changes layer only while holding Fn key.
|
|
||||||
|
|
||||||
This action makes 'Layer 1' active(valid) on key press event and inactive on release event. Namely you can overlay a layer on lower layers or default layer temporarily with this action.
|
|
||||||
|
|
||||||
ACTION_LAYER_MOMENTARY(1)
|
|
||||||
|
|
||||||
|
|
||||||
Note that after switching on press the actions on destination layer(Layer 1) are performed.
|
|
||||||
***Thus you shall need to place an action to go back on destination layer***, or you will be stuck in destination layer without way to get back. Usually you need to place same action or 'KC_TRNS` on destination layer to get back.
|
|
||||||
|
|
||||||
|
|
||||||
### 3.2 Toggle switching
|
|
||||||
Toggle switching performed after releasing a key. With this action you can keep staying on the destination layer until you type the key again to return.
|
|
||||||
|
|
||||||
This performs toggle switching action of 'Layer 2'.
|
|
||||||
|
|
||||||
ACTION_LAYER_TOGGLE(2)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3.3 Momentary switching with Tap key
|
|
||||||
These actions switch a layer only while holding a key but register the key on tap. **Tap** means to press and release a key quickly.
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_KEY(2, KC_SCLN)
|
|
||||||
|
|
||||||
With this you can place a layer switching action on normal key like ';' without losing its original key register function. This action allows you to have layer switching action without necessity of a dedicated key. It means you can have it even on home row of keyboard.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3.4 Momentary switching with Tap Toggle
|
|
||||||
This switches layer only while holding a key but toggle layer with several taps. **Tap** means to press and release key quickly.
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_TOGGLE(1)
|
|
||||||
|
|
||||||
Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by default.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 3.5 Momentary switching with Modifiers
|
|
||||||
This registers modifier key(s) simultaneously with layer switching.
|
|
||||||
|
|
||||||
ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 4. Tapping
|
|
||||||
Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.
|
|
||||||
|
|
||||||
### 4.1 Tap Key
|
|
||||||
This is a feature to assign normal key action and modifier including layer switching to just same one physical key. This is a kind of [Dual role key][dual_role]. It works as modifier when holding the key but registers normal key when tapping.
|
|
||||||
|
|
||||||
Modifier with tap key:
|
|
||||||
|
|
||||||
ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV)
|
|
||||||
|
|
||||||
Layer switching with tap key:
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_KEY(2, KC_SCLN)
|
|
||||||
|
|
||||||
[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys
|
|
||||||
|
|
||||||
|
|
||||||
### 4.2 Tap Toggle
|
|
||||||
This is a feature to assign both toggle layer and momentary switch layer action to just same one physical key. It works as momentary layer switch when holding a key but toggle switch with several taps.
|
|
||||||
|
|
||||||
ACTION_LAYER_TAP_TOGGLE(1)
|
|
||||||
|
|
||||||
|
|
||||||
### 4.3 Oneshot Modifier
|
|
||||||
This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping.
|
|
||||||
|
|
||||||
ACTION_MODS_ONESHOT(MOD_LSFT)
|
|
||||||
|
|
||||||
Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can release Shift before 't' is pressed down.
|
|
||||||
|
|
||||||
Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined.
|
|
||||||
|
|
||||||
|
|
||||||
### 4.4 Tap Toggle Mods
|
|
||||||
Similar to layer tap toggle, this works as a momentary modifier when holding, but toggles on with several taps. A single tap will 'unstick' the modifier again.
|
|
||||||
|
|
||||||
ACTION_MODS_TAP_TOGGLE(MOD_LSFT)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 5. Legacy Keymap
|
|
||||||
This was used in prior version and still works due to legacy support code in `common/keymap.c`. Legacy keymap doesn't support many of features that new keymap offers. ***It is not recommended to use Legacy Keymap for new project.***
|
|
||||||
|
|
||||||
To enable Legacy Keymap support define this macro in `config.h`.
|
|
||||||
|
|
||||||
#define USE_LEGACY_KEYMAP
|
|
||||||
|
|
||||||
Legacy Keymap uses two arrays `fn_layer[]` and `fn_keycode[]` to define Fn key. The index of arrays corresponds with postfix number of `Fn` key. Array `fn_layer[]` indicates destination layer to switch and `fn_keycode[]` has keycodes to send when tapping `Fn` key.
|
|
||||||
|
|
||||||
In following setting example, `Fn0`, `Fn1` and `Fn2` switch layer to 1, 2 and 2 respectively. `Fn2` registers `Space` key when tapping while `Fn0` and `Fn1` doesn't send any key.
|
|
||||||
|
|
||||||
static const uint8_t PROGMEM fn_layer[] = {
|
|
||||||
1, // Fn0
|
|
||||||
2, // Fn1
|
|
||||||
2, // Fn2
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t PROGMEM fn_keycode[] = {
|
|
||||||
KC_NO, // Fn0
|
|
||||||
KC_NO, // Fn1
|
|
||||||
KC_SPC, // Fn2
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
## 6. Terminology
|
|
||||||
***TBD***
|
|
||||||
### keymap
|
|
||||||
is comprised of multiple layers.
|
|
||||||
### layer
|
|
||||||
is matrix of keycodes.
|
|
||||||
### key
|
|
||||||
is physical button on keyboard or logical switch on software.
|
|
||||||
### keycode
|
|
||||||
is codes used on firmware.
|
|
||||||
### action
|
|
||||||
is a function assigned on a key.
|
|
||||||
### layer transparency
|
|
||||||
Using transparent keycode one layer can refer key definition on other lower layer.
|
|
||||||
### layer precedence
|
|
||||||
Top layer has higher precedence than lower layers.
|
|
||||||
### tapping
|
|
||||||
is to press and release a key quickly.
|
|
||||||
### Fn key
|
|
||||||
is key which executes a special action like layer switching, mouse key, macro or etc.
|
|
||||||
### dual role key
|
|
||||||
<http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys>
|
|
@ -0,0 +1,134 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# On command line:
|
||||||
|
#
|
||||||
|
# make all = Make software.
|
||||||
|
#
|
||||||
|
# make clean = Clean out built project files.
|
||||||
|
#
|
||||||
|
# make coff = Convert ELF to AVR COFF.
|
||||||
|
#
|
||||||
|
# make extcoff = Convert ELF to AVR Extended COFF.
|
||||||
|
#
|
||||||
|
# make program = Download the hex file to the device.
|
||||||
|
# Please customize your programmer settings(PROGRAM_CMD)
|
||||||
|
#
|
||||||
|
# make teensy = Download the hex file to the device, using teensy_loader_cli.
|
||||||
|
# (must have teensy_loader_cli installed).
|
||||||
|
#
|
||||||
|
# make dfu = Download the hex file to the device, using dfu-programmer (must
|
||||||
|
# have dfu-programmer installed).
|
||||||
|
#
|
||||||
|
# make flip = Download the hex file to the device, using Atmel FLIP (must
|
||||||
|
# have Atmel FLIP installed).
|
||||||
|
#
|
||||||
|
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
|
||||||
|
# (must have dfu-programmer installed).
|
||||||
|
#
|
||||||
|
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
|
||||||
|
# (must have Atmel FLIP installed).
|
||||||
|
#
|
||||||
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
|
# with avr-gdb or avr-insight as the front end for debugging.
|
||||||
|
#
|
||||||
|
# make filename.s = Just compile filename.c into the assembler code only.
|
||||||
|
#
|
||||||
|
# make filename.i = Create a preprocessed source file for use in submitting
|
||||||
|
# bug reports to the GCC project.
|
||||||
|
#
|
||||||
|
# To rebuild project do "make clean" then "make all".
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Target file name (without extension).
|
||||||
|
TARGET = alps64
|
||||||
|
|
||||||
|
# Directory common source filess exist
|
||||||
|
TMK_DIR = ../../tmk_core
|
||||||
|
|
||||||
|
# Directory keyboard dependent files exist
|
||||||
|
TARGET_DIR = .
|
||||||
|
|
||||||
|
# project specific files
|
||||||
|
SRC = keymap_common.c \
|
||||||
|
matrix.c \
|
||||||
|
led.c
|
||||||
|
|
||||||
|
ifdef KEYMAP
|
||||||
|
SRC := keymap_$(KEYMAP).c $(SRC)
|
||||||
|
else
|
||||||
|
SRC := keymap_plain.c $(SRC)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CONFIG_H = config.h
|
||||||
|
|
||||||
|
|
||||||
|
# MCU name
|
||||||
|
MCU = atmega32u2
|
||||||
|
|
||||||
|
# Processor frequency.
|
||||||
|
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||||
|
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||||
|
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||||
|
# automatically to create a 32-bit value in your source code.
|
||||||
|
#
|
||||||
|
# This will be an integer division of F_USB below, as it is sourced by
|
||||||
|
# F_USB after it has run through any CPU prescalers. Note that this value
|
||||||
|
# does not *change* the processor frequency - it should merely be updated to
|
||||||
|
# reflect the processor speed set externally so that the code can use accurate
|
||||||
|
# software delays.
|
||||||
|
F_CPU = 16000000
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# LUFA specific
|
||||||
|
#
|
||||||
|
# Target architecture (see library "Board Types" documentation).
|
||||||
|
ARCH = AVR8
|
||||||
|
|
||||||
|
# Input clock frequency.
|
||||||
|
# This will define a symbol, F_USB, in all source code files equal to the
|
||||||
|
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||||
|
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||||
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
|
||||||
|
# at the end, this will be done automatically to create a 32-bit value in your
|
||||||
|
# source code.
|
||||||
|
#
|
||||||
|
# If no clock division is performed on the input clock inside the AVR (via the
|
||||||
|
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
|
||||||
|
F_USB = $(F_CPU)
|
||||||
|
|
||||||
|
# Interrupt driven control endpoint task(+60)
|
||||||
|
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
|
||||||
|
|
||||||
|
|
||||||
|
# Boot Section Size in *bytes*
|
||||||
|
# Teensy halfKay 512
|
||||||
|
# Teensy++ halfKay 1024
|
||||||
|
# Atmel DFU loader 4096
|
||||||
|
# LUFA bootloader 4096
|
||||||
|
# USBaspLoader 2048
|
||||||
|
OPT_DEFS += -DBOOTLOADER_SIZE=4096
|
||||||
|
|
||||||
|
|
||||||
|
# Build Options
|
||||||
|
# comment out to disable the options.
|
||||||
|
#
|
||||||
|
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
|
||||||
|
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
|
||||||
|
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
|
||||||
|
CONSOLE_ENABLE = yes # Console for debug(+400)
|
||||||
|
COMMAND_ENABLE = yes # Commands for debug and configuration
|
||||||
|
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
|
||||||
|
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
|
||||||
|
|
||||||
|
|
||||||
|
# Optimize size but this may cause error "relocation truncated to fit"
|
||||||
|
#EXTRALDFLAGS = -Wl,--relax
|
||||||
|
|
||||||
|
# Search Path
|
||||||
|
VPATH += $(TARGET_DIR)
|
||||||
|
VPATH += $(TMK_DIR)
|
||||||
|
|
||||||
|
include $(TMK_DIR)/protocol/lufa.mk
|
||||||
|
include $(TMK_DIR)/common.mk
|
||||||
|
include $(TMK_DIR)/rules.mk
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Jun Wako <wakojun@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 CONFIG_H
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
|
||||||
|
/* USB Device descriptor parameter */
|
||||||
|
#define VENDOR_ID 0xFEED
|
||||||
|
#define PRODUCT_ID 0x6464
|
||||||
|
#define DEVICE_VER 0x0001
|
||||||
|
#define MANUFACTURER TMK
|
||||||
|
#define PRODUCT Alps64
|
||||||
|
#define DESCRIPTION TMK keyboard firmware for Alps64
|
||||||
|
|
||||||
|
/* key matrix size */
|
||||||
|
#define MATRIX_ROWS 8
|
||||||
|
#define MATRIX_COLS 8
|
||||||
|
|
||||||
|
/* define if matrix has ghost */
|
||||||
|
//#define MATRIX_HAS_GHOST
|
||||||
|
|
||||||
|
/* Set 0 if debouncing isn't needed */
|
||||||
|
#define DEBOUNCE 5
|
||||||
|
|
||||||
|
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
|
||||||
|
#define LOCKING_SUPPORT_ENABLE
|
||||||
|
/* Locking resynchronize hack */
|
||||||
|
#define LOCKING_RESYNC_ENABLE
|
||||||
|
|
||||||
|
/* key combination for command */
|
||||||
|
#define IS_COMMAND() ( \
|
||||||
|
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Feature disable options
|
||||||
|
* These options are also useful to firmware size reduction.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* disable debug print */
|
||||||
|
//#define NO_DEBUG
|
||||||
|
|
||||||
|
/* disable print */
|
||||||
|
//#define NO_PRINT
|
||||||
|
|
||||||
|
/* disable action features */
|
||||||
|
//#define NO_ACTION_LAYER
|
||||||
|
//#define NO_ACTION_TAPPING
|
||||||
|
//#define NO_ACTION_ONESHOT
|
||||||
|
//#define NO_ACTION_MACRO
|
||||||
|
//#define NO_ACTION_FUNCTION
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012,2013 Jun Wako <wakojun@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 "keymap_common.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* translates key to keycode */
|
||||||
|
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
|
||||||
|
{
|
||||||
|
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* translates Fn keycode to action */
|
||||||
|
action_t keymap_fn_to_action(uint8_t keycode)
|
||||||
|
{
|
||||||
|
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012,2013 Jun Wako <wakojun@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 KEYMAP_COMMON_H
|
||||||
|
#define KEYMAP_COMMON_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
#include "keycode.h"
|
||||||
|
#include "action.h"
|
||||||
|
#include "action_macro.h"
|
||||||
|
#include "report.h"
|
||||||
|
#include "host.h"
|
||||||
|
#include "print.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "keymap.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
|
||||||
|
extern const uint16_t fn_actions[];
|
||||||
|
|
||||||
|
|
||||||
|
/* Alps64 keymap definition macro */
|
||||||
|
#define KEYMAP( \
|
||||||
|
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \
|
||||||
|
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
|
||||||
|
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
|
||||||
|
K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \
|
||||||
|
K30, K40, K50, K60, K70, K00, K10, K20 \
|
||||||
|
) { \
|
||||||
|
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
|
||||||
|
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
|
||||||
|
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
|
||||||
|
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
|
||||||
|
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
|
||||||
|
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
|
||||||
|
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
|
||||||
|
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \
|
||||||
|
}
|
||||||
|
|
||||||
|
/* AEK US */
|
||||||
|
#define KEYMAP_AEK( \
|
||||||
|
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \
|
||||||
|
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
|
||||||
|
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
|
||||||
|
K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \
|
||||||
|
K30, K40, K50, K60, K00, K10, K20 \
|
||||||
|
) KEYMAP( \
|
||||||
|
K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \
|
||||||
|
K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \
|
||||||
|
K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \
|
||||||
|
K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \
|
||||||
|
K30, K40, K50, K60, APP, K00, K10, K20 \
|
||||||
|
)
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,151 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hasu
|
||||||
|
*/
|
||||||
|
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* Default Layer
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl |
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[0] = KEYMAP_AEK( \
|
||||||
|
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, \
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \
|
||||||
|
LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN1, \
|
||||||
|
LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, FN4, RALT,FN5, FN0),
|
||||||
|
|
||||||
|
/* HHKB mode[HHKB Fn]
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | | | | | | +| -|End|PgD|Dow|Shift |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl |
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[1] = KEYMAP_AEK( \
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||||
|
CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, DEL, \
|
||||||
|
LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \
|
||||||
|
LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT, \
|
||||||
|
LCTL,LGUI,LALT, TRNS, RALT,RGUI,TRNS),
|
||||||
|
|
||||||
|
/* Vi mode[Slash]
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl |
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
*/
|
||||||
|
[2] = KEYMAP_AEK( \
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||||
|
TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, DEL, \
|
||||||
|
LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \
|
||||||
|
LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL),
|
||||||
|
|
||||||
|
/* Mouse mode(IJKL)[Semicolon]
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl |
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||||
|
*/
|
||||||
|
[3] = KEYMAP_AEK( \
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||||
|
FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
|
||||||
|
LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \
|
||||||
|
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS),
|
||||||
|
|
||||||
|
/* Layer 4: Mouse mode(IJKL)[Space]
|
||||||
|
* ,-----------------------------------------------------------.
|
||||||
|
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
|
||||||
|
* |-----------------------------------------------------------|
|
||||||
|
* |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl |
|
||||||
|
* `-----------------------------------------------------------'
|
||||||
|
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
|
||||||
|
*/
|
||||||
|
[4] = KEYMAP_AEK( \
|
||||||
|
GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \
|
||||||
|
FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
|
||||||
|
LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \
|
||||||
|
LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \
|
||||||
|
LCTL,LGUI,LALT, TRNS, TRNS,TRNS,TRNS),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* id for user defined function/macro */
|
||||||
|
enum function_id {
|
||||||
|
NONE,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum macro_id {
|
||||||
|
ALT_TAB,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fn action definition
|
||||||
|
*/
|
||||||
|
const uint16_t PROGMEM fn_actions[] = {
|
||||||
|
[0] = ACTION_LAYER_MOMENTARY(1), // HHKB layer
|
||||||
|
[1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // HHKB layer
|
||||||
|
[2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash*
|
||||||
|
[3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon*
|
||||||
|
[4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space
|
||||||
|
[5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer(IJKL)
|
||||||
|
[6] = ACTION_LAYER_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter
|
||||||
|
[7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift
|
||||||
|
[8] = ACTION_MACRO(ALT_TAB), // Application switching
|
||||||
|
[9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
|
||||||
|
[10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macro definition
|
||||||
|
*/
|
||||||
|
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
|
||||||
|
{
|
||||||
|
switch (id) {
|
||||||
|
case ALT_TAB:
|
||||||
|
return (record->event.pressed ?
|
||||||
|
MACRO( D(LALT), D(TAB), END ) :
|
||||||
|
MACRO( U(TAB), END ));
|
||||||
|
}
|
||||||
|
return MACRO_NONE;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
#include "keymap_common.h"
|
||||||
|
|
||||||
|
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
/* 0: qwerty */
|
||||||
|
KEYMAP( \
|
||||||
|
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \
|
||||||
|
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \
|
||||||
|
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \
|
||||||
|
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,ESC, \
|
||||||
|
LCTL,LGUI,LALT, SPC, APP, RALT,RGUI,RCTL),
|
||||||
|
};
|
||||||
|
const uint16_t PROGMEM fn_actions[] = {};
|
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@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 "stdint.h"
|
||||||
|
#include "led.h"
|
||||||
|
|
||||||
|
|
||||||
|
void led_set(uint8_t usb_led)
|
||||||
|
{
|
||||||
|
if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
|
||||||
|
// output high
|
||||||
|
DDRC |= (1<<5);
|
||||||
|
PORTC |= (1<<5);
|
||||||
|
} else {
|
||||||
|
// Hi-Z
|
||||||
|
DDRC &= ~(1<<5);
|
||||||
|
PORTC &= ~(1<<5);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,200 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2012 Jun Wako <wakojun@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* scan matrix
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
#include "print.h"
|
||||||
|
#include "debug.h"
|
||||||
|
#include "util.h"
|
||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DEBOUNCE
|
||||||
|
# define DEBOUNCE 5
|
||||||
|
#endif
|
||||||
|
static uint8_t debouncing = DEBOUNCE;
|
||||||
|
|
||||||
|
/* matrix state(1:on, 0:off) */
|
||||||
|
static matrix_row_t matrix[MATRIX_ROWS];
|
||||||
|
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
|
||||||
|
|
||||||
|
static matrix_row_t read_cols(void);
|
||||||
|
static void init_cols(void);
|
||||||
|
static void unselect_rows(void);
|
||||||
|
static void select_row(uint8_t row);
|
||||||
|
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_rows(void)
|
||||||
|
{
|
||||||
|
return MATRIX_ROWS;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
uint8_t matrix_cols(void)
|
||||||
|
{
|
||||||
|
return MATRIX_COLS;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0)
|
||||||
|
#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0)
|
||||||
|
#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0)
|
||||||
|
|
||||||
|
void matrix_init(void)
|
||||||
|
{
|
||||||
|
// initialize row and col
|
||||||
|
unselect_rows();
|
||||||
|
init_cols();
|
||||||
|
|
||||||
|
// initialize matrix state: all keys off
|
||||||
|
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
|
||||||
|
matrix[i] = 0;
|
||||||
|
matrix_debouncing[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//debug
|
||||||
|
debug_matrix = true;
|
||||||
|
LED_ON();
|
||||||
|
_delay_ms(500);
|
||||||
|
LED_OFF();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t matrix_scan(void)
|
||||||
|
{
|
||||||
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
|
select_row(i);
|
||||||
|
_delay_us(30); // without this wait read unstable value.
|
||||||
|
matrix_row_t cols = read_cols();
|
||||||
|
if (matrix_debouncing[i] != cols) {
|
||||||
|
matrix_debouncing[i] = cols;
|
||||||
|
if (debouncing) {
|
||||||
|
debug("bounce!: "); debug_hex(debouncing); debug("\n");
|
||||||
|
}
|
||||||
|
debouncing = DEBOUNCE;
|
||||||
|
}
|
||||||
|
unselect_rows();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debouncing) {
|
||||||
|
if (--debouncing) {
|
||||||
|
_delay_ms(1);
|
||||||
|
} else {
|
||||||
|
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
|
||||||
|
matrix[i] = matrix_debouncing[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
bool matrix_is_on(uint8_t row, uint8_t col)
|
||||||
|
{
|
||||||
|
return (matrix[row] & ((matrix_row_t)1<<col));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
matrix_row_t matrix_get_row(uint8_t row)
|
||||||
|
{
|
||||||
|
return matrix[row];
|
||||||
|
}
|
||||||
|
|
||||||
|
void matrix_print(void)
|
||||||
|
{
|
||||||
|
print("\nr/c 0123456789ABCDEF\n");
|
||||||
|
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
|
||||||
|
phex(row); print(": ");
|
||||||
|
pbin_reverse16(matrix_get_row(row));
|
||||||
|
print("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Column pin configuration
|
||||||
|
* col: 0 1 2 3 4 5 6 7
|
||||||
|
* pin: B0 B1 B2 B3 B4 B5 B6 B7
|
||||||
|
*/
|
||||||
|
static void init_cols(void)
|
||||||
|
{
|
||||||
|
// Input with pull-up(DDR:0, PORT:1)
|
||||||
|
DDRB &= ~0b11111111;
|
||||||
|
PORTB |= 0b11111111;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns status of switches(1:on, 0:off) */
|
||||||
|
static matrix_row_t read_cols(void)
|
||||||
|
{
|
||||||
|
// Invert because PIN indicates 'switch on' with low(0) and 'off' with high(1)
|
||||||
|
return ~PINB;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Row pin configuration
|
||||||
|
* row: 0 1 2 3 4 5 6 7
|
||||||
|
* pin: D0 D1 D2 D3 D4 D5 D6 C2
|
||||||
|
*/
|
||||||
|
static void unselect_rows(void)
|
||||||
|
{
|
||||||
|
// Hi-Z(DDR:0, PORT:0) to unselect
|
||||||
|
DDRD &= ~0b01111111;
|
||||||
|
PORTD &= ~0b01111111;
|
||||||
|
DDRC &= ~0b00000100;
|
||||||
|
PORTC &= ~0b00000100;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void select_row(uint8_t row)
|
||||||
|
{
|
||||||
|
// Output low(DDR:1, PORT:0) to select
|
||||||
|
switch (row) {
|
||||||
|
case 0:
|
||||||
|
DDRD |= (1<<0);
|
||||||
|
PORTD &= ~(1<<0);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
DDRD |= (1<<1);
|
||||||
|
PORTD &= ~(1<<1);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
DDRD |= (1<<2);
|
||||||
|
PORTD &= ~(1<<2);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
DDRD |= (1<<3);
|
||||||
|
PORTD &= ~(1<<3);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
DDRD |= (1<<4);
|
||||||
|
PORTD &= ~(1<<4);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
DDRD |= (1<<5);
|
||||||
|
PORTD &= ~(1<<5);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
DDRD |= (1<<6);
|
||||||
|
PORTD &= ~(1<<6);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
DDRC |= (1<<2);
|
||||||
|
PORTC &= ~(1<<2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
HHKB keycodes
|
||||||
|
=============
|
||||||
|
2015/10/03
|
||||||
|
Looked into unclear keycodes(usages) of Fn-chording-key on HHKB.
|
||||||
|
Followings are usages of Keyboard/Keypad Page(0x07) that HHKB spits out when Fn key is down.
|
||||||
|
|
||||||
|
## HHK mode(Off-Off)
|
||||||
|
Key Usage
|
||||||
|
------------------------
|
||||||
|
⌘ / ◇ 0x78 Stop
|
||||||
|
|
||||||
|
## Lite Ext. mode(On-Off)
|
||||||
|
|
||||||
|
|
||||||
|
## Mac mode(Off-On)
|
||||||
|
Key Usage
|
||||||
|
------------------------
|
||||||
|
Esc 0x66 Power
|
||||||
|
A 0x81 Volume Down
|
||||||
|
S 0x80 Volume Up
|
||||||
|
D 0x7F Mute
|
||||||
|
F 0x6F F20
|
||||||
|
Delete 0x53 Num Lock and Clear
|
||||||
|
|
||||||
|
|
||||||
|
## Secret mode(On-On)
|
||||||
|
Key Usage
|
||||||
|
------------------------
|
||||||
|
Esc 0x66 Power
|
||||||
|
Q 0x78 Stop
|
||||||
|
W 0x7E Find
|
||||||
|
E 0x74 Execute
|
||||||
|
R 0x77 Select
|
||||||
|
T 0x76 Menu
|
||||||
|
Y 0x75 Help
|
||||||
|
Z 0x7A Undo
|
||||||
|
X 0x7B Cut
|
||||||
|
C 0x7C Copy
|
||||||
|
V 0x7D Paste
|
||||||
|
B 0x79 Again
|
||||||
|
|
||||||
|
|
||||||
|
## Matrix Key-Mode
|
||||||
|
|
||||||
|
|
||||||
|
Mode
|
||||||
|
-------------------------------
|
||||||
|
Key HHK Lite Mac Secret Desc
|
||||||
|
---------------------------------------------------------------------------------------
|
||||||
|
⌘ / ◇ 0x78 - - - Stop
|
||||||
|
Esc - - 0x66 0x66 Power
|
||||||
|
A - - 0x81 - Volume Down
|
||||||
|
S - - 0x80 - Volume Up
|
||||||
|
D - - 0x7F - Mute
|
||||||
|
F - - 0x6F - F20
|
||||||
|
Delete 0x2A 0x2A 0x53 0x2A Num Lock and Clear(0x53)/Backspace(0x2A)
|
||||||
|
Q - - - 0x78 Stop
|
||||||
|
W - - - 0x7E Find
|
||||||
|
E - - - 0x74 Execute
|
||||||
|
R - - - 0x77 Select
|
||||||
|
T - - - 0x76 Menu
|
||||||
|
Y - - - 0x75 Help
|
||||||
|
Z - - - 0x7A Undo
|
||||||
|
X - - - 0x7B Cut
|
||||||
|
C - - - 0x7C Copy
|
||||||
|
V - - - 0x7D Paste
|
||||||
|
B - - - 0x79 Again
|
||||||
|
|
||||||
|
EOF
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue