diff --git a/BUILD_GUIDE.md b/BUILD_GUIDE.md index f7a57d2fc9b..fd8b6202ff4 100644 --- a/BUILD_GUIDE.md +++ b/BUILD_GUIDE.md @@ -47,8 +47,8 @@ If you have any problems building the firmware, you can try using a tool called Note: Some keyboard folders have non-standard organizations, and may not even support specifying alternate keymaps. Until these get reorganized, you will need to edit their default keymaps directly. -1. Running the `make` command from your keyboard's folder will generate a .hex file based on the default keymap. All keymaps for a particular keyboard live in the `keymaps` folder in that keyboard's folder. To create your own keymap, copy `keymaps/default/keymap.c` to the `keymaps` folder, and rename it with your name, for example jack.c. Or, if you don't care about the ability to share your keymap with the community via GitHub, you can just modify the default keymap itself. Details on how to program keymap files can be found in other guides. -2. To build a keymap other than the default, type `KEYMAP=` after `make`. So if I've named my keymap jack.c, the full command would be `make KEYMAP=jack`. +1. Running the `make` command from your keyboard's folder will generate a .hex file based on the default keymap. All keymaps for a particular keyboard live in the `keymaps` folder in that keyboard's folder. To create your own keymap, duplicate the folder `keymaps/default`, and rename it with your name, for example `jack`. Or, if you don't care about the ability to share your keymap with the community via GitHub, you can just modify the default keymap itself. Details on how to program keymap files can be found in other guides. +2. To build a keymap other than the default, type `KEYMAP=` after `make`. So if I've named my keymap `jack`, the full command would be `make KEYMAP=jack`. 3. How you deploy the firmware will depend on whether you are using a PCB or a Teensy. In both cases, you'll need to put the keyboard in bootloader mode, either by pressing a button on the PCB/Teensy or pressing the key with the `RESET` keycode. Then, if you're using a PCB, just run `make KEYMAP= dfu` to both build and deploy the firmware. If you're using a Teensy, you'll probably need to take the .hex file that make produces in the keyboard's folder, and deploy it using the [Teensy Loader.](https://www.pjrc.com/teensy/loader.html) ## Helpful Tips diff --git a/HAND_WIRE.md b/HAND_WIRE.md index 3f4d75b272b..0b7367eda33 100644 --- a/HAND_WIRE.md +++ b/HAND_WIRE.md @@ -51,11 +51,11 @@ A problem arises when you start pressing more than one key at a time. Looking at x row0 ---(-+-0)---(-+-1) x row0 ---(-+-0)---(-+-1) | | | | x row1 ---(key2)---(-+-3) x row1 ---(key2)---(-+-3) - + Remember that this ^ is still connected to row1 The data we get from that is: - + col0: 0b11 col1: 0b11 │└row0 @@ -73,7 +73,7 @@ Which isn't accurate, since we only have 3 keys pressed down, not all 4. This be │ │ | │ (key2) (key3) (key2) (key3) ! ! ! ! - row1 ─────┴────────┘ row1 ─────┴────────┘ + row1 ─────┴────────┘ row1 ─────┴────────┘ In practical applications, the black line of the diode will be placed facing the row, and away from the keyswitch - the `!` in this case is the diode, where the gap represents the black line. A good way to remember this is to think of this symbol: `>|` @@ -89,10 +89,10 @@ Now when we press the three keys, invoking what would be a ghosting scenario: │ │ │ │ (key2) (┌─┘3) (key2) (┌─┘3) ! ! ! ! - row1 ─────┴────────┘ x row1 ─────┴────────┘ + row1 ─────┴────────┘ x row1 ─────┴────────┘ Things act as they should! Which will get us the following data: - + col0: 0b01 col1: 0b11 │└row0 @@ -106,7 +106,7 @@ The firmware can then use this correct data to detect what it should do, and eve When starting this, you should have all of your stabilisers and keyswitches already installed (and optionally keycaps). If you're using a Cherry-type stabiliser (plate-mounted only, obviously), you'll need to install that before your keyswitches. If you're using Costar ones, you can installed them afterwards. -To make things easier on yourself, make sure all of the keyswitches are oriented the same way (if they can be - not all layouts support this). Despite this, it's important to remember that the contacts on the keyswitches are completely symmetrical. We'll be using the keyswitch's left side contact for wiring the rows, and the right side one for wiring the columns. +To make things easier on yourself, make sure all of the keyswitches are oriented the same way (if they can be - not all layouts support this). Despite this, it's important to remember that the contacts on the keyswitches are completely symmetrical. We'll be using the keyswitch's left side contact for wiring the rows, and the right side one for wiring the columns. Get your soldering iron heated-up and collect the rest of the materials from the part list at the beginning of the guide. Place your keyboard so that the bottoms of the keyswitches are accessible - it may be a good idea to place it on a cloth to protect your keyswitches/keycaps. @@ -155,7 +155,7 @@ When all of the diodes are completely soldered, it's a good idea to quickly insp ### Soldering the columns -You'll have some options in the next process - it's a good idea to insulate the column wires (since the diodes aren't), but if you're careful enough, you can use exposed wires for the columns - it's not recommended, though. If you're using single-cored wire, stripping the plastic off of the whole wire and feeding it back on is probably the best option, but can be difficult depending on the size and materials. You'll want to leave parts of the wire exposed where you're going to be solder it onto the keyswitch. +You'll have some options in the next process - it's a good idea to insulate the column wires (since the diodes aren't), but if you're careful enough, you can use exposed wires for the columns - it's not recommended, though. If you're using single-cored wire, stripping the plastic off of the whole wire and feeding it back on is probably the best option, but can be difficult depending on the size and materials. You'll want to leave parts of the wire exposed where you're going to be solder it onto the keyswitch. If you're using stranded wire, it's probably easiest to just use a lot of small wires to connect each keyswitch along the column. It's possible to use one and melt through the insulation, but this isn't recommended, will produce even more harmful fumes, and can ruin your soldering iron. @@ -195,15 +195,13 @@ You'll want to navigate to the `keyboard//` folder by typing, like #### config.h -The first thing we're going to want to modify is the `config.h` file. On line 32 and 33, you'll see `MATRIX_ROWS` and `MATRIX_COLS` - set both these variables to however many rows and columns you have on your keyboard. +The first thing you're going to want to modify is the `config.h` file. Find `MATRIX_ROWS` and `MATRIX_COLS` and them to match the dimensions of your keyboard's matrix. -On line 38 and 39 you'll see the `COLS` and `ROWS` definitions - this is where you'll enter the pins you used, in order (left-to-right when looking at the top of the keyboard, but right-to-left when looking at the bottom). - -There are some other variables that you'll be able to modify (lines 23-29), but it's not necessary to do that now (or ever, really). +Farther down are `MATRIX_ROW_PINS` and `MATRIX_COL_PINS`. Change their definitions to match how you wired up your matrix (looking from the top of the keyboard, the rows run top-to-bottom and the columns run left-to-right). Likewise, change the definition of `UNUSED_PINS` to match the pins you did not use (this will save power). #### \.h -The next file you'll want to look at is `.h`. You're going to want to rewrite the `KEYMAP` definition - the format and syntax here is extremely important, so pay attention to how things are setup. The first half of the definition are considered the arguments - this is the format that you'll be following in your keymap later on, so you'll want to have as many k*xy* variables here as you do keys. The second half is the part that the firmware actually looks at, and will contain gaps depending on how you wired your matrix. +The next file you'll want to look at is `.h`. You're going to want to rewrite the `KEYMAP` definition - the format and syntax here is extremely important, so pay attention to how things are setup. The first half of the definition are considered the arguments - this is the format that you'll be following in your keymap later on, so you'll want to have as many k*xy* variables here as you do keys. The second half is the part that the firmware actually looks at, and will contain gaps depending on how you wired your matrix. We'll dive into how this will work with the following example. Say we have a keyboard like this: @@ -230,7 +228,7 @@ The middle column is unused on the bottom row in this example. Our `KEYMAP` defi { \ { k00, k01, k02 }, \ { k10, KC_NO, k11 }, \ - } + } Notice how the top half is spaced to resemble our physical layout - this helps us understand which keys are associated with which columns. The bottom half uses the keycode `KC_NO` where there is no keyswitch wired in. It's easiest to keep the bottom half aligned in a grid to help us make sense of how the firmware actually sees the wiring. @@ -251,7 +249,7 @@ This would require our `KEYMAP` definition to look like this: { \ { k00, k01, k02 }, \ { k10, k11, KC_NO }, \ - } + } Notice how the `k11` and `KC_NO` switched places to represent the wiring, and the unused final column on the bottom row. Sometimes it'll make more sense to put a keyswitch on a particular column, but in the end, it won't matter, as long as all of them are accounted for. You can use this process to write out the `KEYMAP` for your entire keyboard - be sure to remember that your keyboard is actually backwards when looking at the underside of it. diff --git a/README.md b/README.md index d20557f597e..4e53569a8e8 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ This is a keyboard firmware based on the [tmk_keyboard firmware](http://github.com/tmk/tmk_keyboard) with some useful features for Atmel AVR controllers, and more specifically, the [OLKB product line](http://olkb.co), the [ErgoDox EZ](http://www.ergodox-ez.com) keyboard, and the [Clueboard product line](http://clueboard.co/). -QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, TMK. +QMK is developed and maintained by Jack Humbert of OLKB with contributions from the community, and of course, TMK. In fact, this repo used to be a fork of TMK, and we are incredibly grateful for his founding contributions to the firmware. We've had to break the fork due to purely technical reasons -- it simply became too different over time, and we've had to start refactoring some of the basic bits and pieces. We are huge fans of TMK, both the firmware and the person. :) This documentation is edited and maintained by Erez Zukerman of ErgoDox EZ. If you spot any typos or inaccuracies, please [open an issue](https://github.com/jackhumbert/qmk_firmware/issues/new). -The OLKB product firmwares are maintained by Jack, the Ergodox EZ by Erez, and the Clueboard by [skullydazed](/skullydazed). +The OLKB product firmwares are maintained by Jack, the Ergodox EZ by Erez, and the Clueboard by [Zach White](https://github.com/skullydazed). ## Important background info: TMK documentation @@ -33,6 +33,10 @@ If your keymap directory has a file called `makefile.mk` (note the lowercase fil So let's say your keyboard's makefile has `CONSOLE_ENABLE = yes` (or maybe doesn't even list the `CONSOLE_ENABLE` option, which would cause it to revert to the global Quantum default). You want your particular keymap to not have the debug console, so you make a file called `makefile.mk` and specify `CONSOLE_ENABLE = no`. +### Customizing config.h on a per-keymap basis + +If you use the ErgoDox EZ, you can make a `config_user.h` file in your keymap directory and use it to override any `config.h` settings you don't like. Anything you set there will take precedence over the global `config.h` for the ErgoDox EZ. To see an example of this, check out `keymaps/erez_experimental`. + ## Quick aliases to common actions Your keymap can include shortcuts to common operations (called "function actions" in tmk). @@ -41,10 +45,13 @@ Your keymap can include shortcuts to common operations (called "function actions `MO(layer)` - momentary switch to *layer*. As soon as you let go of the key, the layer is deactivated and you pop back out to the previous layer. When you apply this to a key, that same key must be set as `KC_TRNS` on the destination layer. Otherwise, you won't make it back to the original layer when you release the key (and you'll get a keycode sent). You can only switch to layers *above* your current layer. If you're on layer 0 and you use `MO(1)`, that will switch to layer 1 just fine. But if you include `MO(3)` on layer 5, that won't do anything for you -- because layer 3 is lower than layer 5 on the stack. +`OSL(layer)` - momentary switch to *layer*, as a one-shot operation. So if you have a key that's defined as `OSL(1)`, and you tap that key, then only the very next keystroke would come from layer 1. You would drop back to layer zero immediately after that one keystroke. That's handy if you have a layer full of custom shortcuts -- for example, a dedicated key for closing a window. So you tap your one-shot layer mod, then tap that magic 'close window' key, and keep typing like a boss. Layer 1 would remain active as long as you hold that key down, too (so you can use it like a momentary toggle-layer key with extra powers). + `LT(layer, kc)` - momentary switch to *layer* when held, and *kc* when tapped. Like `MO()`, this only works upwards in the layer stack (`layer` must be higher than the current layer). `TG(layer)` - toggles a layer on or off. As with `MO()`, you should set this key as `KC_TRNS` in the destination layer so that tapping it again actually toggles back to the original layer. Only works upwards in the layer stack. + ### Fun with modifier keys * `LSFT(kc)` - applies left Shift to *kc* (keycode) - `S(kc)` is an alias @@ -80,17 +87,24 @@ The following shortcuts automatically add `LSFT()` to keycodes to get commonly u KC_PLUS + KC_LCBR { KC_RCBR } + KC_LABK < + KC_RABK > KC_PIPE | KC_COLN : +`OSM(mod)` - this is a "one shot" modifier. So let's say you have your left Shift key defined as `OSM(MOD_LSFT)`. Tap it, let go, and Shift is "on" -- but only for the next character you'll type. So to write "The", you don't need to hold down Shift -- you tap it, tap t, and move on with life. And if you hold down the left Shift key, it just works as a left Shift key, as you would expect (so you could type THE). There's also a magical, secret way to "lock" a modifier by tapping it multiple times. If you want to learn more about that, open an issue. :) + `MT(mod, kc)` - is *mod* (modifier key - MOD_LCTL, MOD_LSFT) when held, and *kc* when tapped. In other words, you can have a key that sends Esc (or the letter O or whatever) when you tap it, but works as a Control key or a Shift key when you hold it down. -These are the values you can use for the `mod` in `MT()` (right-hand modifiers are not available): +These are the values you can use for the `mod` in `MT()` and `OSM()` (right-hand modifiers are not available for `MT()`): * MOD_LCTL * MOD_LSFT * MOD_LALT * MOD_LGUI + * MOD_HYPR + * MOD_MEH + These can also be combined like `MOD_LCTL | MOD_LSFT` e.g. `MT(MOD_LCTL | MOD_LSFT, KC_ESC)` which would activate Control and Shift when held, and send Escape when tapped. @@ -363,6 +377,55 @@ You can currently send 4 hex digits with your OS-specific modifier key (RALT for Enable the backlight from the Makefile. +## Driving a speaker - audio support + +Your keyboard can make sounds! If you've got a Planck, Preonic, or basically any keyboard that allows access to the C6 port, you can hook up a simple speaker and have it beep. You can use those beeps to indicate layer transitions, modifiers, special keys, or just to play some funky 8bit tunes. + +The audio code lives in [quantum/audio/audio.h](/quantum/audio/audio.h) and in the other files in the audio directory. It's enabled by default on the Planck [stock keymap](/keyboard/planck/keymaps/default/keymap.c). Here are the important bits: + +``` +#include "audio.h" +``` + +Then, lower down the file: + +``` +float tone_startup[][2] = { + ED_NOTE(_E7 ), + E__NOTE(_CS7), + E__NOTE(_E6 ), + E__NOTE(_A6 ), + M__NOTE(_CS7, 20) +}; +``` + +This is how you write a song. Each of these lines is a note, so we have a little ditty composed of five notes here. + +Then, we have this chunk: + +``` +float tone_qwerty[][2] = SONG(QWERTY_SOUND); +float tone_dvorak[][2] = SONG(DVORAK_SOUND); +float tone_colemak[][2] = SONG(COLEMAK_SOUND); +float tone_plover[][2] = SONG(PLOVER_SOUND); +float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); + +float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); +float goodbye[][2] = SONG(GOODBYE_SOUND); +``` + +Wherein we bind predefined songs (from [audio/song_list.h](/audio/song_list.h)) into named variables. This is one optimization that helps save on memory: These songs only take up memory when you reference them in your keymap, because they're essentially all preprocessor directives. + +So now you have something called `tone_plover` for example. How do you make it play the Plover tune, then? If you look further down the keymap, you'll see this: + +``` +PLAY_NOTE_ARRAY(tone_plover, false, 0); // Signature is: Song name, repeat, rest style +``` + +This is inside one of the macros. So when that macro executes, your keyboard plays that particular chime. + +"Rest style" in the method signature above (the last parameter) specifies if there's a rest (a moment of silence) between the notes. + ## MIDI functionalty This is still a WIP, but check out `quantum/keymap_midi.c` to see what's happening. Enable from the Makefile. diff --git a/keyboard/Bantam44/config.h b/keyboard/Bantam44/config.h index 26d680704d6..a55f629990a 100644 --- a/keyboard/Bantam44/config.h +++ b/keyboard/Bantam44/config.h @@ -35,8 +35,9 @@ along with this program. If not, see . // Planck PCB default pin-out // Change this to how you wired your keyboard // COLS: Left to right, ROWS: Top to bottom -#define COLS (int []){ B0, B1, B2, B3, B7, D0, B6, F7, F6, F5, F4, F1 } -#define ROWS (int []){ F0, D6, D4, D5 } +#define MATRIX_ROW_PINS { F0, D6, D4, D5 } +#define MATRIX_COL_PINS { B0, B1, B2, B3, B7, D0, B6, F7, F6, F5, F4, F1 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -48,7 +49,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile index 1d91c34b7fe..c1a0a6db422 100644 --- a/keyboard/atomic/Makefile +++ b/keyboard/atomic/Makefile @@ -171,10 +171,6 @@ endif endif -ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) - SRC := backlight.c $(SRC) -endif - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/atomic/atomic.c b/keyboard/atomic/atomic.c index 5e31264e68e..fa218a48f31 100644 --- a/keyboard/atomic/atomic.c +++ b/keyboard/atomic/atomic.c @@ -2,27 +2,28 @@ __attribute__ ((weak)) void matrix_init_user(void) { - // leave this function blank - it can be defined in a keymap file + // leave this function blank - it can be defined in a keymap file }; __attribute__ ((weak)) void matrix_scan_user(void) { - // leave this function blank - it can be defined in a keymap file + // leave this function blank - it can be defined in a keymap file } __attribute__ ((weak)) -void process_action_user(keyrecord_t *record) { - // leave this function blank - it can be defined in a keymap file +bool process_action_user(keyrecord_t *record) { + // leave this function blank - it can be defined in a keymap file + return true; } __attribute__ ((weak)) void led_set_user(uint8_t usb_led) { - // leave this function blank - it can be defined in a keymap file + // leave this function blank - it can be defined in a keymap file } void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up + // put your keyboard start-up code here + // runs once when the firmware starts up MCUCR |= (1<= BACKLIGHT_LEVELS ) + { + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + + // Set the brightness to max + CHANNEL = 0xFFFF; + } + else + { + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + + // Set the brightness + CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); + } + breathing_intensity_default(); +} + + +void breathing_enable(void) +{ + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint (brightest point) + breathing_index = 0x20 << breath_speed; + } + + breathing_halt = BREATHING_NO_HALT; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); +} + +void breathing_pulse(void) +{ + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint + 1 (brightest point) + breathing_index = 0x21 << breath_speed; + } + + breathing_halt = BREATHING_HALT_ON; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); +} + +void breathing_disable(void) +{ + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + backlight_set(get_backlight_level()); +} + +void breathing_self_disable(void) +{ + if (get_backlight_level() == 0) + { + breathing_halt = BREATHING_HALT_OFF; + } + else + { + breathing_halt = BREATHING_HALT_ON; + } + + //backlight_set(get_backlight_level()); +} + +void breathing_toggle(void) +{ + if (!is_breathing()) + { + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint + 1 (brightest point) + breathing_index = 0x21 << breath_speed; + } + + breathing_halt = BREATHING_NO_HALT; + } + + // Toggle breathing interrupt + TIMSK1 ^= _BV(OCIE1A); + + // Restore backlight level + if (!is_breathing()) + { + backlight_set(get_backlight_level()); + } +} + +bool is_breathing(void) +{ + return (TIMSK1 && _BV(OCIE1A)); +} + +void breathing_intensity_default(void) +{ + //breath_intensity = (uint8_t)((uint16_t)100 * (uint16_t)get_backlight_level() / (uint16_t)BACKLIGHT_LEVELS); + breath_intensity = ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2)); +} + +void breathing_intensity_set(uint8_t value) +{ + breath_intensity = value; +} + +void breathing_speed_default(void) +{ + breath_speed = 4; +} + +void breathing_speed_set(uint8_t value) +{ + bool is_breathing_now = is_breathing(); + uint8_t old_breath_speed = breath_speed; + + if (is_breathing_now) + { + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + } + + breath_speed = value; + + if (is_breathing_now) + { + // Adjust index to account for new speed + breathing_index = (( (uint8_t)( (breathing_index) >> old_breath_speed ) ) & 0x3F) << breath_speed; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); + } + +} + +void breathing_speed_inc(uint8_t value) +{ + if ((uint16_t)(breath_speed - value) > 10 ) + { + breathing_speed_set(0); + } + else + { + breathing_speed_set(breath_speed - value); + } +} + +void breathing_speed_dec(uint8_t value) +{ + if ((uint16_t)(breath_speed + value) > 10 ) + { + breathing_speed_set(10); + } + else + { + breathing_speed_set(breath_speed + value); + } +} + +void breathing_defaults(void) +{ + breathing_intensity_default(); + breathing_speed_default(); + breathing_halt = BREATHING_NO_HALT; +} + +/* Breathing Sleep LED brighness(PWM On period) table + * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle + * + * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 + * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i } + */ +static const uint8_t breathing_table[64] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, + 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, +255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, + 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +ISR(TIMER1_COMPA_vect) +{ + // CHANNEL = (pgm_read_byte(&breathing_table[ ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F ] )) * breath_intensity; + + + uint8_t local_index = ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F; + + if (((breathing_halt == BREATHING_HALT_ON) && (local_index == 0x20)) || ((breathing_halt == BREATHING_HALT_OFF) && (local_index == 0x3F))) + { + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + } + + CHANNEL = (uint16_t)(((uint16_t)pgm_read_byte(&breathing_table[local_index]) * 257)) >> breath_intensity; + +} + + + +#endif \ No newline at end of file diff --git a/keyboard/atomic/atomic.h b/keyboard/atomic/atomic.h index d5461e424d4..456c3fbdf8d 100644 --- a/keyboard/atomic/atomic.h +++ b/keyboard/atomic/atomic.h @@ -1,10 +1,9 @@ #ifndef ATOMIC_H #define ATOMIC_H -#include "matrix.h" -#include "keymap_common.h" -#include "backlight.h" +#include "quantum.h" #include +#include // This a shortcut to help you visually see your layout. // The following is an example using the Planck MIT layout @@ -26,8 +25,24 @@ void matrix_init_user(void); void matrix_scan_user(void); -void process_action_user(keyrecord_t *record); +bool process_action_user(keyrecord_t *record); void led_set_user(uint8_t usb_led); void backlight_init_ports(void); +void breathing_enable(void); +void breathing_pulse(void); +void breathing_disable(void); +void breathing_self_disable(void); +void breathing_toggle(void); +bool is_breathing(void); + + +void breathing_defaults(void); +void breathing_intensity_default(void); +void breathing_speed_default(void); +void breathing_speed_set(uint8_t value); +void breathing_speed_inc(uint8_t value); +void breathing_speed_dec(uint8_t value); + + #endif \ No newline at end of file diff --git a/keyboard/atomic/backlight.c b/keyboard/atomic/backlight.c deleted file mode 100644 index 647b57e7185..00000000000 --- a/keyboard/atomic/backlight.c +++ /dev/null @@ -1,63 +0,0 @@ - -#include -#include "backlight.h" -#include "atomic.h" - - -#define CHANNEL OCR1C - -void backlight_init_ports() -{ - - // Setup PB7 as output and output low. - DDRB |= (1<<7); - PORTB &= ~(1<<7); - - // Use full 16-bit resolution. - ICR1 = 0xFFFF; - - // I could write a wall of text here to explain... but TL;DW - // Go read the ATmega32u4 datasheet. - // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on - - // Pin PB7 = OCR1C (Timer 1, Channel C) - // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 - // (i.e. start high, go low when counter matches.) - // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 - // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 - - TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; - TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; - - backlight_init(); -} - -void backlight_set(uint8_t level) -{ - if ( level == 0 ) - { - // Turn off PWM control on PB7, revert to output low. - TCCR1A &= ~(_BV(COM1C1)); - CHANNEL = 0x0; - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - } - else if ( level == BACKLIGHT_LEVELS ) - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF; - } - else - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); - } -} \ No newline at end of file diff --git a/keyboard/atomic/config.h b/keyboard/atomic/config.h index 1b34decf9c7..bf9550e9480 100644 --- a/keyboard/atomic/config.h +++ b/keyboard/atomic/config.h @@ -41,15 +41,16 @@ along with this program. If not, see . * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * -*/ -#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } -#define ROWS (int []){ D0, D5, B5, B6, C6 } +*/ +#define MATRIX_ROW_PINS { D0, D5, B5, B6, C6 } +#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* define if matrix has ghost (lacks anti-ghosting diodes) */ //#define MATRIX_HAS_GHOST @@ -62,17 +63,17 @@ along with this program. If not, see . /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -/* +/* * Force NKRO * - * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the * makefile for this to work.) * * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) * until the next keyboard reset. * - * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is * fully operational during normal computer usage. * * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) @@ -90,7 +91,7 @@ along with this program. If not, see . * the keyboard. They are best used in combination with the HID Listen program, * found here: https://www.pjrc.com/teensy/hid_listen.html * - * The options below allow the magic key functionality to be changed. This is + * The options below allow the magic key functionality to be changed. This is * useful if your keyboard/keypad is missing keys and you want magic key support. * */ diff --git a/keyboard/atomic/keymaps/pvc/config.h b/keyboard/atomic/keymaps/pvc/config.h index cc926346463..1473aac34f0 100644 --- a/keyboard/atomic/keymaps/pvc/config.h +++ b/keyboard/atomic/keymaps/pvc/config.h @@ -22,7 +22,7 @@ along with this program. If not, see . /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED -#define PRODUCT_ID 0x6060 +#define PRODUCT_ID 0x0419 #define DEVICE_VER 0x0001 #define MANUFACTURER Ortholinear Keyboards #define PRODUCT The Atomic Keyboard @@ -42,14 +42,15 @@ along with this program. If not, see . * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * */ -#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } -#define ROWS (int []){ D0, D5, B5, B6, B3 } +#define MATRIX_ROW_PINS { D0, D5, B5, B6, B3 } +#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7, D3, D2, D1 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* define if matrix has ghost (lacks anti-ghosting diodes) */ //#define MATRIX_HAS_GHOST @@ -158,4 +159,8 @@ along with this program. If not, see . //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION + +//#define VIBRATO_ENABLE +//#define VIBRATO_STRENGTH_ENABLE + #endif diff --git a/keyboard/atomic/keymaps/pvc/keymap.c b/keyboard/atomic/keymaps/pvc/keymap.c index e17c41e23db..f16ec8a6ec5 100644 --- a/keyboard/atomic/keymaps/pvc/keymap.c +++ b/keyboard/atomic/keymaps/pvc/keymap.c @@ -8,42 +8,44 @@ #include "song_list.h" #endif -#define LAYER_QWERTY 0 -#define LAYER_COLEMAK 1 -#define LAYER_DVORAK 2 -#define LAYER_LOWER 3 -#define LAYER_RAISE 4 -#define LAYER_FUNCTION 5 -#define LAYER_MOUSE 6 -#define LAYER_MUSIC 7 -#define LAYER_ADJUST 8 +#define LAYER_QWERTY 0 +#define LAYER_COLEMAK 1 +#define LAYER_DVORAK 2 +#define LAYER_UPPER 3 +#define LAYER_LOWER 4 +#define LAYER_FUNCTION 5 +#define LAYER_MOUSE 6 +#define LAYER_ADJUST 7 -#define MACRO_QWERTY 0 -#define MACRO_COLEMAK 1 -#define MACRO_DVORAK 2 -#define MACRO_LOWER 3 -#define MACRO_RAISE 4 -#define MACRO_FUNCTION 5 -#define MACRO_MOUSE 6 -#define MACRO_TIMBRE_1 7 -#define MACRO_TIMBRE_2 8 -#define MACRO_TIMBRE_3 9 -#define MACRO_TIMBRE_4 10 -#define MACRO_TEMPO_U 11 -#define MACRO_TEMPO_D 12 -#define MACRO_TONE_DEFAULT 13 -#define MACRO_MUSIC_ON 14 -#define MACRO_MUSIC_OFF 15 -#define MACRO_AUDIO_ON 16 -#define MACRO_AUDIO_OFF 17 -#define MACRO_INC_VOICE 18 -#define MACRO_DEC_VOICE 19 +#define MACRO_QWERTY 0 +#define MACRO_COLEMAK 1 +#define MACRO_DVORAK 2 +#define MACRO_UPPER 3 +#define MACRO_LOWER 4 +#define MACRO_FUNCTION 5 +#define MACRO_MOUSE 6 +#define MACRO_TIMBRE_1 7 +#define MACRO_TIMBRE_2 8 +#define MACRO_TIMBRE_3 9 +#define MACRO_TIMBRE_4 10 +#define MACRO_TEMPO_U 11 +#define MACRO_TEMPO_D 12 +#define MACRO_TONE_DEFAULT 13 +#define MACRO_MUSIC_TOGGLE 14 +#define MACRO_AUDIO_TOGGLE 16 +#define MACRO_INC_VOICE 18 +#define MACRO_DEC_VOICE 19 +#define MACRO_BACKLIGHT 20 +#define MACRO_BREATH_TOGGLE 21 +#define MACRO_BREATH_SPEED_INC 23 +#define MACRO_BREATH_SPEED_DEC 24 +#define MACRO_BREATH_DEFAULT 25 #define M_QWRTY M(MACRO_QWERTY) #define M_COLMK M(MACRO_COLEMAK) #define M_DVORK M(MACRO_DVORAK) +#define M_UPPER M(MACRO_UPPER) #define M_LOWER M(MACRO_LOWER) -#define M_RAISE M(MACRO_RAISE) #define M_FUNCT M(MACRO_FUNCTION) #define M_MOUSE M(MACRO_MOUSE) #define TIMBR_1 M(MACRO_TIMBRE_1) @@ -53,12 +55,13 @@ #define TMPO_UP M(MACRO_TEMPO_U) #define TMPO_DN M(MACRO_TEMPO_D) #define TMPO_DF M(MACRO_TONE_DEFAULT) +#define M_BACKL M(MACRO_BACKLIGHT) +#define M_BRTOG M(MACRO_BREATH_TOGGLE) +#define M_BSPDU M(MACRO_BREATH_SPEED_INC) +#define M_BSPDD M(MACRO_BREATH_SPEED_DEC) +#define M_BDFLT M(MACRO_BREATH_DEFAULT) -#define MUS_ON M(MACRO_MUSIC_ON) -#define MUS_OFF M(MACRO_MUSIC_OFF) -#define AUD_OFF M(MACRO_AUDIO_OFF) -#define AUD_ON M(MACRO_AUDIO_ON) #define VC_UP M(MACRO_INC_VOICE) #define VC_DOWN M(MACRO_DEC_VOICE) @@ -74,6 +77,7 @@ #define SC_ACLS LALT(KC_F4) #define SC_CCLS LCTL(KC_F4) +#define OS_SHFT KC_FN0 #define _______ KC_TRNS #define XXXXXXX KC_NO @@ -92,16 +96,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| * | LSHIFT | Z | X | C | V | B | N | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN | * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT | * '--------------------------------------------------------------------------------------------------------------------------------------' */ - [LAYER_QWERTY] = { /* QWERTY */ + [LAYER_QWERTY] = { // QWERTY { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC }, { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL }, { KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_ENT, KC_PGUP }, { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, }, /* COLEMAK @@ -114,17 +118,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| * | LSHIFT | Z | X | C | V | B | K | M | , | . | / | XXXXXX . RSHIFT | UP | PG DN | * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT | * '--------------------------------------------------------------------------------------------------------------------------------------' */ - [LAYER_COLEMAK] = { /* COLEMAK */ + [LAYER_COLEMAK] = { // COLEMAK { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_BSPC }, { KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL }, { KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, KC_ENT, KC_PGUP }, { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, - }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, +}, /* DVORAK * .---------------------------------------------------------------------------------------------------------------------- 2u ------------. @@ -136,36 +140,63 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| * | LSHIFT | ; | Q | J | K | X | B | M | W | V | Z | XXXXXX . RSHIFT | UP | PG DN | * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | XXXXXX . SPACE | LOWER | RALT | RWIN | MENU | RCTRL | LEFT | DOWN | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | XXXXXX . SPACE | LOWER | SHIFT | RALT | APP | RCTRL | LEFT | DOWN | RIGHT | * '--------------------------------------------------------------------------------------------------------------------------------------' */ - [LAYER_DVORAK] = { /* DVORAK */ + [LAYER_DVORAK] = { // DVORAK { KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_LBRC, KC_RBRC, KC_BSPC, KC_BSPC }, { KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, KC_EQL, KC_BSLS, KC_DEL }, { KC_CAPS, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, KC_ENT, KC_ENT, KC_PGUP }, { KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, KC_RSFT, KC_UP, KC_PGDN }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_RALT, KC_RGUI, KC_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_RALT, KC_APP, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT }, }, +/* UPPER + * .---------------------------------------------------------------------------------------------------------------------- 2u ------------. + * | PRINT | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | NUM LK | / | * | | NUM LK | SCR LK | XXXXXX . PAUSE | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | F1 | F2 | F3 | F4 | | | 7 | 8 | 9 | - | | | | INS | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------| + * | CAP LK | F5 | F6 | F7 | F8 | | | 4 | 5 | 6 | + | | XXXXXX . | HOME | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| + * | | F9 | F10 | F11 | F12 | | | 1 | 2 | 3 | ENTER | XXXXXX . | | END | + * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| + * | | | | | | 0 | | RALT | . | ENTER | | | | | + * '--------------------------------------------------------------------------------------------------------------------------------------' + */ - [LAYER_LOWER] = { /* LOWERED */ - { KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ }, - { _______, _______, _______, _______, SC_CCLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS }, - { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_HOME }, - { _______, SC_REDO, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______, KC_END }, - { _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, _______, _______, _______, _______, _______, _______, _______ }, + [LAYER_UPPER] = { // UPPER + { KC_PSCR, M_BRTOG, M_BSPDU, M_BSPDD, M_BDFLT, XXXXXXX, XXXXXXX, KC_NLCK, KC_PSLS, KC_PAST, XXXXXXX, XXXXXXX, KC_SLCK, KC_PAUS, KC_PAUS }, + { _______, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, XXXXXXX, KC_KP_7, KC_KP_8, KC_KP_9, KC_PMNS, _______, _______, _______, KC_INS }, + { KC_CAPS, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX, XXXXXXX, KC_KP_4, KC_KP_5, KC_KP_6, KC_PPLS, _______, ________________, KC_HOME }, + { _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, KC_KP_1, KC_KP_2, KC_KP_3, KC_PENT, ________________, _______, KC_END }, + { _______, _______, _______, _______, _______, KC_KP_0, KC_KP_0, _______, KC_RALT, KC_PDOT, KC_PENT, _______, _______, _______, _______ }, }, - [LAYER_RAISE] = { /* RAISED */ - { KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ }, - { _______, _______, _______, _______, SC_ACLS, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_INS }, - { _______, SC_SELA, SC_SAVE, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_HOME }, - { _______, SC_UNDO, SC_CUT, SC_COPY, SC_PSTE, _______, _______, _______, _______, _______, _______, ________________, _______, KC_END }, +/* LOWER + * .---------------------------------------------------------------------------------------------------------------------- 2u ------------. + * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX . BACKSP | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | $ | { | [ | ( | % | # | ) | ] | } | @ | | | | INS | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ------------+--------| + * | | ^ | * | + | - | ; | : | _ | ' | " | ` | | XXXXXX . | HOME | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+- 2u ---------------------+--------| + * | | | | & | ! | ~ | / | \ | = | < | > | ? | XXXXXX . | | END | + * |--------+--------+--------+--------+--------+- 2u ------------+--------+--------+--------+--------+-----------------+--------+--------| + * | | | | | | | | | | | | | | | + * '--------------------------------------------------------------------------------------------------------------------------------------' + */ + + [LAYER_LOWER] = { // LOWER + { _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ }, + { _______, KC_DLR, KC_LCBR, KC_LBRC, KC_LPRN, KC_PERC, KC_HASH, KC_RPRN, KC_RBRC, KC_RCBR, KC_AT, _______, _______, _______, KC_INS }, + { _______, KC_CIRC, KC_ASTR, KC_PPLS, KC_PMNS, KC_SCLN, KC_COLN, KC_UNDS, KC_QUOT, KC_DQT, KC_GRV, _______, ________________, KC_HOME }, + { _______, KC_PIPE, KC_AMPR, KC_EXLM, KC_TILD, KC_SLSH, KC_BSLS, KC_EQL, KC_LT, KC_GT, KC_QUES, ________________, _______, KC_END }, { _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, _______, _______ }, }, - [LAYER_FUNCTION] = { /* FUNCTION */ + [LAYER_FUNCTION] = { // FUNCTION { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, ________________ }, { KC_SLCK, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_F21, KC_F22, KC_F23, KC_F24, _______, KC_PAUS }, { KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, KC_PSCR }, @@ -175,7 +206,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #ifdef MOUSEKEY_ENABLE - [LAYER_MOUSE] = { /* MOUSE */ + [LAYER_MOUSE] = { // MOUSE { _______, KC_ACL0, KC_ACL1, KC_ACL2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXXXXXXXXXXX }, { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, { XXXXXXX, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXXXXXXXXXXX, KC_WH_U }, @@ -185,25 +216,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #endif - [LAYER_MUSIC] = { /* MUSIC */ - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_RAISE, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - }, - - [LAYER_ADJUST] = { /* ADJUST */ - { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF, ________________ }, + [LAYER_ADJUST] = { // ADJUST + { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, _______, _______, MU_TOG, AU_TOG, ________________ }, { _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______ }, - { _______, _______, _______, _______, _______, RESET, _______, M_MOUSE, _______, _______, _______, ________________, VC_UP, _______ }, - { _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, VC_DOWN, _______ }, + { _______, _______, _______, _______, M_BACKL, RESET, _______, M_MOUSE, _______, _______, _______, ________________, MUV_IN, _______ }, + { _______, _______, _______, _______, _______, ________________, _______, _______, _______, _______, _______, _______, MUV_DE, _______ }, }, /* - [LAYER_EMPTY] = { + [LAYER_EMPTY] = { // LAYER { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________ }, { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ }, { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, ________________, _______ }, @@ -225,13 +248,14 @@ float tone_colemak[][2] = SONG(COLEMAK_SOUND); float tone_audio_on[][2] = SONG(CLOSE_ENCOUNTERS_5_NOTE); float tone_music_on[][2] = SONG(DOE_A_DEER); +float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); + float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND); float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND); float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND); float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND); float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND); float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND); -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); #endif /* AUDIO_ENABLE */ @@ -242,6 +266,7 @@ void persistant_default_layer_set(uint16_t default_layer) } const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_MODS_ONESHOT(MOD_LSFT), }; const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) @@ -251,13 +276,41 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) switch(id) { + case MACRO_BREATH_TOGGLE: + if (record->event.pressed) + { + breathing_toggle(); + } + break; + + case MACRO_BREATH_SPEED_INC: + if (record->event.pressed) + { + breathing_speed_inc(1); + } + break; + + case MACRO_BREATH_SPEED_DEC: + if (record->event.pressed) + { + breathing_speed_dec(1); + } + break; + + case MACRO_BREATH_DEFAULT: + if (record->event.pressed) + { + breathing_defaults(); + } + break; + case MACRO_QWERTY: if (record->event.pressed) { persistant_default_layer_set(1UL<event.pressed) { persistant_default_layer_set(1UL<event.pressed) { persistant_default_layer_set(1UL<event.pressed) + { + layer_on(LAYER_UPPER); + breathing_speed_set(2); + breathing_pulse(); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); + } + else + { + layer_off(LAYER_UPPER); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; @@ -285,35 +353,28 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + breathing_speed_set(2); + breathing_pulse(); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); - } - break; - - case MACRO_RAISE: - if (record->event.pressed) - { - layer_on(LAYER_RAISE); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); - } - else - { - layer_off(LAYER_RAISE); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; case MACRO_FUNCTION: if (record->event.pressed) { + breathing_speed_set(3); + breathing_enable(); layer_on(LAYER_FUNCTION); } else { + breathing_speed_set(1); + breathing_self_disable(); layer_off(LAYER_FUNCTION); } break; @@ -363,45 +424,37 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) } break; - case MACRO_AUDIO_OFF: +/* + case MACRO_AUDIO_TOGGLE: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_off(); - #endif + if (is_audio_on()) + { + audio_off(); + } + else + { + audio_on(); + PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO); + } } break; - case MACRO_AUDIO_ON: + case MACRO_MUSIC_TOGGLE: if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_on(); - PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO); - #endif - } - break; - - case MACRO_MUSIC_ON: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE + if (IS_LAYER_ON(LAYER_MUSIC)) + { + layer_off(LAYER_MUSIC); + stop_all_notes(); + } + else + { PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO); layer_on(LAYER_MUSIC); - #endif + } } break; - - case MACRO_MUSIC_OFF: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - layer_off(LAYER_MUSIC); - stop_all_notes(); - #endif - } - break; - case MACRO_INC_VOICE: if (record->event.pressed) { @@ -421,9 +474,18 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #endif } break; +*/ #endif /* AUDIO_ENABLE */ +#ifdef BACKLIGHT_ENABLE + case MACRO_BACKLIGHT: + if (record->event.pressed) + { + backlight_step(); + } +#endif + default: break; @@ -434,31 +496,10 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE - -void process_action_user(keyrecord_t *record) -{ - - uint8_t starting_note = 0x0C; - int offset = 7; - - if (IS_LAYER_ON(LAYER_MUSIC)) - { - if (record->event.pressed) - { - play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); - } - else - { - stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); - } - } -} - - void matrix_init_user(void) { set_voice(default_voice); - play_startup_tone(); + startup_user(); println("Matrix Init"); } @@ -468,50 +509,70 @@ void led_set_user(uint8_t usb_led) _delay_ms(10); // gets rid of tick - if ((usb_led & (1<. // Change this to how you wired your keyboard // COLS: Left to right, ROWS: Top to bottom #if defined(ATREUS_ASTAR) - #define COLS (int []){ B7, D6, F7, F6, B6, D4, E6, B4, B5, C6, D7 } - #define ROWS (int []){ D0, D1, D3, D2 } +# define MATRIX_ROW_PINS { D0, D1, D3, D2 } +# define MATRIX_COL_PINS { D7, C6, B5, B4, E6, D4, B6, F6, F7, D6, B7 } +# define UNUSED_PINS #elif defined(ATREUS_TEENSY2) - #define COLS (int []){ F6, F5, F4, B7, B6, B5, B4, B3, B2, B1, B0} - #define ROWS (int []){ D0, D1, D2, D3 } +# define MATRIX_ROW_PINS { D0, D1, D2, D3 } +# define MATRIX_COL_PINS { F6, F5, F4, B7, B6, B5, B4, B3, B2, B1, B0 } +# define UNUSED_PINS #endif /* COL2ROW or ROW2COL */ @@ -53,7 +55,7 @@ along with this program. If not, see . //#define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/clueboard1/Makefile b/keyboard/clueboard1/Makefile index 50cde1517bf..7192a9734ce 100644 --- a/keyboard/clueboard1/Makefile +++ b/keyboard/clueboard1/Makefile @@ -114,15 +114,16 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # comment out to disable the options. # BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -# MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -# RGBLIGHT_ENABLE = yes # Enable keyboard underlight functionality -# MIDI_ENABLE = YES # MIDI controls -# UNICODE_ENABLE = YES # Unicode -# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality +MIDI_ENABLE = no # MIDI controls +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID # Optimize size but this may cause error "relocation truncated to fit" diff --git a/keyboard/clueboard1/config.h b/keyboard/clueboard1/config.h index 2b20c3873d1..16338ddb03d 100644 --- a/keyboard/clueboard1/config.h +++ b/keyboard/clueboard1/config.h @@ -32,19 +32,18 @@ along with this program. If not, see . #define MATRIX_ROWS 5 #define MATRIX_COLS 16 -// COLS: Left to right, ROWS: Top to bottom - +// ROWS: Top to bottom, COLS: Left to right /* Column pin configuration - * col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - * pin: B3 F1 F4 F5 F6 C7 C6 B6 B5 B4 D7 D6 D4 F7 B0 B1 - */ -#define COLS (int []){ B3, F1, F4, F5, F6, C7, C6, B6, B5, B4, D7, D6, D4, F7, B0, B1 } - - /* Row pin configuration - * row: 0 1 2 3 4 - * pin: D1 D0 D2 D5 D3 - */ -#define ROWS (int []){ D1, D0, D2, D5, D3 } +* col: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +* pin: B3 F1 F4 F5 F6 C7 C6 B6 B5 B4 D7 D6 D4 F7 B0 B1 +*/ +#define MATRIX_COL_PINS { B3, F1, F4, F5, F6, C7, C6, B6, B5, B4, D7, D6, D4, F7, B0, B1 } +/* Row pin configuration +* row: 0 1 2 3 4 +* pin: D1 D0 D2 D5 D3 +*/ +#define MATRIX_ROW_PINS { D1, D0, D2, D5, D3 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -53,7 +52,7 @@ along with this program. If not, see . //#define MATRIX_HAS_GHOST /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/clueboard2/Makefile b/keyboard/clueboard2/Makefile index 788c204872f..bcce8ac9fa0 100644 --- a/keyboard/clueboard2/Makefile +++ b/keyboard/clueboard2/Makefile @@ -114,16 +114,17 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # comment out to disable the options. # BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -# MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -RGBLIGHT_ENABLE = yes # Enable keyboard underlight functionality -BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -# MIDI_ENABLE = YES # MIDI controls -# UNICODE_ENABLE = YES # Unicode -# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable keyboard underlight functionality (+4870) +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality (+1150) +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID #ifdef BACKLIGHT_ENABLE SRC := backlight.c $(SRC) diff --git a/keyboard/clueboard2/config.h b/keyboard/clueboard2/config.h index 04166c20f63..2887519afd2 100644 --- a/keyboard/clueboard2/config.h +++ b/keyboard/clueboard2/config.h @@ -32,19 +32,18 @@ along with this program. If not, see . #define MATRIX_ROWS 10 #define MATRIX_COLS 8 -// COLS: Left to right, ROWS: Top to bottom - +// ROWS: Top to bottom, COLS: Left to right +/* Row pin configuration +* row: 0 1 2 3 4 5 6 7 8 9 +* pin: B2 C7 C6 B6 B5 B0 B3 D5 D3 D2 +*/ +#define MATRIX_ROW_PINS { B2, C7, C6, B6, B5, B0, B3, D5, D3, D2 } /* Column pin configuration * col: 0 1 2 3 4 5 6 7 * pin: F0 F1 F4 F5 F6 F7 E6 B1 */ -#define COLS (int []){ F0, F1, F4, F5, F6, F7, E6, B1 } - - /* Row pin configuration - * row: 0 1 2 3 4 5 6 7 8 9 - * pin: B2 C7 C6 B6 B5 B0 B3 D5 D3 D2 - */ -#define ROWS (int []){ B2, C7, C6, B6, B5, B0, B3, D5, D3, D2 } +#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, E6, B1 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -53,7 +52,7 @@ along with this program. If not, see . //#define MATRIX_HAS_GHOST /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/cluepad/Makefile b/keyboard/cluepad/Makefile index cfa130d75a7..9d4ddc07fb1 100644 --- a/keyboard/cluepad/Makefile +++ b/keyboard/cluepad/Makefile @@ -115,9 +115,9 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) # MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration +# EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +# CONSOLE_ENABLE = yes # Console for debug(+400) +# COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = yes # Enable numpad's backlight functionality RGBLIGHT_ENABLE = yes diff --git a/keyboard/cluepad/config.h b/keyboard/cluepad/config.h index 5ed421a6e0b..0955e0f7026 100644 --- a/keyboard/cluepad/config.h +++ b/keyboard/cluepad/config.h @@ -32,19 +32,18 @@ along with this program. If not, see . #define MATRIX_ROWS 5 #define MATRIX_COLS 4 -// COLS: Left to right, ROWS: Top to bottom - +// ROWS: Top to bottom, COLS: Left to right +/* Row pin configuration +* row: 0 1 2 3 4 +* pin: +*/ +#define MATRIX_ROW_PINS { B0, D3, D5, D4, D6 } /* Column pin configuration * col: 0 1 2 3 * pin: F4 E6 B1 D2 */ -#define COLS (int []){ F4, E6, B1, D2 } - - /* Row pin configuration - * row: 0 1 2 3 4 - * pin: - */ -#define ROWS (int []){ B0, D3, D5, D4, D6 } +#define MATRIX_COL_PINS { F4, E6, B1, D2 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -53,7 +52,7 @@ along with this program. If not, see . //#define MATRIX_HAS_GHOST /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Number of backlighting levels */ #define BACKLIGHT_LEVELS 3 diff --git a/keyboard/ergodox_ez/Makefile b/keyboard/ergodox_ez/Makefile index 5dfcca2c803..3a07ec254f4 100644 --- a/keyboard/ergodox_ez/Makefile +++ b/keyboard/ergodox_ez/Makefile @@ -101,6 +101,22 @@ NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: ht # MIDI_ENABLE = yes # MIDI controls # UNICODE_ENABLE = yes # Unicode +# If you want to have your own config_user.h, you can just put it in +# your keymap directory. Anything you set there will take precedence +# over the global config.h. +ifneq ("$(wildcard keymaps/$(KEYMAP)/config_user.h)","") +CONFIG_USER_H = keymaps/$(KEYMAP)/config_user.h +endif + +ifdef KEYMAP + +ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif +endif +endif + # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/ergodox_ez/keymaps/ab/ab.hex b/keyboard/ergodox_ez/keymaps/ab/ab.hex new file mode 100644 index 00000000000..1659ae5802c Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/ab/ab.hex differ diff --git a/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.json b/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.json new file mode 100644 index 00000000000..4ade7487322 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.json @@ -0,0 +1,385 @@ +[ + { + "name": "Beginner's Keymap for Ergodox-EZ", + "author": "Anand Babu Periasamy" + }, + [ + { + "x": 3.5 + }, + "#\n3\n\n\nF3", + { + "x": 10.5 + }, + ")\n0\n\n\nF10" + ], + [ + { + "y": -0.875, + "x": 2.5 + }, + "@\n2\n\n\nF2", + { + "x": 1 + }, + "$\n4\n\n\nF4", + { + "x": 8.5 + }, + "(\n9\n\n\nF9", + { + "x": 1 + }, + "_\n-\n\n\nF11" + ], + [ + { + "y": -0.875, + "x": 5.5 + }, + "%\n5\n\n\nF5", + "^\n6\n\n\nF6", + { + "x": 4.5 + }, + "&\n7\n\n\nF7", + "*\n8\n\n\nF8" + ], + [ + { + "y": -0.875, + "w": 1.5 + }, + "~\n`\n\n\nEsc", + "!\n1\n\n\nF1", + { + "x": 14.5 + }, + "+\n=\n\n\nF12", + { + "a": 7, + "w": 1.5 + }, + "Backspace\n\n\n\nBackspace" + ], + [ + { + "y": -0.375, + "x": 3.5 + }, + "E\n\n\n\n", + { + "x": 10.5 + }, + "I" + ], + [ + { + "y": -0.8799999999999999, + "x": 2.5 + }, + "W" + ], + [ + { + "y": -0.9950000000000001, + "x": 4.5, + "a": 4 + }, + "R", + { + "x": 8.5, + "a": 7 + }, + "U", + { + "x": 1 + }, + "O" + ], + [ + { + "y": -0.875, + "x": 5.5 + }, + "T", + { + "h": 1.5 + }, + "", + { + "x": 4.5, + "h": 1.5 + }, + "", + "Y" + ], + [ + { + "y": -0.875, + "a": 6, + "w": 1.5 + }, + "Tab", + { + "a": 7 + }, + "Q", + { + "x": 14.5 + }, + "P", + { + "a": 4, + "w": 1.5 + }, + "|\n\\" + ], + [ + { + "y": -0.375, + "x": 3.5, + "a": 7 + }, + "D\n\n\n\n", + { + "x": 10.5 + }, + "K" + ], + [ + { + "y": -0.875, + "x": 2.5 + }, + "S\n\n\n\n", + { + "x": 1 + }, + "F\n\n\n\n", + { + "x": 8.5 + }, + "J", + { + "x": 1 + }, + "L" + ], + [ + { + "y": -0.875, + "x": 5.5 + }, + "G", + { + "x": 6.5 + }, + "H" + ], + [ + { + "y": -0.875, + "a": 4, + "fa": [ + 0, + 0, + 0, + 2 + ], + "w": 1.5 + }, + "\n\n\nCtrl\n\n\nCaps", + { + "a": 7 + }, + "A", + { + "x": 14.5, + "a": 4 + }, + ":\n;", + { + "a": 7, + "w": 1.5 + }, + "Enter" + ], + [ + { + "y": -0.625, + "x": 6.5, + "h": 1.5 + }, + "PgUp", + { + "x": 4.5, + "h": 1.5 + }, + "PgDn" + ], + [ + { + "y": -0.75, + "x": 3.5 + }, + "C", + { + "x": 10.5, + "a": 4 + }, + "<\n," + ], + [ + { + "y": -0.875, + "x": 2.5, + "a": 7 + }, + "X", + { + "x": 1 + }, + "V", + { + "x": 8.5 + }, + "M", + { + "x": 1, + "a": 4 + }, + ">\n." + ], + [ + { + "y": -0.875, + "x": 5.5, + "a": 7 + }, + "B", + { + "x": 6.5 + }, + "N" + ], + [ + { + "y": -0.875, + "w": 1.5 + }, + "Shift", + "Z", + { + "x": 14.5, + "a": 4 + }, + "?\n/", + { + "w": 1.5 + }, + "\"\n'" + ], + [ + { + "y": -0.375, + "x": 3.5, + "a": 7 + }, + "Alt\n\n\n\n", + { + "x": 10.5 + }, + "\n\n\n\n" + ], + [ + { + "y": -0.875, + "x": 2.5 + }, + "", + { + "x": 1 + }, + "Alt\n\n\n\n", + { + "x": 8.5 + }, + "", + { + "x": 1 + }, + "\n\n\n\n" + ], + [ + { + "y": -0.75, + "x": 0.5 + }, + "Ctrl\n\n\n\n", + "Esc", + { + "x": 14.5 + }, + "\n\n\n\n", + "Fn" + ], + [ + { + "r": 30, + "rx": 6.5, + "ry": 4.25, + "y": -1, + "x": 1 + }, + "", + "(" + ], + [ + { + "h": 2 + }, + "Space", + { + "h": 2 + }, + "Del", + "[" + ], + [ + { + "x": 2 + }, + "{" + ], + [ + { + "r": -30, + "rx": 13, + "y": -1, + "x": -3 + }, + ")", + "" + ], + [ + { + "x": -3 + }, + "]", + { + "h": 2 + }, + "Enter", + { + "h": 2 + }, + "" + ], + [ + { + "x": -3 + }, + "}" + ] +] \ No newline at end of file diff --git a/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.png b/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.png new file mode 100644 index 00000000000..9a6546e3572 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/ab/keyboard-layout.png differ diff --git a/keyboard/ergodox_ez/keymaps/ab/keymap.c b/keyboard/ergodox_ez/keymaps/ab/keymap.c new file mode 100644 index 00000000000..9b5c93c1eed --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/ab/keymap.c @@ -0,0 +1,140 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 // default layer +#define FN1 1 // media layer + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | ` | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 0 | - | = | BSpace | + * |--------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | Tab | Q | W | E | R | T | Fwd | | Back | Y | U | I | O | P | \ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * |Caps/Ctl| A | S | D | F | G |------| |------| H | J | K | L | ; | Enter | + * |--------+------+------+------+------+------| PgUp | | PgDn |------+------+------+------+------+--------| + * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | ' | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | Ctrl | Esc | LGui | Alt | Alt | | Left | Up | Dn | Right| Fn | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | Copy | ( | | ) | Paste| + * ,------|------+------| |------+------+------. + * | | | [ | | ] | | | + * |Space | Del |------| |------| Enter|BSpace| + * | | | { | | } | | | + * `--------------------' `--------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* + [BASE] = KEYMAP( // layer 0 : default + // left hand + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_WBAK, + CTL_T(KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_PGUP, + KC_LCTL, KC_ESC, KC_LGUI, KC_LALT, KC_LALT, + LCTL(KC_C), KC_LCBR, + KC_LPRN, + KC_SPC, KC_DEL, KC_LBRC, + // right hand + KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_WFWD, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, + KC_PGDN, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_QUOT, + KC_UP, KC_LEFT, KC_RIGHT,KC_DOWN, TG(FN1), + KC_RCBR, LCTL(KC_V), + KC_RPRN, + KC_RBRC, KC_ENT, KC_BSPC + ), +/* Keymap 1: Fn Keys, media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | Esc | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | BSpace | + * |--------+------+------+------+------+------+------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |Teensy| | | Lclk | Rclk | | |VolUp |VolDn | Mute | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------+------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// FN1 Layer + [FN1] = KEYMAP( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + RESET, KC_TRNS, KC_TRNS, + // right hand + KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_BSPC, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_VOLD, KC_VOLU, KC_MUTE, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboard/ergodox_ez/keymaps/ab/readme.md b/keyboard/ergodox_ez/keymaps/ab/readme.md new file mode 100644 index 00000000000..67d47151bc2 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/ab/readme.md @@ -0,0 +1,21 @@ +# Beginner's keymap for Ergodox-EZ +Beginner's keymap emulates standard QWERTY keyboard for beginners. Once you get comfortable with the Ergodox-EZ, you may fork this keymap and customize it for your own needs or find a suitable one from the community contributed keymaps. + +![Beginner's Keymap](keyboard-layout.png) + +#### Pros +* Easier to switch between regular keyboards and Ergodox-EZ. +* Easy on beginners. It has everything you need for your day to day usage. + +#### Cons +* Keys are not ergonomically placed to take full advantage of Ergodox-EZ. Take a look at this [Default Keymap](https://github.com/jackhumbert/qmk_firmware/blob/master/keyboard/ergodox_ez/keymaps/default/readme.md) +* While multiple layers are possible, beginner's keymap only uses one additional layer for mouse, function and volume keys. + +#### Notes +* Ideally number key [6] should have started from the right-hand side of the keyboard. Doing so breaks the familiar QWERTY layout. +* Quote key ['] should have been placed between [:] and [Enter]. Due to lack of key space, it is placed below [Enter]. +* Double [Alt] keys are placed adjacent to each other for convenience. +* [CapsLock] also acts as [Ctrl] key when you press and hold. It is convenient for GNU Emacs users. +* Additional bracket keys are placed in the center of the keyboard for programmer's convenience. + + diff --git a/keyboard/ergodox_ez/keymaps/adnw/k_o_y/k_o_y.hex b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/k_o_y.hex new file mode 100644 index 00000000000..95036fc4444 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/k_o_y.hex differ diff --git a/keyboard/ergodox_ez/keymaps/adnw/k_o_y/keymap.c b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/keymap.c new file mode 100644 index 00000000000..e33037b3304 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/keymap.c @@ -0,0 +1,185 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" +#include "keymap_extras/keymap_german.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | Del | K | . | O | , | Y | L1 | | L1 | V | G | C | L | ß | Z | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | BkSp | H | A | E | I | U |------| |------| D | T | R | N | S | F | + * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------| + * | LShift |X/Ctrl| Q | Ä | Ü | Ö | | | | B | P | W | M | J | RShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | App | LGui | | Alt |Ctrl/Esc| + * ,------|------|------| |------+--------+------. + * | | | Home | | PgUp | | | + * | Space|Enter |------| |------| Tab |RShift| + * | | | End | | PgDn | | | + * `--------------------' `----------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* +[BASE] = KEYMAP( // layer 0 : default + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, + KC_DELT, DE_K, DE_DOT, DE_O, DE_COMM,DE_Y, TG(SYMB), + KC_BSPC, DE_H, DE_A, DE_E, DE_I, DE_U, + KC_LSFT, CTL_T(DE_X), DE_Q, DE_AE, DE_UE, DE_OE, ALL_T(KC_NO), + LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT, + ALT_T(KC_APP), KC_LGUI, + KC_HOME, + KC_SPC,KC_ENT ,KC_END, + // right hand + KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + TG(SYMB), DE_V, DE_G, DE_C, DE_L, DE_SS, DE_Z, + DE_D, DE_T, DE_R, DE_N, LT(MDIA, DE_S), GUI_T(KC_F), + MEH_T(KC_NO),KC_B, KC_P, KC_W, KC_M, CTL_T(KC_J), KC_RSFT, + KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, + KC_LALT, CTL_T(KC_ESC), + KC_PGUP, + KC_PGDN,KC_TAB, KC_RSFT + ), +/* Keymap 1: Symbol Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | . | 0 | = | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = KEYMAP( + // left hand + KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS, + KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS, + KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | Prev | Next | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// MEDIA AND MOUSE +[MDIA] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboard/ergodox_ez/keymaps/adnw/k_o_y/readme.md b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/readme.md new file mode 100644 index 00000000000..f0dd3815c14 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/adnw/k_o_y/readme.md @@ -0,0 +1,7 @@ +# Basic implementation for k.o,y variant of the adnw layout + +adnw is a layout optimised for usage with german and english language +k.o,y is a variant of this layout +http://www.adnw.de/index.php?n=Main.SeitlicheNachbaranschl%C3%A4ge + +The os must use the de_DE layout diff --git a/keyboard/ergodox_ez/keymaps/default_osx/keymap.c b/keyboard/ergodox_ez/keymaps/default_osx/keymap.c index 81b49ceff94..c57ffbb889a 100644 --- a/keyboard/ergodox_ez/keymaps/default_osx/keymap.c +++ b/keyboard/ergodox_ez/keymaps/default_osx/keymap.c @@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [BASE] = KEYMAP( // layer 0 : default // left hand KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, - KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(1), + KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT, @@ -45,7 +45,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_SPC,KC_BSPC,KC_END, // right hand KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, - TG(1), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),KC_LGUI, MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT, KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, @@ -117,7 +117,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * `--------------------' `--------------------' */ // MEDIA AND MOUSE -KEYMAP( +[MDIA] = KEYMAP( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/config_user.h b/keyboard/ergodox_ez/keymaps/erez_experimental/config_user.h new file mode 100644 index 00000000000..d19c2783c3e --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/erez_experimental/config_user.h @@ -0,0 +1,8 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "config.h" +#define ONESHOT_TAP_TOGGLE 2 +#define ONESHOT_TIMEOUT 3000 + +#endif diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/erez_experimental.hex b/keyboard/ergodox_ez/keymaps/erez_experimental/erez_experimental.hex index bb78a5ea47c..bdd707165f3 100644 Binary files a/keyboard/ergodox_ez/keymaps/erez_experimental/erez_experimental.hex and b/keyboard/ergodox_ez/keymaps/erez_experimental/erez_experimental.hex differ diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c b/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c index f3190133121..f4e4f92e013 100644 --- a/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c +++ b/keyboard/ergodox_ez/keymaps/erez_experimental/keymap.c @@ -20,9 +20,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| * | BkSp | A | S | D | F | G |------| |------| H | Alt/J| K | L |; / L2| LGui/' | * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------| - * |LShift/(|Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl|RShift/)| + * |LShift/(|Z/Ctrl| X | C | V | B | [ | | ] | N | M | , | . |//Ctrl|RShift/)| * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' - * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | -/L1 | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | App | LGui | | Alt |Ctrl/Esc| @@ -39,18 +39,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, - LSFTO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), + LSFTO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_LBRC), LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, ALT_T(KC_APP), KC_LGUI, KC_HOME, - KC_SPC,KC_FN1,KC_END, + KC_SPC,KC_FN1,KC_END, // right hand - KC_RGHT, KC_6,KC_7, KC_8, KC_9, KC_0, KC_MINS, - TG(SYMB), KC_Y,KC_U, KC_I, KC_O, KC_P, KC_BSLS, - KC_H,ALT_T(KC_J),KC_K, KC_L, LT(MDIA,KC_SCLN),GUI_T(KC_QUOT), - MEH_T(KC_NO),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), RSFTC, - KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, - KC_LALT, CTL_T(KC_ESC), + KC_RGHT, KC_6,KC_7, KC_8, KC_9, KC_0, KC_MINS, + TG(SYMB), KC_Y,KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_H,ALT_T(KC_J),KC_K, KC_L, LT(MDIA,KC_SCLN),GUI_T(KC_QUOT), + MEH_T(KC_RBRC),KC_N,KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), RSFTC, + KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, LT(SYMB,KC_MINS), + KC_LALT, CTL_T(KC_ESC), KC_PGUP, KC_PGDN,LT(SYMB, KC_TAB), KC_ENT ), @@ -59,13 +59,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ,--------------------------------------------------. ,--------------------------------------------------. * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| - * | | 1 | 2 | 3 | 4 | | | | | | % | = | @ | | F12 | + * | | | | | | | | | | | | | | | F12 | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| - * | | 5 | 6 | 7 | 8 | 9 |------| |------| & | _ | - | ; | + | | + * | | 1 | 2 | 3 | 4 | 5 |------| |------| & | _ | - | ; | + | | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| - * | | ( | ) | [ | ] | 0 | | | | | | ( | ) | | | | + * | | 6 | 7 | 8 | 9 | 0 | | | | | | @ | = | % | | | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' - * | | | | | | | | | | | | + * | | | |NxtTab|PrvTab| | | | | | | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | | | | | | @@ -79,19 +79,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [SYMB] = KEYMAP( // left hand KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, - KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_TRNS, KC_TRNS, - KC_TRNS, KC_5, KC_6, KC_7, KC_8, KC_9, - KC_TRNS, KC_LPRN,KC_RPRN,KC_LBRC, KC_RBRC, KC_0, KC_TRNS, + KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_1, KC_2, KC_3, KC_4, KC_5, + KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,LCTL(KC_PGUP), LCTL(KC_PGDN), KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS,KC_TRNS, // right hand - KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, - KC_TRNS, KC_TRNS, KC_PERC,KC_EQL, KC_AT, KC_TRNS, KC_F12, - KC_AMPR, KC_UNDS,KC_MINS, CM_SCLN, KC_PLUS, KC_TRNS, - KC_TRNS, KC_PIPE, KC_LPRN,KC_RPRN, KC_3, KC_TRNS, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_F12, + KC_AMPR, KC_UNDS, KC_MINS, CM_SCLN, KC_PLUS, KC_TRNS, + KC_TRNS, KC_PIPE, KC_AT, KC_EQL, KC_PERC, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS @@ -101,13 +101,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ,--------------------------------------------------. ,--------------------------------------------------. * | | | | | | | | | | | | | | | | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| - * | | | | MsUp | | | | | | | | | | | | + * | | | | | | | | | | | | | | | | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| - * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * | | PgUp | Home | End | PgDn | |------| |------| | | | | | Play | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| * | | | | | | | | | | | | Prev | Next | | | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' - * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * | | | | | | |VolUp |VolDn | Mute | | | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | | | | | | @@ -120,10 +120,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // MEDIA AND MOUSE [MDIA] = KEYMAP( KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_PGUP, KC_HOME, KC_END, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -140,7 +140,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB), // FN1 - Momentary Layer 1 (Symbols) + [2] = ACTION_MACRO_TAP(0), // Eric Tang's Famous Macro! + [3] = ACTION_MACRO_TAP(1) // Eric Tang's Famous Macro! }; static uint16_t key_timer; @@ -148,33 +150,46 @@ static uint16_t key_timer; const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { switch(id) { - case 0: { - if (record->event.pressed) { - key_timer = timer_read(); // if the key is being pressed, we start the timer. - register_code(KC_LSFT); // we're now holding down Shift. - } else { // this means the key was just released, so we can figure out how long it was pressed for (tap or "held down"). - if (timer_elapsed(key_timer) < 70) { // the threshhold we pick for counting something as a tap. - register_code(KC_9); // sending 9 while Shift is held down gives us an opening paren - unregister_code(KC_9); // now let's let go of that key - } - unregister_code(KC_LSFT); // let's release the Shift key now. - } - break; + case 0: + if (record->event.pressed) { + register_mods(MOD_BIT(KC_LSFT)); + if (record->tap.count && !record->tap.interrupted) { + register_code(KC_9); + } + else { + record->tap.count = 0; + } + } + else { + if (record->tap.count) { + unregister_code(KC_9); + } + else { + } + unregister_mods(MOD_BIT(KC_LSFT)); + } + break; + + case 1: + if (record->event.pressed) { + register_mods(MOD_BIT(KC_LSFT)); + if (record->tap.count && !record->tap.interrupted) { + register_code(KC_0); + } + else { + record->tap.count = 0; + } + } + else { + if (record->tap.count) { + unregister_code(KC_0); + } + else { + } + unregister_mods(MOD_BIT(KC_LSFT)); + } + break; } - case 1: { - if (record->event.pressed) { - key_timer = timer_read(); // Now we're doing the same thing, only for the right shift/close paren key - register_code(KC_RSFT); - } else { - if (timer_elapsed(key_timer) < 70) { - register_code(KC_0); - unregister_code(KC_0); - } - unregister_code(KC_RSFT); - } - break; - } - } return MACRO_NONE; }; diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/makefile.mk b/keyboard/ergodox_ez/keymaps/erez_experimental/makefile.mk new file mode 100644 index 00000000000..4c3a314ed6d --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/erez_experimental/makefile.mk @@ -0,0 +1,5 @@ +# Having a file like this allows you to override Makefile definitions +# for your own particular keymap + +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend + diff --git a/keyboard/ergodox_ez/keymaps/erez_experimental/readme.md b/keyboard/ergodox_ez/keymaps/erez_experimental/readme.md index 82e1c5e4a0e..a9c572390ae 100644 --- a/keyboard/ergodox_ez/keymaps/erez_experimental/readme.md +++ b/keyboard/ergodox_ez/keymaps/erez_experimental/readme.md @@ -4,6 +4,23 @@ This is my personal layout which I use to test out ideas which may or may not ma Changelog: +## May 8, 2016: + +* Makes bottom-right key send minus/underscore when tapped, L1 temporary toggle when held +* Tweaked the positions of the numbers on the symbol layer. Basically, 12345 are now directly under their number-row counterparts in layer 0. You can imagine pulling the number row down to the home row. And 67890 are directly under 12345 - so it's a matter of just adding 5 and going to the next row (1+5 = 6, 2+5 = 7 and so on). +* Tweaks media/nav layer + * Removes mouse control, as I don't use it + * Makes left home row keys PgUp, Home, End, PgDn + +## Apr 29, 2016: + +* Tweaks the Hyper and Meh key to send brackets when tapped +* Turns bottom-right key into a minus/underscore (easy to reach with the right pinky) + +## Apr 25, 2016: + +* Made it so that the right and left Shift keys send opening and closing parens ( ) when tapped + ## Feb 11, 2016: * Updated ASCII legend for thumb clusters diff --git a/keyboard/ergodox_ez/keymaps/ordinary/keymap.c b/keyboard/ergodox_ez/keymaps/ordinary/keymap.c index efd67addd5c..18939b1923a 100644 --- a/keyboard/ergodox_ez/keymaps/ordinary/keymap.c +++ b/keyboard/ergodox_ez/keymaps/ordinary/keymap.c @@ -4,434 +4,421 @@ #include "action_layer.h" #include "action_util.h" -#define BASE 0 // default layer -#define LOCK 1 // shift-lock layer -#define SYMB_SH 2 // symbols shift layer -#define SYMB_LK 3 // symbols lock layer -#define SYMB_UN 4 // symbols unlock layer -#define MDIA_SH 5 // media shift layer -#define MDIA_LK 6 // media lock layer -#define MDIA_UN 7 // media unlock layer -#define UNLOCK 8 // clear to base layer +#define BASE 0 // default layer +#define SYMB 1 // symbols layer +#define MDIA 2 // media layer +#define SPEC 3 // special layer + +#define LCaps 10 // left caps-shift key +#define LSymb 11 // left symbol-shift key +#define LMdia 12 // left media-shift key +#define LSpec 13 // left special-shift key +#define RCaps 14 // right caps-shift key +#define RSymb 15 // right symbol-shift key +#define RMdia 16 // right media-shift key +#define RSpec 17 // right special-shift key + +#define MUL 20 // mouse up left +#define MUR 21 // mouse up right +#define MDL 22 // mouse down left +#define MDR 23 // mouse down right /* - * The Ordinary Layout for the Ergodox EZ keyboard, v3.1 - * modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com + * The Ordinary Layout for the Ergodox EZ keyboard, v4 + * + * Modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com + * + * No rights reserved. This software is in the public domain. + * Credit me if you are friendly but if you're a jerk don't bother. + * * Details: readme.md * https://github.com/nrrkeene/qmk_firmware/tree/master/keyboard/ergodox_ez/keymaps/ordinary */ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -/* Keymap 0: Base Layer +/******* Base Layer ******************************************************************************************************** * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | LOCK `~ | 1 | 2 | 3 | 4 | 5 | ESC | | - | 6 | 7 | 8 | 9 | 0 | = LOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | Media Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \ Media | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | Symbol | A | S | D | F | G |------| |------| H | J | K | L | ; | ' Symbol | - * |-----------+------+------+------+------+------|Shift | | Tab |------+------+------+------+------+-----------| - * | LShift | Z | X | C | V | B | -Tab | | | N | M | , | . | / | RShift | - * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' - * | LCtrl | Meh |Hyper | LAlt | LGui | | RGui | RAlt | Hyper| Meh | RCtrl | - * `-----------------------------------' `-----------------------------------' - * ,-------------. ,-------------. - * | Home | End | | Left | Right| - * ,------|------|------| |------+------+------. - * | | | PgUp | | Up | | | - * |Backsp| Del |------| |------| Enter| Space| - * | | | PgDn | | Down | | | - * `--------------------' `--------------------' + * ,------------------------------------------------------. ,------------------------------------------------------. + * | Special `~ | 1 | 2 | 3 | 4 | 5 | ESC | | - | 6 | 7 | 8 | 9 | 0 | =+ Special | + * |------------+------+------+------+------+-------------| |------+------+------+------+------+------+------------| + * | Media Tab | Q | W | E | R | T | [ | | ] | Y | U | I | O | P | \| Media | + * |------------+------+------+------+------+------| | | |------+------+------+------+------+------------| + * | Symbol | A | S | D | F | G |------| |------| H | J | K | L | ; | '" Symbol | + * |------------+------+------+------+------+------|Shift | | Tab |------+------+------+------+------+------------| + * | Capitals | Z | X | C | V | B | -Tab | | | N | M | , | . | / | Capitals | + * `------------+------+------+------+------+-------------' `-------------+------+------+------+------+------------' + * | LCtrl | Meh |Hyper | LAlt | LGui | | RGui | RAlt | Hyper| Meh | RCtrl | + * `-----------------------------------' `-----------------------------------' + * ,-------------. ,-------------. + * | Home | End | | Left | Right| + * ,------|------|------| |------+------+------. + * | | | PgUp | | Up | | | + * |Backsp| Del |------| |------| Enter| Space| + * | | | PgDn | | Down | | | + * `--------------------' `--------------------' */ [BASE] = KEYMAP( // left hand - LT(LOCK, KC_GRV) ,KC_1 ,KC_2 ,KC_3 ,KC_4 ,KC_5 ,KC_ESC -,LT(MDIA_SH, KC_TAB),KC_Q ,KC_W ,KC_E ,KC_R ,KC_T ,KC_LBRC -,MO(SYMB_SH) ,KC_A ,KC_S ,KC_D ,KC_F ,KC_G -,KC_LSFT ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,LSFT(KC_TAB) -,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI - - ,KC_HOME,KC_END - ,KC_PGUP - ,KC_BSPC,KC_DEL ,KC_PGDN - - // right hand - ,KC_MINS ,KC_6 ,KC_7 ,KC_8 ,KC_9 ,KC_0 ,LT(LOCK, KC_EQL) - ,KC_RBRC ,KC_Y ,KC_U ,KC_I ,KC_O ,KC_P ,LT(MDIA_SH, KC_BSLS) - ,KC_H ,KC_J ,KC_K ,KC_L ,KC_SCLN ,LT(SYMB_SH, KC_QUOT) - ,KC_TAB ,KC_N ,KC_M ,KC_COMM,KC_DOT ,KC_SLSH ,KC_RSFT - ,KC_RGUI,KC_RALT,ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL - - ,KC_LEFT ,KC_RGHT - ,KC_UP - ,KC_DOWN ,KC_ENT ,KC_SPC + F(LSpec),KC_1,KC_2,KC_3 ,KC_4 ,KC_5 ,KC_ESC +,F(LMdia) ,KC_Q ,KC_W ,KC_E ,KC_R ,KC_T ,KC_LBRC +,M(LSymb) ,KC_A ,KC_S ,KC_D ,KC_F ,KC_G +,M(LCaps) ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,LSFT(KC_TAB) +,KC_LCTL ,KC_MEH ,KC_HYPR,KC_LALT,KC_LGUI + ,KC_HOME,KC_END + ,KC_PGUP + ,KC_BSPC,KC_DEL ,KC_PGDN + // right hand + ,KC_MINS ,KC_6 ,KC_7 ,KC_8 ,KC_9 ,KC_0 ,F(RSpec) + ,KC_RBRC ,KC_Y ,KC_U ,KC_I ,KC_O ,KC_P ,F(RMdia) + ,KC_H ,KC_J ,KC_K ,KC_L ,KC_SCLN ,F(RSymb) + ,KC_TAB ,KC_N ,KC_M ,KC_COMM,KC_DOT ,KC_SLSH ,M(RCaps) + ,KC_RGUI,KC_RALT,KC_HYPR ,KC_MEH ,KC_RCTL + ,KC_LEFT ,KC_RGHT + ,KC_UP + ,KC_DOWN ,KC_ENT ,KC_SPC ), -/* Keymap 1: Layer Lock Keys +/******* Symbols Layer ***************************************************************************************************** * - * ,-------------------------------------------------------. ,-------------------------------------------------------. - * | | Esc | | | | | | | | | | | | Bspc | | - * |-------------+------+------+------+------+-------------| |------+------+------+------+------+------+-------------| - * | Media LOCK | | | | | | | | | | | | | | Media LOCK | - * |-------------+------+------+------+------+------| | | |------+------+------+------+------+-------------| - * | Symbol LOCK | | | | | |------| |------| | | | | | Symbol LOCK | - * |-------------+------+------+------+------+------| | | |------+------+------+------+------+-------------| - * | Caps LOCK | | | | | | | | | | | | | | Caps LOCK | - * `-------------+------+------+------+------+-------------' `-------------+------+------+------+------+-------------' - * | | | | | | | | | | | | - * `------------------------------------' `------------------------------------' - * ,-------------. ,-------------. - * | | | | | | - * ,------|------|------| |------+------+------. - * | | | | | | | | - * | | |------| |------| | | - * | | | | | | | | - * `--------------------' `--------------------' + * ,-----------------------------------------------------. ,-----------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | Esc | | - | F6 | F7 | F8 | F9 | F10 | | + * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| + * | | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | | + * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| + * | | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | | + * |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------| + * | | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | | + * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' + * | LCtrl | Meh |Hyper | LAlt | LGui | |RGui/0|RAlt/.|Hypr/=|Meh/+ |RCtrl/Ent| + * `-----------------------------------' `-------------------------------------' + * ,-------------. ,-------------. + * | Left | Right| | Home | End | + * ,------|------|------| |------+------+------. + * | | | Up | | PgUp | | | + * |Space |Enter |------| |------|BackSp| Del | + * | | | Down | | PgDn | | | + * `--------------------' `--------------------' */ -[LOCK] = KEYMAP( +[SYMB] = KEYMAP( +// left hand + KC_TRNS ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_ESC +,KC_TRNS ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM) +,KC_TRNS ,KC_HASH ,KC_DLR ,KC_LPRN ,KC_RPRN ,KC_GRV +,KC_TRNS ,KC_PERC ,KC_CIRC ,KC_LBRC ,KC_RBRC ,KC_TILD ,KC_TAB +,KC_LCTL ,KC_MEH ,KC_HYPR,KC_LALT ,KC_LGUI + ,KC_LEFT ,KC_RGHT + ,KC_UP + ,KC_SPC ,KC_ENT ,KC_DOWN + // right hand + ,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_TRNS + ,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,KC_TRNS + ,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,KC_TRNS + ,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_TRNS + ,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT) + ,KC_HOME ,KC_END + ,KC_PGUP + ,KC_PGDN ,KC_BSPC ,KC_DEL +), + +/******* Media Layer ******************************************************************************************************* + * + * ,---------------------------------------------------------------. ,---------------------------------------------------------------. + * | | F11 | F12 | F13 | F14 | F15 | Esc | | | F16 | F17 | F18 | F19 | F20 | | + * |------+---------+---------+---------+---------+----------------| |------+---------+---------+---------+---------+---------+------| + * | |Shut Down|MouseUpLf|Mouse Up |MouseUpRg|Volume Up|Scroll| |Scroll|PrintScrn| Home | Up | PgUp | Mail | | + * |------+---------+---------+---------+---------+---------| Up | | Up |---------+---------+---------+---------+---------+------| + * | | Sleep |MouseLeft|MouseDown|MouseRght|Volume Dn|------| |------| Num Lock| Left | Down | Right | MyComp | | + * |------+---------+---------+---------+---------+---------|Scroll| |Scroll|---------+---------+---------+---------+---------+------| + * | | |MouseDnLf|MouseDown|MouseDnRg| Mute | Down | | Down | | End | Down | PgDn | | | + * `------+---------+---------+---------+---------+----------------' `----------------+---------+---------+---------+---------+------' + * |LCtrl| Meh | MClick | LClick | R Click| |Cmd/Insrt|Optn/Del | Hyper | Meh |RCtrl| + * `---------------------------------------------' `---------------------------------------------' + * ,-------------. ,-------------. + * | Stop |Refrsh| | Prev | Next | + * ,------|------|------| |------+------+------. + * |Brwser|Brwser|Search| |VolUp | | | + * |Back | Fwd |------| |------| Stop | Play-| + * | | | Home | |VolDn | | Pause| + * `--------------------' `--------------------' + */ +[MDIA] = KEYMAP( +// left hand + KC_TRNS ,KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_ESC +,KC_TRNS ,KC_POWER ,M(MUL) ,KC_MS_U ,M(MUR) ,KC_VOLU ,KC_WH_U +,KC_TRNS ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD +,KC_TRNS ,KC_NO ,M(MDL) ,KC_MS_D ,M(MDR) ,KC_MUTE ,KC_WH_D +,KC_LCTL ,KC_MEH ,KC_BTN3 ,KC_BTN1 ,KC_BTN2 + ,KC_WSTP ,KC_WREF + ,KC_WSCH + ,KC_WBAK ,KC_NO ,KC_WHOM + // right hand + ,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,KC_TRNS + ,KC_WH_U ,KC_PSCR ,KC_HOME ,KC_UP ,KC_PGUP ,KC_MAIL ,KC_TRNS + ,KC_NLCK ,KC_LEFT ,KC_DOWN ,KC_RIGHT,KC_MYCM ,KC_TRNS + ,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_TRNS + ,GUI_T(KC_INS),ALT_T(KC_DEL),KC_HYPR ,KC_MEH ,KC_RCTL + ,KC_MPRV ,KC_MNXT + ,KC_VOLU + ,KC_VOLD ,KC_MSTP ,KC_MPLY +), + +/******* Special Layer ***************************************************************************************************** + * + * ,-----------------------------------------------------. ,-----------------------------------------------------. + * | | Esc | | | | | | | | | | | | Bspc | | + * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| + * | | | | | | | | | | | | | | | | + * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| + * | | | | | | |------| |------| | | | | | | + * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| + * | | | | | | | | | | | | | | | RShift | + * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +[SPEC] = KEYMAP( // left hand KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_FN3 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_FN2 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_CAPS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS +,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS +,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS +,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS,KC_TRNS ,KC_TRNS - - // right hand - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN3 - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN2 - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_CAPS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS - ), - -/* Keymap 2: Symbol Shift Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | LOCK | F1 | F2 | F3 | F4 | F5 | | | - | F6 | F7 | F8 | F9 | F10 | LOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | Media | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | Media | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | Symbol | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | Symbol | - * |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------| - * | LShift | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | RShift | - * `-----------+------+------+------+------+-------------' `------------+------+------+------+------+------------' - * | | | | | | | 0 | . | = | + | Entr | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | Left | Right| | Home | End | - * ,------|------|------| |------+------+------. - * | | | Up | | PgUp | | | - * |Space |Enter |------| |------|BackSp| Del | - * | | | Down | | PgDn | | | - * `--------------------' `--------------------' - */ -[SYMB_SH] = KEYMAP( -// left hand - KC_FN2 ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_TRNS -,MO(MDIA_SH) ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM) -,MO(SYMB_SH) ,KC_HASH ,KC_DLR ,KC_LPRN ,KC_RPRN ,KC_GRV -,KC_LSFT ,KC_PERC ,KC_CIRC ,KC_LBRC ,KC_RBRC ,KC_TILD ,KC_TAB -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_LEFT ,KC_RGHT - ,KC_UP - ,KC_SPC ,KC_ENT ,KC_DOWN - // right hand - ,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_FN2 - ,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,MO(MDIA_SH) - ,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,MO(SYMB_SH) - ,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_RSFT - ,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT) - ,KC_HOME ,KC_END - ,KC_PGUP - ,KC_PGDN ,KC_BSPC ,KC_DEL -), - -/* Keymap 3: Symbol Lock Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | LOCK | F1 | F2 | F3 | F4 | F5 | | | - | F6 | F7 | F8 | F9 | F10 | LOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | Media | ! | @ | { | } | & | < | | > | | | 7 | 8 | 9 | / | Media | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | Symbol | # | $ | ( | ) | ` |------| |------| / | 4 | 5 | 6 | * | Symbol | - * |-----------+------+------+------+------+------| Tab | | Shift|------+------+------+------+------+-----------| - * | LShift | % | ^ | [ | ] | ~ | | | -Tab| \ | 1 | 2 | 3 | - | RShift | - * `-----------+------+------+------+------+-------------' `------------+------+------+------+------+------------' - * | | | | | | | 0 | . | = | + | Entr | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | Left | Right| | Home | End | - * ,------|------|------| |------+------+------. - * | | | Up | | PgUp | | | - * |Space |Enter |------| |------|BackSp| Del | - * | | | Down | | PgDn | | | - * `--------------------' `--------------------' - */ -[SYMB_LK] = KEYMAP( -// left hand - MO(SYMB_UN) ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 ,KC_TRNS -,MO(MDIA_SH) ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_AMPR ,LSFT(KC_COMM) -,MO(UNLOCK) ,KC_HASH ,KC_DLR ,KC_LPRN ,KC_RPRN ,KC_GRV -,KC_LSFT ,KC_PERC ,KC_CIRC ,KC_LBRC ,KC_RBRC ,KC_TILD ,KC_TAB -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_LEFT ,KC_RGHT - ,KC_UP - ,KC_SPC ,KC_ENT ,KC_DOWN - // right hand - ,KC_MINS ,KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,MO(SYMB_UN) - ,LSFT(KC_DOT),KC_PIPE ,KC_7 ,KC_8 ,KC_9 ,KC_SLSH ,MO(MDIA_SH) - ,KC_SLSH ,KC_4 ,KC_5 ,KC_6 ,KC_ASTR ,MO(UNLOCK) - ,LSFT(KC_TAB),KC_BSLS ,KC_1 ,KC_2 ,KC_3 ,KC_MINS ,KC_RSFT - ,GUI_T(KC_0),ALT_T(KC_DOT),ALL_T(KC_EQL),MEH_T(KC_PLUS),CTL_T(KC_ENT) - ,KC_HOME ,KC_END - ,KC_PGUP - ,KC_PGDN ,KC_BSPC ,KC_DEL - ), - -/* Keymap 4: Symbol Unlock Layer - * - * ,------------------------------------------------------. ,------------------------------------------------------. - * | | Esc | | | | | | | | | | | | Bspc | | - * |------------+------+------+------+------+-------------| |------+------+------+------+------+------+------------| - * | Media LOCK | | | | | | | | | | | | | | Media LOCK | - * |------------+------+------+------+------+------| | | |------+------+------+------+------+------------| - * | UNLOCK | | | | | |------| |------| | | | | | UNLOCK | - * |------------+------+------+------+------+------| | | |------+------+------+------+------+------------| - * | Caps LOCK | | | | | | | | | | | | | | Caps LOCK | - * `------------+------+------+------+------+-------------' `-------------+------+------+------+------+------------' - * | | | | | | | | | | | | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | | | | | | - * ,------|------|------| |------+------+------. - * | | | | | | | | - * | | |------| |------| | | - * | | | | | | | | - * `--------------------' `--------------------' - */ -[SYMB_UN] = KEYMAP( -// left hand - KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,TG(MDIA_LK) ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_FN1 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_CAPS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS,KC_TRNS ,KC_TRNS // right hand ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,TG(MDIA_LK) - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1 - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_CAPS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS + ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS + ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS + ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_RSFT + ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS + ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -), - -/* Keymap 5: Media Shift Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | LOCK | F11 | F12 | F13 | F14 | F15 | | | | F16 | F17 | F18 | F19 | F20 | LOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | Media |ShutDn|LClick| MsUp |RClick|Vol Up|ScrlUp| |ScrlUp|PrtScr| Home | Up | PgUp | Mail | Media | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | Symbol | Sleep|MsLeft|MsDown|MsRght|Vol Dn|------| |------|NumLok| Left | Down | Right|MyComp| Symbol | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | LShift | | |MsDown| | Mute |ScrlDn| |ScrlDn| | End | Down | PgDn | | RShift | - * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' - * | LCtrl| Meh |Hyper | LAlt | LGui | |Insert|Delete| Hyper| LAlt | LGui | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | Stop |Refrsh| | Prev | Next | - * ,------|------|------| |------+------+------. - * |Brwser|Brwser|Search| |VolUp | | | - * |Back | Fwd |------| |------| Stop | Play-| - * | | | Home | |VolDn | | Pause| - * `--------------------' `--------------------' - */ -[MDIA_SH] = KEYMAP( -// left hand - KC_FN3 ,KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_NO -,MO(MDIA_SH) ,KC_POWER ,KC_BTN1 ,KC_MS_U ,KC_BTN2 ,KC_VOLU ,KC_WH_U -,MO(SYMB_SH) ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD -,KC_LSFT ,KC_NO ,KC_NO ,KC_MS_D ,KC_NO ,KC_MUTE ,KC_WH_D -,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI - ,KC_WSTP ,KC_WREF - ,KC_WSCH - ,KC_WBAK ,KC_NO ,KC_WHOM - // right hand - ,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,KC_FN3 - ,KC_WH_U ,KC_PSCR ,KC_HOME,KC_UP ,KC_PGUP ,KC_MAIL ,MO(MDIA_SH) - ,KC_NLCK ,KC_LEFT,KC_DOWN ,KC_RIGHT,KC_MYCM ,MO(SYMB_SH) - ,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_RSFT - ,GUI_T(KC_INS),ALT_T(KC_DEL),ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL - ,KC_MPRV ,KC_MNXT - ,KC_VOLU - ,KC_VOLD ,KC_MSTP ,KC_MPLY -), - -/* Keymap 6: Media Lock Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | LOCK | F11 | F12 | F13 | F14 | F15 | | | | F16 | F17 | F18 | F19 | F20 | LOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | Media |ShutDn|LClick| MsUp |RClick|Vol Up|ScrlUp| |ScrlUp|PrtScr| Home | Up | PgUp | Mail | Media | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | | Sleep|MsLeft|MsDown|MsRght|Vol Dn|------| |------|NumLok| Left | Down | Right|MyComp| | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | LShift | | |MsDown| | Mute |ScrlDn| |ScrlDn| | End | Down | PgDn | | RShift | - * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' - * | LCtrl| Meh |Hyper | LAlt | LGui | |Insert|Delete| Hyper| LAlt | LGui | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | Stop |Refrsh| | Prev | Next | - * ,------|------|------| |------+------+------. - * |Brwser|Brwser|Search| |VolUp | | | - * |Back | Fwd |------| |------| Stop | Play-| - * | | | Home | |VolDn | | Pause| - * `--------------------' `--------------------' - */ -[MDIA_LK] = KEYMAP( -// left hand - MO(MDIA_UN),KC_F11 ,KC_F12 ,KC_F13 ,KC_F14 ,KC_F15 ,KC_NO -,MO(UNLOCK) ,KC_POWER ,KC_BTN1 ,KC_MS_U ,KC_BTN2 ,KC_VOLU ,KC_WH_U -,KC_NO ,KC_SLEP ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_VOLD -,KC_LSFT ,KC_NO ,KC_NO ,KC_MS_D ,KC_NO ,KC_MUTE ,KC_WH_D -,KC_LCTL ,MEH_T(KC_NO),ALL_T(KC_NO),KC_LALT,KC_LGUI - ,KC_WSTP ,KC_WREF - ,KC_WSCH - ,KC_WBAK ,KC_NO ,KC_WHOM - // right hand - ,KC_NO ,KC_F16 ,KC_F17 ,KC_F18 ,KC_F19 ,KC_F20 ,MO(MDIA_UN) - ,KC_WH_U ,KC_PSCR ,KC_HOME,KC_UP ,KC_PGUP ,KC_MAIL ,MO(UNLOCK) - ,KC_NLCK ,KC_LEFT,KC_DOWN ,KC_RIGHT,KC_MYCM ,KC_NO - ,KC_WH_D ,KC_NO ,KC_END ,KC_DOWN ,KC_PGDN ,KC_NO ,KC_RSFT - ,GUI_T(KC_INS),ALT_T(KC_DEL),ALL_T(KC_NO),MEH_T(KC_NO),KC_RCTL - ,KC_MPRV ,KC_MNXT - ,KC_VOLU - ,KC_VOLD ,KC_MSTP ,KC_MPLY - ), - -/* Keymap 7: Media Unlock Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | | Esc | | | | | | | | | | | | Bspc | | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | UNLOCK | | | | | | | | | | | | | | UNLOCK | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | | | | | | |------| |------| | | | | | | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | Caps LOCK | | | | | | | | | | | | | | Caps LOCK | - * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' - * | | | | | | | | | | | | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | | | | | | - * ,------|------|------| |------+------+------. - * | | | | | | | | - * | | |------| |------| | | - * | | | | | | | | - * `--------------------' `--------------------' - */ -[MDIA_UN] = KEYMAP( -// left hand - KC_TRNS ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_FN1 ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_CAPS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS - - // right hand - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_BSPC ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1 - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_CAPS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS - ), - -/* Keymap 8: Unlock Layer - * - * ,-----------------------------------------------------. ,-----------------------------------------------------. - * | UNLOCK | | | | | | | | | | | | | | UNLOCK | - * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| - * | | | | | | | | | | | | | | | | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | | | | | | |------| |------| | | | | | | - * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| - * | | | | | | | | | | | | | | | | - * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' - * | | | | | | | | | | | | - * `----------------------------------' `----------------------------------' - * ,-------------. ,-------------. - * | | | | | | - * ,------|------|------| |------+------+------. - * | | | | | | | | - * | | |------| |------| | | - * | | | | | | | | - * `--------------------' `--------------------' - */ -[UNLOCK] = KEYMAP( -// left hand - KC_FN1 ,KC_ESC ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS -,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS - - // right hand - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_FN1 - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS ,KC_TRNS - - ,KC_TRNS ,KC_TRNS - ,KC_TRNS - ,KC_TRNS ,KC_TRNS ,KC_TRNS ) }; const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_CLEAR(ON_PRESS) // FN1 - clear to base layer - ,[2] = ACTION_LAYER_INVERT(SYMB_LK, ON_PRESS) // FN2 - toggle to Symbols on press - ,[3] = ACTION_LAYER_INVERT(MDIA_LK, ON_PRESS) // FN3 - toggle to Media on press + // the faux shift keys are implemented as macro taps + [LCaps] = ACTION_MACRO_TAP(LCaps) + ,[LSymb] = ACTION_MACRO_TAP(LSymb) + ,[LMdia] = ACTION_MACRO_TAP(LMdia) + ,[LSpec] = ACTION_MACRO_TAP(LSpec) + ,[RCaps] = ACTION_MACRO_TAP(RCaps) + ,[RSymb] = ACTION_MACRO_TAP(RSymb) + ,[RMdia] = ACTION_MACRO_TAP(RMdia) + ,[RSpec] = ACTION_MACRO_TAP(RSpec) }; +uint16_t caps_shift = 0; +uint16_t symb_shift = 0; +uint16_t mdia_shift = 0; + +bool symb_lock = false; +bool mdia_lock = false; + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { - // MACRODOWN only works in this function - switch(id) { - case 0: - if (record->event.pressed) { - register_code(KC_RSFT); + switch(id) { + // There are two shift keys for each layer so we increment a layer_shift var when one + // is pressed and decrement when one is released. If both are pressed at the same time + // then the layer is locked (or unlocked). The shift counts are bound between 0 and 2 + // only because sometimes rapid pressing led to irregular events; this way the states + // are self healing during use. + + case LCaps: // both caps-shift keys trigger Left Shift + case RCaps: // so they don't interfere with the magic combo + if (record->event.pressed && !record->tap.count) { + if(++caps_shift > 2) caps_shift = 2; + if(caps_shift == 2) { + register_code(KC_CAPS); + unregister_code(KC_CAPS); + } else if(caps_shift == 1) { + register_code(KC_LSFT); + } } else { - unregister_code(KC_RSFT); + if(--caps_shift < 0) caps_shift = 0; + if(caps_shift == 0) unregister_code(KC_LSFT); } break; - } + + case LSymb: + if (record->event.pressed) { + if(++symb_shift > 2) symb_shift = 2; + if(symb_shift == 2) { + symb_lock = !symb_lock; + } else if(symb_shift == 1) { + layer_on(SYMB); + } + } else { + if(--symb_shift < 0) symb_shift = 0; + if((symb_shift == 0) && (!symb_lock)) layer_off(SYMB); + } + break; + + case LMdia: + if (record->event.pressed) { + if (record->tap.count && (!mdia_shift) && (!mdia_lock)) { + register_code(KC_TAB); + } else { + if(++mdia_shift > 2) mdia_shift = 2; + if(mdia_shift == 2) { + mdia_lock = !mdia_lock; + } else if(mdia_shift == 1) { + layer_on(MDIA); + } + } + } else { + if(record->tap.count && (!mdia_shift) && (!mdia_lock)) { + unregister_code(KC_TAB); + } else { + if(--mdia_shift < 0) mdia_shift = 0; + if((!mdia_shift) && (!mdia_lock)) layer_off(MDIA); + } + } + break; + + case LSpec: + if (record->event.pressed) { + if (record->tap.count && !record->tap.interrupted) { + register_code(KC_GRV); + } else { + layer_on(SPEC); + } + } else { + if(record->tap.count && !record->tap.interrupted) { + unregister_code(KC_GRV); + } else { + layer_off(SPEC); + } + } + break; + + case RSymb: + if (record->event.pressed) { + if (record->tap.count && (!symb_shift) && (!symb_lock)) { + register_code(KC_QUOT); + } else { + if(++symb_shift > 2) symb_shift = 2; + if(symb_shift == 2) { + symb_lock = !symb_lock; + } else if(symb_shift == 1) { + layer_on(SYMB); + } + } + } else { + if(record->tap.count && symb_shift == 0) { + unregister_code(KC_QUOT); + } else { + if(--symb_shift < 0) symb_shift = 0; + if((!symb_shift) && (!symb_lock)) layer_off(SYMB); + } + } + break; + + case RMdia: + if (record->event.pressed) { + if (record->tap.count && (!mdia_shift) && (!mdia_lock)) { + register_code(KC_BSLS); + } else { + if(++mdia_shift > 2) mdia_shift = 2; + if(mdia_shift == 2) { + mdia_lock = !mdia_lock; + } else if(mdia_shift == 1) { + layer_on(MDIA); + } + } + } else { + if(record->tap.count && (!mdia_shift) && (!mdia_lock)) { + unregister_code(KC_BSLS); + } else { + if(--mdia_shift < 0) mdia_shift = 0; + if((!mdia_shift) && (!mdia_lock)) layer_off(MDIA); + } + } + break; + + case RSpec: + if (record->event.pressed) { + if (record->tap.count && !record->tap.interrupted) { + register_code(KC_EQL); + } else { + layer_on(SPEC); + } + } else { + if(record->tap.count && !record->tap.interrupted) { + unregister_code(KC_EQL); + } else { + layer_off(SPEC); + } + } + break; + + // mouse diagonals + + case MUL: // mouse up left + if (record->event.pressed) { + mousekey_on(KC_MS_UP); + mousekey_on(KC_MS_LEFT); + mousekey_send(); + } else { + mousekey_off(KC_MS_UP); + mousekey_off(KC_MS_LEFT); + mousekey_send(); + } + break; + + case MUR: // mouse up right + if (record->event.pressed) { + mousekey_on(KC_MS_UP); + mousekey_on(KC_MS_RIGHT); + mousekey_send(); + } else { + mousekey_off(KC_MS_UP); + mousekey_off(KC_MS_RIGHT); + mousekey_send(); + } + break; + + case MDL: // mouse down left + if (record->event.pressed) { + mousekey_on(KC_MS_DOWN); + mousekey_on(KC_MS_LEFT); + mousekey_send(); + } else { + mousekey_off(KC_MS_DOWN); + mousekey_off(KC_MS_LEFT); + mousekey_send(); + } + break; + + case MDR: // mouse down right + if (record->event.pressed) { + mousekey_on(KC_MS_DOWN); + mousekey_on(KC_MS_RIGHT); + mousekey_send(); + } else { + mousekey_off(KC_MS_DOWN); + mousekey_off(KC_MS_RIGHT); + mousekey_send(); + } + break; + + default: + // none + break; + } + return MACRO_NONE; }; @@ -442,31 +429,22 @@ void matrix_init_user(void) { // Runs constantly in the background, in a loop. void matrix_scan_user(void) { - uint8_t layer = biton32(layer_state); - // shift or caps lock turns on red light - if((keyboard_report->mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT))) || (host_keyboard_leds() & (1<mods & MOD_BIT(KC_RSFT)) || (host_keyboard_leds() & (1<\n."], [{y:-0.875,x:5.5},"B",{x:6.5},"N"], -[{y:-0.875,c:"#2277ff",fa:[0,1,0,1,0,0,0],w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#cccccc"},"Z",{x:14.5,f:3},"?\n/",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"], +[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#cccccc"},"Z",{x:14.5},"?\n/",{c:"#2277ff",w:1.5},"\n\nCapitals\n\n\n\n\nShift"], [{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5},"Option\n\n\nRAlt"], [{y:-0.875,x:2.5},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5},"Cmd\n\n\nSuper",{x:1},"Hyper"], [{y:-0.75,x:0.5},"Ctrl\n\n\nLCtrl","Meh",{x:14.5},"Meh","Ctrl\n\n\nRCtrl"], diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.png b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.png index 0ae162431d3..99e5ed80b14 100644 Binary files a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.png and b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.png differ diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.txt b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.txt index cc4c877ebdc..4eccc9f350e 100644 --- a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.txt +++ b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-media.txt @@ -1,22 +1,22 @@ [{x:3.5,c:"#99de2a"},"F13",{x:10.5},"F18"], [{y:-0.875,x:2.5},"F12",{x:1},"F14",{x:8.5},"F17",{x:1},"F19"], -[{y:-0.875,x:5.5},"F15",{c:"#ff4444"},"Esc",{x:4.5,c:"#cccccc",a:7},"",{c:"#99de2a",a:4},"F16"], -[{y:-0.875,c:"#2277ff",w:1.5},"Shift\n\n\n\n\n\nLock",{c:"#99de2a"},"F11",{x:14.5},"F20",{c:"#2277ff",w:1.5},"\n\nShift\n\n\n\n\nLock"], +[{y:-0.875,x:5.5},"F15",{c:"#ff4444"},"Esc",{x:4.5,c:"#737373",a:7},"",{c:"#99de2a",a:4},"F16"], +[{y:-0.875,c:"#2277ff",w:1.5},"Special\n\n\n\n\n\nShift",{c:"#99de2a"},"F11",{x:14.5},"F20",{c:"#2277ff",w:1.5},"\n\nSpecial\n\n\n\n\nShift"], [{y:-0.375,x:3.5,c:"#ff8500"},"Mouse\n\n\n\n\n\nUp",{x:10.5},"Cursor\n\n\n\n\n\nUp"], -[{y:-0.875,x:2.5},"Left\n\n\n\n\n\nClick",{x:1},"Right\n\n\n\n\n\nClick",{x:8.5,c:"#ffb063"},"Home",{x:1},"Page\n\n\n\n\n\nUp"], +[{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nUpLeft",{x:1},"Mouse\n\n\n\n\n\nUpRgt",{x:8.5,c:"#ffb063"},"Home",{x:1},"Page\n\n\n\n\n\nUp"], [{y:-0.875,x:5.5,c:"#e6e067"},"Vol\n\n\n\n\n\nUp",{c:"#ffb063",h:1.5},"Scroll\n\n\n\n\n\nUp",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nUp",{c:"#e6e067"},"Print\n\n\n\n\n\nScreen"], [{y:-0.875,c:"#000000",t:"#ff0000",w:1.5},"Media\n\n\n\n\n\nShift",{c:"#e6e067",t:"#000000"},"Shut\n\n\n\n\n\nDown",{x:14.5},"Mail",{c:"#000000",t:"#ff0000",w:1.5},"\n\nMedia\n\n\n\n\nShift"], [{y:-0.375,x:3.5,c:"#ff8500",t:"#000000"},"Mouse\n\n\n\n\n\nDown",{x:10.5},"Cursor\n\n\n\n\n\nDown"], [{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nLeft",{x:1},"Mouse\n\n\n\n\n\nRight",{x:8.5},"Cursor\n\n\n\n\n\nLeft",{x:1},"Cursor\n\n\n\n\n\nRight"], [{y:-0.875,x:5.5,c:"#e6e067"},"Vol\n\n\n\n\n\nDown",{x:6.5},"Num\n\n\n\n\n\nLock"], -[{y:-0.875,c:"#cccccc",a:7,w:1.5},"",{c:"#e6e067",a:4},"Sleep",{x:14.5},"My\n\n\n\n\n\nComp",{c:"#cccccc",a:7,w:1.5},""], -[{y:-0.625,x:6.5,c:"#ffb063",a:4,h:1.5},"Scroll\n\n\n\n\n\nDown",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nDown"], +[{y:-0.875,c:"#2277ff",w:1.5},"Symbols\n\n\n\n\n\nShift",{c:"#e6e067"},"Sleep",{x:14.5},"My\n\n\n\n\n\nComp",{c:"#2277ff",w:1.5},"\n\nSymbols\n\n\n\n\nShift"], +[{y:-0.625,x:6.5,c:"#ffb063",h:1.5},"Scroll\n\n\n\n\n\nDown",{x:4.5,h:1.5},"Scroll\n\n\n\n\n\nDown"], [{y:-0.75,x:3.5,c:"#ff8500"},"Mouse\n\n\n\n\n\nDown",{x:10.5},"Cursor\n\n\n\n\n\nDown"], -[{y:-0.875,x:2.5,c:"#cccccc",a:7},"",{x:1},"",{x:8.5,c:"#ffb063",a:4},"End",{x:1},"Page\n\n\n\n\n\nDown"], -[{y:-0.875,x:5.5,c:"#e6e067"},"Mute",{x:6.5,c:"#cccccc",a:7},""], -[{y:-0.875,c:"#2277ff",a:4,f2:1,w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#cccccc",a:7},"",{x:14.5},"",{c:"#2277ff",a:4,fa:[0,1,0,1],w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"], -[{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5,c:"#ffb063"},"Delete\n\n\nOption"], -[{y:-0.875,x:2.5,c:"#77aaff"},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5,c:"#ffb063"},"Insert\n\n\nCmd",{x:1,c:"#77aaff"},"Hyper"], +[{y:-0.875,x:2.5},"Mouse\n\n\n\n\n\nDnLeft",{x:1},"Mouse\n\n\n\n\n\nDnRgt",{x:8.5,c:"#ffb063"},"End",{x:1},"Page\n\n\n\n\n\nDown"], +[{y:-0.875,x:5.5,c:"#e6e067"},"Mute",{x:6.5,c:"#737373",a:7},""], +[{y:-0.875,c:"#2277ff",a:4,w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#737373",a:7},"",{x:14.5},"",{c:"#2277ff",a:4,w:1.5},"\n\nCapitals\n\n\n\n\nShift"], +[{y:-0.375,x:3.5,c:"#ff8500"},"Middle\n\n\n\n\n\nClick",{x:10.5,c:"#ffb063",fa:[0,0,0,1]},"Delete\n\n\nOption"], +[{y:-0.875,x:2.5,c:"#ff8500"},"Left\n\n\n\n\n\nClick",{x:1},"Right\n\n\n\n\n\nClick",{x:8.5,c:"#ffb063"},"Insert\n\n\nCmd",{x:1,c:"#77aaff"},"Hyper"], [{y:-0.75,x:0.5},"Ctrl\n\n\nLCtrl","Meh",{x:14.5},"Meh","Crtl\n\n\nRCtrl"], [{r:30,rx:6.5,ry:4.25,y:-1,x:1,c:"#ccbb00"},"Stop\n\n\nBrowser","Reload\n\n\nBrowser"], [{h:2},"< Web\n\n\nBrowser",{h:2},"Web >\n\n\nBrowser","Search\n\n\nBrowser"], diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.png b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.png new file mode 100644 index 00000000000..6eecf447ee4 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.png differ diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.txt b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.txt new file mode 100644 index 00000000000..a08827c6de9 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-special.txt @@ -0,0 +1,27 @@ +[{x:3.5,a:7},"",{x:10.5},""], +[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""], +[{y:-0.875,x:5.5},"",{c:"#ff4444",a:4},"Esc",{x:4.5,c:"#cccccc",a:7},"",""], +[{y:-0.875,c:"#000000",t:"#ff0000",a:4,w:1.5},"Special\n\n\n\n\n\nShift",{c:"#ff4444",t:"#000000"},"Esc",{x:14.5,c:"#54d6de"},"Back\n\n\n\n\n\nspace",{c:"#000000",t:"#ff0000",w:1.5},"\n\nSpecial\n\n\n\n\nShift"], +[{y:-0.375,x:3.5,c:"#cccccc",t:"#000000",a:7},"",{x:10.5},""], +[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""], +[{y:-0.875,x:5.5},"",{h:1.5},"",{x:4.5,h:1.5},"",""], +[{y:-0.875,w:1.5},"","",{x:14.5},"",{w:1.5},""], +[{y:-0.375,x:3.5},"",{x:10.5},""], +[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""], +[{y:-0.875,x:5.5},"",{x:6.5},""], +[{y:-0.875,w:1.5},"","",{x:14.5},"",{w:1.5},""], +[{y:-0.625,x:6.5,h:1.5},"",{x:4.5,h:1.5},""], +[{y:-0.75,x:3.5},"",{x:10.5},""], +[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""], +[{y:-0.875,x:5.5},"",{x:6.5},""], +[{y:-0.875,w:1.5},"","",{x:14.5},"",{c:"#2277ff",w:1.5},"RShift"], +[{y:-0.375,x:3.5,c:"#cccccc"},"",{x:10.5},""], +[{y:-0.875,x:2.5},"",{x:1},"",{x:8.5},"",{x:1},""], +[{y:-0.75,x:0.5},"","",{x:14.5},"",""], +[{r:30,rx:6.5,ry:4.25,y:-1,x:1},"",""], +[{h:2},"",{h:2},"",""], +[{x:2},""], +[{r:-30,rx:13,y:-1,x:-3},"",""], +[{x:-3},"",{h:2},"",{h:2},""], +[{x:-3},""] + diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.png b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.png index b3101e5c049..e4de64a96f1 100644 Binary files a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.png and b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.png differ diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.txt b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.txt index 35efdba7d6a..e199f5c59f4 100644 --- a/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.txt +++ b/keyboard/ergodox_ez/keymaps/ordinary/ordinary-symbol.txt @@ -1,7 +1,7 @@ [{x:3.5,c:"#99de2a"},"F3",{x:10.5},"F8"], [{y:-0.875,x:2.5},"F2",{x:1},"F4",{x:8.5},"F7",{x:1},"F9"], [{y:-0.875,x:5.5},"F5",{c:"#ff4444"},"Esc",{x:4.5,c:"#bbddbb"},"_\n\n\n\n\n\n-",{c:"#99de2a"},"F6"], -[{y:-0.875,c:"#2277ff",w:1.5},"Shift\n\n\n\n\n\nLock",{c:"#99de2a"},"F1",{x:14.5},"F10",{c:"#2277ff",w:1.5},"\n\nShift\n\n\n\n\nLock"], +[{y:-0.875,c:"#2277ff",w:1.5},"Special\n\n\n\n\n\nShift",{c:"#99de2a"},"F1",{x:14.5},"F10",{c:"#2277ff",w:1.5},"\n\nSpecial\n\n\n\n\nShift"], [{y:-0.375,x:3.5,c:"#bbddbb"},"{",{x:10.5,c:"#89b087"},"8"], [{y:-0.875,x:2.5,c:"#bbddbb"},"@",{x:1},"}",{x:8.5,c:"#89b087"},"7",{x:1},"9"], [{y:-0.875,x:5.5,c:"#bbddbb"},"&",{h:1.5},"<",{x:4.5,h:1.5},">","|"], @@ -14,7 +14,7 @@ [{y:-0.75,x:3.5,c:"#bbddbb"},"[",{x:10.5,c:"#89b087"},"2"], [{y:-0.875,x:2.5,c:"#bbddbb"},"^",{x:1},"]",{x:8.5,c:"#89b087"},"1",{x:1},"3"], [{y:-0.875,x:5.5,c:"#bbddbb"},"~",{x:6.5},"\\"], -[{y:-0.875,c:"#2277ff",fa:[0,1,0,1,0,0,1],w:1.5},"Capitals\nShift\n\n\n\n\nShift",{c:"#bbddbb"},"%",{x:14.5,c:"#89b087"},"-",{c:"#2277ff",w:1.5},"\n\nCapitals\nShift\n\n\n\nShift"], +[{y:-0.875,c:"#2277ff",w:1.5},"Capitals\n\n\n\n\n\nShift",{c:"#bbddbb"},"%",{x:14.5,c:"#89b087"},"-",{c:"#2277ff",w:1.5},"\n\nCapitals\n\n\n\n\nShift"], [{y:-0.375,x:3.5,c:"#77aaff"},"Option\n\n\nLAlt",{x:10.5,c:"#89b087"},".\n\n\nOption"], [{y:-0.875,x:2.5,c:"#77aaff"},"Hyper",{x:1},"Cmd\n\n\nSuper",{x:8.5,c:"#89b087"},"0\n\n\nCmd",{x:1},"=\n\n\nHyper"], [{y:-0.75,x:0.5,c:"#77aaff"},"Ctrl\n\n\nLCtrl","Meh",{x:14.5,c:"#89b087"},"+\n\n\nMeh","Enter\n\n\nCtrl"], @@ -22,6 +22,6 @@ [{h:2},"Space",{h:2},"Enter","Up"], [{x:2},"Down"], [{r:-30,rx:13,y:-1,x:-3},"Home","End"], -[{x:-3,f:3},"Page\n\n\n\n\n\nUp",{h:2},"< Del\n\n\nBackspace",{h:2},"Del >\n\n\nDelete"], -[{x:-3,f:3},"Page\n\n\n\n\n\nDown"] +[{x:-3},"Page\n\n\n\n\n\nUp",{h:2},"< Del\n\n\nBackspace",{h:2},"Del >\n\n\nDelete"], +[{x:-3},"Page\n\n\n\n\n\nDown"] diff --git a/keyboard/ergodox_ez/keymaps/ordinary/ordinary.hex b/keyboard/ergodox_ez/keymaps/ordinary/ordinary.hex index 8e2d5ce26d4..1e740e4f39f 100644 Binary files a/keyboard/ergodox_ez/keymaps/ordinary/ordinary.hex and b/keyboard/ergodox_ez/keymaps/ordinary/ordinary.hex differ diff --git a/keyboard/ergodox_ez/keymaps/ordinary/readme.md b/keyboard/ergodox_ez/keymaps/ordinary/readme.md index 842dc7ee19b..6465cd79e06 100644 --- a/keyboard/ergodox_ez/keymaps/ordinary/readme.md +++ b/keyboard/ergodox_ez/keymaps/ordinary/readme.md @@ -55,7 +55,7 @@ Finally, consider the turquoise text-nav keys. Here in the Symbols layer, these * The bright green keys are more F-keys * The dark yellow keys signal Web and Audio applications * The light yellow keys signal the operating system -* The uncolored keys do nothing in case you bump them by accident +* The dark gray keys do nothing in case you bump them by accident ![Ordinary media layout](ordinary-media.png) @@ -67,14 +67,37 @@ Alas, the yellow keys have at best spotty success with common software. Good luc ## Switching Between Layers ## -The three Shift keys correspond to three logical layers on top of the ever-present base layer, and are represented in the three LEDs on the keyboard: Capitals (red), Symbols (green), Media (blue). The color of a layer illuminates when the layer is active. Shift keys work in the expected way: press them and the keys shift to that layer; release them and the keys shift back to the base layer. The Ordinary Layout also features a Shift Lock key to keep a layer active indefinitely. Hold down the Shift Lock key then press any Shift key to lock to that layer. Or, hold down the Shift key and press the Shift Lock key; it works either way. To revert to the base layer, use the Shift Lock key again in combination with the Shift key. +In addition to Symbols and Media there is the Capitals layer which is exactly the same as pressing the shift key. Each layer is accessed by a shift key on each edge of the keyboard and corresponds to one of the three LEDs on the keyboard: Capitals (red), Symbols (green), Media (blue). The color of a layer illuminates when the layer is active. -This layout attempts to treat the Capitals Shift layer the same as the other two Shift layers, but internally they are different which causes some inconsistencies. For instance, it is possible to switch from any layer to any other layer, and to lock to any layer, *except* it is not possible to go from Media to Symbols. You must exit the Media layer before engaging the Symbols layer. Also, the Caps Lock feature must be triggered by first pressing the Shift Lock key then a Capitals Shift key; it doesn't work if you press the Shift key first (instead you get the secondary symbol character associated with the Shift Lock button). +Shift buttons work in the expected way: press them and all of the keys switch to that layer; release them and the keys switch back to the base layer. If you press both of a pair of shift keys, the layer will lock on until you press both shift keys again. For instance, the widely and rightly loathed Caps Lock is engaged by pressing both Capitals Shift buttons. All the Shift keys work this way. -## Special Escape & Backspace Sequences ## +Multiple layers can be turned on at once. The Capitals layer will affect characters on other layers to capitalize. Other layers, however, don't 'mix': Symbols blankets the base layout; Media blankets Symbols. -In the Ordinary Layout, the most unsatisfying key location is the Escape key which rightly belongs segregated on its own way up on the top left of the keyboard. The Ergodox does not have a physical button in such a location and the nearest one, in the top left corner, is home to the tilde (er, grave) which is commonly found there. The Escape key is important so it features prominently on the other top corner on the left side of the keyboard, and is always there in all layers. Nevertheless, alas, it isn't Ordinary to put the escape in that different corner! +## Special Sequences ## -That tilde key has a second function as the Shift Lock key and that makes possible a special feature. To make this layout as Ordinary as possible, the Escape key can *also* be accessed by pressing Shift Lock then the 1 button right next to it. This easy gesture is a way to partially maintain the ease of flicking your wrist to the left and tapping Escape. This gesture works in all layers. +![Ordinary special layout](ordinary-special.png) -Finally, because the special Escape sequence is so natural and useful, on the top right corner of the Ergodox EZ you can do the same gesture with the 0 key to produce a Backspace. Users of this keyboard and this layout are well advised to learn to use their thumbs for deleting text, but sometimes you are doing other computery things and just want to flick your digits up to the right and press backspace a bunch times. These special sequences should feel unremarkably mundane but might prove to be remarkably useful. +### Escape ### + +The One True Location for the Escape key is segregated way up on the top left of the keyboard. The Ergodox does not have a physical button in such a location and the nearest one is home to the tilde (er, grave) which is commonly found there. In the Ordinary layout the Escape key is found on all layers in the prominent location in the corner next to the 5, whnich is easy to remember, and yet it isn't natural for those of us with muscle memory flicking our wrists up and to the left looking for Escape. + +The Ordinary layout offers as a consolation prize a Special sequence for Escape: Special Shift + 1. This is natural so you can tap the top left button, then the button next to it and get Escape. This gesture works in all layers. + +### Backspace ### + +At the top right corner of the Ergodox EZ you can a gesture similar to the special Escape sequence, using the 0 key, to produce a Backspace. Users of this keyboard and this layout are well advised to learn to use their thumbs for deleting text, but sometimes you are doing other computery things and just want to flick your digits up to the right and press backspace a bunch times. + +### RShift ### + +The Ordinary Layout locks layers by pressing both of a pair of shift keys. This interferes with the QMK firmware magic sequence, which is LShift+RShift. To work around this, both of the Capitals Shift keys produce a *Left Shift* keystroke. If for some reason a person needs *Right Shift* they can find it by pressing a Special Shift key, then the Capitals Shift key on the right side of the keyboard. + +**** + +The Ordinary Layout for the Ergodox EZ keyboard, v4 + +Modifications from default by Nicholas Keene ergodoxez@nicholaskeene.com + +No rights reserved. This software is in the public domain. Credit me if you are friendly but if you're a jerk don't bother. + +Details: readme.md + https://github.com/nrrkeene/qmk_firmware/tree/master/keyboard/ergodox_ez/keymaps/ordinary diff --git a/keyboard/ergodox_ez/keymaps/osx_de_experimental/keymap.c b/keyboard/ergodox_ez/keymaps/osx_de_experimental/keymap.c index b3ed55f217a..19e539006ac 100644 --- a/keyboard/ergodox_ez/keymaps/osx_de_experimental/keymap.c +++ b/keyboard/ergodox_ez/keymaps/osx_de_experimental/keymap.c @@ -15,6 +15,15 @@ #include "keymap_extras/keymap_spanish.h" #include "keymap_extras/keymap_bepo.h" + +/** +* This layout was generated using the ErgodoxLayoutGenerator (ELG). You can download it from https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases +* documentation about it can be found here https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/ +* Thanks to the team of Erez Zukerman for building the great Ergodox-EZ! +* +* use at own risk! +**/ + #define BASE 0 #define SYMB 1 #define MDIA 2 @@ -23,24 +32,73 @@ #define EGOS 5 #define SMLY_TOG_QUOT 0 + #define M_TOGGLE_5 1 + #define TGH_NUM 2 + #define M_DE_OSX_PLUS_CTRLALT 3 + #define SM_KISS 4 + #define SM_FROWN 5 + #define SM_CRY 6 + #define SM_SMILE 7 + #define SM_SMIRK 8 + #define M_LGUI_SHFT 9 + #define SM_HEART 10 + #define TOG_HLD_MDIA 11 + #define SM_LAUGH 12 + #define SM_SAD 13 + #define M_DE_OSX_CIRC_CTRLCMD 14 + #define M_MEH_SH_ACUT 15 + //Layout keymap.c generated with ErgodoxLayoutGenerator V1.0BETA1 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/** +* Layer: BASE +* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ +* | ESC | 1 | 2 | 3 | 4 | 5 | Hold or toggle | | Hold or toggle | 6 | 7 | 8 | 9 | 0 | ß | +* | | | | | | | Layer NUMB | | Layer MDIA | | | | | | | +* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ +* | TAB | Q | W | E | R | T | Cmd | | Cmd | Z | U | I | O | P | Ü | +* | | | | | | | | | | | | | | | | +* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/\-------------------\ \-------------------\/-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ +* | Alt | A | S | D | F | G | | H | J | K | L | Ö | Ä | +* | | | | | | | | | | | | | ALT | +* /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------//-------------------//-------------------/ +* | Shift | Y | X | C | V | B | Alt | | Alt | N | M | , | . | - | Shift | +* | | Ctrl | | | | | | | | | | | | Ctrl | | +* \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\ \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\\-------------------\ +* +* +* /-------------------//-------------------//-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------//-------------------//-------------------/ +* | < | LongPress / Type | LongPress / Type | Shift+Ctrl | Type | | # | ACUT | CMD+Shift | ALT+Shift | + | +* | SYMB | DE_OSX_CIRC_CTRLCMD| DE_OSX_PLUS_CTRAlt | | Toggle SMLY | | Meh | Hyper | | | SYMB | +* \-------------------\\-------------------\\-------------------\\-------------------\/-------------------//-------------------/ /-------------------//-------------------/ \-------------------\\-------------------\\-------------------\\-------------------\\-------------------\ +* | HOME | END | | LEFT | RIGHT | +* | | | | | | +* \-------------------\/-------------------/ /-------------------/\-------------------\ +* | PGUP | | UP | +* | | | | +* /-------------------//-------------------//-------------------/ /-------------------//-------------------//-------------------/ +* | BSPC | DEL | PGDN | | DOWN | ENT | SPC | +* | | | | | | | | +* \-------------------\\-------------------\\-------------------\ \-------------------\\-------------------\\-------------------\ +* +* +**/ [BASE]=KEYMAP( //left half KC_ESC, DE_OSX_1, DE_OSX_2, DE_OSX_3, DE_OSX_4, DE_OSX_5, M(TGH_NUM), @@ -60,6 +118,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LEFT, KC_RIGHT, KC_UP, KC_DOWN, KC_ENT, KC_SPC), +/** +* Layer: SYMB +* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ +* | APPLICATION| F1 | F2 | F3 | F4 | F5 | F5 | | F6 | F6 | F7 | F8 | F9 | F10 | F11 | +* | | | | | | | | | | | | | | | | +* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ +* | | < | > | ! | ? | | | | | \ | [ | ] | < | > | ! | +* | | | | | | | | | | | | | | | | +* /-----------//-----------//-----------//-----------//-----------//-----------/\-----------\ \-----------\/-----------//-----------//-----------//-----------//-----------//-----------/ +* | | # | $ | \ | / | . | | / | ( | ) | { | } | # | +* | | | | | | | | | | | | | | +* /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------//-----------//-----------/ +* | | | < | % | | | ~ | | | | | | ~ | | | | | +* | | | | | | | | | | | | | | | | +* \-----------\\-----------\\-----------\\-----------\\-----------\\-----------\\-----------\ \-----------\\-----------\\-----------\\-----------\\-----------\\-----------\\-----------\ +* +* +* /-----------//-----------//-----------//-----------//-----------/ /-----------//-----------//-----------//-----------//-----------/ +* | | | | | | | ' | DQOT | | Toggle 5 | | +* | | | | | | | | | | | | +* \-----------\\-----------\\-----------\\-----------\/-----------//-----------/ /-----------//-----------/ \-----------\\-----------\\-----------\\-----------\\-----------\ +* | | | | F13 | F12 | +* | | | | | | +* \-----------\/-----------/ /-----------/\-----------\ +* | | | F14 | +* | | | | +* /-----------//-----------//-----------/ /-----------//-----------//-----------/ +* | | DEL | | | F15 | | | +* | | | | | | | | +* \-----------\\-----------\\-----------\ \-----------\\-----------\\-----------\ +* +* +**/ [SYMB]=KEYMAP( //left half KC_APPLICATION, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F5, @@ -79,6 +170,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_F13, KC_F12, KC_F14, KC_F15, KC_TRNS, KC_TRNS), +/** +* Layer: MDIA +* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/ +* | | | | | | | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/ +* | | | BTN1 | U | BTN2 | U | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* /-----//-----//-----//-----//-----//-----/\-----\ \-----\/-----//-----//-----//-----//-----//-----/ +* | | | L | D | R | D | | | | | | | | +* | | | | | | | | | | | | | | +* /-----//-----//-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----//-----//-----/ +* | | | L | D | R | BTN3 | | | | | | | | UP | | +* | | | | | | | | | | | | | | | | +* \-----\\-----\\-----\\-----\\-----\\-----\\-----\ \-----\\-----\\-----\\-----\\-----\\-----\\-----\ +* +* +* /-----//-----//-----//-----//-----/ /-----//-----//-----//-----//-----/ +* | | | | | | | | | LEFT | DOWN | RIGHT| +* | | | | | | | | | | | | +* \-----\\-----\\-----\\-----\/-----//-----/ /-----//-----/ \-----\\-----\\-----\\-----\\-----\ +* | | | | MPRV | MNXT | +* | | | | | | +* \-----\/-----/ /-----/\-----\ +* | | | VOLU | +* | | | | +* /-----//-----//-----/ /-----//-----//-----/ +* | | | | | VOLD | MUTE | MPLY | +* | | | | | | | | +* \-----\\-----\\-----\ \-----\\-----\\-----\ +* +* +**/ [MDIA]=KEYMAP( //left half KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -90,14 +214,47 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, //right half - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_VOLU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_VOLD, KC_TRNS, KC_MPRV, KC_MNXT, KC_UP, KC_TRNS, - KC_MUTE, KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT, - KC_TRNS, KC_TRNS, - KC_TRNS, - KC_TRNS, KC_TRNS, KC_WBAK), + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, + KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RIGHT, + KC_MPRV, KC_MNXT, + KC_VOLU, + KC_VOLD, KC_MUTE, KC_MPLY), +/** +* Layer: SMLY +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | Typing | Typing | Typing | | | | | +* | | | | | | | | | SM_SMILE| SM_SMIRK| SM_LAUGH| | | | | +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | | Typing | Typing | Typing | | | | +* | | | | | | | | | | SM_FROWN| SM_SAD | SM_CRY | | | | +* /--------//--------//--------//--------//--------//--------/\--------\ \--------\/--------//--------//--------//--------//--------//--------/ +* | | | | | | | | Typing | Typing | | | | | +* | | | | | | | | SM_HEART| SM_KISS | | | | | +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* \--------\\--------\\--------\\--------\\--------\\--------\\--------\ \--------\\--------\\--------\\--------\\--------\\--------\\--------\ +* +* +* /--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------/ +* | | | | | | | | | | | | +* | | | | | | | | | | | | +* \--------\\--------\\--------\\--------\/--------//--------/ /--------//--------/ \--------\\--------\\--------\\--------\\--------\ +* | | | | | | +* | | | | | | +* \--------\/--------/ /--------/\--------\ +* | | | | +* | | | | +* /--------//--------//--------/ /--------//--------//--------/ +* | | | | | | | | +* | | | | | | | | +* \--------\\--------\\--------\ \--------\\--------\\--------\ +* +* +**/ [SMLY]=KEYMAP( //left half KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -117,6 +274,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +/** +* Layer: NUMB +* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/ +* | | | | | | | | | | F6 | F7 | F8 | F9 | F10 | F11 | +* | | | | | | | | | | | | | | | | +* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/ +* | | | | UP | | | | | | / | 7 | 8 | 9 | * | F12 | +* | | | | | | | | | | | | | | | | +* /----//----//----//----//----//----/\----\ \----\/----//----//----//----//----//----/ +* | | | LEFT| DOWN| RGHT| | | / | 4 | 5 | 6 | + | - | +* | | | | | | | | | | | | | | +* /----//----//----//----//----//----//----/ /----//----//----//----//----//----//----/ +* | | | | | | | | | | % | 1 | 2 | 3 | | | +* | | | | | | | | | | | | | | | | +* \----\\----\\----\\----\\----\\----\\----\ \----\\----\\----\\----\\----\\----\\----\ +* +* +* /----//----//----//----//----/ /----//----//----//----//----/ +* | | | | | | | 0 | . | , | = | | +* | | | | | | | | | | | | +* \----\\----\\----\\----\/----//----/ /----//----/ \----\\----\\----\\----\\----\ +* | | | | | | +* | | | | | | +* \----\/----/ /----/\----\ +* | | | | +* | | | | +* /----//----//----/ /----//----//----/ +* | | | | | | | | +* | | | | | | | | +* \----\\----\\----\ \----\\----\\----\ +* +* +**/ [NUMB]=KEYMAP( //left half KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -136,6 +326,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS), +/** +* Layer: EGOS +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* /--------//--------//--------//--------//--------//--------/\--------\ \--------\/--------//--------//--------//--------//--------//--------/ +* | Shift | | | | | | | | | | | | | +* | | | | | | | | | | | | | | +* /--------//--------//--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------//--------//--------/ +* | | | | | | | | | | | | | | | | +* | | | | | | | | | | | | | | | | +* \--------\\--------\\--------\\--------\\--------\\--------\\--------\ \--------\\--------\\--------\\--------\\--------\\--------\\--------\ +* +* +* /--------//--------//--------//--------//--------/ /--------//--------//--------//--------//--------/ +* | Ctrl | | | | | | | | | Toggle 5| | +* | | | | | | | | | | | | +* \--------\\--------\\--------\\--------\/--------//--------/ /--------//--------/ \--------\\--------\\--------\\--------\\--------\ +* | F1 | F2 | | | | +* | | | | | | +* \--------\/--------/ /--------/\--------\ +* | F3 | | | +* | | | | +* /--------//--------//--------/ /--------//--------//--------/ +* | SPC | Ctrl | F4 | | | | | +* | | | | | | | | +* \--------\\--------\\--------\ \--------\\--------\\--------\ +* +* +**/ [EGOS]=KEYMAP( //left half KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, @@ -259,7 +482,7 @@ case M_LGUI_SHFT: if (record->event.pressed){ return MACRO(DOWN(KC_LGUI),DOWN(KC_LSFT),END); }else{ - return MACRO(UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),U(LGUI),U(LSFT),END); + return MACRO(UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),UP(KC_LGUI),UP(KC_LSFT),U(LGUI),U(LSFT),END); } break; diff --git a/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental.hex b/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental.hex new file mode 100644 index 00000000000..3c7ab58597c Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental.hex differ diff --git a/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental_highres.png b/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental_highres.png index 29f1099d06d..031d874a7ba 100644 Binary files a/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental_highres.png and b/keyboard/ergodox_ez/keymaps/osx_de_experimental/osx_de_experimental_highres.png differ diff --git a/keyboard/ergodox_ez/keymaps/osx_de_experimental/readme.md b/keyboard/ergodox_ez/keymaps/osx_de_experimental/readme.md new file mode 100644 index 00000000000..e6a10184167 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/osx_de_experimental/readme.md @@ -0,0 +1,22 @@ + +# Ergodox und Ergodox-EZ experimentelles Layout + +dieses layout ist experimentell und wird im Lufe der Zeit viele Änderungen und Verbesserungen durchlaufen. Falls diese sich als vorteilhaft erweisen, werden sie evtl. auch in das `osx_de` layout übernommen. + + + +# Erstellt Mit Dem ErgodoxLayoutGenerator + +Der ErgodoxLayoutGenerator (ELG) ist ein kleines Werkzeug, welches die Erstellung und Pflege der eigenen Keymaps erleichtern soll. Es ist in java geschrieben und kann [hier](https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases) heruntergeladen werden. Damit das Tool funktioniert sollte das offizielle Oracle JDK in aktueller Version installiert sein. +Die Dokumentation für den ELG kann man [hier](https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/) nachlesen (momentan leider nur in Englisch verfügbar). +--------------------------------------------------------------------------------------------------------------------- + +# Ergodox and Ergodox-EZ experimental layout + +This is an experimental layout which will undergo heavy changes over time. If changes prove to be good, they might also move into the `osx_de` layout. + +Created Using the ErgodoxLayoutGenerator + +The ErgodoxLayoutGenerator (ELG) is a little tool, which makes the creation and maintenance of keycaps a lot easier. It was written in Java and can be downloaded [here](https://github.com/sboesebeck/ErgodoxLayoutGenerator/releases). To use the tool, you need to have a current version of Oracles JDK installed. + +The documentation of the ELG can be viewed [here](https://boesebeck.name/2016/04/16/ergodoxlayoutgenerator-documentation/). \ No newline at end of file diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/keymap.c b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/keymap.c new file mode 100644 index 00000000000..e23c5a1d6af --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/keymap.c @@ -0,0 +1,45 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [BASE] = KEYMAP( + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_F5, + KC_TAB, KC_Q, KC_W, KC_D, KC_F, KC_K, KC_BSLS, + CTL_T(KC_ESC), KC_A, KC_S, KC_E, KC_T, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, + KC_F1, KC_F2, KC_F3, KC_F4, KC_LGUI, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_VOLD, KC_MUTE, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_VOLU, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_BSPC, CTL_T(KC_ESC), KC_LALT, + // + /*-*/ KC_F6, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL, + /*-*/ KC_NO, KC_J, KC_U, KC_R, KC_L, KC_SCLN, KC_MINS, + /*-*/ /*-*/ KC_Y, KC_N, KC_I, KC_O, KC_H, KC_ENT, + /*-*/ KC_RBRC, KC_P, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + /*-*/ /*-*/ /*-*/ KC_RGUI, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, + KC_MPLY, KC_MNXT, + KC_MPRV, + KC_RALT, KC_QUOT, KC_SPC + ) +}; + +const uint16_t PROGMEM fn_actions[] = { +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { +}; diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/readme.md b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/readme.md new file mode 100644 index 00000000000..80475ab21e7 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/readme.md @@ -0,0 +1,28 @@ +# Roman's Layout + +There is only one layer based on [Norman layout](https://normanlayout.info/). + +Looking for multiple-layer layouts? + +- [Symbols, arrows, plover, HJKL arrows](../romanzolotarev-norman-plover-osx-hjkl/) +- [Same with IJKL arrows](../romanzolotarev-norman-plover-osx/) + +[![keyboard-layout](romanzolotarev-norman-osx.png)](http://www.keyboard-layout-editor.com/#/gists/9e89d54f1ea6eeeb7dab1b2d19d28195) + +## Functional Keys + +- Tap `F1` to mute microphone via [Shush](http://mizage.com/shush/). +- Tap `F2` to copy screenshot to the clipboard. +- Hold `SHIFT` and tap `F2` to save screenshot as a file. +- Tap `F3`, `F4`, `F5`, `F6` to resize a window via [Divvy](http://mizage.com/divvy/). + +## CTRL/ESC + +CTRL and ESC are frequently used in Vim. + +- Tap `CTRL/ESC` to send `ESC`. +- Hold `CTRL/ESC` to use as `CTRL`. + +## Activate N-rollover + +- Hold left `SHIFT` and right `SHIRT` and then tap `N`. diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.hex b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.hex new file mode 100644 index 00000000000..1be94c43d10 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.hex differ diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.png b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.png new file mode 100644 index 00000000000..4b9433be28c Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-osx/romanzolotarev-norman-osx.png differ diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/keymap.c b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/keymap.c new file mode 100644 index 00000000000..dd946c1823f --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/keymap.c @@ -0,0 +1,73 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 +#define QWRT 1 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [BASE] = KEYMAP( + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_F5, + KC_TAB, KC_Q, KC_W, KC_D, KC_F, KC_K, KC_BSLS, + KC_LCTL, KC_A, KC_S, KC_E, KC_T, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, + KC_F1, KC_F2, KC_F3, KC_F4, KC_LGUI, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_VOLD, KC_MUTE, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_VOLU, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_BSPC, CTL_T(KC_ESC), KC_LALT, + // + /*-*/ KC_F6, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL, + /*-*/ TG(QWRT), KC_J, KC_U, KC_R, KC_L, KC_SCLN, KC_MINS, + /*-*/ /*-*/ KC_Y, KC_N, KC_I, KC_O, KC_H, KC_ENT, + /*-*/ KC_RBRC, KC_P, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + /*-*/ /*-*/ /*-*/ KC_RGUI, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, + KC_MPLY, KC_MNXT, + KC_MPRV, + KC_RALT, KC_QUOT, KC_SPC + ), + [QWRT] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_E, KC_R, KC_T, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_D, KC_F, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, + /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, + /*-*/ /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, + // + /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + /*-*/ KC_TRNS, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_TRNS, + /*-*/ /*-*/ KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_TRNS, + /*-*/ KC_TRNS, KC_N, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + /*-*/ /*-*/ /*-*/ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + uint8_t layer = biton32(layer_state); + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + case QWRT: + ergodox_right_led_1_on(); + break; + default: + break; + } +}; diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/readme.md b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/readme.md new file mode 100644 index 00000000000..0e78c130b36 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/readme.md @@ -0,0 +1,34 @@ +# Roman's Layout + +There are two layers: + +- **BASE** is [Norman layout](https://normanlayout.info/). +- **QWRT** is QWERTY. + +[![keyboard-layout](romanzolotarev-norman-qwerty-osx.png)](http://www.keyboard-layout-editor.com/#/gists/3b236f450da474dc506a5a80390c3cc7) + +## Switching + +- Tap `QWRT` to toggle **QWRT**. + +## LEDs + +- Red: QWRT is on. + +## Functional Keys + +- Tap `F1` to mute microphone via [Shush](http://mizage.com/shush/). +- Tap `F2` to copy screenshot to the clipboard. +- Hold `SHIFT` and tap `F2` to save screenshot as a file. +- Tap `F3`, `F4`, `F5`, `F6` to resize a window via [Divvy](http://mizage.com/divvy/). + +## CTRL/ESC + +Both CTRL and ESC are frequently used in Vim. + +- Tap `CTRL/ESC` to send `ESC`. +- Hold `CTRL/ESC` to use as `CTRL`. + +## Activate N-rollover + +- Hold left `SHIFT` and right `SHIRT` and then tap `N`. diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.hex b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.hex new file mode 100644 index 00000000000..80ae0751b18 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.hex differ diff --git a/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.png b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.png new file mode 100644 index 00000000000..34762ecb752 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/romanzolotarev-norman-qwerty-osx/romanzolotarev-norman-qwerty-osx.png differ diff --git a/keyboard/ergodox_ez/keymaps/sneako/README.md b/keyboard/ergodox_ez/keymaps/sneako/README.md new file mode 100644 index 00000000000..8dd110ee68e --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/sneako/README.md @@ -0,0 +1,6 @@ +# ergodox_keymap + +Based on the default Ergodox EZ firmware + +Replaced the left side Bksp with a Crtl/Esc, this really helps in vim. +Removed the Ctrls from the Z and / keys. diff --git a/keyboard/ergodox_ez/keymaps/sneako/keymap.c b/keyboard/ergodox_ez/keymaps/sneako/keymap.c new file mode 100644 index 00000000000..0c68631029b --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/sneako/keymap.c @@ -0,0 +1,187 @@ +// Based on `default_osx` +// Replace left Bksp with Ctrl/Esc +// Remove the Ctrl from Z and / +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | Del | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * |Ctrl/Esc| A | S | D | F | G |------| |------| H | J | K | L |; / L2| LGui | + * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------| + * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | RShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | App | LGui | | Alt |Ctrl/Esc| + * ,------|------|------| |------+--------+------. + * | | | Home | | PgUp | | | + * | Space|Backsp|------| |------| Tab |Enter | + * | |ace | End | | PgDn | | | + * `--------------------' `----------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* +[BASE] = KEYMAP( // layer 0 : default + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, + KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(1), + CTL_T(KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO), + LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT, + ALT_T(KC_APP), KC_LGUI, + KC_HOME, + KC_SPC,KC_BSPC,KC_END, + // right hand + KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + TG(1), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),GUI_T(KC_QUOT), + MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_RSFT, + KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, + KC_LALT, CTL_T(KC_ESC), + KC_PGUP, + KC_PGDN,KC_TAB, KC_ENT + ), +/* Keymap 1: Symbol Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | . | 0 | = | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = KEYMAP( + // left hand + KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS, + KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS, + KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: Media and mouse keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | Prev | Next | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// MEDIA AND MOUSE +KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboard/ergodox_ez/keymaps/sneako/sneako.hex b/keyboard/ergodox_ez/keymaps/sneako/sneako.hex new file mode 100644 index 00000000000..1db1728652a Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/sneako/sneako.hex differ diff --git a/keyboard/ergodox_ez/keymaps/techtomas/keymap.c b/keyboard/ergodox_ez/keymaps/techtomas/keymap.c new file mode 100644 index 00000000000..b7d3b9a116d --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/techtomas/keymap.c @@ -0,0 +1,231 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media +#define CNTL 3 // control layer + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | L1/` | 1 | 2 | 3 | 4 | 5 |CmdSpc| | - | 6 | 7 | 8 | 9 | 0 | = | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * |Meh/Tab | Q | W | E | R | T | STab | | L3 | Y | U | I | O | P | Meh/\ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * |Hyp/Esc | L3/A | S | D | F | G |------| |------| H | J | K | L | L2/; | Hyp/' | + * |--------+------+------+------+------+------| Tab | |AltGui|------+------+------+------+------+--------| + * | LShift | L3/Z | X | C | V | B | | | | N | M | , | . | L2// | RShift | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * |LCtrl | LAlt | LGui |Left |Right | | UP | Down | [ | ] | L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | LCtl | LGui | | LAlt |ShfGui| + * ,-------|------|------| |------+--------+------. + * | | | Home | | PgUp | | | + * | Backsp|Delete|------| |------| Enter | Space | + * | | | End | | PgDn | | | + * `--------------------' `-----------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* +[BASE] = KEYMAP( // layer 0 : default + // left hand + LT(SYMB,KC_GRV), KC_1, KC_2, KC_3, KC_4, KC_5, LGUI(KC_SPC), + MEH_T(KC_TAB), KC_Q, KC_W, KC_E, KC_R, KC_T, S(KC_TAB), + ALL_T(KC_ESC), LT(CNTL,KC_A), KC_S, KC_D, KC_F, KC_G, + KC_LSFT, LT(CNTL,KC_Z), KC_X, KC_C, KC_V, KC_B, KC_TAB, + KC_LCTL, KC_LALT, KC_LGUI, KC_LEFT, KC_RIGHT, + KC_LCTL, KC_LGUI, + KC_HOME, + KC_BSPC, KC_DELETE, KC_END, + // right hand + KC_MINS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL, + KC_FN3, KC_Y, KC_U, KC_I, KC_O, KC_P, MEH_T(KC_BSLS), + KC_H, KC_J, KC_K, KC_L, LT(MDIA,KC_SCLN), ALL_T(KC_QUOT), + LALT(KC_LGUI), KC_N, KC_M, KC_COMM, KC_DOT, LT(MDIA,KC_SLSH), KC_RSFT, + KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_FN1, + KC_LALT, S(KC_LGUI), + KC_PGUP, + KC_PGDN,KC_ENT, KC_SPC + ), +/* Keymap 1: Symbol Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | ! | @ | { | } | | | < | | > | : | 7 | 8 | 9 | / | F12 | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | # | $ | ( | ) | ` |------| |------| ; | 4 | 5 | 6 | * | Prnt | + * |--------+------+------+------+------+------| F14 | | F15 |------+------+------+------+------+--------| + * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | - | Entr | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | 0 | . | = | + | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = KEYMAP( + // left hand + KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,S(KC_COMM), + KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV, + KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_F14, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS, + KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + S(KC_DOT), KC_COLN, KC_7, KC_8, KC_9, KC_BSLS, KC_F12, + KC_SCLN, KC_4, KC_5, KC_6, KC_ASTR, KC_PSCR, + KC_F15, KC_AMPR, KC_1, KC_2, KC_3, KC_MINS, KC_ENT, + KC_0, KC_DOT, KC_EQL, KC_PLUS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: Media Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | |------| |------| | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | | | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | Prev | Next | | Prev | Next | + * ,------|------|------| |------+------+------. + * | | | VolUp| | VolUp| | | + * | Play | Mute |------| |------| Mute | Play | + * | | | VolDn| | VolDn| | | + * `--------------------' `--------------------' + */ +// Control +[MDIA] = KEYMAP( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_MPRV, KC_MNXT, + KC_VOLU, + KC_MPLY, KC_MUTE, KC_VOLD, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_MPRV, KC_MNXT, + KC_VOLU, + KC_VOLD, KC_MUTE, KC_MPLY +), +/* Keymap 3: Control Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | Sleep | | | | | | Pwr | | | | | | | | | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | MsUp | | | | | | | | | | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | |MsLeft|MsDown|MsRght| Lclk |------| |------| Lft | Down | Up | Right| | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | Rclk | | | | | | | | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | | | | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// Control +[CNTL] = KEYMAP( + KC_SLEP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PWR, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_BTN1, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN2, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB), + [2] = ACTION_LAYER_TAP_TOGGLE(MDIA), + [3] = ACTION_LAYER_TAP_TOGGLE(CNTL) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + case 3: + ergodox_right_led_3_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboard/ergodox_ez/keymaps/techtomas/readme.md b/keyboard/ergodox_ez/keymaps/techtomas/readme.md new file mode 100644 index 00000000000..1ed80fc20c4 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/techtomas/readme.md @@ -0,0 +1,36 @@ +# Techtomas Configuration + +## Base Layer + +The base layer is a merge of what I liked with the default layout and the ordinary layout. The thumb cluster is more like the Kinesis advantage and the top row of the cluster is convient for use on the mac. + +* The Caps Lock postion handles [Hyper/Esc](http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/) +* The Tab key toggles MEH. +* The two vertical mods on the left board are Shift+Tab and Tab. +* The two vertical mods on the right board are Control Layer tap/toggle and Alt+Cmd. +* The HYPER and MEH key are made in the same location on the right side of the board as well. Using Keyboard Maestro for OS X makes one-handed shortcuts very easy. + +## Symbol Layer +The symbol layer can be tap/toggled through the bottom right key and also toggled holding the tilde/grave key in the upper left corner. I haven't used the symbol layer enough to tell if this was a good place or not but it made sense in my head + +The bottom two vertical mods are set to F14 and F15 which is the default for changing screen brightness on the mac + +## Media Layer +/ & ; will toggle the media layer which has play and volume controls assigned to the thumb cluster. I found this an easy way to quickly play/pause + +## Control Layer +The a and z keys toggle the control layer. + +On the left board you have mouse control with left & right click in the location of the G and B keys. +On the right board you have vim-style arrow keys using hjkl + +The thumb cluster and mods all pass down to this layer. + +## Changelog + +* Apr 29, 2016 (V1.1): + * Added F14 and F15 to symbol layer + * Added control layer toggle to A key. + +* Apr 28, 2016 (V1.0): + * Modified config based on the default layout plus inspiration from the ordinary layout diff --git a/keyboard/ergodox_ez/keymaps/techtomas/techtomas.hex b/keyboard/ergodox_ez/keymaps/techtomas/techtomas.hex new file mode 100644 index 00000000000..8aa849208f1 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/techtomas/techtomas.hex differ diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/config.h b/keyboard/ergodox_ez/keymaps/townk_osx/config.h new file mode 100644 index 00000000000..78aa3ee8b92 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/townk_osx/config.h @@ -0,0 +1,92 @@ +/* +Copyright 2012 Jun Wako +Copyright 2013 Oleg Kostyuk + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x1307 +#define DEVICE_VER 0x0001 +#define MANUFACTURER ErgoDox EZ +#define PRODUCT ErgoDox EZ +#define DESCRIPTION t.m.k. keyboard firmware for Ergodox + +/* key matrix size */ +#define MATRIX_ROWS 14 +#define MATRIX_COLS 6 + +#define MOUSEKEY_DELAY 100 +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_MAX_SPEED 3 +#define MOUSEKEY_TIME_TO_MAX 10 + +#define TAPPING_TOGGLE 1 + +#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } +#define ROWS (int []){ D0, D5, B5, B6 } + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* number of backlight levels */ +#define BACKLIGHT_LEVELS 3 + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 2 +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.) + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \ +) + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +#define NO_DEBUG + +/* disable print */ +// #define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION +//#define DEBUG_MATRIX_SCAN_RATE +#define ONESHOT_TAP_TOGGLE 2 +#define ONESHOT_TIMEOUT 3000 + +#endif diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/keymap.c b/keyboard/ergodox_ez/keymaps/townk_osx/keymap.c new file mode 100644 index 00000000000..b63698ec6a7 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/townk_osx/keymap.c @@ -0,0 +1,285 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" +#include "action_util.h" +#include "led.h" +#include "keymap_common.h" +#include "timer.h" + +/* + +# Why this Layout + +This layout was based on Kinesis layout and other ErgoDox user layouts +available. It's target to be used on a MacOS but I'm pretty sure it can be +addapted to Windows and/or Linux easily. + +## Function Key + +The `fn` key work almost like it would in any other keyboard with the exception +it has a semi-sticky behavior. What does that mean? + +Well, if you press the `fn` and release it, the keyboard will be put on the +_function layout_ and the next key stroke will be processed as if the `fn` key +was pressed. Aftwards, the leyout get back to _normal_. If you hold `fn` and +press any other key, when you release them, the keyboard leyout is back to +_normal_. + +While pressing the `fn` with the left hand and strikeing the other keys on the +right hand is farly easy, the same cannot being said for the other keys on the +left side. So, instead of trying to do contorcionism with my left hand, I +decided to do a semi-sticky version of `fn`. This way, I can press the `fn` +key with my pinky, release it and press the `1` key to issue an `F1` to the +operating system. + +## Key-Pad Key + +The `key pad` key is a layout switch key. If pressed, it will put the keyboard +on the _key pad layout_ and stay there until key is pressed again. + +This is used to make the keyboard behave mostly like a **num pad keyboard**. + +## Notes +- Regardless in which layout you are, keys from other layouts are not + accessible. This means that if you are on the _key pad layout_, the left hand + will be pretty much unusable. + Of course that like anything else, there are exceptions to this rule. + Modifiers should remain accessible throughout the layers. +- The _shift key_ is, like the _function key_, also configured to have a sticky + behavior. +- All sticky keys have a timeout of 3 seconds. + +*/ +#define BASE 0 +#define KEYPAD 1 +#define FN 2 + +#define MACRO_TMUX_ESC 10 +#define MACRO_TMUX_PASTE 11 +#define MACRO_OSX_COPY 12 +#define MACRO_OSX_PASTE 13 + +#define M_TESC M(MACRO_TMUX_ESC) +#define M_TPASTE M(MACRO_TMUX_PASTE) +#define M_OSXCPY M(MACRO_OSX_COPY) +#define M_OSXPST M(MACRO_OSX_PASTE) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Base Layer + * + * ,-----------------------------------------------------. ,-----------------------------------------------------. + * | `~ | 1 | 2 | 3 | 4 | 5 | ESC | | Pwr | 6 | 7 | 8 | 9 | 0 | - _ | + * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| + * | Tab | Q | W | E | R | T | F16 | | F17 | Y | U | I | O | P | = + | + * |-----------+------+------+------+------+------| Meh | | Meh |------+------+------+------+------+-----------| + * | \ (Ctrl) | A | S | D | F | G |------| |------| H | J | K | L | ; | ' " (Ctrl)| + * |-----------+------+------+------+------+------| F18 | | F19 |------+------+------+------+------+-----------| + * | LShift | Z | X | C | V | B | Hyper| | Hyper| N | M | , | . | / | RShift | + * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' + * | FN | KPAD |LCtrl | LAlt | LGui | | RGui | RAlt | RCtrl| KPAD | FN | + * `-----------------------------------' `-----------------------------------' + * ,-------------. ,-------------. + * | M(0) | M(1) | | M(2) | M(3) | + * ,------|------|------| |------+------+------. + * | | | Home | | PgUp | | | + * |Backsp| Del |------| |------| Enter| Space| + * | | | End | | PgDn | | | + * `--------------------' `--------------------' + * + * M(0) = Ctrk+A Esc + * (this is used to issue the Esc key to the Tmux application) + * M(1) = Ctrk+A P + * (this is used to issue the Paste key to the Tmux application) + * M(2) = Cmd+C + * M(3) = Cmd+V + */ +[BASE]=KEYMAP(//left half + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_ESC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, MEH_T(KC_F16), + CTL_T(KC_BSLS), KC_A, KC_S, KC_D, KC_F, KC_G, + KC_FN2, KC_Z, KC_X, KC_C, KC_V, KC_B, ALL_T(KC_F18), + KC_FN1, TG(KEYPAD), KC_LCTRL, KC_LALT, KC_LGUI, + M_TESC, M_TPASTE, + KC_HOME, + KC_BSPC, KC_DELT, KC_END, + //right half + KC_POWER, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + MEH_T(KC_F17), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL, + KC_H, KC_J, KC_K, KC_L, KC_SCLN, CTL_T(KC_QUOT), + ALL_T(KC_F19), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_FN2, + KC_RGUI, KC_RALT, CTL_T(KC_LBRC), KC_FN3, KC_FN1, + M_OSXCPY, M_OSXPST, + KC_PGUP, + KC_PGDN, KC_ENT, KC_SPC), + +/* Keymap 1: KeyPad Layer + * + * ,-----------------------------------------------------. ,-----------------------------------------------------. + * | | | LClk | RClk | MClk | | | | BTab | Clear| / | * | ^ | ( | | + * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| + * | M.Accel 2 | |ScrlUp| U |ScrlDn| | | | Tab | 7 | 8 | 9 | + | ) | | + * |-----------+------+------+------+------+------| | | |------+------+------+------+------+-----------| + * | M.Accel 1 | | L | D | R | |------| |------| 4 | 5 | 6 | - | | | + * |-----------+------+------+------+------+------| | |Return|------+------+------+------+------+-----------| + * | M.Accel 0 | |ScrlL | |ScrlR | | | | | 1 | 2 | 3 | = | | | + * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' + * | | XXXX | | | | | 0 | . | , | XXXX | | + * `-----------------------------------' `-----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | XXXX | | + * | | |------| |------| XXXX | | + * | | | | | | XXXX | | + * `--------------------' `--------------------' + */ +[KEYPAD]=KEYMAP(//left half + KC_NO, KC_NO, KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3, KC_NO, KC_NO, + KC_MS_ACCEL2, KC_NO, KC_MS_WH_UP, KC_MS_U, KC_MS_WH_DOWN, KC_NO, KC_NO, + KC_MS_ACCEL1, KC_NO, KC_MS_L, KC_MS_D, KC_MS_R, KC_NO, + KC_MS_ACCEL0, KC_NO, KC_MS_WH_LEFT, KC_NO, KC_MS_WH_RIGHT, KC_NO, KC_NO, + KC_NO, KC_TRNS, KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, + KC_NO, + KC_NO, KC_NO, KC_NO, + //right half + LSFT(KC_TAB), KC_CLEAR, KC_KP_SLASH, KC_KP_ASTERISK, KC_CIRCUMFLEX, KC_LPRN, KC_NO, + KC_TAB, KC_KP_7, KC_KP_8, KC_KP_9, KC_KP_PLUS, KC_RPRN, KC_NO, + KC_KP_4, KC_KP_5, KC_KP_6, KC_KP_MINUS, KC_NO, KC_NO, + KC_KP_ENTER, KC_KP_1, KC_KP_2, KC_KP_3, KC_KP_EQUAL, KC_NO, KC_NO, + KC_KP_0, KC_KP_DOT, KC_KP_COMMA, KC_TRNS, KC_NO, + KC_NO, KC_NO, + KC_NO, + KC_NO, KC_TRNS, KC_NO), + +/* Keymap 2: Functions Layer + * + * ,-----------------------------------------------------. ,-----------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | Vol. Up | + * |-----------+------+------+------+------+-------------| |------+------+------+------+------+------+-----------| + * | | Stop | Rw | Rec | FF | | XXXX | | XXXX | | | | | | Vol. Down | + * |-----------+------+------+------+------+------| XXXX | | XXXX |------+------+------+------+------+-----------| + * | CapsLock | Eject| Prev | Play | Next | |------| |------| Left | Down | Up | Right| | Mute | + * |-----------+------+------+------+------+------| XXXX | | XXXX |------+------+------+------+------+-----------| + * | L Shift | | | | | | XXXX | | XXXX | | | | | | R Shift | + * `-----------+------+------+------+------+-------------' `-------------+------+------+------+------+-----------' + * | XXXXX | | XXXX | XXXX | XXXX | | XXXX | XXXX | XXXX | | XXXXX | + * `-----------------------------------' `-----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + * + * XXX = These keys are transparent keys that, when pressed, they issue the key from the previous layer. + */ +[FN]=KEYMAP(//left half + KC_NO, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, + KC_NO, KC_MEDIA_STOP, KC_MEDIA_REWIND, KC_MEDIA_SELECT, KC_MEDIA_FAST_FORWARD, KC_NO, KC_TRNS, + KC_CAPS, KC_MEDIA_EJECT, KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_NO, + KC_LSFT, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, + KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_TRNS, + KC_NO, KC_NO, + KC_NO, + KC_NO, KC_NO, KC_NO, + //right half + KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_VOLU, + KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_VOLD, + KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_NO, KC_MUTE, + KC_TRNS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_RSFT, + KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_TRNS, + KC_NO, KC_NO, + KC_NO, + KC_NO, KC_NO, KC_NO)}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_ONESHOT(FN), + [2] = ACTION_MODS_ONESHOT(MOD_LSFT), // Sticky shift light. Tap for the next keypress to be shifted. Hold for regular shift. + [3] = ACTION_LAYER_TAP_KEY(KEYPAD, KC_RBRC), +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + // MACRODOWN only works in this function + switch(id) { + case MACRO_TMUX_ESC: + if (record->event.pressed) { + return MACRO(D(LCTRL), T(A), U(LCTRL), D(ESC), END); + } + return MACRO(U(ESC), END); + case MACRO_TMUX_PASTE: + if (record->event.pressed) { + return MACRO(D(LCTRL), T(A), U(LCTRL), D(P), END); + } + return MACRO(U(P), END); + case MACRO_OSX_COPY: + if (record->event.pressed) { + return MACRO(D(LGUI), D(C), END); + } + return MACRO(U(C), U(LGUI), END); + case MACRO_OSX_PASTE: + if (record->event.pressed) { + return MACRO(D(LGUI), D(V), END); + } + return MACRO(U(V), U(LGUI), END); + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { +}; + +uint8_t current_layer = BASE; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + uint8_t layer = biton32(layer_state); + + ergodox_led_all_off(); + ergodox_led_all_set(LED_BRIGHTNESS_LO); + + switch (layer) { + case BASE: + current_layer = BASE; + break; + case KEYPAD: + current_layer = KEYPAD; + break; + default: + // none + break; + } + + // layer leds + if (current_layer == KEYPAD) { + ergodox_right_led_3_on(); + } + + // capslock + if (host_keyboard_leds() & (3<mods & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && // is shift pressed and there is no other + !(keyboard_report->mods & (~MOD_BIT(KC_LSFT) & ~MOD_BIT(KC_RSFT)))) || // modifier being pressed as well + (get_oneshot_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) && !has_oneshot_mods_timed_out())) { // or the one shot shift didn't timed out + ergodox_right_led_1_set(LED_BRIGHTNESS_HI); + ergodox_right_led_1_on(); + } +}; diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/makefile.mk b/keyboard/ergodox_ez/keymaps/townk_osx/makefile.mk new file mode 100644 index 00000000000..e757557bdae --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/townk_osx/makefile.mk @@ -0,0 +1,4 @@ +# I don't want my keyboard blinking lights when is suppose to be asleep. +SLEEP_LED_ENABLE = no + +CONFIG_H = keymaps/$(KEYMAP)/config.h diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/readme.md b/keyboard/ergodox_ez/keymaps/townk_osx/readme.md new file mode 100644 index 00000000000..c2853ca173b --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/townk_osx/readme.md @@ -0,0 +1,77 @@ +# Townk's Keymap + +Trying to take care of an enjury on my arm I borrow an ergonomic keyboard from +a frient ([Kinesis Advantage](http://www.kinesis-ergo.com/shop/advantage-pro-for-pc-mac/)). + +I really enjoyed my time with it but there were some anoyancies: + +* The curvature on the keys bothered me since I'm a Vim user and using the + motion keys on my editor was awkard. +* I had to spend too much time remapping the keyboard to make some symbol keys + more accessible to me. +* The fact that my hands had to stay close to each other was a bit stressfull + to my sholders. + +After a long research I find out that Ergodox EZ would be perfect for my needs +and purchase one. Before the keyboard even got in my hands I started to think +on the layout I would use on it and soon enough I planed couple adjustments +from the Kinesis I was using so far. + +## The layout + +Here are the layout mapping in images so you can have a glimpse on it: + +![Base Layout](townk_osx_base.png) +![fn Layout](townk_osx_fn.png) +![Keypad & Mouse Layout](townk_osx_keypad.png) + +Notice that, differently from the default behavior, my layer keys are not transparent +by default, which means that if you press any non-labeled white key, nothing will be +handled to the OS. + +### One shot keys + +It all started with the access to the function keys (F1, F2, F3...), since +those keys are located on a different layer I needed a way to press them with +minimal effort without disrupting my flow. + +For me, togglihg a layer to press a button and than toggle it back is a waste +of time (although I admit it's a single tap from what I have), so I decided to +do it as a one shot key. I could press it and the next pressed key would be +handled by the target layer which just after it delivers the key to the OS it +would get back to the previous layer. + +After setting up my layout to do just that I realized that occasionally I +would stop myseld on the middle of the process and the one shot layer would be +still triggered until I press any other key. So to prevent me from tapping +keys I don't want I added a timeout of 3 seconds for the one shot actions. + +Ultimately I tested the shift key as a one shot one and really like it, so +here you have it, all the one shot keys on my layout. + +## Glossary + +If you're not familiar with the Mac symbols used on some keys, here is a +reference to them: + +| Symbol | Description | +| :----: | ------------------- | +| ⌘ | Command | +| ⇪ | Caps Lock | +| ⇧ | Shift | +| ⌥ | Option (alt) | +| ⎋ | Esc | +| ⇥ | Tab forward | +| ⇤ | Tab backward | +| ⌃ | Control | +| ␣ | Space | +| ⌫ | Backspace | +| ⌦ | Delete | +| ⏎ | Enter | +| ⌤ | Return | +| ⌽ | Power on/off button | +| ↖ | Home | +| ↘ | End | +| ⇞ | Page up | +| ⇟ | Page down | +| ⌧ | Clear | diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx.hex b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx.hex new file mode 100644 index 00000000000..868d86e82d7 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx.hex differ diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_base.png b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_base.png new file mode 100644 index 00000000000..f9bc8b443a6 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_base.png differ diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_fn.png b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_fn.png new file mode 100644 index 00000000000..983b723480f Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_fn.png differ diff --git a/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_keypad.png b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_keypad.png new file mode 100644 index 00000000000..8f04b4327d4 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/townk_osx/townk_osx_keypad.png differ diff --git a/keyboard/ergodox_ez/keymaps/twey/keymap.c b/keyboard/ergodox_ez/keymaps/twey/keymap.c index 75d264bdbee..019930f2a2d 100644 --- a/keyboard/ergodox_ez/keymaps/twey/keymap.c +++ b/keyboard/ergodox_ez/keymaps/twey/keymap.c @@ -5,8 +5,8 @@ #define BASE 0 // default layer #define SYMB 1 // symbols -#define MDIA 2 // media keys -#define STEN 3 // steno +#define STEN 2 // steno +#define MDIA 3 // media keys const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -17,19 +17,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+------+------+------+-------+-------------| |-------+------+------+------+------+------+--------| * | Del | ' | , | . | P | Y | Esc | | Caps | F | G | C | R | L | / | * |--------+------+------+------+-------+------| | | |------+------+------+------+------+--------| - * | BkSp | A | O | E | U | I |------| |-------| D | H | T | N |S / L2|- / Cmd | + * | BkSp | A | O | E | U | I |------| |-------| D | H | T | N | S | - | * |--------+------+------+------+-------+------| Tab | | Enter |------+------+------+------+------+--------| * | LShift | ; | Q | J | K | X | | | | B | M | W | V | Z | RShift | * `--------+------+------+------+-------+-------------' `--------------+------+------+------+------+--------' - * |Grv/L1| '" |AltShf| Left | Right | | Up | Down | [ | ] | ~L1 | + * | L1 | NONE | Grv | Left | Right | | Up | Down | [ | ] | L1 | * `-----------------------------------' `----------------------------------' - * ,-------------. ,---------------. - * | PgUp | PgDn | | Home | End | - * ,------|------|------| |-------+-------+------. - * | | | NONE | | NONE | | | - * | Alt | NONE |------| |-------| Space | Ctrl | - * | | | Supr | | AltGr | | | - * `--------------------' `----------------------' + * ,--------------. ,---------------. + * | PgUp | PgDn | | Home | End | + * ,------|-------|------| |-------+-------+------. + * | | | NONE | | AltGr | | | + * | Alt | Enter |------| |-------| Space | Ctrl | + * | | | Supr | | ~MDIA | | | + * `---------------------' `----------------------' */ // If it accepts an argument (i.e, is a function), it doesn't need KC_. // Otherwise, it needs KC_* @@ -39,19 +39,19 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_DELT, KC_QUOT, KC_COMM,KC_DOT, KC_P, KC_Y, KC_ESC, KC_BSPC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_TAB, - LT(SYMB,KC_GRV),KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT, + MO(SYMB), KC_NO, KC_GRV, KC_LEFT,KC_RGHT, KC_PGUP,KC_PGDN, KC_NO, KC_LALT,KC_ENT ,KC_LGUI, // right hand - KC_NO, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, - KC_CAPS, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, - KC_D, KC_H, KC_T, KC_N, LT(MDIA, KC_S), GUI_T(KC_MINS), - KC_ENT, KC_B, KC_M, KC_W, KC_V, KC_Z , KC_RSFT, - KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, - KC_HOME,KC_END, - KC_NO, - KC_RALT,KC_SPC,KC_RCTL + KC_NO, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, + KC_CAPS, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, + KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, + KC_ENT, KC_B, KC_M, KC_W, KC_V, KC_Z , KC_RSFT, + KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, MO(SYMB), + KC_HOME, KC_END, + KC_RALT, + MO(MDIA),KC_SPC,KC_RCTL ), /* Keymap 1: Symbol Layer * @@ -95,24 +95,46 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), -/* Keymap 2: Media and mouse keys + +[STEN] = KEYMAP( // layout: layer 2: Steno for Plover + // left hand + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, + KC_NO, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_STAR, + KC_NO, PV_LS, PV_LT, PV_LP, PV_LH, PV_STAR, + KC_NO, PV_LS, PV_LK, PV_LW, PV_LR, PV_STAR, PV_STAR, + KC_TRNS,KC_NO, KC_NO, KC_TRNS, KC_TRNS, + KC_NO, KC_NO, + KC_NO, + PV_A, PV_O, KC_NO, + // right hand + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + PV_STAR, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, + PV_STAR, PV_RF, PV_RP, PV_RL, PV_RT, PV_RD, + PV_STAR, PV_STAR, PV_RR, PV_RB, PV_RG, PV_RS, PV_RZ, + KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_TRNS, + KC_NO, KC_NO, + KC_NO, + KC_TRNS,PV_E, PV_U +), + +/* Keymap 3: Media and mouse keys * * ,--------------------------------------------------. ,--------------------------------------------------. * | | | | | | | | | | | | | | | | * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| - * | | | | MsUp | | | | | | | | | | | | + * | | | | MsUp | | | | | | | Back | | Frwd | | | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| - * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | Play | + * | | |MsLeft|MsDown|MsRght| |------| |------| | Prev | Play | Next | | | * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| - * | | | | | | | | | | | | Prev | Next | | | + * | | | | | | | | | | | | | | | | * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | | * `----------------------------------' `----------------------------------' * ,-------------. ,-------------. * | | | | | | * ,------|------|------| |------+------+------. - * | | | | | | |Brwser| - * | | |------| |------| |Back | + * | | | | | | | | + * | | |------| |------| | | * | | | | | | | | * `--------------------' `--------------------' */ @@ -128,39 +150,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, // right hand KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK, KC_TRNS, KC_WFWD, KC_TRNS, KC_TRNS, + KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MPLY, - KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_WBAK ), - -[STEN] = KEYMAP( // layout: layer 4: Steno for Plover - // left hand - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_TRNS, - KC_NO, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_STAR, - KC_NO, PV_LS, PV_LT, PV_LP, PV_LH, PV_STAR, - KC_NO, PV_LS, PV_LK, PV_LW, PV_LR, PV_STAR, PV_STAR, - KC_NO, KC_NO, KC_NO, KC_TRNS, KC_TRNS, - KC_NO, KC_NO, - KC_NO, - PV_A, PV_O, KC_NO, - // right hand - KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, - PV_STAR, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, PV_NUM, - PV_STAR, PV_RF, PV_RP, PV_RL, PV_RT, PV_RD, - PV_STAR, PV_STAR, PV_RR, PV_RB, PV_RG, PV_RS, PV_RZ, - KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_NO, - KC_NO, KC_NO, - KC_NO, - KC_NO, PV_E, PV_U -), }; const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) + [1] = ACTION_LAYER_TAP_TOGGLE(MDIA) // FN1 - Momentary Layer 3 (Media) }; void toggle_steno(int pressed) @@ -170,15 +171,19 @@ void toggle_steno(int pressed) if (pressed) { if (layer != STEN) layer_on(STEN); else layer_off(STEN); - register_code(PV_LS); + register_code(PV_LP); register_code(PV_LH); - register_code(PV_RF); - register_code(PV_RT); + register_code(PV_LR); + register_code(PV_O); + register_code(PV_RL); + register_code(PV_RG); } else { - unregister_code(PV_LS); + unregister_code(PV_LP); unregister_code(PV_LH); - unregister_code(PV_RF); - unregister_code(PV_RT); + unregister_code(PV_LR); + unregister_code(PV_O); + unregister_code(PV_RL); + unregister_code(PV_RG); } } @@ -200,26 +205,17 @@ void matrix_init_user(void) { // Runs constantly in the background, in a loop. void matrix_scan_user(void) { - uint8_t layer = biton32(layer_state); + uint32_t layer0 = layer_state & (1UL << 0), + layer1 = layer_state & (1UL << 1), + layer2 = layer_state & (1UL << 2), + layer3 = layer_state & (1UL << 3); ergodox_board_led_off(); ergodox_right_led_1_off(); ergodox_right_led_2_off(); ergodox_right_led_3_off(); - switch (layer) { - // TODO: Make this relevant to the ErgoDox EZ. - case 1: - ergodox_right_led_1_on(); - break; - case 2: - ergodox_right_led_2_on(); - break; - case 3: - ergodox_right_led_3_on(); - break; - default: - // none - break; - } + if (layer1) ergodox_right_led_1_on(); + if (layer2) ergodox_right_led_2_on(); + if (layer3) ergodox_right_led_3_on(); }; diff --git a/keyboard/ergodox_ez/keymaps/twey/readme.md b/keyboard/ergodox_ez/keymaps/twey/readme.md index d44c0a23822..979e4261e58 100644 --- a/keyboard/ergodox_ez/keymaps/twey/readme.md +++ b/keyboard/ergodox_ez/keymaps/twey/readme.md @@ -3,8 +3,8 @@ - Layer 0: Non-ANSI Dvorak layout, with modified modifiers — all modifiers on thumb keys, as well as return and space. - Layer 1: Default symbol layout. -- Layer 2: Default media/mouse layout. -- Layer 3: Plover-oriented stenography layer. +- Layer 2: Plover-oriented stenography layer. +- Layer 3: Extended media/mouse layout. ## Unusual features The Plover key (top right key on the left half) also sends my Plover @@ -12,8 +12,6 @@ The Plover key (top right key on the left half) also sends my Plover layer, so you can toggle between steno and typing modes with a single keypress. -If you want to use this feature, you'll need to add: - - "SH-FT": "{PLOVER:TOGGLE}" - -to your Plover dictionary. +If you want to use this feature, you'll need to add the +`commands.json` dictionary to your Plover dictionaries, or define the +toggle stroke (`PHROLG`) yourself. diff --git a/keyboard/ergodox_ez/keymaps/zweihander-osx/keymap.c b/keyboard/ergodox_ez/keymaps/zweihander-osx/keymap.c new file mode 100644 index 00000000000..e9963886be3 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/zweihander-osx/keymap.c @@ -0,0 +1,187 @@ +#include "ergodox_ez.h" +#include "debug.h" +#include "action_layer.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | ← | | → | 6 | 7 | 8 | 9 | 0 | - | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | ⌦ | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | ⌫ | A | S | D | F | G |------| |------| H | J | K | L |; / L2| ' / L⌘ | + * |--------+------+------+------+------+------| L⌘ | | L⌘ |------+------+------+------+------+--------| + * | L⇧ | Z | X | C | V | B | | | | N | M | , | . | / / ⌃| R⇧ | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | L⌃ | L⌥ | L⌘ | ← | → | | ↑ | ↓ | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,---------------. + * | `~ | '" | | ⎋ | ⌫ | + * ,------|------|------| |------+--------+------. + * | | | PgUp | | PgDn | | | + * | | ⌫ |------| |------| ⇥ |Enter | + * | | | L⌥ | | L⌃ | | | + * `--------------------' `----------------------' + */ +// If it accepts an argument (i.e, is a function), it doesn't need KC_. +// Otherwise, it needs KC_* +[BASE] = KEYMAP( // layer 0 : default + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT, + KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB), + KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LGUI, + KC_LCTL, KC_LALT, KC_LGUI,KC_LEFT,KC_RGHT, + KC_GRV, KC_QUOT, + KC_PGUP, + KC_SPC,KC_BSPC,KC_LALT, + // right hand + KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),GUI_T(KC_QUOT), + KC_LGUI, KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT, + KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1, + KC_ESC, KC_BSPC, + KC_PGDN, + KC_LCTL, KC_TAB, KC_ENT + ), +/* Keymap 1: Symbol Layer + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | [ | ] | { | } | | | | | / | 7 | 8 | 9 | * | F12 | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | < | > | ( | ) | |------| |------| - | 4 | 5 | 6 | + | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | | & | 1 | 2 | 3 | = | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | | 0 | . | ← | → | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | Home | | | + * | | |------| |------| | | + * | | | | | End | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = KEYMAP( + // left hand + KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_TRNS,KC_LBRC,KC_RBRC,KC_LCBR,KC_RCBR,KC_TRNS,KC_TRNS, + KC_TRNS,KC_LABK,KC_RABK,KC_LPRN,KC_RPRN,KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS, + KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_SLSH, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_MINS, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_EQL, KC_TRNS, + KC_0, KC_DOT, KC_LEFT, KC_RGHT, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_HOME, + KC_END , KC_TRNS, KC_TRNS +), +/* Keymap 2: Media keys + * + * ,--------------------------------------------------. ,--------------------------------------------------. + * | | F14 | F15 | | | | | | ⌘Q | ⌘W | ⌘⇧` | ⌘` | ⌥⇧⇥ | ⌥⇥ | Power | + * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------| + * | | | | PgUp | | | | | | ⌘] | ⌥⌘↑ | ↑ | ⌥⌘↓ | | | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | Home | PgDn | End | |------| |------| ⌘[ | ← | ↓ | → | | ⏯ | + * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------| + * | | | | | | | | | |L⇧+Spc| Spc | ⏮ | ⏭ | | | + * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------' + * | | | | | | |VolUp |VolDn | Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| ⌘C | ⌘V | + * | | | | | ⌘X | | | + * `--------------------' `--------------------' + */ +// MEDIA AND MOUSE +[MDIA] = KEYMAP( + KC_TRNS, KC_F14 , KC_F15 , KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, /* F14 dims screen, F15 brightens */ + KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_HOME, KC_PGDN, KC_END , KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + LGUI(KC_Q), LGUI(KC_W), LGUI(LSFT(KC_GRV)), LGUI(KC_GRV), LALT(LSFT(KC_TAB)), LALT(KC_TAB), KC_PWR, + KC_TRNS, LGUI(KC_RBRC), LGUI(LALT(KC_UP)), KC_UP , LGUI(LALT(KC_DOWN)), KC_TRNS, KC_TRNS, + LGUI(KC_LBRC), KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_MPLY, + KC_TRNS, LSFT(KC_SPC), KC_SPC , KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + LGUI(KC_X), LGUI(KC_C), LGUI(KC_V) +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +// action_get_macro() is unused — remove the “#if 0” and “#endif” lines to reenable +#if 0 +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; +#endif + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/keyboard/ergodox_ez/keymaps/zweihander-osx/readme.markdown b/keyboard/ergodox_ez/keymaps/zweihander-osx/readme.markdown new file mode 100644 index 00000000000..7bce7c69096 --- /dev/null +++ b/keyboard/ergodox_ez/keymaps/zweihander-osx/readme.markdown @@ -0,0 +1,45 @@ +# The Zweihander Layout + +NB: the backtick (\`) is special in Markdown. If I write ⌘\` in this readme, I mean “command-backtick”, not “command-backslash-backtick”. + +This layout is tuned for people who… + + +## use OS X + +This layout doesn’t make any concessions for Windows use. While it should work fine in Windows, I’m not about to devote precious keyboard space to Windows-specific shortcuts. + + +## mouse left-handed while doing other things with the right hand + +I tend to have my mouse in my left hand, but I like to use my other hand to make things go faster. I’ve added a bunch of buttons to the media layer to speed up browsing in Safari and Finder: + +- Close Window (⌘W) +- Back (⌘[) +- Forward (⌘]) +- Open and Close Parent Folder (⌥⌘↓) +- Go Up and Close Just-Left Folder (⌥⌘↑) +- Cycle through open windows in current application (⌘\` and ⌘⇧\`) +- Cycle through tabs in current window (⌥⇥ and ⌥⇧⇥) +- Space (page down in browsers; Quick Look in the Finder) +- Shift-Space (page up in web browsers) + +Because moving letter-by-letter is way slower than moving word-by-word, I added Option (⌥) to the bottommost button on the left side. This key can be held easily while holding ; (activate media layer) and pressing J and L to move left and right by word. + + +## use lots of modifier keys in OS X menu-item shortcuts + +I wanted to preserve the feel of a number of shortcuts that involve pressing lots of modifier keys at once; this is why the bottom left of the keyboard has shift, control, option, and command in the usual spaces. Further, some common shortcuts I press have a key on the right side of the keyboard. These shortcuts include: + +- Empty Trash Without Asking for Confirmation (⇧⌥⌘⌫) +- Shut Down Without Asking for Confirmation (⇧⌥⌘ power) + + +## use Emacs-style shortcuts + +I press C-a, C-e, and C-k all the time. It’s difficult to press these key combinations with the control key on the bottom left and I’m too quick on the draw for the control function on the / key to work reliably, so the bottommost thumb button on the right side is another control key. + + +## use spreadsheets + +All the common spreadsheet operations (+-*/=) are now on the right side of the symbol layer. diff --git a/keyboard/ergodox_ez/keymaps/zweihander-osx/zweihander-osx.hex b/keyboard/ergodox_ez/keymaps/zweihander-osx/zweihander-osx.hex new file mode 100644 index 00000000000..b76c3ec8e84 Binary files /dev/null and b/keyboard/ergodox_ez/keymaps/zweihander-osx/zweihander-osx.hex differ diff --git a/keyboard/ergodox_ez/readme.md b/keyboard/ergodox_ez/readme.md index 4afb42c8fd5..97a10ff4d8f 100644 --- a/keyboard/ergodox_ez/readme.md +++ b/keyboard/ergodox_ez/readme.md @@ -17,7 +17,7 @@ This requires a little bit of familiarity with coding. 2. Clone the repository (download it) 3. Set up a build environment as per [the build guide](/BUILD_GUIDE.md) - Using a Mac and have homebrew? just run `brew tap osx-cross/avr && brew install avr-libc` -4. Copy `keymaps/default/keymap.c` into `keymaps/your_name/keymap.c` (for example, `keymaps/german/keymap.c`) +4. Copy `keyboard/ergodox_ez/keymaps/default/keymap.c` into `keymaps/your_name/keymap.c` (for example, `keymaps/german/keymap.c`) 5. Edit this file, changing keycodes to your liking (see "Finding the keycodes you need" below). Try to edit the comments as well, so the "text graphics" represent your layout correctly. See below for more tips on sharing your work. 6. Compile your firmware by running `make clean` followed by `make KEYMAP=your_name`. For example, `make KEYMAP=german`. This will result in a hex file, which will always be called `ergodox_ez.hex`, regardless of your keymap name. 6. Flash this hex file using the [Teensy loader](https://www.pjrc.com/teensy/loader.html) as described in step 4 in the "Easy Way" above. diff --git a/keyboard/gh60_rev_c/config.h b/keyboard/gh60_rev_c/config.h index 2fd8f574396..827c08d1be5 100644 --- a/keyboard/gh60_rev_c/config.h +++ b/keyboard/gh60_rev_c/config.h @@ -41,15 +41,16 @@ along with this program. If not, see . * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * -*/ -#define COLS (int []){ F0, F1, E6, C7, C6, B6, D4, B1, B7, B5, B4, D7, D6, B3 } -#define ROWS (int []){ D0, D1, D2, D3, D5 } +*/ +#define MATRIX_ROW_PINS { D0, D1, D2, D3, D5 } +#define MATRIX_COL_PINS { F0, F1, E6, C7, C6, B6, D4, B1, B7, B5, B4, D7, D6, B3 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* define if matrix has ghost (lacks anti-ghosting diodes) */ //#define MATRIX_HAS_GHOST @@ -62,17 +63,17 @@ along with this program. If not, see . /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -/* +/* * Force NKRO * - * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the * makefile for this to work.) * * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) * until the next keyboard reset. * - * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is * fully operational during normal computer usage. * * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) @@ -90,7 +91,7 @@ along with this program. If not, see . * the keyboard. They are best used in combination with the HID Listen program, * found here: https://www.pjrc.com/teensy/hid_listen.html * - * The options below allow the magic key functionality to be changed. This is + * The options below allow the magic key functionality to be changed. This is * useful if your keyboard/keypad is missing keys and you want magic key support. * */ diff --git a/keyboard/gh60_rev_c/gh60.c b/keyboard/gh60_rev_c/gh60.c index 8e7219bfe8c..6da4d8ee3e1 100644 --- a/keyboard/gh60_rev_c/gh60.c +++ b/keyboard/gh60_rev_c/gh60.c @@ -12,8 +12,9 @@ void matrix_scan_user(void) { } __attribute__ ((weak)) -void process_action_user(keyrecord_t *record) { +bool process_action_user(keyrecord_t *record) { // leave this function blank - it can be defined in a keymap file + return true; } __attribute__ ((weak)) @@ -35,11 +36,11 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -void process_action_kb(keyrecord_t *record) { +bool process_action_kb(keyrecord_t *record) { // put your per-action keyboard code here // runs for every action, just before processing by the firmware - process_action_user(record); + return process_action_user(record); } void led_set_kb(uint8_t usb_led) { diff --git a/keyboard/gh60_rev_c/gh60.h b/keyboard/gh60_rev_c/gh60.h index 2373ad333c3..95e5e1ebc72 100644 --- a/keyboard/gh60_rev_c/gh60.h +++ b/keyboard/gh60_rev_c/gh60.h @@ -75,7 +75,7 @@ inline void gh60_wasd_leds_off(void) { DDRF &= ~(1<<7); PORTF &= ~(1<<7); } void matrix_init_user(void); void matrix_scan_user(void); -void process_action_user(keyrecord_t *record); +bool process_action_user(keyrecord_t *record); void led_set_user(uint8_t usb_led); #endif diff --git a/keyboard/jd45/config.h b/keyboard/jd45/config.h index 1b81fe32ed3..ffedb6a1a98 100644 --- a/keyboard/jd45/config.h +++ b/keyboard/jd45/config.h @@ -30,11 +30,12 @@ along with this program. If not, see . /* key matrix size */ #define MATRIX_ROWS 4 -#define MATRIX_COLS 13 +#define MATRIX_COLS 13 /* Planck PCB default pin-out */ -#define COLS (int []){F4, D7, B5, B6, C6, C7, D4, D6, D5, D0, D1, D2, B0} -#define ROWS (int []){F0, F1, F5, B4} +#define MATRIX_ROW_PINS { F0, F1, F5, B4 } +#define MATRIX_COL_PINS { F4, D7, B5, B6, C6, C7, D4, D6, D5, D0, D1, D2, B0 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -46,7 +47,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile index 01d9e3ce9a5..c0c6201cba3 100644 --- a/keyboard/planck/Makefile +++ b/keyboard/planck/Makefile @@ -171,10 +171,6 @@ endif endif -ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) - SRC := backlight.c $(SRC) -endif - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c deleted file mode 100644 index f69364b2afb..00000000000 --- a/keyboard/planck/backlight.c +++ /dev/null @@ -1,61 +0,0 @@ - -#include -#include "backlight.h" - -#define CHANNEL OCR1C - -void backlight_init_ports() -{ - - // Setup PB7 as output and output low. - DDRB |= (1<<7); - PORTB &= ~(1<<7); - - // Use full 16-bit resolution. - ICR1 = 0xFFFF; - - // I could write a wall of text here to explain... but TL;DW - // Go read the ATmega32u4 datasheet. - // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on - - // Pin PB7 = OCR1C (Timer 1, Channel C) - // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 - // (i.e. start high, go low when counter matches.) - // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 - // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 - - TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; - TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; - - backlight_init(); -} - -void backlight_set(uint8_t level) -{ - if ( level == 0 ) - { - // Turn off PWM control on PB7, revert to output low. - TCCR1A &= ~(_BV(COM1C1)); - CHANNEL = 0x0; - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - } - else if ( level == BACKLIGHT_LEVELS ) - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF; - } - else - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); - } -} \ No newline at end of file diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h index 7d64f09773f..b6489310819 100644 --- a/keyboard/planck/config.h +++ b/keyboard/planck/config.h @@ -33,8 +33,9 @@ along with this program. If not, see . #define MATRIX_COLS 12 /* Planck PCB default pin-out */ -#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } -#define ROWS (int []){ D0, D5, B5, B6 } +#define MATRIX_ROW_PINS { D0, D5, B5, B6 } +#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -46,7 +47,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/planck/keymaps/alexey.c b/keyboard/planck/keymaps/alexey/alexey.c similarity index 100% rename from keyboard/planck/keymaps/alexey.c rename to keyboard/planck/keymaps/alexey/alexey.c diff --git a/keyboard/planck/keymaps/angerthosenear.c b/keyboard/planck/keymaps/angerthosenear/angerthosenear.c similarity index 100% rename from keyboard/planck/keymaps/angerthosenear.c rename to keyboard/planck/keymaps/angerthosenear/angerthosenear.c diff --git a/keyboard/planck/keymaps/austin.c b/keyboard/planck/keymaps/austin/austin.c similarity index 100% rename from keyboard/planck/keymaps/austin.c rename to keyboard/planck/keymaps/austin/austin.c diff --git a/keyboard/planck/keymaps/bone2planck.c b/keyboard/planck/keymaps/bone2planck/bone2planck.c similarity index 100% rename from keyboard/planck/keymaps/bone2planck.c rename to keyboard/planck/keymaps/bone2planck/bone2planck.c diff --git a/keyboard/planck/keymaps/brandon.c b/keyboard/planck/keymaps/brandon/brandon.c similarity index 100% rename from keyboard/planck/keymaps/brandon.c rename to keyboard/planck/keymaps/brandon/brandon.c diff --git a/keyboard/planck/keymaps/charlie.c b/keyboard/planck/keymaps/charlie/charlie.c similarity index 100% rename from keyboard/planck/keymaps/charlie.c rename to keyboard/planck/keymaps/charlie/charlie.c diff --git a/keyboard/planck/keymaps/daniel.c b/keyboard/planck/keymaps/daniel/daniel.c similarity index 100% rename from keyboard/planck/keymaps/daniel.c rename to keyboard/planck/keymaps/daniel/daniel.c diff --git a/keyboard/planck/keymaps/david.c b/keyboard/planck/keymaps/david/david.c similarity index 100% rename from keyboard/planck/keymaps/david.c rename to keyboard/planck/keymaps/david/david.c diff --git a/keyboard/planck/keymaps/default/keymap.c b/keyboard/planck/keymaps/default/keymap.c index fa9c3915a8d..3d62898171d 100644 --- a/keyboard/planck/keymaps/default/keymap.c +++ b/keyboard/planck/keymaps/default/keymap.c @@ -19,8 +19,7 @@ extern keymap_config_t keymap_config; #define _DVORAK 2 #define _LOWER 3 #define _RAISE 4 -#define _MUSIC 5 -#define _PLOVER 6 +#define _PLOVER 5 #define _ADJUST 16 // Macro name shortcuts @@ -30,14 +29,9 @@ extern keymap_config_t keymap_config; #define LOWER M(_LOWER) #define RAISE M(_RAISE) #define M_BL 5 -#define AUD_OFF M(6) -#define AUD_ON M(7) -#define MUS_OFF M(8) -#define MUS_ON M(9) -#define VC_IN M(10) -#define VC_DE M(11) #define PLOVER M(12) #define EXT_PLV M(13) +#define TOG_OUT M(14) // Fillers to make layering more clear #define _______ KC_TRNS @@ -105,7 +99,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+-------------+------+------+------+------+------| * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' @@ -113,7 +107,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_LOWER] = { {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, @@ -123,7 +117,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+-------------+------+------+------+------+------| * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' @@ -131,27 +125,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_RAISE] = { {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, -/* Music (reserved for process_action_user) - * - */ -[_MUSIC] = { - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, LOWER, XXXXXXX, XXXXXXX, RAISE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX} -}, - /* Plover layer (http://opensteno.org) * ,-----------------------------------------------------------------------------------. * | # | # | # | # | # | # | # | # | # | # | # | # | * |------+------+------+------+------+-------------+------+------+------+------+------| * | | S | T | P | H | * | * | F | P | L | T | D | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | S | K | W | R | * | * | R | B | G | S | Z | + * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | * |------+------+------+------+------+------+------+------+------+------+------+------| * | Exit | | | A | O | | E | U | | | | * `-----------------------------------------------------------------------------------' @@ -160,7 +144,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_PLOVER] = { {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, - {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {TOG_OUT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} }, @@ -177,8 +161,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { */ [_ADJUST] = { {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, - {_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, - {_______, VC_DE, VC_IN, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, + {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } @@ -190,22 +174,16 @@ const uint16_t PROGMEM fn_actions[] = { }; #ifdef AUDIO_ENABLE -float tone_startup[][2] = { - {440.0*pow(2.0,(31)/12.0), 12}, - {440.0*pow(2.0,(28)/12.0), 8}, - {440.0*pow(2.0,(19)/12.0), 8}, - {440.0*pow(2.0,(24)/12.0), 8}, - {440.0*pow(2.0,(28)/12.0), 20} -}; +float tone_startup[][2] = SONG(STARTUP_SOUND); float tone_qwerty[][2] = SONG(QWERTY_SOUND); float tone_dvorak[][2] = SONG(DVORAK_SOUND); float tone_colemak[][2] = SONG(COLEMAK_SOUND); float tone_plover[][2] = SONG(PLOVER_SOUND); float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); +float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); -float goodbye[][2] = SONG(GOODBYE_SOUND); +float tone_goodbye[][2] = SONG(GOODBYE_SOUND); #endif @@ -269,63 +247,15 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) unregister_code(KC_RSFT); } break; - case 6: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_off(); - #endif - } - break; - case 7: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_on(); - PLAY_NOTE_ARRAY(tone_startup, false, 0); - #endif - } - break; - case 8: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - layer_off(_MUSIC); - stop_all_notes(); - #endif - } - break; - case 9: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(music_scale, false, 0); - layer_on(_MUSIC); - #endif - } - break; - case 10: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - voice_iterate(); - PLAY_NOTE_ARRAY(music_scale, false, 0); - #endif - } - break; - case 11: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - voice_deiterate(); - PLAY_NOTE_ARRAY(music_scale, false, 0); - #endif - } - break; case 12: if (record->event.pressed) { #ifdef AUDIO_ENABLE + stop_all_notes(); PLAY_NOTE_ARRAY(tone_plover, false, 0); #endif layer_off(_RAISE); layer_off(_LOWER); layer_off(_ADJUST); - layer_off(_MUSIC); - stop_all_notes(); layer_on(_PLOVER); if (!eeconfig_is_enabled()) { eeconfig_init(); @@ -343,37 +273,44 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) layer_off(_PLOVER); } break; - + case 14: + if (record->event.pressed) { + return MACRO( D(E), D(R), D(F), D(V), D(O), D(L), U(E), U(R), U(F), U(V), U(O), U(L), END ); + } + break; } return MACRO_NONE; }; void matrix_init_user(void) { - #ifdef AUDIO_ENABLE - _delay_ms(20); // stops the tick - PLAY_NOTE_ARRAY(tone_startup, false, 0); - #endif + #ifdef AUDIO_ENABLE + startup_user(); + #endif } #ifdef AUDIO_ENABLE -void play_goodbye_tone() + +void startup_user() { - PLAY_NOTE_ARRAY(goodbye, false, 0); - _delay_ms(150); + _delay_ms(20); // gets rid of tick + PLAY_NOTE_ARRAY(tone_startup, false, 0); } -uint8_t starting_note = 0x0C; -int offset = 7; - -void process_action_user(keyrecord_t *record) { - - if (IS_LAYER_ON(_MUSIC)) { - if (record->event.pressed) { - play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); - } else { - stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); - } - } - +void shutdown_user() +{ + PLAY_NOTE_ARRAY(tone_goodbye, false, 0); + _delay_ms(150); + stop_all_notes(); } + +void music_on_user(void) +{ + music_scale_user(); +} + +void music_scale_user(void) +{ + PLAY_NOTE_ARRAY(music_scale, false, 0); +} + #endif diff --git a/keyboard/planck/keymaps/dzobert.c b/keyboard/planck/keymaps/dzobert/dzobert.c similarity index 100% rename from keyboard/planck/keymaps/dzobert.c rename to keyboard/planck/keymaps/dzobert/dzobert.c diff --git a/keyboard/planck/keymaps/experimental/README.md b/keyboard/planck/keymaps/experimental/README.md new file mode 100644 index 00000000000..de9680b4985 --- /dev/null +++ b/keyboard/planck/keymaps/experimental/README.md @@ -0,0 +1,2 @@ +# The Default Planck Layout + diff --git a/keyboard/planck/keymaps/experimental/keymap.c b/keyboard/planck/keymaps/experimental/keymap.c new file mode 100644 index 00000000000..4b9c15e0841 --- /dev/null +++ b/keyboard/planck/keymaps/experimental/keymap.c @@ -0,0 +1,333 @@ +// This is the canonical layout file for the Quantum project. If you want to add another keyboard, +// this is the style you want to emulate. + +#include "planck.h" +#include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif + +#include "eeconfig.h" + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +#define _QWERTY 0 +#define _COLEMAK 1 +#define _DVORAK 2 +#define _LOWER 3 +#define _RAISE 4 +#define _PLOVER 5 +#define _ADJUST 16 + +// Macro name shortcuts +#define QWERTY M(_QWERTY) +#define COLEMAK M(_COLEMAK) +#define DVORAK M(_DVORAK) +#define LOWER M(_LOWER) +#define RAISE M(_RAISE) +#define M_BL 5 +#define PLOVER M(12) +#define EXT_PLV M(13) + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Qwerty + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | S | D | F | G | H | J | K | L | ; | " | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_QWERTY] = { + {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, + {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Colemak + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | R | S | T | D | H | N | E | I | O | " | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_COLEMAK] = { + {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, + {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, + {KC_LEAD, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Dvorak + * ,-----------------------------------------------------------------------------------. + * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | O | E | U | I | D | H | T | N | S | / | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_DVORAK] = { + {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, + {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, + {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Lower + * ,-----------------------------------------------------------------------------------. + * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_LOWER] = { + {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Raise + * ,-----------------------------------------------------------------------------------. + * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_RAISE] = { + {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUHS, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Plover layer (http://opensteno.org) + * ,-----------------------------------------------------------------------------------. + * | # | # | # | # | # | # | # | # | # | # | # | # | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | S | T | P | H | * | * | F | P | L | T | D | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | S | K | W | R | * | * | R | B | G | S | Z | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Exit | | | A | O | | E | U | | | | + * `-----------------------------------------------------------------------------------' + */ + +[_PLOVER] = { + {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, + {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, + {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} +}, + +/* Adjust (Lower + Raise) + * ,-----------------------------------------------------------------------------------. + * | | Reset| | | | | | | | | | Del | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_ADJUST] = { + {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, + {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, + {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} +} + + +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +#ifdef AUDIO_ENABLE +float tone_startup[][2] = { + {440.0*pow(2.0,(31)/12.0), 12}, + {440.0*pow(2.0,(28)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, + {440.0*pow(2.0,(28)/12.0), 20} +}; + +float tone_qwerty[][2] = SONG(QWERTY_SOUND); +float tone_dvorak[][2] = SONG(DVORAK_SOUND); +float tone_colemak[][2] = SONG(COLEMAK_SOUND); +float tone_plover[][2] = SONG(PLOVER_SOUND); +float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); + +float goodbye[][2] = SONG(GOODBYE_SOUND); +#endif + + +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case _QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_qwerty, false, 0); + #endif + persistant_default_layer_set(1UL<<_QWERTY); + } + break; + case _COLEMAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_colemak, false, 0); + #endif + persistant_default_layer_set(1UL<<_COLEMAK); + } + break; + case _DVORAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_dvorak, false, 0); + #endif + persistant_default_layer_set(1UL<<_DVORAK); + } + break; + case _LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + #ifdef BACKLIGHT_ENABLE + breathing_speed_set(2); + breathing_pulse(); + #endif + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + break; + case _RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + #ifdef BACKLIGHT_ENABLE + breathing_speed_set(2); + breathing_pulse(); + #endif + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + break; + case M_BL: + if (record->event.pressed) { + register_code(KC_RSFT); + #ifdef BACKLIGHT_ENABLE + backlight_step(); + #endif + } else { + unregister_code(KC_RSFT); + } + break; + case 12: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_NOTE_ARRAY(tone_plover, false, 0); + #endif + layer_off(_RAISE); + layer_off(_LOWER); + layer_off(_ADJUST); + layer_on(_PLOVER); + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + keymap_config.raw = eeconfig_read_keymap(); + keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); + } + break; + case 13: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); + #endif + layer_off(_PLOVER); + } + break; + + } + return MACRO_NONE; +}; + +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + _delay_ms(20); // stops the tick + PLAY_NOTE_ARRAY(tone_startup, false, 0); + #endif +} + +#ifdef AUDIO_ENABLE + void play_goodbye_tone(void) + { + PLAY_NOTE_ARRAY(goodbye, false, 0); + _delay_ms(150); + } +#endif + +LEADER_EXTERNS(); + +#define LEADER_TIMEOUT 300 + +void matrix_scan_user(void) { + LEADER_DICTIONARY() { + leading = false; + leader_end(); + + SEQ_ONE_KEY(KC_F) { + register_code(KC_S); + unregister_code(KC_S); + } + SEQ_TWO_KEYS(KC_A, KC_S) { + register_code(KC_H); + unregister_code(KC_H); + } + SEQ_THREE_KEYS(KC_A, KC_S, KC_D) { + register_code(KC_LGUI); + register_code(KC_S); + unregister_code(KC_S); + unregister_code(KC_LGUI); + } + } +} diff --git a/keyboard/planck/keymaps/experimental/makefile.mk b/keyboard/planck/keymaps/experimental/makefile.mk new file mode 100644 index 00000000000..6c1e05b65a7 --- /dev/null +++ b/keyboard/planck/keymaps/experimental/makefile.mk @@ -0,0 +1,5 @@ +AUDIO_ENABLE = yes +NKRO_ENABLE = yes +MIDI_ENABLE = yes +BACKLIGHT_ENABLE = no +COMMAND_ENABLE = no \ No newline at end of file diff --git a/keyboard/planck/keymaps/gabriel.c b/keyboard/planck/keymaps/gabriel/gabriel.c similarity index 100% rename from keyboard/planck/keymaps/gabriel.c rename to keyboard/planck/keymaps/gabriel/gabriel.c diff --git a/keyboard/planck/keymaps/jacob/Keyboard Layout.PNG b/keyboard/planck/keymaps/jacob/Keyboard Layout.PNG new file mode 100644 index 00000000000..40f0b89429f Binary files /dev/null and b/keyboard/planck/keymaps/jacob/Keyboard Layout.PNG differ diff --git a/keyboard/planck/keymaps/jacob/keymap.c b/keyboard/planck/keymaps/jacob/keymap.c new file mode 100644 index 00000000000..5e6e8498e2f --- /dev/null +++ b/keyboard/planck/keymaps/jacob/keymap.c @@ -0,0 +1,56 @@ +#include "planck.h" +#include "action_layer.h" +#ifdef BACKLIGHT_ENABLE + #include "backlight.h" +#endif + +//Simple Keymap where CTRL, WINKEY, and ALT keys are placed in a more familiar location for Windows users. +//Focus of this particular keymap is to enable easy transition from more traditional keyboards to OLKB Planck. + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +#define _QW 0 +#define _LW 1 +#define _RS 2 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QW] = { /* Qwerty */ + {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, + {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MT(MOD_RSFT, KC_ENT)}, + {KC_LCTL, KC_LGUI, KC_LALT, M(0), MO(_LW), KC_SPC, KC_SPC, MO(_RS), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} + }, + [_RS] = { /* RAISE */ + {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL }, + {KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS}, + {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS} + }, + [_LW] = { /* LOWER */ + {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL }, + {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, KC_RBRC, KC_TRNS}, + {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS} + } +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + #ifdef BACKLIGHT_ENABLE + backlight_step(); + #endif + } else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; diff --git a/keyboard/planck/keymaps/jacob/readme.md b/keyboard/planck/keymaps/jacob/readme.md new file mode 100644 index 00000000000..2a4be4ebcea --- /dev/null +++ b/keyboard/planck/keymaps/jacob/readme.md @@ -0,0 +1 @@ +Focus of this particular keymap is to enable easy transition from more traditional keyboards to OLKB Planck. \ No newline at end of file diff --git a/keyboard/planck/keymaps/joe.c b/keyboard/planck/keymaps/joe/joe.c similarity index 100% rename from keyboard/planck/keymaps/joe.c rename to keyboard/planck/keymaps/joe/joe.c diff --git a/keyboard/planck/keymaps/kyle.c b/keyboard/planck/keymaps/kyle/kyle.c similarity index 100% rename from keyboard/planck/keymaps/kyle.c rename to keyboard/planck/keymaps/kyle/kyle.c diff --git a/keyboard/planck/keymaps/leo.c b/keyboard/planck/keymaps/leo/leo.c similarity index 100% rename from keyboard/planck/keymaps/leo.c rename to keyboard/planck/keymaps/leo/leo.c diff --git a/keyboard/planck/keymaps/lucas.c b/keyboard/planck/keymaps/lucas/lucas.c similarity index 100% rename from keyboard/planck/keymaps/lucas.c rename to keyboard/planck/keymaps/lucas/lucas.c diff --git a/keyboard/planck/keymaps/lukas.c b/keyboard/planck/keymaps/lukas/lukas.c similarity index 100% rename from keyboard/planck/keymaps/lukas.c rename to keyboard/planck/keymaps/lukas/lukas.c diff --git a/keyboard/planck/keymaps/max.c b/keyboard/planck/keymaps/max/max.c similarity index 100% rename from keyboard/planck/keymaps/max.c rename to keyboard/planck/keymaps/max/max.c diff --git a/keyboard/planck/keymaps/mollat.c b/keyboard/planck/keymaps/mollat/mollat.c similarity index 100% rename from keyboard/planck/keymaps/mollat.c rename to keyboard/planck/keymaps/mollat/mollat.c diff --git a/keyboard/planck/keymaps/monkey.c b/keyboard/planck/keymaps/monkey/monkey.c similarity index 100% rename from keyboard/planck/keymaps/monkey.c rename to keyboard/planck/keymaps/monkey/monkey.c diff --git a/keyboard/planck/keymaps/nico.c b/keyboard/planck/keymaps/nico/nico.c similarity index 100% rename from keyboard/planck/keymaps/nico.c rename to keyboard/planck/keymaps/nico/nico.c diff --git a/keyboard/planck/keymaps/numpad.c b/keyboard/planck/keymaps/numpad/numpad.c similarity index 100% rename from keyboard/planck/keymaps/numpad.c rename to keyboard/planck/keymaps/numpad/numpad.c diff --git a/keyboard/planck/keymaps/pete/README.md b/keyboard/planck/keymaps/pete/README.md new file mode 100644 index 00000000000..3cf594f3a91 --- /dev/null +++ b/keyboard/planck/keymaps/pete/README.md @@ -0,0 +1,14 @@ +# Planck Layout by Pete + +This layout is based on the default layout but uses a FN key in the bottom left corner instead of the shift / backlight key. +On the FN layer you can do the following things + +- Step through back light +- Put a mac to sleep +- The Fxx keys in a block to click with the right hand +- The delete key in the upper right corner +- Quick access to screenshot functions +- Control volume and media playback +- Home/PgDown/PgUp/End buttons where the arrow keys are + +Pressing the lower and raise buttons allows to reset and change from QWERT to Colemak or Dvorak. diff --git a/keyboard/planck/keymaps/pete/keymap.c b/keyboard/planck/keymaps/pete/keymap.c new file mode 100644 index 00000000000..57cab65a31e --- /dev/null +++ b/keyboard/planck/keymaps/pete/keymap.c @@ -0,0 +1,223 @@ +// This is the canonical layout file for the Quantum project. If you want to add another keyboard, +// this is the style you want to emulate. + +#include "planck.h" +#include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif +#include "eeconfig.h" + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +#define _QWERTY 0 +#define _COLEMAK 1 +#define _DVORAK 2 +#define _LOWER 3 +#define _RAISE 4 +#define _FCT 5 +#define _SETUP 6 +#define _MICMUTE 16 + +// Macro name shortcuts +#define QWERTY M(_QWERTY) +#define COLEMAK M(_COLEMAK) +#define DVORAK M(_DVORAK) +#define LOWER M(_LOWER) +#define RAISE M(_RAISE) +#define FCT M(_FCT) +#define MICMUTE M(_MICMUTE) + +#define MACPRNT LGUI(LSFT(KC_3)) +#define MACPRNT2 LGUI(LSFT(KC_4)) +#define CYCLWIN LGUI(KC_GRV) +#define MAC_SLEP LSFT(LCTL(KC_POWER)) + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[_QWERTY] = { + {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, + {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, + {FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +[_COLEMAK] = { + {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC}, + {KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, + {FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +[_DVORAK] = { + {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, + {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, + {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, + {FCT, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +[_LOWER] = { + {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, + {_______, _______, _______, _______, _______, _______, _______, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +[_RAISE] = { + {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, + {_______, _______, _______, _______, _______, _______, _______, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +[_FCT] = { /* Function */ + {BL_STEP, MAC_SLEP,XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_DELT}, + {_______, MICMUTE, KC_MUTE, KC_VOLD, KC_VOLU, XXXXXXX, XXXXXXX, KC_F5, KC_F6, KC_F7, KC_F8, MACPRNT}, + {_______, CYCLWIN, KC_MPRV, KC_MPLY, KC_MNXT, XXXXXXX, XXXXXXX, KC_F9, KC_F10, KC_F11, KC_F12, MACPRNT2}, + {FCT, _______, _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_PGDOWN,KC_PGUP,KC_END } +}, + +[_SETUP] = { /* Setup */ + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, RESET, RESET, _______, _______, _______, _______, _______} +} +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +#ifdef AUDIO_ENABLE +float tone_startup[][2] = { + {440.0*pow(2.0,(31)/12.0), 12}, + {440.0*pow(2.0,(28)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, + {440.0*pow(2.0,(28)/12.0), 20} +}; + +float tone_qwerty[][2] = SONG(QWERTY_SOUND); +float tone_dvorak[][2] = SONG(DVORAK_SOUND); +float tone_colemak[][2] = SONG(COLEMAK_SOUND); +float tone_plover[][2] = SONG(PLOVER_SOUND); +float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); + +float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); +float goodbye[][2] = SONG(GOODBYE_SOUND); +#endif + + +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case _QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_qwerty, false, 0); + #endif + persistant_default_layer_set(1UL<<_QWERTY); + } + break; + case _COLEMAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_colemak, false, 0); + #endif + persistant_default_layer_set(1UL<<_COLEMAK); + } + break; + case _DVORAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_dvorak, false, 0); + #endif + persistant_default_layer_set(1UL<<_DVORAK); + } + break; + case _LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _SETUP); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _SETUP); + } + break; + case _RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _SETUP); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _SETUP); + } + break; + case _FCT: + if (record->event.pressed) { + layer_on(_FCT); + } else { + layer_off(_FCT); + } + break; + case _MICMUTE: + if (record->event.pressed) { + register_code(KC_RSFT); + register_code(KC_RCTL); + register_code(KC_RALT); + register_code(KC_RGUI); + } else { + unregister_code(KC_RSFT); + unregister_code(KC_RCTL); + unregister_code(KC_RALT); + unregister_code(KC_RGUI); + } + break; + + } + return MACRO_NONE; +}; + +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + _delay_ms(20); // stops the tick + PLAY_NOTE_ARRAY(tone_startup, false, 0); + #endif +} + +#ifdef AUDIO_ENABLE +void play_goodbye_tone() +{ + PLAY_NOTE_ARRAY(goodbye, false, 0); + _delay_ms(150); +} + +uint8_t starting_note = 0x0C; +int offset = 0; + +void process_action_user(keyrecord_t *record) { + + if (IS_LAYER_ON(_MUSIC)) { + if (record->event.pressed) { + play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); + } else { + stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); + } + } + +} +#endif diff --git a/keyboard/planck/keymaps/pete/makefile.mk b/keyboard/planck/keymaps/pete/makefile.mk new file mode 100644 index 00000000000..812264cb356 --- /dev/null +++ b/keyboard/planck/keymaps/pete/makefile.mk @@ -0,0 +1,2 @@ +AUDIO_ENABLE = no +NKRO_ENABLE = yes \ No newline at end of file diff --git a/keyboard/planck/keymaps/pvc/config.h b/keyboard/planck/keymaps/pvc/config.h index 7d64f09773f..b6489310819 100644 --- a/keyboard/planck/keymaps/pvc/config.h +++ b/keyboard/planck/keymaps/pvc/config.h @@ -33,8 +33,9 @@ along with this program. If not, see . #define MATRIX_COLS 12 /* Planck PCB default pin-out */ -#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } -#define ROWS (int []){ D0, D5, B5, B6 } +#define MATRIX_ROW_PINS { D0, D5, B5, B6 } +#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -46,7 +47,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/planck/keymaps/pvc/keymap.c b/keyboard/planck/keymaps/pvc/keymap.c index 27850b21540..2fc5f0da16f 100644 --- a/keyboard/planck/keymaps/pvc/keymap.c +++ b/keyboard/planck/keymaps/pvc/keymap.c @@ -8,42 +8,44 @@ #include "song_list.h" #endif -#define LAYER_QWERTY 0 -#define LAYER_COLEMAK 1 -#define LAYER_DVORAK 2 -#define LAYER_LOWER 3 -#define LAYER_RAISE 4 -#define LAYER_FUNCTION 5 -#define LAYER_MOUSE 6 -#define LAYER_MUSIC 7 -#define LAYER_ADJUST 8 +#define LAYER_QWERTY 0 +#define LAYER_COLEMAK 1 +#define LAYER_DVORAK 2 +#define LAYER_UPPER 3 +#define LAYER_LOWER 4 +#define LAYER_FUNCTION 5 +#define LAYER_MOUSE 6 +#define LAYER_ADJUST 7 -#define MACRO_QWERTY 0 -#define MACRO_COLEMAK 1 -#define MACRO_DVORAK 2 -#define MACRO_LOWER 3 -#define MACRO_RAISE 4 -#define MACRO_FUNCTION 5 -#define MACRO_MOUSE 6 -#define MACRO_TIMBRE_1 7 -#define MACRO_TIMBRE_2 8 -#define MACRO_TIMBRE_3 9 -#define MACRO_TIMBRE_4 10 -#define MACRO_TEMPO_U 11 -#define MACRO_TEMPO_D 12 -#define MACRO_TONE_DEFAULT 13 -#define MACRO_MUSIC_ON 14 -#define MACRO_MUSIC_OFF 15 -#define MACRO_AUDIO_ON 16 -#define MACRO_AUDIO_OFF 17 -#define MACRO_INC_VOICE 18 -#define MACRO_DEC_VOICE 19 +#define MACRO_QWERTY 0 +#define MACRO_COLEMAK 1 +#define MACRO_DVORAK 2 +#define MACRO_UPPER 3 +#define MACRO_LOWER 4 +#define MACRO_FUNCTION 5 +#define MACRO_MOUSE 6 +#define MACRO_TIMBRE_1 7 +#define MACRO_TIMBRE_2 8 +#define MACRO_TIMBRE_3 9 +#define MACRO_TIMBRE_4 10 +#define MACRO_TEMPO_U 11 +#define MACRO_TEMPO_D 12 +#define MACRO_TONE_DEFAULT 13 +#define MACRO_MUSIC_TOGGLE 14 +#define MACRO_AUDIO_TOGGLE 16 +#define MACRO_INC_VOICE 18 +#define MACRO_DEC_VOICE 19 +#define MACRO_BACKLIGHT 20 +#define MACRO_BREATH_TOGGLE 21 +#define MACRO_BREATH_SPEED_INC 23 +#define MACRO_BREATH_SPEED_DEC 24 +#define MACRO_BREATH_DEFAULT 25 #define M_QWRTY M(MACRO_QWERTY) #define M_COLMK M(MACRO_COLEMAK) #define M_DVORK M(MACRO_DVORAK) +#define M_UPPER M(MACRO_UPPER) #define M_LOWER M(MACRO_LOWER) -#define M_RAISE M(MACRO_RAISE) #define M_FUNCT M(MACRO_FUNCTION) #define M_MOUSE M(MACRO_MOUSE) #define TIMBR_1 M(MACRO_TIMBRE_1) @@ -53,12 +55,13 @@ #define TMPO_UP M(MACRO_TEMPO_U) #define TMPO_DN M(MACRO_TEMPO_D) #define TMPO_DF M(MACRO_TONE_DEFAULT) +#define M_BACKL M(MACRO_BACKLIGHT) +#define M_BRTOG M(MACRO_BREATH_TOGGLE) +#define M_BSPDU M(MACRO_BREATH_SPEED_INC) +#define M_BSPDD M(MACRO_BREATH_SPEED_DEC) +#define M_BDFLT M(MACRO_BREATH_DEFAULT) -#define MUS_ON M(MACRO_MUSIC_ON) -#define MUS_OFF M(MACRO_MUSIC_OFF) -#define AUD_OFF M(MACRO_AUDIO_OFF) -#define AUD_ON M(MACRO_AUDIO_ON) #define VC_UP M(MACRO_INC_VOICE) #define VC_DOWN M(MACRO_DEC_VOICE) @@ -74,6 +77,7 @@ #define SC_ACLS LALT(KC_F4) #define SC_CCLS LCTL(KC_F4) +#define OS_SHFT KC_FN0 #define _______ KC_TRNS #define XXXXXXX KC_NO @@ -88,17 +92,17 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| * | ESC | A | S | D | F | G | H | J | K | L | ; | ' | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LSHIFT | Z | X | C | V | B | N | M | , | . | / | ENTER | + * | LSHIFT | Z | X | C | V | B | N | M | , | . | UP | ENTER | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | SPACE | SPACE | LOWER | UP | DOWN | LEFT | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | SPACE | SPACE | LOWER | SHIFT | LEFT | DOWN | RIGHT | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_QWERTY] = { /* QWERTY */ - { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC }, - { KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT }, - { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT }, + [LAYER_QWERTY] = { // QWERTY + { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC }, + { KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT }, + { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_LEFT, KC_DOWN, KC_RGHT }, }, /* COLEMAK @@ -107,77 +111,77 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| * | BACKSP | A | R | S | T | D | H | N | E | I | O | ' | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LSHIFT | Z | X | C | V | B | K | M | , | . | / | ENTER | + * | LSHIFT | Z | X | C | V | B | K | M | , | . | UP | ENTER | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | SPACE | SPACE | LOWER | UP | DOWN | LEFT | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | SPACE | SPACE | LOWER | SHIFT | LEFT | DOWN | RIGHT | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_COLEMAK] = { /* COLEMAK */ + [LAYER_COLEMAK] = { // COLEMAK { KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_ESC }, - { KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT }, - { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT }, + { KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT }, + { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, OS_SHFT, KC_LEFT, KC_DOWN, KC_RGHT }, }, /* DVORAK * .-----------------------------------------------------------------------------------------------------------. * | TAB | ' | , | . | P | Y | F | G | C | R | L | BACKSP | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | ESC | A | O | E | U | I | D | H | T | N | S | ' | + * | ESC | A | O | E | U | I | D | H | T | N | S | / | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| * | LSHIFT | ; | Q | J | K | X | B | M | W | V | Z | ENTER | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | SPACE | SPACE | LOWER | UP | DOWN | LEFT | RIGHT | + * | LCTRL | LWIN | FN | LALT | UPPER | SPACE | SPACE | LOWER | UP | DOWN | LEFT | RIGHT | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_DVORAK] = { /* DVORAK */ + [LAYER_DVORAK] = { // DVORAK { KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC }, { KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH }, { KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, - { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_RAISE, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT }, + { KC_LCTL, KC_LGUI, M_FUNCT, KC_LALT, M_UPPER, KC_SPC, KC_SPC, M_LOWER, KC_UP, KC_DOWN, KC_LEFT, KC_RGHT }, }, -/* Raise +/* UPPER * .-----------------------------------------------------------------------------------------------------------. - * | ~ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | DEL | + * | PRINT | F1 | F2 | F3 | F4 | NUM LK | / | 7 | 8 | 9 | - | DEL | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | XXXXXX | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | [ | ] | \ | + * | CAP LK | F5 | F6 | F7 | F8 | SCR LK | * | 4 | 5 | 6 | + | INS | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LSHIFT | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX | XXXXXX | XXXXXX | XXXXXX | ENTER | - * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | BACKSP | BACKSP | LOWER | PG UP | PG DN | HOME | END | + * | | F9 | F10 | F11 | F12 | PAUSE | | 1 | 2 | 3 | ENTER | HOME | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | | | | | 0 | 0 | | RALT | . | ENTER | END | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_RAISE] = { /* RAISED */ - { KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL }, - { XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS }, - { _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, KC_PGUP, KC_PGDN, KC_HOME, KC_END }, + [LAYER_UPPER] = { // UPPER + { KC_PSCR, KC_F1, KC_F2, KC_F3, KC_F4, KC_NLCK, KC_PSLS, KC_KP_7, KC_KP_8, KC_KP_9, KC_PMNS, KC_DEL }, + { KC_CAPS, KC_F5, KC_F6, KC_F7, KC_F8, KC_SLCK, KC_PAST, KC_KP_4, KC_KP_5, KC_KP_6, KC_PPLS, KC_INS }, + { _______, KC_F9, KC_F10, KC_F11, KC_F12, KC_PAUS, XXXXXXX, KC_KP_1, KC_KP_2, KC_KP_3, KC_PENT, KC_HOME }, + { _______, _______, _______, _______, _______, KC_KP_0, KC_KP_0, _______, KC_RALT, KC_PDOT, KC_PENT, KC_END }, }, - -/* LOWERED +/* LOWER * .-----------------------------------------------------------------------------------------------------------. - * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | INS | + * | | $ | { | [ | ( | % | # | ) | ] | } | @ | PG UP | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | XXXXXX | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * | | ^ | * | + | - | ; | : | _ | ' | " | ` | PG DN | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LSHIFT | F7 | F8 | F9 | F10 | F11 | F12 | XXXXXX | XXXXXX | XXXXXX | XXXXXX | ENTER | - * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | BACKSP | BACKSP | LOWER | PG UP | PG DN | HOME | END | + * | | | | & | ! | ~ | / | \ | = | < | > | ? | HOME | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | | | | | | | | | | | END | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_LOWER] = { /* LOWERED */ - { KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_INS }, - { XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS }, - { _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { _______, _______, _______, _______, _______, KC_BSPC, KC_BSPC, _______, KC_PGUP, KC_PGDN, KC_HOME, KC_END }, + [LAYER_LOWER] = { // LOWER + { _______, KC_DLR, KC_LCBR, KC_LBRC, KC_LPRN, KC_PERC, KC_HASH, KC_RPRN, KC_RBRC, KC_RCBR, KC_AT, KC_PGUP }, + { _______, KC_CIRC, KC_ASTR, KC_PPLS, KC_PMNS, KC_SCLN, KC_COLN, KC_UNDS, KC_QUOT, KC_DQT, KC_GRV, KC_PGDN }, + { _______, KC_PIPE, KC_AMPR, KC_EXLM, KC_TILD, KC_SLSH, KC_BSLS, KC_EQL, KC_LT, KC_GT, KC_QUES, KC_HOME }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_END }, }, + /* FUNCTION * .-----------------------------------------------------------------------------------------------------------. * | NUM LK | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | PAUSE | @@ -186,10 +190,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| * | SCR LK | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | XXXXXX | MUTE | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| - * | LCTRL | LWIN | FN | LALT | RAISE | PLAY | PLAY | LOWER | VOL UP | VOL DN | NEXT | PREV | + * | LCTRL | LWIN | FN | LALT | UPPER | PLAY | PLAY | LOWER | VOL UP | VOL DN | NEXT | PREV | * '-----------------------------------------------------------------------------------------------------------' */ - [LAYER_FUNCTION] = { /* FUNCTION */ + [LAYER_FUNCTION] = { // FUNCTION { KC_NLCK, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_PAUS }, { KC_CAPS, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_PSCR }, { KC_SLCK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MUTE }, @@ -198,7 +202,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #ifdef MOUSEKEY_ENABLE - [LAYER_MOUSE] = { /* MOUSE */ + [LAYER_MOUSE] = { // MOUSE { KC_ESC, KC_ACL0, KC_ACL1, KC_ACL2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_ESC }, { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, { _______, KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_WH_U, KC_WH_D }, @@ -207,21 +211,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #endif - [LAYER_MUSIC] = { /* MUSIC */ - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - { XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, M_RAISE, XXXXXXX, XXXXXXX, M_LOWER, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX }, - }, - - [LAYER_ADJUST] = { /* ADJUST */ - { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, MUS_ON, MUS_OFF, AUD_ON, AUD_OFF }, + [LAYER_ADJUST] = { // ADJUST + { _______, TIMBR_1, TIMBR_2, TIMBR_3, TIMBR_4, TMPO_UP, TMPO_DN, TMPO_DF, _______, _______, MU_TOG, AU_TOG }, { _______, M_QWRTY, M_COLMK, M_DVORK, _______, _______, _______, _______, _______, _______, _______, _______ }, - { _______, _______, _______, _______, _______, RESET, _______, M_MOUSE, _______, _______, _______, _______ }, - { _______, _______, _______, _______, _______, _______, _______, _______, VC_UP, VC_DOWN, _______, _______ }, + { _______, _______, _______, _______, M_BACKL, RESET, _______, M_MOUSE, _______, _______, MUV_IN, _______ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, MUV_DE, _______ }, }, - /* [LAYER_EMPTY] = { { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, }, @@ -261,6 +257,7 @@ void persistant_default_layer_set(uint16_t default_layer) } const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_MODS_ONESHOT(MOD_LSFT), }; const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) @@ -304,25 +301,25 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) if (record->event.pressed) { layer_on(LAYER_LOWER); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { layer_off(LAYER_LOWER); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; - case MACRO_RAISE: + case MACRO_UPPER: if (record->event.pressed) { - layer_on(LAYER_RAISE); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + layer_on(LAYER_UPPER); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } else { - layer_off(LAYER_RAISE); - update_tri_layer(LAYER_LOWER, LAYER_RAISE, LAYER_ADJUST); + layer_off(LAYER_UPPER); + update_tri_layer(LAYER_LOWER, LAYER_UPPER, LAYER_ADJUST); } break; @@ -337,6 +334,15 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) } break; + +#ifdef BACKLIGHT_ENABLE + case MACRO_BACKLIGHT: + if (record->event.pressed) + { + backlight_step(); + } +#endif + #ifdef MOUSEKEY_ENABLE case MACRO_MOUSE: @@ -382,65 +388,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) } break; - case MACRO_AUDIO_OFF: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - audio_off(); - #endif - } - break; - - case MACRO_AUDIO_ON: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - audio_on(); - PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO); - #endif - } - break; - - case MACRO_MUSIC_ON: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO); - layer_on(LAYER_MUSIC); - #endif - } - break; - - case MACRO_MUSIC_OFF: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - layer_off(LAYER_MUSIC); - stop_all_notes(); - #endif - } - break; - - case MACRO_INC_VOICE: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - voice_iterate(); - PLAY_NOTE_ARRAY(music_scale, false, STACCATO); - #endif - } - break; - - case MACRO_DEC_VOICE: - if (record->event.pressed) - { - #ifdef AUDIO_ENABLE - voice_deiterate(); - PLAY_NOTE_ARRAY(music_scale, false, STACCATO); - #endif - } - break; - #endif /* AUDIO_ENABLE */ default: @@ -453,31 +400,10 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) #ifdef AUDIO_ENABLE - -void process_action_user(keyrecord_t *record) -{ - - uint8_t starting_note = 0x0C; - int offset = 7; - - if (IS_LAYER_ON(LAYER_MUSIC)) - { - if (record->event.pressed) - { - play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); - } - else - { - stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); - } - } -} - - void matrix_init_user(void) { set_voice(default_voice); - play_startup_tone(); + startup_user(); println("Matrix Init"); } @@ -521,16 +447,32 @@ void led_set_user(uint8_t usb_led) } -void play_startup_tone() +void startup_user() { _delay_ms(10); // gets rid of tick PLAY_NOTE_ARRAY(tone_my_startup, false, STACCATO); } -void play_goodbye_tone() +void shutdown_user() { PLAY_NOTE_ARRAY(tone_my_goodbye, false, STACCATO); - _delay_ms(1000); + _delay_ms(2000); + stop_all_notes(); +} + +void audio_on_user(void) +{ + PLAY_NOTE_ARRAY(tone_audio_on, false, STACCATO); +} + +void music_on_user(void) +{ + PLAY_NOTE_ARRAY(tone_music_on, false, STACCATO); +} + +void music_scale_user(void) +{ + PLAY_NOTE_ARRAY(music_scale, false, STACCATO); } #endif /* AUDIO_ENABLE */ \ No newline at end of file diff --git a/keyboard/planck/keymaps/pvc/makefile.mk b/keyboard/planck/keymaps/pvc/makefile.mk index 4b9e34c53fa..f7798b09d5c 100644 --- a/keyboard/planck/keymaps/pvc/makefile.mk +++ b/keyboard/planck/keymaps/pvc/makefile.mk @@ -1,11 +1,12 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) +CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 +AUDIO_ENABLE = yes # Audio output on port C6 UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. @@ -13,4 +14,4 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend -CONFIG_H = keymaps/$(KEYMAP)/config.h +CONFIG_H = keymaps/$(KEYMAP)/config.h \ No newline at end of file diff --git a/keyboard/planck/keymaps/tak3over.c b/keyboard/planck/keymaps/tak3over/tak3over.c similarity index 100% rename from keyboard/planck/keymaps/tak3over.c rename to keyboard/planck/keymaps/tak3over/tak3over.c diff --git a/keyboard/planck/keymaps/unicode/keymap.c b/keyboard/planck/keymaps/unicode/keymap.c new file mode 100644 index 00000000000..d73e7e09d45 --- /dev/null +++ b/keyboard/planck/keymaps/unicode/keymap.c @@ -0,0 +1,326 @@ +/* + Copyright + 2015 Jack Humbert + 2016 Francois Marlier + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + For more info on how this works per OS, see here + https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input +*/ + + +#include "planck.h" +#include "action_layer.h" +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif +#include "eeconfig.h" + +extern keymap_config_t keymap_config; + +// Each layer gets a name for readability, which is then used in the keymap matrix below. +// The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, obviously, and you can also skip them +// entirely and just use numbers. +#define _QWERTY 0 +#define _COLEMAK 1 +#define _DVORAK 2 +#define _LOWER 3 +#define _RAISE 4 +#define _PLOVER 5 +#define _ADJUST 16 + +// Macro name shortcuts +#define QWERTY M(_QWERTY) +#define COLEMAK M(_COLEMAK) +#define DVORAK M(_DVORAK) +#define LOWER M(_LOWER) +#define RAISE M(_RAISE) +#define M_BL 5 +#define PLOVER M(12) +#define EXT_PLV M(13) +#define TOG_OUT M(14) + +// Fillers to make layering more clear +#define _______ KC_TRNS +#define XXXXXXX KC_NO + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Qwerty + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | S | D | F | G | H | J | K | L | ; | " | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_QWERTY] = { + {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC}, + {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT }, + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Colemak + * ,-----------------------------------------------------------------------------------. + * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | R | S | T | D | H | N | E | I | O | " | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_COLEMAK] = { + {KC_TAB, UC_q, UC_w, UC_f, UC_p, UC_g, UC_j, UC_l, UC_u, UC_y, UC_SCLN, UC_BSPC}, + {KC_ESC, UC_a, UC_r, UC_s, UC_t, UC_d, UC_h, UC_n, UC_e, UC_i, UC_o, UC_QUOT}, + {KC_LSFT, UC_z, UC_x, UC_c, UC_v, UC_b, UC_k, UC_m, UC_COMM, UC_DOT, UC_SLSH, KC_ENT}, + {KC_TRNS, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Dvorak + * ,-----------------------------------------------------------------------------------. + * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Esc | A | O | E | U | I | D | H | T | N | S | / | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Brite| Ctrl | Alt | GUI |Lower | Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------------------------------------------------' + */ +[_DVORAK] = { + {KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC}, + {KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH}, + {KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT }, + {M(M_BL), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT} +}, + +/* Lower + * ,-----------------------------------------------------------------------------------. + * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_LOWER] = { + {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Raise + * ,-----------------------------------------------------------------------------------. + * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | Next | Vol- | Vol+ | Play | + * `-----------------------------------------------------------------------------------' + */ +[_RAISE] = { + {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, + {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} +}, + +/* Plover layer (http://opensteno.org) + * ,-----------------------------------------------------------------------------------. + * | # | # | # | # | # | # | # | # | # | # | # | # | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | S | T | P | H | * | * | F | P | L | T | D | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * |TogOut| S | K | W | R | * | * | R | B | G | S | Z | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | Exit | | | A | O | | E | U | | | | + * `-----------------------------------------------------------------------------------' + */ + +[_PLOVER] = { + {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 }, + {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC}, + {TOG_OUT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT}, + {EXT_PLV, XXXXXXX, XXXXXXX, KC_C, KC_V, XXXXXXX, XXXXXXX, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX} +}, + +/* Adjust (Lower + Raise) + * ,-----------------------------------------------------------------------------------. + * | | Reset| | | | | | | | | | Del | + * |------+------+------+------+------+-------------+------+------+------+------+------| + * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|Plover| | + * |------+------+------+------+------+------|------+------+------+------+------+------| + * | |Voice-|Voice+|Mus on|Musoff| | | | | | | | + * |------+------+------+------+------+------+------+------+------+------+------+------| + * | | | | | | | | | | | | + * `-----------------------------------------------------------------------------------' + */ +[_ADJUST] = { + {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, + {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, PLOVER, _______}, + {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, + {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} +} + + +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +#ifdef AUDIO_ENABLE +float tone_startup[][2] = { + {440.0*pow(2.0,(31)/12.0), 12}, + {440.0*pow(2.0,(28)/12.0), 8}, + {440.0*pow(2.0,(19)/12.0), 8}, + {440.0*pow(2.0,(24)/12.0), 8}, + {440.0*pow(2.0,(28)/12.0), 20} +}; + +float tone_qwerty[][2] = SONG(QWERTY_SOUND); +float tone_dvorak[][2] = SONG(DVORAK_SOUND); +float tone_colemak[][2] = SONG(COLEMAK_SOUND); +float tone_plover[][2] = SONG(PLOVER_SOUND); +float tone_plover_gb[][2] = SONG(PLOVER_GOODBYE_SOUND); + +float goodbye[][2] = SONG(GOODBYE_SOUND); +#endif + + +void persistant_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch(id) { + case _QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_qwerty, false, 0); + #endif + persistant_default_layer_set(1UL<<_QWERTY); + } + break; + case _COLEMAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_colemak, false, 0); + #endif + persistant_default_layer_set(1UL<<_COLEMAK); + } + break; + case _DVORAK: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_dvorak, false, 0); + #endif + persistant_default_layer_set(1UL<<_DVORAK); + } + break; + case _LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + break; + case _RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + break; + case M_BL: + if (record->event.pressed) { + register_code(KC_RSFT); + #ifdef BACKLIGHT_ENABLE + backlight_step(); + #endif + } else { + unregister_code(KC_RSFT); + } + break; + case 12: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_NOTE_ARRAY(tone_plover, false, 0); + #endif + layer_off(_RAISE); + layer_off(_LOWER); + layer_off(_ADJUST); + layer_on(_PLOVER); + if (!eeconfig_is_enabled()) { + eeconfig_init(); + } + keymap_config.raw = eeconfig_read_keymap(); + keymap_config.nkro = 1; + eeconfig_update_keymap(keymap_config.raw); + } + break; + case 13: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + PLAY_NOTE_ARRAY(tone_plover_gb, false, 0); + #endif + layer_off(_PLOVER); + } + break; + case 14: + if (record->event.pressed) { + return MACRO( D(E), D(R), D(F), D(V), D(O), D(L), U(E), U(R), U(F), U(V), U(O), U(L), END ); + } + break; + } + return MACRO_NONE; +}; + +void matrix_init_user(void) { + #ifdef AUDIO_ENABLE + _delay_ms(20); // stops the tick + PLAY_NOTE_ARRAY(tone_startup, false, 0); + #endif +} + +#ifdef AUDIO_ENABLE +void play_goodbye_tone() +{ + PLAY_NOTE_ARRAY(goodbye, false, 0); + _delay_ms(150); +} +#endif + + diff --git a/keyboard/planck/keymaps/unicode/makefile.mk b/keyboard/planck/keymaps/unicode/makefile.mk new file mode 100644 index 00000000000..9b27b08bed1 --- /dev/null +++ b/keyboard/planck/keymaps/unicode/makefile.mk @@ -0,0 +1 @@ +UNICODE_ENABLE = yes # Unicode diff --git a/keyboard/planck/planck.c b/keyboard/planck/planck.c index 4b39cf1e8bd..da7b3a1702b 100644 --- a/keyboard/planck/planck.c +++ b/keyboard/planck/planck.c @@ -7,7 +7,12 @@ __attribute__ ((weak)) void matrix_scan_user(void) {} __attribute__ ((weak)) -void process_action_user(keyrecord_t *record) {} +bool process_action_user(keyrecord_t *record) { + return true; +} + +__attribute__ ((weak)) +void led_set_user(uint8_t usb_led) {} void matrix_init_kb(void) { #ifdef BACKLIGHT_ENABLE @@ -29,6 +34,273 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -void process_action_kb(keyrecord_t *record) { - process_action_user(record); +bool process_action_kb(keyrecord_t *record) { + return process_action_user(record); } + +void led_set_kb(uint8_t usb_led) { + // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here + + led_set_user(usb_led); +} + +#ifdef BACKLIGHT_ENABLE +#define CHANNEL OCR1C +#define BREATHING_NO_HALT 0 +#define BREATHING_HALT_OFF 1 +#define BREATHING_HALT_ON 2 + +static uint8_t breath_intensity; +static uint8_t breath_speed; +static uint16_t breathing_index; +static uint8_t breathing_halt; + +void backlight_init_ports() +{ + + // Setup PB7 as output and output low. + DDRB |= (1<<7); + PORTB &= ~(1<<7); + + // Use full 16-bit resolution. + ICR1 = 0xFFFF; + + // I could write a wall of text here to explain... but TL;DW + // Go read the ATmega32u4 datasheet. + // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on + + // Pin PB7 = OCR1C (Timer 1, Channel C) + // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 + // (i.e. start high, go low when counter matches.) + // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 + // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 + + TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; + TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + + backlight_init(); + breathing_defaults(); +} + +void backlight_set(uint8_t level) +{ + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + + if ( level == 0 ) + { + // Turn off PWM control on PB7, revert to output low. + TCCR1A &= ~(_BV(COM1C1)); + CHANNEL = 0x0; + } + else if ( level == BACKLIGHT_LEVELS ) + { + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF; + } + else + { + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); + } + breathing_intensity_default(); +} + + +void breathing_enable(void) +{ + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint (brightest point) + breathing_index = 0x20 << breath_speed; + } + + breathing_halt = BREATHING_NO_HALT; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); +} + +void breathing_pulse(void) +{ + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint + 1 (brightest point) + breathing_index = 0x21 << breath_speed; + } + + breathing_halt = BREATHING_HALT_ON; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); +} + +void breathing_disable(void) +{ + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + backlight_set(get_backlight_level()); +} + +void breathing_self_disable(void) +{ + if (get_backlight_level() == 0) + { + breathing_halt = BREATHING_HALT_OFF; + } + else + { + breathing_halt = BREATHING_HALT_ON; + } + + //backlight_set(get_backlight_level()); +} + +void breathing_toggle(void) +{ + if (!is_breathing()) + { + if (get_backlight_level() == 0) + { + breathing_index = 0; + } + else + { + // Set breathing_index to be at the midpoint + 1 (brightest point) + breathing_index = 0x21 << breath_speed; + } + + breathing_halt = BREATHING_NO_HALT; + } + + // Toggle breathing interrupt + TIMSK1 ^= _BV(OCIE1A); + + // Restore backlight level + if (!is_breathing()) + { + backlight_set(get_backlight_level()); + } +} + +bool is_breathing(void) +{ + return (TIMSK1 && _BV(OCIE1A)); +} + +void breathing_intensity_default(void) +{ + //breath_intensity = (uint8_t)((uint16_t)100 * (uint16_t)get_backlight_level() / (uint16_t)BACKLIGHT_LEVELS); + breath_intensity = ((BACKLIGHT_LEVELS - get_backlight_level()) * ((BACKLIGHT_LEVELS + 1) / 2)); +} + +void breathing_intensity_set(uint8_t value) +{ + breath_intensity = value; +} + +void breathing_speed_default(void) +{ + breath_speed = 4; +} + +void breathing_speed_set(uint8_t value) +{ + bool is_breathing_now = is_breathing(); + uint8_t old_breath_speed = breath_speed; + + if (is_breathing_now) + { + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + } + + breath_speed = value; + + if (is_breathing_now) + { + // Adjust index to account for new speed + breathing_index = (( (uint8_t)( (breathing_index) >> old_breath_speed ) ) & 0x3F) << breath_speed; + + // Enable breathing interrupt + TIMSK1 |= _BV(OCIE1A); + } + +} + +void breathing_speed_inc(uint8_t value) +{ + if ((uint16_t)(breath_speed - value) > 10 ) + { + breathing_speed_set(0); + } + else + { + breathing_speed_set(breath_speed - value); + } +} + +void breathing_speed_dec(uint8_t value) +{ + if ((uint16_t)(breath_speed + value) > 10 ) + { + breathing_speed_set(10); + } + else + { + breathing_speed_set(breath_speed + value); + } +} + +void breathing_defaults(void) +{ + breathing_intensity_default(); + breathing_speed_default(); + breathing_halt = BREATHING_NO_HALT; +} + +/* Breathing Sleep LED brighness(PWM On period) table + * (64[steps] * 4[duration]) / 64[PWM periods/s] = 4 second breath cycle + * + * http://www.wolframalpha.com/input/?i=%28sin%28+x%2F64*pi%29**8+*+255%2C+x%3D0+to+63 + * (0..63).each {|x| p ((sin(x/64.0*PI)**8)*255).to_i } + */ +static const uint8_t breathing_table[64] PROGMEM = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 6, 10, + 15, 23, 32, 44, 58, 74, 93, 113, 135, 157, 179, 199, 218, 233, 245, 252, +255, 252, 245, 233, 218, 199, 179, 157, 135, 113, 93, 74, 58, 44, 32, 23, + 15, 10, 6, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; + +ISR(TIMER1_COMPA_vect) +{ + // CHANNEL = (pgm_read_byte(&breathing_table[ ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F ] )) * breath_intensity; + + + uint8_t local_index = ( (uint8_t)( (breathing_index++) >> breath_speed ) ) & 0x3F; + + if (((breathing_halt == BREATHING_HALT_ON) && (local_index == 0x20)) || ((breathing_halt == BREATHING_HALT_OFF) && (local_index == 0x3F))) + { + // Disable breathing interrupt + TIMSK1 &= ~_BV(OCIE1A); + } + + CHANNEL = (uint16_t)(((uint16_t)pgm_read_byte(&breathing_table[local_index]) * 257)) >> breath_intensity; + +} + + + +#endif \ No newline at end of file diff --git a/keyboard/planck/planck.h b/keyboard/planck/planck.h index edcb5fbff6d..8aec6b26278 100644 --- a/keyboard/planck/planck.h +++ b/keyboard/planck/planck.h @@ -1,18 +1,7 @@ #ifndef PLANCK_H #define PLANCK_H -#include "matrix.h" -#include "keymap_common.h" -#ifdef BACKLIGHT_ENABLE - #include "backlight.h" -#endif -#ifdef RGBLIGHT_ENABLE - #include "rgblight.h" -#endif -#include -#ifdef MIDI_ENABLE - #include -#endif +#include "quantum.h" #define PLANCK_MIT( \ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ @@ -42,6 +31,24 @@ void matrix_init_user(void); void matrix_scan_user(void); -void process_action_user(keyrecord_t *record); +bool process_action_user(keyrecord_t *record); + +void led_set_user(uint8_t usb_led); +void backlight_init_ports(void); + +void breathing_enable(void); +void breathing_pulse(void); +void breathing_disable(void); +void breathing_self_disable(void); +void breathing_toggle(void); +bool is_breathing(void); + + +void breathing_defaults(void); +void breathing_intensity_default(void); +void breathing_speed_default(void); +void breathing_speed_set(uint8_t value); +void breathing_speed_inc(uint8_t value); +void breathing_speed_dec(uint8_t value); #endif diff --git a/keyboard/planck/planck_pcb_r4.hex b/keyboard/planck/planck_pcb_r4.hex index 889af7f2253..bd68d9e904b 100644 Binary files a/keyboard/planck/planck_pcb_r4.hex and b/keyboard/planck/planck_pcb_r4.hex differ diff --git a/keyboard/planck/planck_pcb_r4_w_bootloader.hex b/keyboard/planck/planck_pcb_r4_w_bootloader.hex index f2e9993ac8f..140bf415f2c 100644 Binary files a/keyboard/planck/planck_pcb_r4_w_bootloader.hex and b/keyboard/planck/planck_pcb_r4_w_bootloader.hex differ diff --git a/keyboard/preonic/Makefile b/keyboard/preonic/Makefile index 3504e27201b..259dd6686be 100644 --- a/keyboard/preonic/Makefile +++ b/keyboard/preonic/Makefile @@ -162,11 +162,6 @@ endif endif -ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) - SRC := backlight.c $(SRC) -endif - - # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/keyboard/preonic/backlight.c b/keyboard/preonic/backlight.c deleted file mode 100644 index f69364b2afb..00000000000 --- a/keyboard/preonic/backlight.c +++ /dev/null @@ -1,61 +0,0 @@ - -#include -#include "backlight.h" - -#define CHANNEL OCR1C - -void backlight_init_ports() -{ - - // Setup PB7 as output and output low. - DDRB |= (1<<7); - PORTB &= ~(1<<7); - - // Use full 16-bit resolution. - ICR1 = 0xFFFF; - - // I could write a wall of text here to explain... but TL;DW - // Go read the ATmega32u4 datasheet. - // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on - - // Pin PB7 = OCR1C (Timer 1, Channel C) - // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 - // (i.e. start high, go low when counter matches.) - // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 - // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 - - TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; - TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; - - backlight_init(); -} - -void backlight_set(uint8_t level) -{ - if ( level == 0 ) - { - // Turn off PWM control on PB7, revert to output low. - TCCR1A &= ~(_BV(COM1C1)); - CHANNEL = 0x0; - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - } - else if ( level == BACKLIGHT_LEVELS ) - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF; - } - else - { - // Prevent backlight blink on lowest level - PORTB &= ~(_BV(PORTB7)); - // Turn on PWM control of PB7 - TCCR1A |= _BV(COM1C1); - // Set the brightness - CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); - } -} \ No newline at end of file diff --git a/keyboard/preonic/config.h b/keyboard/preonic/config.h index bb9d29dab77..e8d0e82fc9c 100644 --- a/keyboard/preonic/config.h +++ b/keyboard/preonic/config.h @@ -33,8 +33,9 @@ along with this program. If not, see . #define MATRIX_COLS 12 /* Planck PCB default pin-out */ -#define COLS (int []){ F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } -#define ROWS (int []){ D2, D5, B5, B6, D3 } +#define MATRIX_ROW_PINS { D2, D5, B5, B6, D3 } +#define MATRIX_COL_PINS { F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -46,7 +47,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 3 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE diff --git a/keyboard/preonic/keymaps/default/keymap.c b/keyboard/preonic/keymaps/default/keymap.c index 95b97187625..06e6647136d 100644 --- a/keyboard/preonic/keymaps/default/keymap.c +++ b/keyboard/preonic/keymaps/default/keymap.c @@ -14,7 +14,6 @@ #define _DVORAK 2 #define _LOWER 3 #define _RAISE 4 -#define _MUSIC 5 #define _ADJUST 16 // Macro name shortcuts @@ -24,12 +23,6 @@ #define LOWER M(_LOWER) #define RAISE M(_RAISE) #define M_BL 5 -#define AUD_OFF M(6) -#define AUD_ON M(7) -#define MUS_OFF M(8) -#define MUS_ON M(9) -#define VC_IN M(10) -#define VC_DE M(11) // Fillers to make layering more clear #define _______ KC_TRNS @@ -108,7 +101,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+-------------+------+------+------+------+------| * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' @@ -117,7 +110,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC}, {KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, @@ -129,7 +122,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |------+------+------+------+------+-------------+------+------+------+------+------| * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ | * |------+------+------+------+------+------|------+------+------+------+------+------| - * | | F7 | F8 | F9 | F10 | F11 | F12 | | | | |Enter | + * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter | * |------+------+------+------+------+------+------+------+------+------+------+------| * | | | | | | | | Next | Vol- | Vol+ | Play | * `-----------------------------------------------------------------------------------' @@ -138,21 +131,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC}, {KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL}, {KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS}, - {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______}, + {_______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY} }, -/* Music (reserved for process_action_user) - * - */ -[_MUSIC] = { - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}, - {XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, LOWER, XXXXXXX, XXXXXXX, RAISE, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX} -}, - /* Adjust (Lower + Raise) * ,-----------------------------------------------------------------------------------. * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | @@ -169,8 +151,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_ADJUST] = { {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12}, {_______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL}, - {_______, _______, _______, AUD_ON, AUD_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, - {_______, VC_DE, VC_IN, MUS_ON, MUS_OFF, _______, _______, _______, _______, _______, _______, _______}, + {_______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______}, + {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, _______, _______, _______, _______, _______}, {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______} } @@ -193,7 +175,6 @@ float tone_qwerty[][2] = SONG(QWERTY_SOUND); float tone_dvorak[][2] = SONG(DVORAK_SOUND); float tone_colemak[][2] = SONG(COLEMAK_SOUND); -float music_scale[][2] = SONG(MUSIC_SCALE_SOUND); float goodbye[][2] = SONG(GOODBYE_SOUND); #endif @@ -257,53 +238,6 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) unregister_code(KC_RSFT); } break; - case 6: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_off(); - #endif - } - break; - case 7: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - audio_on(); - PLAY_NOTE_ARRAY(start_up, false, 0); - #endif - } - break; - case 8: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - layer_off(_MUSIC); - stop_all_notes(); - #endif - } - break; - case 9: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - PLAY_NOTE_ARRAY(music_scale, false, 0); - layer_on(_MUSIC); - #endif - } - break; - case 10: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - voice_iterate(); - PLAY_NOTE_ARRAY(music_scale, false, 0); - #endif - } - break; - case 11: - if (record->event.pressed) { - #ifdef AUDIO_ENABLE - voice_deiterate(); - PLAY_NOTE_ARRAY(music_scale, false, 0); - #endif - } - break; } return MACRO_NONE; }; @@ -318,21 +252,6 @@ void matrix_init_user(void) { #ifdef AUDIO_ENABLE -uint8_t starting_note = 0x0C; -int offset = 7; - -void process_action_user(keyrecord_t *record) { - - if (IS_LAYER_ON(_MUSIC)) { - if (record->event.pressed) { - play_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)), 0xF); - } else { - stop_note(((double)220.0)*pow(2.0, -4.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row))); - } - } - -} - void play_goodbye_tone() { PLAY_NOTE_ARRAY(goodbye, false, 0); diff --git a/keyboard/preonic/preonic.c b/keyboard/preonic/preonic.c index f639f247a51..13e05c65a73 100644 --- a/keyboard/preonic/preonic.c +++ b/keyboard/preonic/preonic.c @@ -11,8 +11,8 @@ void matrix_scan_user(void) { }; __attribute__ ((weak)) -void process_action_user(keyrecord_t *record) { - +bool process_action_user(keyrecord_t *record) { + return true; }; void matrix_init_kb(void) { @@ -36,6 +36,67 @@ void matrix_scan_kb(void) { matrix_scan_user(); }; -void process_action_kb(keyrecord_t *record) { - process_action_user(record); -} \ No newline at end of file +bool process_action_kb(keyrecord_t *record) { + return process_action_user(record); +} + +#ifdef BACKLIGHT_ENABLE +#define CHANNEL OCR1C + +void backlight_init_ports() +{ + + // Setup PB7 as output and output low. + DDRB |= (1<<7); + PORTB &= ~(1<<7); + + // Use full 16-bit resolution. + ICR1 = 0xFFFF; + + // I could write a wall of text here to explain... but TL;DW + // Go read the ATmega32u4 datasheet. + // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on + + // Pin PB7 = OCR1C (Timer 1, Channel C) + // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 + // (i.e. start high, go low when counter matches.) + // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 + // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 + + TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; + TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + + backlight_init(); +} + +void backlight_set(uint8_t level) +{ + if ( level == 0 ) + { + // Turn off PWM control on PB7, revert to output low. + TCCR1A &= ~(_BV(COM1C1)); + CHANNEL = 0x0; + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + } + else if ( level == BACKLIGHT_LEVELS ) + { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF; + } + else + { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); + } +} + +#endif \ No newline at end of file diff --git a/keyboard/preonic/preonic.h b/keyboard/preonic/preonic.h index 51ed9ba393b..feb87977440 100644 --- a/keyboard/preonic/preonic.h +++ b/keyboard/preonic/preonic.h @@ -1,18 +1,7 @@ #ifndef PREONIC_H #define PREONIC_H -#include "matrix.h" -#include "keymap_common.h" -#ifdef BACKLIGHT_ENABLE - #include "backlight.h" -#endif -#ifdef RGBLIGHT_ENABLE - #include "rgblight.h" -#endif -#include -#ifdef MIDI_ENABLE - #include -#endif +#include "quantum.h" #define PREONIC_MIT( \ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k0a, k0b, \ @@ -46,6 +35,6 @@ void matrix_init_user(void); void matrix_scan_user(void); -void process_action_kb(keyrecord_t *record); +bool process_action_kb(keyrecord_t *record); #endif diff --git a/keyboard/preonic/preonic_pcb_r1.hex b/keyboard/preonic/preonic_pcb_r1.hex index 5bdc190e1de..eda1b1979f4 100644 Binary files a/keyboard/preonic/preonic_pcb_r1.hex and b/keyboard/preonic/preonic_pcb_r1.hex differ diff --git a/keyboard/preonic/preonic_pcb_r1_w_bootloader.hex b/keyboard/preonic/preonic_pcb_r1_w_bootloader.hex index a29f23c00ef..c42365c436f 100644 Binary files a/keyboard/preonic/preonic_pcb_r1_w_bootloader.hex and b/keyboard/preonic/preonic_pcb_r1_w_bootloader.hex differ diff --git a/keyboard/retro_refit/config.h b/keyboard/retro_refit/config.h index 05fceb92b2b..f2194e550cc 100644 --- a/keyboard/retro_refit/config.h +++ b/keyboard/retro_refit/config.h @@ -33,8 +33,9 @@ along with this program. If not, see . #define MATRIX_COLS 8 // See note in retro_refit.h for an explanation of how this matrix is wired up -#define COLS (int []){ B0, B1, B2, B3, D2, D3, C7, D5 } -#define ROWS (int []){ D4, D7, B4, B5, B6, F7, F6, F5, F4, F1, F0 } +#define MATRIX_ROW_PINS { D4, D7, B4, B5, B6, F7, F6, F5, F4, F1, F0 } +#define MATRIX_COL_PINS { B0, B1, B2, B3, D2, D3, C7, D5 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW @@ -46,7 +47,7 @@ along with this program. If not, see . #define BACKLIGHT_LEVELS 0 /* Set 0 if debouncing isn't needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ #define LOCKING_SUPPORT_ENABLE @@ -119,4 +120,4 @@ along with this program. If not, see . //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION -#endif \ No newline at end of file +#endif diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index e85370d9583..3ca249fdf57 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -1,6 +1,6 @@ #include #include -#include +//#include #include #include #include @@ -10,30 +10,28 @@ #include "eeconfig.h" -#ifdef VIBRATO_ENABLE - #include "vibrato_lut.h" -#endif - -#define PI 3.14159265 - #define CPU_PRESCALER 8 -#ifdef PWM_AUDIO - #include "wave.h" - #define SAMPLE_DIVIDER 39 - #define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048) - // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap +// ----------------------------------------------------------------------------- +// Timer Abstractions +// ----------------------------------------------------------------------------- - float places[8] = {0, 0, 0, 0, 0, 0, 0, 0}; - uint16_t place_int = 0; - bool repeat = true; -#endif +// TIMSK3 - Timer/Counter #3 Interrupt Mask Register +// Turn on/off 3A interputs, stopping/enabling the ISR calls +#define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) +#define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) + +// TCCR3A: Timer/Counter #3 Control Register +// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 +#define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); +#define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); + +// Fast PWM Mode Controls +#define TIMER_3_PERIOD ICR3 +#define TIMER_3_DUTY_CYCLE OCR3A + +// ----------------------------------------------------------------------------- -void delay_us(int count) { - while(count--) { - _delay_us(1); - } -} int voices = 0; int voice_place = 0; @@ -45,26 +43,23 @@ float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; bool sliding = false; -int max = 0xFF; -float sum = 0; float place = 0; uint8_t * sample; uint16_t sample_length = 0; -// float freq = 0; -bool notes = false; -bool note = false; -float note_frequency = 0; -float note_length = 0; -float note_tempo = TEMPO_DEFAULT; -float note_timbre = TIMBRE_DEFAULT; +bool playing_notes = false; +bool playing_note = false; +float note_frequency = 0; +float note_length = 0; +uint8_t note_tempo = TEMPO_DEFAULT; +float note_timbre = TIMBRE_DEFAULT; uint16_t note_position = 0; float (* notes_pointer)[][2]; uint16_t notes_count; -bool notes_repeat; -float notes_rest; -bool note_resting = false; +bool notes_repeat; +float notes_rest; +bool note_resting = false; uint8_t current_note = 0; uint8_t rest_counter = 0; @@ -77,20 +72,323 @@ float vibrato_rate = 0.125; float polyphony_rate = 0; -bool inited = false; +static bool audio_initialized = false; audio_config_t audio_config; uint16_t envelope_index = 0; +void audio_init() +{ + + // Check EEPROM + if (!eeconfig_is_enabled()) + { + eeconfig_init(); + } + audio_config.raw = eeconfig_read_audio(); + + // Set port PC6 (OC3A and /OC4A) as output + DDRC |= _BV(PORTC6); + + DISABLE_AUDIO_COUNTER_3_ISR; + + // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers + // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 + // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) + // Clock Select (CS3n) = 0b010 = Clock / 8 + TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); + TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); + + audio_initialized = true; +} + +void stop_all_notes() +{ + if (!audio_initialized) { + audio_init(); + } + voices = 0; + + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + + playing_notes = false; + playing_note = false; + frequency = 0; + volume = 0; + + for (uint8_t i = 0; i < 8; i++) + { + frequencies[i] = 0; + volumes[i] = 0; + } +} + +void stop_note(float freq) +{ + if (playing_note) { + if (!audio_initialized) { + audio_init(); + } + for (int i = 7; i >= 0; i--) { + if (frequencies[i] == freq) { + frequencies[i] = 0; + volumes[i] = 0; + for (int j = i; (j < 7); j++) { + frequencies[j] = frequencies[j+1]; + frequencies[j+1] = 0; + volumes[j] = volumes[j+1]; + volumes[j+1] = 0; + } + break; + } + } + voices--; + if (voices < 0) + voices = 0; + if (voice_place >= voices) { + voice_place = 0; + } + if (voices == 0) { + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + frequency = 0; + volume = 0; + playing_note = false; + } + } +} + +#ifdef VIBRATO_ENABLE + +float mod(float a, int b) +{ + float r = fmod(a, b); + return r < 0 ? r + b : r; +} + +float vibrato(float average_freq) { + #ifdef VIBRATO_STRENGTH_ENABLE + float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); + #else + float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; + #endif + vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); + return vibrated_freq; +} + +#endif + +ISR(TIMER3_COMPA_vect) +{ + float freq; + + if (playing_note) { + if (voices > 0) { + if (polyphony_rate > 0) { + if (voices > 1) { + voice_place %= voices; + if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { + voice_place = (voice_place + 1) % voices; + place = 0.0; + } + } + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequencies[voice_place]); + } else { + freq = frequencies[voice_place]; + } + #else + freq = frequencies[voice_place]; + #endif + } else { + if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, 440/frequency/12/2); + } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, -440/frequency/12/2); + } else { + frequency = frequencies[voices - 1]; + } + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequency); + } else { + freq = frequency; + } + #else + freq = frequency; + #endif + } + + if (envelope_index < 65535) { + envelope_index++; + } + + freq = voice_envelope(freq); + + if (freq < 30.517578125) { + freq = 30.52; + } + + TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); + TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); + } + } + + if (playing_notes) { + if (note_frequency > 0) { + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(note_frequency); + } else { + freq = note_frequency; + } + #else + freq = note_frequency; + #endif + + if (envelope_index < 65535) { + envelope_index++; + } + freq = voice_envelope(freq); + + TIMER_3_PERIOD = (uint16_t)(((float)F_CPU) / (freq * CPU_PRESCALER)); + TIMER_3_DUTY_CYCLE = (uint16_t)((((float)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); + } else { + TIMER_3_PERIOD = 0; + TIMER_3_DUTY_CYCLE = 0; + } + + note_position++; + bool end_of_note = false; + if (TIMER_3_PERIOD > 0) { + end_of_note = (note_position >= (note_length / TIMER_3_PERIOD * 0xFFFF)); + } else { + end_of_note = (note_position >= (note_length * 0x7FF)); + } + + if (end_of_note) { + current_note++; + if (current_note >= notes_count) { + if (notes_repeat) { + current_note = 0; + } else { + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + playing_notes = false; + return; + } + } + if (!note_resting && (notes_rest > 0)) { + note_resting = true; + note_frequency = 0; + note_length = notes_rest; + current_note--; + } else { + note_resting = false; + envelope_index = 0; + note_frequency = (*notes_pointer)[current_note][0]; + note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); + } + + note_position = 0; + } + } + + if (!audio_config.enable) { + playing_notes = false; + playing_note = false; + } +} + +void play_note(float freq, int vol) { + + if (!audio_initialized) { + audio_init(); + } + + if (audio_config.enable && voices < 8) { + DISABLE_AUDIO_COUNTER_3_ISR; + + // Cancel notes if notes are playing + if (playing_notes) + stop_all_notes(); + + playing_note = true; + + envelope_index = 0; + + if (freq > 0) { + frequencies[voices] = freq; + volumes[voices] = vol; + voices++; + } + + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + } + +} + +void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) +{ + + if (!audio_initialized) { + audio_init(); + } + + if (audio_config.enable) { + + DISABLE_AUDIO_COUNTER_3_ISR; + + // Cancel note if a note is playing + if (playing_note) + stop_all_notes(); + + playing_notes = true; + + notes_pointer = np; + notes_count = n_count; + notes_repeat = n_repeat; + notes_rest = n_rest; + + place = 0; + current_note = 0; + + note_frequency = (*notes_pointer)[current_note][0]; + note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); + note_position = 0; + + + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + } + +} + +bool is_playing_notes(void) { + return playing_notes; +} + +bool is_audio_on(void) { + return (audio_config.enable != 0); +} + void audio_toggle(void) { audio_config.enable ^= 1; eeconfig_update_audio(audio_config.raw); + if (audio_config.enable) + audio_on_user(); } void audio_on(void) { audio_config.enable = 1; eeconfig_update_audio(audio_config.raw); + audio_on_user(); } void audio_off(void) { @@ -99,6 +397,7 @@ void audio_off(void) { } #ifdef VIBRATO_ENABLE + // Vibrato rate functions void set_vibrato_rate(float rate) { @@ -127,9 +426,9 @@ void decrease_vibrato_strength(float change) { vibrato_strength /= change; } -#endif +#endif /* VIBRATO_STRENGTH_ENABLE */ -#endif +#endif /* VIBRATO_ENABLE */ // Polyphony functions @@ -161,447 +460,18 @@ void set_timbre(float timbre) { // Tempo functions -void set_tempo(float tempo) { +void set_tempo(uint8_t tempo) { note_tempo = tempo; } void decrease_tempo(uint8_t tempo_change) { - note_tempo += (float) tempo_change; + note_tempo += tempo_change; } void increase_tempo(uint8_t tempo_change) { - if (note_tempo - (float) tempo_change < 10) { + if (note_tempo - tempo_change < 10) { note_tempo = 10; } else { - note_tempo -= (float) tempo_change; + note_tempo -= tempo_change; } } - -void audio_init() { - - /* check signature */ - if (!eeconfig_is_enabled()) { - eeconfig_init(); - } - audio_config.raw = eeconfig_read_audio(); - - #ifdef PWM_AUDIO - PLLFRQ = _BV(PDIV2); - PLLCSR = _BV(PLLE); - while(!(PLLCSR & _BV(PLOCK))); - PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */ - - /* Init a fast PWM on Timer4 */ - TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */ - TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */ - OCR4A = 0; - - /* Enable the OC4A output */ - DDRC |= _BV(PORTC6); - - TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs - - TCCR3A = 0x0; // Options not needed - TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC - OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback - #else - DDRC |= _BV(PORTC6); - - TIMSK3 &= ~_BV(OCIE3A); // Turn off 3A interputs - - TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); - TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); - #endif - - inited = true; -} - -void stop_all_notes() { - if (!inited) { - audio_init(); - } - voices = 0; - #ifdef PWM_AUDIO - TIMSK3 &= ~_BV(OCIE3A); - #else - TIMSK3 &= ~_BV(OCIE3A); - TCCR3A &= ~_BV(COM3A1); - #endif - notes = false; - note = false; - frequency = 0; - volume = 0; - - for (int i = 0; i < 8; i++) { - frequencies[i] = 0; - volumes[i] = 0; - } -} - -void stop_note(float freq) { - if (note) { - if (!inited) { - audio_init(); - } - #ifdef PWM_AUDIO - freq = freq / SAMPLE_RATE; - #endif - for (int i = 7; i >= 0; i--) { - if (frequencies[i] == freq) { - frequencies[i] = 0; - volumes[i] = 0; - for (int j = i; (j < 7); j++) { - frequencies[j] = frequencies[j+1]; - frequencies[j+1] = 0; - volumes[j] = volumes[j+1]; - volumes[j+1] = 0; - } - break; - } - } - voices--; - if (voices < 0) - voices = 0; - if (voice_place >= voices) { - voice_place = 0; - } - if (voices == 0) { - #ifdef PWM_AUDIO - TIMSK3 &= ~_BV(OCIE3A); - #else - TIMSK3 &= ~_BV(OCIE3A); - TCCR3A &= ~_BV(COM3A1); - #endif - frequency = 0; - volume = 0; - note = false; - } - } -} - -#ifdef VIBRATO_ENABLE - -float mod(float a, int b) -{ - float r = fmod(a, b); - return r < 0 ? r + b : r; -} - -float vibrato(float average_freq) { - #ifdef VIBRATO_STRENGTH_ENABLE - float vibrated_freq = average_freq * pow(VIBRATO_LUT[(int)vibrato_counter], vibrato_strength); - #else - float vibrated_freq = average_freq * VIBRATO_LUT[(int)vibrato_counter]; - #endif - vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); - return vibrated_freq; -} - -#endif - -ISR(TIMER3_COMPA_vect) { - if (note) { - #ifdef PWM_AUDIO - if (voices == 1) { - // SINE - OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2; - - // SQUARE - // if (((int)place) >= 1024){ - // OCR4A = 0xFF >> 2; - // } else { - // OCR4A = 0x00; - // } - - // SAWTOOTH - // OCR4A = (int)place / 4; - - // TRIANGLE - // if (((int)place) >= 1024) { - // OCR4A = (int)place / 2; - // } else { - // OCR4A = 2048 - (int)place / 2; - // } - - place += frequency; - - if (place >= SINE_LENGTH) - place -= SINE_LENGTH; - - } else { - int sum = 0; - for (int i = 0; i < voices; i++) { - // SINE - sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2; - - // SQUARE - // if (((int)places[i]) >= 1024){ - // sum += 0xFF >> 2; - // } else { - // sum += 0x00; - // } - - places[i] += frequencies[i]; - - if (places[i] >= SINE_LENGTH) - places[i] -= SINE_LENGTH; - } - OCR4A = sum; - } - #else - if (voices > 0) { - float freq; - if (polyphony_rate > 0) { - if (voices > 1) { - voice_place %= voices; - if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { - voice_place = (voice_place + 1) % voices; - place = 0.0; - } - } - #ifdef VIBRATO_ENABLE - if (vibrato_strength > 0) { - freq = vibrato(frequencies[voice_place]); - } else { - #else - { - #endif - freq = frequencies[voice_place]; - } - } else { - if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { - frequency = frequency * pow(2, 440/frequency/12/2); - } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { - frequency = frequency * pow(2, -440/frequency/12/2); - } else { - frequency = frequencies[voices - 1]; - } - - - #ifdef VIBRATO_ENABLE - if (vibrato_strength > 0) { - freq = vibrato(frequency); - } else { - #else - { - #endif - freq = frequency; - } - } - - if (envelope_index < 65535) { - envelope_index++; - } - freq = voice_envelope(freq); - - if (freq < 30.517578125) - freq = 30.52; - ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period - OCR3A = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period - } - #endif - } - - // SAMPLE - // OCR4A = pgm_read_byte(&sample[(uint16_t)place_int]); - - // place_int++; - - // if (place_int >= sample_length) - // if (repeat) - // place_int -= sample_length; - // else - // TIMSK3 &= ~_BV(OCIE3A); - - - if (notes) { - #ifdef PWM_AUDIO - OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0; - - place += note_frequency; - if (place >= SINE_LENGTH) - place -= SINE_LENGTH; - #else - if (note_frequency > 0) { - float freq; - - #ifdef VIBRATO_ENABLE - if (vibrato_strength > 0) { - freq = vibrato(note_frequency); - } else { - #else - { - #endif - freq = note_frequency; - } - - if (envelope_index < 65535) { - envelope_index++; - } - freq = voice_envelope(freq); - - ICR3 = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period - OCR3A = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period - } else { - ICR3 = 0; - OCR3A = 0; - } - #endif - - - note_position++; - bool end_of_note = false; - if (ICR3 > 0) - end_of_note = (note_position >= (note_length / ICR3 * 0xFFFF)); - else - end_of_note = (note_position >= (note_length * 0x7FF)); - if (end_of_note) { - current_note++; - if (current_note >= notes_count) { - if (notes_repeat) { - current_note = 0; - } else { - #ifdef PWM_AUDIO - TIMSK3 &= ~_BV(OCIE3A); - #else - TIMSK3 &= ~_BV(OCIE3A); - TCCR3A &= ~_BV(COM3A1); - #endif - notes = false; - return; - } - } - if (!note_resting && (notes_rest > 0)) { - note_resting = true; - note_frequency = 0; - note_length = notes_rest; - current_note--; - } else { - note_resting = false; - #ifdef PWM_AUDIO - note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; - note_length = (*notes_pointer)[current_note][1] * (note_tempo / 100); - #else - envelope_index = 0; - note_frequency = (*notes_pointer)[current_note][0]; - note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100); - #endif - } - note_position = 0; - } - - } - - if (!audio_config.enable) { - notes = false; - note = false; - } -} - -void play_note(float freq, int vol) { - - if (!inited) { - audio_init(); - } - -if (audio_config.enable && voices < 8) { - TIMSK3 &= ~_BV(OCIE3A); - // Cancel notes if notes are playing - if (notes) - stop_all_notes(); - note = true; - envelope_index = 0; - #ifdef PWM_AUDIO - freq = freq / SAMPLE_RATE; - #endif - if (freq > 0) { - frequencies[voices] = freq; - volumes[voices] = vol; - voices++; - } - - #ifdef PWM_AUDIO - TIMSK3 |= _BV(OCIE3A); - #else - TIMSK3 |= _BV(OCIE3A); - TCCR3A |= _BV(COM3A1); - #endif -} - -} - -void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) { - - if (!inited) { - audio_init(); - } - -if (audio_config.enable) { - TIMSK3 &= ~_BV(OCIE3A); - // Cancel note if a note is playing - if (note) - stop_all_notes(); - notes = true; - - notes_pointer = np; - notes_count = n_count; - notes_repeat = n_repeat; - notes_rest = n_rest; - - place = 0; - current_note = 0; - #ifdef PWM_AUDIO - note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; - note_length = (*notes_pointer)[current_note][1] * (note_tempo / 100); - #else - note_frequency = (*notes_pointer)[current_note][0]; - note_length = ((*notes_pointer)[current_note][1] / 4) * (note_tempo / 100); - #endif - note_position = 0; - - - #ifdef PWM_AUDIO - TIMSK3 |= _BV(OCIE3A); - #else - TIMSK3 |= _BV(OCIE3A); - TCCR3A |= _BV(COM3A1); - #endif -} - -} - -#ifdef PWM_AUDIO -void play_sample(uint8_t * s, uint16_t l, bool r) { - if (!inited) { - audio_init(); - } - - if (audio_config.enable) { - TIMSK3 &= ~_BV(OCIE3A); - stop_all_notes(); - place_int = 0; - sample = s; - sample_length = l; - repeat = r; - - TIMSK3 |= _BV(OCIE3A); - } -} -#endif - -//------------------------------------------------------------------------------ -// Override these functions in your keymap file to play different tunes on -// startup and bootloader jump -__attribute__ ((weak)) -void play_startup_tone() -{ -} - - - -__attribute__ ((weak)) -void play_goodbye_tone() -{ - -} -//------------------------------------------------------------------------------ diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 89769507e1b..00d45f7ac19 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -5,6 +5,7 @@ #include "musical_notes.h" #include "song_list.h" #include "voices.h" +#include "quantum.h" #ifndef AUDIO_H #define AUDIO_H @@ -25,6 +26,7 @@ typedef union { }; } audio_config_t; +bool is_audio_on(void); void audio_toggle(void); void audio_on(void); void audio_off(void); @@ -56,7 +58,7 @@ void increase_polyphony_rate(float change); void decrease_polyphony_rate(float change); void set_timbre(float timbre); -void set_tempo(float tempo); +void set_tempo(uint8_t tempo); void increase_tempo(uint8_t tempo_change); void decrease_tempo(uint8_t tempo_change); @@ -71,11 +73,11 @@ void stop_note(float freq); void stop_all_notes(void); void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest); -#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ - 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ - 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ - 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ - 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } +#define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ + 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ + 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ + 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ + 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } // These macros are used to allow play_notes to play an array of indeterminate // length. This works around the limitation of C's sizeof operation on pointers. @@ -83,7 +85,7 @@ void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) #define NOTE_ARRAY_SIZE(x) ((int16_t)(sizeof(x) / (sizeof(x[0])))) #define PLAY_NOTE_ARRAY(note_array, note_repeat, note_rest_style) play_notes(¬e_array, NOTE_ARRAY_SIZE((note_array)), (note_repeat), (note_rest_style)); -void play_goodbye_tone(void); -void play_startup_tone(void); + +bool is_playing_notes(void); #endif \ No newline at end of file diff --git a/quantum/audio/audio_pwm.c b/quantum/audio/audio_pwm.c new file mode 100644 index 00000000000..328a253a7e9 --- /dev/null +++ b/quantum/audio/audio_pwm.c @@ -0,0 +1,643 @@ +#include +#include +//#include +#include +#include +#include +#include "print.h" +#include "audio.h" +#include "keymap_common.h" + +#include "eeconfig.h" + +#define PI 3.14159265 + +#define CPU_PRESCALER 8 + + +// Timer Abstractions + +// TIMSK3 - Timer/Counter #3 Interrupt Mask Register +// Turn on/off 3A interputs, stopping/enabling the ISR calls +#define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A) +#define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A) + + +// TCCR3A: Timer/Counter #3 Control Register +// Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 +#define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1); +#define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0)); + + +#define NOTE_PERIOD ICR3 +#define NOTE_DUTY_CYCLE OCR3A + + +#ifdef PWM_AUDIO + #include "wave.h" + #define SAMPLE_DIVIDER 39 + #define SAMPLE_RATE (2000000.0/SAMPLE_DIVIDER/2048) + // Resistor value of 1/ (2 * PI * 10nF * (2000000 hertz / SAMPLE_DIVIDER / 10)) for 10nF cap + + float places[8] = {0, 0, 0, 0, 0, 0, 0, 0}; + uint16_t place_int = 0; + bool repeat = true; +#endif + +void delay_us(int count) { + while(count--) { + _delay_us(1); + } +} + +int voices = 0; +int voice_place = 0; +float frequency = 0; +int volume = 0; +long position = 0; + +float frequencies[8] = {0, 0, 0, 0, 0, 0, 0, 0}; +int volumes[8] = {0, 0, 0, 0, 0, 0, 0, 0}; +bool sliding = false; + +float place = 0; + +uint8_t * sample; +uint16_t sample_length = 0; +// float freq = 0; + +bool playing_notes = false; +bool playing_note = false; +float note_frequency = 0; +float note_length = 0; +uint8_t note_tempo = TEMPO_DEFAULT; +float note_timbre = TIMBRE_DEFAULT; +uint16_t note_position = 0; +float (* notes_pointer)[][2]; +uint16_t notes_count; +bool notes_repeat; +float notes_rest; +bool note_resting = false; + +uint8_t current_note = 0; +uint8_t rest_counter = 0; + +#ifdef VIBRATO_ENABLE +float vibrato_counter = 0; +float vibrato_strength = .5; +float vibrato_rate = 0.125; +#endif + +float polyphony_rate = 0; + +static bool audio_initialized = false; + +audio_config_t audio_config; + +uint16_t envelope_index = 0; + +void audio_init() { + + // Check EEPROM + if (!eeconfig_is_enabled()) + { + eeconfig_init(); + } + audio_config.raw = eeconfig_read_audio(); + + #ifdef PWM_AUDIO + + PLLFRQ = _BV(PDIV2); + PLLCSR = _BV(PLLE); + while(!(PLLCSR & _BV(PLOCK))); + PLLFRQ |= _BV(PLLTM0); /* PCK 48MHz */ + + /* Init a fast PWM on Timer4 */ + TCCR4A = _BV(COM4A0) | _BV(PWM4A); /* Clear OC4A on Compare Match */ + TCCR4B = _BV(CS40); /* No prescaling => f = PCK/256 = 187500Hz */ + OCR4A = 0; + + /* Enable the OC4A output */ + DDRC |= _BV(PORTC6); + + DISABLE_AUDIO_COUNTER_3_ISR; // Turn off 3A interputs + + TCCR3A = 0x0; // Options not needed + TCCR3B = _BV(CS31) | _BV(CS30) | _BV(WGM32); // 64th prescaling and CTC + OCR3A = SAMPLE_DIVIDER - 1; // Correct count/compare, related to sample playback + + #else + + // Set port PC6 (OC3A and /OC4A) as output + DDRC |= _BV(PORTC6); + + DISABLE_AUDIO_COUNTER_3_ISR; + + // TCCR3A / TCCR3B: Timer/Counter #3 Control Registers + // Compare Output Mode (COM3An) = 0b00 = Normal port operation, OC3A disconnected from PC6 + // Waveform Generation Mode (WGM3n) = 0b1110 = Fast PWM Mode 14 (Period = ICR3, Duty Cycle = OCR3A) + // Clock Select (CS3n) = 0b010 = Clock / 8 + TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30); + TCCR3B = (1 << WGM33) | (1 << WGM32) | (0 << CS32) | (1 << CS31) | (0 << CS30); + + #endif + + audio_initialized = true; +} + +void stop_all_notes() { + if (!audio_initialized) { + audio_init(); + } + voices = 0; + #ifdef PWM_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #else + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + + playing_notes = false; + playing_note = false; + frequency = 0; + volume = 0; + + for (uint8_t i = 0; i < 8; i++) + { + frequencies[i] = 0; + volumes[i] = 0; + } +} + +void stop_note(float freq) +{ + if (playing_note) { + if (!audio_initialized) { + audio_init(); + } + #ifdef PWM_AUDIO + freq = freq / SAMPLE_RATE; + #endif + for (int i = 7; i >= 0; i--) { + if (frequencies[i] == freq) { + frequencies[i] = 0; + volumes[i] = 0; + for (int j = i; (j < 7); j++) { + frequencies[j] = frequencies[j+1]; + frequencies[j+1] = 0; + volumes[j] = volumes[j+1]; + volumes[j+1] = 0; + } + break; + } + } + voices--; + if (voices < 0) + voices = 0; + if (voice_place >= voices) { + voice_place = 0; + } + if (voices == 0) { + #ifdef PWM_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #else + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + frequency = 0; + volume = 0; + playing_note = false; + } + } +} + +#ifdef VIBRATO_ENABLE + +float mod(float a, int b) +{ + float r = fmod(a, b); + return r < 0 ? r + b : r; +} + +float vibrato(float average_freq) { + #ifdef VIBRATO_STRENGTH_ENABLE + float vibrated_freq = average_freq * pow(vibrato_lut[(int)vibrato_counter], vibrato_strength); + #else + float vibrated_freq = average_freq * vibrato_lut[(int)vibrato_counter]; + #endif + vibrato_counter = mod((vibrato_counter + vibrato_rate * (1.0 + 440.0/average_freq)), VIBRATO_LUT_LENGTH); + return vibrated_freq; +} + +#endif + +ISR(TIMER3_COMPA_vect) +{ + if (playing_note) { + #ifdef PWM_AUDIO + if (voices == 1) { + // SINE + OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 2; + + // SQUARE + // if (((int)place) >= 1024){ + // OCR4A = 0xFF >> 2; + // } else { + // OCR4A = 0x00; + // } + + // SAWTOOTH + // OCR4A = (int)place / 4; + + // TRIANGLE + // if (((int)place) >= 1024) { + // OCR4A = (int)place / 2; + // } else { + // OCR4A = 2048 - (int)place / 2; + // } + + place += frequency; + + if (place >= SINE_LENGTH) + place -= SINE_LENGTH; + + } else { + int sum = 0; + for (int i = 0; i < voices; i++) { + // SINE + sum += pgm_read_byte(&sinewave[(uint16_t)places[i]]) >> 2; + + // SQUARE + // if (((int)places[i]) >= 1024){ + // sum += 0xFF >> 2; + // } else { + // sum += 0x00; + // } + + places[i] += frequencies[i]; + + if (places[i] >= SINE_LENGTH) + places[i] -= SINE_LENGTH; + } + OCR4A = sum; + } + #else + if (voices > 0) { + float freq; + if (polyphony_rate > 0) { + if (voices > 1) { + voice_place %= voices; + if (place++ > (frequencies[voice_place] / polyphony_rate / CPU_PRESCALER)) { + voice_place = (voice_place + 1) % voices; + place = 0.0; + } + } + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequencies[voice_place]); + } else { + #else + { + #endif + freq = frequencies[voice_place]; + } + } else { + if (frequency != 0 && frequency < frequencies[voices - 1] && frequency < frequencies[voices - 1] * pow(2, -440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, 440/frequency/12/2); + } else if (frequency != 0 && frequency > frequencies[voices - 1] && frequency > frequencies[voices - 1] * pow(2, 440/frequencies[voices - 1]/12/2)) { + frequency = frequency * pow(2, -440/frequency/12/2); + } else { + frequency = frequencies[voices - 1]; + } + + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(frequency); + } else { + #else + { + #endif + freq = frequency; + } + } + + if (envelope_index < 65535) { + envelope_index++; + } + freq = voice_envelope(freq); + + if (freq < 30.517578125) + freq = 30.52; + NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period + NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period + } + #endif + } + + // SAMPLE + // OCR4A = pgm_read_byte(&sample[(uint16_t)place_int]); + + // place_int++; + + // if (place_int >= sample_length) + // if (repeat) + // place_int -= sample_length; + // else + // DISABLE_AUDIO_COUNTER_3_ISR; + + + if (playing_notes) { + #ifdef PWM_AUDIO + OCR4A = pgm_read_byte(&sinewave[(uint16_t)place]) >> 0; + + place += note_frequency; + if (place >= SINE_LENGTH) + place -= SINE_LENGTH; + #else + if (note_frequency > 0) { + float freq; + + #ifdef VIBRATO_ENABLE + if (vibrato_strength > 0) { + freq = vibrato(note_frequency); + } else { + #else + { + #endif + freq = note_frequency; + } + + if (envelope_index < 65535) { + envelope_index++; + } + freq = voice_envelope(freq); + + NOTE_PERIOD = (int)(((double)F_CPU) / (freq * CPU_PRESCALER)); // Set max to the period + NOTE_DUTY_CYCLE = (int)((((double)F_CPU) / (freq * CPU_PRESCALER)) * note_timbre); // Set compare to half the period + } else { + NOTE_PERIOD = 0; + NOTE_DUTY_CYCLE = 0; + } + #endif + + + note_position++; + bool end_of_note = false; + if (NOTE_PERIOD > 0) + end_of_note = (note_position >= (note_length / NOTE_PERIOD * 0xFFFF)); + else + end_of_note = (note_position >= (note_length * 0x7FF)); + if (end_of_note) { + current_note++; + if (current_note >= notes_count) { + if (notes_repeat) { + current_note = 0; + } else { + #ifdef PWM_AUDIO + DISABLE_AUDIO_COUNTER_3_ISR; + #else + DISABLE_AUDIO_COUNTER_3_ISR; + DISABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + playing_notes = false; + return; + } + } + if (!note_resting && (notes_rest > 0)) { + note_resting = true; + note_frequency = 0; + note_length = notes_rest; + current_note--; + } else { + note_resting = false; + #ifdef PWM_AUDIO + note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; + note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); + #else + envelope_index = 0; + note_frequency = (*notes_pointer)[current_note][0]; + note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); + #endif + } + note_position = 0; + } + + } + + if (!audio_config.enable) { + playing_notes = false; + playing_note = false; + } +} + +void play_note(float freq, int vol) { + + if (!audio_initialized) { + audio_init(); + } + + if (audio_config.enable && voices < 8) { + DISABLE_AUDIO_COUNTER_3_ISR; + + // Cancel notes if notes are playing + if (playing_notes) + stop_all_notes(); + + playing_note = true; + + envelope_index = 0; + + #ifdef PWM_AUDIO + freq = freq / SAMPLE_RATE; + #endif + if (freq > 0) { + frequencies[voices] = freq; + volumes[voices] = vol; + voices++; + } + + #ifdef PWM_AUDIO + ENABLE_AUDIO_COUNTER_3_ISR; + #else + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + } + +} + +void play_notes(float (*np)[][2], uint16_t n_count, bool n_repeat, float n_rest) +{ + + if (!audio_initialized) { + audio_init(); + } + + if (audio_config.enable) { + + DISABLE_AUDIO_COUNTER_3_ISR; + + // Cancel note if a note is playing + if (playing_note) + stop_all_notes(); + + playing_notes = true; + + notes_pointer = np; + notes_count = n_count; + notes_repeat = n_repeat; + notes_rest = n_rest; + + place = 0; + current_note = 0; + + #ifdef PWM_AUDIO + note_frequency = (*notes_pointer)[current_note][0] / SAMPLE_RATE; + note_length = (*notes_pointer)[current_note][1] * (((float)note_tempo) / 100); + #else + note_frequency = (*notes_pointer)[current_note][0]; + note_length = ((*notes_pointer)[current_note][1] / 4) * (((float)note_tempo) / 100); + #endif + note_position = 0; + + + #ifdef PWM_AUDIO + ENABLE_AUDIO_COUNTER_3_ISR; + #else + ENABLE_AUDIO_COUNTER_3_ISR; + ENABLE_AUDIO_COUNTER_3_OUTPUT; + #endif + } + +} + +#ifdef PWM_AUDIO +void play_sample(uint8_t * s, uint16_t l, bool r) { + if (!audio_initialized) { + audio_init(); + } + + if (audio_config.enable) { + DISABLE_AUDIO_COUNTER_3_ISR; + stop_all_notes(); + place_int = 0; + sample = s; + sample_length = l; + repeat = r; + + ENABLE_AUDIO_COUNTER_3_ISR; + } +} +#endif + + +void audio_toggle(void) { + audio_config.enable ^= 1; + eeconfig_update_audio(audio_config.raw); +} + +void audio_on(void) { + audio_config.enable = 1; + eeconfig_update_audio(audio_config.raw); +} + +void audio_off(void) { + audio_config.enable = 0; + eeconfig_update_audio(audio_config.raw); +} + +#ifdef VIBRATO_ENABLE + +// Vibrato rate functions + +void set_vibrato_rate(float rate) { + vibrato_rate = rate; +} + +void increase_vibrato_rate(float change) { + vibrato_rate *= change; +} + +void decrease_vibrato_rate(float change) { + vibrato_rate /= change; +} + +#ifdef VIBRATO_STRENGTH_ENABLE + +void set_vibrato_strength(float strength) { + vibrato_strength = strength; +} + +void increase_vibrato_strength(float change) { + vibrato_strength *= change; +} + +void decrease_vibrato_strength(float change) { + vibrato_strength /= change; +} + +#endif /* VIBRATO_STRENGTH_ENABLE */ + +#endif /* VIBRATO_ENABLE */ + +// Polyphony functions + +void set_polyphony_rate(float rate) { + polyphony_rate = rate; +} + +void enable_polyphony() { + polyphony_rate = 5; +} + +void disable_polyphony() { + polyphony_rate = 0; +} + +void increase_polyphony_rate(float change) { + polyphony_rate *= change; +} + +void decrease_polyphony_rate(float change) { + polyphony_rate /= change; +} + +// Timbre function + +void set_timbre(float timbre) { + note_timbre = timbre; +} + +// Tempo functions + +void set_tempo(uint8_t tempo) { + note_tempo = tempo; +} + +void decrease_tempo(uint8_t tempo_change) { + note_tempo += tempo_change; +} + +void increase_tempo(uint8_t tempo_change) { + if (note_tempo - tempo_change < 10) { + note_tempo = 10; + } else { + note_tempo -= tempo_change; + } +} + + +//------------------------------------------------------------------------------ +// Override these functions in your keymap file to play different tunes on +// startup and bootloader jump +__attribute__ ((weak)) +void play_startup_tone() +{ +} + +__attribute__ ((weak)) +void play_goodbye_tone() +{ +} +//------------------------------------------------------------------------------ diff --git a/quantum/audio/frequency_lut.h b/quantum/audio/frequency_lut.h deleted file mode 100644 index e62da5be4e0..00000000000 --- a/quantum/audio/frequency_lut.h +++ /dev/null @@ -1,357 +0,0 @@ -#include -#include -#include - -#define FREQUENCY_LUT_LENGTH 349 - -const uint16_t FREQUENCY_LUT[FREQUENCY_LUT_LENGTH] = { -0x8E0B, -0x8C02, -0x8A00, -0x8805, -0x8612, -0x8426, -0x8241, -0x8063, -0x7E8C, -0x7CBB, -0x7AF2, -0x792E, -0x7772, -0x75BB, -0x740B, -0x7261, -0x70BD, -0x6F20, -0x6D88, -0x6BF6, -0x6A69, -0x68E3, -0x6762, -0x65E6, -0x6470, -0x6300, -0x6194, -0x602E, -0x5ECD, -0x5D71, -0x5C1A, -0x5AC8, -0x597B, -0x5833, -0x56EF, -0x55B0, -0x5475, -0x533F, -0x520E, -0x50E1, -0x4FB8, -0x4E93, -0x4D73, -0x4C57, -0x4B3E, -0x4A2A, -0x491A, -0x480E, -0x4705, -0x4601, -0x4500, -0x4402, -0x4309, -0x4213, -0x4120, -0x4031, -0x3F46, -0x3E5D, -0x3D79, -0x3C97, -0x3BB9, -0x3ADD, -0x3A05, -0x3930, -0x385E, -0x3790, -0x36C4, -0x35FB, -0x3534, -0x3471, -0x33B1, -0x32F3, -0x3238, -0x3180, -0x30CA, -0x3017, -0x2F66, -0x2EB8, -0x2E0D, -0x2D64, -0x2CBD, -0x2C19, -0x2B77, -0x2AD8, -0x2A3A, -0x299F, -0x2907, -0x2870, -0x27DC, -0x2749, -0x26B9, -0x262B, -0x259F, -0x2515, -0x248D, -0x2407, -0x2382, -0x2300, -0x2280, -0x2201, -0x2184, -0x2109, -0x2090, -0x2018, -0x1FA3, -0x1F2E, -0x1EBC, -0x1E4B, -0x1DDC, -0x1D6E, -0x1D02, -0x1C98, -0x1C2F, -0x1BC8, -0x1B62, -0x1AFD, -0x1A9A, -0x1A38, -0x19D8, -0x1979, -0x191C, -0x18C0, -0x1865, -0x180B, -0x17B3, -0x175C, -0x1706, -0x16B2, -0x165E, -0x160C, -0x15BB, -0x156C, -0x151D, -0x14CF, -0x1483, -0x1438, -0x13EE, -0x13A4, -0x135C, -0x1315, -0x12CF, -0x128A, -0x1246, -0x1203, -0x11C1, -0x1180, -0x1140, -0x1100, -0x10C2, -0x1084, -0x1048, -0x100C, -0xFD1, -0xF97, -0xF5E, -0xF25, -0xEEE, -0xEB7, -0xE81, -0xE4C, -0xE17, -0xDE4, -0xDB1, -0xD7E, -0xD4D, -0xD1C, -0xCEC, -0xCBC, -0xC8E, -0xC60, -0xC32, -0xC05, -0xBD9, -0xBAE, -0xB83, -0xB59, -0xB2F, -0xB06, -0xADD, -0xAB6, -0xA8E, -0xA67, -0xA41, -0xA1C, -0x9F7, -0x9D2, -0x9AE, -0x98A, -0x967, -0x945, -0x923, -0x901, -0x8E0, -0x8C0, -0x8A0, -0x880, -0x861, -0x842, -0x824, -0x806, -0x7E8, -0x7CB, -0x7AF, -0x792, -0x777, -0x75B, -0x740, -0x726, -0x70B, -0x6F2, -0x6D8, -0x6BF, -0x6A6, -0x68E, -0x676, -0x65E, -0x647, -0x630, -0x619, -0x602, -0x5EC, -0x5D7, -0x5C1, -0x5AC, -0x597, -0x583, -0x56E, -0x55B, -0x547, -0x533, -0x520, -0x50E, -0x4FB, -0x4E9, -0x4D7, -0x4C5, -0x4B3, -0x4A2, -0x491, -0x480, -0x470, -0x460, -0x450, -0x440, -0x430, -0x421, -0x412, -0x403, -0x3F4, -0x3E5, -0x3D7, -0x3C9, -0x3BB, -0x3AD, -0x3A0, -0x393, -0x385, -0x379, -0x36C, -0x35F, -0x353, -0x347, -0x33B, -0x32F, -0x323, -0x318, -0x30C, -0x301, -0x2F6, -0x2EB, -0x2E0, -0x2D6, -0x2CB, -0x2C1, -0x2B7, -0x2AD, -0x2A3, -0x299, -0x290, -0x287, -0x27D, -0x274, -0x26B, -0x262, -0x259, -0x251, -0x248, -0x240, -0x238, -0x230, -0x228, -0x220, -0x218, -0x210, -0x209, -0x201, -0x1FA, -0x1F2, -0x1EB, -0x1E4, -0x1DD, -0x1D6, -0x1D0, -0x1C9, -0x1C2, -0x1BC, -0x1B6, -0x1AF, -0x1A9, -0x1A3, -0x19D, -0x197, -0x191, -0x18C, -0x186, -0x180, -0x17B, -0x175, -0x170, -0x16B, -0x165, -0x160, -0x15B, -0x156, -0x151, -0x14C, -0x148, -0x143, -0x13E, -0x13A, -0x135, -0x131, -0x12C, -0x128, -0x124, -0x120, -0x11C, -0x118, -0x114, -0x110, -0x10C, -0x108, -0x104, -0x100, -0xFD, -0xF9, -0xF5, -0xF2, -0xEE -}; \ No newline at end of file diff --git a/quantum/audio/luts.c b/quantum/audio/luts.c new file mode 100644 index 00000000000..9f3de9a05c8 --- /dev/null +++ b/quantum/audio/luts.c @@ -0,0 +1,382 @@ +#include +#include +#include +#include "luts.h" + +const float vibrato_lut[VIBRATO_LUT_LENGTH] = +{ + 1.0022336811487, + 1.0042529943610, + 1.0058584256028, + 1.0068905285205, + 1.0072464122237, + 1.0068905285205, + 1.0058584256028, + 1.0042529943610, + 1.0022336811487, + 1.0000000000000, + 0.9977712970630, + 0.9957650169978, + 0.9941756956510, + 0.9931566259436, + 0.9928057204913, + 0.9931566259436, + 0.9941756956510, + 0.9957650169978, + 0.9977712970630, + 1.0000000000000, +}; + +const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH] = +{ + 0x8E0B, + 0x8C02, + 0x8A00, + 0x8805, + 0x8612, + 0x8426, + 0x8241, + 0x8063, + 0x7E8C, + 0x7CBB, + 0x7AF2, + 0x792E, + 0x7772, + 0x75BB, + 0x740B, + 0x7261, + 0x70BD, + 0x6F20, + 0x6D88, + 0x6BF6, + 0x6A69, + 0x68E3, + 0x6762, + 0x65E6, + 0x6470, + 0x6300, + 0x6194, + 0x602E, + 0x5ECD, + 0x5D71, + 0x5C1A, + 0x5AC8, + 0x597B, + 0x5833, + 0x56EF, + 0x55B0, + 0x5475, + 0x533F, + 0x520E, + 0x50E1, + 0x4FB8, + 0x4E93, + 0x4D73, + 0x4C57, + 0x4B3E, + 0x4A2A, + 0x491A, + 0x480E, + 0x4705, + 0x4601, + 0x4500, + 0x4402, + 0x4309, + 0x4213, + 0x4120, + 0x4031, + 0x3F46, + 0x3E5D, + 0x3D79, + 0x3C97, + 0x3BB9, + 0x3ADD, + 0x3A05, + 0x3930, + 0x385E, + 0x3790, + 0x36C4, + 0x35FB, + 0x3534, + 0x3471, + 0x33B1, + 0x32F3, + 0x3238, + 0x3180, + 0x30CA, + 0x3017, + 0x2F66, + 0x2EB8, + 0x2E0D, + 0x2D64, + 0x2CBD, + 0x2C19, + 0x2B77, + 0x2AD8, + 0x2A3A, + 0x299F, + 0x2907, + 0x2870, + 0x27DC, + 0x2749, + 0x26B9, + 0x262B, + 0x259F, + 0x2515, + 0x248D, + 0x2407, + 0x2382, + 0x2300, + 0x2280, + 0x2201, + 0x2184, + 0x2109, + 0x2090, + 0x2018, + 0x1FA3, + 0x1F2E, + 0x1EBC, + 0x1E4B, + 0x1DDC, + 0x1D6E, + 0x1D02, + 0x1C98, + 0x1C2F, + 0x1BC8, + 0x1B62, + 0x1AFD, + 0x1A9A, + 0x1A38, + 0x19D8, + 0x1979, + 0x191C, + 0x18C0, + 0x1865, + 0x180B, + 0x17B3, + 0x175C, + 0x1706, + 0x16B2, + 0x165E, + 0x160C, + 0x15BB, + 0x156C, + 0x151D, + 0x14CF, + 0x1483, + 0x1438, + 0x13EE, + 0x13A4, + 0x135C, + 0x1315, + 0x12CF, + 0x128A, + 0x1246, + 0x1203, + 0x11C1, + 0x1180, + 0x1140, + 0x1100, + 0x10C2, + 0x1084, + 0x1048, + 0x100C, + 0xFD1, + 0xF97, + 0xF5E, + 0xF25, + 0xEEE, + 0xEB7, + 0xE81, + 0xE4C, + 0xE17, + 0xDE4, + 0xDB1, + 0xD7E, + 0xD4D, + 0xD1C, + 0xCEC, + 0xCBC, + 0xC8E, + 0xC60, + 0xC32, + 0xC05, + 0xBD9, + 0xBAE, + 0xB83, + 0xB59, + 0xB2F, + 0xB06, + 0xADD, + 0xAB6, + 0xA8E, + 0xA67, + 0xA41, + 0xA1C, + 0x9F7, + 0x9D2, + 0x9AE, + 0x98A, + 0x967, + 0x945, + 0x923, + 0x901, + 0x8E0, + 0x8C0, + 0x8A0, + 0x880, + 0x861, + 0x842, + 0x824, + 0x806, + 0x7E8, + 0x7CB, + 0x7AF, + 0x792, + 0x777, + 0x75B, + 0x740, + 0x726, + 0x70B, + 0x6F2, + 0x6D8, + 0x6BF, + 0x6A6, + 0x68E, + 0x676, + 0x65E, + 0x647, + 0x630, + 0x619, + 0x602, + 0x5EC, + 0x5D7, + 0x5C1, + 0x5AC, + 0x597, + 0x583, + 0x56E, + 0x55B, + 0x547, + 0x533, + 0x520, + 0x50E, + 0x4FB, + 0x4E9, + 0x4D7, + 0x4C5, + 0x4B3, + 0x4A2, + 0x491, + 0x480, + 0x470, + 0x460, + 0x450, + 0x440, + 0x430, + 0x421, + 0x412, + 0x403, + 0x3F4, + 0x3E5, + 0x3D7, + 0x3C9, + 0x3BB, + 0x3AD, + 0x3A0, + 0x393, + 0x385, + 0x379, + 0x36C, + 0x35F, + 0x353, + 0x347, + 0x33B, + 0x32F, + 0x323, + 0x318, + 0x30C, + 0x301, + 0x2F6, + 0x2EB, + 0x2E0, + 0x2D6, + 0x2CB, + 0x2C1, + 0x2B7, + 0x2AD, + 0x2A3, + 0x299, + 0x290, + 0x287, + 0x27D, + 0x274, + 0x26B, + 0x262, + 0x259, + 0x251, + 0x248, + 0x240, + 0x238, + 0x230, + 0x228, + 0x220, + 0x218, + 0x210, + 0x209, + 0x201, + 0x1FA, + 0x1F2, + 0x1EB, + 0x1E4, + 0x1DD, + 0x1D6, + 0x1D0, + 0x1C9, + 0x1C2, + 0x1BC, + 0x1B6, + 0x1AF, + 0x1A9, + 0x1A3, + 0x19D, + 0x197, + 0x191, + 0x18C, + 0x186, + 0x180, + 0x17B, + 0x175, + 0x170, + 0x16B, + 0x165, + 0x160, + 0x15B, + 0x156, + 0x151, + 0x14C, + 0x148, + 0x143, + 0x13E, + 0x13A, + 0x135, + 0x131, + 0x12C, + 0x128, + 0x124, + 0x120, + 0x11C, + 0x118, + 0x114, + 0x110, + 0x10C, + 0x108, + 0x104, + 0x100, + 0xFD, + 0xF9, + 0xF5, + 0xF2, + 0xEE, +}; + diff --git a/quantum/audio/luts.h b/quantum/audio/luts.h new file mode 100644 index 00000000000..7df3078a7f6 --- /dev/null +++ b/quantum/audio/luts.h @@ -0,0 +1,15 @@ +#include +#include +#include + +#ifndef LUTS_H +#define LUTS_H + +#define VIBRATO_LUT_LENGTH 20 + +#define FREQUENCY_LUT_LENGTH 349 + +extern const float vibrato_lut[VIBRATO_LUT_LENGTH]; +extern const uint16_t frequency_lut[FREQUENCY_LUT_LENGTH]; + +#endif /* LUTS_H */ \ No newline at end of file diff --git a/quantum/audio/vibrato_lut.h b/quantum/audio/vibrato_lut.h deleted file mode 100644 index a2b1f3e5ceb..00000000000 --- a/quantum/audio/vibrato_lut.h +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#define VIBRATO_LUT_LENGTH 20 - -const float VIBRATO_LUT[VIBRATO_LUT_LENGTH] = { \ -1.00223368114872, -1.00425299436105, -1.00585842560279, -1.00689052852052, -1.0072464122237, -1.00689052852052, -1.00585842560279, -1.00425299436105, -1.00223368114872, -1, -0.99777129706302, -0.99576501699778, -0.994175695650927, -0.993156625943589, -0.992805720491269, -0.993156625943589, -0.994175695650927, -0.99576501699778, -0.99777129706302, -1 -}; \ No newline at end of file diff --git a/quantum/audio/voices.c b/quantum/audio/voices.c index 0921bd5931e..6d4172a06c2 100644 --- a/quantum/audio/voices.c +++ b/quantum/audio/voices.c @@ -1,6 +1,6 @@ #include "voices.h" +#include "audio.h" #include "stdlib.h" -#include "vibrato_lut.h" // these are imported from audio.c extern uint16_t envelope_index; @@ -54,28 +54,28 @@ float voice_envelope(float frequency) { } break; - case octave_crunch: - polyphony_rate = 0; - switch (compensated_index) { - case 0 ... 9: - case 20 ... 24: - case 30 ... 32: - frequency = frequency / 2; - note_timbre = TIMBRE_12; - break; + // case octave_crunch: + // polyphony_rate = 0; + // switch (compensated_index) { + // case 0 ... 9: + // case 20 ... 24: + // case 30 ... 32: + // frequency = frequency / 2; + // note_timbre = TIMBRE_12; + // break; - case 10 ... 19: - case 25 ... 29: - case 33 ... 35: - frequency = frequency * 2; - note_timbre = TIMBRE_12; - break; + // case 10 ... 19: + // case 25 ... 29: + // case 33 ... 35: + // frequency = frequency * 2; + // note_timbre = TIMBRE_12; + // break; - default: - note_timbre = TIMBRE_12; - break; - } - break; + // default: + // note_timbre = TIMBRE_12; + // break; + // } + // break; case duty_osc: // This slows the loop down a substantial amount, so higher notes may freeze @@ -109,7 +109,7 @@ float voice_envelope(float frequency) { case 0 ... VOICE_VIBRATO_DELAY: break; default: - frequency = frequency * VIBRATO_LUT[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; + frequency = frequency * vibrato_lut[(int)fmod((((float)compensated_index - (VOICE_VIBRATO_DELAY + 1))/1000*VOICE_VIBRATO_SPEED), VIBRATO_LUT_LENGTH)]; break; } break; @@ -160,4 +160,6 @@ float voice_envelope(float frequency) { } return frequency; -} \ No newline at end of file +} + + diff --git a/quantum/audio/voices.h b/quantum/audio/voices.h index 74c873f42f0..b2495b23b57 100644 --- a/quantum/audio/voices.h +++ b/quantum/audio/voices.h @@ -2,8 +2,7 @@ #include #include #include -#include "musical_notes.h" -#include "song_list.h" +#include "luts.h" #ifndef VOICES_H #define VOICES_H diff --git a/quantum/config_common.h b/quantum/config_common.h index da53fce89b5..02f11d979c5 100644 --- a/quantum/config_common.h +++ b/quantum/config_common.h @@ -1,70 +1,74 @@ #ifndef CONFIG_DEFINITIONS_H #define CONFIG_DEFINITIONS_H -#define B0 0x20 -#define B1 0x21 -#define B2 0x22 -#define B3 0x23 -#define B4 0x24 -#define B5 0x25 -#define B6 0x26 -#define B7 0x27 -#define C0 0x30 -#define C1 0x31 -#define C2 0x32 -#define C3 0x33 -#define C4 0x34 -#define C5 0x35 -#define C6 0x36 -#define C7 0x37 -#define D0 0x40 -#define D1 0x41 -#define D2 0x42 -#define D3 0x43 -#define D4 0x44 -#define D5 0x45 -#define D6 0x46 -#define D7 0x47 -#define E0 0x50 -#define E1 0x51 -#define E2 0x52 -#define E3 0x53 -#define E4 0x54 -#define E5 0x55 -#define E6 0x56 -#define E7 0x57 -#define F0 0x60 -#define F1 0x61 -#define F2 0x62 -#define F3 0x63 -#define F4 0x64 -#define F5 0x65 -#define F6 0x66 -#define F7 0x67 - -#define COL2ROW 0x0 -#define ROW2COL 0x1 +/* diode directions */ +#define COL2ROW 0 +#define ROW2COL 1 +/* I/O pins */ +#define B0 { .input_addr = 3, .bit = 0 } +#define B1 { .input_addr = 3, .bit = 1 } +#define B2 { .input_addr = 3, .bit = 2 } +#define B3 { .input_addr = 3, .bit = 3 } +#define B4 { .input_addr = 3, .bit = 4 } +#define B5 { .input_addr = 3, .bit = 5 } +#define B6 { .input_addr = 3, .bit = 6 } +#define B7 { .input_addr = 3, .bit = 7 } +#define C0 { .input_addr = 6, .bit = 0 } +#define C1 { .input_addr = 6, .bit = 1 } +#define C2 { .input_addr = 6, .bit = 2 } +#define C3 { .input_addr = 6, .bit = 3 } +#define C4 { .input_addr = 6, .bit = 4 } +#define C5 { .input_addr = 6, .bit = 5 } +#define C6 { .input_addr = 6, .bit = 6 } +#define C7 { .input_addr = 6, .bit = 7 } +#define D0 { .input_addr = 9, .bit = 0 } +#define D1 { .input_addr = 9, .bit = 1 } +#define D2 { .input_addr = 9, .bit = 2 } +#define D3 { .input_addr = 9, .bit = 3 } +#define D4 { .input_addr = 9, .bit = 4 } +#define D5 { .input_addr = 9, .bit = 5 } +#define D6 { .input_addr = 9, .bit = 6 } +#define D7 { .input_addr = 9, .bit = 7 } +#define E0 { .input_addr = 0xC, .bit = 0 } +#define E1 { .input_addr = 0xC, .bit = 1 } +#define E2 { .input_addr = 0xC, .bit = 2 } +#define E3 { .input_addr = 0xC, .bit = 3 } +#define E4 { .input_addr = 0xC, .bit = 4 } +#define E5 { .input_addr = 0xC, .bit = 5 } +#define E6 { .input_addr = 0xC, .bit = 6 } +#define E7 { .input_addr = 0xC, .bit = 7 } +#define F0 { .input_addr = 0xF, .bit = 0 } +#define F1 { .input_addr = 0xF, .bit = 1 } +#define F2 { .input_addr = 0xF, .bit = 2 } +#define F3 { .input_addr = 0xF, .bit = 3 } +#define F4 { .input_addr = 0xF, .bit = 4 } +#define F5 { .input_addr = 0xF, .bit = 5 } +#define F6 { .input_addr = 0xF, .bit = 6 } +#define F7 { .input_addr = 0xF, .bit = 7 } +/* USART configuration */ #ifdef BLUETOOTH_ENABLE -#ifdef __AVR_ATmega32U4__ - #define SERIAL_UART_BAUD 9600 - #define SERIAL_UART_DATA UDR1 - #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) - #define SERIAL_UART_RXD_VECT USART1_RX_vect - #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ - UCSR1B = (1<> 8; \ + /* enable TX */ \ + UCSR1B = _BV(TXEN1); \ + /* 8-bit data */ \ + UCSR1C = _BV(UCSZ11) | _BV(UCSZ10); \ + sei(); \ + } while(0) +# else +# error "USART configuration is needed." #endif - // I'm fairly sure these aren't needed, but oh well - Jack /* @@ -113,4 +117,3 @@ #endif #endif - diff --git a/quantum/keymap_common.c b/quantum/keymap_common.c index 4b4bd62109b..ba7269388bc 100644 --- a/quantum/keymap_common.c +++ b/quantum/keymap_common.c @@ -24,9 +24,13 @@ along with this program. If not, see . #include "action_macro.h" #include "debug.h" #include "backlight.h" -#include "keymap_midi.h" #include "bootloader.h" #include "eeconfig.h" +#include "quantum.h" + +#ifdef MIDI_ENABLE + #include "keymap_midi.h" +#endif extern keymap_config_t keymap_config; @@ -150,20 +154,22 @@ static action_t keycode_to_action(uint16_t keycode) case KC_TRNS: action.code = ACTION_TRANSPARENT; break; - case 0x0100 ... 0x1FFF: ; + case LCTL(0) ... 0x1FFF: ; // Has a modifier // Split it up action.code = ACTION_MODS_KEY(keycode >> 8, keycode & 0xFF); // adds modifier to key break; - case 0x2000 ... 0x2FFF: + case FUNC(0) ... FUNC(0xFFF): ; // Is a shortcut for function layer, pull last 12bits // This means we have 4,096 FN macros at our disposal return keymap_func_to_action(keycode & 0xFFF); break; - case 0x3000 ... 0x3FFF: ; - // When the code starts with 3, it's an action macro. + case M(0) ... M(0xFF): action.code = ACTION_MACRO(keycode & 0xFF); break; + case LT(0, 0) ... LT(0xFF, 0xF): + action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); + break; #ifdef BACKLIGHT_ENABLE case BL_0 ... BL_15: action.code = ACTION_BACKLIGHT_LEVEL(keycode & 0x000F); @@ -185,7 +191,7 @@ static action_t keycode_to_action(uint16_t keycode) clear_keyboard(); #ifdef AUDIO_ENABLE stop_all_notes(); - play_goodbye_tone(); + shutdown_user(); #endif _delay_ms(250); #ifdef ATREUS_ASTAR @@ -197,7 +203,7 @@ static action_t keycode_to_action(uint16_t keycode) print("\nDEBUG: enabled.\n"); debug_enable = true; break; - case 0x5002 ... 0x50FF: + case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_UNSWAP_ALT_GUI: // MAGIC actions (BOOTMAGIC without the boot) if (!eeconfig_is_enabled()) { eeconfig_init(); @@ -247,7 +253,7 @@ static action_t keycode_to_action(uint16_t keycode) } eeconfig_update_keymap(keymap_config.raw); break; - case 0x5100 ... 0x5FFF: ; + case TO(0, 1) ... OSM(0xFF): ; // Layer movement shortcuts // See .h to see constraints/usage int type = (keycode >> 0x8) & 0xF; @@ -268,25 +274,19 @@ static action_t keycode_to_action(uint16_t keycode) // Set default layer int layer = keycode & 0xFF; action.code = ACTION_LAYER_TOGGLE(layer); + } else if (type == 0x5) { + // OSL(layer) - One-shot layer + int layer = keycode & 0xFF; + action.code = ACTION_LAYER_ONESHOT(layer); + } else if (type == 0x6) { + // OSM(mod) - One-shot mod + int mod = keycode & 0xFF; + action.code = ACTION_MODS_ONESHOT(mod); } break; - #ifdef MIDI_ENABLE - case 0x6000 ... 0x6FFF: - action.code = ACTION_FUNCTION_OPT(keycode & 0xFF, (keycode & 0x0F00) >> 8); - break; - #endif - case 0x7000 ... 0x7FFF: + case MT(0, 0) ... MT(0xF, 0xFF): action.code = ACTION_MODS_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); break; - case 0x8000 ... 0x8FFF: - action.code = ACTION_LAYER_TAP_KEY((keycode >> 0x8) & 0xF, keycode & 0xFF); - break; - #ifdef UNICODE_ENABLE - case 0x8000000 ... 0x8FFFFFF: - uint16_t unicode = keycode & ~(0x8000); - action.code = ACTION_FUNCTION_OPT(unicode & 0xFF, (unicode & 0xFF00) >> 8); - break; - #endif default: action.code = ACTION_NO; break; diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h index 0ede0296b98..91d5c09c1cf 100644 --- a/quantum/keymap_common.h +++ b/quantum/keymap_common.h @@ -67,6 +67,9 @@ extern const uint16_t fn_actions[]; #define MEH(kc) kc | 0x0700 #define LCAG(kc) kc | 0x0D00 // Modifier Ctrl Alt and GUI +#define MOD_HYPR 0xf +#define MOD_MEH 0x7 + #define RCTL(kc) kc | 0x1100 #define RSFT(kc) kc | 0x1200 #define RALT(kc) kc | 0x1400 @@ -84,8 +87,11 @@ extern const uint16_t fn_actions[]; #define KC_EXCLAIM KC_EXLM #define KC_AT LSFT(KC_2) // @ + + #define KC_HASH LSFT(KC_3) // # + #define KC_DLR LSFT(KC_4) // $ #define KC_DOLLAR KC_DLR @@ -107,22 +113,43 @@ extern const uint16_t fn_actions[]; #define KC_RPRN LSFT(KC_0) // ) #define KC_RIGHT_PAREN KC_RPRN + #define KC_UNDS LSFT(KC_MINS) // _ #define KC_UNDERSCORE KC_UNDS #define KC_PLUS LSFT(KC_EQL) // + + #define KC_LCBR LSFT(KC_LBRC) // { #define KC_LEFT_CURLY_BRACE KC_LCBR #define KC_RCBR LSFT(KC_RBRC) // } #define KC_RIGHT_CURLY_BRACE KC_RCBR +#define KC_LABK LSFT(KC_COMM) // < +#define KC_LEFT_ANGLE_BRACKET KC_LABK + +#define KC_RABK LSFT(KC_DOT) // > +#define KC_RIGHT_ANGLE_BRACKET KC_RABK + #define KC_COLN LSFT(KC_SCLN) // : #define KC_COLON KC_COLN #define KC_PIPE LSFT(KC_BSLS) // | +#define KC_LT LSFT(KC_COMM) // < + + +#define KC_GT LSFT(KC_DOT) // > + + +#define KC_QUES LSFT(KC_SLSH) // ? +#define KC_QUESTION KC_QUES + + +#define KC_DQT LSFT(KC_QUOT) // " +#define KC_DOUBLE_QUOTE KC_DQT + #define KC_DELT KC_DELETE // Del key (four letter code) // Alias for function layers than expand past FN31 @@ -132,35 +159,14 @@ extern const uint16_t fn_actions[]; #define S(kc) LSFT(kc) #define F(kc) FUNC(kc) -#define M(kc) kc | 0x3000 +#define M(kc) (kc | 0x3000) #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE) -// These affect the backlight (if your keyboard has one). -// We don't need to comment them out if your keyboard doesn't have a backlight, -// since they don't take up any space. -#define BL_ON 0x4009 -#define BL_OFF 0x4000 -#define BL_0 0x4000 -#define BL_1 0x4001 -#define BL_2 0x4002 -#define BL_3 0x4003 -#define BL_4 0x4004 -#define BL_5 0x4005 -#define BL_6 0x4006 -#define BL_7 0x4007 -#define BL_8 0x4008 -#define BL_9 0x4009 -#define BL_10 0x400A -#define BL_11 0x400B -#define BL_12 0x400C -#define BL_13 0x400D -#define BL_14 0x400E -#define BL_15 0x400F -#define BL_DEC 0x4010 -#define BL_INC 0x4011 -#define BL_TOGG 0x4012 -#define BL_STEP 0x4013 +// 0x3100+ is free + +// L-ayer, T-ap - 256 keycode max, 16 layer max +#define LT(layer, kc) (kc | 0x4000 | ((layer & 0xF) << 8)) #define RESET 0x5000 #define DEBUG 0x5001 @@ -188,6 +194,51 @@ extern const uint16_t fn_actions[]; #define AG_SWAP MAGIC_SWAP_ALT_GUI #define AG_NORM MAGIC_UNSWAP_ALT_GUI +#define KC_LEAD 0x5014 + +// Audio on/off +#define AU_ON 0x5020 +#define AU_OFF 0x5021 +#define AU_TOG 0x5022 + +// Music mode on/off +#define MU_ON 0x5023 +#define MU_OFF 0x5024 +#define MU_TOG 0x5025 + +// Music voice iterate +#define MUV_IN 0x5026 +#define MUV_DE 0x5027 + +// Midi mode on/off +#define MI_ON 0x5028 +#define MI_OFF 0x5029 + +// These affect the backlight (if your keyboard has one). +// We don't need to comment them out if your keyboard doesn't have a backlight, +// since they don't take up any space. +#define BL_ON 0x5079 +#define BL_OFF 0x5070 +#define BL_0 0x5070 +#define BL_1 0x5071 +#define BL_2 0x5072 +#define BL_3 0x5073 +#define BL_4 0x5074 +#define BL_5 0x5075 +#define BL_6 0x5076 +#define BL_7 0x5077 +#define BL_8 0x5078 +#define BL_9 0x5079 +#define BL_10 0x507A +#define BL_11 0x507B +#define BL_12 0x507C +#define BL_13 0x507D +#define BL_14 0x507E +#define BL_15 0x507F +#define BL_DEC 0x5080 +#define BL_INC 0x5081 +#define BL_TOGG 0x5082 +#define BL_STEP 0x5083 // GOTO layer - 16 layers max // when: @@ -205,6 +256,14 @@ extern const uint16_t fn_actions[]; // Toggle to layer - 256 layer max #define TG(layer) (layer | 0x5400) +// One-shot layer - 256 layer max +#define OSL(layer) (layer | 0x5500) + +// One-shot mod +#define OSM(layer) (layer | 0x5600) + +// chording is currently at 0x57xx + // M-od, T-ap - 256 keycode max #define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8)) #define CTL_T(kc) MT(0x1, kc) @@ -220,14 +279,13 @@ extern const uint16_t fn_actions[]; #define KC_HYPR HYPR(KC_NO) #define KC_MEH MEH(KC_NO) -// L-ayer, T-ap - 256 keycode max, 16 layer max -#define LT(layer, kc) (kc | 0x8000 | ((layer & 0xF) << 8)) - -// For sending unicode codes. -// You may not send codes over 1FFF -- this supports most of UTF8. -// To have a key that sends out Œ, go UC(0x0152) -#define UNICODE(n) (n | 0x8000) -#define UC(n) UNICODE(n) +#ifdef UNICODE_ENABLE + // For sending unicode codes. + // You may not send codes over 7FFF -- this supports most of UTF8. + // To have a key that sends out Œ, go UC(0x0152) + #define UNICODE(n) (n | 0x8000) + #define UC(n) UNICODE(n) +#endif // For tri-layer void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3); diff --git a/quantum/keymap_extras/keymap_german_ch.h b/quantum/keymap_extras/keymap_german_ch.h new file mode 100644 index 00000000000..0874abf7dd6 --- /dev/null +++ b/quantum/keymap_extras/keymap_german_ch.h @@ -0,0 +1,102 @@ +#ifndef KEYMAP_SWISS_GERMAN +#define KEYMAP_SWISS_GERMAN + +#include "keymap_common.h" + +// Alt gr +#define ALGR(kc) kc | 0x1400 +#define CH_ALGR KC_RALT + +// normal characters +#define CH_Z KC_Y +#define CH_Y KC_Z + +#define CH_A KC_A +#define CH_B KC_B +#define CH_C KC_C +#define CH_D KC_D +#define CH_E KC_E +#define CH_F KC_F +#define CH_G KC_G +#define CH_H KC_H +#define CH_I KC_I +#define CH_J KC_J +#define CH_K KC_K +#define CH_L KC_L +#define CH_M KC_M +#define CH_N KC_N +#define CH_O KC_O +#define CH_P KC_P +#define CH_Q KC_Q +#define CH_R KC_R +#define CH_S KC_S +#define CH_T KC_T +#define CH_U KC_U +#define CH_V KC_V +#define CH_W KC_W +#define CH_X KC_X + +#define CH_0 KC_0 +#define CH_1 KC_1 +#define CH_2 KC_2 +#define CH_3 KC_3 +#define CH_4 KC_4 +#define CH_5 KC_5 +#define CH_6 KC_6 +#define CH_7 KC_7 +#define CH_8 KC_8 +#define CH_9 KC_9 + +#define CH_DOT KC_DOT +#define CH_COMM KC_COMM + +#define CH_QUOT KC_MINS // ' ? ´ +#define CH_AE KC_QUOT +#define CH_UE KC_LBRC +#define CH_OE KC_SCLN + +#define CH_PARA KC_GRAVE // secction sign § and ° +#define CH_CARR KC_EQL // carret ^ ` ~ +#define CH_DIER KC_RBRC // dieresis ¨ ! ] +#define CH_DLR KC_BSLS // $ £ } +#define CH_LESS KC_NUBS // < and > and backslash +#define CH_MINS KC_SLSH // - and _ + +// shifted characters +#define CH_RING LSFT(CH_PARA) // ° +#define CH_PLUS LSFT(KC_1) // + +#define CH_DQOT LSFT(KC_2) // " +#define CH_PAST LSFT(KC_3) // * +#define CH_CELA LSFT(KC_4) // ç +#define CH_PERC LSFT(KC_5) // % +#define CH_AMPR LSFT(KC_6) // & +#define CH_SLSH LSFT(KC_7) // / +#define CH_LPRN LSFT(KC_8) // ( +#define CH_RPRN LSFT(KC_9) // ) +#define CH_EQL LSFT(KC_0) // = +#define CH_QST LSFT(CH_QUOT) // ? +#define CH_GRV LSFT(CH_CARR) // ` +#define CH_EXLM LSFT(CH_DIER) // ! +#define CH_POND LSFT(CH_DLR) // £ +#define CH_MORE LSFT(CH_LESS) // > +#define CH_COLN LSFT(KC_DOT) // : +#define CH_SCLN LSFT(KC_COMM) // ; +#define CH_UNDS LSFT(CH_MINS) // _ + +// Alt Gr-ed characters +#define CH_BRBR ALGR(KC_1) // ¦ brocken bar +#define CH_AT ALGR(KC_2) // @ +#define CH_HASH ALGR(KC_3) // # +#define CH_NOTL ALGR(KC_6) // ¬ negative logic +#define CH_PIPE ALGR(KC_7) // | +#define CH_CENT ALGR(KC_8) // ¢ cent +#define CH_ACUT ALGR(CH_QUOT) // ´ +#define CH_TILD ALGR(CH_CARR) // ~ +#define CH_EURO ALGR(KC_E) // € +#define CH_LBRC ALGR(CH_UE) // [ +#define CH_RBRC ALGR(CH_DIER) // ] +#define CH_LCBR ALGR(CH_AE) // { +#define CH_RCBR ALGR(CH_DLR) // } +#define CH_BSLS ALGR(CH_LESS) // backslash + +#endif diff --git a/quantum/keymap_midi.h b/quantum/keymap_midi.h index 795f26380ed..3a2bf3afff6 100644 --- a/quantum/keymap_midi.h +++ b/quantum/keymap_midi.h @@ -25,11 +25,11 @@ along with this program. If not, see . #define CHNL(note, channel) (note + (channel << 8)) -#define SCALE (int []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ - 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ - 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ - 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ - 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } +#define SCALE (int8_t []){ 0 + (12*0), 2 + (12*0), 4 + (12*0), 5 + (12*0), 7 + (12*0), 9 + (12*0), 11 + (12*0), \ + 0 + (12*1), 2 + (12*1), 4 + (12*1), 5 + (12*1), 7 + (12*1), 9 + (12*1), 11 + (12*1), \ + 0 + (12*2), 2 + (12*2), 4 + (12*2), 5 + (12*2), 7 + (12*2), 9 + (12*2), 11 + (12*2), \ + 0 + (12*3), 2 + (12*3), 4 + (12*3), 5 + (12*3), 7 + (12*3), 9 + (12*3), 11 + (12*3), \ + 0 + (12*4), 2 + (12*4), 4 + (12*4), 5 + (12*4), 7 + (12*4), 9 + (12*4), 11 + (12*4), } #define N_CN1 (0x600C + (12 * -1) + 0 ) #define N_CN1S (0x600C + (12 * -1) + 1 ) diff --git a/quantum/keymap_unicode.c b/quantum/keymap_unicode.c deleted file mode 100644 index a44965e6111..00000000000 --- a/quantum/keymap_unicode.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2015 Jack Humbert - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "keymap_common.h" - -uint16_t hextokeycode(int hex) { - if (hex == 0x0) { - return KC_0; - } else if (hex < 0xA) { - return KC_1 + (hex - 0x1); - } else { - return KC_A + (hex - 0xA); - } -} - -void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) -{ - - // For more info on how this works per OS, see here: https://en.wikipedia.org/wiki/Unicode_input#Hexadecimal_code_input - - if (record->event.pressed) { - uint16_t unicode = (opt << 8) | id; - register_code(KC_LALT); - - register_code(hextokeycode((unicode & 0xF000) >> 12)); - unregister_code(hextokeycode((unicode & 0xF000) >> 12)); - register_code(hextokeycode((unicode & 0x0F00) >> 8)); - unregister_code(hextokeycode((unicode & 0x0F00) >> 8)); - register_code(hextokeycode((unicode & 0x00F0) >> 4)); - unregister_code(hextokeycode((unicode & 0x00F0) >> 4)); - register_code(hextokeycode((unicode & 0x000F))); - unregister_code(hextokeycode((unicode & 0x000F))); - - /* Test 'a' */ - // register_code(hextokeycode(0x0)); - // unregister_code(hextokeycode(0x0)); - // register_code(hextokeycode(0x0)); - // unregister_code(hextokeycode(0x0)); - // register_code(hextokeycode(0x6)); - // unregister_code(hextokeycode(0x6)); - // register_code(hextokeycode(0x1)); - // unregister_code(hextokeycode(0x1)); - - unregister_code(KC_LALT); - } - return; -} \ No newline at end of file diff --git a/quantum/matrix.c b/quantum/matrix.c index 2dab6ae941e..d5fd7def8ab 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -1,6 +1,6 @@ /* -Copyright 2012 Jun Wako -Generated by planckkeyboard.com (2014 Jack Humbert) +Copyright 2012 Jun Wako +Copyright 2014 Jack Humbert This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,293 +15,211 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ - -/* - * scan matrix - */ #include #include #include -#include +#include "wait.h" #include "print.h" #include "debug.h" #include "util.h" #include "matrix.h" -#ifndef DEBOUNCE -# define DEBOUNCE 10 +#ifdef MATRIX_HAS_GHOST +# error "The universal matrix.c file cannot be used for this keyboard." #endif -static uint8_t debouncing = DEBOUNCE; -/* matrix state(1:on, 0:off) */ +#ifndef DEBOUNCING_DELAY +# define DEBOUNCING_DELAY 5 +#endif + +static const io_pin_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS; +static const io_pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS; +/* matrix state */ +#if DIODE_DIRECTION == COL2ROW static matrix_row_t matrix[MATRIX_ROWS]; -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; +#else +static matrix_col_t matrix[MATRIX_COLS]; +#endif +static int8_t debouncing_delay = -1; -#if DIODE_DIRECTION == ROW2COL - static matrix_row_t matrix_reversed[MATRIX_COLS]; - static matrix_row_t matrix_reversed_debouncing[MATRIX_COLS]; +#if DIODE_DIRECTION == COL2ROW +static void toggle_row(uint8_t row); +static matrix_row_t read_cols(void); +#else +static void toggle_col(uint8_t col); +static matrix_col_t read_rows(void); #endif -static matrix_row_t read_cols(void); -static void init_cols(void); -static void unselect_rows(void); -static void select_row(uint8_t row); - __attribute__ ((weak)) -void matrix_init_kb(void) { - +void matrix_init_quantum(void) { } __attribute__ ((weak)) -void matrix_scan_kb(void) { - +void matrix_scan_quantum(void) { } -inline -uint8_t matrix_rows(void) -{ +uint8_t matrix_rows(void) { return MATRIX_ROWS; } -inline -uint8_t matrix_cols(void) -{ +uint8_t matrix_cols(void) { return MATRIX_COLS; } -void matrix_init(void) -{ - // To use PORTF disable JTAG with writing JTD bit twice within four cycles. - MCUCR |= (1<= 0; --r) { + /* DDRxn */ + _SFR_IO8(row_pins[r].input_addr + 1) |= _BV(row_pins[r].bit); + toggle_row(r); } - - if (debouncing) { - if (--debouncing) { - _delay_ms(1); - } else { - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - matrix[i] = matrix_debouncing[i]; - } - } + for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { + /* PORTxn */ + _SFR_IO8(col_pins[c].input_addr + 2) |= _BV(col_pins[c].bit); } #else - for (uint8_t i = 0; i < MATRIX_COLS; i++) { - select_row(i); - _delay_us(30); // without this wait read unstable value. - matrix_row_t rows = read_cols(); - if (matrix_reversed_debouncing[i] != rows) { - matrix_reversed_debouncing[i] = rows; - if (debouncing) { - debug("bounce!: "); debug_hex(debouncing); debug("\n"); - } - debouncing = DEBOUNCE; - } - unselect_rows(); + for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { + /* DDRxn */ + _SFR_IO8(col_pins[c].input_addr + 1) |= _BV(col_pins[c].bit); + toggle_col(c); } - - if (debouncing) { - if (--debouncing) { - _delay_ms(1); - } else { - for (uint8_t i = 0; i < MATRIX_COLS; i++) { - matrix_reversed[i] = matrix_reversed_debouncing[i]; - } - } - } - for (uint8_t y = 0; y < MATRIX_ROWS; y++) { - matrix_row_t row = 0; - for (uint8_t x = 0; x < MATRIX_COLS; x++) { - row |= ((matrix_reversed[x] & (1<> y) << x; - } - matrix[y] = row; + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + /* PORTxn */ + _SFR_IO8(row_pins[r].input_addr + 2) |= _BV(row_pins[r].bit); } #endif + matrix_init_quantum(); +} - matrix_scan_kb(); - +#if DIODE_DIRECTION == COL2ROW +uint8_t matrix_scan(void) { + static matrix_row_t debouncing_matrix[MATRIX_ROWS]; + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + toggle_row(r); + matrix_row_t state = read_cols(); + if (debouncing_matrix[r] != state) { + debouncing_matrix[r] = state; + debouncing_delay = DEBOUNCING_DELAY; + } + toggle_row(r); + } + if (debouncing_delay >= 0) { + dprintf("Debouncing delay remaining: %X\n", debouncing_delay); + --debouncing_delay; + if (debouncing_delay >= 0) { + wait_ms(1); + } + else { + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + matrix[r] = debouncing_matrix[r]; + } + } + } + matrix_scan_quantum(); return 1; } -bool matrix_is_modified(void) -{ - if (debouncing) return false; - return true; +static void toggle_row(uint8_t row) { + /* PINxn */ + _SFR_IO8(row_pins[row].input_addr) = _BV(row_pins[row].bit); } -inline -bool matrix_is_on(uint8_t row, uint8_t col) -{ - return (matrix[row] & ((matrix_row_t)1= 0; --c) { + /* PINxn */ + if (!(_SFR_IO8(col_pins[c].input_addr) & _BV(col_pins[c].bit))) { + state |= (matrix_row_t)1 << c; + } + } + return state; } -inline -matrix_row_t matrix_get_row(uint8_t row) -{ +matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } -void matrix_print(void) -{ - print("\nr/c 0123456789ABCDEF\n"); - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - phex(row); print(": "); - pbin_reverse16(matrix_get_row(row)); - print("\n"); +#else +uint8_t matrix_scan(void) { + static matrix_col_t debouncing_matrix[MATRIX_COLS]; + for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { + toggle_col(c); + matrix_col_t state = read_rows(); + if (debouncing_matrix[c] != state) { + debouncing_matrix[c] = state; + debouncing_delay = DEBOUNCING_DELAY; + } + toggle_col(c); + } + if (debouncing_delay >= 0) { + dprintf("Debouncing delay remaining: %X\n", debouncing_delay); + --debouncing_delay; + if (debouncing_delay >= 0) { + wait_ms(1); + } + else { + for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { + matrix[c] = debouncing_matrix[c]; + } + } + } + matrix_scan_quantum(); + return 1; +} + +static void toggle_col(uint8_t col) { + /* PINxn */ + _SFR_IO8(col_pins[col].input_addr) = _BV(col_pins[col].bit); +} + +static matrix_col_t read_rows(void) { + matrix_col_t state = 0; + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + /* PINxn */ + if (!(_SFR_IO8(row_pins[r].input_addr) & _BV(row_pins[r].bit))) { + state |= (matrix_col_t)1 << r; + } + } + return state; +} + +matrix_row_t matrix_get_row(uint8_t row) { + matrix_row_t state = 0; + matrix_col_t mask = (matrix_col_t)1 << row; + for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) { + if (matrix[c] & mask) { + state |= (matrix_row_t)1 << c; + } + } + return state; +} + +#endif + +bool matrix_is_modified(void) { + if (debouncing_delay >= 0) return false; + return true; +} + +bool matrix_is_on(uint8_t row, uint8_t col) { + return matrix_get_row(row) & (matrix_row_t)1 << col; +} + +void matrix_print(void) { + dprintln("Human-readable matrix state:"); + for (uint8_t r = 0; r < MATRIX_ROWS; r++) { + dprintf("State of row %X: %016b\n", r, bitrev16(matrix_get_row(r))); } } -uint8_t matrix_key_count(void) -{ +uint8_t matrix_key_count(void) { uint8_t count = 0; - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { - count += bitpop16(matrix[i]); + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + count += bitpop16(matrix_get_row(r)); } return count; } - -static void init_cols(void) -{ - int B = 0, C = 0, D = 0, E = 0, F = 0; - -#if DIODE_DIRECTION == COL2ROW - for(int x = 0; x < MATRIX_COLS; x++) { - int col = COLS[x]; -#else - for(int x = 0; x < MATRIX_ROWS; x++) { - int col = ROWS[x]; -#endif - if ((col & 0xF0) == 0x20) { - B |= (1<<(col & 0x0F)); - } else if ((col & 0xF0) == 0x30) { - C |= (1<<(col & 0x0F)); - } else if ((col & 0xF0) == 0x40) { - D |= (1<<(col & 0x0F)); - } else if ((col & 0xF0) == 0x50) { - E |= (1<<(col & 0x0F)); - } else if ((col & 0xF0) == 0x60) { - F |= (1<<(col & 0x0F)); - } - } - DDRB &= ~(B); PORTB |= (B); - DDRC &= ~(C); PORTC |= (C); - DDRD &= ~(D); PORTD |= (D); - DDRE &= ~(E); PORTE |= (E); - DDRF &= ~(F); PORTF |= (F); -} - -static matrix_row_t read_cols(void) -{ - matrix_row_t result = 0; - -#if DIODE_DIRECTION == COL2ROW - for(int x = 0; x < MATRIX_COLS; x++) { - int col = COLS[x]; -#else - for(int x = 0; x < MATRIX_ROWS; x++) { - int col = ROWS[x]; -#endif - - if ((col & 0xF0) == 0x20) { - result |= (PINB&(1<<(col & 0x0F)) ? 0 : (1<event.key; + uint16_t keycode; + + #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) + uint8_t layer; + + if (record->event.pressed) { + layer = layer_switch_get_layer(key); + update_source_layers_cache(key, layer); + } else { + layer = read_source_layers_cache(key); + } + keycode = keymap_key_to_keycode(layer, key); + #else + keycode = keymap_key_to_keycode(layer_switch_get_layer(key), key); + #endif + + // This is how you use actions here + // if (keycode == KC_LEAD) { + // action_t action; + // action.code = ACTION_DEFAULT_LAYER_SET(0); + // process_action(record, action); + // return false; + // } + + #ifdef MIDI_ENABLE + if (keycode == MI_ON && record->event.pressed) { + midi_activated = true; + music_scale_user(); + return false; + } + + if (keycode == MI_OFF && record->event.pressed) { + midi_activated = false; + midi_send_cc(&midi_device, 0, 0x7B, 0); + return false; + } + + if (midi_activated) { + if (record->event.key.col == (MATRIX_COLS - 1) && record->event.key.row == (MATRIX_ROWS - 1)) { + if (record->event.pressed) { + starting_note++; // Change key + midi_send_cc(&midi_device, 0, 0x7B, 0); + // midi_send_cc(&midi_device, 1, 0x7B, 0); + // midi_send_cc(&midi_device, 2, 0x7B, 0); + // midi_send_cc(&midi_device, 3, 0x7B, 0); + // midi_send_cc(&midi_device, 4, 0x7B, 0); + } + return false; + } + if (record->event.key.col == (MATRIX_COLS - 2) && record->event.key.row == (MATRIX_ROWS - 1)) { + if (record->event.pressed) { + starting_note--; // Change key + midi_send_cc(&midi_device, 0, 0x7B, 0); + // midi_send_cc(&midi_device, 1, 0x7B, 0); + // midi_send_cc(&midi_device, 2, 0x7B, 0); + // midi_send_cc(&midi_device, 3, 0x7B, 0); + // midi_send_cc(&midi_device, 4, 0x7B, 0); + } + return false; + } + if (record->event.key.col == (MATRIX_COLS - 3) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { + offset++; // Change scale + midi_send_cc(&midi_device, 0, 0x7B, 0); + // midi_send_cc(&midi_device, 1, 0x7B, 0); + // midi_send_cc(&midi_device, 2, 0x7B, 0); + // midi_send_cc(&midi_device, 3, 0x7B, 0); + // midi_send_cc(&midi_device, 4, 0x7B, 0); + return false; + } + if (record->event.key.col == (MATRIX_COLS - 4) && record->event.key.row == (MATRIX_ROWS - 1) && record->event.pressed) { + offset--; // Change scale + midi_send_cc(&midi_device, 0, 0x7B, 0); + // midi_send_cc(&midi_device, 1, 0x7B, 0); + // midi_send_cc(&midi_device, 2, 0x7B, 0); + // midi_send_cc(&midi_device, 3, 0x7B, 0); + // midi_send_cc(&midi_device, 4, 0x7B, 0); + return false; + } + // basic + // uint8_t note = (starting_note + SCALE[record->event.key.col + offset])+12*(MATRIX_ROWS - record->event.key.row); + // advanced + // uint8_t note = (starting_note + record->event.key.col + offset)+12*(MATRIX_ROWS - record->event.key.row); + // guitar + uint8_t note = (starting_note + record->event.key.col + offset)+5*(MATRIX_ROWS - record->event.key.row); + // violin + // uint8_t note = (starting_note + record->event.key.col + offset)+7*(MATRIX_ROWS - record->event.key.row); + + if (record->event.pressed) { + // midi_send_noteon(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); + midi_send_noteon(&midi_device, 0, note, 127); + } else { + // midi_send_noteoff(&midi_device, record->event.key.row, starting_note + SCALE[record->event.key.col], 127); + midi_send_noteoff(&midi_device, 0, note, 127); + } + + if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through + return false; + } + #endif + + #ifdef AUDIO_ENABLE + if (keycode == AU_ON && record->event.pressed) { + audio_on(); + return false; + } + + if (keycode == AU_OFF && record->event.pressed) { + audio_off(); + return false; + } + + if (keycode == AU_TOG && record->event.pressed) { + if (is_audio_on()) + { + audio_off(); + } + else + { + audio_on(); + } + return false; + } + + if (keycode == MU_ON && record->event.pressed) { + music_on(); + return false; + } + + if (keycode == MU_OFF && record->event.pressed) { + music_off(); + return false; + } + + if (keycode == MU_TOG && record->event.pressed) { + if (music_activated) + { + music_off(); + } + else + { + music_on(); + } + return false; + } + + if (keycode == MUV_IN && record->event.pressed) { + voice_iterate(); + music_scale_user(); + return false; + } + + if (keycode == MUV_DE && record->event.pressed) { + voice_deiterate(); + music_scale_user(); + return false; + } + + if (music_activated) { + + if (keycode == KC_LCTL && record->event.pressed) { // Start recording + stop_all_notes(); + music_sequence_recording = true; + music_sequence_playing = false; + music_sequence_count = 0; + return false; + } + + if (keycode == KC_LALT && record->event.pressed) { // Stop recording/playing + stop_all_notes(); + music_sequence_recording = false; + music_sequence_playing = false; + return false; + } + + if (keycode == KC_LGUI && record->event.pressed) { // Start playing + stop_all_notes(); + music_sequence_recording = false; + music_sequence_playing = true; + music_sequence_position = 0; + music_sequence_timer = 0; + return false; + } + + if (keycode == KC_UP) { + if (record->event.pressed) + music_sequence_interval-=10; + return false; + } + + if (keycode == KC_DOWN) { + if (record->event.pressed) + music_sequence_interval+=10; + return false; + } + + float freq = ((float)220.0)*pow(2.0, -5.0)*pow(2.0,(starting_note + SCALE[record->event.key.col + offset])/12.0+(MATRIX_ROWS - record->event.key.row)); + if (record->event.pressed) { + play_note(freq, 0xF); + if (music_sequence_recording) { + music_sequence[music_sequence_count] = freq; + music_sequence_count++; + } + } else { + stop_note(freq); + } + + if (keycode < 0xFF) // ignores all normal keycodes, but lets RAISE, LOWER, etc through + return false; + } + #endif + +#ifndef DISABLE_LEADER + // Leader key set-up + if (record->event.pressed) { + if (!leading && keycode == KC_LEAD) { + leader_start(); + leading = true; + leader_time = timer_read(); + leader_sequence_size = 0; + leader_sequence[0] = 0; + leader_sequence[1] = 0; + leader_sequence[2] = 0; + return false; + } + if (leading && timer_elapsed(leader_time) < LEADER_TIMEOUT) { + leader_sequence[leader_sequence_size] = keycode; + leader_sequence_size++; + return false; + } + } +#endif + +#define DISABLE_CHORDING +#ifndef DISABLE_CHORDING + + if (keycode >= 0x5700 && keycode <= 0x57FF) { + if (record->event.pressed) { + if (!chording) { + chording = true; + for (uint8_t i = 0; i < CHORDING_MAX; i++) + chord_keys[i] = 0; + chord_key_count = 0; + chord_key_down = 0; + } + chord_keys[chord_key_count] = (keycode & 0xFF); + chord_key_count++; + chord_key_down++; + return false; + } else { + if (chording) { + chord_key_down--; + if (chord_key_down == 0) { + chording = false; + // Chord Dictionary + if (keys_chord((uint8_t[]){KC_ENTER, KC_SPACE})) { + register_code(KC_A); + unregister_code(KC_A); + return false; + } + for (uint8_t i = 0; i < chord_key_count; i++) { + register_code(chord_keys[i]); + unregister_code(chord_keys[i]); + return false; + } + } + } + } + } + +#endif + +#ifdef UNICODE_ENABLE + + if (keycode > UNICODE(0) && record->event.pressed) { + uint16_t unicode = keycode & 0x7FFF; + switch(input_mode) { + case UC_OSX: + register_code(KC_LALT); + break; + case UC_LNX: + register_code(KC_LCTL); + register_code(KC_LSFT); + register_code(KC_U); + unregister_code(KC_U); + break; + case UC_WIN: + register_code(KC_LALT); + register_code(KC_PPLS); + unregister_code(KC_PPLS); + break; + } + for(int i = 3; i >= 0; i--) { + uint8_t digit = ((unicode >> (i*4)) & 0xF); + register_code(hex_to_keycode(digit)); + unregister_code(hex_to_keycode(digit)); + } + switch(input_mode) { + case UC_OSX: + case UC_WIN: + unregister_code(KC_LALT); + break; + case UC_LNX: + unregister_code(KC_LCTL); + unregister_code(KC_LSFT); + break; + } + } + +#endif + + return process_action_kb(record); +} + +void matrix_init_quantum() { + matrix_init_kb(); +} + +void matrix_scan_quantum() { + #ifdef AUDIO_ENABLE + if (music_sequence_playing) { + if ((music_sequence_timer == 0) || (timer_elapsed(music_sequence_timer) > music_sequence_interval)) { + music_sequence_timer = timer_read(); + stop_note(music_sequence[(music_sequence_position - 1 < 0)?(music_sequence_position - 1 + music_sequence_count):(music_sequence_position - 1)]); + play_note(music_sequence[music_sequence_position], 0xF); + music_sequence_position = (music_sequence_position + 1) % music_sequence_count; + } + } + + #endif + + matrix_scan_kb(); +} +#ifdef AUDIO_ENABLE + bool is_music_on(void) { + return (music_activated != 0); + } + + void music_toggle(void) { + if (!music_activated) { + music_on(); + } else { + music_off(); + } + } + + void music_on(void) { + music_activated = 1; + music_on_user(); + } + + void music_off(void) { + music_activated = 0; + stop_all_notes(); + } + +#endif + +//------------------------------------------------------------------------------ +// Override these functions in your keymap file to play different tunes on +// different events such as startup and bootloader jump + +__attribute__ ((weak)) +void startup_user() {} + +__attribute__ ((weak)) +void shutdown_user() {} + +__attribute__ ((weak)) +void music_on_user() {} + +__attribute__ ((weak)) +void audio_on_user() {} + +__attribute__ ((weak)) +void music_scale_user() {} + +//------------------------------------------------------------------------------ \ No newline at end of file diff --git a/quantum/quantum.h b/quantum/quantum.h new file mode 100644 index 00000000000..69a0d8126ab --- /dev/null +++ b/quantum/quantum.h @@ -0,0 +1,76 @@ +#ifndef QUANTUM_H +#define QUANTUM_H + +#include "matrix.h" +#include "keymap_common.h" +#ifdef BACKLIGHT_ENABLE + #include "backlight.h" +#endif +#ifdef RGBLIGHT_ENABLE + #include "rgblight.h" +#endif +#ifdef AUDIO_ENABLE + #include "audio.h" +#endif +#ifdef MIDI_ENABLE + #include +#endif +#ifdef UNICODE_ENABLE + #include "unicode.h" +#endif + +#include "action_layer.h" +#include "eeconfig.h" +#include +#include + +extern uint32_t default_layer_state; + +#ifndef NO_ACTION_LAYER + extern uint32_t layer_state; +#endif + +#ifdef AUDIO_ENABLE + bool music_activated; +#endif + +#ifdef UNICODE_ENABLE + #define UC_OSX 0 + #define UC_LNX 1 + #define UC_WIN 2 + #define UC_BSD 3 + + void set_unicode_input_mode(uint8_t os_target); +#endif + +#ifndef DISABLE_LEADER + void leader_start(void); + void leader_end(void); + + #ifndef LEADER_TIMEOUT + #define LEADER_TIMEOUT 200 + #endif + #define SEQ_ONE_KEY(key) if (leader_sequence[0] == (key) && leader_sequence[1] == 0 && leader_sequence[2] == 0) + #define SEQ_TWO_KEYS(key1, key2) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == 0) + #define SEQ_THREE_KEYS(key1, key2, key3) if (leader_sequence[0] == (key1) && leader_sequence[1] == (key2) && leader_sequence[2] == (key3)) + + #define LEADER_EXTERNS() extern bool leading; extern uint16_t leader_time; extern uint16_t leader_sequence[3]; extern uint8_t leader_sequence_size + #define LEADER_DICTIONARY() if (leading && timer_elapsed(leader_time) > LEADER_TIMEOUT) +#endif + +void matrix_init_kb(void); +void matrix_scan_kb(void); +bool process_action_kb(keyrecord_t *record); + +bool is_music_on(void); +void music_toggle(void); +void music_on(void); +void music_off(void); + +void startup_user(void); +void shutdown_user(void); +void audio_on_user(void); +void music_on_user(void); +void music_scale_user(void); + +#endif \ No newline at end of file diff --git a/quantum/quantum.mk b/quantum/quantum.mk index 83c4f1d1db8..c099d67939a 100644 --- a/quantum/quantum.mk +++ b/quantum/quantum.mk @@ -1,7 +1,8 @@ QUANTUM_DIR = quantum # # project specific files -SRC += $(QUANTUM_DIR)/keymap_common.c \ +SRC += $(QUANTUM_DIR)/quantum.c \ + $(QUANTUM_DIR)/keymap_common.c \ $(QUANTUM_DIR)/led.c # ifdef KEYMAP_FILE @@ -23,16 +24,14 @@ ifndef CUSTOM_MATRIX SRC += $(QUANTUM_DIR)/matrix.c endif -ifeq ($(strip $(MIDI_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/keymap_midi.c -endif +#ifeq ($(strip $(MIDI_ENABLE)), yes) +# SRC += $(QUANTUM_DIR)/keymap_midi.c +#endif ifeq ($(strip $(AUDIO_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/audio/audio.c $(QUANTUM_DIR)/audio/voices.c -endif - -ifeq ($(strip $(UNICODE_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/keymap_unicode.c + SRC += $(QUANTUM_DIR)/audio/audio.c + SRC += $(QUANTUM_DIR)/audio/voices.c + SRC += $(QUANTUM_DIR)/audio/luts.c endif ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) diff --git a/quantum/template/Makefile b/quantum/template/Makefile index 4fa195468d1..1a535ef2cba 100644 --- a/quantum/template/Makefile +++ b/quantum/template/Makefile @@ -111,23 +111,41 @@ OPT_DEFS += -DBOOTLOADER_SIZE=512 # Build Options -# comment out to disable the options. +# change yes to no to disable # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) -EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = yes # Console for debug(+400) +COMMAND_ENABLE = yes # Commands for debug and configuration +KEYBOARD_LOCK_ENABLE = yes # Allow locking of keyboard via magic key # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -# SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend -#NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -# BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality -# MIDI_ENABLE = YES # MIDI controls -# UNICODE_ENABLE = YES # Unicode -# BLUETOOTH_ENABLE = yes # Enable Bluetooth with the Adafruit EZ-Key HID +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +NKRO_ENABLE = no # USB Nkey Rollover +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +AUDIO_ENABLE = no # Audio output on port C6 +ifdef KEYMAP + +ifeq ("$(wildcard keymaps/$(KEYMAP).c)","") +ifneq ("$(wildcard keymaps/$(KEYMAP)/makefile.mk)","") + include keymaps/$(KEYMAP)/makefile.mk +endif +endif + +else + +ifneq ("$(wildcard keymaps/default/makefile.mk)","") + include keymaps/default/makefile.mk +endif + +endif + # Optimize size but this may cause error "relocation truncated to fit" #EXTRALDFLAGS = -Wl,--relax diff --git a/quantum/template/config.h b/quantum/template/config.h index e6fb7866c6c..cad3e3260a0 100644 --- a/quantum/template/config.h +++ b/quantum/template/config.h @@ -41,15 +41,16 @@ along with this program. If not, see . * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) * -*/ -#define COLS (int []){ F1, F0, B0 } -#define ROWS (int []){ D0, D5 } +*/ +#define MATRIX_ROW_PINS { D0, D5 } +#define MATRIX_COL_PINS { F1, F0, B0 } +#define UNUSED_PINS /* COL2ROW or ROW2COL */ #define DIODE_DIRECTION COL2ROW /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 +#define DEBOUNCING_DELAY 5 /* define if matrix has ghost (lacks anti-ghosting diodes) */ //#define MATRIX_HAS_GHOST @@ -62,17 +63,17 @@ along with this program. If not, see . /* Locking resynchronize hack */ #define LOCKING_RESYNC_ENABLE -/* +/* * Force NKRO * - * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the * makefile for this to work.) * * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) * until the next keyboard reset. * - * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is * fully operational during normal computer usage. * * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) @@ -90,7 +91,7 @@ along with this program. If not, see . * the keyboard. They are best used in combination with the HID Listen program, * found here: https://www.pjrc.com/teensy/hid_listen.html * - * The options below allow the magic key functionality to be changed. This is + * The options below allow the magic key functionality to be changed. This is * useful if your keyboard/keypad is missing keys and you want magic key support. * */ diff --git a/quantum/template/template.c b/quantum/template/template.c index cc52e496ffe..649072eb2e2 100644 --- a/quantum/template/template.c +++ b/quantum/template/template.c @@ -11,8 +11,9 @@ void matrix_scan_user(void) { } __attribute__ ((weak)) -void process_action_user(keyrecord_t *record) { +bool process_action_user(keyrecord_t *record) { // leave this function blank - it can be defined in a keymap file + return true; } __attribute__ ((weak)) @@ -34,11 +35,11 @@ void matrix_scan_kb(void) { matrix_scan_user(); } -void process_action_kb(keyrecord_t *record) { +bool process_action_kb(keyrecord_t *record) { // put your per-action keyboard code here // runs for every action, just before processing by the firmware - process_action_user(record); + return process_action_user(record); } void led_set_kb(uint8_t usb_led) { @@ -46,3 +47,64 @@ void led_set_kb(uint8_t usb_led) { led_set_user(usb_led); } + +#ifdef BACKLIGHT_ENABLE +#define CHANNEL OCR1C + +void backlight_init_ports() +{ + + // Setup PB7 as output and output low. + DDRB |= (1<<7); + PORTB &= ~(1<<7); + + // Use full 16-bit resolution. + ICR1 = 0xFFFF; + + // I could write a wall of text here to explain... but TL;DW + // Go read the ATmega32u4 datasheet. + // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on + + // Pin PB7 = OCR1C (Timer 1, Channel C) + // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0 + // (i.e. start high, go low when counter matches.) + // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0 + // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1 + + TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010; + TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001; + + backlight_init(); +} + +void backlight_set(uint8_t level) +{ + if ( level == 0 ) + { + // Turn off PWM control on PB7, revert to output low. + TCCR1A &= ~(_BV(COM1C1)); + CHANNEL = 0x0; + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + } + else if ( level == BACKLIGHT_LEVELS ) + { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF; + } + else + { + // Prevent backlight blink on lowest level + PORTB &= ~(_BV(PORTB7)); + // Turn on PWM control of PB7 + TCCR1A |= _BV(COM1C1); + // Set the brightness + CHANNEL = 0xFFFF >> ((BACKLIGHT_LEVELS - level) * ((BACKLIGHT_LEVELS + 1) / 2)); + } +} + +#endif \ No newline at end of file diff --git a/quantum/template/template.h b/quantum/template/template.h index b1c34d3cbee..8537e3b4be5 100644 --- a/quantum/template/template.h +++ b/quantum/template/template.h @@ -3,7 +3,10 @@ #include "matrix.h" #include "keymap_common.h" -#include "backlight.h" +#ifdef BACKLIGHT_ENABLE + #include "backlight.h" +#endif +#include #include // This a shortcut to help you visually see your layout. @@ -21,7 +24,7 @@ void matrix_init_user(void); void matrix_scan_user(void); -void process_action_user(keyrecord_t *record); +bool process_action_user(keyrecord_t *record); void led_set_user(uint8_t usb_led); #endif diff --git a/quantum/tools/README.md b/quantum/tools/README.md index 0702144238f..5f355256def 100644 --- a/quantum/tools/README.md +++ b/quantum/tools/README.md @@ -1,6 +1,6 @@ `eeprom_reset.hex` is to reset the eeprom on the Atmega32u4, like this: dfu-programmer atmega32u4 erase - dfu-programmer atmega32u4 flash --eeprom eeprom-reset.bin + dfu-programmer atmega32u4 flash --eeprom eeprom_reset.hex - You'll need to reflash afterwards, because DFU requires the flash to be erased before messing with the eeprom. \ No newline at end of file + You'll need to reflash afterwards, because DFU requires the flash to be erased before messing with the eeprom. diff --git a/quantum/unicode.h b/quantum/unicode.h new file mode 100644 index 00000000000..756ec8bc3f1 --- /dev/null +++ b/quantum/unicode.h @@ -0,0 +1,128 @@ +/* +Copyright 2016 Jack Humbert +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef UNICODE_H +#define UNICODE_H + +#include "quantum.h" +#include + +#define UC_BSPC UC(0x0008) + +#define UC_SPC UC(0x0020) + +#define UC_EXLM UC(0x0021) +#define UC_DQUT UC(0x0022) +#define UC_HASH UC(0x0023) +#define UC_DLR UC(0x0024) +#define UC_PERC UC(0x0025) +#define UC_AMPR UC(0x0026) +#define UC_QUOT UC(0x0027) +#define UC_LPRN UC(0x0028) +#define UC_RPRN UC(0x0029) +#define UC_ASTR UC(0x002A) +#define UC_PLUS UC(0x002B) +#define UC_COMM UC(0x002C) +#define UC_DASH UC(0x002D) +#define UC_DOT UC(0x002E) +#define UC_SLSH UC(0x002F) + +#define UC_0 UC(0x0030) +#define UC_1 UC(0x0031) +#define UC_2 UC(0x0032) +#define UC_3 UC(0x0033) +#define UC_4 UC(0x0034) +#define UC_5 UC(0x0035) +#define UC_6 UC(0x0036) +#define UC_7 UC(0x0037) +#define UC_8 UC(0x0038) +#define UC_9 UC(0x0039) + +#define UC_COLN UC(0x003A) +#define UC_SCLN UC(0x003B) +#define UC_LT UC(0x003C) +#define UC_EQL UC(0x003D) +#define UC_GT UC(0x003E) +#define UC_QUES UC(0x003F) +#define UC_AT UC(0x0040) + +#define UC_A UC(0x0041) +#define UC_B UC(0x0042) +#define UC_C UC(0x0043) +#define UC_D UC(0x0044) +#define UC_E UC(0x0045) +#define UC_F UC(0x0046) +#define UC_G UC(0x0047) +#define UC_H UC(0x0048) +#define UC_I UC(0x0049) +#define UC_J UC(0x004A) +#define UC_K UC(0x004B) +#define UC_L UC(0x004C) +#define UC_M UC(0x004D) +#define UC_N UC(0x004E) +#define UC_O UC(0x004F) +#define UC_P UC(0x0050) +#define UC_Q UC(0x0051) +#define UC_R UC(0x0052) +#define UC_S UC(0x0053) +#define UC_T UC(0x0054) +#define UC_U UC(0x0055) +#define UC_V UC(0x0056) +#define UC_W UC(0x0057) +#define UC_X UC(0x0058) +#define UC_Y UC(0x0059) +#define UC_Z UC(0x005A) + +#define UC_LBRC UC(0x005B) +#define UC_BSLS UC(0x005C) +#define UC_RBRC UC(0x005D) +#define UC_CIRM UC(0x005E) +#define UC_UNDR UC(0x005F) + +#define UC_GRV UC(0x0060) + +#define UC_a UC(0x0061) +#define UC_b UC(0x0062) +#define UC_c UC(0x0063) +#define UC_d UC(0x0064) +#define UC_e UC(0x0065) +#define UC_f UC(0x0066) +#define UC_g UC(0x0067) +#define UC_h UC(0x0068) +#define UC_i UC(0x0069) +#define UC_j UC(0x006A) +#define UC_k UC(0x006B) +#define UC_l UC(0x006C) +#define UC_m UC(0x006D) +#define UC_n UC(0x006E) +#define UC_o UC(0x006F) +#define UC_p UC(0x0070) +#define UC_q UC(0x0071) +#define UC_r UC(0x0072) +#define UC_s UC(0x0073) +#define UC_t UC(0x0074) +#define UC_u UC(0x0075) +#define UC_v UC(0x0076) +#define UC_w UC(0x0077) +#define UC_x UC(0x0078) +#define UC_y UC(0x0079) +#define UC_z UC(0x007A) + +#define UC_LCBR UC(0x007B) +#define UC_PIPE UC(0x007C) +#define UC_RCBR UC(0x007D) +#define UC_TILD UC(0x007E) +#define UC_DEL UC(0x007F) + +#endif \ No newline at end of file diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 9cb2eb8ecd0..b5d7e39dd16 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -60,6 +60,10 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) OPT_DEFS += -DAUDIO_ENABLE endif +ifeq ($(strip $(UNICODE_ENABLE)), yes) + OPT_DEFS += -DUNICODE_ENABLE +endif + ifeq ($(strip $(USB_6KRO_ENABLE)), yes) OPT_DEFS += -DUSB_6KRO_ENABLE endif diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index 0162fbd632e..be6dea2b799 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -27,11 +27,11 @@ along with this program. If not, see . #include "action_util.h" #include "action.h" -//#ifdef DEBUG_ACTION +#ifdef DEBUG_ACTION #include "debug.h" -//#else -//#include "nodebug.h" -//#endif +#else +#include "nodebug.h" +#endif void action_exec(keyevent_t event) @@ -46,7 +46,7 @@ void action_exec(keyevent_t event) #ifndef NO_ACTION_TAPPING action_tapping_process(record); #else - process_action(&record); + process_record(&record); if (!IS_NOEVENT(record.event)) { dprint("processed: "); debug_record(record); dprintln(); } @@ -56,34 +56,32 @@ void action_exec(keyevent_t event) #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) bool disable_action_cache = false; -void process_action_nocache(keyrecord_t *record) +void process_record_nocache(keyrecord_t *record) { disable_action_cache = true; - process_action(record); + process_record(record); disable_action_cache = false; } #else -void process_action_nocache(keyrecord_t *record) +void process_record_nocache(keyrecord_t *record) { - process_action(record); + process_record(record); } #endif __attribute__ ((weak)) -void process_action_kb(keyrecord_t *record) {} +bool process_record_quantum(keyrecord_t *record) { + return true; +} -void process_action(keyrecord_t *record) +void process_record(keyrecord_t *record) { - keyevent_t event = record->event; -#ifndef NO_ACTION_TAPPING - uint8_t tap_count = record->tap.count; -#endif + if (IS_NOEVENT(record->event)) { return; } - if (IS_NOEVENT(event)) { return; } + if(!process_record_quantum(record)) + return; - process_action_kb(record); - - action_t action = store_or_get_action(event.pressed, event.key); + action_t action = store_or_get_action(record->event.pressed, record->event.key); dprint("ACTION: "); debug_action(action); #ifndef NO_ACTION_LAYER dprint(" layer_state: "); layer_debug(); @@ -91,10 +89,37 @@ void process_action(keyrecord_t *record) #endif dprintln(); + process_action(record, action); +} + +void process_action(keyrecord_t *record, action_t action) +{ + bool do_release_oneshot = false; + keyevent_t event = record->event; +#ifndef NO_ACTION_TAPPING + uint8_t tap_count = record->tap.count; +#endif + +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + if (has_oneshot_layer_timed_out()) { + dprintf("Oneshot layer: timeout\n"); + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + } +#endif + if (event.pressed) { // clear the potential weak mods left by previously pressed keys clear_weak_mods(); } + +#ifndef NO_ACTION_ONESHOT + // notice we only clear the one shot layer if the pressed key is not a modifier. + if (is_oneshot_layer_active() && event.pressed && !IS_MOD(action.key.code)) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + do_release_oneshot = !is_oneshot_layer_active(); + } +#endif + switch (action.kind.id) { /* Key and Mods */ case ACT_LMODS: @@ -139,24 +164,37 @@ void process_action(keyrecord_t *record) // Oneshot modifier if (event.pressed) { if (tap_count == 0) { + dprint("MODS_TAP: Oneshot: 0\n"); register_mods(mods); - } - else if (tap_count == 1) { + } else if (tap_count == 1) { dprint("MODS_TAP: Oneshot: start\n"); set_oneshot_mods(mods); - } - else { + #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 + } else if (tap_count == ONESHOT_TAP_TOGGLE) { + dprint("MODS_TAP: Toggling oneshot"); + clear_oneshot_mods(); + set_oneshot_locked_mods(mods); + register_mods(mods); + #endif + } else { register_mods(mods); } } else { if (tap_count == 0) { clear_oneshot_mods(); unregister_mods(mods); - } - else if (tap_count == 1) { + } else if (tap_count == 1) { // Retain Oneshot mods - } - else { + #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 + if (mods & get_mods()) { + clear_oneshot_locked_mods(); + clear_oneshot_mods(); + unregister_mods(mods); + } + } else if (tap_count == ONESHOT_TAP_TOGGLE) { + // Toggle Oneshot Layer + #endif + } else { clear_oneshot_mods(); unregister_mods(mods); } @@ -309,6 +347,44 @@ void process_action(keyrecord_t *record) event.pressed ? layer_move(action.layer_tap.val) : layer_clear(); break; + #ifndef NO_ACTION_ONESHOT + case OP_ONESHOT: + // Oneshot modifier + #if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 + do_release_oneshot = false; + if (event.pressed) { + del_mods(get_oneshot_locked_mods()); + if (get_oneshot_layer_state() == ONESHOT_TOGGLED) { + reset_oneshot_layer(); + layer_off(action.layer_tap.val); + break; + } else if (tap_count < ONESHOT_TAP_TOGGLE) { + layer_on(action.layer_tap.val); + set_oneshot_layer(action.layer_tap.val, ONESHOT_START); + } + } else { + add_mods(get_oneshot_locked_mods()); + if (tap_count >= ONESHOT_TAP_TOGGLE) { + reset_oneshot_layer(); + clear_oneshot_locked_mods(); + set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED); + } else { + clear_oneshot_layer_state(ONESHOT_PRESSED); + } + } + #else + if (event.pressed) { + layer_on(action.layer_tap.val); + set_oneshot_layer(action.layer_tap.val, ONESHOT_START); + } else { + clear_oneshot_layer_state(ONESHOT_PRESSED); + if (tap_count > 1) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + } + } + #endif + break; + #endif default: /* tap key */ if (event.pressed) { @@ -372,6 +448,18 @@ void process_action(keyrecord_t *record) default: break; } + +#ifndef NO_ACTION_ONESHOT + /* Because we switch layers after a oneshot event, we need to release the + * key before we leave the layer or no key up event will be generated. + */ + if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED ) ) { + record->event.pressed = false; + layer_on(get_oneshot_layer()); + process_record(record); + layer_off(get_oneshot_layer()); + } +#endif } @@ -560,6 +648,7 @@ bool is_tap_key(keypos_t key) switch (action.layer_tap.code) { case 0x00 ... 0xdf: case OP_TAP_TOGGLE: + case OP_ONESHOT: return true; } return false; diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h index 44ec3047ba5..e8aa12a7cbd 100644 --- a/tmk_core/common/action.h +++ b/tmk_core/common/action.h @@ -59,14 +59,15 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); /* keyboard-specific key event (pre)processing */ -void process_action_kb(keyrecord_t *record); +bool process_record_quantum(keyrecord_t *record); /* Utilities for actions. */ #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS) extern bool disable_action_cache; #endif -void process_action_nocache(keyrecord_t *record); -void process_action(keyrecord_t *record); +void process_record_nocache(keyrecord_t *record); +void process_record(keyrecord_t *record); +void process_action(keyrecord_t *record, action_t action); void register_code(uint8_t code); void unregister_code(uint8_t code); void register_mods(uint8_t mods); diff --git a/tmk_core/common/action_code.h b/tmk_core/common/action_code.h index 2b0b0b077ef..ca729aaece2 100644 --- a/tmk_core/common/action_code.h +++ b/tmk_core/common/action_code.h @@ -76,7 +76,8 @@ along with this program. If not, see . * 101E|LLLL|1111 0001 On/Off (0xF1) [NOT TAP] * 101E|LLLL|1111 0010 Off/On (0xF2) [NOT TAP] * 101E|LLLL|1111 0011 Set/Clear (0xF3) [NOT TAP] - * 101E|LLLL|1111 xxxx Reserved (0xF4-FF) + * 101E|LLLL|1111 0100 One Shot Layer (0xF4) [TAP] + * 101E|LLLL|1111 xxxx Reserved (0xF5-FF) * ELLLL: layer 0-31(E: extra bit for layer 16-31) * * @@ -250,6 +251,7 @@ enum layer_pram_tap_op { OP_ON_OFF, OP_OFF_ON, OP_SET_CLEAR, + OP_ONESHOT, }; #define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f)) #define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key)) @@ -266,6 +268,7 @@ enum layer_pram_tap_op { #define ACTION_LAYER_ON_OFF(layer) ACTION_LAYER_TAP((layer), OP_ON_OFF) #define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON) #define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR) +#define ACTION_LAYER_ONESHOT(layer) ACTION_LAYER_TAP((layer), OP_ONESHOT) #define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | ((mods)&0x0f)) /* With Tapping */ #define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key)) diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c index 845fbbb2108..63fa2b5ae47 100644 --- a/tmk_core/common/action_layer.c +++ b/tmk_core/common/action_layer.c @@ -4,11 +4,11 @@ #include "util.h" #include "action_layer.h" -//#ifdef DEBUG_ACTION +#ifdef DEBUG_ACTION #include "debug.h" -//#else -//#include "nodebug.h" -//#endif +#else +#include "nodebug.h" +#endif /* diff --git a/tmk_core/common/action_macro.c b/tmk_core/common/action_macro.c index cc78c823279..7726b119076 100644 --- a/tmk_core/common/action_macro.c +++ b/tmk_core/common/action_macro.c @@ -19,11 +19,11 @@ along with this program. If not, see . #include "action_macro.h" #include "wait.h" -//#ifdef DEBUG_ACTION +#ifdef DEBUG_ACTION #include "debug.h" -//#else -//#include "nodebug.h" -//#endif +#else +#include "nodebug.h" +#endif #ifndef NO_ACTION_MACRO diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index 6b6fa1dfe21..ff78d7f2aba 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c @@ -6,11 +6,11 @@ #include "keycode.h" #include "timer.h" -//#ifdef DEBUG_ACTION +#ifdef DEBUG_ACTION #include "debug.h" -//#else -//#include "nodebug.h" -//#endif +#else +#include "nodebug.h" +#endif #ifndef NO_ACTION_TAPPING @@ -89,7 +89,7 @@ bool process_tapping(keyrecord_t *keyp) debug("Tapping: First tap(0->1).\n"); tapping_key.tap.count = 1; debug_tapping_key(); - process_action(&tapping_key); + process_record(&tapping_key); // copy tapping state keyp->tap = tapping_key.tap; @@ -103,7 +103,7 @@ bool process_tapping(keyrecord_t *keyp) */ else if (IS_RELEASED(event) && waiting_buffer_typed(event)) { debug("Tapping: End. No tap. Interfered by typing key\n"); - process_action(&tapping_key); + process_record(&tapping_key); tapping_key = (keyrecord_t){}; debug_tapping_key(); // enqueue @@ -131,7 +131,7 @@ bool process_tapping(keyrecord_t *keyp) } // Release of key should be process immediately. debug("Tapping: release event of a key pressed before tapping\n"); - process_action(keyp); + process_record(keyp); return true; } else { @@ -148,7 +148,7 @@ bool process_tapping(keyrecord_t *keyp) if (IS_TAPPING_KEY(event.key) && !event.pressed) { debug("Tapping: Tap release("); debug_dec(tapping_key.tap.count); debug(")\n"); keyp->tap = tapping_key.tap; - process_action(keyp); + process_record(keyp); tapping_key = *keyp; debug_tapping_key(); return true; @@ -157,7 +157,7 @@ bool process_tapping(keyrecord_t *keyp) if (tapping_key.tap.count > 1) { debug("Tapping: Start new tap with releasing last tap(>1).\n"); // unregister key - process_action(&(keyrecord_t){ + process_record(&(keyrecord_t){ .tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, @@ -175,7 +175,7 @@ bool process_tapping(keyrecord_t *keyp) if (!IS_NOEVENT(event)) { debug("Tapping: key event while last tap(>0).\n"); } - process_action(keyp); + process_record(keyp); return true; } } @@ -185,7 +185,7 @@ bool process_tapping(keyrecord_t *keyp) if (tapping_key.tap.count == 0) { debug("Tapping: End. Timeout. Not tap(0): "); debug_event(event); debug("\n"); - process_action(&tapping_key); + process_record(&tapping_key); tapping_key = (keyrecord_t){}; debug_tapping_key(); return false; @@ -193,7 +193,7 @@ bool process_tapping(keyrecord_t *keyp) if (IS_TAPPING_KEY(event.key) && !event.pressed) { debug("Tapping: End. last timeout tap release(>0)."); keyp->tap = tapping_key.tap; - process_action(keyp); + process_record(keyp); tapping_key = (keyrecord_t){}; return true; } @@ -201,7 +201,7 @@ bool process_tapping(keyrecord_t *keyp) if (tapping_key.tap.count > 1) { debug("Tapping: Start new tap with releasing last timeout tap(>1).\n"); // unregister key - process_action(&(keyrecord_t){ + process_record(&(keyrecord_t){ .tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, @@ -219,7 +219,7 @@ bool process_tapping(keyrecord_t *keyp) if (!IS_NOEVENT(event)) { debug("Tapping: key event while last timeout tap(>0).\n"); } - process_action(keyp); + process_record(keyp); return true; } } @@ -233,7 +233,7 @@ bool process_tapping(keyrecord_t *keyp) keyp->tap = tapping_key.tap; if (keyp->tap.count < 15) keyp->tap.count += 1; debug("Tapping: Tap press("); debug_dec(keyp->tap.count); debug(")\n"); - process_action(keyp); + process_record(keyp); tapping_key = *keyp; debug_tapping_key(); return true; @@ -253,12 +253,12 @@ bool process_tapping(keyrecord_t *keyp) // should none in buffer // FIX: interrupted when other key is pressed tapping_key.tap.interrupted = true; - process_action(keyp); + process_record(keyp); return true; } } else { if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); - process_action(keyp); + process_record(keyp); return true; } } else { @@ -280,7 +280,7 @@ bool process_tapping(keyrecord_t *keyp) debug_tapping_key(); return true; } else { - process_action(keyp); + process_record(keyp); return true; } } @@ -347,7 +347,7 @@ void waiting_buffer_scan_tap(void) WITHIN_TAPPING_TERM(waiting_buffer[i].event)) { tapping_key.tap.count = 1; waiting_buffer[i].tap.count = 1; - process_action(&tapping_key); + process_record(&tapping_key); debug("waiting_buffer_scan_tap: found at ["); debug_dec(i); debug("]\n"); debug_waiting_buffer(); diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c index a2d6577b24d..61ff202befa 100644 --- a/tmk_core/common/action_util.c +++ b/tmk_core/common/action_util.c @@ -18,6 +18,7 @@ along with this program. If not, see . #include "report.h" #include "debug.h" #include "action_util.h" +#include "action_layer.h" #include "timer.h" static inline void add_key_byte(uint8_t code); @@ -47,11 +48,70 @@ report_keyboard_t *keyboard_report = &(report_keyboard_t){}; #ifndef NO_ACTION_ONESHOT static int8_t oneshot_mods = 0; +static int8_t oneshot_locked_mods = 0; +int8_t get_oneshot_locked_mods(void) { return oneshot_locked_mods; } +void set_oneshot_locked_mods(int8_t mods) { oneshot_locked_mods = mods; } +void clear_oneshot_locked_mods(void) { oneshot_locked_mods = 0; } #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) static int16_t oneshot_time = 0; +inline bool has_oneshot_mods_timed_out() { + return TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT; +} #endif #endif +/* oneshot layer */ +#ifndef NO_ACTION_ONESHOT +/* oneshot_layer_data bits +* LLLL LSSS +* where: +* L => are layer bits +* S => oneshot state bits +*/ +static int8_t oneshot_layer_data = 0; + +inline uint8_t get_oneshot_layer(void) { return oneshot_layer_data >> 3; } +inline uint8_t get_oneshot_layer_state(void) { return oneshot_layer_data & 0b111; } + +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) +static int16_t oneshot_layer_time = 0; +inline bool has_oneshot_layer_timed_out() { + return TIMER_DIFF_16(timer_read(), oneshot_layer_time) >= ONESHOT_TIMEOUT && + !(get_oneshot_layer_state() & ONESHOT_TOGGLED); +} +#endif + +/* Oneshot layer */ +void set_oneshot_layer(uint8_t layer, uint8_t state) +{ + oneshot_layer_data = layer << 3 | state; + layer_on(layer); +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + oneshot_layer_time = timer_read(); +#endif +} +void reset_oneshot_layer(void) { + oneshot_layer_data = 0; +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + oneshot_layer_time = 0; +#endif +} +void clear_oneshot_layer_state(oneshot_fullfillment_t state) +{ + uint8_t start_state = oneshot_layer_data; + oneshot_layer_data &= ~state; + if (!get_oneshot_layer_state() && start_state != oneshot_layer_data) { + layer_off(get_oneshot_layer()); +#if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) + oneshot_layer_time = 0; +#endif + } +} +bool is_oneshot_layer_active(void) +{ + return get_oneshot_layer_state(); +} +#endif void send_keyboard_report(void) { keyboard_report->mods = real_mods; @@ -60,7 +120,7 @@ void send_keyboard_report(void) { #ifndef NO_ACTION_ONESHOT if (oneshot_mods) { #if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0)) - if (TIMER_DIFF_16(timer_read(), oneshot_time) >= ONESHOT_TIMEOUT) { + if (has_oneshot_mods_timed_out()) { dprintf("Oneshot: timeout\n"); clear_oneshot_mods(); } @@ -70,6 +130,7 @@ void send_keyboard_report(void) { clear_oneshot_mods(); } } + #endif host_keyboard_send(keyboard_report); } @@ -143,11 +204,12 @@ void clear_oneshot_mods(void) oneshot_time = 0; #endif } +uint8_t get_oneshot_mods(void) +{ + return oneshot_mods; +} #endif - - - /* * inspect keyboard state */ diff --git a/tmk_core/common/action_util.h b/tmk_core/common/action_util.h index 1a95cec10ec..dd0c4c2bfe7 100644 --- a/tmk_core/common/action_util.h +++ b/tmk_core/common/action_util.h @@ -56,10 +56,30 @@ void clear_macro_mods(void); /* oneshot modifier */ void set_oneshot_mods(uint8_t mods); +uint8_t get_oneshot_mods(void); void clear_oneshot_mods(void); void oneshot_toggle(void); void oneshot_enable(void); void oneshot_disable(void); +bool has_oneshot_mods_timed_out(void); + +int8_t get_oneshot_locked_mods(void); +void set_oneshot_locked_mods(int8_t mods); +void clear_oneshot_locked_mods(void); + +typedef enum { + ONESHOT_PRESSED = 0b01, + ONESHOT_OTHER_KEY_PRESSED = 0b10, + ONESHOT_START = 0b11, + ONESHOT_TOGGLED = 0b100 +} oneshot_fullfillment_t; +void set_oneshot_layer(uint8_t layer, uint8_t state); +uint8_t get_oneshot_layer(void); +void clear_oneshot_layer_state(oneshot_fullfillment_t state); +void reset_oneshot_layer(void); +bool is_oneshot_layer_active(void); +uint8_t get_oneshot_layer_state(void); +bool has_oneshot_layer_timed_out(void); /* inspect */ uint8_t has_anykey(void); diff --git a/tmk_core/common/avr/suspend.c b/tmk_core/common/avr/suspend.c index 4980680198e..a6f3c644147 100644 --- a/tmk_core/common/avr/suspend.c +++ b/tmk_core/common/avr/suspend.c @@ -114,9 +114,7 @@ bool suspend_wakeup_condition(void) matrix_power_up(); matrix_scan(); matrix_power_down(); - for (uint8_t r = 0; r < MATRIX_ROWS; r++) { - if (matrix_get_row(r)) return true; - } + if (matrix_key_count()) return true; return false; } @@ -146,4 +144,3 @@ ISR(WDT_vect) } } #endif - diff --git a/tmk_core/common/backlight.c b/tmk_core/common/backlight.c index 2f6fc1cd6c4..c9e8fd3fd2d 100644 --- a/tmk_core/common/backlight.c +++ b/tmk_core/common/backlight.c @@ -83,3 +83,8 @@ void backlight_level(uint8_t level) eeconfig_update_backlight(backlight_config.raw); backlight_set(backlight_config.level); } + +uint8_t get_backlight_level(void) +{ + return backlight_config.level; +} \ No newline at end of file diff --git a/tmk_core/common/backlight.h b/tmk_core/common/backlight.h index 525ec8bbef0..f5730926745 100644 --- a/tmk_core/common/backlight.h +++ b/tmk_core/common/backlight.h @@ -36,5 +36,6 @@ void backlight_toggle(void); void backlight_step(void); void backlight_set(uint8_t level); void backlight_level(uint8_t level); +uint8_t get_backlight_level(void); #endif diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c index 2c1b1adfc5d..30e8a0f20fe 100644 --- a/tmk_core/common/bootmagic.c +++ b/tmk_core/common/bootmagic.c @@ -105,15 +105,13 @@ void bootmagic(void) } } -static bool scan_keycode(uint8_t keycode) -{ - for (uint8_t r = 0; r < MATRIX_ROWS; r++) { +static bool scan_keycode(uint8_t keycode) { + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { matrix_row_t matrix_row = matrix_get_row(r); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_row & ((matrix_row_t)1<= 0; --c) { + if (matrix_row & (matrix_row_t)1 << c) { + keypos_t key = (keypos_t){ .row = r, .col = c }; + if (keycode == keymap_key_to_keycode(0, key)) return true; } } } diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index f06abaf7f02..024d7c67a33 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c @@ -33,20 +33,21 @@ along with this program. If not, see . #include "led.h" #include "command.h" #include "backlight.h" +#include "quantum.h" #ifdef MOUSEKEY_ENABLE #include "mousekey.h" #endif #ifdef PROTOCOL_PJRC -# include "usb_keyboard.h" -# ifdef EXTRAKEY_ENABLE -# include "usb_extra.h" -# endif + #include "usb_keyboard.h" + #ifdef EXTRAKEY_ENABLE + #include "usb_extra.h" + #endif #endif #ifdef PROTOCOL_VUSB -# include "usbdrv.h" + #include "usbdrv.h" #endif #ifdef AUDIO_ENABLE @@ -357,9 +358,11 @@ static bool command_common(uint8_t code) clear_keyboard(); // clear to prevent stuck keys print("\n\nJumping to bootloader... "); #ifdef AUDIO_ENABLE - play_goodbye_tone(); + stop_all_notes(); + shutdown_user(); + #else + _delay_ms(1000); #endif - _delay_ms(1000); bootloader_jump(); // not return break; diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 1d998184811..bd543c45e1a 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -1,5 +1,5 @@ /* -Copyright 2011,2012,2013 Jun Wako +Copyright 2011, 2012, 2013 Jun Wako This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,13 +27,13 @@ along with this program. If not, see . #include "command.h" #include "util.h" #include "sendchar.h" -#ifdef BOOTMAGIC_ENABLE - #include "bootmagic.h" -#else - #include "magic.h" -#endif #include "eeconfig.h" #include "backlight.h" +#ifdef BOOTMAGIC_ENABLE +# include "bootmagic.h" +#else +# include "magic.h" +#endif #ifdef MOUSEKEY_ENABLE # include "mousekey.h" #endif @@ -41,40 +41,35 @@ along with this program. If not, see . # include "ps2_mouse.h" #endif #ifdef SERIAL_MOUSE_ENABLE -#include "serial_mouse.h" +# include "serial_mouse.h" #endif #ifdef ADB_MOUSE_ENABLE -#include "adb.h" +# include "adb.h" #endif - #ifdef MATRIX_HAS_GHOST -static bool has_ghost_in_row(uint8_t row) -{ - matrix_row_t matrix_row = matrix_get_row(row); - // No ghost exists when less than 2 keys are down on the row - if (((matrix_row - 1) & matrix_row) == 0) - return false; - - // Ghost occurs when the row shares column line with other row - for (uint8_t i=0; i < MATRIX_ROWS; i++) { - if (i != row && (matrix_get_row(i) & matrix_row)) - return true; +static bool is_row_ghosting(uint8_t row){ + matrix_row_t state = matrix_get_row(row); + /* no ghosting happens when only one key in the row is pressed */ + if (!(state - 1 & state)) return false; + /* ghosting occurs when two keys in the same column are pressed */ + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + if (r != row && matrix_get_row(r) & state) return true; } return false; } + #endif +__attribute__ ((weak)) +void matrix_setup(void) { +} -__attribute__ ((weak)) void matrix_setup(void) {} -void keyboard_setup(void) -{ +void keyboard_setup(void) { matrix_setup(); } -void keyboard_init(void) -{ - +void keyboard_init(void) { timer_init(); matrix_init(); #ifdef PS2_MOUSE_ENABLE @@ -86,104 +81,85 @@ void keyboard_init(void) #ifdef ADB_MOUSE_ENABLE adb_mouse_init(); #endif - - #ifdef BOOTMAGIC_ENABLE bootmagic(); #else magic(); #endif - #ifdef BACKLIGHT_ENABLE backlight_init(); #endif - #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) keyboard_nkro = true; #endif - } -/* - * Do keyboard routine jobs: scan mantrix, light LEDs, ... - * This is repeatedly called as fast as possible. - */ -void keyboard_task(void) -{ - static matrix_row_t matrix_prev[MATRIX_ROWS]; -#ifdef MATRIX_HAS_GHOST - static matrix_row_t matrix_ghost[MATRIX_ROWS]; -#endif - static uint8_t led_status = 0; - matrix_row_t matrix_row = 0; - matrix_row_t matrix_change = 0; - +/* does routine keyboard jobs */ +void keyboard_task(void) { + static uint8_t led_status; matrix_scan(); - for (uint8_t r = 0; r < MATRIX_ROWS; r++) { - matrix_row = matrix_get_row(r); - matrix_change = matrix_row ^ matrix_prev[r]; - if (matrix_change) { + for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) { + static matrix_row_t previous_matrix[MATRIX_ROWS]; + matrix_row_t state = matrix_get_row(r); + matrix_row_t changes = state ^ previous_matrix[r]; + if (changes) { #ifdef MATRIX_HAS_GHOST - if (has_ghost_in_row(r)) { - /* Keep track of whether ghosted status has changed for - * debugging. But don't update matrix_prev until un-ghosted, or - * the last key would be lost. + static matrix_row_t deghosting_matrix[MATRIX_ROWS]; + if (is_row_ghosting(r)) { + /* debugs the deghosting mechanism */ + /* doesn't update previous_matrix until the ghosting has stopped + * in order to prevent the last key from being lost */ - if (debug_matrix && matrix_ghost[r] != matrix_row) { + if (debug_matrix && deghosting_matrix[r] != state) { matrix_print(); } - matrix_ghost[r] = matrix_row; + deghosting_matrix[r] = state; continue; } - matrix_ghost[r] = matrix_row; + deghosting_matrix[r] = state; #endif if (debug_matrix) matrix_print(); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_change & ((matrix_row_t)1<= 0; --c) { + matrix_row_t mask = (matrix_row_t)1 << c; + if (changes & mask) { + keyevent_t event; + event.key = (keypos_t){ .row = r, .col = c }; + event.pressed = state & mask; + /* the time should not be 0 */ + event.time = timer_read() | 1; + action_exec(event); + /* records the processed key event */ + previous_matrix[r] ^= mask; + /* processes one key event per call */ + goto event_processed; } } } } - // call with pseudo tick event when no real key event. + /* sends tick events when the keyboard is idle */ action_exec(TICK); - -MATRIX_LOOP_END: - +event_processed: #ifdef MOUSEKEY_ENABLE - // mousekey repeat & acceleration + /* repeats and accelerates the mouse keys */ mousekey_task(); #endif - #ifdef PS2_MOUSE_ENABLE ps2_mouse_task(); #endif - #ifdef SERIAL_MOUSE_ENABLE - serial_mouse_task(); + serial_mouse_task(); #endif - #ifdef ADB_MOUSE_ENABLE - adb_mouse_task(); + adb_mouse_task(); #endif - - // update LED + /* updates the LEDs */ if (led_status != host_keyboard_leds()) { led_status = host_keyboard_leds(); keyboard_set_leds(led_status); } } -void keyboard_set_leds(uint8_t leds) -{ - if (debug_keyboard) { debug("keyboard_set_led: "); debug_hex8(leds); debug("\n"); } +void keyboard_set_leds(uint8_t leds) { + if (debug_keyboard) dprintf("Keyboard LEDs state: %x\n", leds); led_set(leds); } diff --git a/tmk_core/common/matrix.h b/tmk_core/common/matrix.h index 0b013fc989a..5f380aaaba0 100644 --- a/tmk_core/common/matrix.h +++ b/tmk_core/common/matrix.h @@ -14,59 +14,68 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #ifndef MATRIX_H #define MATRIX_H #include #include - -#if (MATRIX_COLS <= 8) -typedef uint8_t matrix_row_t; -#elif (MATRIX_COLS <= 16) -typedef uint16_t matrix_row_t; -#elif (MATRIX_COLS <= 32) -typedef uint32_t matrix_row_t; +#if MATRIX_COLS <= 8 +typedef uint8_t matrix_row_t; +#elif MATRIX_COLS <= 16 +typedef uint16_t matrix_row_t; +#elif MATRIX_COLS <= 32 +typedef uint32_t matrix_row_t; #else -#error "MATRIX_COLS: invalid value" +# error "There are too many columns." #endif -#define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1<. */ #ifndef NODEBUG_H -#define NODEBUG_H 1 +#define NODEBUG_H -#define NO_DEBUG -#include "debug.h" -#undef NO_DEBUG +#ifndef NO_DEBUG + #define NO_DEBUG + #include "debug.h" + #undef NO_DEBUG +#else + #include "debug.h" +#endif #endif diff --git a/tmk_core/doc/keymap.md b/tmk_core/doc/keymap.md index d4a129b2081..4d42fbe5cb9 100644 --- a/tmk_core/doc/keymap.md +++ b/tmk_core/doc/keymap.md @@ -528,14 +528,20 @@ This is a feature to assign both toggle layer and momentary switch layer action ### 4.3 Oneshot Modifier -This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping. +This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping. The behavior of oneshot modifiers is similar to the [sticky keys](https://en.wikipedia.org/wiki/StickyKeys) functionality found in most operating systems. ACTION_MODS_ONESHOT(MOD_LSFT) +Oneshot layer key: + + ACTION_LAYER_ONESHOT(MY_LAYER) + Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can release Shift before 't' is pressed down. Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined. +Most implementations of sticky keys allow you to lock a modifier by double tapping the modifier. The layer then remains locked untill the modifier is tapped again. To enable this behaviour for oneshot modifiers set `ONESHOT_TAP_TOGGLE` to the number taps required. The feature is disabled if `ONESHOT_TAP_TOGGLE<2` or not defined. + ### 4.4 Tap Toggle Mods Similar to layer tap toggle, this works as a momentary modifier when holding, but toggles on with several taps. A single tap will 'unstick' the modifier again. diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index f03f9a9b929..b70b52bf4d3 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -883,7 +883,7 @@ int main(void) midi_register_cc_callback(&midi_device, cc_callback); midi_register_sysex_callback(&midi_device, sysex_callback); - init_notes(); + // init_notes(); // midi_send_cc(&midi_device, 0, 1, 2); // midi_send_cc(&midi_device, 15, 1, 0); // midi_send_noteon(&midi_device, 0, 64, 127); @@ -947,10 +947,10 @@ void fallthrough_callback(MidiDevice * device, if (cnt == 3) { switch (byte0 & 0xF0) { case MIDI_NOTEON: - play_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(byte1 & 0x7F)/12.0), (byte2 & 0x7F) / 8); + play_note(((double)261.6)*pow(2.0, -4.0)*pow(2.0,(byte1 & 0x7F)/12.0), (byte2 & 0x7F) / 8); break; case MIDI_NOTEOFF: - stop_note(((double)261.6)*pow(2.0, -1.0)*pow(2.0,(byte1 & 0x7F)/12.0)); + stop_note(((double)261.6)*pow(2.0, -4.0)*pow(2.0,(byte1 & 0x7F)/12.0)); break; } } diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index 860fc1a9310..1d384574f61 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk @@ -142,6 +142,9 @@ CFLAGS += $(CSTANDARD) ifdef CONFIG_H CFLAGS += -include $(CONFIG_H) endif +ifdef CONFIG_USER_H + CFLAGS += -include $(CONFIG_USER_H) +endif #---------------- Compiler Options C++ ---------------- @@ -176,6 +179,9 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) ifdef CONFIG_H CPPFLAGS += -include $(CONFIG_H) endif +ifdef CONFIG_USER_H + CPPFLAGS += -include $(CONFIG_USER_H) +endif #---------------- Assembler Options ---------------- @@ -192,6 +198,9 @@ ASFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) ifdef CONFIG_H ASFLAGS += -include $(CONFIG_H) endif +ifdef CONFIG_USER_H + ASFLAGS += -include $(CONFIG_USER_H) +endif #---------------- Library Options ---------------- @@ -357,7 +366,13 @@ ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) # Default target. -all: begin gccversion sizebefore build sizeafter end +all: + $(MAKE) begin + $(MAKE) gccversion + $(MAKE) sizebefore + $(MAKE) build + $(MAKE) sizeafter + $(MAKE) end # Change the build target to build a HEX file or a library. build: elf hex eep lss sym @@ -419,7 +434,7 @@ flip: $(TARGET).hex batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program batchisp -hardware usb -device $(MCU) -operation start reset 0 -dfu: $(TARGET).hex +dfu: $(TARGET).hex sizeafter ifneq (, $(findstring 0.7, $(shell dfu-programmer --version 2>&1))) dfu-programmer $(MCU) erase --force else