Merge pull request #29 from Wraul/update_phantom

Update Phantom for new keymap framework
This commit is contained in:
tmk 2013-04-21 15:13:20 -07:00
commit c852b04128
4 changed files with 93 additions and 101 deletions

View File

@ -97,11 +97,13 @@ F_USB = $(F_CPU)
# Build Options # Build Options
# comment out to disable the options. # comment out to disable the options.
# #
#MOUSEKEY_ENABLE = yes # Mouse keys BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
EXTRAKEY_ENABLE = yes # Audio control and System control #MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
CONSOLE_ENABLE = yes # Console for debug EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
# Boot Section Size in bytes # Boot Section Size in bytes

View File

@ -74,11 +74,14 @@ F_CPU = 16000000
# Build Options # Build Options
# comment out to disable the options. # comment out to disable the options.
# #
#MOUSEKEY_ENABLE = yes # Mouse keys BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support #MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
EXTRAKEY_ENABLE = yes # Audio control and System control EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
#NKRO_ENABLE = yes # USB Nkey Rollover
CONSOLE_ENABLE = yes # Console for debug CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
# Search Path # Search Path

View File

@ -39,9 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Set 0 if need no debouncing */ /* Set 0 if need no debouncing */
#define DEBOUNCE 7 #define DEBOUNCE 7
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
/* key combination for command */ /* key combination for command */
#define IS_COMMAND() ( \ #define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \

View File

@ -22,9 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h> #include <stdbool.h>
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "keycode.h" #include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "print.h" #include "print.h"
#include "debug.h" #include "debug.h"
#include "util.h"
#include "keymap.h" #include "keymap.h"
@ -47,34 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \ /* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \
} }
#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
static const uint8_t PROGMEM fn_layer[] = {
0, // Fn0
1, // Fn1
2, // Fn2
3, // Fn3
4, // Fn4
5, // Fn5
6, // Fn6
7 // Fn7
};
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_NO, // Fn2
KC_NO, // Fn3
KC_NO, // Fn4
KC_NO, // Fn5
KC_NO, // Fn6
KC_NO // Fn7
};
/* /*
* Phantom keyboard layout with winkeys and 7bit style editing block. I am * Phantom keyboard layout with winkeys and 7bit style editing block. I am
* Not in the mood to implement full 7-bit keymap. * Not in the mood to implement full 7-bit keymap.
@ -122,51 +97,66 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \ ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, \
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, \
FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ FN0, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, 0, 0, 0, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, 0, UP, 0, \ LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, 0, UP, 0, \
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT), LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT),
/* Overlay 1
/* *
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Slp| * | | | | | | | | | | | | | | | | | | | |Slp|
* `---' `---------------' `---------------' `---------------' `-----------' * `---' `---------------' `---------------' `---------------' `-----------'
* ,-----------------------------------------------------------. ,-----------. * ,-----------------------------------------------------------. ,-----------.
* |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9|Mut|V- |V+ |Backsp | |Ins|Hom|PgU| * | | | | | | | | | | |Mut|V- |V+ | | | | | |
* |-----------------------------------------------------------| |-----------| * |-----------------------------------------------------------| |-----------|
* |Tab | Q| W| E| R| T| Y| U| I|MSt|Ply|Prv|Nxt|Media| |Del|End|PgD| * | | | | | | | | | |MSt|Ply|Prv|Nxt|Media| | | | |
* |-----------------------------------------------------------| |-----------| * |-----------------------------------------------------------| |-----------|
* |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return | |???|???|???| * | | | | | | | | | | | | | | |???|???|???|
* |-----------------------------------------------------------| |-----------| * |-----------------------------------------------------------| |-----------|
* |Shft | Z| X|Clc| V| B| N| M| ,| .| /|Caps | |???|Up |???| * | | | |Clc| | | | | | | |Caps | |???| |???|
* |-----------------------------------------------------------| |-----------| * |-----------------------------------------------------------| |-----------|
* |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| * | | | | | | | | | | | | |
* `-----------------------------------------------------------' `-----------' * `-----------------------------------------------------------' `-----------'
*/ */
KEYMAP(\ KEYMAP(\
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,SLEP, \
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MUTE,VOLD,VOLU,TRNS, TRNS,TRNS,TRNS, \
TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MSTP,MPLY,MPRV,MNXT,MSEL, TRNS,TRNS,TRNS, \
FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \
LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \ TRNS,TRNS,TRNS,CALC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, CAPS, TRNS,TRNS,TRNS, \
LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS),
}; };
/*
* Fn action definition
*/
static const uint16_t PROGMEM fn_actions[] = {
[0] = ACTION_LAYER_MOMENTARY(1)
};
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) #define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{ {
return KEYCODE(layer, row, col); if (layer < KEYMAPS_SIZE) {
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
} else {
// fall back to layer 0
return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
}
} }
uint8_t keymap_fn_layer(uint8_t index) /* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{ {
return pgm_read_byte(&fn_layer[index]); action_t action;
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
} else {
action.code = ACTION_NO;
} }
return action;
uint8_t keymap_fn_keycode(uint8_t index)
{
return pgm_read_byte(&fn_keycode[index]);
} }