├── src ├── .gitignore ├── lib │ ├── readme.md │ ├── key-functions │ │ ├── readme.md │ │ ├── private.h │ │ ├── public │ │ │ ├── device.c │ │ │ ├── special.c │ │ │ └── basic.c │ │ ├── public.h │ │ └── private.c │ ├── data-types │ │ └── misc.h │ ├── variable-include.h │ ├── twi.h │ ├── twi │ │ ├── teensy-2-0.h │ │ ├── teensy-2-0.md │ │ └── teensy-2-0.c │ └── usb │ │ ├── notes from hid device class definition 1.11.md │ │ ├── common.h │ │ ├── TODO.c │ │ └── usage-page │ │ ├── led.h │ │ ├── keyboard--short-names.h │ │ └── keyboard.h ├── keyboard │ ├── ergodox │ │ ├── layout.md │ │ ├── layout.h │ │ ├── controller │ │ │ ├── teensy-2-0--functions.h │ │ │ ├── mcp23018--functions.h │ │ │ ├── teensy-2-0--led.h │ │ │ ├── mcp23018.c │ │ │ ├── mcp23018.md │ │ │ ├── teensy-2-0.md │ │ │ └── teensy-2-0.c │ │ ├── controller.h │ │ ├── layout │ │ │ ├── norman-mod.h │ │ │ ├── colemak-jc-mod.h │ │ │ ├── dvorak-kinesis-mod.h │ │ │ ├── qwerty-kinesis-mod.h │ │ │ ├── colemak-symbol-mod.h │ │ │ ├── norman-symbol-mod.h │ │ │ ├── default--led-control.h │ │ │ ├── default--matrix-control.h │ │ │ ├── colemak-jc-mod.c │ │ │ ├── dvorak-kinesis-mod.c │ │ │ └── qwerty-kinesis-mod.c │ │ ├── controller.c │ │ ├── options.h │ │ └── matrix.h │ ├── layout.h │ ├── matrix.h │ └── controller.h ├── lib-other │ └── pjrc │ │ ├── readme.md │ │ └── usb_keyboard │ │ └── usb_keyboard.h ├── makefile-options ├── main.h ├── makefile └── main.c ├── contrib └── readme.md ├── license.md └── makefile /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.eep 2 | *.elf 3 | *.hex 4 | *.map 5 | *.o 6 | *.o.dep 7 | 8 | -------------------------------------------------------------------------------- /contrib/readme.md: -------------------------------------------------------------------------------- 1 | This directory is for projects closely related to the firmware. 2 | 3 | -------------------------------------------------------------------------------- /src/lib/readme.md: -------------------------------------------------------------------------------- 1 | # src/lib 2 | Stuff that's generally useful 3 | 4 | ------------------------------------------------------------------------------- 5 | 6 | Copyright © 2012 Ben Blazak 7 | Released under The MIT License (MIT) (see "license.md") 8 | Project located at 9 | 10 | -------------------------------------------------------------------------------- /src/lib/key-functions/readme.md: -------------------------------------------------------------------------------- 1 | # src/lib/key-functions 2 | 3 | These functions may do.. pretty much anything rational that they like. If they 4 | want keycodes to be sent to the host in an aggregate report, they're responsible 5 | for modifying the appropriate report variables. 6 | 7 | ------------------------------------------------------------------------------- 8 | 9 | Copyright © 2012 Ben Blazak 10 | Released under The MIT License (MIT) (see "license.md") 11 | Project located at 12 | 13 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout.md: -------------------------------------------------------------------------------- 1 | # Documentation : layout 2 | 3 | Different layouts are included by modifying a variable in the makefile. 4 | 5 | 6 | ## notes 7 | 8 | * Each full layer takes 420 bytes of memory (the matrix size is 12x7, keycodes 9 | are 1 byte each, and function pointers are 2 bytes each). 10 | 11 | ------------------------------------------------------------------------------- 12 | 13 | Copyright © 2012 Ben Blazak 14 | Released under The MIT License (MIT) (see "license.md") 15 | Project located at 16 | 17 | -------------------------------------------------------------------------------- /src/lib/data-types/misc.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * miscellaneous data types 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef LIB__DATA_TYPES_h 11 | #define LIB__DATA_TYPES_h 12 | 13 | typedef void (*void_funptr_t)(void); 14 | 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/lib/variable-include.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Macros to help with conditional includes 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #undef INCLUDE 11 | #define STR(s) #s // stringify 12 | #define EXP_STR(s) STR(s) // expand -> stringify 13 | 14 | -------------------------------------------------------------------------------- /src/keyboard/layout.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * layout specific exports 3 | * 4 | * Files for different keyboards are used by modifying a variable in the 5 | * Makefile 6 | * ---------------------------------------------------------------------------- 7 | * Copyright (c) 2012 Ben Blazak 8 | * Released under The MIT License (MIT) (see "license.md") 9 | * Project located at 10 | * ------------------------------------------------------------------------- */ 11 | 12 | 13 | #include "../lib/variable-include.h" 14 | #define INCLUDE EXP_STR( ./MAKEFILE_KEYBOARD/layout.h ) 15 | #include INCLUDE 16 | 17 | -------------------------------------------------------------------------------- /src/keyboard/matrix.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * matrix specific exports 3 | * 4 | * Files for different keyboards are used by modifying a variable in the 5 | * Makefile 6 | * ---------------------------------------------------------------------------- 7 | * Copyright (c) 2012 Ben Blazak 8 | * Released under The MIT License (MIT) (see "license.md") 9 | * Project located at 10 | * ------------------------------------------------------------------------- */ 11 | 12 | 13 | #include "../lib/variable-include.h" 14 | #define INCLUDE EXP_STR( ./MAKEFILE_KEYBOARD/matrix.h ) 15 | #include INCLUDE 16 | 17 | -------------------------------------------------------------------------------- /src/lib-other/pjrc/readme.md: -------------------------------------------------------------------------------- 1 | # src/lib/pjrc 2 | 3 | ## links to original files 4 | 5 | * [pjrc] (http://pjrc.com/teensy/) 6 | * [usb_keyboard] (http://pjrc.com/teensy/usb_keyboard.zip) 7 | 13 | 14 | ------------------------------------------------------------------------------- 15 | 16 | Copyright © 2012 Ben Blazak 17 | Released under The MIT License (MIT) (see "license.md") 18 | Project located at 19 | 20 | -------------------------------------------------------------------------------- /src/lib/twi.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * TWI (I2C) : exports 3 | * 4 | * Code specific to different development boards is used by modifying a 5 | * variable in the makefile. 6 | * ---------------------------------------------------------------------------- 7 | * Copyright (c) 2012 Ben Blazak 8 | * Released under The MIT License (MIT) (see "license.md") 9 | * Project located at 10 | * ------------------------------------------------------------------------- */ 11 | 12 | 13 | #include "../lib/variable-include.h" 14 | #define INCLUDE EXP_STR( ./twi/MAKEFILE_BOARD.h ) 15 | #include INCLUDE 16 | 17 | -------------------------------------------------------------------------------- /src/keyboard/controller.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * controller specific exports 3 | * 4 | * Files for different keyboards are used by modifying a variable in the 5 | * Makefile 6 | * ---------------------------------------------------------------------------- 7 | * Copyright (c) 2012 Ben Blazak 8 | * Released under The MIT License (MIT) (see "license.md") 9 | * Project located at 10 | * ------------------------------------------------------------------------- */ 11 | 12 | 13 | #include "../lib/variable-include.h" 14 | #define INCLUDE EXP_STR( ./MAKEFILE_KEYBOARD/controller.h ) 15 | #include INCLUDE 16 | 17 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout exports 3 | * 4 | * Different layouts are included by modifying a variable in the makefile. 5 | * ---------------------------------------------------------------------------- 6 | * Copyright (c) 2012 Ben Blazak 7 | * Released under The MIT License (MIT) (see "license.md") 8 | * Project located at 9 | * ------------------------------------------------------------------------- */ 10 | 11 | 12 | #ifndef KEYBOARD__ERGODOX__LAYOUT_h 13 | #define KEYBOARD__ERGODOX__LAYOUT_h 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | // include the appropriate keyboard layout header 18 | #include "../../lib/variable-include.h" 19 | #define INCLUDE EXP_STR( ./layout/MAKEFILE_KEYBOARD_LAYOUT.h ) 20 | #include INCLUDE 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/teensy-2-0--functions.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller : Teensy 2.0 specific exports : functions 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__CONTROLLER__TEENSY_2_0__FUNCTIONS_h 11 | #define KEYBOARD__ERGODOX__CONTROLLER__TEENSY_2_0__FUNCTIONS_h 12 | 13 | #include 14 | #include 15 | #include "../matrix.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | uint8_t teensy_init(void); 20 | uint8_t teensy_update_matrix( bool matrix[KB_ROWS][KB_COLUMNS] ); 21 | 22 | #endif 23 | 24 | -------------------------------------------------------------------------------- /src/lib/twi/teensy-2-0.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Very simple Teensy 2.0 TWI library : exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef TWI_h 11 | #define TWI_h 12 | 13 | // -------------------------------------------------------------------- 14 | 15 | #ifndef TWI_FREQ 16 | #define TWI_FREQ 100000 // in Hz 17 | #endif 18 | 19 | // -------------------------------------------------------------------- 20 | 21 | void twi_init (void); 22 | uint8_t twi_start (void); 23 | void twi_stop (void); 24 | uint8_t twi_send (uint8_t data); 25 | uint8_t twi_read (uint8_t * data); 26 | 27 | #endif 28 | 29 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller specific exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__CONTROLLER_h 11 | #define KEYBOARD__ERGODOX__CONTROLLER_h 12 | 13 | #include 14 | #include 15 | #include "./matrix.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | #include "./controller/teensy-2-0--led.h" 20 | 21 | // -------------------------------------------------------------------- 22 | 23 | uint8_t kb_init(void); 24 | uint8_t kb_update_matrix(bool matrix[KB_ROWS][KB_COLUMNS]); 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/lib/usb/notes from hid device class definition 1.11.md: -------------------------------------------------------------------------------- 1 | # Notes from the HID Device Class Definition, version 1.11 2 | 3 | 4 | * sec 4.1 (The HID Class) 5 | * The `bInterfaceClass` member of an Interface descriptor is always 3 for 6 | HID class devices. 7 | 8 | * sec 4.2 (Subclass) 9 | * The `bInterfaceSubClass` member declares whether a device supports a boot interface. 10 | * 0 => no subclass 11 | * 1 => boot interface subclass 12 | * 2..255 => reserved 13 | 14 | * sec 4.3 (Protocols) 15 | * The `bInterfaceProtocol` member of an Interface descriptor only has meaning if the `bInterfaceSubClass` member declares that the device supports a boot interface, otherwise it is 0. 16 | * 0 => none 17 | * 1 => keyboard 18 | * 2 => mouse 19 | * 3..255 => reserved 20 | 21 | 22 | ------------------------------------------------------------------------------- 23 | 24 | Copyright © 2012 Ben Blazak 25 | Released under The MIT License (MIT) (see "license.md") 26 | Project located at 27 | 28 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/mcp23018--functions.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller : MCP23018 specific exports : functions 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__CONTROLLER__MCP23018__FUNCTIONS_h 11 | #define KEYBOARD__ERGODOX__CONTROLLER__MCP23018__FUNCTIONS_h 12 | 13 | #include 14 | #include 15 | #include "../matrix.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | #define MCP23018_TWI_ADDRESS 0b0100000 20 | 21 | // -------------------------------------------------------------------- 22 | 23 | uint8_t mcp23018_init(void); 24 | uint8_t mcp23018_update_matrix( bool matrix[KB_ROWS][KB_COLUMNS] ); 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/lib/key-functions/private.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * key functions : private : exports 3 | * 4 | * Things to be used only by keyfunctions. Exported so layouts can use these 5 | * functions to help define their own, if they like. 6 | * ---------------------------------------------------------------------------- 7 | * Copyright (c) 2012 Ben Blazak 8 | * Released under The MIT License (MIT) (see "license.md") 9 | * Project located at 10 | * ------------------------------------------------------------------------- */ 11 | 12 | 13 | #ifndef LIB__KEY_FUNCTIONS__INTERNAL_h 14 | #define LIB__KEY_FUNCTIONS__INTERNAL_h 15 | 16 | #include 17 | #include 18 | #include "../../keyboard/matrix.h" 19 | 20 | // -------------------------------------------------------------------- 21 | 22 | void _kbfun_press_release (bool press, uint8_t keycode); 23 | bool _kbfun_is_pressed (uint8_t keycode); 24 | void _kbfun_mediakey_press_release (bool press, uint8_t keycode); 25 | 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/makefile-options: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # certain compilations options 3 | # ----------------------------------------------------------------------------- 4 | # Copyright (c) 2012 Ben Blazak 5 | # Released under The MIT License (MIT) (see "license.md") 6 | # Project located at 7 | # ----------------------------------------------------------------------------- 8 | 9 | 10 | TARGET := firmware # the name we want for our program binary 11 | KEYBOARD := ergodox # keyboard model; see "src/keyboard" for what's available 12 | LAYOUT := norman-mod # keyboard layout 13 | # see "src/keyboard/*/layout" for what's 14 | # available 15 | 16 | LED_BRIGHTNESS := 0.5 # a multiplier, with 1 being the max 17 | DEBOUNCE_TIME := 5 # in ms; see keyswitch spec for necessary value; 5ms should 18 | # be good for cherry mx switches 19 | 20 | 21 | # remove whitespace 22 | TARGET := $(strip $(TARGET)) 23 | KEYBOARD := $(strip $(KEYBOARD)) 24 | LAYOUT := $(strip $(LAYOUT)) 25 | DEBOUNCE_TIME := $(strip $(DEBOUNCE_TIME)) 26 | 27 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/norman-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : DEFAULT : exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__DEFAULT_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__DEFAULT_h 12 | 13 | #include "../controller.h" 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | #define kb_led_num_on() _kb_led_1_on() 18 | #define kb_led_num_off() _kb_led_1_off() 19 | #define kb_led_caps_on() _kb_led_2_on() 20 | #define kb_led_caps_off() _kb_led_2_off() 21 | #define kb_led_scroll_on() _kb_led_3_on() 22 | #define kb_led_scroll_off() _kb_led_3_off() 23 | 24 | // -------------------------------------------------------------------- 25 | 26 | #include "./default--led-control.h" 27 | #include "./default--matrix-control.h" 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/colemak-jc-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : DEFAULT : exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__DEFAULT_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__DEFAULT_h 12 | 13 | #include "../controller.h" 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | #define kb_led_num_on() _kb_led_1_on() 18 | #define kb_led_num_off() _kb_led_1_off() 19 | #define kb_led_caps_on() _kb_led_2_on() 20 | #define kb_led_caps_off() _kb_led_2_off() 21 | #define kb_led_scroll_on() _kb_led_3_on() 22 | #define kb_led_scroll_off() _kb_led_3_off() 23 | 24 | // -------------------------------------------------------------------- 25 | 26 | #include "./default--led-control.h" 27 | #include "./default--matrix-control.h" 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/dvorak-kinesis-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : Dvorak : exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__DVORAK_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__DVORAK_h 12 | 13 | #include "../controller.h" 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | #define kb_led_num_on() _kb_led_1_on() 18 | #define kb_led_num_off() _kb_led_1_off() 19 | #define kb_led_caps_on() _kb_led_2_on() 20 | #define kb_led_caps_off() _kb_led_2_off() 21 | #define kb_led_scroll_on() _kb_led_3_on() 22 | #define kb_led_scroll_off() _kb_led_3_off() 23 | 24 | // -------------------------------------------------------------------- 25 | 26 | #include "./default--led-control.h" 27 | #include "./default--matrix-control.h" 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/qwerty-kinesis-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : QWERTY : exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__QWERTY_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__QWERTY_h 12 | 13 | #include "../controller.h" 14 | 15 | // -------------------------------------------------------------------- 16 | 17 | #define kb_led_num_on() _kb_led_1_on() 18 | #define kb_led_num_off() _kb_led_1_off() 19 | #define kb_led_caps_on() _kb_led_2_on() 20 | #define kb_led_caps_off() _kb_led_2_off() 21 | #define kb_led_scroll_on() _kb_led_3_on() 22 | #define kb_led_scroll_off() _kb_led_3_off() 23 | 24 | // -------------------------------------------------------------------- 25 | 26 | #include "./default--led-control.h" 27 | #include "./default--matrix-control.h" 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/colemak-symbol-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : COLEMAK : exports 3 | * 4 | * Submitted by Jason Trill [jjt] (https://github.com/jjt) 5 | * ---------------------------------------------------------------------------- 6 | * Copyright (c) 2012 Ben Blazak 7 | * Released under The MIT License (MIT) (see "license.md") 8 | * Project located at 9 | * ------------------------------------------------------------------------- */ 10 | 11 | 12 | #ifndef KEYBOARD__ERGODOX__LAYOUT__COLEMAK_h 13 | #define KEYBOARD__ERGODOX__LAYOUT__COLEMAK_h 14 | 15 | #include "../controller.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | #define kb_led_num_on() _kb_led_1_on() 20 | #define kb_led_num_off() _kb_led_1_off() 21 | #define kb_led_caps_on() _kb_led_2_on() 22 | #define kb_led_caps_off() _kb_led_2_off() 23 | #define kb_led_scroll_on() _kb_led_3_on() 24 | #define kb_led_scroll_off() _kb_led_3_off() 25 | 26 | // -------------------------------------------------------------------- 27 | 28 | #include "./default--led-control.h" 29 | #include "./default--matrix-control.h" 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/norman-symbol-mod.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : COLEMAK : exports 3 | * 4 | * Submitted by Jason Trill [jjt] (https://github.com/jjt) 5 | * ---------------------------------------------------------------------------- 6 | * Copyright (c) 2012 Ben Blazak 7 | * Released under The MIT License (MIT) (see "license.md") 8 | * Project located at 9 | * ------------------------------------------------------------------------- */ 10 | 11 | 12 | #ifndef KEYBOARD__ERGODOX__LAYOUT__COLEMAK_h 13 | #define KEYBOARD__ERGODOX__LAYOUT__COLEMAK_h 14 | 15 | #include "../controller.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | #define kb_led_num_on() _kb_led_1_on() 20 | #define kb_led_num_off() _kb_led_1_off() 21 | #define kb_led_caps_on() _kb_led_2_on() 22 | #define kb_led_caps_off() _kb_led_2_off() 23 | #define kb_led_scroll_on() _kb_led_3_on() 24 | #define kb_led_scroll_off() _kb_led_3_off() 25 | 26 | // -------------------------------------------------------------------- 27 | 28 | #include "./default--led-control.h" 29 | #include "./default--matrix-control.h" 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller specific code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include "./matrix.h" 13 | #include "./controller/mcp23018--functions.h" 14 | #include "./controller/teensy-2-0--functions.h" 15 | 16 | // ---------------------------------------------------------------------------- 17 | 18 | /* returns 19 | * - success: 0 20 | * - error: number of the function that failed 21 | */ 22 | uint8_t kb_init(void) { 23 | if (teensy_init()) // must be first 24 | return 1; 25 | if (mcp23018_init()) // must be second 26 | return 2; 27 | 28 | return 0; // success 29 | } 30 | 31 | /* returns 32 | * - success: 0 33 | * - error: number of the function that failed 34 | */ 35 | uint8_t kb_update_matrix(bool matrix[KB_ROWS][KB_COLUMNS]) { 36 | if (teensy_update_matrix(matrix)) 37 | return 1; 38 | if (mcp23018_update_matrix(matrix)) 39 | return 2; 40 | 41 | return 0; // success 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/lib/twi/teensy-2-0.md: -------------------------------------------------------------------------------- 1 | # Documentation : I²C : Teensy 2.0 2 | 3 | ## I²C Status Codes (for Master modes) 4 | 5 | ### Master Transmitter (datasheet section 20.8.1, table 20-3) 6 | 7 | * `0x08` A START condition has been transmitted 8 | * `0x10` A repeated START condition has been transmitted 9 | * `0x18` SLA+W has been transmitted; ACK has been received 10 | * `0x20` SLA+W has been transmitted; NOT ACK has been received 11 | * `0x28` Data byte has been transmitted; ACK has been received 12 | * `0x30` Data byte has been transmitted; NOT ACK has been received 13 | * `0x38` Arbitration lost in SLA+W or data bytes 14 | 15 | ### Master Receiver (datasheet section 20.8.2, table 20-4) 16 | 17 | * `0x08` A START condition has been transmitted 18 | * `0x10` A repeated START condition has been transmitted 19 | * `0x38` Arbitration lost in SLA+R or NOT ACK bit 20 | * `0x40` SLA+R has been transmitted; ACK has been received 21 | * `0x48` SLA+R has been transmitted; NOT ACK has been received 22 | * `0x50` Data byte has been received; ACK has been returned 23 | * `0x58` Data byte has been received; NOT ACK has been returned 24 | 25 | ------------------------------------------------------------------------------- 26 | 27 | Copyright © 2012 Ben Blazak 28 | Released under The MIT License (MIT) (see "license.md") 29 | Project located at 30 | 31 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | Retrieved from on 2012-03-10 3 | 4 | This copyright and licence apply to all files in this project, except where 5 | otherwise noted. If you feel that this infringes on any existing intellectual 6 | property, please email me at the address below. 7 | 8 | ------------------------------------------------------------------------------- 9 | 10 | Copyright © 2012 Ben Blazak 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining a copy of 13 | this software and associated documentation files (the "Software"), to deal in 14 | the Software without restriction, including without limitation the rights to 15 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 16 | of the Software, and to permit persons to whom the Software is furnished to do 17 | so, subject to the following conditions: 18 | 19 | The above copyright notice and this permission notice shall be included in all 20 | copies or substantial portions of the Software. 21 | 22 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 | SOFTWARE. 29 | 30 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/options.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : keyboard specific options 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__OPTIONS_h 11 | #define KEYBOARD__ERGODOX__OPTIONS_h 12 | 13 | // -------------------------------------------------------------------- 14 | 15 | /* 16 | * DRIVE_ROWS and DRIVE_COLUMNS 17 | * - Select which pins will drive (alternate between hi-Z and drive 18 | * low) and which will be inputs 19 | * 20 | * Notes 21 | * - You must set exactly one of each 'TEENSY' macro, and of each 22 | * 'MCP23018' macro 23 | * - If you are using internal diodes (inside the key switches)... then 24 | * i don't know what to tell you. You will set one chip to drive 25 | * rows, and the other to drive columns, but i don't have a key 26 | * switch to check which at the moment, and i couldn't seem to find 27 | * it online. 28 | * - If the diode cathode is towards the square solder pad, set 29 | * #define TEENSY__DRIVE_COLUMNS 1 30 | * #define MCP23018__DRIVE_COLUMNS 1 31 | * - If the diode cathode is towards the circular solder pad, set 32 | * #define TEENSY__DRIVE_ROWS 1 33 | * #define MCP23018__DRIVE_ROWS 1 34 | */ 35 | #define TEENSY__DRIVE_ROWS 0 36 | #define TEENSY__DRIVE_COLUMNS 1 37 | #define MCP23018__DRIVE_ROWS 0 38 | #define MCP23018__DRIVE_COLUMNS 1 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * main() : functions and data that may be useful externally 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef MAIN_h 11 | #define MAIN_h 12 | 13 | #include 14 | #include 15 | #include "./keyboard/matrix.h" 16 | 17 | // -------------------------------------------------------------------- 18 | 19 | typedef enum StickyState 20 | { 21 | eStickyNone, 22 | eStickyOnceDown, 23 | eStickyOnceUp, 24 | eStickyLock 25 | } StickyState; 26 | 27 | extern bool (*main_kb_is_pressed)[KB_ROWS][KB_COLUMNS]; 28 | extern bool (*main_kb_was_pressed)[KB_ROWS][KB_COLUMNS]; 29 | 30 | extern uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS]; 31 | 32 | extern uint8_t main_loop_row; 33 | extern uint8_t main_loop_col; 34 | 35 | extern uint8_t main_arg_layer; 36 | extern uint8_t main_arg_layer_offset; 37 | extern uint8_t main_arg_row; 38 | extern uint8_t main_arg_col; 39 | extern bool main_arg_is_pressed; 40 | extern bool main_arg_was_pressed; 41 | extern bool main_arg_any_non_trans_key_pressed; 42 | extern bool main_arg_trans_key_pressed; 43 | 44 | // -------------------------------------------------------------------- 45 | 46 | void main_exec_key (void); 47 | 48 | uint8_t main_layers_peek (uint8_t offset); 49 | uint8_t main_layers_peek_sticky (uint8_t offset); 50 | uint8_t main_layers_push (uint8_t layer, uint8_t sticky); 51 | void main_layers_pop_id (uint8_t id); 52 | uint8_t main_layers_get_offset_id (uint8_t id); 53 | 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /src/lib/usb/common.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * USB 2.0 common macros and definitions 3 | * 4 | * See "notes from usb 2.0 spec sec 9 (usb device framework).h". 5 | * ---------------------------------------------------------------------------- 6 | * Copyright (c) 2012 Ben Blazak 7 | * Released under The MIT License (MIT) (see "license.md") 8 | * Project located at 9 | * ------------------------------------------------------------------------- */ 10 | 11 | 12 | #ifndef USB_COMMON_h 13 | #define USB_COMMON_h 14 | // ---------------------------------------------------------------------------- 15 | // ---------------------------------------------------------------------------- 16 | 17 | 18 | // - spec table 9-4 (Standard Request Codes) 19 | #define USB_GET_STATUS 0 20 | #define USB_CLEAR_FEATURE 1 21 | // (reserved for future use): 2 22 | #define USB_SET_FEATURE 3 23 | // (reserved for future use): 4 24 | #define USB_SET_ADDRESS 5 25 | #define USB_GET_DESCRIPTOR 6 26 | #define USB_SET_DESCRIPTOR 7 27 | #define USB_GET_CONFIGURATION 8 28 | #define USB_SET_CONFIGURATION 9 29 | #define USB_GET_INTERFACE 10 30 | #define USB_SET_INTERFACE 11 31 | #define USB_SYNCH_FRAME 12 32 | 33 | // - spec table 9-5 (Descriptor Types) 34 | #define USB_DEVICE 1 35 | #define USB_CONFIGURATION 2 36 | #define USB_STRING 3 37 | #define USB_INTERFACE 4 38 | #define USB_ENDPOINT 5 39 | #define USB_DEVICE_QUALIFIER 6 40 | #define USB_OTHER_SPEED_CONFIGURATION 7 41 | #define USB_INTERFACE_POWER 8 42 | 43 | // - spec table 9-6 (Standard Feature Selectors) 44 | #define USB_DEVICE_REMOTE_WAKEUP 1 // recipient: device 45 | #define USB_ENDPOINT_HALT 0 // recipient: endpoint 46 | #define USB_TEST_MODE 2 // recipient: device 47 | 48 | 49 | // ---------------------------------------------------------------------------- 50 | // ---------------------------------------------------------------------------- 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/teensy-2-0--led.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller : Teensy 2.0 specific exports : LED control 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__CONTROLLER__TEENSY_2_0__LED_h 11 | #define KEYBOARD__ERGODOX__CONTROLLER__TEENSY_2_0__LED_h 12 | 13 | #include 14 | #include // for the register macros 15 | 16 | // -------------------------------------------------------------------- 17 | 18 | #define _kb_led_1_on() (DDRB |= (1<<5)) 19 | #define _kb_led_1_off() (DDRB &= ~(1<<5)) 20 | #define _kb_led_1_set(n) (OCR1A = (uint8_t)(n)) 21 | #define _kb_led_1_set_percent(n) (OCR1A = (uint8_t)((n) * 0xFF)) 22 | 23 | #define _kb_led_2_on() (DDRB |= (1<<6)) 24 | #define _kb_led_2_off() (DDRB &= ~(1<<6)) 25 | #define _kb_led_2_set(n) (OCR1B = (uint8_t)(n)) 26 | #define _kb_led_2_set_percent(n) (OCR1B = (uint8_t)((n) * 0xFF)) 27 | 28 | #define _kb_led_3_on() (DDRB |= (1<<7)) 29 | #define _kb_led_3_off() (DDRB &= ~(1<<7)) 30 | #define _kb_led_3_set(n) (OCR1C = (uint8_t)(n)) 31 | #define _kb_led_3_set_percent(n) (OCR1C = (uint8_t)((n) * 0xFF)) 32 | 33 | 34 | #define _kb_led_all_on() do { \ 35 | _kb_led_1_on(); \ 36 | _kb_led_2_on(); \ 37 | _kb_led_3_on(); \ 38 | } while(0) 39 | 40 | #define _kb_led_all_off() do { \ 41 | _kb_led_1_off(); \ 42 | _kb_led_2_off(); \ 43 | _kb_led_3_off(); \ 44 | } while(0) 45 | 46 | #define _kb_led_all_set(n) do { \ 47 | _kb_led_1_set(n); \ 48 | _kb_led_2_set(n); \ 49 | _kb_led_3_set(n); \ 50 | } while(0) 51 | 52 | #define _kb_led_all_set_percent(n) do { \ 53 | _kb_led_1_set_percent(n); \ 54 | _kb_led_2_set_percent(n); \ 55 | _kb_led_3_set_percent(n); \ 56 | } while(0) 57 | 58 | #endif 59 | 60 | -------------------------------------------------------------------------------- /src/lib/key-functions/public/device.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * key functions : device specific : code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include "../public.h" 13 | 14 | 15 | // ---------------------------------------------------------------------------- 16 | // descriptions 17 | // ---------------------------------------------------------------------------- 18 | 19 | /* 20 | * [name] 21 | * Jump to Bootloader 22 | * 23 | * [description] 24 | * For reflashing the controller 25 | */ 26 | void kbfun_jump_to_bootloader(void); 27 | 28 | 29 | // ---------------------------------------------------------------------------- 30 | #if MAKEFILE_BOARD == teensy-2-0 31 | // ---------------------------------------------------------------------------- 32 | 33 | // from PJRC (slightly modified) 34 | // 35 | void kbfun_jump_to_bootloader(void) { 36 | // --- for all Teensy boards --- 37 | 38 | cli(); 39 | 40 | // disable watchdog, if enabled 41 | // disable all peripherals 42 | UDCON = 1; 43 | USBCON = (1< 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef LIB__KEY_FUNCTIONS__COMMON_h 11 | #define LIB__KEY_FUNCTIONS__COMMON_h 12 | 13 | #include 14 | #include 15 | 16 | // -------------------------------------------------------------------- 17 | 18 | // basic 19 | void kbfun_press_release (void); 20 | void kbfun_press_release_preserve_sticky (void); 21 | void kbfun_toggle (void); 22 | void kbfun_transparent (void); 23 | // --- layer push/pop functions 24 | void kbfun_layer_push_1 (void); 25 | void kbfun_layer_push_2 (void); 26 | void kbfun_layer_push_3 (void); 27 | void kbfun_layer_push_4 (void); 28 | void kbfun_layer_push_5 (void); 29 | void kbfun_layer_push_6 (void); 30 | void kbfun_layer_push_7 (void); 31 | void kbfun_layer_push_8 (void); 32 | void kbfun_layer_push_9 (void); 33 | void kbfun_layer_push_10 (void); 34 | void kbfun_layer_sticky_1 (void); 35 | void kbfun_layer_sticky_2 (void); 36 | void kbfun_layer_sticky_3 (void); 37 | void kbfun_layer_sticky_4 (void); 38 | void kbfun_layer_sticky_5 (void); 39 | void kbfun_layer_sticky_6 (void); 40 | void kbfun_layer_sticky_7 (void); 41 | void kbfun_layer_sticky_8 (void); 42 | void kbfun_layer_sticky_9 (void); 43 | void kbfun_layer_sticky_10 (void); 44 | void kbfun_layer_pop_1 (void); 45 | void kbfun_layer_pop_2 (void); 46 | void kbfun_layer_pop_3 (void); 47 | void kbfun_layer_pop_4 (void); 48 | void kbfun_layer_pop_5 (void); 49 | void kbfun_layer_pop_6 (void); 50 | void kbfun_layer_pop_7 (void); 51 | void kbfun_layer_pop_8 (void); 52 | void kbfun_layer_pop_9 (void); 53 | void kbfun_layer_pop_10 (void); 54 | // --- 55 | 56 | // device 57 | void kbfun_jump_to_bootloader (void); 58 | 59 | // special 60 | void kbfun_shift_press_release (void); 61 | void kbfun_2_keys_capslock_press_release (void); 62 | void kbfun_layer_push_numpad (void); 63 | void kbfun_layer_pop_numpad (void); 64 | void kbfun_mediakey_press_release (void); 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /src/lib/usb/TODO.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * TODO: not sure where this stuff should be yet. a lot of it (depending on 3 | * what ends up here) will likely be device and application specific. 4 | * 5 | * - The following document versions were used, unless otherwise noted: 6 | * - USB Specification: revision 2.0 7 | * - HID Usage Tables: version 1.12 8 | * - Device Class Definition for Human Interface Devices (HID): version 1.11 9 | * ---------------------------------------------------------------------------- 10 | * Copyright (c) 2012 Ben Blazak 11 | * Released under The MIT License (MIT) (see "license.md") 12 | * Project located at 13 | * ------------------------------------------------------------------------- */ 14 | 15 | 16 | // TODO: does stuff from spec sec 9.4.* belong directly in an interrupt vector? 17 | 18 | // - spec sec 9.4.1 (Standard Device Requests / Clear Feature) (pg 252) 19 | 20 | // - spec sec 9.4.2 (Standard Device Requests / Get Configuration) (pg 253) 21 | 22 | // - spec sec 9.4.3 (Standard Device Requests / Get Descriptor) (pg 253) 23 | 24 | // - spec sec 9.4.4 (Standard Device Requests / Get Interface) (pg 254) 25 | 26 | // - spec sec 9.4.5 (Standard Device Requests / Get Status) (pg 254) 27 | 28 | // - spec sec 9.4.6 (Standard Device Requests / Set Address) (pg 256) 29 | 30 | // - spec sec 9.4.7 (Standard Device Requests / Set Configuration) (pg 257) 31 | 32 | // - spec sec 9.4.8 (Standard Device Requests / Set Descriptor) (pg 257) 33 | 34 | // - spec sec 9.4.9 (Standard Device Requests / Set Feature) (pg 258) 35 | 36 | // - spec sec 9.4.10 (Standard Device Requests / Set Interface) (pg 259) 37 | 38 | // - spec sec 9.4.11 (Standard Device Requests / Synch Frame) (pg 260) 39 | 40 | // TODO 41 | // - read the hid device class definition .pdf 42 | // - set USB vendor ID = 0x1d50 // Openmoko, Inc. 43 | // USB product ID = 0x6028 // ErgoDox ergonomic keyboard 44 | 45 | // DONE 46 | // - read the hid usage tables .pdf 47 | // - i think this is more for reference and implementation than 48 | // understanding. i've copied the relevant (i think) tables ones into 49 | // headers. the unicode usage page, i'll have to look into more later: i'm 50 | // not sure if it can be used with keyboards. if so though, i'll have to 51 | // look on the unicode website, or elsewhere, coz this .pdf doesn't list 52 | // anything about them out, it just references the unicode spec. 53 | 54 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/default--led-control.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : default LED control 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__DEFAULT__LED_CONTROL_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__DEFAULT__LED_CONTROL_h 12 | 13 | // -------------------------------------------------------------------- 14 | 15 | /* 16 | * state and delay macros 17 | */ 18 | 19 | #ifndef kb_led_state_power_on 20 | #define kb_led_state_power_on() do { \ 21 | _kb_led_all_set_percent(MAKEFILE_LED_BRIGHTNESS/10); \ 22 | _kb_led_all_on(); \ 23 | } while(0) 24 | #endif 25 | 26 | // note: need to delay for a total of ~1 second 27 | #ifndef kb_led_delay_usb_init 28 | #define kb_led_delay_usb_init() do { \ 29 | _kb_led_1_set_percent(MAKEFILE_LED_BRIGHTNESS); \ 30 | _delay_ms(333); \ 31 | _kb_led_2_set_percent(MAKEFILE_LED_BRIGHTNESS); \ 32 | _delay_ms(333); \ 33 | _kb_led_3_set_percent(MAKEFILE_LED_BRIGHTNESS); \ 34 | _delay_ms(333); \ 35 | } while(0) 36 | #endif 37 | 38 | #ifndef kb_led_state_ready 39 | #define kb_led_state_ready() do { \ 40 | _kb_led_all_off(); \ 41 | _kb_led_all_set_percent(MAKEFILE_LED_BRIGHTNESS); \ 42 | } while(0) 43 | #endif 44 | 45 | 46 | /* 47 | * logical LED macros 48 | * - unused macros should be defined to nothing 49 | * - they all are here, because they really need to be specified in 50 | * the layout specific file 51 | */ 52 | 53 | #ifndef kb_led_num_on 54 | #define kb_led_num_on() 55 | #endif 56 | #ifndef kb_led_num_off 57 | #define kb_led_num_off() 58 | #endif 59 | #ifndef kb_led_caps_on 60 | #define kb_led_caps_on() 61 | #endif 62 | #ifndef kb_led_caps_off 63 | #define kb_led_caps_off() 64 | #endif 65 | #ifndef kb_led_scroll_on 66 | #define kb_led_scroll_on() 67 | #endif 68 | #ifndef kb_led_scroll_off 69 | #define kb_led_scroll_off() 70 | #endif 71 | #ifndef kb_led_compose_on 72 | #define kb_led_compose_on() 73 | #endif 74 | #ifndef kb_led_compose_off 75 | #define kb_led_compose_off() 76 | #endif 77 | #ifndef kb_led_kana_on 78 | #define kb_led_kana_on() 79 | #endif 80 | #ifndef kb_led_kana_off 81 | #define kb_led_kana_off() 82 | #endif 83 | 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/default--matrix-control.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : layout : default matrix control 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX_CONTROL_h 11 | #define KEYBOARD__ERGODOX__LAYOUT__DEFAULT__MATRIX_CONTROL_h 12 | 13 | #include 14 | #include 15 | #include "../../../lib/data-types/misc.h" 16 | #include "../../../lib/key-functions/public.h" 17 | #include "../matrix.h" 18 | 19 | // -------------------------------------------------------------------- 20 | 21 | #ifndef KB_LAYERS 22 | #define KB_LAYERS 10 23 | #endif 24 | 25 | // -------------------------------------------------------------------- 26 | 27 | /* 28 | * matrix 'get' macros, and `extern` matrix declarations 29 | * 30 | * These are written for when the matrices are stored solely in Flash. 31 | * Layouts may redefine them if they wish and use Flash, RAM, EEPROM, 32 | * or any combination of the three, as long as they maintain the same 33 | * interface. 34 | * 35 | * - If the macro is overridden, the matrix declaration must be too, 36 | * and vice versa. 37 | * 38 | * - 'set' functions are optional, and should be defined in the layout 39 | * specific '.h'. They'll require the use of the EEPROM, possibly in 40 | * clever conjunction with one of the other two memories (since the 41 | * EEPROM is small). Custom key functions will also need to be 42 | * written. 43 | * 44 | * - To override these macros with real functions, set the macro equal 45 | * to itself (e.g. `#define kb_layout_get kb_layout_get`) and provide 46 | * function prototypes, in the layout specific '.h' 47 | */ 48 | 49 | #ifndef kb_layout_get 50 | extern const uint8_t PROGMEM \ 51 | _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS]; 52 | 53 | #define kb_layout_get(layer,row,column) \ 54 | ( (uint8_t) \ 55 | pgm_read_byte(&( \ 56 | _kb_layout[layer][row][column] )) ) 57 | #endif 58 | 59 | #ifndef kb_layout_press_get 60 | extern const void_funptr_t PROGMEM \ 61 | _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS]; 62 | 63 | #define kb_layout_press_get(layer,row,column) \ 64 | ( (void_funptr_t) \ 65 | pgm_read_word(&( \ 66 | _kb_layout_press[layer][row][column] )) ) 67 | #endif 68 | 69 | #ifndef kb_layout_release_get 70 | extern const void_funptr_t PROGMEM \ 71 | _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS]; 72 | 73 | #define kb_layout_release_get(layer,row,column) \ 74 | ( (void_funptr_t) \ 75 | pgm_read_word(&( \ 76 | _kb_layout_release[layer][row][column] )) ) 77 | 78 | #endif 79 | 80 | #endif 81 | 82 | -------------------------------------------------------------------------------- /src/lib/twi/teensy-2-0.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * Very simple Teensy 2.0 TWI library : code 3 | * 4 | * - This is mostly straight from the datasheet, section 20.6.6, figure 20-11 5 | * (the code example in C), and section 20.8.1, figure 20-12 6 | * - Also see the documentation for `` at 7 | * 8 | * 9 | * Some other (more complete) TWI libraries for the Teensy 2.0 (and other Atmel 10 | * processors): 11 | * - [i2cmaster] (http://homepage.hispeed.ch/peterfleury/i2cmaster.zip) 12 | * - written by [peter-fleury] (http://homepage.hispeed.ch/peterfleury/) 13 | * - [the arduino twi library] 14 | * (https://github.com/arduino/Arduino/tree/master/libraries/Wire/utility) 15 | * - look for an older version if you need one that doesn't depend on all the 16 | * other Arduino stuff 17 | * ---------------------------------------------------------------------------- 18 | * Copyright (c) 2012 Ben Blazak 19 | * Released under The MIT License (MIT) (see "license.md") 20 | * Project located at 21 | * ------------------------------------------------------------------------- */ 22 | 23 | 24 | // ---------------------------------------------------------------------------- 25 | // conditional compile 26 | #if MAKEFILE_BOARD == teensy-2-0 27 | // ---------------------------------------------------------------------------- 28 | 29 | 30 | #include 31 | #include "./teensy-2-0.h" 32 | 33 | // ---------------------------------------------------------------------------- 34 | 35 | void twi_init(void) { 36 | // set the prescaler value to 0 37 | TWSR &= ~( (1< 17 | # Released under The MIT License (MIT) (see "license.md") 18 | # Project located at 19 | # ----------------------------------------------------------------------------- 20 | 21 | 22 | include src/makefile-options 23 | 24 | # which layouts to compile (will override the variable in src/makefile-options) 25 | # --- default 26 | LAYOUT := norman-symbol-mod 27 | # --- all 28 | LAYOUTS := qwerty-kinesis-mod dvorak-kinesis-mod colemak-symbol-mod norman-symbol-mod 29 | 30 | # system specific stuff 31 | UNAME := $(shell uname) 32 | ifeq ($(UNAME),Darwin) 33 | DATE_PROG := gdate 34 | else 35 | DATE_PROG := date 36 | endif 37 | 38 | CURRENT_DATE := $(shell $(DATE_PROG) --rfc-3339 s) 39 | 40 | # git info 41 | GIT_BRANCH := $(shell git branch -l | grep '*' | cut -c 3-) 42 | GIT_COMMIT_DATE := $(shell git log -n 1 --pretty --date=iso | grep 'Date' | cut -c 9- ) 43 | GIT_COMMIT_ID := $(shell git log -n 1 | grep 'commit' | cut -c 8-) 44 | 45 | # name to use for the final distribution file or package 46 | TARGET := ergodox-firmware--$(GIT_BRANCH)--$(shell $(DATE_PROG) -d "$(GIT_COMMIT_DATE)" +'%Y%m%dT%H%M%S')--$(shell echo $(GIT_COMMIT_ID) | cut -c 1-7)--$(LAYOUT) 47 | 48 | # directories 49 | BUILD := build 50 | ROOT := $(BUILD)/$(TARGET) 51 | SCRIPTS := build-scripts 52 | 53 | # ----------------------------------------------------------------------------- 54 | # ----------------------------------------------------------------------------- 55 | 56 | .PHONY: all clean checkin build-dir firmware dist zip zip-all 57 | 58 | all: dist 59 | 60 | clean: 61 | git clean -dX # remove ignored files and directories 62 | -rm -r '$(BUILD)' 63 | 64 | checkin: 65 | -git commit -a 66 | 67 | build-dir: 68 | -rm -r '$(BUILD)/$(TARGET)'* 69 | -mkdir -p '$(BUILD)/$(TARGET)' 70 | 71 | firmware: 72 | cd src; $(MAKE) LAYOUT=$(LAYOUT) all 73 | 74 | $(ROOT)/firmware.%: firmware 75 | cp 'src/firmware.$*' '$@' 76 | 77 | 78 | $(ROOT)/firmware--ui-info.json: $(SCRIPTS)/gen-ui-info.py checkin 79 | ( ./'$<' \ 80 | --current-date '$(shell $(DATE_PROG) --rfc-3339 s)' \ 81 | --git-commit-date '$(GIT_COMMIT_DATE)' \ 82 | --git-commit-id '$(GIT_COMMIT_ID)' \ 83 | --map-file-path '$(BUILD)/$(TARGET)/firmware.map' \ 84 | --source-code-path 'src' \ 85 | --matrix-file-path 'src/keyboard/$(KEYBOARD)/matrix.h' \ 86 | --layout-file-path \ 87 | 'src/keyboard/$(KEYBOARD)/layout/$(LAYOUT).c' \ 88 | ) > '$@' 89 | 90 | $(ROOT)/firmware--layout.html: \ 91 | $(SCRIPTS)/gen-layout.py \ 92 | $(ROOT)/firmware--ui-info.json 93 | \ 94 | ( ./'$<' \ 95 | --ui-info-file '$(ROOT)/firmware--ui-info.json' \ 96 | ) > '$@' 97 | 98 | 99 | dist: \ 100 | checkin \ 101 | build-dir \ 102 | $(ROOT)/firmware.hex \ 103 | $(ROOT)/firmware.eep \ 104 | $(ROOT)/firmware.map \ 105 | $(ROOT)/firmware--ui-info.json \ 106 | $(ROOT)/firmware--layout.html 107 | 108 | zip: dist 109 | ( cd '$(BUILD)/$(TARGET)'; \ 110 | zip '../$(TARGET).zip' \ 111 | -r * .* \ 112 | -x '..*' ) 113 | 114 | zip-all: 115 | for layout in $(LAYOUTS); do \ 116 | make LAYOUT=$$layout zip; \ 117 | done 118 | 119 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/matrix.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : matrix specific exports 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #ifndef KEYBOARD__ERGODOX__MATRIX_h 11 | #define KEYBOARD__ERGODOX__MATRIX_h 12 | 13 | // -------------------------------------------------------------------- 14 | 15 | #define KB_ROWS 6 // must match real life 16 | #define KB_COLUMNS 14 // must match real life 17 | 18 | // -------------------------------------------------------------------- 19 | 20 | /* mapping from spatial position to matrix position 21 | * - spatial position: where the key is spatially, relative to other 22 | * keys both on the keyboard and in the layout 23 | * - matrix position: the coordinate in the matrix to which a key is 24 | * scanned by the update functions 25 | * 26 | * - location numbers are in the format `row##column`, where both 'row' 27 | * and 'column' are single digit hex numbers corresponding to the 28 | * matrix position (which also corresponds to the row and column pin 29 | * labels used in the teensy and mcp23018 files) 30 | * 31 | * - coordinates 32 | * - optional keys 33 | * k15, k16 (left hand thumb group) 34 | * k17, k18 (right hand thumb group) 35 | * - unused keys 36 | * k36, k00 (left hand) 37 | * k37, k0D (right hand) 38 | * 39 | * --- other info ----------------------------------------------------- 40 | * rows x columns = positions; used, unused 41 | * per hand: 6 x 7 = 42; 40, 2 42 | * total: 6 x 14 = 84; 80, 4 43 | * 44 | * left hand : rows 0..5, cols 0..6 45 | * right hand : rows 0..5, cols 7..D 46 | * -------------------------------------------------------------------- 47 | */ 48 | #define KB_MATRIX_LAYER( \ 49 | /* for unused positions */ \ 50 | na, \ 51 | \ 52 | /* left hand, spatial positions */ \ 53 | k50,k51,k52,k53,k54,k55,k56, \ 54 | k40,k41,k42,k43,k44,k45,k46, \ 55 | k30,k31,k32,k33,k34,k35, \ 56 | k20,k21,k22,k23,k24,k25,k26, \ 57 | k10,k11,k12,k13,k14, \ 58 | k05,k06, \ 59 | k15,k16,k04, \ 60 | k03,k02,k01, \ 61 | \ 62 | /* right hand, spatial positions */ \ 63 | k57,k58,k59,k5A,k5B,k5C,k5D, \ 64 | k47,k48,k49,k4A,k4B,k4C,k4D, \ 65 | k38,k39,k3A,k3B,k3C,k3D, \ 66 | k27,k28,k29,k2A,k2B,k2C,k2D, \ 67 | k19,k1A,k1B,k1C,k1D, \ 68 | k07,k08, \ 69 | k09,k17,k18, \ 70 | k0C,k0B,k0A ) \ 71 | \ 72 | /* matrix positions */ \ 73 | {{ na,k01,k02,k03,k04,k05,k06, k07,k08,k09,k0A,k0B,k0C, na }, \ 74 | { k10,k11,k12,k13,k14,k15,k16, k17,k18,k19,k1A,k1B,k1C,k1D }, \ 75 | { k20,k21,k22,k23,k24,k25,k26, k27,k28,k29,k2A,k2B,k2C,k2D }, \ 76 | { k30,k31,k32,k33,k34,k35, na, na,k38,k39,k3A,k3B,k3C,k3D }, \ 77 | { k40,k41,k42,k43,k44,k45,k46, k47,k48,k49,k4A,k4B,k4C,k4D }, \ 78 | { k50,k51,k52,k53,k54,k55,k56, k57,k58,k59,k5A,k5B,k5C,k5D }} 79 | 80 | 81 | #define KB_MATRIX_LAYER_SET_ALL(na, kxx) \ 82 | LAYER( \ 83 | na, \ 84 | \ 85 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 86 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 87 | kxx,kxx,kxx,kxx,kxx,kxx, \ 88 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 89 | kxx,kxx,kxx,kxx,kxx, \ 90 | kxx,kxx, \ 91 | kxx,kxx,kxx, \ 92 | kxx,kxx,kxx, \ 93 | \ 94 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 95 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 96 | kxx,kxx,kxx,kxx,kxx,kxx, \ 97 | kxx,kxx,kxx,kxx,kxx,kxx,kxx, \ 98 | kxx,kxx,kxx,kxx,kxx, \ 99 | kxx,kxx, \ 100 | kxx,kxx,kxx, \ 101 | kxx,kxx,kxx ) \ 102 | 103 | #endif 104 | 105 | -------------------------------------------------------------------------------- /src/lib/key-functions/private.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * key functions : private : code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include "../../lib-other/pjrc/usb_keyboard/usb_keyboard.h" 13 | #include "../../lib/usb/usage-page/keyboard.h" 14 | #include "../../keyboard/layout.h" 15 | #include "../../keyboard/matrix.h" 16 | #include "../../main.h" 17 | #include "./public.h" 18 | 19 | /* 20 | * MediaCodeLookupTable is used to translate from enumeration in keyboard.h to 21 | * consumer key scan code in usb_keyboard.h 22 | */ 23 | static const uint16_t _media_code_lookup_table[] = { 24 | TRANSPORT_PLAY_PAUSE, /* MEDIAKEY_PLAY_PAUSE */ 25 | TRANSPORT_PREV_TRACK, /* MEDIAKEY_PREV_TRACK */ 26 | TRANSPORT_NEXT_TRACK, /* MEDIAKEY_NEXT_TRACK */ 27 | }; 28 | 29 | // ---------------------------------------------------------------------------- 30 | 31 | /* 32 | * Generate a normal keypress or keyrelease 33 | * 34 | * Arguments 35 | * - press: whether to generate a keypress (true) or keyrelease (false) 36 | * - keycode: the keycode to use 37 | * 38 | * Note 39 | * - Because of the way USB does things, what this actually does is either add 40 | * or remove 'keycode' from the list of currently pressed keys, to be sent at 41 | * the end of the current cycle (see main.c) 42 | */ 43 | void _kbfun_press_release(bool press, uint8_t keycode) { 44 | // no-op 45 | if (keycode == 0) 46 | return; 47 | 48 | // modifier keys 49 | switch (keycode) { 50 | case KEY_LeftControl: (press) 51 | ? (keyboard_modifier_keys |= (1<<0)) 52 | : (keyboard_modifier_keys &= ~(1<<0)); 53 | return; 54 | case KEY_LeftShift: (press) 55 | ? (keyboard_modifier_keys |= (1<<1)) 56 | : (keyboard_modifier_keys &= ~(1<<1)); 57 | return; 58 | case KEY_LeftAlt: (press) 59 | ? (keyboard_modifier_keys |= (1<<2)) 60 | : (keyboard_modifier_keys &= ~(1<<2)); 61 | return; 62 | case KEY_LeftGUI: (press) 63 | ? (keyboard_modifier_keys |= (1<<3)) 64 | : (keyboard_modifier_keys &= ~(1<<3)); 65 | return; 66 | case KEY_RightControl: (press) 67 | ? (keyboard_modifier_keys |= (1<<4)) 68 | : (keyboard_modifier_keys &= ~(1<<4)); 69 | return; 70 | case KEY_RightShift: (press) 71 | ? (keyboard_modifier_keys |= (1<<5)) 72 | : (keyboard_modifier_keys &= ~(1<<5)); 73 | return; 74 | case KEY_RightAlt: (press) 75 | ? (keyboard_modifier_keys |= (1<<6)) 76 | : (keyboard_modifier_keys &= ~(1<<6)); 77 | return; 78 | case KEY_RightGUI: (press) 79 | ? (keyboard_modifier_keys |= (1<<7)) 80 | : (keyboard_modifier_keys &= ~(1<<7)); 81 | return; 82 | } 83 | 84 | // all others 85 | for (uint8_t i=0; i<6; i++) { 86 | if (press) { 87 | if (keyboard_keys[i] == 0) { 88 | keyboard_keys[i] = keycode; 89 | return; 90 | } 91 | } else { 92 | if (keyboard_keys[i] == keycode) { 93 | keyboard_keys[i] = 0; 94 | return; 95 | } 96 | } 97 | } 98 | } 99 | 100 | /* 101 | * Is the given keycode pressed? 102 | */ 103 | bool _kbfun_is_pressed(uint8_t keycode) { 104 | // modifier keys 105 | switch (keycode) { 106 | case KEY_LeftControl: if (keyboard_modifier_keys & (1<<0)) 107 | return true; 108 | case KEY_LeftShift: if (keyboard_modifier_keys & (1<<1)) 109 | return true; 110 | case KEY_LeftAlt: if (keyboard_modifier_keys & (1<<2)) 111 | return true; 112 | case KEY_LeftGUI: if (keyboard_modifier_keys & (1<<3)) 113 | return true; 114 | case KEY_RightControl: if (keyboard_modifier_keys & (1<<4)) 115 | return true; 116 | case KEY_RightShift: if (keyboard_modifier_keys & (1<<5)) 117 | return true; 118 | case KEY_RightAlt: if (keyboard_modifier_keys & (1<<6)) 119 | return true; 120 | case KEY_RightGUI: if (keyboard_modifier_keys & (1<<7)) 121 | return true; 122 | } 123 | 124 | // all others 125 | for (uint8_t i=0; i<6; i++) 126 | if (keyboard_keys[i] == keycode) 127 | return true; 128 | 129 | return false; 130 | } 131 | 132 | void _kbfun_mediakey_press_release(bool press, uint8_t keycode) { 133 | uint16_t mediakey_code = _media_code_lookup_table[keycode]; 134 | if (press) { 135 | consumer_key = mediakey_code; 136 | } else { 137 | // Only one key can be pressed at a time so only clear the keypress for 138 | // active key (most recently pressed) 139 | if (mediakey_code == consumer_key) { 140 | consumer_key = 0; 141 | } 142 | } 143 | } 144 | 145 | -------------------------------------------------------------------------------- /src/lib/key-functions/public/special.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * key functions : special : code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include "../../../lib-other/pjrc/usb_keyboard/usb_keyboard.h" 13 | #include "../../../lib/usb/usage-page/keyboard.h" 14 | #include "../../../keyboard/layout.h" 15 | #include "../../../main.h" 16 | #include "../public.h" 17 | #include "../private.h" 18 | 19 | // ---------------------------------------------------------------------------- 20 | 21 | // convenience macros 22 | #define LAYER main_arg_layer 23 | #define LAYER_OFFSET main_arg_layer_offset 24 | #define ROW main_arg_row 25 | #define COL main_arg_col 26 | #define IS_PRESSED main_arg_is_pressed 27 | #define WAS_PRESSED main_arg_was_pressed 28 | 29 | 30 | // ---------------------------------------------------------------------------- 31 | 32 | 33 | /* 34 | * [name] 35 | * Shift + press|release 36 | * 37 | * [description] 38 | * Generate a 'shift' press or release before the normal keypress or 39 | * keyrelease 40 | */ 41 | void kbfun_shift_press_release(void) { 42 | _kbfun_press_release(IS_PRESSED, KEY_LeftShift); 43 | kbfun_press_release(); 44 | } 45 | 46 | /* 47 | * [name] 48 | * Two keys => capslock 49 | * 50 | * [description] 51 | * When assigned to two keys (e.g. the physical left and right shift keys) 52 | * (in both the press and release matrices), pressing and holding down one of 53 | * the keys will make the second key toggle capslock 54 | * 55 | * [note] 56 | * If either of the shifts are pressed when the second key is pressed, they 57 | * wil be released so that capslock will register properly when pressed. 58 | * Capslock will then be pressed and released, and the original state of the 59 | * shifts will be restored 60 | */ 61 | void kbfun_2_keys_capslock_press_release(void) { 62 | static uint8_t keys_pressed; 63 | static bool lshift_pressed; 64 | static bool rshift_pressed; 65 | 66 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 67 | 68 | if (!IS_PRESSED) keys_pressed--; 69 | 70 | // take care of the key that was actually pressed 71 | _kbfun_press_release(IS_PRESSED, keycode); 72 | 73 | // take care of capslock (only on the press of the 2nd key) 74 | if (keys_pressed == 1 && IS_PRESSED) { 75 | // save the state of left and right shift 76 | lshift_pressed = _kbfun_is_pressed(KEY_LeftShift); 77 | rshift_pressed = _kbfun_is_pressed(KEY_RightShift); 78 | // disable both 79 | _kbfun_press_release(false, KEY_LeftShift); 80 | _kbfun_press_release(false, KEY_RightShift); 81 | 82 | // press capslock, then release it 83 | _kbfun_press_release(true, KEY_CapsLock); 84 | usb_keyboard_send(); 85 | _kbfun_press_release(false, KEY_CapsLock); 86 | usb_keyboard_send(); 87 | 88 | // restore the state of left and right shift 89 | if (lshift_pressed) 90 | _kbfun_press_release(true, KEY_LeftShift); 91 | if (rshift_pressed) 92 | _kbfun_press_release(true, KEY_RightShift); 93 | } 94 | 95 | if (IS_PRESSED) keys_pressed++; 96 | } 97 | 98 | /* ---------------------------------------------------------------------------- 99 | * numpad functions 100 | * ------------------------------------------------------------------------- */ 101 | 102 | static uint8_t numpad_layer_id; 103 | 104 | static inline void numpad_toggle_numlock(void) { 105 | _kbfun_press_release(true, KEY_LockingNumLock); 106 | usb_keyboard_send(); 107 | _kbfun_press_release(false, KEY_LockingNumLock); 108 | usb_keyboard_send(); 109 | } 110 | 111 | /* 112 | * [name] 113 | * Numpad on 114 | * 115 | * [description] 116 | * Set the numpad to on (put the numpad layer, specified in the keymap, in an 117 | * element at the top of the layer stack, and record that element's id) and 118 | * toggle numlock (regardless of whether or not numlock is currently on) 119 | * 120 | * [note] 121 | * Meant to be assigned (along with "numpad off") instead of a normal numlock 122 | * key 123 | */ 124 | void kbfun_layer_push_numpad(void) { 125 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 126 | main_layers_pop_id(numpad_layer_id); 127 | numpad_layer_id = main_layers_push(keycode, eStickyNone); 128 | numpad_toggle_numlock(); 129 | } 130 | 131 | /* 132 | * [name] 133 | * Numpad off 134 | * 135 | * [description] 136 | * Set the numpad to off (pop the layer element created by "numpad on" out of 137 | * the stack) and toggle numlock (regardless of whether or not numlock is 138 | * currently on) 139 | * 140 | * [note] 141 | * Meant to be assigned (along with "numpad on") instead of a normal numlock 142 | * key 143 | */ 144 | void kbfun_layer_pop_numpad(void) { 145 | main_layers_pop_id(numpad_layer_id); 146 | numpad_layer_id = 0; 147 | numpad_toggle_numlock(); 148 | } 149 | 150 | /* 151 | * [name] 152 | * Media Key Press Release 153 | * 154 | * [description] 155 | * Generate a keypress for a media key, such as play/pause, next track, or 156 | * previous track 157 | * 158 | */ 159 | void kbfun_mediakey_press_release(void) { 160 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 161 | _kbfun_mediakey_press_release(IS_PRESSED, keycode); 162 | } 163 | 164 | /* ---------------------------------------------------------------------------- 165 | * ------------------------------------------------------------------------- */ 166 | 167 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/mcp23018.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller: MCP23018 specific code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "../../../lib/twi.h" // `TWI_FREQ` defined in "teensy-2-0.c" 14 | #include "../options.h" 15 | #include "../matrix.h" 16 | #include "./mcp23018--functions.h" 17 | 18 | // ---------------------------------------------------------------------------- 19 | 20 | // check options 21 | #if (MCP23018__DRIVE_ROWS && MCP23018__DRIVE_COLUMNS) \ 22 | || !(MCP23018__DRIVE_ROWS || MCP23018__DRIVE_COLUMNS) 23 | #error "See 'Pin drive direction' in 'options.h'" 24 | #endif 25 | 26 | // ---------------------------------------------------------------------------- 27 | 28 | // register addresses (see "mcp23018.md") 29 | #define IODIRA 0x00 // i/o direction register 30 | #define IODIRB 0x01 31 | #define GPPUA 0x0C // GPIO pull-up resistor register 32 | #define GPPUB 0x0D 33 | #define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT) 34 | #define GPIOB 0x13 35 | #define OLATA 0x14 // output latch register 36 | #define OLATB 0x15 37 | 38 | // TWI aliases 39 | #define TWI_ADDR_WRITE ( (MCP23018_TWI_ADDRESS<<1) | TW_WRITE ) 40 | #define TWI_ADDR_READ ( (MCP23018_TWI_ADDRESS<<1) | TW_READ ) 41 | 42 | // ---------------------------------------------------------------------------- 43 | 44 | /* returns: 45 | * - success: 0 46 | * - failure: twi status code 47 | * 48 | * notes: 49 | * - `twi_stop()` must be called *exactly once* for each twi block, the way 50 | * things are currently set up. this may change in the future. 51 | */ 52 | uint8_t mcp23018_init(void) { 53 | uint8_t ret; 54 | 55 | // set pin direction 56 | // - unused : input : 1 57 | // - input : input : 1 58 | // - driving : output : 0 59 | twi_start(); 60 | ret = twi_send(TWI_ADDR_WRITE); 61 | if (ret) goto out; // make sure we got an ACK 62 | twi_send(IODIRA); 63 | #if MCP23018__DRIVE_ROWS 64 | twi_send(0b11111111); // IODIRA 65 | twi_send(0b11000000); // IODIRB 66 | #elif MCP23018__DRIVE_COLUMNS 67 | twi_send(0b10000000); // IODIRA 68 | twi_send(0b11111111); // IODIRB 69 | #endif 70 | twi_stop(); 71 | 72 | // set pull-up 73 | // - unused : on : 1 74 | // - input : on : 1 75 | // - driving : off : 0 76 | twi_start(); 77 | ret = twi_send(TWI_ADDR_WRITE); 78 | if (ret) goto out; // make sure we got an ACK 79 | twi_send(GPPUA); 80 | #if MCP23018__DRIVE_ROWS 81 | twi_send(0b11111111); // GPPUA 82 | twi_send(0b11000000); // GPPUB 83 | #elif MCP23018__DRIVE_COLUMNS 84 | twi_send(0b10000000); // GPPUA 85 | twi_send(0b11111111); // GPPUB 86 | #endif 87 | twi_stop(); 88 | 89 | // set logical value (doesn't matter on inputs) 90 | // - unused : hi-Z : 1 91 | // - input : hi-Z : 1 92 | // - driving : hi-Z : 1 93 | twi_start(); 94 | ret = twi_send(TWI_ADDR_WRITE); 95 | if (ret) goto out; // make sure we got an ACK 96 | twi_send(OLATA); 97 | twi_send(0b11111111); //OLATA 98 | twi_send(0b11111111); //OLATB 99 | 100 | out: 101 | twi_stop(); 102 | return ret; 103 | } 104 | 105 | /* returns: 106 | * - success: 0 107 | * - failure: twi status code 108 | */ 109 | #if KB_ROWS != 6 || KB_COLUMNS != 14 110 | #error "Expecting different keyboard dimensions" 111 | #endif 112 | uint8_t mcp23018_update_matrix(bool matrix[KB_ROWS][KB_COLUMNS]) { 113 | uint8_t ret, data; 114 | 115 | // initialize things, just to make sure 116 | // - it's not appreciably faster to skip this, and it takes care of the 117 | // case when the i/o expander isn't plugged in during the first 118 | // init() 119 | ret = mcp23018_init(); 120 | 121 | // if there was an error 122 | if (ret) { 123 | // clear our part of the matrix 124 | for (uint8_t row=0; row<=5; row++) 125 | for (uint8_t col=0; col<=6; col++) 126 | matrix[row][col] = 0; 127 | 128 | return ret; 129 | } 130 | 131 | 132 | // -------------------------------------------------------------------- 133 | // update our part of the matrix 134 | 135 | #if MCP23018__DRIVE_ROWS 136 | for (uint8_t row=0; row<=5; row++) { 137 | // set active row low : 0 138 | // set other rows hi-Z : 1 139 | twi_start(); 140 | twi_send(TWI_ADDR_WRITE); 141 | twi_send(GPIOB); 142 | twi_send( 0xFF & ~(1<<(5-row)) ); 143 | twi_stop(); 144 | 145 | // read column data 146 | twi_start(); 147 | twi_send(TWI_ADDR_WRITE); 148 | twi_send(GPIOA); 149 | twi_start(); 150 | twi_send(TWI_ADDR_READ); 151 | twi_read(&data); 152 | twi_stop(); 153 | 154 | // update matrix 155 | for (uint8_t col=0; col<=6; col++) { 156 | matrix[row][col] = !( data & (1< 6 | * 7 | * - applicable Usage Types (from Section 3.4) 8 | * - OOC : On/Off Control 9 | * - Sel : Selector 10 | * - DV : Dynamic Value 11 | * - US : Usage Switch 12 | * - UM : Usage Modifier 13 | * 14 | * [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf 15 | * [2]: http://www.usb.org/developers/hidpage 16 | * ---------------------------------------------------------------------------- 17 | * Copyright (c) 2012 Ben Blazak 18 | * Released under The MIT License (MIT) (see "license.md") 19 | * Project located at 20 | * ------------------------------------------------------------------------- */ 21 | 22 | 23 | #ifndef USB_USAGE_PAGE_LED_h 24 | #define USB_USAGE_PAGE_LED_h 25 | // ---------------------------------------------------------------------------- 26 | // ---------------------------------------------------------------------------- 27 | 28 | 29 | // Name ID Usage Type Section of HID Tables 30 | // --------------------------- ---- ---------- ---------------------- 31 | 32 | // (Undefined) 0x00 // - - 33 | 34 | #define LED_NumLock 0x01 // OOC 11.1 35 | #define LED_CapsLock 0x02 // OOC 11.1 36 | #define LED_ScrollLock 0x03 // OOC 11.1 37 | #define LED_Compose 0x04 // OOC 11.1 38 | #define LED_Kana 0x05 // OOC 11.1 39 | #define LED_Power 0x06 // OOC 11.6 40 | #define LED_Shift 0x07 // OOC 11.1 41 | #define LED_DoNotDisturb 0x08 // OOC 11.2 42 | #define LED_Mute 0x09 // OOC 11.3 43 | #define LED_ToneEnable 0x0A // OOC 11.3 44 | #define LED_HighCutFilter 0x0B // OOC 11.3 45 | #define LED_LowCutFilter 0x0C // OOC 11.3 46 | #define LED_EqualizerEnable 0x0D // OOC 11.3 47 | #define LED_SoundFieldOn 0x0E // OOC 11.3 48 | #define LED_SurroundOn 0x0F // OOC 11.3 49 | #define LED_Repeat 0x10 // OOC 11.3 50 | #define LED_Stereo 0x11 // OOC 11.3 51 | #define LED_SamplingRateDetect 0x12 // OOC 11.3 52 | #define LED_Spinning 0x13 // OOC 11.4 53 | #define LED_CAV 0x14 // OOC 11.3 54 | #define LED_CLV 0x15 // OOC 11.3 55 | #define LED_RecordingFormatDetect 0x16 // OOC 11.4 56 | #define LED_OffHook 0x17 // OOC 11.2 57 | #define LED_Ring 0x18 // OOC 11.2 58 | #define LED_MessageWaiting 0x19 // OOC 11.2 59 | #define LED_DataMode 0x1A // OOC 11.2 60 | #define LED_BatteryOperation 0x1B // OOC 11.6 61 | #define LED_BatteryOK 0x1C // OOC 11.6 62 | #define LED_BatteryLow 0x1D // OOC 11.6 63 | #define LED_Speaker 0x1E // OOC 11.2 64 | #define LED_HeadSet 0x1F // OOC 11.2 65 | #define LED_Hold 0x20 // OOC 11.2 66 | #define LED_Microphone 0x21 // OOC 11.2 67 | #define LED_Coverage 0x22 // OOC 11.2 68 | #define LED_NightMode 0x23 // OOC 11.2 69 | #define LED_SendCalls 0x24 // OOC 11.2 70 | #define LED_CallPickup 0x25 // OOC 11.2 71 | #define LED_Conference 0x26 // OOC 11.2 72 | #define LED_Standby 0x27 // OOC 11.6 73 | #define LED_CameraOn 0x28 // OOC 11.3 74 | #define LED_CameraOff 0x29 // OOC 11.3 75 | #define LED_OnLine 0x2A // OOC 11.6 76 | #define LED_OffLine 0x2B // OOC 11.6 77 | #define LED_Busy 0x2C // OOC 11.6 78 | #define LED_Ready 0x2D // OOC 11.6 79 | #define LED_PaperOut 0x2E // OOC 11.5 80 | #define LED_PaperJam 0x2F // OOC 11.5 81 | #define LED_Remote 0x30 // OOC 11.6 82 | #define LED_Forward 0x31 // OOC 11.4 83 | #define LED_Reverse 0x32 // OOC 11.4 84 | #define LED_Stop 0x33 // OOC 11.4 85 | #define LED_Rewind 0x34 // OOC 11.4 86 | #define LED_FastForward 0x35 // OOC 11.4 87 | #define LED_Play 0x36 // OOC 11.4 88 | #define LED_Pause 0x37 // OOC 11.4 89 | #define LED_Record 0x38 // OOC 11.4 90 | #define LED_Error 0x39 // OOC 11.6 91 | #define LED_UsageSelectedIndicator 0x3A // US 11.6 92 | #define LED_UsageInUseIndicator 0x3B // US 11.6 93 | #define LED_UsageMultiModeIndicator 0x3C // UM 11.6 94 | #define LED_IndicatorOn 0x3D // Sel 11.6 95 | #define LED_IndicatorFlash 0x3E // Sel 11.6 96 | #define LED_IndicatorSlowBlink 0x3F // Sel 11.6 97 | #define LED_IndicatorFastBlink 0x40 // Sel 11.6 98 | #define LED_IndicatorOff 0x41 // Sel 11.6 99 | #define LED_FlashOnTime 0x42 // DV 11.6 100 | #define LED_SlowBlinkOnTime 0x43 // DV 11.6 101 | #define LED_SlowBlinkOffTime 0x44 // DV 11.6 102 | #define LED_FastBlinkOnTime 0x45 // DV 11.6 103 | #define LED_FastBlinkOffTime 0x46 // DV 11.6 104 | #define LED_UsageIndicatorColor 0x47 // UM 11.6 105 | #define LED_IndicatorRed 0x48 // Sel 11.6 106 | #define LED_IndicatorGreen 0x49 // Sel 11.6 107 | #define LED_IndicatorAmber 0x4A // Sel 11.6 108 | #define LED_GenericIndicator 0x4B // OOC 11.6 109 | #define LED_SystemSuspend 0x4C // OOC 11.6 110 | #define LED_ExternalPowerConnected 0x4D // OOC 11.6 111 | 112 | // (Reserved) 0x4E..0xFFFF // - - 113 | 114 | 115 | // ---------------------------------------------------------------------------- 116 | // ---------------------------------------------------------------------------- 117 | #endif 118 | 119 | -------------------------------------------------------------------------------- /src/makefile: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # makefile for the ergoDOX firmware 3 | # 4 | # - .h file dependencies are automatically generated 5 | # 6 | # - This makefile was originally (extensively) modified from the WinAVR 7 | # makefile template, mostly by removing stuff. The copy I used was from 8 | # [pjrc : usb_keyboard] (http://pjrc.com/teensy/usb_keyboard.zip). 9 | # ----------------------------------------------------------------------------- 10 | # Copyright (c) 2012 Ben Blazak 11 | # Released under The MIT License (MIT) (see "license.md") 12 | # Project located at 13 | # ----------------------------------------------------------------------------- 14 | 15 | 16 | include makefile-options 17 | 18 | FORMAT := ihex # the program binary's format 19 | MCU := atmega32u4 # processor type (for teensy 2.0); must match real life 20 | BOARD := teensy-2-0 # see the libraries you're using for what's available 21 | F_CPU := 16000000 # processor speed, in Hz 22 | 23 | # firmware stuff 24 | SRC := $(wildcard *.c) 25 | # keyboard and layout stuff 26 | # --- remove whitespace from vars 27 | KEYBOARD := $(strip $(KEYBOARD)) 28 | LAYOUT := $(strip $(LAYOUT)) 29 | # --- include stuff 30 | SRC += $(wildcard keyboard/$(KEYBOARD)*.c) 31 | SRC += $(wildcard keyboard/$(KEYBOARD)/*.c) 32 | SRC += $(wildcard keyboard/$(KEYBOARD)/controller/*.c) 33 | SRC += $(wildcard keyboard/$(KEYBOARD)/layout/$(LAYOUT)*.c) 34 | # library stuff 35 | # - should be last in the list of files to compile, in case there are default 36 | # macros that have to be overridden in other source files 37 | # - add more "*/*/..."s as necessary to compile everything. 38 | # - parts of the stuff under "lib" may not be necessary, depending on other 39 | # options, but it's all included here. hopefully any unnecessary stuff gets 40 | # compiled out. else, the makefile will have to become more complicated. 41 | SRC += $(wildcard lib/*.c) 42 | SRC += $(wildcard lib/*/*.c) 43 | SRC += $(wildcard lib/*/*/*.c) 44 | SRC += $(wildcard lib-other/*.c) 45 | SRC += $(wildcard lib-other/*/*.c) 46 | SRC += $(wildcard lib-other/*/*/*.c) 47 | 48 | OBJ = $(SRC:%.c=%.o) 49 | 50 | 51 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 | CFLAGS := -mmcu=$(MCU) # processor type (teensy 2.0); must match real 53 | # life 54 | CFLAGS += -DF_CPU=$(F_CPU) # processor frequency; must match initialization 55 | # in source 56 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 | CFLAGS += -DMAKEFILE_BOARD='$(strip $(BOARD))' 58 | CFLAGS += -DMAKEFILE_KEYBOARD='$(strip $(KEYBOARD))' 59 | CFLAGS += -DMAKEFILE_KEYBOARD_LAYOUT='$(strip $(LAYOUT))' 60 | CFLAGS += -DMAKEFILE_DEBOUNCE_TIME='$(strip $(DEBOUNCE_TIME))' 61 | CFLAGS += -DMAKEFILE_LED_BRIGHTNESS='$(strip $(LED_BRIGHTNESS))' 62 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 | CFLAGS += -std=gnu99 # use C99 plus GCC extensions 64 | CFLAGS += -Os # optimize for size 65 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 | CFLAGS += -Wall # enable lots of common warnings 67 | CFLAGS += -Wstrict-prototypes # "warn if a function is declared or defined 68 | # without specifying the argument types" 69 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 | CFLAGS += -fpack-struct # "pack all structure members together without holes" 71 | CFLAGS += -fshort-enums # "allocate to an 'enum' type only as many bytes as it 72 | # needs for the declared range of possible values" 73 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 | CFLAGS += -ffunction-sections # \ "place each function or data into its own 75 | CFLAGS += -fdata-sections # / section in the output file if the 76 | # target supports arbitrary sections." for 77 | # linker optimizations, and discarding 78 | # unused code. 79 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 | LDFLAGS := -Wl,-Map=$(strip $(TARGET)).map,--cref # generate a link map, with 82 | # a cross reference table 83 | LDFLAGS += -Wl,--relax # for some linker optimizations 84 | LDFLAGS += -Wl,--gc-sections # discard unused functions and data 85 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 | GENDEPFLAGS += -MMD -MP -MF $@.dep # generate dependency files 88 | # . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 | 90 | 91 | CC := avr-gcc 92 | OBJCOPY := avr-objcopy 93 | SIZE := avr-size 94 | 95 | 96 | # remove whitespace from some of the options 97 | FORMAT := $(strip $(FORMAT)) 98 | 99 | 100 | # ----------------------------------------------------------------------------- 101 | # ----------------------------------------------------------------------------- 102 | 103 | .PHONY: all clean 104 | 105 | all: $(TARGET).hex $(TARGET).eep 106 | @echo 107 | @echo '---------------------------------------------------------------' 108 | @echo '------- done --------------------------------------------------' 109 | @echo 110 | $(SIZE) --target=$(FORMAT) $(TARGET).hex 111 | @echo 112 | $(SIZE) --target=$(FORMAT) $(TARGET).eep 113 | @echo 114 | @echo 'you can load "$(TARGET).hex" and "$(TARGET).eep" onto the' 115 | @echo 'Teensy using the Teensy loader' 116 | @echo 117 | @echo '---------------------------------------------------------------' 118 | @echo 119 | 120 | clean: 121 | @echo 122 | @echo --- cleaning --- 123 | git clean -dX # remove ignored files and directories 124 | 125 | # ----------------------------------------------------------------------------- 126 | 127 | .SECONDARY: 128 | 129 | %.hex: %.elf 130 | @echo 131 | @echo --- making $@ --- 132 | # from the WinAVR makefile template (modified) 133 | $(OBJCOPY) -O $(FORMAT) \ 134 | -R .eeprom -R .fuse -R .lock -R .signature \ 135 | $< $@ 136 | 137 | %.eep: %.elf 138 | @echo 139 | @echo --- making $@ --- 140 | # from the WinAVR makefile template (modified) 141 | -$(OBJCOPY) -O $(FORMAT) \ 142 | -j .eeprom \ 143 | --set-section-flags=.eeprom="alloc,load" \ 144 | --change-section-lma .eeprom=0 \ 145 | --no-change-warnings \ 146 | $< $@ || exit 0 147 | 148 | %.elf: $(OBJ) 149 | @echo 150 | @echo --- making $@ --- 151 | $(CC) $(strip $(CFLAGS)) $(strip $(LDFLAGS)) $^ --output $@ 152 | 153 | %.o: %.c 154 | @echo 155 | @echo --- making $@ --- 156 | $(CC) -c $(strip $(CFLAGS)) $(strip $(GENDEPFLAGS)) $< -o $@ 157 | 158 | # ----------------------------------------------------------------------------- 159 | 160 | -include $(OBJ:%=%.dep) 161 | 162 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/mcp23018.md: -------------------------------------------------------------------------------- 1 | # Documentation : MCP23018 2 | 3 | ## Pinout and Pin assignments 4 | 5 | * `+` indicates connected pin 6 | * `o` indicates unconnected pin 7 | * `=` is used to list other things the pin is connected to 8 | * `-`s inserted between some of the pin functions for readability 9 | 10 | ### MCP23018 11 | Vss(GND) +01---.---28+ NC 12 | NC +02 27+ GPA7 13 | GPB0 +03 26+ GPA6 14 | GPB1 +04 25+ GPA5 15 | GPB2 +05 24+ GPA4 16 | GPB3 +06 23+ GPA3 17 | GPB4 +07 22+ GPA2 18 | GPB5 +08 21+ GPA1 19 | GPB6 +09 20+ GPA0 20 | GPB7 +10 19+ INTA 21 | Vdd(Vcc) +11 18+ INTB 22 | SCL +12 17+ NC 23 | SDA +13 16+ RESET 24 | NC +14-------15+ ADDR 25 | 26 | ### MCP32018 Pin Assignments 27 | 28 | power_negative Vss(GND) +01---.---28o NC 29 | NC o02 27o GPA7 30 | row_5 GPB0 +03 26+ GPA6 column_6 31 | row_4 GPB1 +04 25+ GPA5 column_5 32 | row_3 GPB2 +05 24+ GPA4 column_4 33 | row_2 GPB3 +06 23+ GPA3 column_3 34 | row_1 GPB4 +07 22+ GPA2 column_2 35 | row_0 GPB5 +08 21+ GPA1 column_1 36 | GPB6 o09 20+ GPA0 column_0 37 | GPB7 o10 19o INTA 38 | power_positive Vdd(Vcc) +11 18o INTB 39 | I2C SCL +12 17o NC 40 | I2C SDA +13 16+ RESET = Vdd(Vcc) (see note) 41 | NC o14-------15+ ADDR = Vss(GND) (see note) 42 | 43 | * notes: 44 | * Row and column assignments are to matrix positions, which may or may 45 | or may not correspond to the physical position of the key: e.g. the key 46 | where `row_4` and `column_2` cross will be scanned into the matrix at 47 | `[4][2]`, wherever it happens to be located on the keyboard. Mapping 48 | from one to the other (which only matters for defining layouts) is 49 | handled elsewhere. 50 | * ADDR (pin15): Set slave address to `0b0100000` by connecting to Vss(GND). 51 | * The user-defined bits are the three least significant 52 | * I2C addresses are 7 bits long (the last bit in the byte is used for 53 | indicating read/write) 54 | * RESET (pin16) must be externally biased. Since we're not going to 55 | trigger it ourselves, we can tie it high. 56 | * This is not noted in the I2C Pinout Description section of the 57 | MCP23018 datasheet, but it's true (empirically), and it is noted in 58 | the SPI Pinout Description section, and in the MCP23017 datasheet. 59 | * I'm not the first person who's failed to notice ;) 60 | * 61 | * 62 | 63 | ## Notes about Registers 64 | 65 | register address function (for all bits) 66 | -------- ------- ----------------------- 67 | IODIRA 0x00 \ 1: set corresponding pin as input 68 | IODIRB 0x01 / 0: set ................. as output 69 | GPPUA 0x0C \ 1: set corresponding pin internal pull-up on 70 | GPPUB 0x0D / 0: set .......................... pull-up off 71 | GPIOA 0x12 \ read: returns the value on the port 72 | GPIOB 0x13 / write: modifies the OLAT register 73 | OLATA 0x14 \ read: returns the value of this register 74 | OLATB 0x15 / write: modifies the output latches that control the 75 | pins configured as output 76 | 77 | * IOCON register (see datasheet section 1.6, table 1-5, register 1-8) 78 | * BANK: bit 7; read/write; default = 0 79 | * 1: The registers associated with each port are separated into 80 | different banks 81 | * 0: The registers are in the same bank (addresses are sequential) 82 | * SEQOP: bit 5; read/write; default = 0 83 | * 1: Sequential operation disabled, address pointer does not increment 84 | * 0: Sequential operation enabled, address pointer increments 85 | 86 | * notes: 87 | * All addresses given for IOCON.BANK = 0, since that's the default value of 88 | the bit, and that's what we'll be using. 89 | * Initially, we want either columns or rows (see <../options.h>) set as 90 | hi-Z without pull-ups, and the other set of pins set as input with 91 | pull-ups. During the update function, we'll cycle through setting the 92 | first set low and checking each pin in the second set. 93 | 94 | * abbreviations: 95 | * IODIR = I/O Direction Register 96 | * IOCON = I/O Control Register 97 | * GPPU = GPIO Pull-Up Resistor Register 98 | * GPIO = General Purpose I/O Port Register 99 | * OLAT = Output Latch Register 100 | 101 | ## I²C Device Protocol (see datasheet section 1.3, figure 1-1) 102 | 103 | S : Start OP : Device opcode 104 | SR : Restart ADDR : Device address 105 | P : Stop Dout : Data out from MCP23018 106 | W : Write Din : Data in to MCP23018 107 | R : Read 108 | 109 | 110 | S OP W ADDR ----> Din ... Din --> P 111 | | 112 | |--> SR OP R Dout ... Dout ---> P 113 | |<--------------------------| 114 | | 115 | |--> SR OP W ADDR ... Din --> P 116 | | 117 | |--> P 118 | 119 | S OP R ----> Dout ... Dout --> P 120 | | 121 | |--> SR OP R Dout ... Dout ---> P 122 | |<--------------------------| 123 | | 124 | |--> SR OP W ADDR Din ... Din --> P 125 | | 126 | |--> P 127 | 128 | Byte and Sequential Write 129 | ------------------------- 130 | Byte : S OP W ADDR --> Din --> P 131 | Sequential : S OP W ADDR --> Din ... Din --> P 132 | 133 | Byte and Sequential Read 134 | ------------------------ 135 | Byte : S OP W ADDR --> SR OP R Dout --> P 136 | Sequential : S OP W ADDR --> SR OP R Dout ... Dout --> P 137 | 138 | * notes: 139 | * We'll be using sequential mode (ICON.SEQOP = 0; default) (see datasheet 140 | section 1.3.1). 141 | 142 | ------------------------------------------------------------------------------- 143 | 144 | Copyright © 2012 Ben Blazak 145 | Released under The MIT License (MIT) (see "license.md") 146 | Project located at 147 | 148 | -------------------------------------------------------------------------------- /src/lib-other/pjrc/usb_keyboard/usb_keyboard.h: -------------------------------------------------------------------------------- 1 | #ifndef usb_serial_h__ 2 | #define usb_serial_h__ 3 | 4 | #include 5 | 6 | void usb_init(void); // initialize everything 7 | uint8_t usb_configured(void); // is the USB port configured 8 | 9 | int8_t usb_keyboard_press(uint8_t key, uint8_t modifier); 10 | int8_t usb_keyboard_send(void); 11 | extern uint8_t keyboard_modifier_keys; 12 | extern uint8_t keyboard_keys[6]; 13 | extern volatile uint8_t keyboard_leds; 14 | 15 | extern uint16_t consumer_key; 16 | 17 | // This file does not include the HID debug functions, so these empty 18 | // macros replace them with nothing, so users can compile code that 19 | // has calls to these functions. 20 | #define usb_debug_putchar(c) 21 | #define usb_debug_flush_output() 22 | 23 | int8_t usb_extra_consumer_send(); 24 | 25 | #if 0 // removed in favor of equivalent code elsewhere ::Ben Blazak, 2012:: 26 | 27 | #define KEY_CTRL 0x01 28 | #define KEY_SHIFT 0x02 29 | #define KEY_ALT 0x04 30 | #define KEY_GUI 0x08 31 | #define KEY_LEFT_CTRL 0x01 32 | #define KEY_LEFT_SHIFT 0x02 33 | #define KEY_LEFT_ALT 0x04 34 | #define KEY_LEFT_GUI 0x08 35 | #define KEY_RIGHT_CTRL 0x10 36 | #define KEY_RIGHT_SHIFT 0x20 37 | #define KEY_RIGHT_ALT 0x40 38 | #define KEY_RIGHT_GUI 0x80 39 | 40 | #define KEY_A 4 41 | #define KEY_B 5 42 | #define KEY_C 6 43 | #define KEY_D 7 44 | #define KEY_E 8 45 | #define KEY_F 9 46 | #define KEY_G 10 47 | #define KEY_H 11 48 | #define KEY_I 12 49 | #define KEY_J 13 50 | #define KEY_K 14 51 | #define KEY_L 15 52 | #define KEY_M 16 53 | #define KEY_N 17 54 | #define KEY_O 18 55 | #define KEY_P 19 56 | #define KEY_Q 20 57 | #define KEY_R 21 58 | #define KEY_S 22 59 | #define KEY_T 23 60 | #define KEY_U 24 61 | #define KEY_V 25 62 | #define KEY_W 26 63 | #define KEY_X 27 64 | #define KEY_Y 28 65 | #define KEY_Z 29 66 | #define KEY_1 30 67 | #define KEY_2 31 68 | #define KEY_3 32 69 | #define KEY_4 33 70 | #define KEY_5 34 71 | #define KEY_6 35 72 | #define KEY_7 36 73 | #define KEY_8 37 74 | #define KEY_9 38 75 | #define KEY_0 39 76 | #define KEY_ENTER 40 77 | #define KEY_ESC 41 78 | #define KEY_BACKSPACE 42 79 | #define KEY_TAB 43 80 | #define KEY_SPACE 44 81 | #define KEY_MINUS 45 82 | #define KEY_EQUAL 46 83 | #define KEY_LEFT_BRACE 47 84 | #define KEY_RIGHT_BRACE 48 85 | #define KEY_BACKSLASH 49 86 | #define KEY_NUMBER 50 87 | #define KEY_SEMICOLON 51 88 | #define KEY_QUOTE 52 89 | #define KEY_TILDE 53 90 | #define KEY_COMMA 54 91 | #define KEY_PERIOD 55 92 | #define KEY_SLASH 56 93 | #define KEY_CAPS_LOCK 57 94 | #define KEY_F1 58 95 | #define KEY_F2 59 96 | #define KEY_F3 60 97 | #define KEY_F4 61 98 | #define KEY_F5 62 99 | #define KEY_F6 63 100 | #define KEY_F7 64 101 | #define KEY_F8 65 102 | #define KEY_F9 66 103 | #define KEY_F10 67 104 | #define KEY_F11 68 105 | #define KEY_F12 69 106 | #define KEY_PRINTSCREEN 70 107 | #define KEY_SCROLL_LOCK 71 108 | #define KEY_PAUSE 72 109 | #define KEY_INSERT 73 110 | #define KEY_HOME 74 111 | #define KEY_PAGE_UP 75 112 | #define KEY_DELETE 76 113 | #define KEY_END 77 114 | #define KEY_PAGE_DOWN 78 115 | #define KEY_RIGHT 79 116 | #define KEY_LEFT 80 117 | #define KEY_DOWN 81 118 | #define KEY_UP 82 119 | #define KEY_NUM_LOCK 83 120 | #define KEYPAD_SLASH 84 121 | #define KEYPAD_ASTERIX 85 122 | #define KEYPAD_MINUS 86 123 | #define KEYPAD_PLUS 87 124 | #define KEYPAD_ENTER 88 125 | #define KEYPAD_1 89 126 | #define KEYPAD_2 90 127 | #define KEYPAD_3 91 128 | #define KEYPAD_4 92 129 | #define KEYPAD_5 93 130 | #define KEYPAD_6 94 131 | #define KEYPAD_7 95 132 | #define KEYPAD_8 96 133 | #define KEYPAD_9 97 134 | #define KEYPAD_0 98 135 | #define KEYPAD_PERIOD 99 136 | 137 | #endif 138 | 139 | /* Consumer Page(0x0C) 140 | * following are supported by Windows: http://msdn.microsoft.com/en-us/windows/hardware/gg463372.aspx 141 | */ 142 | #define AUDIO_MUTE 0x00E2 143 | #define AUDIO_VOL_UP 0x00E9 144 | #define AUDIO_VOL_DOWN 0x00EA 145 | #define TRANSPORT_NEXT_TRACK 0x00B5 146 | #define TRANSPORT_PREV_TRACK 0x00B6 147 | #define TRANSPORT_STOP 0x00B7 148 | #define TRANSPORT_PLAY_PAUSE 0x00CD 149 | /* application launch */ 150 | #define AL_CC_CONFIG 0x0183 151 | #define AL_EMAIL 0x018A 152 | #define AL_CALCULATOR 0x0192 153 | #define AL_LOCAL_BROWSER 0x0194 154 | /* application control */ 155 | #define AC_SEARCH 0x0221 156 | #define AC_HOME 0x0223 157 | #define AC_BACK 0x0224 158 | #define AC_FORWARD 0x0225 159 | #define AC_STOP 0x0226 160 | #define AC_REFRESH 0x0227 161 | #define AC_BOOKMARKS 0x022A 162 | /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */ 163 | #define AL_LOCK 0x019E 164 | #define TRANSPORT_RECORD 0x00B2 165 | #define TRANSPORT_REWIND 0x00B4 166 | #define TRANSPORT_EJECT 0x00B8 167 | #define AC_MINIMIZE 0x0206 168 | 169 | /* Generic Desktop Page(0x01) - system power control */ 170 | #define SYSTEM_POWER_DOWN 0x0081 171 | #define SYSTEM_SLEEP 0x0082 172 | #define SYSTEM_WAKE_UP 0x0083 173 | 174 | // Everything below this point is only intended for usb_serial.c 175 | #ifdef USB_SERIAL_PRIVATE_INCLUDE 176 | #include 177 | #include 178 | #include 179 | 180 | #define EP_TYPE_CONTROL 0x00 181 | #define EP_TYPE_BULK_IN 0x81 182 | #define EP_TYPE_BULK_OUT 0x80 183 | #define EP_TYPE_INTERRUPT_IN 0xC1 184 | #define EP_TYPE_INTERRUPT_OUT 0xC0 185 | #define EP_TYPE_ISOCHRONOUS_IN 0x41 186 | #define EP_TYPE_ISOCHRONOUS_OUT 0x40 187 | 188 | #define EP_SINGLE_BUFFER 0x02 189 | #define EP_DOUBLE_BUFFER 0x06 190 | 191 | #define EP_SIZE(s) ((s) == 64 ? 0x30 : \ 192 | ((s) == 32 ? 0x20 : \ 193 | ((s) == 16 ? 0x10 : \ 194 | 0x00))) 195 | 196 | #define MAX_ENDPOINT 4 197 | 198 | #define LSB(n) (n & 255) 199 | #define MSB(n) ((n >> 8) & 255) 200 | 201 | #if defined(__AVR_AT90USB162__) 202 | #define HW_CONFIG() 203 | #define PLL_CONFIG() (PLLCSR = ((1<) set as 83 | hi-Z without pull-ups, and the other set of pins set as input with 84 | pull-ups. During the update function, we'll cycle through setting the 85 | first set low and checking each pin in the second set. 86 | * To set a pin hi-Z on this board, set it as input with pull-up 87 | disabled. 88 | * Switching the driving pins (the first set of pins) between hi-Z and 89 | drive low (treating them as if they were open drain) seems just as 90 | good as, and a little safer than, driving them high when they're not 91 | active. 92 | * We need to delay for at least 1 μs between changing the column pins and 93 | reading the row pins. I would assume this is to allow the pins time to 94 | stabalize. 95 | * Thanks to [hasu] (http://geekhack.org/member.php?3412-hasu) 96 | for the suggestion [here] 97 | (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606415&viewfull=1#post606415), 98 | and [PrinsValium] (http://geekhack.org/member.php?6408-PrinsValium) 99 | for noting that his firmware had erratic behavior without the delays 100 | [here] 101 | (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606426&viewfull=1#post606426). 102 | DOX tried it and confirmed that it worked for his protoype PCB (as of 103 | 3 June 2012) [here] 104 | (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=606865&viewfull=1#post606865). 105 | Before adding a delay we were having [strange problems with ghosting] 106 | (http://geekhack.org/showthread.php?22780-Interest-Check-Custom-split-ergo-keyboard&p=605857&viewfull=1#post605857). 107 | 108 | 109 | ### PWM on ports OC1(A|B|C) (see datasheet section 14.10) 110 | 111 | * notes: settings: 112 | * PWM pins should be set as outputs. 113 | * we want Waveform Generation Mode 5 114 | (fast PWM, 8-bit) 115 | (see table 14-5) 116 | * set `TCCRB[4,3],TCCRA[1,0]` to `0,1,0,1` 117 | * we want "Compare Output Mode, Fast PWM" to be `0b10` 118 | "Clear OCnA/OCnB/OCnC on compare match, set OCnA/OCnB/OCnC at TOP" 119 | (see table 14-3) 120 | this way higher values of `OCR1(A|B|C)` will mean longer 'on' times for 121 | the LEDs (provided they're hooked up to GND; other way around if they're 122 | hooked up to Vcc) 123 | * when in a fast PWM mode, set `TCCR1A[7,6,5,4,3,2]` to `1,0,1,0,1,0` 124 | * we want "Clock Select Bit Description" to be `0b001` 125 | "clkI/O/1 (No prescaling)" 126 | (see table 14-6) 127 | * set `TCCR1B[2,1,0]` to `0,0,1` 128 | * LEDs will be at minimum brightness until OCR1(A|B|C) are changed 129 | (since the default value of all the bits in those registers is 0) 130 | 131 | * notes: behavior: 132 | * The pins source current when on, and sink current when off. They aren't 133 | set to high impediance for either. 134 | * In Fast PWM mode setting `OCR1(A|B|C)` to `0` does not make the output on 135 | `OC1(A|B|C)` constant low; just close. Per the datasheet, this isn't 136 | true for every PWM mode. 137 | 138 | * abbreviations: 139 | * OCR = Output Compare Register 140 | * TCCR = Timer/Counter Control Register 141 | 142 | ------------------------------------------------------------------------------- 143 | 144 | Copyright © 2012 Ben Blazak 145 | Released under The MIT License (MIT) (see "license.md") 146 | Project located at 147 | 148 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/controller/teensy-2-0.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX : controller: Teensy 2.0 specific code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | // for "lib/twi.h" 11 | #define TWI_FREQ 400000 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include "../../../lib/twi.h" 18 | #include "../options.h" 19 | #include "../matrix.h" 20 | #include "./teensy-2-0--functions.h" 21 | #include "./teensy-2-0--led.h" 22 | 23 | // ---------------------------------------------------------------------------- 24 | 25 | // check options 26 | #if (TEENSY__DRIVE_ROWS && TEENSY__DRIVE_COLUMNS) \ 27 | || !(TEENSY__DRIVE_ROWS || TEENSY__DRIVE_COLUMNS) 28 | #error "See 'Pin drive direction' in 'options.h'" 29 | #endif 30 | // ---------------------------------------------------------------------------- 31 | 32 | // processor frequency (from ) 33 | #define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) 34 | #define CPU_16MHz 0x00 35 | #define CPU_8MHz 0x01 36 | #define CPU_4MHz 0x02 37 | #define CPU_2MHz 0x03 38 | #define CPU_1MHz 0x04 39 | #define CPU_500kHz 0x05 40 | #define CPU_250kHz 0x06 41 | #define CPU_125kHz 0x07 42 | #define CPU_62kHz 0x08 43 | 44 | 45 | /* 46 | * pin macros 47 | * - note: you can move the `UNUSED`, `ROW`, and `COLUMN` pins around, but be 48 | * sure to keep the set of all the pins listed constant. other pins are not 49 | * movable, and either are referenced explicitly or have macros defined for 50 | * them elsewhere. 51 | * - note: if you change pin assignments, please be sure to update 52 | * "teensy-2-0.md", and the '.svg' circuit diagram. 53 | */ 54 | 55 | // --- unused 56 | #define UNUSED_0 C, 7 57 | #define UNUSED_1 D, 7 58 | #define UNUSED_2 D, 4 // hard to use with breadboard (on the end) 59 | #define UNUSED_3 D, 5 // hard to use with breadboard (on the end) 60 | #define UNUSED_4 E, 6 // hard to use with breadboard (internal) 61 | 62 | // --- rows 63 | #define ROW_0 F, 7 64 | #define ROW_1 F, 6 65 | #define ROW_2 F, 5 66 | #define ROW_3 F, 4 67 | #define ROW_4 F, 1 68 | #define ROW_5 F, 0 69 | 70 | // --- columns 71 | #define COLUMN_7 B, 0 72 | #define COLUMN_8 B, 1 73 | #define COLUMN_9 B, 2 74 | #define COLUMN_A B, 3 75 | #define COLUMN_B D, 2 76 | #define COLUMN_C D, 3 77 | #define COLUMN_D C, 6 78 | 79 | // --- helpers 80 | #define SET |= 81 | #define CLEAR &=~ 82 | 83 | #define _teensypin_write(register, operation, pin_letter, pin_number) \ 84 | do { \ 85 | ((register##pin_letter) operation (1<<(pin_number))); \ 86 | _delay_us(1); /* allow pins time to stabilize */ \ 87 | } while(0) 88 | #define teensypin_write(register, operation, pin) \ 89 | _teensypin_write(register, operation, pin) 90 | 91 | #define _teensypin_read(pin_letter, pin_number) \ 92 | ((PIN##pin_letter) & (1<<(pin_number))) 93 | #define teensypin_read(pin) \ 94 | _teensypin_read(pin) 95 | 96 | #define teensypin_write_all_unused(register, operation) \ 97 | do { \ 98 | teensypin_write(register, operation, UNUSED_0); \ 99 | teensypin_write(register, operation, UNUSED_1); \ 100 | teensypin_write(register, operation, UNUSED_2); \ 101 | teensypin_write(register, operation, UNUSED_3); \ 102 | teensypin_write(register, operation, UNUSED_4); } \ 103 | while(0) 104 | 105 | #define teensypin_write_all_row(register, operation) \ 106 | do { \ 107 | teensypin_write(register, operation, ROW_0); \ 108 | teensypin_write(register, operation, ROW_1); \ 109 | teensypin_write(register, operation, ROW_2); \ 110 | teensypin_write(register, operation, ROW_3); \ 111 | teensypin_write(register, operation, ROW_4); \ 112 | teensypin_write(register, operation, ROW_5); } \ 113 | while(0) 114 | 115 | #define teensypin_write_all_column(register, operation) \ 116 | do { \ 117 | teensypin_write(register, operation, COLUMN_7); \ 118 | teensypin_write(register, operation, COLUMN_8); \ 119 | teensypin_write(register, operation, COLUMN_9); \ 120 | teensypin_write(register, operation, COLUMN_A); \ 121 | teensypin_write(register, operation, COLUMN_B); \ 122 | teensypin_write(register, operation, COLUMN_C); \ 123 | teensypin_write(register, operation, COLUMN_D); } \ 124 | while(0) 125 | 126 | 127 | /* 128 | * update macros 129 | */ 130 | #define update_rows_for_column(matrix, column) \ 131 | do { \ 132 | /* set column low (set as output) */ \ 133 | teensypin_write(DDR, SET, COLUMN_##column); \ 134 | /* read rows 0..5 and update matrix */ \ 135 | matrix[0x0][0x##column] = ! teensypin_read(ROW_0); \ 136 | matrix[0x1][0x##column] = ! teensypin_read(ROW_1); \ 137 | matrix[0x2][0x##column] = ! teensypin_read(ROW_2); \ 138 | matrix[0x3][0x##column] = ! teensypin_read(ROW_3); \ 139 | matrix[0x4][0x##column] = ! teensypin_read(ROW_4); \ 140 | matrix[0x5][0x##column] = ! teensypin_read(ROW_5); \ 141 | /* set column hi-Z (set as input) */ \ 142 | teensypin_write(DDR, CLEAR, COLUMN_##column); \ 143 | } while(0) 144 | 145 | #define update_columns_for_row(matrix, row) \ 146 | do { \ 147 | /* set row low (set as output) */ \ 148 | teensypin_write(DDR, SET, ROW_##row); \ 149 | /* read columns 7..D and update matrix */ \ 150 | matrix[0x##row][0x7] = ! teensypin_read(COLUMN_7); \ 151 | matrix[0x##row][0x8] = ! teensypin_read(COLUMN_8); \ 152 | matrix[0x##row][0x9] = ! teensypin_read(COLUMN_9); \ 153 | matrix[0x##row][0xA] = ! teensypin_read(COLUMN_A); \ 154 | matrix[0x##row][0xB] = ! teensypin_read(COLUMN_B); \ 155 | matrix[0x##row][0xC] = ! teensypin_read(COLUMN_C); \ 156 | matrix[0x##row][0xD] = ! teensypin_read(COLUMN_D); \ 157 | /* set row hi-Z (set as input) */ \ 158 | teensypin_write(DDR, CLEAR, ROW_##row); \ 159 | } while(0) 160 | 161 | // ---------------------------------------------------------------------------- 162 | 163 | /* returns 164 | * - success: 0 165 | */ 166 | uint8_t teensy_init(void) { 167 | // CPU speed : should match F_CPU in makefile 168 | #if F_CPU != 16000000 169 | #error "Expecting different CPU frequency" 170 | #endif 171 | CPU_PRESCALE(CPU_16MHz); 172 | 173 | // onboard LED 174 | // (tied to GND for hardware convenience) 175 | DDRD &= ~(1<<6); // set D(6) as input 176 | PORTD &= ~(1<<6); // set D(6) internal pull-up disabled 177 | 178 | // (tied to Vcc for hardware convenience) 179 | DDRB &= ~(1<<4); // set B(4) as input 180 | PORTB &= ~(1<<4); // set B(4) internal pull-up disabled 181 | 182 | // keyboard LEDs (see "PWM on ports OC1(A|B|C)" in "teensy-2-0.md") 183 | _kb_led_all_off(); // (just to put the pins in a known state) 184 | TCCR1A = 0b10101001; // set and configure fast PWM 185 | TCCR1B = 0b00001001; // set and configure fast PWM 186 | 187 | // I2C (TWI) 188 | twi_init(); // on pins D(1,0) 189 | 190 | // unused pins 191 | teensypin_write_all_unused(DDR, CLEAR); // set as input 192 | teensypin_write_all_unused(PORT, SET); // set internal pull-up enabled 193 | 194 | // rows and columns 195 | teensypin_write_all_row(DDR, CLEAR); // set as input (hi-Z) 196 | teensypin_write_all_column(DDR, CLEAR); // set as input (hi-Z) 197 | #if TEENSY__DRIVE_ROWS 198 | teensypin_write_all_row(PORT, CLEAR); // pull-up disabled 199 | teensypin_write_all_column(PORT, SET); // pull-up enabled 200 | #elif TEENSY__DRIVE_COLUMNS 201 | teensypin_write_all_row(PORT, SET); // pull-up enabled 202 | teensypin_write_all_column(PORT, CLEAR); // pull-up disabled 203 | #endif 204 | 205 | return 0; // success 206 | } 207 | 208 | /* returns 209 | * - success: 0 210 | */ 211 | #if KB_ROWS != 6 || KB_COLUMNS != 14 212 | #error "Expecting different keyboard dimensions" 213 | #endif 214 | 215 | uint8_t teensy_update_matrix(bool matrix[KB_ROWS][KB_COLUMNS]) { 216 | #if TEENSY__DRIVE_ROWS 217 | update_columns_for_row(matrix, 0); 218 | update_columns_for_row(matrix, 1); 219 | update_columns_for_row(matrix, 2); 220 | update_columns_for_row(matrix, 3); 221 | update_columns_for_row(matrix, 4); 222 | update_columns_for_row(matrix, 5); 223 | #elif TEENSY__DRIVE_COLUMNS 224 | update_rows_for_column(matrix, 7); 225 | update_rows_for_column(matrix, 8); 226 | update_rows_for_column(matrix, 9); 227 | update_rows_for_column(matrix, A); 228 | update_rows_for_column(matrix, B); 229 | update_rows_for_column(matrix, C); 230 | update_rows_for_column(matrix, D); 231 | #endif 232 | 233 | return 0; // success 234 | } 235 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | // vim: ts=4 sw=4 sts=4 2 | /* ---------------------------------------------------------------------------- 3 | * main() 4 | * ---------------------------------------------------------------------------- 5 | * Copyright (c) 2012 Ben Blazak 6 | * Released under The MIT License (MIT) (see "license.md") 7 | * Project located at 8 | * ------------------------------------------------------------------------- */ 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | #include "./lib-other/pjrc/usb_keyboard/usb_keyboard.h" 15 | #include "./lib/key-functions/public.h" 16 | #include "./keyboard/controller.h" 17 | #include "./keyboard/layout.h" 18 | #include "./keyboard/matrix.h" 19 | #include "./main.h" 20 | 21 | // ---------------------------------------------------------------------------- 22 | 23 | #define MAX_ACTIVE_LAYERS 20 24 | 25 | // ---------------------------------------------------------------------------- 26 | 27 | static bool _main_kb_is_pressed[KB_ROWS][KB_COLUMNS]; 28 | bool (*main_kb_is_pressed)[KB_ROWS][KB_COLUMNS] = &_main_kb_is_pressed; 29 | 30 | static bool _main_kb_was_pressed[KB_ROWS][KB_COLUMNS]; 31 | bool (*main_kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_main_kb_was_pressed; 32 | 33 | static bool main_kb_was_transparent[KB_ROWS][KB_COLUMNS]; 34 | 35 | uint8_t main_layers_pressed[KB_ROWS][KB_COLUMNS]; 36 | 37 | uint8_t main_loop_row; 38 | uint8_t main_loop_col; 39 | 40 | uint8_t main_arg_layer; 41 | uint8_t main_arg_layer_offset; 42 | uint8_t main_arg_row; 43 | uint8_t main_arg_col; 44 | bool main_arg_is_pressed; 45 | bool main_arg_was_pressed; 46 | bool main_arg_any_non_trans_key_pressed; 47 | bool main_arg_trans_key_pressed; 48 | 49 | // ---------------------------------------------------------------------------- 50 | 51 | /* 52 | * main() 53 | */ 54 | int main(void) { 55 | kb_init(); // does controller initialization too 56 | 57 | kb_led_state_power_on(); 58 | 59 | usb_init(); 60 | while (!usb_configured()); 61 | kb_led_delay_usb_init(); // give the OS time to load drivers, etc. 62 | 63 | kb_led_state_ready(); 64 | 65 | for (;;) { 66 | // swap `main_kb_is_pressed` and `main_kb_was_pressed`, then update 67 | bool (*temp)[KB_ROWS][KB_COLUMNS] = main_kb_was_pressed; 68 | main_kb_was_pressed = main_kb_is_pressed; 69 | main_kb_is_pressed = temp; 70 | 71 | kb_update_matrix(*main_kb_is_pressed); 72 | 73 | // this loop is responsible to 74 | // - "execute" keys when they change state 75 | // - keep track of which layers the keys were on when they were pressed 76 | // (so they can be released using the function from that layer) 77 | // 78 | // note 79 | // - everything else is the key function's responsibility 80 | // - see the keyboard layout file ("keyboard/ergodox/layout/*.c") for 81 | // which key is assigned which function (per layer) 82 | // - see "lib/key-functions/public/*.c" for the function definitions 83 | #define row main_loop_row 84 | #define col main_loop_col 85 | #define layer main_arg_layer 86 | #define is_pressed main_arg_is_pressed 87 | #define was_pressed main_arg_was_pressed 88 | for (row=0; row 9 | * Released under The MIT License (MIT) (see "license.md") 10 | * Project located at 11 | * ------------------------------------------------------------------------- */ 12 | 13 | 14 | #ifndef USB_USAGE_PAGE_KEYBOARD_SHORT_NAMES_h 15 | #define USB_USAGE_PAGE_KEYBOARD_SHORT_NAMES_h 16 | // ---------------------------------------------------------------------------- 17 | // ---------------------------------------------------------------------------- 18 | 19 | 20 | #include "./keyboard.h" 21 | 22 | 23 | // ---------------------------------------------------------------------------- 24 | // protocol 25 | // ---------------------------------------------------------------------------- 26 | 27 | // error 28 | #define _ErrRollover KEY_ErrorRollOver 29 | #define _PostFail KEY_POSTFail 30 | #define _ErrUndef KEY_ErrorUndefined 31 | 32 | 33 | // ---------------------------------------------------------------------------- 34 | // main keyboard 35 | // ---------------------------------------------------------------------------- 36 | 37 | // letters 38 | #define _A KEY_a_A 39 | #define _B KEY_b_B 40 | #define _C KEY_c_C 41 | #define _D KEY_d_D 42 | #define _E KEY_e_E 43 | #define _F KEY_f_F 44 | #define _G KEY_g_G 45 | #define _H KEY_h_H 46 | #define _I KEY_i_I 47 | #define _J KEY_j_J 48 | #define _K KEY_k_K 49 | #define _L KEY_l_L 50 | #define _M KEY_m_M 51 | #define _N KEY_n_N 52 | #define _O KEY_o_O 53 | #define _P KEY_p_P 54 | #define _Q KEY_q_Q 55 | #define _R KEY_r_R 56 | #define _S KEY_s_S 57 | #define _T KEY_t_T 58 | #define _U KEY_u_U 59 | #define _V KEY_v_V 60 | #define _W KEY_w_W 61 | #define _X KEY_x_X 62 | #define _Y KEY_y_Y 63 | #define _Z KEY_z_Z 64 | 65 | // numbers 66 | #define _0 KEY_0_RightParenthesis 67 | #define _1 KEY_1_Exclamation 68 | #define _2 KEY_2_At 69 | #define _3 KEY_3_Pound 70 | #define _4 KEY_4_Dollar 71 | #define _5 KEY_5_Percent 72 | #define _6 KEY_6_Caret 73 | #define _7 KEY_7_Ampersand 74 | #define _8 KEY_8_Asterisk 75 | #define _9 KEY_9_LeftParenthesis 76 | 77 | // function 78 | #define _F1 KEY_F1 79 | #define _F2 KEY_F2 80 | #define _F3 KEY_F3 81 | #define _F4 KEY_F4 82 | #define _F5 KEY_F5 83 | #define _F6 KEY_F6 84 | #define _F7 KEY_F7 85 | #define _F8 KEY_F8 86 | #define _F9 KEY_F9 87 | #define _F10 KEY_F10 88 | #define _F11 KEY_F11 89 | #define _F12 KEY_F12 90 | #define _F13 KEY_F13 91 | #define _F14 KEY_F14 92 | #define _F15 KEY_F15 93 | #define _F16 KEY_F16 94 | #define _F17 KEY_F17 95 | #define _F18 KEY_F18 96 | #define _F19 KEY_F19 97 | #define _F20 KEY_F20 98 | #define _F21 KEY_F21 99 | #define _F22 KEY_F22 100 | #define _F23 KEY_F23 101 | #define _F24 KEY_F24 102 | 103 | // whitespace and symbols 104 | #define _enter KEY_ReturnEnter 105 | #define _space KEY_Spacebar 106 | #define _tab KEY_Tab 107 | // --- 108 | #define _backslash KEY_Backslash_Pipe 109 | #define _bracketL KEY_LeftBracket_LeftBrace 110 | #define _bracketR KEY_RightBracket_RightBrace 111 | #define _comma KEY_Comma_LessThan 112 | #define _dash KEY_Dash_Underscore 113 | #define _equal KEY_Equal_Plus 114 | #define _grave KEY_GraveAccent_Tilde 115 | #define _period KEY_Period_GreaterThan 116 | #define _quote KEY_SingleQuote_DoubleQuote 117 | #define _semicolon KEY_Semicolon_Colon 118 | #define _slash KEY_Slash_Question 119 | // --- 120 | #define _sep_dec KEY_DecimalSeparator 121 | #define _sep_thousands KEY_ThousandsSeparator 122 | #define _currencyUnit KEY_CurrencyUnit 123 | #define _currencySubunit KEY_CurrencySubunit 124 | 125 | // international and language 126 | #define _int1 KEY_International1 127 | #define _int2 KEY_International2 128 | #define _int3 KEY_International3 129 | #define _int4 KEY_International4 130 | #define _int5 KEY_International5 131 | #define _int6 KEY_International6 132 | #define _int7 KEY_International7 133 | #define _int8 KEY_International8 134 | #define _int9 KEY_International9 135 | // --- 136 | #define _lang1 KEY_LANG1 137 | #define _lang2 KEY_LANG2 138 | #define _lang3 KEY_LANG3 139 | #define _lang4 KEY_LANG4 140 | #define _lang5 KEY_LANG5 141 | #define _lang6 KEY_LANG6 142 | #define _lang7 KEY_LANG7 143 | #define _lang8 KEY_LANG8 144 | #define _lang9 KEY_LANG9 145 | // --- 146 | #define _backslash_nonUS KEY_NonUS_Backslash_Pipe 147 | #define _pound_nonUS KEY_NonUS_Pound_Tilde 148 | 149 | // text control 150 | #define _bs KEY_DeleteBackspace 151 | #define _del KEY_DeleteForward 152 | #define _home KEY_Home 153 | #define _end KEY_End 154 | #define _pageU KEY_PageUp 155 | #define _pageD KEY_PageDown 156 | #define _arrowU KEY_UpArrow 157 | #define _arrowD KEY_DownArrow 158 | #define _arrowL KEY_LeftArrow 159 | #define _arrowR KEY_RightArrow 160 | #define _esc KEY_Escape 161 | #define _insert KEY_Insert 162 | 163 | // modifier 164 | #define _altL KEY_LeftAlt 165 | #define _altR KEY_RightAlt 166 | #define _ctrlL KEY_LeftControl 167 | #define _ctrlR KEY_RightControl 168 | #define _guiL KEY_LeftGUI 169 | #define _guiR KEY_RightGUI 170 | #define _shiftL KEY_LeftShift 171 | #define _shiftR KEY_RightShift 172 | 173 | // lock 174 | #define _capsLock KEY_CapsLock 175 | #define _scrollLock KEY_ScrollLock 176 | // (numlock is under keypad) 177 | // --- not generally used 178 | #define _capsLock_locking KEY_LockingCapsLock 179 | #define _numLock_locking KEY_LockingNumLock 180 | #define _scrollLock_locking KEY_LockingScrollLock 181 | 182 | // special function 183 | #define _pause KEY_Pause 184 | #define _print KEY_PrintScreen 185 | // --- 186 | #define _application KEY_Application 187 | #define _execute KEY_Execute 188 | #define _power KEY_Power 189 | // --- 190 | #define _help KEY_Help 191 | #define _menu KEY_Menu 192 | // --- 193 | #define _cut KEY_Cut 194 | #define _copy KEY_Copy 195 | #define _paste KEY_Paste 196 | #define _find KEY_Find 197 | #define _select KEY_Select 198 | #define _stop KEY_Stop 199 | #define _undo KEY_Undo 200 | // --- 201 | #define _mute KEY_Mute 202 | #define _volumeU KEY_VolumeUp 203 | #define _volumeD KEY_VolumeDown 204 | // --- 205 | #define _altErase KEY_AlternateErase 206 | // --- 207 | #define _again KEY_Again 208 | #define _cancel KEY_Cancel 209 | #define _clear_again KEY_Clear_Again 210 | #define _clear KEY_Clear 211 | #define _oper KEY_Oper 212 | #define _out KEY_Out 213 | #define _prior KEY_Prior 214 | #define _return KEY_Return 215 | #define _separator KEY_Separator 216 | // --- 217 | #define _crSel KEY_CrSel_Props 218 | #define _exSel KEY_ExSel 219 | #define _sysReq KEY_SysReq_Attention 220 | 221 | 222 | // ---------------------------------------------------------------------------- 223 | // keypad 224 | // ---------------------------------------------------------------------------- 225 | 226 | // numbers and hex letters 227 | #define _1_kp KEYPAD_1_End 228 | #define _2_kp KEYPAD_2_DownArrow 229 | #define _3_kp KEYPAD_3_PageDown 230 | #define _4_kp KEYPAD_4_LeftArrow 231 | #define _5_kp KEYPAD_5 232 | #define _6_kp KEYPAD_6_RightArrow 233 | #define _7_kp KEYPAD_7_Home 234 | #define _8_kp KEYPAD_8_UpArrow 235 | #define _9_kp KEYPAD_9_PageUp 236 | #define _0_kp KEYPAD_0_Insert 237 | #define _A_kp KEYPAD_A 238 | #define _B_kp KEYPAD_B 239 | #define _C_kp KEYPAD_C 240 | #define _D_kp KEYPAD_D 241 | #define _E_kp KEYPAD_E 242 | #define _F_kp KEYPAD_F 243 | // --- 244 | #define _00_kp KEYPAD_00 245 | #define _000_kp KEYPAD_000 246 | 247 | // whitespace and symbols 248 | #define _tab_kp KEYPAD_Tab 249 | #define _space_kp KEYPAD_Space 250 | #define _enter_kp KEYPAD_ENTER 251 | // --- 252 | #define _dec_del_kp KEYPAD_Period_Delete 253 | #define _comma_kp KEYPAD_Comma 254 | #define _equal_kp KEYPAD_Equal 255 | #define _equalSign_kp KEYPAD_EqualSign 256 | #define _parenL_kp KEYPAD_LeftParenthesis 257 | #define _parenR_kp KEYPAD_RightParenthesis 258 | #define _braceL_kp KEYPAD_LeftBrace 259 | #define _braceR_kp KEYPAD_RightBrace 260 | 261 | // operations 262 | // --- basic 263 | #define _add_kp KEYPAD_Plus 264 | #define _sub_kp KEYPAD_Minus 265 | #define _mul_kp KEYPAD_Asterisk 266 | #define _div_kp KEYPAD_Slash 267 | #define _plusMinus_kp KEYPAD_PlusMinus 268 | // --- logical 269 | #define _lt_kp KEYPAD_LessThan 270 | #define _gt_kp KEYPAD_GreaterThan 271 | #define _xor_kp KEYPAD_XOR 272 | #define _and_kp KEYPAD_Ampersand 273 | #define _andand_kp KEYPAD_AmpersandAmpersand 274 | #define _pipe_kp KEYPAD_Pipe 275 | #define _pipepipe_kp KEYPAD_PipePipe 276 | #define _caret_kp KEYPAD_Caret 277 | #define _exclamation_kp KEYPAD_Exclamation 278 | // --- other 279 | #define _at_kp KEYPAD_At 280 | #define _colon_kp KEYPAD_Colon 281 | #define _percent_kp KEYPAD_Percent 282 | #define _pound_kp KEYPAD_Pound 283 | 284 | // radix 285 | #define _bin_kp KEYPAD_Binary 286 | #define _oct_kp KEYPAD_Octal 287 | #define _dec_kp KEYPAD_Decimal 288 | #define _hex_kp KEYPAD_Hexadecimal 289 | 290 | // text control 291 | #define _bs_kp KEYPAD_Backspace 292 | #define _clear_kp KEYPAD_Clear 293 | #define _clearEntry_kp KEYPAD_ClearEntry 294 | 295 | // lock 296 | #define _numLock_kp KEYPAD_NumLock_Clear 297 | 298 | // memory control 299 | #define _memStore_kp KEYPAD_MemoryStore 300 | #define _memRecall_kp KEYPAD_MemoryRecall 301 | #define _memClear_kp KEYPAD_MemoryClear 302 | #define _memAdd_kp KEYPAD_MemoryAdd 303 | #define _memSub_kp KEYPAD_MemorySubtract 304 | #define _memMul_kp KEYPAD_MemoryMultiply 305 | #define _memDiv_kp KEYPAD_MemoryDivide 306 | 307 | 308 | // ---------------------------------------------------------------------------- 309 | // ---------------------------------------------------------------------------- 310 | #endif 311 | 312 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/colemak-jc-mod.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX layout : COLEMAK JC Sticky Keys Mod 3 | * created by Ryan Prince 4 | * Description: This layout is designed for programming with a focus on 5 | * minimizing/elimnating the need to take the hands out of home-row position 6 | * to reach other keys. Layer sticky keys are used to reduce the average 7 | * number of keystrokes required to access keys in other layers. Some 8 | * redundancy of navigation and spacing keys is added to the left hand to 9 | * allow for greater one-handed access when using a mouse with the right 10 | * hand. 11 | * The alpha key layout is COLEMAK with sticky layer keys on the thumb 12 | * switches for a symbol layer and a ten-key/function 13 | * layer. 14 | * Modifiers are symetric on each hand with the exception of the Alt 15 | * key because my primary machine is a Mac which utilizes command and ctrl 16 | * for chorded shortcuts more frequenty than ctrl and alt. The layer sticky 17 | * keys compliment standard modifier sticky keys (for shift, ctrl, command, 18 | * alt) to allow fast touch typing with minimal chording in favor of 19 | * sequential keying (preferably on alternate hands) for multi-key shortcuts 20 | * as chording introduces strain and fatigue and takes your hands out of 21 | * home row position increasing the likelihood of mistyping. 22 | * Sticky keys for standard modifiers are used as an operating system setting 23 | * for the benefit of key state visualization, though this can interfere 24 | * with the kbfun_shift_press_release() behavior which implicitly adds the 25 | * shift down modifier to output symbols that require it without knowledge 26 | * of the virtual sticky state maintained by the operating system. 27 | * The ErgoDox Layout Configurator layout that best approximates the layout 28 | * defined in this file is available here: 29 | * https://www.massdrop.com/ext/ergodox/?referer=EAZJPJ&hash=f26761358ba99e21ae937173da512849 30 | * The differences are mainly the use of layer toggles instead of sticky 31 | * layer keys and many of the symbols add the kbfun_shift_press_release() 32 | * which is not accessible for all keys in the cofigurator (as of 33 | * 2013-04-10). 34 | * ----------------------------------------------------------------------------- 35 | * Copyright (c) 2012 Ben Blazak , 36 | * 2013 Ryan Prince 37 | * Released under The MIT License (MIT) (see "license.md") 38 | * Project located at 39 | * -------------------------------------------------------------------------- */ 40 | #include 41 | #include 42 | #include 43 | #include "../../../lib/data-types/misc.h" 44 | #include "../../../lib/usb/usage-page/keyboard--short-names.h" 45 | #include "../../../lib/key-functions/public.h" 46 | #include "../matrix.h" 47 | #include "../layout.h" 48 | // FUNCTIONS ------------------------------------------------------------------ 49 | void kbfun_layer_pop_all(void) { 50 | kbfun_layer_pop_1(); 51 | kbfun_layer_pop_2(); 52 | kbfun_layer_pop_3(); 53 | kbfun_layer_pop_4(); 54 | kbfun_layer_pop_5(); 55 | kbfun_layer_pop_6(); 56 | kbfun_layer_pop_7(); 57 | kbfun_layer_pop_8(); 58 | kbfun_layer_pop_9(); 59 | kbfun_layer_pop_10(); 60 | } 61 | 62 | // DEFINITIONS ---------------------------------------------------------------- 63 | #define kprrel &kbfun_press_release 64 | #define kprpst &kbfun_press_release_preserve_sticky 65 | #define mprrel &kbfun_mediakey_press_release 66 | #define ktrans &kbfun_transparent 67 | #define lpush1 &kbfun_layer_push_1 68 | #define lpush2 &kbfun_layer_push_2 69 | #define lsticky1 &kbfun_layer_sticky_1 70 | #define lsticky2 &kbfun_layer_sticky_2 71 | #define lpop &kbfun_layer_pop_all 72 | #define lpop1 &kbfun_layer_pop_1 73 | #define lpop2 &kbfun_layer_pop_2 74 | #define dbtldr &kbfun_jump_to_bootloader 75 | #define sshprre &kbfun_shift_press_release 76 | // ---------------------------------------------------------------------------- 77 | 78 | // LAYOUT --------------------------------------------------------------------- 79 | const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 80 | // LAYER 0 81 | KB_MATRIX_LAYER( 82 | // unused 83 | 0, 84 | // left hand 85 | KEY_GraveAccent_Tilde, KEY_1_Exclamation, KEY_2_At, KEY_3_Pound, KEY_4_Dollar, KEY_5_Percent, KEY_LeftBracket_LeftBrace, 86 | KEY_LeftControl, KEY_q_Q, KEY_w_W, KEY_f_F, KEY_p_P, KEY_g_G, KEY_Equal_Plus, 87 | KEY_LeftShift, KEY_a_A, KEY_r_R, KEY_s_S, KEY_t_T, KEY_d_D, 88 | KEY_LeftGUI, KEY_z_Z, KEY_x_X, KEY_c_C, KEY_v_V, KEY_b_B, 0, 89 | KEY_Home, KEY_End, KEY_PageUp, KEY_PageDown, 1, 90 | KEY_Tab, KEY_Spacebar, 91 | 0, 0, KEY_ReturnEnter, 92 | KEY_Escape, 2, KEY_LeftAlt, 93 | // right hand 94 | KEY_RightBracket_RightBrace, KEY_6_Caret, KEY_7_Ampersand, KEY_8_Asterisk, KEY_9_LeftParenthesis, KEY_0_RightParenthesis, KEY_Backslash_Pipe, 95 | KEY_Dash_Underscore, KEY_j_J, KEY_l_L, KEY_u_U, KEY_y_Y, KEY_Semicolon_Colon, KEY_RightControl, 96 | KEY_h_H, KEY_n_N, KEY_e_E, KEY_i_I, KEY_o_O, KEY_RightShift, 97 | 2, KEY_k_K, KEY_m_M, KEY_Comma_LessThan, KEY_Period_GreaterThan, KEY_Slash_Question, KEY_RightGUI, 98 | 1, KEY_DownArrow, KEY_UpArrow, KEY_LeftArrow, KEY_RightArrow, 99 | KEY_Insert, KEY_DeleteForward, 100 | 0, 0, 0, 101 | KEY_DeleteBackspace, KEY_ReturnEnter, KEY_Spacebar 102 | ), 103 | // LAYER 1 104 | KB_MATRIX_LAYER( 105 | // unused 106 | 0, 107 | // left hand 108 | 0, 0, 0, 0, 0, 0, 0, 109 | 0, KEY_1_Exclamation, KEY_2_At, KEY_3_Pound, KEY_4_Dollar, KEY_5_Percent, 0, 110 | 0, KEY_SingleQuote_DoubleQuote, 0x34, 0x2F, 0x30, KEY_Equal_Plus, 111 | 0, 0x31, KEY_Backslash_Pipe, KEY_Dash_Underscore, KEY_DeleteBackspace, KEY_Tab, 0, 112 | KEY_LeftArrow, KEY_RightArrow, KEY_UpArrow, KEY_DownArrow, 0, 113 | 0, 0, 114 | 0, 0, 0, 115 | 0, 0, 0, 116 | // right hand 117 | 0, 0, MEDIAKEY_PREV_TRACK, MEDIAKEY_PLAY_PAUSE, MEDIAKEY_NEXT_TRACK, 0, 0, 118 | 0, KEY_6_Caret, KEY_7_Ampersand, KEYPAD_Asterisk, KEYPAD_Minus, KEY_GraveAccent_Tilde, 0, 119 | KEYPAD_Plus, KEY_9_LeftParenthesis, KEY_0_RightParenthesis, KEY_LeftBracket_LeftBrace, KEY_RightBracket_RightBrace, 0, 120 | 0, KEY_GraveAccent_Tilde, KEY_DownArrow, KEY_UpArrow, KEY_LeftArrow, KEY_RightArrow, 0, 121 | 0, 0, 0, 0, 0, 122 | 0, 0, 123 | 0, 0, 0, 124 | 0, 0, 0 125 | ), 126 | // LAYER 2 127 | KB_MATRIX_LAYER( 128 | // unused 129 | 0, 130 | // left hand 131 | 0, 0, 0, 0, 0, 0, 0, 132 | 0, KEY_F9, KEY_F10, KEY_F11, KEY_F12, KEY_VolumeUp, 0, 133 | 0, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_VolumeDown, 134 | 0, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_Mute, 0, 135 | 0, 0, 0, 0, 0, 136 | 0, 0, 137 | 0, 0, 0, 138 | 0, 0, 0, 139 | // right hand 140 | 0, 0, KEYPAD_NumLock_Clear, KEYPAD_Asterisk, KEYPAD_Slash, KEY_5_Percent, 0, 141 | 0, KEYPAD_Minus, KEYPAD_7_Home, KEYPAD_8_UpArrow, KEYPAD_9_PageUp, KEYPAD_Plus, 0, 142 | KEYPAD_Equal, KEYPAD_4_LeftArrow, KEYPAD_5, KEYPAD_6_RightArrow, KEYPAD_0_Insert, 0, 143 | 0, KEY_Comma_LessThan, KEYPAD_1_End, KEYPAD_2_DownArrow, KEYPAD_3_PageDown, KEYPAD_Period_Delete, 0, 144 | 0, 0, 0, 0, 0, 145 | 0, 0, 146 | 0, 0, 0, 147 | 0, 0, 0 148 | ), 149 | }; 150 | // ---------------------------------------------------------------------------- 151 | 152 | // PRESS ---------------------------------------------------------------------- 153 | const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 154 | // LAYER 0 155 | KB_MATRIX_LAYER( 156 | // unused 157 | NULL, 158 | // left hand 159 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 160 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 161 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 162 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, lpop, 163 | kprrel, kprrel, kprrel, kprrel, lsticky1, 164 | kprrel, kprrel, 165 | NULL, NULL, kprrel, 166 | kprrel, lsticky2, kprrel, 167 | // right hand 168 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 169 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 170 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 171 | lsticky2, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 172 | lsticky1, kprrel, kprrel, kprrel, kprrel, 173 | kprrel, kprrel, 174 | lpop, NULL, NULL, 175 | kprrel, kprrel, kprrel 176 | ), 177 | // LAYER 1 178 | KB_MATRIX_LAYER( 179 | // unused 180 | NULL, 181 | // left hand 182 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 183 | ktrans, sshprre, sshprre, sshprre, sshprre, sshprre, ktrans, 184 | ktrans, kprrel, sshprre, sshprre, sshprre, kprrel, 185 | ktrans, sshprre, kprrel, sshprre, kprrel, kprrel, ktrans, 186 | kprrel, kprrel, kprrel, kprrel, ktrans, 187 | ktrans, ktrans, 188 | NULL, NULL, ktrans, 189 | ktrans, ktrans, ktrans, 190 | // right hand 191 | ktrans, ktrans, mprrel, mprrel, mprrel, ktrans, ktrans, 192 | ktrans, sshprre, sshprre, kprrel, kprrel, kprrel, ktrans, 193 | kprrel, sshprre, sshprre, kprrel, kprrel, ktrans, 194 | ktrans, sshprre, kprrel, kprrel, kprrel, kprrel, ktrans, 195 | ktrans, ktrans, ktrans, ktrans, ktrans, 196 | ktrans, ktrans, 197 | ktrans, NULL, NULL, 198 | ktrans, ktrans, ktrans 199 | ), 200 | // LAYER 2 201 | KB_MATRIX_LAYER( 202 | // unused 203 | NULL, 204 | // left hand 205 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 206 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 207 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, 208 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 209 | ktrans, ktrans, ktrans, ktrans, ktrans, 210 | ktrans, ktrans, 211 | NULL, NULL, ktrans, 212 | ktrans, ktrans, ktrans, 213 | // right hand 214 | dbtldr, kprrel, kprrel, kprrel, kprrel, sshprre, ktrans, 215 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 216 | kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 217 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 218 | ktrans, ktrans, ktrans, ktrans, ktrans, 219 | ktrans, ktrans, 220 | ktrans, NULL, NULL, 221 | ktrans, ktrans, ktrans 222 | ), 223 | }; 224 | // ---------------------------------------------------------------------------- 225 | 226 | // RELEASE -------------------------------------------------------------------- 227 | const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 228 | // LAYER 0 229 | KB_MATRIX_LAYER( 230 | // unused 231 | NULL, 232 | // left hand 233 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 234 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 235 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 236 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, NULL, 237 | kprrel, kprrel, kprrel, kprrel, lsticky1, 238 | kprrel, kprrel, 239 | NULL, NULL, kprrel, 240 | kprrel, lsticky2, kprrel, 241 | // right hand 242 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 243 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 244 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 245 | lsticky2, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 246 | lsticky1, kprrel, kprrel, kprrel, kprrel, 247 | kprrel, kprrel, 248 | NULL, NULL, NULL, 249 | kprrel, kprrel, kprrel 250 | ), 251 | // LAYER 1 252 | KB_MATRIX_LAYER( 253 | // unused 254 | NULL, 255 | // left hand 256 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 257 | ktrans, sshprre, sshprre, sshprre, sshprre, sshprre, ktrans, 258 | ktrans, kprrel, sshprre, sshprre, sshprre, kprrel, 259 | kprrel, sshprre, kprrel, sshprre, kprrel, kprrel, ktrans, 260 | kprrel, kprrel, kprrel, kprrel, ktrans, 261 | ktrans, ktrans, 262 | NULL, NULL, ktrans, 263 | ktrans, ktrans, ktrans, 264 | // right hand 265 | ktrans, ktrans, mprrel, mprrel, mprrel, ktrans, ktrans, 266 | ktrans, sshprre, sshprre, kprrel, kprrel, kprrel, ktrans, 267 | kprrel, sshprre, sshprre, kprrel, kprrel, ktrans, 268 | ktrans, sshprre, kprrel, kprrel, kprrel, kprrel, ktrans, 269 | ktrans, ktrans, ktrans, ktrans, ktrans, 270 | ktrans, ktrans, 271 | ktrans, NULL, NULL, 272 | ktrans, ktrans, ktrans 273 | ), 274 | // LAYER 2 275 | KB_MATRIX_LAYER( 276 | // unused 277 | NULL, 278 | // left hand 279 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 280 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 281 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, 282 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 283 | ktrans, ktrans, ktrans, ktrans, ktrans, 284 | ktrans, ktrans, 285 | NULL, NULL, ktrans, 286 | kprrel, ktrans, ktrans, 287 | // right hand 288 | NULL, kprrel, kprrel, kprrel, kprrel, sshprre, ktrans, 289 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 290 | kprrel, kprrel, kprrel, kprrel, kprrel, ktrans, 291 | ktrans, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 292 | ktrans, ktrans, ktrans, ktrans, ktrans, 293 | ktrans, ktrans, 294 | ktrans, NULL, NULL, 295 | ktrans, ktrans, ktrans 296 | ), 297 | }; 298 | // ---------------------------------------------------------------------------- 299 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/dvorak-kinesis-mod.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX layout : Dvorak (modified from the Kinesis layout) 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "../../../lib/data-types/misc.h" 14 | #include "../../../lib/usb/usage-page/keyboard--short-names.h" 15 | #include "../../../lib/key-functions/public.h" 16 | #include "../matrix.h" 17 | #include "../layout.h" 18 | 19 | // ---------------------------------------------------------------------------- 20 | // ---------------------------------------------------------------------------- 21 | 22 | const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 23 | 24 | KB_MATRIX_LAYER( // layout: layer 0: default 25 | // unused 26 | 0, 27 | // left hand 28 | _equal, _1, _2, _3, _4, _5, _esc, 29 | _backslash, _quote, _comma, _period, _P, _Y, 1, 30 | _tab, _A, _O, _E, _U, _I, 31 | _shiftL, _semicolon, _Q, _J, _K, _X, 1, 32 | _guiL, _grave, _backslash, _arrowL, _arrowR, 33 | _ctrlL, _altL, 34 | 0, 0, _home, 35 | _bs, _del, _end, 36 | // right hand 37 | 3, _6, _7, _8, _9, _0, _dash, 38 | _bracketL, _F, _G, _C, _R, _L, _bracketR, 39 | _D, _H, _T, _N, _S, _slash, 40 | 1, _B, _M, _W, _V, _Z, _shiftR, 41 | _arrowL, _arrowD, _arrowU, _arrowR, _guiR, 42 | _altR, _ctrlR, 43 | _pageU, 0, 0, 44 | _pageD, _enter, _space ), 45 | 46 | 47 | KB_MATRIX_LAYER( // layout: layer 1: function and symbol keys 48 | // unused 49 | 0, 50 | // left hand 51 | 0, _F1, _F2, _F3, _F4, _F5, _F11, 52 | 0, _bracketL, _bracketR, _bracketL, _bracketR, 0, 1, 53 | 0, _semicolon, _slash, _dash, _0_kp,_semicolon, 54 | 0, _6_kp, _7_kp, _8_kp, _9_kp, _equal, 2, 55 | 0, 0, 0, 0, 0, 56 | 0, 0, 57 | 0, 0, 0, 58 | 0, 0, 0, 59 | // right hand 60 | _F12, _F6, _F7, _F8, _F9, _F10, _power, 61 | 0, 0, _dash, _comma, _period,_currencyUnit, _volumeU, 62 | _backslash, _1_kp, _9, _0, _equal, _volumeD, 63 | 2, _8, _2_kp, _3_kp, _4_kp, _5_kp, _mute, 64 | 0, 0, 0, 0, 0, 65 | 0, 0, 66 | 0, 0, 0, 67 | 0, 0, 0 ), 68 | 69 | 70 | KB_MATRIX_LAYER( // layout: layer 2: keyboard functions 71 | // unused 72 | 0, 73 | // left hand 74 | 0, 0, 0, 0, 0, 0, 0, 75 | 0, 0, 0, 0, 0, 0, 0, 76 | 0, 0, 0, 0, 0, 0, 77 | 0, 0, 0, 0, 0, 0, 0, 78 | 0, 0, 0, 0, 0, 79 | 0, 0, 80 | 0, 0, 0, 81 | 0, 0, 0, 82 | // right hand 83 | 0, 0, 0, 0, 0, 0, 0, 84 | 0, 0, 0, 0, 0, 0, 0, 85 | 0, 0, 0, 0, 0, 0, 86 | 0, 0, 0, 0, 0, 0, 0, 87 | 0, 0, 0, 0, 0, 88 | 0, 0, 89 | 0, 0, 0, 90 | 0, 0, 0 ), 91 | 92 | 93 | KB_MATRIX_LAYER( // layout: layer 3: numpad 94 | // unused 95 | 0, 96 | // left hand 97 | 0, 0, 0, 0, 0, 0, 0, 98 | 0, 0, 0, 0, 0, 0, 0, 99 | 0, 0, 0, 0, 0, 0, 100 | 0, 0, 0, 0, 0, 0, 0, 101 | 0, _insert, 0, 0, 0, 102 | 0, 0, 103 | 0, 0, 0, 104 | 0, 0, 0, 105 | // right hand 106 | 3, 0, 3, _equal_kp, _div_kp, _mul_kp, 0, 107 | 0, 0, _7_kp, _8_kp, _9_kp, _sub_kp, 0, 108 | 0, _4_kp, _5_kp, _6_kp, _add_kp, 0, 109 | 0, 0, _1_kp, _2_kp, _3_kp, _enter_kp, 0, 110 | 0, 0, _period, _enter_kp, 0, 111 | 0, 0, 112 | 0, 0, 0, 113 | 0, 0, _0_kp ), 114 | 115 | }; 116 | 117 | // ---------------------------------------------------------------------------- 118 | // ---------------------------------------------------------------------------- 119 | 120 | // aliases 121 | 122 | // basic 123 | #define kprrel &kbfun_press_release 124 | #define ktog &kbfun_toggle 125 | #define ktrans &kbfun_transparent 126 | // --- layer push/pop functions 127 | #define lpush1 &kbfun_layer_push_1 128 | #define lpush2 &kbfun_layer_push_2 129 | #define lpush3 &kbfun_layer_push_3 130 | #define lpush4 &kbfun_layer_push_4 131 | #define lpush5 &kbfun_layer_push_5 132 | #define lpush6 &kbfun_layer_push_6 133 | #define lpush7 &kbfun_layer_push_7 134 | #define lpush8 &kbfun_layer_push_8 135 | #define lpush9 &kbfun_layer_push_9 136 | #define lpush10 &kbfun_layer_push_10 137 | #define lpop1 &kbfun_layer_pop_1 138 | #define lpop2 &kbfun_layer_pop_2 139 | #define lpop3 &kbfun_layer_pop_3 140 | #define lpop4 &kbfun_layer_pop_4 141 | #define lpop5 &kbfun_layer_pop_5 142 | #define lpop6 &kbfun_layer_pop_6 143 | #define lpop7 &kbfun_layer_pop_7 144 | #define lpop8 &kbfun_layer_pop_8 145 | #define lpop9 &kbfun_layer_pop_9 146 | #define lpop10 &kbfun_layer_pop_10 147 | // --- 148 | 149 | // device 150 | #define dbtldr &kbfun_jump_to_bootloader 151 | 152 | // special 153 | #define sshprre &kbfun_shift_press_release 154 | #define s2kcap &kbfun_2_keys_capslock_press_release 155 | #define slpunum &kbfun_layer_push_numpad 156 | #define slponum &kbfun_layer_pop_numpad 157 | 158 | // ---------------------------------------------------------------------------- 159 | // ---------------------------------------------------------------------------- 160 | 161 | const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 162 | 163 | KB_MATRIX_LAYER( // press: layer 0: default 164 | // unused 165 | NULL, 166 | // left hand 167 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 168 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1, 169 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 170 | s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1, 171 | kprrel, kprrel, kprrel, kprrel, kprrel, 172 | kprrel, kprrel, 173 | NULL, NULL, kprrel, 174 | kprrel, kprrel, kprrel, 175 | // right hand 176 | slpunum, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 177 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 178 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 179 | lpush1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap, 180 | kprrel, kprrel, kprrel, kprrel, kprrel, 181 | kprrel, kprrel, 182 | kprrel, NULL, NULL, 183 | kprrel, kprrel, kprrel ), 184 | 185 | 186 | KB_MATRIX_LAYER( // press: layer 1: function and symbol keys 187 | // unused 188 | NULL, 189 | // left hand 190 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 191 | ktrans,sshprre,sshprre, kprrel, kprrel, NULL, lpop1, 192 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, 193 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, lpush2, 194 | ktrans, ktrans, ktrans, ktrans, ktrans, 195 | ktrans, ktrans, 196 | ktrans, ktrans, ktrans, 197 | ktrans, ktrans, ktrans, 198 | // right hand 199 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 200 | ktrans, NULL, kprrel,sshprre,sshprre, kprrel, kprrel, 201 | kprrel, kprrel,sshprre,sshprre,sshprre, kprrel, 202 | lpush2,sshprre, kprrel, kprrel, kprrel, kprrel, kprrel, 203 | ktrans, ktrans, ktrans, ktrans, ktrans, 204 | ktrans, ktrans, 205 | ktrans, ktrans, ktrans, 206 | ktrans, ktrans, ktrans ), 207 | 208 | 209 | KB_MATRIX_LAYER( // press: layer 2: keyboard functions 210 | // unused 211 | NULL, 212 | // left hand 213 | dbtldr, NULL, NULL, NULL, NULL, NULL, NULL, 214 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 215 | NULL, NULL, NULL, NULL, NULL, NULL, 216 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 217 | NULL, NULL, NULL, NULL, NULL, 218 | NULL, NULL, 219 | NULL, NULL, NULL, 220 | NULL, NULL, NULL, 221 | // right hand 222 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 223 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 224 | NULL, NULL, NULL, NULL, NULL, NULL, 225 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 226 | NULL, NULL, NULL, NULL, NULL, 227 | NULL, NULL, 228 | NULL, NULL, NULL, 229 | NULL, NULL, NULL ), 230 | 231 | 232 | KB_MATRIX_LAYER( // press: layer 3: numpad 233 | // unused 234 | NULL, 235 | // left hand 236 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 237 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 238 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 239 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 240 | ktrans, kprrel, ktrans, ktrans, ktrans, 241 | ktrans, ktrans, 242 | ktrans, ktrans, ktrans, 243 | ktrans, ktrans, ktrans, 244 | // right hand 245 | slponum, ktrans,slponum, kprrel, kprrel, kprrel, ktrans, 246 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 247 | ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 248 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 249 | ktrans, ktrans, kprrel, kprrel, ktrans, 250 | ktrans, ktrans, 251 | ktrans, ktrans, ktrans, 252 | ktrans, ktrans, kprrel ), 253 | 254 | }; 255 | 256 | // ---------------------------------------------------------------------------- 257 | // ---------------------------------------------------------------------------- 258 | 259 | const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 260 | 261 | KB_MATRIX_LAYER( // release: layer 0: default 262 | // unused 263 | NULL, 264 | // left hand 265 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 266 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, NULL, 267 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 268 | s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpop1, 269 | kprrel, kprrel, kprrel, kprrel, kprrel, 270 | kprrel, kprrel, 271 | NULL, NULL, kprrel, 272 | kprrel, kprrel, kprrel, 273 | // right hand 274 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 275 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 276 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 277 | lpop1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap, 278 | kprrel, kprrel, kprrel, kprrel, kprrel, 279 | kprrel, kprrel, 280 | kprrel, NULL, NULL, 281 | kprrel, kprrel, kprrel ), 282 | 283 | 284 | KB_MATRIX_LAYER( // release: layer 1: function and symbol keys 285 | // unused 286 | NULL, 287 | // left hand 288 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 289 | ktrans,sshprre,sshprre, kprrel, kprrel, NULL, NULL, 290 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, 291 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, lpop2, 292 | ktrans, ktrans, ktrans, ktrans, ktrans, 293 | ktrans, ktrans, 294 | ktrans, ktrans, ktrans, 295 | ktrans, ktrans, ktrans, 296 | // right hand 297 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 298 | ktrans, NULL, kprrel,sshprre,sshprre, kprrel, kprrel, 299 | kprrel, kprrel,sshprre,sshprre,sshprre, kprrel, 300 | lpop2,sshprre, kprrel, kprrel, kprrel, kprrel, kprrel, 301 | ktrans, ktrans, ktrans, ktrans, ktrans, 302 | ktrans, ktrans, 303 | ktrans, ktrans, ktrans, 304 | ktrans, ktrans, ktrans ), 305 | 306 | 307 | KB_MATRIX_LAYER( // release: layer 2: keyboard functions 308 | // unused 309 | NULL, 310 | // left hand 311 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 312 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 313 | NULL, NULL, NULL, NULL, NULL, NULL, 314 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 315 | NULL, NULL, NULL, NULL, NULL, 316 | NULL, NULL, 317 | NULL, NULL, NULL, 318 | NULL, NULL, NULL, 319 | // right hand 320 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 321 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 322 | NULL, NULL, NULL, NULL, NULL, NULL, 323 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 324 | NULL, NULL, NULL, NULL, NULL, 325 | NULL, NULL, 326 | NULL, NULL, NULL, 327 | NULL, NULL, NULL ), 328 | 329 | 330 | KB_MATRIX_LAYER( // release: layer 3: numpad 331 | // unused 332 | NULL, 333 | // left hand 334 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 335 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 336 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 337 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 338 | ktrans, kprrel, ktrans, ktrans, ktrans, 339 | ktrans, ktrans, 340 | ktrans, ktrans, ktrans, 341 | ktrans, ktrans, ktrans, 342 | // right hand 343 | NULL, ktrans, NULL, kprrel, kprrel, kprrel, ktrans, 344 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 345 | ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 346 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 347 | ktrans, ktrans, kprrel, kprrel, ktrans, 348 | ktrans, ktrans, 349 | ktrans, ktrans, ktrans, 350 | ktrans, ktrans, kprrel ), 351 | 352 | 353 | KB_MATRIX_LAYER( // release: layer 3: nothing (just making sure unused 354 | // functions don't get compiled out) 355 | // unused 356 | NULL, 357 | // other 358 | kprrel, lpush8, lpop8, NULL, NULL, NULL, NULL, NULL, 359 | ktog, lpush9, lpop9, NULL, NULL, NULL, NULL, NULL, 360 | ktrans,lpush10, lpop10, NULL, NULL, NULL, NULL, NULL, 361 | lpush1, lpop1, NULL, NULL, NULL, NULL, NULL, NULL, 362 | lpush2, lpop2, dbtldr, NULL, NULL, NULL, NULL, NULL, 363 | lpush3, lpop3, NULL, NULL, NULL, NULL, NULL, NULL, 364 | lpush4, lpop4, s2kcap, NULL, NULL, NULL, NULL, NULL, 365 | lpush5, lpop5,slpunum, NULL, NULL, NULL, NULL, NULL, 366 | lpush6, lpop6,slponum, NULL, NULL, NULL, NULL, NULL, 367 | lpush7, lpop7, NULL, NULL, NULL, NULL, NULL, NULL ) 368 | 369 | }; 370 | 371 | -------------------------------------------------------------------------------- /src/keyboard/ergodox/layout/qwerty-kinesis-mod.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * ergoDOX layout : QWERTY (modified from the Kinesis layout) 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include 11 | #include 12 | #include 13 | #include "../../../lib/data-types/misc.h" 14 | #include "../../../lib/usb/usage-page/keyboard--short-names.h" 15 | #include "../../../lib/key-functions/public.h" 16 | #include "../matrix.h" 17 | #include "../layout.h" 18 | 19 | // ---------------------------------------------------------------------------- 20 | // ---------------------------------------------------------------------------- 21 | 22 | const uint8_t PROGMEM _kb_layout[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 23 | 24 | KB_MATRIX_LAYER( // layout: layer 0: default 25 | // unused 26 | 0, 27 | // left hand 28 | _equal, _1, _2, _3, _4, _5, _esc, 29 | _backslash, _Q, _W, _E, _R, _T, 1, 30 | _tab, _A, _S, _D, _F, _G, 31 | _shiftL, _Z, _X, _C, _V, _B, 1, 32 | _guiL, _grave, _backslash, _arrowL, _arrowR, 33 | _ctrlL, _altL, 34 | 0, 0, _home, 35 | _bs, _del, _end, 36 | // right hand 37 | 3, _6, _7, _8, _9, _0, _dash, 38 | _bracketL, _Y, _U, _I, _O, _P, _bracketR, 39 | _H, _J, _K, _L, _semicolon, _quote, 40 | 1, _N, _M, _comma, _period, _slash, _shiftR, 41 | _arrowL, _arrowD, _arrowU, _arrowR, _guiR, 42 | _altR, _ctrlR, 43 | _pageU, 0, 0, 44 | _pageD, _enter, _space ), 45 | 46 | 47 | KB_MATRIX_LAYER( // layout: layer 1: function and symbol keys 48 | // unused 49 | 0, 50 | // left hand 51 | 0, _F1, _F2, _F3, _F4, _F5, _F11, 52 | 0, _bracketL, _bracketR, _bracketL, _bracketR, 0, 1, 53 | 0, _semicolon, _slash, _dash, _0_kp,_semicolon, 54 | 0, _6_kp, _7_kp, _8_kp, _9_kp, _equal, 2, 55 | 0, 0, 0, 0, 0, 56 | 0, 0, 57 | 0, 0, 0, 58 | 0, 0, 0, 59 | // right hand 60 | _F12, _F6, _F7, _F8, _F9, _F10, _power, 61 | 0, 0, _dash, _comma, _period,_currencyUnit, _volumeU, 62 | _backslash, _1_kp, _9, _0, _equal, _volumeD, 63 | 2, _8, _2_kp, _3_kp, _4_kp, _5_kp, _mute, 64 | 0, 0, 0, 0, 0, 65 | 0, 0, 66 | 0, 0, 0, 67 | 0, 0, 0 ), 68 | 69 | 70 | KB_MATRIX_LAYER( // layout: layer 2: keyboard functions 71 | // unused 72 | 0, 73 | // left hand 74 | 0, 0, 0, 0, 0, 0, 0, 75 | 0, 0, 0, 0, 0, 0, 0, 76 | 0, 0, 0, 0, 0, 0, 77 | 0, 0, 0, 0, 0, 0, 0, 78 | 0, 0, 0, 0, 0, 79 | 0, 0, 80 | 0, 0, 0, 81 | 0, 0, 0, 82 | // right hand 83 | 0, 0, 0, 0, 0, 0, 0, 84 | 0, 0, 0, 0, 0, 0, 0, 85 | 0, 0, 0, 0, 0, 0, 86 | 0, 0, 0, 0, 0, 0, 0, 87 | 0, 0, 0, 0, 0, 88 | 0, 0, 89 | 0, 0, 0, 90 | 0, 0, 0 ), 91 | 92 | 93 | KB_MATRIX_LAYER( // layout: layer 3: numpad 94 | // unused 95 | 0, 96 | // left hand 97 | 0, 0, 0, 0, 0, 0, 0, 98 | 0, 0, 0, 0, 0, 0, 0, 99 | 0, 0, 0, 0, 0, 0, 100 | 0, 0, 0, 0, 0, 0, 0, 101 | 0, _insert, 0, 0, 0, 102 | 0, 0, 103 | 0, 0, 0, 104 | 0, 0, 0, 105 | // right hand 106 | 3, 0, 3, _equal_kp, _div_kp, _mul_kp, 0, 107 | 0, 0, _7_kp, _8_kp, _9_kp, _sub_kp, 0, 108 | 0, _4_kp, _5_kp, _6_kp, _add_kp, 0, 109 | 0, 0, _1_kp, _2_kp, _3_kp, _enter_kp, 0, 110 | 0, 0, _period, _enter_kp, 0, 111 | 0, 0, 112 | 0, 0, 0, 113 | 0, 0, _0_kp ), 114 | 115 | }; 116 | 117 | // ---------------------------------------------------------------------------- 118 | // ---------------------------------------------------------------------------- 119 | 120 | // aliases 121 | 122 | // basic 123 | #define kprrel &kbfun_press_release 124 | #define ktog &kbfun_toggle 125 | #define ktrans &kbfun_transparent 126 | // --- layer push/pop functions 127 | #define lpush1 &kbfun_layer_push_1 128 | #define lpush2 &kbfun_layer_push_2 129 | #define lpush3 &kbfun_layer_push_3 130 | #define lpush4 &kbfun_layer_push_4 131 | #define lpush5 &kbfun_layer_push_5 132 | #define lpush6 &kbfun_layer_push_6 133 | #define lpush7 &kbfun_layer_push_7 134 | #define lpush8 &kbfun_layer_push_8 135 | #define lpush9 &kbfun_layer_push_9 136 | #define lpush10 &kbfun_layer_push_10 137 | #define lpop1 &kbfun_layer_pop_1 138 | #define lpop2 &kbfun_layer_pop_2 139 | #define lpop3 &kbfun_layer_pop_3 140 | #define lpop4 &kbfun_layer_pop_4 141 | #define lpop5 &kbfun_layer_pop_5 142 | #define lpop6 &kbfun_layer_pop_6 143 | #define lpop7 &kbfun_layer_pop_7 144 | #define lpop8 &kbfun_layer_pop_8 145 | #define lpop9 &kbfun_layer_pop_9 146 | #define lpop10 &kbfun_layer_pop_10 147 | // --- 148 | 149 | // device 150 | #define dbtldr &kbfun_jump_to_bootloader 151 | 152 | // special 153 | #define sshprre &kbfun_shift_press_release 154 | #define s2kcap &kbfun_2_keys_capslock_press_release 155 | #define slpunum &kbfun_layer_push_numpad 156 | #define slponum &kbfun_layer_pop_numpad 157 | 158 | // ---------------------------------------------------------------------------- 159 | // ---------------------------------------------------------------------------- 160 | 161 | const void_funptr_t PROGMEM _kb_layout_press[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 162 | 163 | KB_MATRIX_LAYER( // press: layer 0: default 164 | // unused 165 | NULL, 166 | // left hand 167 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 168 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1, 169 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 170 | s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpush1, 171 | kprrel, kprrel, kprrel, kprrel, kprrel, 172 | kprrel, kprrel, 173 | NULL, NULL, kprrel, 174 | kprrel, kprrel, kprrel, 175 | // right hand 176 | slpunum, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 177 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 178 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 179 | lpush1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap, 180 | kprrel, kprrel, kprrel, kprrel, kprrel, 181 | kprrel, kprrel, 182 | kprrel, NULL, NULL, 183 | kprrel, kprrel, kprrel ), 184 | 185 | 186 | KB_MATRIX_LAYER( // press: layer 1: function and symbol keys 187 | // unused 188 | NULL, 189 | // left hand 190 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 191 | ktrans,sshprre,sshprre, kprrel, kprrel, NULL, lpop1, 192 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, 193 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, lpush2, 194 | ktrans, ktrans, ktrans, ktrans, ktrans, 195 | ktrans, ktrans, 196 | ktrans, ktrans, ktrans, 197 | ktrans, ktrans, ktrans, 198 | // right hand 199 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 200 | ktrans, NULL, kprrel,sshprre,sshprre, kprrel, kprrel, 201 | kprrel, kprrel,sshprre,sshprre,sshprre, kprrel, 202 | lpush2,sshprre, kprrel, kprrel, kprrel, kprrel, kprrel, 203 | ktrans, ktrans, ktrans, ktrans, ktrans, 204 | ktrans, ktrans, 205 | ktrans, ktrans, ktrans, 206 | ktrans, ktrans, ktrans ), 207 | 208 | 209 | KB_MATRIX_LAYER( // press: layer 2: keyboard functions 210 | // unused 211 | NULL, 212 | // left hand 213 | dbtldr, NULL, NULL, NULL, NULL, NULL, NULL, 214 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 215 | NULL, NULL, NULL, NULL, NULL, NULL, 216 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 217 | NULL, NULL, NULL, NULL, NULL, 218 | NULL, NULL, 219 | NULL, NULL, NULL, 220 | NULL, NULL, NULL, 221 | // right hand 222 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 223 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 224 | NULL, NULL, NULL, NULL, NULL, NULL, 225 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 226 | NULL, NULL, NULL, NULL, NULL, 227 | NULL, NULL, 228 | NULL, NULL, NULL, 229 | NULL, NULL, NULL ), 230 | 231 | 232 | KB_MATRIX_LAYER( // press: layer 3: numpad 233 | // unused 234 | NULL, 235 | // left hand 236 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 237 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 238 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 239 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 240 | ktrans, kprrel, ktrans, ktrans, ktrans, 241 | ktrans, ktrans, 242 | ktrans, ktrans, ktrans, 243 | ktrans, ktrans, ktrans, 244 | // right hand 245 | slponum, ktrans,slponum, kprrel, kprrel, kprrel, ktrans, 246 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 247 | ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 248 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 249 | ktrans, ktrans, kprrel, kprrel, ktrans, 250 | ktrans, ktrans, 251 | ktrans, ktrans, ktrans, 252 | ktrans, ktrans, kprrel ), 253 | 254 | }; 255 | 256 | // ---------------------------------------------------------------------------- 257 | // ---------------------------------------------------------------------------- 258 | 259 | const void_funptr_t PROGMEM _kb_layout_release[KB_LAYERS][KB_ROWS][KB_COLUMNS] = { 260 | 261 | KB_MATRIX_LAYER( // release: layer 0: default 262 | // unused 263 | NULL, 264 | // left hand 265 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 266 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, NULL, 267 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 268 | s2kcap, kprrel, kprrel, kprrel, kprrel, kprrel, lpop1, 269 | kprrel, kprrel, kprrel, kprrel, kprrel, 270 | kprrel, kprrel, 271 | NULL, NULL, kprrel, 272 | kprrel, kprrel, kprrel, 273 | // right hand 274 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 275 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 276 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 277 | lpop1, kprrel, kprrel, kprrel, kprrel, kprrel, s2kcap, 278 | kprrel, kprrel, kprrel, kprrel, kprrel, 279 | kprrel, kprrel, 280 | kprrel, NULL, NULL, 281 | kprrel, kprrel, kprrel ), 282 | 283 | 284 | KB_MATRIX_LAYER( // release: layer 1: function and symbol keys 285 | // unused 286 | NULL, 287 | // left hand 288 | NULL, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 289 | ktrans,sshprre,sshprre, kprrel, kprrel, NULL, NULL, 290 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, 291 | ktrans, kprrel, kprrel, kprrel, kprrel,sshprre, lpop2, 292 | ktrans, ktrans, ktrans, ktrans, ktrans, 293 | ktrans, ktrans, 294 | ktrans, ktrans, ktrans, 295 | ktrans, ktrans, ktrans, 296 | // right hand 297 | kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, kprrel, 298 | ktrans, NULL, kprrel,sshprre,sshprre, kprrel, kprrel, 299 | kprrel, kprrel,sshprre,sshprre,sshprre, kprrel, 300 | lpop2,sshprre, kprrel, kprrel, kprrel, kprrel, kprrel, 301 | ktrans, ktrans, ktrans, ktrans, ktrans, 302 | ktrans, ktrans, 303 | ktrans, ktrans, ktrans, 304 | ktrans, ktrans, ktrans ), 305 | 306 | 307 | KB_MATRIX_LAYER( // release: layer 2: keyboard functions 308 | // unused 309 | NULL, 310 | // left hand 311 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 312 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 313 | NULL, NULL, NULL, NULL, NULL, NULL, 314 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 315 | NULL, NULL, NULL, NULL, NULL, 316 | NULL, NULL, 317 | NULL, NULL, NULL, 318 | NULL, NULL, NULL, 319 | // right hand 320 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 321 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 322 | NULL, NULL, NULL, NULL, NULL, NULL, 323 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 324 | NULL, NULL, NULL, NULL, NULL, 325 | NULL, NULL, 326 | NULL, NULL, NULL, 327 | NULL, NULL, NULL ), 328 | 329 | 330 | KB_MATRIX_LAYER( // release: layer 3: numpad 331 | // unused 332 | NULL, 333 | // left hand 334 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 335 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 336 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 337 | ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, ktrans, 338 | ktrans, kprrel, ktrans, ktrans, ktrans, 339 | ktrans, ktrans, 340 | ktrans, ktrans, ktrans, 341 | ktrans, ktrans, ktrans, 342 | // right hand 343 | NULL, ktrans, NULL, kprrel, kprrel, kprrel, ktrans, 344 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 345 | ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 346 | ktrans, ktrans, kprrel, kprrel, kprrel, kprrel, ktrans, 347 | ktrans, ktrans, kprrel, kprrel, ktrans, 348 | ktrans, ktrans, 349 | ktrans, ktrans, ktrans, 350 | ktrans, ktrans, kprrel ), 351 | 352 | 353 | KB_MATRIX_LAYER( // release: layer 3: nothing (just making sure unused 354 | // functions don't get compiled out) 355 | // unused 356 | NULL, 357 | // other 358 | kprrel, lpush8, lpop8, NULL, NULL, NULL, NULL, NULL, 359 | ktog, lpush9, lpop9, NULL, NULL, NULL, NULL, NULL, 360 | ktrans,lpush10, lpop10, NULL, NULL, NULL, NULL, NULL, 361 | lpush1, lpop1, NULL, NULL, NULL, NULL, NULL, NULL, 362 | lpush2, lpop2, dbtldr, NULL, NULL, NULL, NULL, NULL, 363 | lpush3, lpop3, NULL, NULL, NULL, NULL, NULL, NULL, 364 | lpush4, lpop4, s2kcap, NULL, NULL, NULL, NULL, NULL, 365 | lpush5, lpop5,slpunum, NULL, NULL, NULL, NULL, NULL, 366 | lpush6, lpop6,slponum, NULL, NULL, NULL, NULL, NULL, 367 | lpush7, lpop7, NULL, NULL, NULL, NULL, NULL, NULL ) 368 | 369 | }; 370 | 371 | -------------------------------------------------------------------------------- /src/lib/usb/usage-page/keyboard.h: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * USB Keyboard Key Codes (usage page 0x07) 3 | * 4 | * Taken from [the HID Usage Tables pdf][1], Section 10, 5 | * which can be found on [the HID Page][2] at 6 | * 7 | * - `Boot Keyboard Req.` indicates that the usage code is one that should be 8 | * supported by the listed types of keyboards (104-key, ...) on boot 9 | * 10 | * - `KEY_` indicates a Keyboard key 11 | * - `KEYPAD_` indicates a Keypad key 12 | * - Multiple names concatenated in CamelCase indicate a single value 13 | * - Multiple names separated by `_`s indicate shifted or alternate values 14 | * 15 | * [1]: http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf 16 | * [2]: http://www.usb.org/developers/hidpage 17 | * ---------------------------------------------------------------------------- 18 | * Copyright (c) 2012 Ben Blazak 19 | * Released under The MIT License (MIT) (see "license.md") 20 | * Project located at 21 | * ------------------------------------------------------------------------- */ 22 | 23 | 24 | #ifndef USB_USAGE_PAGE_KEYBOARD_h 25 | #define USB_USAGE_PAGE_KEYBOARD_h 26 | // ---------------------------------------------------------------------------- 27 | // ---------------------------------------------------------------------------- 28 | 29 | 30 | // Name ID // PC Mac Unix Boot Keyboard Req. 31 | // --------------------------- ---- -- --- ---- --------------------- 32 | 33 | // (Reserved) 0x00 // √ √ √ 84/101/104 34 | 35 | #define KEY_ErrorRollOver 0x01 // √ √ √ 84/101/104 36 | #define KEY_POSTFail 0x02 // √ √ √ 84/101/104 37 | #define KEY_ErrorUndefined 0x03 // √ √ √ 84/101/104 38 | #define KEY_a_A 0x04 // √ √ √ 84/101/104 39 | #define KEY_b_B 0x05 // √ √ √ 84/101/104 40 | #define KEY_c_C 0x06 // √ √ √ 84/101/104 41 | #define KEY_d_D 0x07 // √ √ √ 84/101/104 42 | #define KEY_e_E 0x08 // √ √ √ 84/101/104 43 | #define KEY_f_F 0x09 // √ √ √ 84/101/104 44 | #define KEY_g_G 0x0A // √ √ √ 84/101/104 45 | #define KEY_h_H 0x0B // √ √ √ 84/101/104 46 | #define KEY_i_I 0x0C // √ √ √ 84/101/104 47 | #define KEY_j_J 0x0D // √ √ √ 84/101/104 48 | #define KEY_k_K 0x0E // √ √ √ 84/101/104 49 | #define KEY_l_L 0x0F // √ √ √ 84/101/104 50 | #define KEY_m_M 0x10 // √ √ √ 84/101/104 51 | #define KEY_n_N 0x11 // √ √ √ 84/101/104 52 | #define KEY_o_O 0x12 // √ √ √ 84/101/104 53 | #define KEY_p_P 0x13 // √ √ √ 84/101/104 54 | #define KEY_q_Q 0x14 // √ √ √ 84/101/104 55 | #define KEY_r_R 0x15 // √ √ √ 84/101/104 56 | #define KEY_s_S 0x16 // √ √ √ 84/101/104 57 | #define KEY_t_T 0x17 // √ √ √ 84/101/104 58 | #define KEY_u_U 0x18 // √ √ √ 84/101/104 59 | #define KEY_v_V 0x19 // √ √ √ 84/101/104 60 | #define KEY_w_W 0x1A // √ √ √ 84/101/104 61 | #define KEY_x_X 0x1B // √ √ √ 84/101/104 62 | #define KEY_y_Y 0x1C // √ √ √ 84/101/104 63 | #define KEY_z_Z 0x1D // √ √ √ 84/101/104 64 | #define KEY_1_Exclamation 0x1E // √ √ √ 84/101/104 65 | #define KEY_2_At 0x1F // √ √ √ 84/101/104 66 | #define KEY_3_Pound 0x20 // √ √ √ 84/101/104 67 | #define KEY_4_Dollar 0x21 // √ √ √ 84/101/104 68 | #define KEY_5_Percent 0x22 // √ √ √ 84/101/104 69 | #define KEY_6_Caret 0x23 // √ √ √ 84/101/104 70 | #define KEY_7_Ampersand 0x24 // √ √ √ 84/101/104 71 | #define KEY_8_Asterisk 0x25 // √ √ √ 84/101/104 72 | #define KEY_9_LeftParenthesis 0x26 // √ √ √ 84/101/104 73 | #define KEY_0_RightParenthesis 0x27 // √ √ √ 84/101/104 74 | #define KEY_ReturnEnter 0x28 // √ √ √ 84/101/104 75 | #define KEY_Escape 0x29 // √ √ √ 84/101/104 76 | #define KEY_DeleteBackspace 0x2A // √ √ √ 84/101/104 77 | #define KEY_Tab 0x2B // √ √ √ 84/101/104 78 | #define KEY_Spacebar 0x2C // √ √ √ 84/101/104 79 | #define KEY_Dash_Underscore 0x2D // √ √ √ 84/101/104 80 | #define KEY_Equal_Plus 0x2E // √ √ √ 84/101/104 81 | #define KEY_LeftBracket_LeftBrace 0x2F // √ √ √ 84/101/104 82 | #define KEY_RightBracket_RightBrace 0x30 // √ √ √ 84/101/104 83 | #define KEY_Backslash_Pipe 0x31 // √ √ √ 84/101/104 84 | #define KEY_NonUS_Pound_Tilde 0x32 // √ √ √ 84/101/104 85 | #define KEY_Semicolon_Colon 0x33 // √ √ √ 84/101/104 86 | #define KEY_SingleQuote_DoubleQuote 0x34 // √ √ √ 84/101/104 87 | #define KEY_GraveAccent_Tilde 0x35 // √ √ √ 84/101/104 88 | #define KEY_Comma_LessThan 0x36 // √ √ √ 84/101/104 89 | #define KEY_Period_GreaterThan 0x37 // √ √ √ 84/101/104 90 | #define KEY_Slash_Question 0x38 // √ √ √ 84/101/104 91 | #define KEY_CapsLock 0x39 // √ √ √ 84/101/104 92 | #define KEY_F1 0x3A // √ √ √ 84/101/104 93 | #define KEY_F2 0x3B // √ √ √ 84/101/104 94 | #define KEY_F3 0x3C // √ √ √ 84/101/104 95 | #define KEY_F4 0x3D // √ √ √ 84/101/104 96 | #define KEY_F5 0x3E // √ √ √ 84/101/104 97 | #define KEY_F6 0x3F // √ √ √ 84/101/104 98 | #define KEY_F7 0x40 // √ √ √ 84/101/104 99 | #define KEY_F8 0x41 // √ √ √ 84/101/104 100 | #define KEY_F9 0x42 // √ √ √ 84/101/104 101 | #define KEY_F10 0x43 // √ √ √ 84/101/104 102 | #define KEY_F11 0x44 // √ √ √ 101/104 103 | #define KEY_F12 0x45 // √ √ √ 101/104 104 | #define KEY_PrintScreen 0x46 // √ √ √ 101/104 105 | #define KEY_ScrollLock 0x47 // √ √ √ 84/101/104 106 | #define KEY_Pause 0x48 // √ √ √ 101/104 107 | #define KEY_Insert 0x49 // √ √ √ 101/104 108 | #define KEY_Home 0x4A // √ √ √ 101/104 109 | #define KEY_PageUp 0x4B // √ √ √ 101/104 110 | #define KEY_DeleteForward 0x4C // √ √ √ 101/104 111 | #define KEY_End 0x4D // √ √ √ 101/104 112 | #define KEY_PageDown 0x4E // √ √ √ 101/104 113 | #define KEY_RightArrow 0x4F // √ √ √ 101/104 114 | #define KEY_LeftArrow 0x50 // √ √ √ 101/104 115 | #define KEY_DownArrow 0x51 // √ √ √ 101/104 116 | #define KEY_UpArrow 0x52 // √ √ √ 101/104 117 | 118 | #define KEYPAD_NumLock_Clear 0x53 // √ √ √ 101/104 119 | #define KEYPAD_Slash 0x54 // √ √ √ 101/104 120 | #define KEYPAD_Asterisk 0x55 // √ √ √ 84/101/104 121 | #define KEYPAD_Minus 0x56 // √ √ √ 84/101/104 122 | #define KEYPAD_Plus 0x57 // √ √ √ 84/101/104 123 | #define KEYPAD_ENTER 0x58 // √ √ √ 101/104 124 | #define KEYPAD_1_End 0x59 // √ √ √ 84/101/104 125 | #define KEYPAD_2_DownArrow 0x5A // √ √ √ 84/101/104 126 | #define KEYPAD_3_PageDown 0x5B // √ √ √ 84/101/104 127 | #define KEYPAD_4_LeftArrow 0x5C // √ √ √ 84/101/104 128 | #define KEYPAD_5 0x5D // √ √ √ 84/101/104 129 | #define KEYPAD_6_RightArrow 0x5E // √ √ √ 84/101/104 130 | #define KEYPAD_7_Home 0x5F // √ √ √ 84/101/104 131 | #define KEYPAD_8_UpArrow 0x60 // √ √ √ 84/101/104 132 | #define KEYPAD_9_PageUp 0x61 // √ √ √ 84/101/104 133 | #define KEYPAD_0_Insert 0x62 // √ √ √ 84/101/104 134 | #define KEYPAD_Period_Delete 0x63 // √ √ √ 84/101/104 135 | 136 | #define KEY_NonUS_Backslash_Pipe 0x64 // √ √ √ 84/101/104 137 | #define KEY_Application 0x65 // √ - √ 104 138 | #define KEY_Power 0x66 // - √ √ - 139 | 140 | #define KEYPAD_Equal 0x67 // - √ - - 141 | 142 | #define KEY_F13 0x68 // - √ - - 143 | #define KEY_F14 0x69 // - √ - - 144 | #define KEY_F15 0x6A // - √ - - 145 | #define KEY_F16 0x6B // - - - - 146 | #define KEY_F17 0x6C // - - - - 147 | #define KEY_F18 0x6D // - - - - 148 | #define KEY_F19 0x6E // - - - - 149 | #define KEY_F20 0x6F // - - - - 150 | #define KEY_F21 0x70 // - - - - 151 | #define KEY_F22 0x71 // - - - - 152 | #define KEY_F23 0x72 // - - - - 153 | #define KEY_F24 0x73 // - - - - 154 | #define KEY_Execute 0x74 // - - √ - 155 | #define KEY_Help 0x75 // - - √ - 156 | #define KEY_Menu 0x76 // - - √ - 157 | #define KEY_Select 0x77 // - - √ - 158 | #define KEY_Stop 0x78 // - - √ - 159 | #define KEY_Again 0x79 // - - √ - 160 | #define KEY_Undo 0x7A // - - √ - 161 | #define KEY_Cut 0x7B // - - √ - 162 | #define KEY_Copy 0x7C // - - √ - 163 | #define KEY_Paste 0x7D // - - √ - 164 | #define KEY_Find 0x7E // - - √ - 165 | #define KEY_Mute 0x7F // - - √ - 166 | #define KEY_VolumeUp 0x80 // - - √ - 167 | #define KEY_VolumeDown 0x81 // - - √ - 168 | #define KEY_LockingCapsLock 0x82 // - - √ - 169 | #define KEY_LockingNumLock 0x83 // - - √ - 170 | #define KEY_LockingScrollLock 0x84 // - - √ - 171 | 172 | #define KEYPAD_Comma 0x85 // - - - - 173 | #define KEYPAD_EqualSign 0x86 // - - - - 174 | 175 | #define KEY_International1 0x87 // - - - - 176 | #define KEY_International2 0x88 // - - - - 177 | #define KEY_International3 0x89 // - - - - 178 | #define KEY_International4 0x8A // - - - - 179 | #define KEY_International5 0x8B // - - - - 180 | #define KEY_International6 0x8C // - - - - 181 | #define KEY_International7 0x8D // - - - - 182 | #define KEY_International8 0x8E // - - - - 183 | #define KEY_International9 0x8F // - - - - 184 | #define KEY_LANG1 0x90 // - - - - 185 | #define KEY_LANG2 0x91 // - - - - 186 | #define KEY_LANG3 0x92 // - - - - 187 | #define KEY_LANG4 0x93 // - - - - 188 | #define KEY_LANG5 0x94 // - - - - 189 | #define KEY_LANG6 0x95 // - - - - 190 | #define KEY_LANG7 0x96 // - - - - 191 | #define KEY_LANG8 0x97 // - - - - 192 | #define KEY_LANG9 0x98 // - - - - 193 | #define KEY_AlternateErase 0x99 // - - - - 194 | #define KEY_SysReq_Attention 0x9A // - - - - 195 | #define KEY_Cancel 0x9B // - - - - 196 | #define KEY_Clear 0x9C // - - - - 197 | #define KEY_Prior 0x9D // - - - - 198 | #define KEY_Return 0x9E // - - - - 199 | #define KEY_Separator 0x9F // - - - - 200 | #define KEY_Out 0xA0 // - - - - 201 | #define KEY_Oper 0xA1 // - - - - 202 | #define KEY_Clear_Again 0xA2 // - - - - 203 | #define KEY_CrSel_Props 0xA3 // - - - - 204 | #define KEY_ExSel 0xA4 // - - - - 205 | 206 | // (Reserved) 0xA5..0xAF // - - - - 207 | 208 | #define KEYPAD_00 0xB0 // - - - - 209 | #define KEYPAD_000 0xB1 // - - - - 210 | 211 | #define KEY_ThousandsSeparator 0xB2 // - - - - 212 | #define KEY_DecimalSeparator 0xB3 // - - - - 213 | #define KEY_CurrencyUnit 0xB4 // - - - - 214 | #define KEY_CurrencySubunit 0xB5 // - - - - 215 | 216 | #define KEYPAD_LeftParenthesis 0xB6 // - - - - 217 | #define KEYPAD_RightParenthesis 0xB7 // - - - - 218 | #define KEYPAD_LeftBrace 0xB8 // - - - - 219 | #define KEYPAD_RightBrace 0xB9 // - - - - 220 | 221 | #define KEYPAD_Tab 0xBA // - - - - 222 | #define KEYPAD_Backspace 0xBB // - - - - 223 | #define KEYPAD_A 0xBC // - - - - 224 | #define KEYPAD_B 0xBD // - - - - 225 | #define KEYPAD_C 0xBE // - - - - 226 | #define KEYPAD_D 0xBF // - - - - 227 | #define KEYPAD_E 0xC0 // - - - - 228 | #define KEYPAD_F 0xC1 // - - - - 229 | #define KEYPAD_XOR 0xC2 // - - - - 230 | #define KEYPAD_Caret 0xC3 // - - - - 231 | #define KEYPAD_Percent 0xC4 // - - - - 232 | #define KEYPAD_LessThan 0xC5 // - - - - 233 | #define KEYPAD_GreaterThan 0xC6 // - - - - 234 | #define KEYPAD_Ampersand 0xC7 // - - - - 235 | #define KEYPAD_AmpersandAmpersand 0xC8 // - - - - 236 | #define KEYPAD_Pipe 0xC9 // - - - - 237 | #define KEYPAD_PipePipe 0xCA // - - - - 238 | #define KEYPAD_Colon 0xCB // - - - - 239 | #define KEYPAD_Pound 0xCC // - - - - 240 | #define KEYPAD_Space 0xCD // - - - - 241 | #define KEYPAD_At 0xCE // - - - - 242 | #define KEYPAD_Exclamation 0xCF // - - - - 243 | #define KEYPAD_MemoryStore 0xD0 // - - - - 244 | #define KEYPAD_MemoryRecall 0xD1 // - - - - 245 | #define KEYPAD_MemoryClear 0xD2 // - - - - 246 | #define KEYPAD_MemoryAdd 0xD3 // - - - - 247 | #define KEYPAD_MemorySubtract 0xD4 // - - - - 248 | #define KEYPAD_MemoryMultiply 0xD5 // - - - - 249 | #define KEYPAD_MemoryDivide 0xD6 // - - - - 250 | #define KEYPAD_PlusMinus 0xD7 // - - - - 251 | #define KEYPAD_Clear 0xD8 // - - - - 252 | #define KEYPAD_ClearEntry 0xD9 // - - - - 253 | #define KEYPAD_Binary 0xDA // - - - - 254 | #define KEYPAD_Octal 0xDB // - - - - 255 | #define KEYPAD_Decimal 0xDC // - - - - 256 | #define KEYPAD_Hexadecimal 0xDD // - - - - 257 | 258 | // (Reserved) 0xDE..0xDF // - - - - 259 | 260 | #define KEY_LeftControl 0xE0 // √ √ √ 84/101/104 261 | #define KEY_LeftShift 0xE1 // √ √ √ 84/101/104 262 | #define KEY_LeftAlt 0xE2 // √ √ √ 84/101/104 263 | #define KEY_LeftGUI 0xE3 // √ √ √ 104 264 | #define KEY_RightControl 0xE4 // √ √ √ 101/104 265 | #define KEY_RightShift 0xE5 // √ √ √ 84/101/104 266 | #define KEY_RightAlt 0xE6 // √ √ √ 101/104 267 | #define KEY_RightGUI 0xE7 // √ √ √ 104 268 | 269 | // (Reserved) 0xE8..0xFFFF // - - - - 270 | 271 | // Media key codes are not real scan codes, they must be translated to a 16 272 | // bit number by the consumer key key function 273 | #define MEDIAKEY_PLAY_PAUSE 0x00 274 | #define MEDIAKEY_PREV_TRACK 0x01 275 | #define MEDIAKEY_NEXT_TRACK 0x02 276 | 277 | // ---------------------------------------------------------------------------- 278 | // ---------------------------------------------------------------------------- 279 | #endif 280 | 281 | -------------------------------------------------------------------------------- /src/lib/key-functions/public/basic.c: -------------------------------------------------------------------------------- 1 | /* ---------------------------------------------------------------------------- 2 | * key functions : basic : code 3 | * ---------------------------------------------------------------------------- 4 | * Copyright (c) 2012 Ben Blazak 5 | * Released under The MIT License (MIT) (see "license.md") 6 | * Project located at 7 | * ------------------------------------------------------------------------- */ 8 | 9 | 10 | #include "../../../main.h" 11 | #include "../../../keyboard/layout.h" 12 | #include "../public.h" 13 | #include "../private.h" 14 | 15 | // ---------------------------------------------------------------------------- 16 | 17 | #define MAX_LAYER_PUSH_POP_FUNCTIONS 10 18 | 19 | // ---------------------------------------------------------------------------- 20 | 21 | // convenience macros 22 | #define LAYER main_arg_layer 23 | #define LAYER_OFFSET main_arg_layer_offset 24 | #define ROW main_arg_row 25 | #define COL main_arg_col 26 | #define IS_PRESSED main_arg_is_pressed 27 | #define WAS_PRESSED main_arg_was_pressed 28 | 29 | // ---------------------------------------------------------------------------- 30 | 31 | /* 32 | * [name] 33 | * Press|Release 34 | * 35 | * [description] 36 | * Generate a normal keypress or keyrelease 37 | */ 38 | void kbfun_press_release(void) { 39 | if (!main_arg_trans_key_pressed) 40 | main_arg_any_non_trans_key_pressed = true; 41 | kbfun_press_release_preserve_sticky(); 42 | } 43 | 44 | /* 45 | * [name] 46 | * Press|Release and preserve top layer sticky key state 47 | * 48 | * [description] 49 | * Generate a normal keypress or keyrelease 50 | * While basing the sticky key state transition on whether 51 | * kbfun_press_release() was called after kbfun_transparent() generally 52 | * works in practice, it is not always the desired behavior. One of the 53 | * benefits of sticky keys is avoiding key chording, so we want to make sure 54 | * that standard modifiers do not interrupt the sticky key cycle. Use 55 | * kbfun_press_release_preserve_sticky() if you want to define a standard 56 | * modifier key (shift, control, alt, gui) on the sticky layer instead of 57 | * defining the key to be transparent for the layer. 58 | */ 59 | void kbfun_press_release_preserve_sticky(void) { 60 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 61 | _kbfun_press_release(IS_PRESSED, keycode); 62 | } 63 | 64 | /* 65 | * [name] 66 | * Toggle 67 | * 68 | * [description] 69 | * Toggle the key pressed or unpressed 70 | */ 71 | void kbfun_toggle(void) { 72 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 73 | 74 | if (_kbfun_is_pressed(keycode)) 75 | _kbfun_press_release(false, keycode); 76 | else 77 | _kbfun_press_release(true, keycode); 78 | } 79 | 80 | /* 81 | * [name] 82 | * Transparent 83 | * 84 | * [description] 85 | * Execute the key that would have been executed if the current layer was not 86 | * active 87 | */ 88 | void kbfun_transparent(void) { 89 | main_arg_trans_key_pressed = true; 90 | LAYER_OFFSET++; 91 | LAYER = main_layers_peek(LAYER_OFFSET); 92 | main_layers_pressed[ROW][COL] = LAYER; 93 | main_exec_key(); 94 | } 95 | 96 | 97 | /* ---------------------------------------------------------------------------- 98 | * layer push/pop functions 99 | * ------------------------------------------------------------------------- */ 100 | 101 | // While there are only MAX_LAYER_PUSH_POP_FUNCTIONS number of layer functions, 102 | // there are 1 + MAX_LAYER_PUSH_POP_FUNCTIONS layer ids because we still have 103 | // layer 0 even if we will never have a push or pop function for it 104 | static uint8_t layer_ids[1 + MAX_LAYER_PUSH_POP_FUNCTIONS]; 105 | 106 | static void layer_push(uint8_t local_id) { 107 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 108 | main_layers_pop_id(layer_ids[local_id]); 109 | // Only the topmost layer on the stack should be in sticky once state, pop 110 | // the top layer if it is in sticky once state 111 | uint8_t topSticky = main_layers_peek_sticky(0); 112 | if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) { 113 | main_layers_pop_id(main_layers_peek(0)); 114 | } 115 | layer_ids[local_id] = main_layers_push(keycode, eStickyNone); 116 | } 117 | 118 | static void layer_sticky(uint8_t local_id) { 119 | uint8_t keycode = kb_layout_get(LAYER, ROW, COL); 120 | if (IS_PRESSED) { 121 | uint8_t topLayer = main_layers_peek(0); 122 | uint8_t topSticky = main_layers_peek_sticky(0); 123 | main_layers_pop_id(layer_ids[local_id]); 124 | if (topLayer == local_id) { 125 | if (topSticky == eStickyOnceUp) 126 | layer_ids[local_id] = main_layers_push(keycode, eStickyLock); 127 | } 128 | else 129 | { 130 | // only the topmost layer on the stack should be in sticky once state 131 | if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) { 132 | main_layers_pop_id(layer_ids[topLayer]); 133 | } 134 | layer_ids[local_id] = main_layers_push(keycode, eStickyOnceDown); 135 | // this should be the only place we care about this flag being cleared 136 | main_arg_any_non_trans_key_pressed = false; 137 | } 138 | } 139 | else 140 | { 141 | uint8_t topLayer = main_layers_peek(0); 142 | uint8_t topSticky = main_layers_peek_sticky(0); 143 | if (topLayer == local_id) { 144 | if (topSticky == eStickyOnceDown) { 145 | // When releasing this sticky key, pop the layer always 146 | main_layers_pop_id(layer_ids[local_id]); 147 | if (!main_arg_any_non_trans_key_pressed) { 148 | // If no key defined for this layer (a non-transparent key) 149 | // was pressed, push the layer again, but in the 150 | // StickyOnceUp state 151 | layer_ids[local_id] = main_layers_push(keycode, eStickyOnceUp); 152 | } 153 | } 154 | } 155 | } 156 | } 157 | 158 | static void layer_pop(uint8_t local_id) { 159 | main_layers_pop_id(layer_ids[local_id]); 160 | layer_ids[local_id] = 0; 161 | } 162 | 163 | /* 164 | * [name] 165 | * Layer push #1 166 | * 167 | * [description] 168 | * Push a layer element containing the layer value specified in the keymap to 169 | * the top of the stack, and record the id of that layer element 170 | */ 171 | void kbfun_layer_push_1(void) { 172 | layer_push(1); 173 | } 174 | 175 | /* 176 | * [name] 177 | * Layer sticky cycle #1 178 | * 179 | * [description] 180 | * This function gives similar behavior to sticky keys for modifiers available 181 | * on most operating systems. It is considered an accessibility feature 182 | * because it alleviates the user from having to hold down modifiers while 183 | * pressing a key to produce the modified key function. It is useful for fast 184 | * touch typing because you can avoid chording motions which both strain your 185 | * hands and take your hands out of home-row position while pressing normal 186 | * alpha keys. 187 | * This function emulates the 3-state behavior which is default on OS X and 188 | * optional in Windows where the modifier cycles between Off->Once->Locked 189 | * states. This is particularly handy for symbol layers where you typically 190 | * only type one symbol before you want to return to unmodified typing (layer 191 | * 0), e.g. 'if (condition) { a = "b" + "c"; }'. If you assign a symbol layer 192 | * to a thumb key as a layer sticky cycle, you can type the entire line of 193 | * code without taking your hands out of home row position and you do not need 194 | * to toggle off the layer after each symbol is pressed, only immediately 195 | * before keying the symbol. 196 | * The exact behavior of the layer sticky cycle function is defined as follows 197 | * for each state: 198 | * 1) One time down (set on key press) - The layer was not active and the key 199 | * has been pressed but not yet released. The layer is pushed in the one 200 | * time down state. 201 | * 2) One time up (set on key release) - The layer was active when the layer 202 | * sticky key was released. If a key on this layer (not set to 203 | * transparent) was pressed before the key was released, the layer will be 204 | * popped. If a non-transparent key was not pressed, the layer is popped 205 | * and pushed again in the one time up state. 206 | * 3) Locked (set on key press) - The layer was active and in the one time up 207 | * state when the layer sticky key was pressed again. The layer will be 208 | * popped if the function is invoked on a subsequent keypress. 209 | */ 210 | void kbfun_layer_sticky_1 (void) { 211 | layer_sticky(1); 212 | } 213 | 214 | /* 215 | * [name] 216 | * Layer pop #1 217 | * 218 | * [description] 219 | * Pop the layer element created by the corresponding "layer push" function 220 | * out of the layer stack (no matter where it is in the stack, without 221 | * touching any other elements) 222 | */ 223 | void kbfun_layer_pop_1(void) { 224 | layer_pop(1); 225 | } 226 | 227 | /* 228 | * [name] 229 | * Layer push #2 230 | * 231 | * [description] 232 | * Push a layer element containing the layer value specified in the keymap to 233 | * the top of the stack, and record the id of that layer element 234 | */ 235 | void kbfun_layer_push_2(void) { 236 | layer_push(2); 237 | } 238 | 239 | /* 240 | * [name] 241 | * Layer sticky cycle #2 242 | * 243 | * [description] 244 | * See the description of kbfun_layer_sticky_1() 245 | */ 246 | void kbfun_layer_sticky_2 (void) { 247 | layer_sticky(2); 248 | } 249 | 250 | /* 251 | * [name] 252 | * Layer pop #2 253 | * 254 | * [description] 255 | * Pop the layer element created by the corresponding "layer push" function 256 | * out of the layer stack (no matter where it is in the stack, without 257 | * touching any other elements) 258 | */ 259 | void kbfun_layer_pop_2(void) { 260 | layer_pop(2); 261 | } 262 | 263 | /* 264 | * [name] 265 | * Layer push #3 266 | * 267 | * [description] 268 | * Push a layer element containing the layer value specified in the keymap to 269 | * the top of the stack, and record the id of that layer element 270 | */ 271 | void kbfun_layer_push_3(void) { 272 | layer_push(3); 273 | } 274 | 275 | /* 276 | * [name] 277 | * Layer sticky cycle #3 278 | * 279 | * [description] 280 | * See the description of kbfun_layer_sticky_1() 281 | */ 282 | void kbfun_layer_sticky_3 (void) { 283 | layer_sticky(3); 284 | } 285 | 286 | /* 287 | * [name] 288 | * Layer pop #3 289 | * 290 | * [description] 291 | * Pop the layer element created by the corresponding "layer push" function 292 | * out of the layer stack (no matter where it is in the stack, without 293 | * touching any other elements) 294 | */ 295 | void kbfun_layer_pop_3(void) { 296 | layer_pop(3); 297 | } 298 | 299 | /* 300 | * [name] 301 | * Layer push #4 302 | * 303 | * [description] 304 | * Push a layer element containing the layer value specified in the keymap to 305 | * the top of the stack, and record the id of that layer element 306 | */ 307 | void kbfun_layer_push_4(void) { 308 | layer_push(4); 309 | } 310 | 311 | /* 312 | * [name] 313 | * Layer sticky cycle #4 314 | * 315 | * [description] 316 | * See the description of kbfun_layer_sticky_1() 317 | */ 318 | void kbfun_layer_sticky_4 (void) { 319 | layer_sticky(4); 320 | } 321 | 322 | /* 323 | * [name] 324 | * Layer pop #4 325 | * 326 | * [description] 327 | * Pop the layer element created by the corresponding "layer push" function 328 | * out of the layer stack (no matter where it is in the stack, without 329 | * touching any other elements) 330 | */ 331 | void kbfun_layer_pop_4(void) { 332 | layer_pop(4); 333 | } 334 | 335 | /* 336 | * [name] 337 | * Layer push #5 338 | * 339 | * [description] 340 | * Push a layer element containing the layer value specified in the keymap to 341 | * the top of the stack, and record the id of that layer element 342 | */ 343 | void kbfun_layer_push_5(void) { 344 | layer_push(5); 345 | } 346 | 347 | /* 348 | * [name] 349 | * Layer sticky cycle #5 350 | * 351 | * [description] 352 | * See the description of kbfun_layer_sticky_1() 353 | */ 354 | void kbfun_layer_sticky_5 (void) { 355 | layer_sticky(5); 356 | } 357 | 358 | /* 359 | * [name] 360 | * Layer pop #5 361 | * 362 | * [description] 363 | * Pop the layer element created by the corresponding "layer push" function 364 | * out of the layer stack (no matter where it is in the stack, without 365 | * touching any other elements) 366 | */ 367 | void kbfun_layer_pop_5(void) { 368 | layer_pop(5); 369 | } 370 | 371 | /* 372 | * [name] 373 | * Layer push #6 374 | * 375 | * [description] 376 | * Push a layer element containing the layer value specified in the keymap to 377 | * the top of the stack, and record the id of that layer element 378 | */ 379 | void kbfun_layer_push_6(void) { 380 | layer_push(6); 381 | } 382 | 383 | /* 384 | * [name] 385 | * Layer sticky cycle #6 386 | * 387 | * [description] 388 | * See the description of kbfun_layer_sticky_1() 389 | */ 390 | void kbfun_layer_sticky_6 (void) { 391 | layer_sticky(6); 392 | } 393 | 394 | /* 395 | * [name] 396 | * Layer pop #6 397 | * 398 | * [description] 399 | * Pop the layer element created by the corresponding "layer push" function 400 | * out of the layer stack (no matter where it is in the stack, without 401 | * touching any other elements) 402 | */ 403 | void kbfun_layer_pop_6(void) { 404 | layer_pop(6); 405 | } 406 | 407 | /* 408 | * [name] 409 | * Layer push #7 410 | * 411 | * [description] 412 | * Push a layer element containing the layer value specified in the keymap to 413 | * the top of the stack, and record the id of that layer element 414 | */ 415 | void kbfun_layer_push_7(void) { 416 | layer_push(7); 417 | } 418 | 419 | /* 420 | * [name] 421 | * Layer sticky cycle #7 422 | * 423 | * [description] 424 | * See the description of kbfun_layer_sticky_1() 425 | */ 426 | void kbfun_layer_sticky_7 (void) { 427 | layer_sticky(7); 428 | } 429 | 430 | /* 431 | * [name] 432 | * Layer pop #7 433 | * 434 | * [description] 435 | * Pop the layer element created by the corresponding "layer push" function 436 | * out of the layer stack (no matter where it is in the stack, without 437 | * touching any other elements) 438 | */ 439 | void kbfun_layer_pop_7(void) { 440 | layer_pop(7); 441 | } 442 | 443 | /* 444 | * [name] 445 | * Layer push #8 446 | * 447 | * [description] 448 | * Push a layer element containing the layer value specified in the keymap to 449 | * the top of the stack, and record the id of that layer element 450 | */ 451 | void kbfun_layer_push_8(void) { 452 | layer_push(8); 453 | } 454 | 455 | /* 456 | * [name] 457 | * Layer sticky cycle #8 458 | * 459 | * [description] 460 | * See the description of kbfun_layer_sticky_1() 461 | */ 462 | void kbfun_layer_sticky_8 (void) { 463 | layer_sticky(8); 464 | } 465 | 466 | /* 467 | * [name] 468 | * Layer pop #8 469 | * 470 | * [description] 471 | * Pop the layer element created by the corresponding "layer push" function 472 | * out of the layer stack (no matter where it is in the stack, without 473 | * touching any other elements) 474 | */ 475 | void kbfun_layer_pop_8(void) { 476 | layer_pop(8); 477 | } 478 | 479 | /* 480 | * [name] 481 | * Layer push #9 482 | * 483 | * [description] 484 | * Push a layer element containing the layer value specified in the keymap to 485 | * the top of the stack, and record the id of that layer element 486 | */ 487 | void kbfun_layer_push_9(void) { 488 | layer_push(9); 489 | } 490 | 491 | /* 492 | * [name] 493 | * Layer sticky cycle #9 494 | * 495 | * [description] 496 | * See the description of kbfun_layer_sticky_1() 497 | */ 498 | void kbfun_layer_sticky_9 (void) { 499 | layer_sticky(9); 500 | } 501 | 502 | /* 503 | * [name] 504 | * Layer pop #9 505 | * 506 | * [description] 507 | * Pop the layer element created by the corresponding "layer push" function 508 | * out of the layer stack (no matter where it is in the stack, without 509 | * touching any other elements) 510 | */ 511 | void kbfun_layer_pop_9(void) { 512 | layer_pop(9); 513 | } 514 | 515 | /* 516 | * [name] 517 | * Layer push #10 518 | * 519 | * [description] 520 | * Push a layer element containing the layer value specified in the keymap to 521 | * the top of the stack, and record the id of that layer element 522 | */ 523 | void kbfun_layer_push_10(void) { 524 | layer_push(10); 525 | } 526 | 527 | /* 528 | * [name] 529 | * Layer sticky cycle #10 530 | * 531 | * [description] 532 | * See the description of kbfun_layer_sticky_1() 533 | */ 534 | void kbfun_layer_sticky_10 (void) { 535 | layer_sticky(10); 536 | } 537 | 538 | /* 539 | * [name] 540 | * Layer pop #10 541 | * 542 | * [description] 543 | * Pop the layer element created by the corresponding "layer push" function 544 | * out of the layer stack (no matter where it is in the stack, without 545 | * touching any other elements) 546 | */ 547 | void kbfun_layer_pop_10(void) { 548 | layer_pop(10); 549 | } 550 | 551 | /* ---------------------------------------------------------------------------- 552 | * ------------------------------------------------------------------------- */ 553 | 554 | 555 | --------------------------------------------------------------------------------