aboutsummaryrefslogtreecommitdiff
path: root/keyboard/phantom
diff options
context:
space:
mode:
authorMathias Andersson <wraul@dbox.se>2013-04-21 08:48:56 +0200
committerMathias Andersson <wraul@dbox.se>2013-04-21 22:06:14 +0200
commitc4b012cdb546b2d5ebbbd9df98efc02197073e53 (patch)
tree7da2489c18cc92672d44b156d87b84b68947a7ec /keyboard/phantom
parent2fc681b4f768484c2ba5cfa22662bf4c09586e57 (diff)
downloadqmk_firmware-c4b012cdb546b2d5ebbbd9df98efc02197073e53.tar.gz
qmk_firmware-c4b012cdb546b2d5ebbbd9df98efc02197073e53.zip
Updated Phantom for new keymap framework.
Diffstat (limited to 'keyboard/phantom')
-rw-r--r--keyboard/phantom/Makefile.lufa10
-rw-r--r--keyboard/phantom/Makefile.pjrc11
-rw-r--r--keyboard/phantom/config.h3
-rw-r--r--keyboard/phantom/keymap.c72
4 files changed, 44 insertions, 52 deletions
diff --git a/keyboard/phantom/Makefile.lufa b/keyboard/phantom/Makefile.lufa
index c8c13da09..5199fe39f 100644
--- a/keyboard/phantom/Makefile.lufa
+++ b/keyboard/phantom/Makefile.lufa
@@ -97,11 +97,13 @@ F_USB = $(F_CPU)
97# Build Options 97# Build Options
98# comment out to disable the options. 98# comment out to disable the options.
99# 99#
100#MOUSEKEY_ENABLE = yes # Mouse keys 100BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
101EXTRAKEY_ENABLE = yes # Audio control and System control 101#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
102CONSOLE_ENABLE = yes # Console for debug 102EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
103CONSOLE_ENABLE = yes # Console for debug(+400)
104COMMAND_ENABLE = yes # Commands for debug and configuration
105#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
103#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA 106#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
104#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
105 107
106 108
107# Boot Section Size in bytes 109# Boot Section Size in bytes
diff --git a/keyboard/phantom/Makefile.pjrc b/keyboard/phantom/Makefile.pjrc
index 67bf6df28..7c022a03f 100644
--- a/keyboard/phantom/Makefile.pjrc
+++ b/keyboard/phantom/Makefile.pjrc
@@ -74,11 +74,14 @@ F_CPU = 16000000
74# Build Options 74# Build Options
75# comment out to disable the options. 75# comment out to disable the options.
76# 76#
77#MOUSEKEY_ENABLE = yes # Mouse keys 77BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
78#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support 78#MOUSEKEY_ENABLE = yes # Mouse keys(+5000)
79EXTRAKEY_ENABLE = yes # Audio control and System control 79EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
80#NKRO_ENABLE = yes # USB Nkey Rollover
81CONSOLE_ENABLE = yes # Console for debug 80CONSOLE_ENABLE = yes # Console for debug
81COMMAND_ENABLE = yes # Commands for debug and configuration
82#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
83#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
84#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
82 85
83 86
84# Search Path 87# Search Path
diff --git a/keyboard/phantom/config.h b/keyboard/phantom/config.h
index ac014bae9..09f758cd0 100644
--- a/keyboard/phantom/config.h
+++ b/keyboard/phantom/config.h
@@ -39,9 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39/* Set 0 if need no debouncing */ 39/* Set 0 if need no debouncing */
40#define DEBOUNCE 7 40#define DEBOUNCE 7
41 41
42/* legacy keymap support */
43#define USE_LEGACY_KEYMAP
44
45/* key combination for command */ 42/* key combination for command */
46#define IS_COMMAND() ( \ 43#define IS_COMMAND() ( \
47 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 44 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
diff --git a/keyboard/phantom/keymap.c b/keyboard/phantom/keymap.c
index 0a95f9fbb..1a9edd3ea 100644
--- a/keyboard/phantom/keymap.c
+++ b/keyboard/phantom/keymap.c
@@ -22,9 +22,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#include <stdbool.h> 22#include <stdbool.h>
23#include <avr/pgmspace.h> 23#include <avr/pgmspace.h>
24#include "keycode.h" 24#include "keycode.h"
25#include "action.h"
26#include "action_macro.h"
27#include "report.h"
28#include "host.h"
25#include "print.h" 29#include "print.h"
26#include "debug.h" 30#include "debug.h"
27#include "util.h"
28#include "keymap.h" 31#include "keymap.h"
29 32
30 33
@@ -47,34 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47/* 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}, \ 50/* 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}, \
48} 51}
49 52
50#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
51
52
53// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
54static const uint8_t PROGMEM fn_layer[] = {
55 0, // Fn0
56 1, // Fn1
57 2, // Fn2
58 3, // Fn3
59 4, // Fn4
60 5, // Fn5
61 6, // Fn6
62 7 // Fn7
63};
64
65// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
66// See layer.c for details.
67static const uint8_t PROGMEM fn_keycode[] = {
68 KC_NO, // Fn0
69 KC_NO, // Fn1
70 KC_NO, // Fn2
71 KC_NO, // Fn3
72 KC_NO, // Fn4
73 KC_NO, // Fn5
74 KC_NO, // Fn6
75 KC_NO // Fn7
76};
77
78/* 53/*
79 * Phantom keyboard layout with winkeys and 7bit style editing block. I am 54 * Phantom keyboard layout with winkeys and 7bit style editing block. I am
80 * Not in the mood to implement full 7-bit keymap. 55 * Not in the mood to implement full 7-bit keymap.
@@ -122,7 +97,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
122 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \ 97 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
123 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \ 98 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
124 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \ 99 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
125 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ 100 FN0, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \
126 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, 0, UP, 0, \ 101 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, 0, UP, 0, \
127 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), 102 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
128 103
@@ -148,25 +123,40 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
148 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \ 123 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \
149 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \ 124 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \
150 TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \ 125 TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \
151 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ 126 FN0, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \
152 LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \ 127 LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \
153 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), 128 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
154
155
156}; 129};
157 130
131/*
132 * Fn action definition
133 */
134static const uint16_t PROGMEM fn_actions[] = {
135 [0] = ACTION_LAYER_MOMENTARY(1)
136};
158 137
159uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) 138#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
160{ 139#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
161 return KEYCODE(layer, row, col);
162}
163 140
164uint8_t keymap_fn_layer(uint8_t index) 141/* translates key to keycode */
142uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
165{ 143{
166 return pgm_read_byte(&fn_layer[index]); 144 if (layer < KEYMAPS_SIZE) {
145 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
146 } else {
147 // fall back to layer 0
148 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
149 }
167} 150}
168 151
169uint8_t keymap_fn_keycode(uint8_t index) 152/* translates Fn keycode to action */
153action_t keymap_fn_to_action(uint8_t keycode)
170{ 154{
171 return pgm_read_byte(&fn_keycode[index]); 155 action_t action;
156 if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
157 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
158 } else {
159 action.code = ACTION_NO;
160 }
161 return action;
172} 162}