aboutsummaryrefslogtreecommitdiff
path: root/converter
diff options
context:
space:
mode:
Diffstat (limited to 'converter')
-rw-r--r--converter/ps2_usb/Makefile111
-rw-r--r--converter/ps2_usb/Makefile.pjrc75
-rw-r--r--converter/ps2_usb/config.h87
-rw-r--r--converter/ps2_usb/keymap.c379
-rw-r--r--converter/ps2_usb/keymap_common.c30
-rw-r--r--converter/ps2_usb/keymap_common.h174
-rw-r--r--converter/ps2_usb/keymap_plain.c50
-rw-r--r--converter/ps2_usb/matrix.c49
8 files changed, 485 insertions, 470 deletions
diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile
index 0c6442374..04bf28a00 100644
--- a/converter/ps2_usb/Makefile
+++ b/converter/ps2_usb/Makefile
@@ -1,5 +1,5 @@
1# Target file name (without extension). 1# Target file name (without extension).
2TARGET = ps2_usb 2TARGET = ps2_usb_lufa
3 3
4# Directory common source filess exist 4# Directory common source filess exist
5TOP_DIR = ../.. 5TOP_DIR = ../..
@@ -7,69 +7,96 @@ TOP_DIR = ../..
7# Directory keyboard dependent files exist 7# Directory keyboard dependent files exist
8TARGET_DIR = . 8TARGET_DIR = .
9 9
10# project specific files
11SRC = keymap_common.c \
12 matrix.c \
13 led.c
14
15ifdef KEYMAP
16 SRC := keymap_$(KEYMAP).c $(SRC)
17else
18 SRC := keymap_plain.c $(SRC)
19endif
20
21CONFIG_H = config.h
10 22
11# MCU name, you MUST set this to match the board you are using
12# type "make clean" after changing this, so all files will be rebuilt
13#MCU = at90usb162 # Teensy 1.0
14MCU = atmega32u4 # Teensy 2.0
15#MCU = at90usb646 # Teensy++ 1.0
16#MCU = at90usb1286 # Teensy++ 2.0
17 23
24# MCU name
25#MCU = at90usb1287
26MCU = atmega32u4
18 27
19# Processor frequency. 28# Processor frequency.
20# Normally the first thing your program should do is set the clock prescaler, 29# This will define a symbol, F_CPU, in all source code files equal to the
21# so your program will run at the correct speed. You should also set this 30# processor frequency in Hz. You can then use this symbol in your source code to
22# variable to same clock speed. The _delay_ms() macro uses this, and many 31# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
23# examples use this variable to calculate timings. Do not add a "UL" here. 32# automatically to create a 32-bit value in your source code.
33#
34# This will be an integer division of F_USB below, as it is sourced by
35# F_USB after it has run through any CPU prescalers. Note that this value
36# does not *change* the processor frequency - it should merely be updated to
37# reflect the processor speed set externally so that the code can use accurate
38# software delays.
24F_CPU = 16000000 39F_CPU = 16000000
25 40
26 41
27# Build Options
28# *Comment out* to disable the options.
29# 42#
30MOUSEKEY_ENABLE = yes # Mouse keys 43# LUFA specific
31EXTRAKEY_ENABLE = yes # Audio control and System control 44#
32NKRO_ENABLE = yes # USB Nkey Rollover 45# Target architecture (see library "Board Types" documentation).
46ARCH = AVR8
47
48# Input clock frequency.
49# This will define a symbol, F_USB, in all source code files equal to the
50# input clock frequency (before any prescaling is performed) in Hz. This value may
51# differ from F_CPU if prescaling is used on the latter, and is required as the
52# raw input clock is fed directly to the PLL sections of the AVR for high speed
53# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
54# at the end, this will be done automatically to create a 32-bit value in your
55# source code.
56#
57# If no clock division is performed on the input clock inside the AVR (via the
58# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
59F_USB = $(F_CPU)
33 60
34PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened) 61# Interrupt driven control endpoint task(+60)
35#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin 62OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
36#PS2_USE_BUSYWAIT = yes # uses primitive reference code
37 63
38 64
39# keyboard dependent files 65# Boot Section Size in *bytes*
40SRC = keymap.c \ 66# Teensy halfKay 512
41 matrix.c \ 67# Teensy++ halfKay 1024
42 led.c 68# Atmel DFU loader 4096
43 69# LUFA bootloader 4096
70# USBaspLoader 2048
71OPT_DEFS += -DBOOTLOADER_SIZE=4096
44 72
45ifdef PS2_USE_USART
46 SRC += protocol/ps2_usart.c
47 OPT_DEFS += -DPS2_USE_USART
48endif
49ifdef PS2_USE_INT
50 SRC += protocol/ps2.c
51 OPT_DEFS += -DPS2_USE_INT
52endif
53ifdef PS2_USE_BUSYWAIT
54 SRC += protocol/ps2.c
55 OPT_DEFS += -DPS2_USE_BUSYWAIT
56endif
57 73
74# Build Options
75# comment out to disable the options.
76#
77#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
78MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
79EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
80CONSOLE_ENABLE = yes # Console for debug(+400)
81COMMAND_ENABLE = yes # Commands for debug and configuration
82NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
58 83
59#CONFIG_H = config_pjrc_usart.h
60CONFIG_H = config.h
61 84
85# PS/2 Options
86#
87#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
88#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
89PS2_USE_BUSYWAIT = yes # uses primitive reference code
62 90
63#---------------- Programming Options --------------------------
64PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
65 91
92# Optimize size but this may cause error "relocation truncated to fit"
93#EXTRALDFLAGS = -Wl,--relax
66 94
67# Search Path 95# Search Path
68VPATH += $(TARGET_DIR) 96VPATH += $(TARGET_DIR)
69VPATH += $(TOP_DIR) 97VPATH += $(TOP_DIR)
70 98
71
72include $(TOP_DIR)/protocol/pjrc.mk
73include $(TOP_DIR)/protocol.mk 99include $(TOP_DIR)/protocol.mk
100include $(TOP_DIR)/protocol/lufa.mk
74include $(TOP_DIR)/common.mk 101include $(TOP_DIR)/common.mk
75include $(TOP_DIR)/rules.mk 102include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/Makefile.pjrc b/converter/ps2_usb/Makefile.pjrc
new file mode 100644
index 000000000..0e175f8b4
--- /dev/null
+++ b/converter/ps2_usb/Makefile.pjrc
@@ -0,0 +1,75 @@
1# Target file name (without extension).
2TARGET = ps2_usb_pjrc
3
4# Directory common source filess exist
5TOP_DIR = ../..
6
7# Directory keyboard dependent files exist
8TARGET_DIR = .
9
10# keyboard dependent files
11SRC = keymap_common.c \
12 matrix.c \
13 led.c
14
15ifdef KEYMAP
16 SRC := keymap_$(KEYMAP).c $(SRC)
17else
18 SRC := keymap_plain.c $(SRC)
19endif
20
21CONFIG_H = config.h
22
23
24# MCU name, you MUST set this to match the board you are using
25# type "make clean" after changing this, so all files will be rebuilt
26#MCU = at90usb162 # Teensy 1.0
27MCU = atmega32u4 # Teensy 2.0
28#MCU = at90usb646 # Teensy++ 1.0
29#MCU = at90usb1286 # Teensy++ 2.0
30
31
32# Processor frequency.
33# Normally the first thing your program should do is set the clock prescaler,
34# so your program will run at the correct speed. You should also set this
35# variable to same clock speed. The _delay_ms() macro uses this, and many
36# examples use this variable to calculate timings. Do not add a "UL" here.
37F_CPU = 16000000
38
39
40# Boot Section Size in *bytes*
41# Teensy halfKay 512
42# Teensy++ halfKay 1024
43# Atmel DFU loader 4096
44# LUFA bootloader 4096
45# USBaspLoader 2048
46OPT_DEFS += -DBOOTLOADER_SIZE=4096
47
48
49# Build Options
50# *Comment out* to disable the options.
51#
52#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
53MOUSEKEY_ENABLE = yes # Mouse keys
54EXTRAKEY_ENABLE = yes # Audio control and System control
55CONSOLE_ENABLE = yes # Console for debug(+400)
56COMMAND_ENABLE = yes # Commands for debug and configuration
57NKRO_ENABLE = yes # USB Nkey Rollover
58
59
60# PS/2 Options
61#
62#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
63#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
64PS2_USE_BUSYWAIT = yes # uses primitive reference code
65
66
67# Search Path
68VPATH += $(TARGET_DIR)
69VPATH += $(TOP_DIR)
70
71
72include $(TOP_DIR)/protocol.mk
73include $(TOP_DIR)/protocol/pjrc.mk
74include $(TOP_DIR)/common.mk
75include $(TOP_DIR)/rules.mk
diff --git a/converter/ps2_usb/config.h b/converter/ps2_usb/config.h
index 51cd271d7..c9bab1b07 100644
--- a/converter/ps2_usb/config.h
+++ b/converter/ps2_usb/config.h
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22 22
23#define VENDOR_ID 0xFEED 23#define VENDOR_ID 0xFEED
24#define PRODUCT_ID 0x6512 24#define PRODUCT_ID 0x6512
25#define DEVICE_VER 0x0001
25#define MANUFACTURER t.m.k. 26#define MANUFACTURER t.m.k.
26#define PRODUCT PS/2 keyboard converter 27#define PRODUCT PS/2 keyboard converter
27#define DESCRIPTION convert PS/2 keyboard to USB 28#define DESCRIPTION convert PS/2 keyboard to USB
@@ -39,10 +40,52 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
39) 40)
40 41
41 42
42/* legacy keymap support */ 43//#define NO_SUSPEND_POWER_DOWN
43#define USE_LEGACY_KEYMAP
44 44
45 45
46/*
47 * PS/2 Busywait
48 */
49#ifdef PS2_USE_BUSYWAIT
50#define PS2_CLOCK_PORT PORTD
51#define PS2_CLOCK_PIN PIND
52#define PS2_CLOCK_DDR DDRD
53#define PS2_CLOCK_BIT 5
54#define PS2_DATA_PORT PORTD
55#define PS2_DATA_PIN PIND
56#define PS2_DATA_DDR DDRD
57#define PS2_DATA_BIT 2
58#endif
59
60/*
61 * PS/2 Pin interrupt
62 */
63#ifdef PS2_USE_INT
64/* uses INT1 for clock line(ATMega32U4) */
65#define PS2_CLOCK_PORT PORTD
66#define PS2_CLOCK_PIN PIND
67#define PS2_CLOCK_DDR DDRD
68#define PS2_CLOCK_BIT 1
69#define PS2_DATA_PORT PORTD
70#define PS2_DATA_PIN PIND
71#define PS2_DATA_DDR DDRD
72#define PS2_DATA_BIT 2
73#define PS2_INT_INIT() do { \
74 EICRA |= ((1<<ISC11) | \
75 (0<<ISC10)); \
76} while (0)
77#define PS2_INT_ON() do { \
78 EIMSK |= (1<<INT1); \
79} while (0)
80#define PS2_INT_OFF() do { \
81 EIMSK &= ~(1<<INT1); \
82} while (0)
83#define PS2_INT_VECT INT1_vect
84#endif
85
86/*
87 * PS/2 USART
88 */
46#ifdef PS2_USE_USART 89#ifdef PS2_USE_USART
47#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) 90#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
48/* XCK for clock line and RXD for data line */ 91/* XCK for clock line and RXD for data line */
@@ -54,7 +97,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
54#define PS2_DATA_PIN PIND 97#define PS2_DATA_PIN PIND
55#define PS2_DATA_DDR DDRD 98#define PS2_DATA_DDR DDRD
56#define PS2_DATA_BIT 2 99#define PS2_DATA_BIT 2
57
58/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 100/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
59/* set DDR of CLOCK as input to be slave */ 101/* set DDR of CLOCK as input to be slave */
60#define PS2_USART_INIT() do { \ 102#define PS2_USART_INIT() do { \
@@ -85,7 +127,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
85#define PS2_USART_RX_DATA UDR1 127#define PS2_USART_RX_DATA UDR1
86#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1))) 128#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
87#define PS2_USART_RX_VECT USART1_RX_vect 129#define PS2_USART_RX_VECT USART1_RX_vect
88
89#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__) 130#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
90/* XCK for clock line and RXD for data line */ 131/* XCK for clock line and RXD for data line */
91#define PS2_CLOCK_PORT PORTD 132#define PS2_CLOCK_PORT PORTD
@@ -96,7 +137,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
96#define PS2_DATA_PIN PIND 137#define PS2_DATA_PIN PIND
97#define PS2_DATA_DDR DDRD 138#define PS2_DATA_DDR DDRD
98#define PS2_DATA_BIT 0 139#define PS2_DATA_BIT 0
99
100/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ 140/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
101/* set DDR of CLOCK as input to be slave */ 141/* set DDR of CLOCK as input to be slave */
102#define PS2_USART_INIT() do { \ 142#define PS2_USART_INIT() do { \
@@ -130,41 +170,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
130#endif 170#endif
131#endif 171#endif
132 172
133
134#ifdef PS2_USE_INT
135/* uses INT1 for clock line(ATMega32U4) */
136#define PS2_CLOCK_PORT PORTD
137#define PS2_CLOCK_PIN PIND
138#define PS2_CLOCK_DDR DDRD
139#define PS2_CLOCK_BIT 1
140#define PS2_DATA_PORT PORTD
141#define PS2_DATA_PIN PIND
142#define PS2_DATA_DDR DDRD
143#define PS2_DATA_BIT 2
144
145#define PS2_INT_INIT() do { \
146 EICRA |= ((1<<ISC11) | \
147 (0<<ISC10)); \
148} while (0)
149#define PS2_INT_ON() do { \
150 EIMSK |= (1<<INT1); \
151} while (0)
152#define PS2_INT_OFF() do { \
153 EIMSK &= ~(1<<INT1); \
154} while (0)
155#define PS2_INT_VECT INT1_vect
156#endif
157
158
159#ifdef PS2_USE_BUSYWAIT
160#define PS2_CLOCK_PORT PORTF
161#define PS2_CLOCK_PIN PINF
162#define PS2_CLOCK_DDR DDRF
163#define PS2_CLOCK_BIT 0
164#define PS2_DATA_PORT PORTF
165#define PS2_DATA_PIN PINF
166#define PS2_DATA_DDR DDRF
167#define PS2_DATA_BIT 1
168#endif
169
170#endif 173#endif
diff --git a/converter/ps2_usb/keymap.c b/converter/ps2_usb/keymap.c
deleted file mode 100644
index c97783fa5..000000000
--- a/converter/ps2_usb/keymap.c
+++ /dev/null
@@ -1,379 +0,0 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * Keymap for PS/2 keyboard
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <avr/pgmspace.h>
24#include "keycode.h"
25#include "print.h"
26#include "debug.h"
27#include "util.h"
28#include "keymap.h"
29
30
31
32
33// Following macros help you to define a keymap with the form of actual keyboard layout.
34
35/* US layout plus all other various keys */
36#define KEYMAP_ALL( \
37 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
38 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
39 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
40 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
41 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
42 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
43 \
44 K61, /* for European ISO */ \
45 K51, K13, K6A, K64, K67, /* for Japanese JIS */ \
46 K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \
47 KB7, KBF, KDE, /* System Power, Sleep, Wake */ \
48 KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \
49 KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \
50 KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \
51 K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \
52 KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \
53) { \
54 { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
55 { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \
56 { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
57 { KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \
58 { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
59 { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \
60 { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
61 { KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
62 { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
63 { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \
64 { KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \
65 { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \
66 { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
67 { KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \
68 { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
69 { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \
70 { KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \
71 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
72 { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \
73 { KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \
74 { KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \
75 { KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \
76 { KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \
77 { KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \
78 { KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
79 { KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \
80 { KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
81 { KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \
82 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
83 { KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \
84 { KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \
85 { KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \
86}
87
88/* US layout */
89#define KEYMAP( \
90 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
91 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
92 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
93 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
94 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
95 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
96) \
97KEYMAP_ALL( \
98 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
99 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
100 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
101 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
102 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
103 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
104 \
105 NUBS, \
106 RO, KANA, JYEN, HENK, MHEN, \
107 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
108 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
109 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
110 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
111 MAIL, CALCULATOR, MY_COMPUTER, \
112 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
113 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
114)
115
116/* ISO layout */
117#define KEYMAP_ISO( \
118 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
119 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
120 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
121 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \
122 K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
123 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
124) \
125KEYMAP_ALL( \
126 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
127 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
128 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
129 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
130 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
131 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
132 \
133 K61, \
134 RO, KANA, JYEN, HENK, MHEN, \
135 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
136 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
137 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
138 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
139 MAIL, CALCULATOR, MY_COMPUTER, \
140 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
141 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
142)
143
144/* JIS layout */
145#define KEYMAP_JIS( \
146 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
147 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
148 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
149 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
150 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
151 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
152) \
153KEYMAP_ALL( \
154 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
155 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
156 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
157 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
158 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
159 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
160 \
161 NUBS, \
162 K51, K13, K6A, K64, K67, \
163 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
164 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
165 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
166 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
167 MAIL, CALCULATOR, MY_COMPUTER, \
168 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
169 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
170)
171
172
173// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
174static const uint8_t PROGMEM fn_layer[] = {
175 5, // Fn0
176 6, // Fn1
177 0, // Fn2
178 0, // Fn3
179 0, // Fn4
180 0, // Fn5
181 0, // Fn6
182 0 // Fn7
183};
184
185// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
186// See layer.c for details.
187static const uint8_t PROGMEM fn_keycode[] = {
188 KC_SCLN, // Fn0
189 KC_SLSH, // Fn1
190 KC_NO, // Fn2
191 KC_NO, // Fn3
192 KC_NO, // Fn4
193 KC_NO, // Fn5
194 KC_NO, // Fn6
195 KC_NO // Fn7
196};
197
198
199// The keymap is a 32*8 byte array which convert a PS/2 scan code into a USB keycode.
200// See keycode.h for USB keycodes. You should omit a 'KC_' prefix of USB keycodes in keymap macro.
201// Use KEYMAP_ISO() or KEYMAP_JIS() instead of KEYMAP() if your keyboard is ISO or JIS.
202static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
203 /* 0: default
204 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
205 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak|
206 * `---' `---------------' `---------------' `---------------' `-----------' `-----------'
207 * ,-----------------------------------------------------------. ,-----------. ,---------------.
208 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -|
209 * |-----------------------------------------------------------| |-----------| |---------------|
210 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| |
211 * |-----------------------------------------------------------| `-----------' |-----------| +|
212 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| |
213 * |-----------------------------------------------------------| ,---. |---------------|
214 * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
215 * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
216 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| |
217 * `-----------------------------------------------------------' `-----------' `---------------'
218 * ; = Fn0(to Layer 5)
219 * / = Fn1(to Layer 6)
220 */
221 KEYMAP(
222 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
223 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
224 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
225 CAPS,A, S, D, F, G, H, J, K, L, FN0, QUOT, ENT, P4, P5, P6, PPLS,
226 LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, UP, P1, P2, P3,
227 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
228 ),
229
230 /* 1: plain Qwerty without layer switching
231 * ,-----------------------------------------------------------.
232 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
233 * |-----------------------------------------------------------|
234 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|
235 * |-----------------------------------------------------------|
236 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return |
237 * |-----------------------------------------------------------|
238 * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift |
239 * |-----------------------------------------------------------|
240 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
241 * `-----------------------------------------------------------'
242 */
243 KEYMAP(
244 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
245 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
246 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
247 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
248 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
249 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
250 ),
251
252 /* 2: Colemak http://colemak.com
253 * ,-----------------------------------------------------------.
254 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
255 * |-----------------------------------------------------------|
256 * |Tab | Q| W| F| P| G| J| L| U| Y| ;| [| ]| \|
257 * |-----------------------------------------------------------|
258 * |BackSp| A| R| S| T| D| H| N| E| I| O| '|Return |
259 * |-----------------------------------------------------------|
260 * |Shift | Z| X| C| V| B| K| M| ,| ,| /|Shift |
261 * |-----------------------------------------------------------|
262 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
263 * `----------------------------------------------------------'
264 */
265 KEYMAP(
266 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
267 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
268 TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
269 BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, P4, P5, P6, PPLS,
270 LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
271 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
272 ),
273
274 /* 3: Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
275 * ,-----------------------------------------------------------.
276 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa|
277 * |-----------------------------------------------------------|
278 * |Tab | '| ,| .| P| Y| F| G| C| R| L| /| =| \|
279 * |-----------------------------------------------------------|
280 * |BackSp| A| O| E| U| I| D| H| T| N| S| -|Return |
281 * |-----------------------------------------------------------|
282 * |Shift | ;| Q| J| K| X| B| M| Wl V| Z|Shift |
283 * |-----------------------------------------------------------|
284 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
285 * `-----------------------------------------------------------'
286 */
287 KEYMAP(
288 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
289 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
290 TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9,
291 CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, P4, P5, P6, PPLS,
292 LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, UP, P1, P2, P3,
293 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
294 ),
295
296 /* 4: Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/
297 * ,-----------------------------------------------------------.
298 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
299 * |-----------------------------------------------------------|
300 * |Tab | Q| D| R| W| B| J| F| U| P| ;| [| ]| \|
301 * |-----------------------------------------------------------|
302 * |CapsLo| A| S| H| T| G| Y| N| E| O| I| '|Return |
303 * |-----------------------------------------------------------|
304 * |Shift | Z| X| M| C| V| K| L| ,| ,| /|Shift |
305 * |-----------------------------------------------------------|
306 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
307 * `-----------------------------------------------------------'
308 */
309 KEYMAP(
310 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
311 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
312 TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
313 BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, P4, P5, P6, PPLS,
314 LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
315 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
316 ),
317
318 /* 5: Mouse keys
319 * ,-----------------------------------------------------------.
320 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
321 * |-----------------------------------------------------------|
322 * |Tab |MwL|MwU|McU|WwU|WwR|MwL|MwD|MwU|MwR| | | | \|
323 * |-----------------------------------------------------------|
324 * |CapsLo| |McL|McD|McR| |McL|McD|McU|McR|Fn0| |Return |
325 * |-----------------------------------------------------------|
326 * |Shift |VoD|VoU|Mut|Mb2|Mb3|Mb2|Mb1|VoD|VoU|Mut|Shift |
327 * |-----------------------------------------------------------|
328 * |Ctrl |Gui |Alt | Mb1 |Alt |Gui |Menu|Ctrl|
329 * `-----------------------------------------------------------'
330 * Mc = mouse cursor, Mw = mouse wheel, Mb = mouse button
331 * Vo = Volume, Mut = Mute
332 */
333 KEYMAP(
334 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
335 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
336 TAB, WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9,
337 CAPS,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, P4, P5, P6, PPLS,
338 LSFT,VOLD,VOLU,MUTE,BTN2,BTN3,BTN2,BTN1,VOLD,VOLU,MUTE, RSFT, UP, P1, P2, P3,
339 LCTL,LGUI,LALT, BTN1, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
340 ),
341
342 /* 6: Cursor keys
343 * ,-----------------------------------------------------------.
344 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
345 * |-----------------------------------------------------------|
346 * |Tab |Hom|PgU| Up|PgU|End|Hom|PgD|PgU|End| | | | \|
347 * |-----------------------------------------------------------|
348 * |CapsLo| |Lef|Dow|Rig| |Lef|Dow| Up|Rig| | |Return |
349 * |-----------------------------------------------------------|
350 * |Shift | | | | | |Hom|PgD|PgU|End|Fn1|Shift |
351 * |-----------------------------------------------------------|
352 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
353 * `-----------------------------------------------------------'
354 */
355 KEYMAP(
356 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
357 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
358 TAB, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9,
359 CAPS,NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS,
360 LSFT,VOLD,VOLU,MUTE,NO, NO, HOME,PGDN,PGUP,END, FN1, RSFT, UP, P1, P2, P3,
361 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
362 ),
363};
364
365
366uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
367{
368 return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
369}
370
371uint8_t keymap_fn_layer(uint8_t index)
372{
373 return pgm_read_byte(&fn_layer[index]);
374}
375
376uint8_t keymap_fn_keycode(uint8_t index)
377{
378 return pgm_read_byte(&fn_keycode[index]);
379}
diff --git a/converter/ps2_usb/keymap_common.c b/converter/ps2_usb/keymap_common.c
new file mode 100644
index 000000000..241d2e33b
--- /dev/null
+++ b/converter/ps2_usb/keymap_common.c
@@ -0,0 +1,30 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "keymap_common.h"
18
19
20/* translates key to keycode */
21uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
22{
23 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
24}
25
26/* translates Fn keycode to action */
27action_t keymap_fn_to_action(uint8_t keycode)
28{
29 return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
30}
diff --git a/converter/ps2_usb/keymap_common.h b/converter/ps2_usb/keymap_common.h
new file mode 100644
index 000000000..216a8dc02
--- /dev/null
+++ b/converter/ps2_usb/keymap_common.h
@@ -0,0 +1,174 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#ifndef KEYMAP_COMMON_H
18#define KEYMAP_COMMON_H
19
20#include <stdint.h>
21#include <stdbool.h>
22#include <avr/pgmspace.h>
23#include "keycode.h"
24#include "action.h"
25#include "action_macro.h"
26#include "report.h"
27#include "print.h"
28#include "debug.h"
29#include "keymap.h"
30
31
32// 32*8(256) byte array which converts PS/2 code into USB code
33extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
34extern const uint16_t fn_actions[];
35
36
37/* All keys */
38#define KEYMAP_ALL( \
39 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
40 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
41 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
42 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
43 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
44 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
45 \
46 K61, /* for European ISO */ \
47 K51, K13, K6A, K64, K67, /* for Japanese JIS */ \
48 K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \
49 KB7, KBF, KDE, /* System Power, Sleep, Wake */ \
50 KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \
51 KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \
52 KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \
53 K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \
54 KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \
55) { \
56 { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
57 { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \
58 { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \
59 { KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \
60 { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \
61 { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \
62 { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \
63 { KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \
64 { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \
65 { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \
66 { KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \
67 { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \
68 { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \
69 { KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \
70 { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
71 { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \
72 { KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \
73 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
74 { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \
75 { KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \
76 { KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \
77 { KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \
78 { KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \
79 { KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \
80 { KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
81 { KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \
82 { KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
83 { KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \
84 { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \
85 { KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \
86 { KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \
87 { KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \
88}
89
90/* US layout */
91#define KEYMAP( \
92 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
93 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
94 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
95 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
96 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
97 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
98) \
99KEYMAP_ALL( \
100 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
101 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
102 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
103 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
104 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
105 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
106 \
107 NUBS, \
108 RO, KANA, JYEN, HENK, MHEN, \
109 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
110 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
111 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
112 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
113 MAIL, CALCULATOR, MY_COMPUTER, \
114 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
115 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
116)
117
118/* ISO layout */
119#define KEYMAP_ISO( \
120 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
121 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
122 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
123 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \
124 K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
125 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
126) \
127KEYMAP_ALL( \
128 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
129 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
130 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
131 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
132 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
133 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
134 \
135 K61, \
136 RO, KANA, JYEN, HENK, MHEN, \
137 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
138 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
139 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
140 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
141 MAIL, CALCULATOR, MY_COMPUTER, \
142 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
143 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
144)
145
146/* JIS layout */
147#define KEYMAP_JIS( \
148 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
149 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
150 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
151 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
152 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
153 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \
154) \
155KEYMAP_ALL( \
156 K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \
157 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
158 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \
159 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \
160 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \
161 K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \
162 \
163 NUBS, \
164 K51, K13, K6A, K64, K67, \
165 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
166 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
167 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
168 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
169 MAIL, CALCULATOR, MY_COMPUTER, \
170 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
171 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
172)
173
174#endif
diff --git a/converter/ps2_usb/keymap_plain.c b/converter/ps2_usb/keymap_plain.c
new file mode 100644
index 000000000..9c6e7d9ff
--- /dev/null
+++ b/converter/ps2_usb/keymap_plain.c
@@ -0,0 +1,50 @@
1/*
2Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17#include "keymap_common.h"
18
19
20const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
21 /* 0: default
22 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
23 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak|
24 * `---' `---------------' `---------------' `---------------' `-----------' `-----------'
25 * ,-----------------------------------------------------------. ,-----------. ,---------------.
26 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -|
27 * |-----------------------------------------------------------| |-----------| |---------------|
28 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| |
29 * |-----------------------------------------------------------| `-----------' |-----------| +|
30 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| |
31 * |-----------------------------------------------------------| ,---. |---------------|
32 * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
33 * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
34 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| |
35 * `-----------------------------------------------------------' `-----------' `---------------'
36 * ; = Fn0(to Layer 5)
37 * / = Fn1(to Layer 6)
38 */
39 KEYMAP(
40 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
41 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
42 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
43 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS,
44 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
45 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
46 ),
47};
48
49const uint16_t PROGMEM fn_actions[] = {
50};
diff --git a/converter/ps2_usb/matrix.c b/converter/ps2_usb/matrix.c
index 4187ea060..45344c0f7 100644
--- a/converter/ps2_usb/matrix.c
+++ b/converter/ps2_usb/matrix.c
@@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#include <stdbool.h> 19#include <stdbool.h>
20#include <avr/io.h> 20#include <avr/io.h>
21#include <util/delay.h> 21#include <util/delay.h>
22#include "action.h"
22#include "print.h" 23#include "print.h"
23#include "util.h" 24#include "util.h"
24#include "debug.h" 25#include "debug.h"
@@ -28,6 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28 29
29static void matrix_make(uint8_t code); 30static void matrix_make(uint8_t code);
30static void matrix_break(uint8_t code); 31static void matrix_break(uint8_t code);
32static void matrix_clear(void);
31#ifdef MATRIX_HAS_GHOST 33#ifdef MATRIX_HAS_GHOST
32static bool matrix_has_ghost_in_row(uint8_t row); 34static bool matrix_has_ghost_in_row(uint8_t row);
33#endif 35#endif
@@ -83,6 +85,7 @@ uint8_t matrix_cols(void)
83 85
84void matrix_init(void) 86void matrix_init(void)
85{ 87{
88 debug_enable = true;
86 ps2_host_init(); 89 ps2_host_init();
87 90
88 // initialize matrix state: all keys off 91 // initialize matrix state: all keys off
@@ -185,8 +188,8 @@ uint8_t matrix_scan(void)
185 matrix_break(PAUSE); 188 matrix_break(PAUSE);
186 } 189 }
187 190
188 uint8_t code; 191 uint8_t code = ps2_host_recv();
189 while ((code = ps2_host_recv())) { 192 if (!ps2_error) {
190 switch (state) { 193 switch (state) {
191 case INIT: 194 case INIT:
192 switch (code) { 195 switch (code) {
@@ -207,11 +210,19 @@ uint8_t matrix_scan(void)
207 matrix_make(PRINT_SCREEN); 210 matrix_make(PRINT_SCREEN);
208 state = INIT; 211 state = INIT;
209 break; 212 break;
213 case 0x00: // Overrun [3]p.25
214 matrix_clear();
215 clear_keyboard();
216 print("Overrun\n");
217 state = INIT;
218 break;
210 default: // normal key make 219 default: // normal key make
211 if (code < 0x80) { 220 if (code < 0x80) {
212 matrix_make(code); 221 matrix_make(code);
213 } else { 222 } else {
214 debug("unexpected scan code at INIT: "); debug_hex(code); debug("\n"); 223 matrix_clear();
224 clear_keyboard();
225 xprintf("unexpected scan code at INIT: %02X\n", code);
215 } 226 }
216 state = INIT; 227 state = INIT;
217 } 228 }
@@ -232,7 +243,9 @@ uint8_t matrix_scan(void)
232 if (code < 0x80) { 243 if (code < 0x80) {
233 matrix_make(code|0x80); 244 matrix_make(code|0x80);
234 } else { 245 } else {
235 debug("unexpected scan code at E0: "); debug_hex(code); debug("\n"); 246 matrix_clear();
247 clear_keyboard();
248 xprintf("unexpected scan code at E0: %02X\n", code);
236 } 249 }
237 state = INIT; 250 state = INIT;
238 } 251 }
@@ -247,11 +260,18 @@ uint8_t matrix_scan(void)
247 matrix_break(PRINT_SCREEN); 260 matrix_break(PRINT_SCREEN);
248 state = INIT; 261 state = INIT;
249 break; 262 break;
263 case 0xF0:
264 matrix_clear();
265 clear_keyboard();
266 xprintf("unexpected scan code at F0: F0(clear and cont.)\n");
267 break;
250 default: 268 default:
251 if (code < 0x80) { 269 if (code < 0x80) {
252 matrix_break(code); 270 matrix_break(code);
253 } else { 271 } else {
254 debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); 272 matrix_clear();
273 clear_keyboard();
274 xprintf("unexpected scan code at F0: %02X\n", code);
255 } 275 }
256 state = INIT; 276 state = INIT;
257 } 277 }
@@ -266,7 +286,9 @@ uint8_t matrix_scan(void)
266 if (code < 0x80) { 286 if (code < 0x80) {
267 matrix_break(code|0x80); 287 matrix_break(code|0x80);
268 } else { 288 } else {
269 debug("unexpected scan code at E0_F0: "); debug_hex(code); debug("\n"); 289 matrix_clear();
290 clear_keyboard();
291 xprintf("unexpected scan code at E0_F0: %02X\n", code);
270 } 292 }
271 state = INIT; 293 state = INIT;
272 } 294 }
@@ -357,8 +379,15 @@ uint8_t matrix_scan(void)
357 default: 379 default:
358 state = INIT; 380 state = INIT;
359 } 381 }
360 phex(code);
361 } 382 }
383
384 // TODO: request RESEND when error occurs?
385/*
386 if (PS2_IS_FAILED(ps2_error)) {
387 uint8_t ret = ps2_host_send(PS2_RESEND);
388 xprintf("Resend: %02X\n", ret);
389 }
390*/
362 return 1; 391 return 1;
363} 392}
364 393
@@ -450,3 +479,9 @@ static void matrix_break(uint8_t code)
450 is_modified = true; 479 is_modified = true;
451 } 480 }
452} 481}
482
483inline
484static void matrix_clear(void)
485{
486 for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
487}