aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2013-02-24 18:10:50 +0900
committertmk <nobody@nowhere>2013-02-24 18:10:50 +0900
commitfea6792f1636a716e799539b072930461bfcba67 (patch)
tree49f7fc333ac37d2bbb8050dc4b543e5efa2f0bea
parent79b1f129085425c72b72bee28ed065bf243c0a0b (diff)
downloadqmk_firmware-fea6792f1636a716e799539b072930461bfcba67.tar.gz
qmk_firmware-fea6792f1636a716e799539b072930461bfcba67.zip
New keymap of PC98
-rw-r--r--converter/pc98_usb/README5
-rw-r--r--converter/pc98_usb/config.h24
-rw-r--r--converter/pc98_usb/keymap.c153
3 files changed, 90 insertions, 92 deletions
diff --git a/converter/pc98_usb/README b/converter/pc98_usb/README
index 7d9547d50..23f1b614e 100644
--- a/converter/pc98_usb/README
+++ b/converter/pc98_usb/README
@@ -60,6 +60,11 @@ http://davy.nyacom.net/kbd98usb/
60 60
61PC98 to PS/2 61PC98 to PS/2
62http://www.tsp.ne.jp/~sawada/mago/c_gka98at.htm 62http://www.tsp.ne.jp/~sawada/mago/c_gka98at.htm
63http://www.tsp.ne.jp/~sawada/mago/src/gka98at.asm
63 64
64PC98 keyboard commands 65PC98 keyboard commands
65http://www.webtech.co.jp/company/doc/undocumented_mem/io_kb.txt 66http://www.webtech.co.jp/company/doc/undocumented_mem/io_kb.txt
67
68
69Inhibit repeating key:
700x9C, 0x70
diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h
index 6ef2c6ac3..aa0476e3e 100644
--- a/converter/pc98_usb/config.h
+++ b/converter/pc98_usb/config.h
@@ -30,12 +30,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
30#define MATRIX_ROWS 16 30#define MATRIX_ROWS 16
31#define MATRIX_COLS 8 31#define MATRIX_COLS 8
32 32
33/* To use new keymap framework */
34#define USE_KEYMAP_V2
33 35
34/* key combination for command */ 36/* key combination for command */
35#define IS_COMMAND() ( \ 37#define IS_COMMAND() ( \
36 keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \ 38 host_get_first_key() == KC_CANCEL \
37 keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
38 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
39) 39)
40 40
41 41
@@ -46,11 +46,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
46#define SERIAL_BAUD 19200 46#define SERIAL_BAUD 19200
47#define SERIAL_PARITY_ODD 47#define SERIAL_PARITY_ODD
48#define SERIAL_BIT_ORDER_LSB 48#define SERIAL_BIT_ORDER_LSB
49#define SERIAL_LOGIC_POSITIVE
49 50
50/* PC98 Reset Port */ 51/* PC98 Reset Port shared with TXD */
51#define PC98_RST_DDR DDRD 52#define PC98_RST_DDR DDRD
52#define PC98_RST_PORT PORTD 53#define PC98_RST_PORT PORTD
53#define PC98_RST_BIT 1 54#define PC98_RST_BIT 3
54/* PC98 Ready Port */ 55/* PC98 Ready Port */
55#define PC98_RDY_DDR DDRD 56#define PC98_RDY_DDR DDRD
56#define PC98_RDY_PORT PORTD 57#define PC98_RDY_PORT PORTD
@@ -65,7 +66,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
65#define SERIAL_RXD_PORT PORTD 66#define SERIAL_RXD_PORT PORTD
66#define SERIAL_RXD_PIN PIND 67#define SERIAL_RXD_PIN PIND
67#define SERIAL_RXD_BIT 2 68#define SERIAL_RXD_BIT 2
69#ifdef SERIAL_LOGIC_NEGATIVE
70#define SERIAL_RXD_READ() ~(SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT))
71#else
68#define SERIAL_RXD_READ() (SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT)) 72#define SERIAL_RXD_READ() (SERIAL_RXD_PIN&(1<<SERIAL_RXD_BIT))
73#endif
69/* RXD Interupt */ 74/* RXD Interupt */
70#define SERIAL_RXD_VECT INT2_vect 75#define SERIAL_RXD_VECT INT2_vect
71#define SERIAL_RXD_INIT() do { \ 76#define SERIAL_RXD_INIT() do { \
@@ -75,6 +80,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
75 /* enable interrupt: INT2(falling edge) */ \ 80 /* enable interrupt: INT2(falling edge) */ \
76 EICRA |= ((1<<ISC21)|(0<<ISC20)); \ 81 EICRA |= ((1<<ISC21)|(0<<ISC20)); \
77 EIMSK |= (1<<INT2); \ 82 EIMSK |= (1<<INT2); \
83 sei(); \
78} while (0) 84} while (0)
79#define SERIAL_RXD_INT_ENTER() 85#define SERIAL_RXD_INT_ENTER()
80#define SERIAL_RXD_INT_EXIT() do { \ 86#define SERIAL_RXD_INT_EXIT() do { \
@@ -82,14 +88,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
82 EIFR = (1<<INTF2); \ 88 EIFR = (1<<INTF2); \
83} while (0) 89} while (0)
84 90
85/* TXD Port: Not used */ 91/* TXD Port */
86#define SERIAL_TXD_DDR DDRD 92#define SERIAL_TXD_DDR DDRD
87#define SERIAL_TXD_PORT PORTD 93#define SERIAL_TXD_PORT PORTD
88#define SERIAL_TXD_PIN PIND 94#define SERIAL_TXD_PIN PIND
89#define SERIAL_TXD_BIT 3 95#define SERIAL_TXD_BIT 3
90/* negative logic */ 96#ifdef SERIAL_LOGIC_NEGATIVE
91#define SERIAL_TXD_ON() do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0) 97#define SERIAL_TXD_ON() do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0)
92#define SERIAL_TXD_OFF() do { SERIAL_TXD_PORT |= (1<<SERIAL_TXD_BIT); } while (0) 98#define SERIAL_TXD_OFF() do { SERIAL_TXD_PORT |= (1<<SERIAL_TXD_BIT); } while (0)
99#else
100#define SERIAL_TXD_ON() do { SERIAL_TXD_PORT |= (1<<SERIAL_TXD_BIT); } while (0)
101#define SERIAL_TXD_OFF() do { SERIAL_TXD_PORT &= ~(1<<SERIAL_TXD_BIT); } while (0)
102#endif
93#define SERIAL_TXD_INIT() do { \ 103#define SERIAL_TXD_INIT() do { \
94 /* pin configuration: output */ \ 104 /* pin configuration: output */ \
95 SERIAL_TXD_DDR |= (1<<SERIAL_TXD_BIT); \ 105 SERIAL_TXD_DDR |= (1<<SERIAL_TXD_BIT); \
diff --git a/converter/pc98_usb/keymap.c b/converter/pc98_usb/keymap.c
index 1e2dd03d5..6bc549b05 100644
--- a/converter/pc98_usb/keymap.c
+++ b/converter/pc98_usb/keymap.c
@@ -19,6 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#include <stdbool.h> 19#include <stdbool.h>
20#include <avr/pgmspace.h> 20#include <avr/pgmspace.h>
21#include "keycode.h" 21#include "keycode.h"
22#include "action.h"
23#include "action_macro.h"
24#include "layer_switch.h"
22#include "util.h" 25#include "util.h"
23#include "keymap.h" 26#include "keymap.h"
24 27
@@ -33,7 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
33 | 00| 01| 02| 03| 04| 05| 58| 71| 06| 07| 08| 09| 0A| 0E| 36 | 00| 01| 02| 03| 04| 05| 58| 71| 06| 07| 08| 09| 0A| 0E|
34 |---------------------------------------------------------------| 37 |---------------------------------------------------------------|
35 | 0F| 10| 11| 12| 13| 14| 3A | 15| 16| 17| 18| 19| 1C| 38 | 0F| 10| 11| 12| 13| 14| 3A | 15| 16| 17| 18| 19| 1C|
36 |---------------------------------------------------------------| 39 |---------------------------------------------------------'. |
37 | 74| 20| 21| 22| 23| 24| 3B | 3C | 25| 26| 27| 28| 29| | 40 | 74| 20| 21| 22| 23| 24| 3B | 3C | 25| 26| 27| 28| 29| |
38 |---------------------------------------------------------------| 41 |---------------------------------------------------------------|
39 | 70| 2A| 2B| 2C| 2D| 2E| 38| 3D | 39| 2F| 30| 31| 32| 33| 70| 42 | 70| 2A| 2B| 2C| 2D| 2E| 38| 3D | 39| 2F| 30| 31| 32| 33| 70|
@@ -70,33 +73,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
70 73
71 74
72 75
73
74// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
75static const uint8_t PROGMEM fn_layer[] = {
76 2, // Fn0
77 3, // Fn1
78 4, // Fn2
79 0, // Fn3
80 0, // Fn4
81 0, // Fn5
82 0, // Fn6
83 0 // Fn7
84};
85
86// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
87// See layer.c for details.
88static const uint8_t PROGMEM fn_keycode[] = {
89 KC_NO, // Fn0
90 KC_SCLN, // Fn1
91 KC_SLSH, // Fn2
92 KC_NO, // Fn3
93 KC_NO, // Fn4
94 KC_NO, // Fn5
95 KC_NO, // Fn6
96 KC_NO // Fn7
97};
98
99
100static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 76static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
101 /* 77 /*
102 ,---------------------------------------------------------------. 78 ,---------------------------------------------------------------.
@@ -115,73 +91,80 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
115 `-----------------------------------------------' 91 `-----------------------------------------------'
116 */ 92 */
117 KEYMAP( 93 KEYMAP(
118 PAUS,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, 94 CANCEL,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14,
119 ESC, 1, 2, 3, 4, 5, NO, NO, 6, 7, 8, 9, 0, BSPC, 95 ESC, 1, 2, 3, 4, 5, NO, NO, 6, 7, 8, 9, 0, BSPC,
120 TAB, Q, W, E, R, T, UP, Y, U, I, O, P, ENT, 96 TAB, Q, W, E, R, T, UP, Y, U, I, O, P, ENT,
121 LCTL, A, S, D, F, G, MINS, EQL, H, J, K, L,SCLN, 97 LCTL, A, S, D, F, G, MINS, EQL, H, J, K, L, FN2,
122 LSFT, Z, X, C, V, B, INS, DOWN, DEL, N, M,COMM, DOT,SLSH, 98 LSFT, Z, X, C, V, B, INS, DOWN, DEL, N, M,COMM, DOT, FN1,
99 LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT
100 ),
101 KEYMAP(
102 PAUS,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14,
103 GRV, F1, F2, F3, F4, F5, NO, NO, F6, F7, F8, F9, F10, DEL,
104 TAB, Q, W, E, R, T, UP, HOME,PGDN,PGUP, END, P, ENT,
105 LCTL, A, S, D, F, G, MINS, EQL, LEFT,DOWN, UP,RGHT,SCLN,
106 LSFT, Z, X, C, V, B, INS, DOWN, DEL,HOME,PGDN,PGUP, END,TRNS,
107 LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT
108 ),
109 KEYMAP(
110 PAUS,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14,
111 GRV, F1, F2, F3, F4, F5, NO, NO, F6, F7, F8, F9, F10, DEL,
112 TAB, Q, W, E, R, T, UP, WH_L,WH_D,WH_U,WH_R, P, ENT,
113 LCTL, A, S, D, F, G, MINS, EQL, MS_L,MS_D,MS_U,MS_R,TRNS,
114 LSFT, Z, X, C, V, B, INS, DOWN, BTN3,BTN2,BTN1,BTN4,BTN5,TRNS,
123 LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT 115 LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT
124 ), 116 ),
125}; 117};
126 118
119static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
120
121static const uint16_t PROGMEM fn_actions[] = {
122 ACTION_KEYMAP_TAP_TOGGLE(0), // FN0
123 ACTION_KEYMAP_TAP_KEY(1, KC_SLASH), // FN1
124 ACTION_KEYMAP_TAP_KEY(2, KC_SCLN), // FN2
125 ACTION_KEYMAP(2), // FN3
126};
127 127
128uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
129{
130 return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
131}
132 128
133uint8_t keymap_fn_layer(uint8_t index)
134{
135 return pgm_read_byte(&fn_layer[index]);
136}
137 129
138uint8_t keymap_fn_keycode(uint8_t index) 130/*
131 * No need to edit.
132 */
133#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
134#define OVERLAYS_SIZE (sizeof(overlays) / sizeof(overlays[0]))
135#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
136
137/* translates key to keycode */
138uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
139{ 139{
140 return pgm_read_byte(&fn_keycode[index]); 140 /* Overlay: 16-31(OVERLAY_BIT(0x10) | overlay_layer) */
141 if (layer & OVERLAY_BIT) {
142 layer &= OVERLAY_MASK;
143 if (layer < OVERLAYS_SIZE) {
144 return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]);
145 } else {
146 return KC_TRANSPARENT;
147 }
148 }
149 /* Keymap: 0-15 */
150 else {
151 if (layer < KEYMAPS_SIZE) {
152 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
153 } else {
154 // fall back to layer 0
155 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
156 }
157 }
141} 158}
142 159
143 160/* translates Fn keycode to action */
144#if 0 161action_t keymap_fn_to_action(uint8_t keycode)
145/* PC-9801-98-S02 Raku Raku keyboard(Luckyboard) M-siki mode 162{
146 ,---------------------------------------------------------------. 163 action_t action;
147 | 60| 61| 62| 63| 64| 65| 66| 67| 68| 69| 6A| 6B| 36| 37| 3F| 3E| 164 if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
148 `---------------------------------------------------------------' 165 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
149 ,---------------------------------------------------------------. 166 } else {
150 | 00| 01| 02| 03| 04| 05| NUM|CAPS| 06| 07| 08| 09| 0A| 0E| 167 action.code = ACTION_NO;
151 |---------------------------------------------------------------| 168 }
152 | 0F| 10| 25| 20| 23| 2B| 3A | 2F| 15| 13| 11| 19| 1C| 169 return action;
153 |---------------------------------------------------------------|
154 | 74| 12| 16| 17| 1D| 18| 3B | 3C | 24| 1E| 14| 2E| 22| |
155 |---------------------------------------------------------------|
156 | 70| xx| 2A| 2C| xx| xx| 38| 3D | 39| 21| 29| 1F| xx| 2D| 70|
157 `---------------------------------------------------------------'
158 | 73| 51| xx| xx| 34| xx| 35| xx|
159 `-----------------------------------------------'
160*/
161
162#define KEYMAP_M( \
163 K60, K61, K62, K63, K64, K65, K66, K67, K68, K69, K6A, K6B, K36, K37, K3F, K3E, \
164 K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0E, \
165 K0F, K10, K25, K23, K20, K2B, K3A, K2F, K15, K13, K11, K19, K1C, \
166 K74, K12, K16, K17, K1D, K18, K3B, K3C, K24, K1E, K14, K2E, K22, \
167 K70, K2A, K2C, K38, K3D, K39, K21, K29, K1F, K2D, \
168 K73, K51, K34, K35 \
169) { \
170 { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
171 { KC_##K08, KC_##K09, KC_##K0A, KC_NO, KC_NO, KC_NO, KC_##K0E, KC_##K0F }, \
172 { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
173 { KC_##K18, KC_##K19, KC_NO, KC_NO, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \
174 { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_NO, KC_NO }, \
175 { KC_NO, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
176 { KC_NO, KC_NO, KC_NO, KC_NO, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
177 { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
178 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
179 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
180 { KC_NO, KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
181 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
182 { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
183 { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_NO, KC_NO, KC_NO, KC_NO }, \
184 { KC_##K70, KC_NO, KC_NO, KC_##K73, KC_##K74, KC_NO, KC_NO, KC_NO }, \
185 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \
186} 170}
187#endif