Merge pull request #730 from IBNobody/master

Change NKRO Report Size = 32, User Print
This commit is contained in:
Jack Humbert 2016-09-08 17:48:54 -04:00 committed by GitHub
commit 4a54ece468
23 changed files with 303 additions and 120 deletions

View File

@ -1,12 +1,12 @@
# Build Options # Build Options
# change to "no" to disable the options, or define them in the Makefile in # change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically # the appropriate keymap folder that will get included automatically
# #
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes # Mouse keys(+4700) MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400) CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality

View File

@ -68,10 +68,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* disable debug print */ /* disable debug print */
//#define NO_DEBUG #ifndef NO_DEBUG
# define NO_DEBUG
#endif
/* disable print */ /* disable print */
//#define NO_PRINT // #ifndef NO_PRINT
// # define NO_PRINT
// #endif
/* Only print user print statements */
#define USER_PRINT
/* disable action features */ /* disable action features */
//#define NO_ACTION_LAYER //#define NO_ACTION_LAYER

View File

@ -83,6 +83,7 @@ enum keyboard_macros {
#define SC_ACLS LALT(KC_F4) #define SC_ACLS LALT(KC_F4)
#define SC_CCLS LCTL(KC_F4) #define SC_CCLS LCTL(KC_F4)
#define TG_NKRO MAGIC_TOGGLE_NKRO
#define OS_SHFT KC_FN0 #define OS_SHFT KC_FN0
#define _______ KC_TRNS #define _______ KC_TRNS
@ -206,7 +207,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_ADJUST] = { [LAYER_ADJUST] = {
{ XXXXXXX, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MU_TOG , AU_TOG }, { XXXXXXX, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, MU_TOG , AU_TOG },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX },
{ XXXXXXX, M_QWRTY, XXXXXXX, XXXXXXX, M_BACKL, RESET , XXXXXXX, M_MOUSE, XXXXXXX, XXXXXXX, MUV_IN , XXXXXXX }, { XXXXXXX, M_QWRTY, XXXXXXX, XXXXXXX, M_BACKL, RESET , TG_NKRO, M_MOUSE, XXXXXXX, XXXXXXX, MUV_IN , XXXXXXX },
{ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_UPPER, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, TMPO_DN, MUV_DE , TMPO_UP } { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_UPPER, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, TMPO_DN, MUV_DE , TMPO_UP }
}, },
@ -236,7 +237,7 @@ void persistant_default_layer_set(uint16_t default_layer)
} }
const uint16_t PROGMEM fn_actions[] = { const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_MODS_ONESHOT(MOD_LSFT), [0] = ACTION_MODS_ONESHOT(MOD_RSFT),
}; };
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)

View File

@ -1,6 +1,9 @@
#include "eeconfig.h" #include "eeconfig.h"
#include "keycode.h" #include "keycode.h"
#ifndef KEYCODE_CONFIG_H
#define KEYCODE_CONFIG_H
uint16_t keycode_config(uint16_t keycode); uint16_t keycode_config(uint16_t keycode);
/* NOTE: Not portable. Bit field order depends on implementation */ /* NOTE: Not portable. Bit field order depends on implementation */
@ -19,3 +22,5 @@ typedef union {
} keymap_config_t; } keymap_config_t;
extern keymap_config_t keymap_config; extern keymap_config_t keymap_config;
#endif /* KEYCODE_CONFIG_H */

View File

@ -111,6 +111,7 @@ enum quantum_keycodes {
MAGIC_UNSWAP_BACKSLASH_BACKSPACE, MAGIC_UNSWAP_BACKSLASH_BACKSPACE,
MAGIC_UNHOST_NKRO, MAGIC_UNHOST_NKRO,
MAGIC_UNSWAP_ALT_GUI, MAGIC_UNSWAP_ALT_GUI,
MAGIC_TOGGLE_NKRO,
// Leader key // Leader key
#ifndef DISABLE_LEADER #ifndef DISABLE_LEADER

View File

@ -199,7 +199,7 @@ bool process_record_quantum(keyrecord_t *record) {
return false; return false;
break; break;
#endif #endif
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO:
if (record->event.pressed) { if (record->event.pressed) {
// MAGIC actions (BOOTMAGIC without the boot) // MAGIC actions (BOOTMAGIC without the boot)
if (!eeconfig_is_enabled()) { if (!eeconfig_is_enabled()) {
@ -207,48 +207,73 @@ bool process_record_quantum(keyrecord_t *record) {
} }
/* keymap config */ /* keymap config */
keymap_config.raw = eeconfig_read_keymap(); keymap_config.raw = eeconfig_read_keymap();
if (keycode == MAGIC_SWAP_CONTROL_CAPSLOCK) { switch (keycode)
keymap_config.swap_control_capslock = 1; {
} else if (keycode == MAGIC_CAPSLOCK_TO_CONTROL) { case MAGIC_SWAP_CONTROL_CAPSLOCK:
keymap_config.capslock_to_control = 1; keymap_config.swap_control_capslock = true;
} else if (keycode == MAGIC_SWAP_LALT_LGUI) { break;
keymap_config.swap_lalt_lgui = 1; case MAGIC_CAPSLOCK_TO_CONTROL:
} else if (keycode == MAGIC_SWAP_RALT_RGUI) { keymap_config.capslock_to_control = true;
keymap_config.swap_ralt_rgui = 1; break;
} else if (keycode == MAGIC_NO_GUI) { case MAGIC_SWAP_LALT_LGUI:
keymap_config.no_gui = 1; keymap_config.swap_lalt_lgui = true;
} else if (keycode == MAGIC_SWAP_GRAVE_ESC) { break;
keymap_config.swap_grave_esc = 1; case MAGIC_SWAP_RALT_RGUI:
} else if (keycode == MAGIC_SWAP_BACKSLASH_BACKSPACE) { keymap_config.swap_ralt_rgui = true;
keymap_config.swap_backslash_backspace = 1; break;
} else if (keycode == MAGIC_HOST_NKRO) { case MAGIC_NO_GUI:
keymap_config.nkro = 1; keymap_config.no_gui = true;
} else if (keycode == MAGIC_SWAP_ALT_GUI) { break;
keymap_config.swap_lalt_lgui = 1; case MAGIC_SWAP_GRAVE_ESC:
keymap_config.swap_ralt_rgui = 1; keymap_config.swap_grave_esc = true;
} break;
/* UNs */ case MAGIC_SWAP_BACKSLASH_BACKSPACE:
else if (keycode == MAGIC_UNSWAP_CONTROL_CAPSLOCK) { keymap_config.swap_backslash_backspace = true;
keymap_config.swap_control_capslock = 0; break;
} else if (keycode == MAGIC_UNCAPSLOCK_TO_CONTROL) { case MAGIC_HOST_NKRO:
keymap_config.capslock_to_control = 0; keymap_config.nkro = true;
} else if (keycode == MAGIC_UNSWAP_LALT_LGUI) { break;
keymap_config.swap_lalt_lgui = 0; case MAGIC_SWAP_ALT_GUI:
} else if (keycode == MAGIC_UNSWAP_RALT_RGUI) { keymap_config.swap_lalt_lgui = true;
keymap_config.swap_ralt_rgui = 0; keymap_config.swap_ralt_rgui = true;
} else if (keycode == MAGIC_UNNO_GUI) { break;
keymap_config.no_gui = 0; case MAGIC_UNSWAP_CONTROL_CAPSLOCK:
} else if (keycode == MAGIC_UNSWAP_GRAVE_ESC) { keymap_config.swap_control_capslock = false;
keymap_config.swap_grave_esc = 0; break;
} else if (keycode == MAGIC_UNSWAP_BACKSLASH_BACKSPACE) { case MAGIC_UNCAPSLOCK_TO_CONTROL:
keymap_config.swap_backslash_backspace = 0; keymap_config.capslock_to_control = false;
} else if (keycode == MAGIC_UNHOST_NKRO) { break;
keymap_config.nkro = 0; case MAGIC_UNSWAP_LALT_LGUI:
} else if (keycode == MAGIC_UNSWAP_ALT_GUI) { keymap_config.swap_lalt_lgui = false;
keymap_config.swap_lalt_lgui = 0; break;
keymap_config.swap_ralt_rgui = 0; case MAGIC_UNSWAP_RALT_RGUI:
keymap_config.swap_ralt_rgui = false;
break;
case MAGIC_UNNO_GUI:
keymap_config.no_gui = false;
break;
case MAGIC_UNSWAP_GRAVE_ESC:
keymap_config.swap_grave_esc = false;
break;
case MAGIC_UNSWAP_BACKSLASH_BACKSPACE:
keymap_config.swap_backslash_backspace = false;
break;
case MAGIC_UNHOST_NKRO:
keymap_config.nkro = false;
break;
case MAGIC_UNSWAP_ALT_GUI:
keymap_config.swap_lalt_lgui = false;
keymap_config.swap_ralt_rgui = false;
break;
case MAGIC_TOGGLE_NKRO:
keymap_config.nkro = !keymap_config.nkro;
break;
default:
break;
} }
eeconfig_update_keymap(keymap_config.raw); eeconfig_update_keymap(keymap_config.raw);
clear_keyboard(); // clear to prevent stuck keys
return false; return false;
} }
break; break;
@ -271,7 +296,7 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_LSFT)); unregister_mods(MOD_BIT(KC_LSFT));
} }
return false; return false;
break; // break;
} }
case KC_RSPC: { case KC_RSPC: {
@ -293,7 +318,7 @@ bool process_record_quantum(keyrecord_t *record) {
unregister_mods(MOD_BIT(KC_RSFT)); unregister_mods(MOD_BIT(KC_RSFT));
} }
return false; return false;
break; // break;
} }
default: { default: {
shift_interrupted[0] = true; shift_interrupted[0] = true;

View File

@ -20,6 +20,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_util.h" #include "action_util.h"
#include "action_layer.h" #include "action_layer.h"
#include "timer.h" #include "timer.h"
#include "keycode_config.h"
extern keymap_config_t keymap_config;
static inline void add_key_byte(uint8_t code); static inline void add_key_byte(uint8_t code);
static inline void del_key_byte(uint8_t code); static inline void del_key_byte(uint8_t code);
@ -139,7 +143,7 @@ void send_keyboard_report(void) {
void add_key(uint8_t key) void add_key(uint8_t key)
{ {
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (keyboard_protocol && keyboard_nkro) { if (keyboard_protocol && keymap_config.nkro) {
add_key_bit(key); add_key_bit(key);
return; return;
} }
@ -150,7 +154,7 @@ void add_key(uint8_t key)
void del_key(uint8_t key) void del_key(uint8_t key)
{ {
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (keyboard_protocol && keyboard_nkro) { if (keyboard_protocol && keymap_config.nkro) {
del_key_bit(key); del_key_bit(key);
return; return;
} }
@ -231,7 +235,7 @@ uint8_t has_anymod(void)
uint8_t get_first_key(void) uint8_t get_first_key(void)
{ {
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (keyboard_protocol && keyboard_nkro) { if (keyboard_protocol && keymap_config.nkro) {
uint8_t i = 0; uint8_t i = 0;
for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++) for (; i < KEYBOARD_REPORT_BITS && !keyboard_report->nkro.bits[i]; i++)
; ;

View File

@ -56,8 +56,8 @@ void xitoa(long value, char radix, char width);
#define xfprintf(func, format, ...) __xfprintf(func, PSTR(format), ##__VA_ARGS__) #define xfprintf(func, format, ...) __xfprintf(func, PSTR(format), ##__VA_ARGS__)
void __xprintf(const char *format_p, ...); /* Send formatted string to the registered device */ void __xprintf(const char *format_p, ...); /* Send formatted string to the registered device */
void __xsprintf(char*, const char *format_p, ...); /* Put formatted string to the memory */ // void __xsprintf(char*, const char *format_p, ...); /* Put formatted string to the memory */
void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send formatted string to the specified device */ // void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send formatted string to the specified device */
/* Format string is placed in the ROM. The format flags is similar to printf(). /* Format string is placed in the ROM. The format flags is similar to printf().
@ -88,7 +88,7 @@ void __xfprintf(void(*func)(uint8_t), const char *format_p, ...); /* Send format
/*-----------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------*/
char xatoi(char **str, long *ret); char xatoi(char **str, long *ret);
/* Get value of the numeral string. /* Get value of the numeral string.
str str
Pointer to pointer to source string Pointer to pointer to source string

View File

@ -83,10 +83,6 @@ void bootmagic(void)
} }
eeconfig_update_keymap(keymap_config.raw); eeconfig_update_keymap(keymap_config.raw);
#ifdef NKRO_ENABLE
keyboard_nkro = keymap_config.nkro;
#endif
/* default layer */ /* default layer */
uint8_t default_layer = 0; uint8_t default_layer = 0;
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); }

View File

@ -238,7 +238,7 @@ static void print_status(void)
print_val_hex8(keyboard_protocol); print_val_hex8(keyboard_protocol);
print_val_hex8(keyboard_idle); print_val_hex8(keyboard_idle);
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
print_val_hex8(keyboard_nkro); print_val_hex8(keymap_config.nkro);
#endif #endif
print_val_hex32(timer_read32()); print_val_hex32(timer_read32());
@ -435,8 +435,8 @@ static bool command_common(uint8_t code)
// NKRO toggle // NKRO toggle
case MAGIC_KC(MAGIC_KEY_NKRO): case MAGIC_KC(MAGIC_KEY_NKRO):
clear_keyboard(); // clear to prevent stuck keys clear_keyboard(); // clear to prevent stuck keys
keyboard_nkro = !keyboard_nkro; keymap_config.nkro = !keymap_config.nkro;
if (keyboard_nkro) { if (keymap_config.nkro) {
print("NKRO: on\n"); print("NKRO: on\n");
} else { } else {
print("NKRO: off\n"); print("NKRO: off\n");

View File

@ -22,11 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "util.h" #include "util.h"
#include "debug.h" #include "debug.h"
#ifdef NKRO_ENABLE
bool keyboard_nkro = true;
#endif
static host_driver_t *driver; static host_driver_t *driver;
static uint16_t last_system_report = 0; static uint16_t last_system_report = 0;
static uint16_t last_consumer_report = 0; static uint16_t last_consumer_report = 0;

View File

@ -28,10 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
extern "C" { extern "C" {
#endif #endif
#ifdef NKRO_ENABLE
extern bool keyboard_nkro;
#endif
extern uint8_t keyboard_idle; extern uint8_t keyboard_idle;
extern uint8_t keyboard_protocol; extern uint8_t keyboard_protocol;

View File

@ -57,6 +57,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# include "visualizer/visualizer.h" # include "visualizer/visualizer.h"
#endif #endif
#ifdef MATRIX_HAS_GHOST #ifdef MATRIX_HAS_GHOST
static bool has_ghost_in_row(uint8_t row) static bool has_ghost_in_row(uint8_t row)
{ {
@ -106,7 +108,7 @@ void keyboard_init(void) {
rgblight_init(); rgblight_init();
#endif #endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO) #if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keyboard_nkro = true; keymap_config.nkro = 1;
#endif #endif
} }

View File

@ -27,10 +27,6 @@ void magic(void)
/* keymap config */ /* keymap config */
keymap_config.raw = eeconfig_read_keymap(); keymap_config.raw = eeconfig_read_keymap();
#ifdef NKRO_ENABLE
keyboard_nkro = keymap_config.nkro;
#endif
uint8_t default_layer = 0; uint8_t default_layer = 0;
default_layer = eeconfig_read_default_layer(); default_layer = eeconfig_read_default_layer();
default_layer_set((uint32_t)default_layer); default_layer_set((uint32_t)default_layer);

View File

@ -7,7 +7,7 @@
#define STRING_STACK_LIMIT 120 #define STRING_STACK_LIMIT 120
//TODO //TODO
int xprintf(const char* format, ...) { return 0; } int __xprintf(const char* format, ...) { return 0; }
#if 0 #if 0
/* mbed Serial */ /* mbed Serial */

View File

@ -7,7 +7,7 @@
extern "C" { extern "C" {
#endif #endif
int xprintf(const char *format, ...); int __xprintf(const char *format, ...);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -36,40 +36,140 @@
#ifndef NO_PRINT #ifndef NO_PRINT
#if defined(__AVR__) /* __AVR__ */
#if defined(__AVR__) # include "avr/xprintf.h"
#include "avr/xprintf.h" # ifdef USER_PRINT /* USER_PRINT */
#define print(s) xputs(PSTR(s))
#define println(s) xputs(PSTR(s "\r\n"))
#ifdef __cplusplus // Remove normal print defines
# define print(s)
# define println(s)
# undef xprintf
# define xprintf(fmt, ...)
// Create user print defines
# define uprint(s) xputs(PSTR(s))
# define uprintln(s) xputs(PSTR(s "\r\n"))
# define uprintf(fmt, ...) __xprintf(PSTR(fmt), ##__VA_ARGS__)
# else /* NORMAL PRINT */
// Create user & normal print defines
# define print(s) xputs(PSTR(s))
# define println(s) xputs(PSTR(s "\r\n"))
# define uprint(s) print(s)
# define uprintln(s) println(s)
# define uprintf(fmt, ...) xprintf(fmt, ...)
# endif /* USER_PRINT / NORMAL PRINT */
# ifdef __cplusplus
extern "C" extern "C"
#endif # endif
/* function pointer of sendchar to be used by print utility */ /* function pointer of sendchar to be used by print utility */
void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t)); void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
#elif defined(PROTOCOL_CHIBIOS) /* __AVR__ */ #elif defined(PROTOCOL_CHIBIOS) /* PROTOCOL_CHIBIOS */
#include "chibios/printf.h" # include "chibios/printf.h"
#define print(s) printf(s) # ifdef USER_PRINT /* USER_PRINT */
#define println(s) printf(s "\r\n")
#define xprintf printf
#elif defined(__arm__) /* __AVR__ */ // Remove normal print defines
# define print(s)
# define println(s)
# define xprintf(fmt, ...)
#include "mbed/xprintf.h" // Create user print defines
# define uprint(s) printf(s)
# define uprintln(s) printf(s "\r\n")
# define uprintf printf
#define print(s) xprintf(s) # else /* NORMAL PRINT */
#define println(s) xprintf(s "\r\n")
// Create user & normal print defines
# define print(s) printf(s)
# define println(s) printf(s "\r\n")
# define xprintf printf
# define uprint(s) printf(s)
# define uprintln(s) printf(s "\r\n")
# define uprintf printf
# endif /* USER_PRINT / NORMAL PRINT */
#elif defined(__arm__) /* __arm__ */
# include "mbed/xprintf.h"
# ifdef USER_PRINT /* USER_PRINT */
// Remove normal print defines
# define print(s)
# define println(s)
# define xprintf(fmt, ...)
// Create user print defines
# define uprintf(fmt, ...) __xprintf(fmt, ...)
# define uprint(s) xprintf(s)
# define uprintln(s) xprintf(s "\r\n")
# else /* NORMAL PRINT */
// Create user & normal print defines
# define xprintf(fmt, ...) __xprintf(fmt, ...)
# define print(s) xprintf(s)
# define println(s) xprintf(s "\r\n")
# define uprint(s) print(s)
# define uprintln(s) println(s)
# define uprintf(fmt, ...) xprintf(fmt, ...)
# endif /* USER_PRINT / NORMAL PRINT */
/* TODO: to select output destinations: UART/USBSerial */ /* TODO: to select output destinations: UART/USBSerial */
#define print_set_sendchar(func) # define print_set_sendchar(func)
#endif /* __AVR__ */ #endif /* __AVR__ / PROTOCOL_CHIBIOS / __arm__ */
// User print disables the normal print messages in the body of QMK/TMK code and
// is meant as a lightweight alternative to NOPRINT. Use it when you only want to do
// a spot of debugging but lack flash resources for allowing all of the codebase to
// print (and store their wasteful strings).
//
// !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!!
//
#ifdef USER_PRINT
// Disable normal print
#define print_dec(data)
#define print_decs(data)
#define print_hex4(data)
#define print_hex8(data)
#define print_hex16(data)
#define print_hex32(data)
#define print_bin4(data)
#define print_bin8(data)
#define print_bin16(data)
#define print_bin32(data)
#define print_bin_reverse8(data)
#define print_bin_reverse16(data)
#define print_bin_reverse32(data)
#define print_val_dec(v)
#define print_val_decs(v)
#define print_val_hex8(v)
#define print_val_hex16(v)
#define print_val_hex32(v)
#define print_val_bin8(v)
#define print_val_bin16(v)
#define print_val_bin32(v)
#define print_val_bin_reverse8(v)
#define print_val_bin_reverse16(v)
#define print_val_bin_reverse32(v)
#else /* NORMAL_PRINT */
//Enable normal print
/* decimal */ /* decimal */
#define print_dec(i) xprintf("%u", i) #define print_dec(i) xprintf("%u", i)
#define print_decs(i) xprintf("%d", i) #define print_decs(i) xprintf("%d", i)
@ -99,6 +199,39 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
#define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) #define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v))
#define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) #define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v))
#endif /* USER_PRINT / NORMAL_PRINT */
// User Print
/* decimal */
#define uprint_dec(i) uprintf("%u", i)
#define uprint_decs(i) uprintf("%d", i)
/* hex */
#define uprint_hex4(i) uprintf("%X", i)
#define uprint_hex8(i) uprintf("%02X", i)
#define uprint_hex16(i) uprintf("%04X", i)
#define uprint_hex32(i) uprintf("%08lX", i)
/* binary */
#define uprint_bin4(i) uprintf("%04b", i)
#define uprint_bin8(i) uprintf("%08b", i)
#define uprint_bin16(i) uprintf("%016b", i)
#define uprint_bin32(i) uprintf("%032lb", i)
#define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i))
#define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i))
#define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i))
/* print value utility */
#define uprint_val_dec(v) uprintf(#v ": %u\n", v)
#define uprint_val_decs(v) uprintf(#v ": %d\n", v)
#define uprint_val_hex8(v) uprintf(#v ": %X\n", v)
#define uprint_val_hex16(v) uprintf(#v ": %02X\n", v)
#define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v)
#define uprint_val_bin8(v) uprintf(#v ": %08b\n", v)
#define uprint_val_bin16(v) uprintf(#v ": %016b\n", v)
#define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v)
#define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v))
#define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v))
#define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v))
#else /* NO_PRINT */ #else /* NO_PRINT */
#define xprintf(fmt, ...) #define xprintf(fmt, ...)
@ -143,5 +276,4 @@ void print_set_sendchar(int8_t (*print_sendchar_func)(uint8_t));
#define pbin_reverse(data) print_bin_reverse8(data) #define pbin_reverse(data) print_bin_reverse8(data)
#define pbin_reverse16(data) print_bin_reverse16(data) #define pbin_reverse16(data) print_bin_reverse16(data)
#endif #endif

View File

@ -28,6 +28,12 @@
#include "led.h" #include "led.h"
#endif #endif
#ifdef NKRO_ENABLE
#include "keycode_config.h"
extern keymap_config_t keymap_config;
#endif
/* --------------------------------------------------------- /* ---------------------------------------------------------
* Global interface variables and declarations * Global interface variables and declarations
* --------------------------------------------------------- * ---------------------------------------------------------
@ -39,9 +45,6 @@ uint16_t keyboard_led_stats __attribute__((aligned(2))) = 0;
volatile uint16_t keyboard_idle_count = 0; volatile uint16_t keyboard_idle_count = 0;
static virtual_timer_t keyboard_idle_timer; static virtual_timer_t keyboard_idle_timer;
static void keyboard_idle_timer_cb(void *arg); static void keyboard_idle_timer_cb(void *arg);
#ifdef NKRO_ENABLE
extern bool keyboard_nkro;
#endif /* NKRO_ENABLE */
report_keyboard_t keyboard_report_sent = {{0}}; report_keyboard_t keyboard_report_sent = {{0}};
#ifdef MOUSE_ENABLE #ifdef MOUSE_ENABLE
@ -943,8 +946,8 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
if((usbp->setup[4] == KBD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */ if((usbp->setup[4] == KBD_INTERFACE) && (usbp->setup[5] == 0)) { /* wIndex */
keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */ keyboard_protocol = ((usbp->setup[2]) != 0x00); /* LSB(wValue) */
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
keyboard_nkro = !!keyboard_protocol; keymap_config.nkro = !!keyboard_protocol;
if(!keyboard_nkro && keyboard_idle) { if(!keymap_config.nkro && keyboard_idle) {
#else /* NKRO_ENABLE */ #else /* NKRO_ENABLE */
if(keyboard_idle) { if(keyboard_idle) {
#endif /* NKRO_ENABLE */ #endif /* NKRO_ENABLE */
@ -962,7 +965,7 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
keyboard_idle = usbp->setup[3]; /* MSB(wValue) */ keyboard_idle = usbp->setup[3]; /* MSB(wValue) */
/* arm the timer */ /* arm the timer */
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if(!keyboard_nkro && keyboard_idle) { if(!keymap_config.nkro && keyboard_idle) {
#else /* NKRO_ENABLE */ #else /* NKRO_ENABLE */
if(keyboard_idle) { if(keyboard_idle) {
#endif /* NKRO_ENABLE */ #endif /* NKRO_ENABLE */
@ -1089,7 +1092,7 @@ static void keyboard_idle_timer_cb(void *arg) {
} }
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if(!keyboard_nkro && keyboard_idle) { if(!keymap_config.nkro && keyboard_idle) {
#else /* NKRO_ENABLE */ #else /* NKRO_ENABLE */
if(keyboard_idle) { if(keyboard_idle) {
#endif /* NKRO_ENABLE */ #endif /* NKRO_ENABLE */
@ -1122,7 +1125,7 @@ void send_keyboard(report_keyboard_t *report) {
osalSysUnlock(); osalSysUnlock();
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if(keyboard_nkro) { /* NKRO protocol */ if(keymap_config.nkro) { /* NKRO protocol */
/* need to wait until the previous packet has made it through */ /* need to wait until the previous packet has made it through */
/* can rewrite this using the synchronous API, then would wait /* can rewrite this using the synchronous API, then would wait
* until *after* the packet has been transmitted. I think * until *after* the packet has been transmitted. I think

View File

@ -1,4 +1,4 @@
/* /*
* Copyright 2012,2013 Jun Wako <wakojun@gmail.com> * Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
* This file is based on: * This file is based on:
* LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse * LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
@ -129,13 +129,13 @@ typedef struct
# define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1) # define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1)
#else #else
# define MOUSE_INTERFACE KEYBOARD_INTERFACE # define MOUSE_INTERFACE KEYBOARD_INTERFACE
#endif #endif
#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
# define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1) # define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1)
#else #else
# define EXTRAKEY_INTERFACE MOUSE_INTERFACE # define EXTRAKEY_INTERFACE MOUSE_INTERFACE
#endif #endif
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
# define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1) # define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1)
@ -171,7 +171,7 @@ typedef struct
#define KEYBOARD_IN_EPNUM 1 #define KEYBOARD_IN_EPNUM 1
#ifdef MOUSE_ENABLE #ifdef MOUSE_ENABLE
# define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) # define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1)
#else #else
# define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM # define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM
#endif #endif
@ -179,7 +179,7 @@ typedef struct
#ifdef EXTRAKEY_ENABLE #ifdef EXTRAKEY_ENABLE
# define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) # define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1)
#else #else
# define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM # define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM
#endif #endif
#ifdef CONSOLE_ENABLE #ifdef CONSOLE_ENABLE
@ -226,7 +226,7 @@ typedef struct
#define MOUSE_EPSIZE 8 #define MOUSE_EPSIZE 8
#define EXTRAKEY_EPSIZE 8 #define EXTRAKEY_EPSIZE 8
#define CONSOLE_EPSIZE 32 #define CONSOLE_EPSIZE 32
#define NKRO_EPSIZE 16 #define NKRO_EPSIZE 32
#define MIDI_STREAM_EPSIZE 64 #define MIDI_STREAM_EPSIZE 64
#define CDC_NOTIFICATION_EPSIZE 8 #define CDC_NOTIFICATION_EPSIZE 8
#define CDC_EPSIZE 16 #define CDC_EPSIZE 16

View File

@ -52,6 +52,13 @@
#include "descriptor.h" #include "descriptor.h"
#include "lufa.h" #include "lufa.h"
#ifdef NKRO_ENABLE
#include "keycode_config.h"
extern keymap_config_t keymap_config;
#endif
#ifdef AUDIO_ENABLE #ifdef AUDIO_ENABLE
#include <audio.h> #include <audio.h>
#endif #endif
@ -502,7 +509,7 @@ static void send_keyboard(report_keyboard_t *report)
/* Select the Keyboard Report Endpoint */ /* Select the Keyboard Report Endpoint */
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (keyboard_protocol && keyboard_nkro) { if (keyboard_protocol && keymap_config.nkro) {
/* Report protocol - NKRO */ /* Report protocol - NKRO */
Endpoint_SelectEndpoint(NKRO_IN_EPNUM); Endpoint_SelectEndpoint(NKRO_IN_EPNUM);

View File

@ -1,17 +1,17 @@
/* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board /* USB Keyboard Plus Debug Channel Example for Teensy USB Development Board
* http://www.pjrc.com/teensy/usb_keyboard.html * http://www.pjrc.com/teensy/usb_keyboard.html
* Copyright (c) 2009 PJRC.COM, LLC * Copyright (c) 2009 PJRC.COM, LLC
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -41,6 +41,12 @@
#include "action.h" #include "action.h"
#include "action_util.h" #include "action_util.h"
#ifdef NKRO_ENABLE
#include "keycode_config.h"
extern keymap_config_t keymap_config;
#endif
/************************************************************************** /**************************************************************************
* *
@ -694,7 +700,7 @@ ISR(USB_GEN_vect)
} }
/* TODO: should keep IDLE rate on each keyboard interface */ /* TODO: should keep IDLE rate on each keyboard interface */
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (!keyboard_nkro && keyboard_idle && (++div4 & 3) == 0) { if (!keymap_config.nkro && keyboard_idle && (++div4 & 3) == 0) {
#else #else
if (keyboard_idle && (++div4 & 3) == 0) { if (keyboard_idle && (++div4 & 3) == 0) {
#endif #endif
@ -881,7 +887,7 @@ ISR(USB_COM_vect)
#endif #endif
if (bmRequestType == 0x00 && wValue == DEVICE_REMOTE_WAKEUP) { if (bmRequestType == 0x00 && wValue == DEVICE_REMOTE_WAKEUP) {
if (bRequest == SET_FEATURE) { if (bRequest == SET_FEATURE) {
remote_wakeup = true; remote_wakeup = true;
} else { } else {
remote_wakeup = false; remote_wakeup = false;
} }
@ -932,7 +938,7 @@ ISR(USB_COM_vect)
if (bRequest == HID_SET_PROTOCOL) { if (bRequest == HID_SET_PROTOCOL) {
keyboard_protocol = wValue; keyboard_protocol = wValue;
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
keyboard_nkro = !!keyboard_protocol; keymap_config.nkro = !!keyboard_protocol;
#endif #endif
clear_keyboard(); clear_keyboard();
//usb_wait_in_ready(); //usb_wait_in_ready();

View File

@ -30,6 +30,12 @@
#include "util.h" #include "util.h"
#include "host.h" #include "host.h"
#ifdef NKRO_ENABLE
#include "keycode_config.h"
extern keymap_config_t keymap_config;
#endif
// protocol setting from the host. We use exactly the same report // protocol setting from the host. We use exactly the same report
// either way, so this variable only stores the setting since we // either way, so this variable only stores the setting since we
@ -56,7 +62,7 @@ int8_t usb_keyboard_send_report(report_keyboard_t *report)
int8_t result = 0; int8_t result = 0;
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
if (keyboard_nkro) if (keymap_config.nkro)
result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE); result = send_report(report, KBD2_ENDPOINT, 0, KBD2_SIZE);
else else
#endif #endif

View File

@ -23,7 +23,7 @@ These features can be used in your keyboard.
* Mouse key - Mouse control with keyboard * Mouse key - Mouse control with keyboard
* System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up * System Control Key - Power Down, Sleep, Wake Up and USB Remote Wake up
* Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc * Media Control Key - Volume Down/Up, Mute, Next/Prev track, Play, Stop and etc
* USB NKRO - 120 keys(+ 8 modifiers) simultaneously * USB NKRO - 240 keys(+ 8 modifiers) simultaneously
* PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device * PS/2 mouse support - PS/2 mouse(TrackPoint) as composite device
* Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols * Keyboard protocols - PS/2, ADB, M0110, Sun and other old keyboard protocols
* User Function - Customizable function of key with writing code * User Function - Customizable function of key with writing code