aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortmk <nobody@nowhere>2012-10-14 20:03:26 +0900
committertmk <nobody@nowhere>2012-10-14 20:06:50 +0900
commit1ac674db66e47e69b87c4c78566932ab73225836 (patch)
treed4005c76a5c2f5ec06c5a74a27460a764c9589d6
parent9f05dc6f444e159af3805baf5117be4d0da2d349 (diff)
downloadqmk_firmware-1ac674db66e47e69b87c4c78566932ab73225836.tar.gz
qmk_firmware-1ac674db66e47e69b87c4c78566932ab73225836.zip
Fix PS/2 protocol build options
-rw-r--r--converter/ps2_usb/Makefile42
-rw-r--r--converter/ps2_usb/Makefile.jis (renamed from converter/ps2_usb/Makefile.pjrc_usart)42
-rw-r--r--converter/ps2_usb/Makefile.vusb16
-rw-r--r--converter/ps2_usb/README116
-rw-r--r--converter/ps2_usb/README.vusb37
-rw-r--r--converter/ps2_usb/config.h (renamed from converter/ps2_usb/config_vusb.h)107
-rw-r--r--converter/ps2_usb/config_pjrc.h59
-rw-r--r--converter/ps2_usb/config_pjrc_usart.h91
-rw-r--r--converter/ps2_usb/keymap_jis.c297
-rw-r--r--converter/ps2_usb/usbconfig.h1
-rw-r--r--protocol/ps2.c15
11 files changed, 503 insertions, 320 deletions
diff --git a/converter/ps2_usb/Makefile b/converter/ps2_usb/Makefile
index 1278a74be..0c6442374 100644
--- a/converter/ps2_usb/Makefile
+++ b/converter/ps2_usb/Makefile
@@ -1,10 +1,5 @@
1#
2# Makefile for PJRC Teensy
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_pjrc 2TARGET = ps2_usb
8 3
9# Directory common source filess exist 4# Directory common source filess exist
10TOP_DIR = ../.. 5TOP_DIR = ../..
@@ -12,14 +7,6 @@ TOP_DIR = ../..
12# Directory keyboard dependent files exist 7# Directory keyboard dependent files exist
13TARGET_DIR = . 8TARGET_DIR = .
14 9
15# keyboard dependent files
16SRC = keymap.c \
17 matrix.c \
18 led.c \
19 ps2.c
20
21CONFIG_H = config_pjrc.h
22
23 10
24# MCU name, you MUST set this to match the board you are using 11# 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 12# type "make clean" after changing this, so all files will be rebuilt
@@ -44,6 +31,33 @@ MOUSEKEY_ENABLE = yes # Mouse keys
44EXTRAKEY_ENABLE = yes # Audio control and System control 31EXTRAKEY_ENABLE = yes # Audio control and System control
45NKRO_ENABLE = yes # USB Nkey Rollover 32NKRO_ENABLE = yes # USB Nkey Rollover
46 33
34PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
35#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
36#PS2_USE_BUSYWAIT = yes # uses primitive reference code
37
38
39# keyboard dependent files
40SRC = keymap.c \
41 matrix.c \
42 led.c
43
44
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
58
59#CONFIG_H = config_pjrc_usart.h
60CONFIG_H = config.h
47 61
48 62
49#---------------- Programming Options -------------------------- 63#---------------- Programming Options --------------------------
diff --git a/converter/ps2_usb/Makefile.pjrc_usart b/converter/ps2_usb/Makefile.jis
index dd74712e4..4e091e8e2 100644
--- a/converter/ps2_usb/Makefile.pjrc_usart
+++ b/converter/ps2_usb/Makefile.jis
@@ -1,10 +1,5 @@
1#
2# Makefile for PJRC Teensy
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_pjrc_usart 2TARGET = ps2_usb_jis
8 3
9# Directory common source filess exist 4# Directory common source filess exist
10TOP_DIR = ../.. 5TOP_DIR = ../..
@@ -12,14 +7,6 @@ TOP_DIR = ../..
12# Directory keyboard dependent files exist 7# Directory keyboard dependent files exist
13TARGET_DIR = . 8TARGET_DIR = .
14 9
15# keyboard dependent files
16SRC = keymap.c \
17 matrix.c \
18 led.c \
19 ps2_usart.c
20
21CONFIG_H = config_pjrc_usart.h
22
23 10
24# MCU name, you MUST set this to match the board you are using 11# 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 12# type "make clean" after changing this, so all files will be rebuilt
@@ -44,6 +31,33 @@ MOUSEKEY_ENABLE = yes # Mouse keys
44EXTRAKEY_ENABLE = yes # Audio control and System control 31EXTRAKEY_ENABLE = yes # Audio control and System control
45NKRO_ENABLE = yes # USB Nkey Rollover 32NKRO_ENABLE = yes # USB Nkey Rollover
46 33
34#PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomened)
35#PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin
36PS2_USE_BUSYWAIT = yes # uses primitive reference code
37
38
39# keyboard dependent files
40SRC = keymap_jis.c \
41 matrix.c \
42 led.c
43
44
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
58
59#CONFIG_H = config_pjrc_usart.h
60CONFIG_H = config.h
47 61
48 62
49#---------------- Programming Options -------------------------- 63#---------------- Programming Options --------------------------
diff --git a/converter/ps2_usb/Makefile.vusb b/converter/ps2_usb/Makefile.vusb
index b08d30d57..d449e1e40 100644
--- a/converter/ps2_usb/Makefile.vusb
+++ b/converter/ps2_usb/Makefile.vusb
@@ -1,8 +1,3 @@
1#
2# Makefile for V-USB
3#
4
5
6# Target file name (without extension). 1# Target file name (without extension).
7TARGET = ps2_usb_vusb 2TARGET = ps2_usb_vusb
8 3
@@ -15,15 +10,18 @@ TARGET_DIR = .
15# keyboard dependent files 10# keyboard dependent files
16SRC = keymap.c \ 11SRC = keymap.c \
17 matrix.c \ 12 matrix.c \
18 led.c \ 13 led.c
19 ps2_usart.c 14
15# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful.
16SRC += protocol/ps2_usart.c
17OPT_DEFS += -DPS2_USE_USART
20 18
21CONFIG_H = config_vusb.h 19CONFIG_H = config.h
22 20
23 21
24# V-USB debug level: To use ps2_usart.c level must be 0 22# V-USB debug level: To use ps2_usart.c level must be 0
25# ps2_usart.c requires USART to receive PS/2 signal. 23# ps2_usart.c requires USART to receive PS/2 signal.
26OPT_DEFS = -DDEBUG_LEVEL=0 24OPT_DEFS += -DDEBUG_LEVEL=0
27 25
28 26
29# MCU name, you MUST set this to match the board you are using 27# MCU name, you MUST set this to match the board you are using
diff --git a/converter/ps2_usb/README b/converter/ps2_usb/README
index c10393e5e..cb7ba5555 100644
--- a/converter/ps2_usb/README
+++ b/converter/ps2_usb/README
@@ -1,7 +1,7 @@
1PS/2 to USB keyboard converter 1PS/2 to USB keyboard converter
2============================== 2==============================
3This firmware converts PS/2 keyboard protocol to USB and for now supports only Scan Code Set 2. 3This firmware converts PS/2 keyboard protocol to USB and supports only Scan Code Set 2.
4This will works on USB AVR(ATMega32U4, AT90USB) or V-USB. 4This will works on USB AVR(ATMega32U4, AT90USB) or V-USB(ATMega168, 328...).
5 5
6 6
7Features 7Features
@@ -19,25 +19,29 @@ Keymap customization
19PS/2 signal handling implementations 19PS/2 signal handling implementations
20------------------------------------ 20------------------------------------
21Following three methods are used to implement PS/2 signal handling. 21Following three methods are used to implement PS/2 signal handling.
22a. Simple and stupid wait & read loop(intensive use of cycles) 22a. Simple and stupid busy-wait(ps2.c)
23 This is implemented with (expected) portable C code for reference. See ps2.c. 23 This is expected to implemented with portable C code for reference.
24b. Interrupt driven 24b. Interrupt driven(ps2.c)
25 See ps2_intr.c 25 Uses external interrupt to detect falling edge of clock line.
26c. Using USART hardware module(no cycle needed) 26c. USART hardware module(ps2_usart.c)
27 This uses AVR USART function to recevie PS/2 signal and be used in V-USB converter. 27 Uses AVR USART engine to recevie PS/2 signal. Recomended and default.
28 See ps2_usart.c. 28 This is required to work with V-USB, preceding two methods tend to
29 29 miss signal edges while V-USB handles USB.
30 30
31Build Converter 31To select method edit Makefile.
32--------------- 32
33Connect PS/2 keyboard into Teensy with 4 lines(Vcc, GND, Data, Clock). 33
34For a. Simple and stupid and b. Interrupt implementaion: 34Connect Wires
35 By default Clock is on PF0 and Data on PF1. 35-------------
36 You can change this pin configuration by editing config_pjrc.h. 36In case of Teensy2.0(ATMega32U4):
37 In this photo Vcc is yellow, GND is green, Data is red and Clock is black. 370. Connect Vcc and GND.
38 http://img17.imageshack.us/img17/7243/201101181933.jpg 381. Connect Clock and Data line.
39For c. USART implementation: 39 For a. Clock is on PF0 and Data on PF1.
40 In case of Teensny(ATMega32u4) CLock is on PD5 and Data on PD2. 40 For b. Clock is on PD1 and Data on PD2.
41 For c. Clock is on PD5 and Data on PD2.
422. Optionally you need pull-up register. 1K-10K Ohm is OK.
43
44To change pin configuration edit config.h.
41 45
42 46
43Build Frimware 47Build Frimware
@@ -45,12 +49,12 @@ Build Frimware
451. Edit Makefile for build options and MCU setting. 491. Edit Makefile for build options and MCU setting.
46 Use 'atmega32u4' for Teensy 2.0 or 'at90usb1286' for Teensy++ 2.0. 50 Use 'atmega32u4' for Teensy 2.0 or 'at90usb1286' for Teensy++ 2.0.
472. make 512. make
48 Just type 'make' in a terminal. 52 Just type `make` in a terminal.
49 Use '-f Makefile.pjrc_intr' option to use b. Interrupt. 53 Use `-f Makefile.vusb` option to build V-USB converter.
50 Use '-f Makefile.pjrc_usart' option to use c. USART. 54 Use `-f Makefile.jis` option to use JIS keyboard.
51 Use '-f Makefile.vusb' option to build V-USB converter. 553. program MCU.
523. program with Teensy Loader. 56 In case of Teensy use `Teensy Loader`.(http://www.pjrc.com/teensy/loader.html)
53 http://www.pjrc.com/teensy/loader.html 57 Otherwise you want to use `avrdude` or `dfu-programmer`.
54 58
55 59
56Demonstration of Features 60Demonstration of Features
@@ -83,34 +87,36 @@ Fn layer function:
83 87
84Keymap 88Keymap
85------ 89------
86You can change a keymap by editing code of keymap.c like following. 90You can change a keymap by editing code of keymap. See common/keycode.h for key symbols.
87How to define the keymap is probably obvious. You can find key symbols in usb_keycodes.h. 91
88To define keymap layer switching may needs a bit of your effort at this time. 92
89 93V-USB Support
90 /* Default Layer: plain keymap 94-------------
91 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. 95You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
92 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| 96The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
93 * `---' `---------------' `---------------' `---------------' `-----------' `-----------' 97
94 * ,-----------------------------------------------------------. ,-----------. ,---------------. 98Circuit
95 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| 99-------
96 * |-----------------------------------------------------------| |-----------| |---------------| 100 +---+ +---------------+
97 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | 101USB GND | | ATmega168 |
98 * |-----------------------------------------------------------| `-----------' |-----------| +| 102=== C3 | |
99 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | 1035V <-------+--------+---|Vcc,AVCC | PS/2
100 * |-----------------------------------------------------------| ,---. |---------------| 104 R1 | | ====
101 * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | 105D- <----+--+-----R2-----|INT1 RXD|------->DATA
102 * |-----------------------------------------------------------| ,-----------. |-----------|Ent| 106D+ <----|---+----R3-----|INT0 XCK|------->CLOCK
103 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | 107 Z1 Z2 | | ->5V
104 * `-----------------------------------------------------------' `-----------' `---------------' 108GND<----+---+--+--+-----|GND | ->GND
105 */ 109 | | | |
106 KEYMAP( 110 | C2-+--|XTAL1 |
107 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, PWR, F13, F14, 111 | X1 | |
108 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, 112 +--C3-+--|XTAL2 |
109 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, 113 +---------------+
110 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, 114R1: 1.5K Ohm
111 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, 115R2,R3: 68 Ohm
112 LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT 116Z1,Z2: Zenner 3.6V
113 ), 117C1,C2: 22pF
118C3: 0.1uF
119X1: Crystal 20MHz(16MHz/12MHz)
114 120
115 121
116EOF 122EOF
diff --git a/converter/ps2_usb/README.vusb b/converter/ps2_usb/README.vusb
deleted file mode 100644
index c92871bcd..000000000
--- a/converter/ps2_usb/README.vusb
+++ /dev/null
@@ -1,37 +0,0 @@
1V-USB Support
2=============
3You can also use this converter on ATmega(168/328) with V-USB instead of Teensy.
4The converter on V-USB lacks some features for now: USB NKRO and System/Media control.
5
6To build a firmware use Makefile.vusb instead of Makefile.
7
8
9Circuit
10-------
11 +---+ +---------------+
12USB GND | | ATmega168 |
13=== C3 | |
145V <-------+--------+---|Vcc,AVCC | PS/2
15 R1 | | ====
16D- <----+--+-----R2-----|INT1 RXD|------->DATA
17D+ <----|---+----R3-----|INT0 XCK|------->CLOCK
18 Z1 Z2 | | ->5V
19GND<----+---+--+--+-----|GND | ->GND
20 | | | |
21 | C2-+--|XTAL1 |
22 | X1 | |
23 +--C3-+--|XTAL2 |
24 +---------------+
25R1: 1.5K Ohm
26R2,R3: 68 Ohm
27Z1,Z2: Zenner 3.6V
28C1,C2: 22pF
29C3: 0.1uF
30X1: Crystal 20MHz(16MHz/12MHz)
31
32
33This is my V-USB converter on breadboard.
34[IMG]http://i.imgur.com/8jJCZl.jpg[/IMG]
35
36
37EOF
diff --git a/converter/ps2_usb/config_vusb.h b/converter/ps2_usb/config.h
index afd2f7911..e5d37e429 100644
--- a/converter/ps2_usb/config_vusb.h
+++ b/converter/ps2_usb/config.h
@@ -1,5 +1,5 @@
1/* 1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com> 2Copyright 2012 Jun Wako <wakojun@gmail.com>
3 3
4This program is free software: you can redistribute it and/or modify 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 5it under the terms of the GNU General Public License as published by
@@ -18,11 +18,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
18#ifndef CONFIG_H 18#ifndef CONFIG_H
19#define CONFIG_H 19#define CONFIG_H
20 20
21#include <avr/interrupt.h>
22/* controller configuration */
23#include "controller_teensy.h"
21 24
22#define VENDOR_ID 0xFEED 25#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x2233 26#define PRODUCT_ID 0x6512
24// TODO: share these strings with usbconfig.h
25// Edit usbconfig.h to change these.
26#define MANUFACTURER t.m.k. 27#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter 28#define PRODUCT PS/2 keyboard converter
28#define DESCRIPTION convert PS/2 keyboard to USB 29#define DESCRIPTION convert PS/2 keyboard to USB
@@ -46,30 +47,62 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
46#endif 47#endif
47 48
48 49
49/* PS/2 lines */ 50#ifdef PS2_USE_USART
51#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)
52/* XCK for clock line and RXD for data line */
50#define PS2_CLOCK_PORT PORTD 53#define PS2_CLOCK_PORT PORTD
51#define PS2_CLOCK_PIN PIND 54#define PS2_CLOCK_PIN PIND
52#define PS2_CLOCK_DDR DDRD 55#define PS2_CLOCK_DDR DDRD
53#define PS2_CLOCK_BIT 4 56#define PS2_CLOCK_BIT 5
54#define PS2_DATA_PORT PORTD 57#define PS2_DATA_PORT PORTD
55#define PS2_DATA_PIN PIND 58#define PS2_DATA_PIN PIND
56#define PS2_DATA_DDR DDRD 59#define PS2_DATA_DDR DDRD
57#define PS2_DATA_BIT 0 60#define PS2_DATA_BIT 2
58 61
62/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
63/* set DDR of CLOCK as input to be slave */
64#define PS2_USART_INIT() do { \
65 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
66 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
67 UCSR1C = ((1 << UMSEL10) | \
68 (3 << UPM10) | \
69 (0 << USBS1) | \
70 (3 << UCSZ10) | \
71 (0 << UCPOL1)); \
72 UCSR1A = 0; \
73 UBRR1H = 0; \
74 UBRR1L = 0; \
75} while (0)
76#define PS2_USART_RX_INT_ON() do { \
77 UCSR1B = ((1 << RXCIE1) | \
78 (1 << RXEN1)); \
79} while (0)
80#define PS2_USART_RX_POLL_ON() do { \
81 UCSR1B = (1 << RXEN1); \
82} while (0)
83#define PS2_USART_OFF() do { \
84 UCSR1C = 0; \
85 UCSR1B &= ~((1 << RXEN1) | \
86 (1 << TXEN1)); \
87} while (0)
88#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
89#define PS2_USART_RX_DATA UDR1
90#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
91#define PS2_USART_RX_VECT USART1_RX_vect
59 92
60// Synchronous USART is used to receive data from keyboard. 93#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
61// Use RXD pin for PS/2 DATA line and XCK for PS/2 CLOCK. 94/* XCK for clock line and RXD for data line */
62// NOTE: This is recomended strongly if you use V-USB library. 95#define PS2_CLOCK_PORT PORTD
63#define PS2_USE_USART 96#define PS2_CLOCK_PIN PIND
64 97#define PS2_CLOCK_DDR DDRD
65// External or Pin Change Interrupt is used to receive data from keyboard. 98#define PS2_CLOCK_BIT 4
66// Use INT1 or PCINTxx for PS/2 CLOCK line. see below. 99#define PS2_DATA_PORT PORTD
67//#define PS2_USE_INT 100#define PS2_DATA_PIN PIND
68 101#define PS2_DATA_DDR DDRD
102#define PS2_DATA_BIT 0
69 103
70#ifdef PS2_USE_USART 104/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */
71// synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge 105/* set DDR of CLOCK as input to be slave */
72// set DDR of CLOCK as input to be slave
73#define PS2_USART_INIT() do { \ 106#define PS2_USART_INIT() do { \
74 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \ 107 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
75 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \ 108 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
@@ -99,10 +132,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
99#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0))) 132#define PS2_USART_ERROR (UCSR0A & ((1<<FE0) | (1<<DOR0) | (1<<UPE0)))
100#define PS2_USART_RX_VECT USART_RX_vect 133#define PS2_USART_RX_VECT USART_RX_vect
101#endif 134#endif
135#endif
102 136
103 137
104#ifdef PS2_USE_INT 138#ifdef PS2_USE_INT
105/* INT1 139/* uses INT1 for clock line(ATMega32U4) */
140#define PS2_CLOCK_PORT PORTD
141#define PS2_CLOCK_PIN PIND
142#define PS2_CLOCK_DDR DDRD
143#define PS2_CLOCK_BIT 1
144#define PS2_DATA_PORT PORTD
145#define PS2_DATA_PIN PIND
146#define PS2_DATA_DDR DDRD
147#define PS2_DATA_BIT 2
148
106#define PS2_INT_INIT() do { \ 149#define PS2_INT_INIT() do { \
107 EICRA |= ((1<<ISC11) | \ 150 EICRA |= ((1<<ISC11) | \
108 (0<<ISC10)); \ 151 (0<<ISC10)); \
@@ -114,20 +157,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
114 EIMSK &= ~(1<<INT1); \ 157 EIMSK &= ~(1<<INT1); \
115} while (0) 158} while (0)
116#define PS2_INT_VECT INT1_vect 159#define PS2_INT_VECT INT1_vect
117*/ 160#endif
118 161
119/* PCINT20 */ 162
120#define PS2_INT_INIT() do { \ 163#ifdef PS2_USE_BUSYWAIT
121 PCICR |= (1<<PCIE2); \ 164#define PS2_CLOCK_PORT PORTF
122} while (0) 165#define PS2_CLOCK_PIN PINF
123#define PS2_INT_ON() do { \ 166#define PS2_CLOCK_DDR DDRF
124 PCMSK2 |= (1<<PCINT20); \ 167#define PS2_CLOCK_BIT 0
125} while (0) 168#define PS2_DATA_PORT PORTF
126#define PS2_INT_OFF() do { \ 169#define PS2_DATA_PIN PINF
127 PCMSK2 &= ~(1<<PCINT20); \ 170#define PS2_DATA_DDR DDRF
128 PCICR &= ~(1<<PCIE2); \ 171#define PS2_DATA_BIT 1
129} while (0)
130#define PS2_INT_VECT PCINT2_vect
131#endif 172#endif
132 173
133#endif 174#endif
diff --git a/converter/ps2_usb/config_pjrc.h b/converter/ps2_usb/config_pjrc.h
deleted file mode 100644
index 883ffab27..000000000
--- a/converter/ps2_usb/config_pjrc.h
+++ /dev/null
@@ -1,59 +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#ifndef CONFIG_H
19#define CONFIG_H
20
21/* controller configuration */
22#include "controller_teensy.h"
23
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6512
26#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter
28#define DESCRIPTION convert PS/2 keyboard to USB
29
30
31/* matrix size */
32#define MATRIX_ROWS 32 // keycode bit: 3-0
33#define MATRIX_COLS 8 // keycode bit: 6-4
34
35
36/* key combination for command */
37#define IS_COMMAND() ( \
38 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) || \
39 keyboard_report->mods == (MOD_BIT(KB_LCTRL) | MOD_BIT(KB_RSHIFT)) \
40)
41
42
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48
49/* PS/2 lines */
50#define PS2_CLOCK_PORT PORTF
51#define PS2_CLOCK_PIN PINF
52#define PS2_CLOCK_DDR DDRF
53#define PS2_CLOCK_BIT 0
54#define PS2_DATA_PORT PORTF
55#define PS2_DATA_PIN PINF
56#define PS2_DATA_DDR DDRF
57#define PS2_DATA_BIT 1
58
59#endif
diff --git a/converter/ps2_usb/config_pjrc_usart.h b/converter/ps2_usb/config_pjrc_usart.h
deleted file mode 100644
index 83ddbf770..000000000
--- a/converter/ps2_usb/config_pjrc_usart.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2Copyright 2012 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#ifndef CONFIG_H
19#define CONFIG_H
20
21/* controller configuration */
22#include "controller_teensy.h"
23
24#define VENDOR_ID 0xFEED
25#define PRODUCT_ID 0x6513
26#define MANUFACTURER t.m.k.
27#define PRODUCT PS/2 keyboard converter(USART)
28#define DESCRIPTION convert PS/2 keyboard to USB
29
30
31/* matrix size */
32#define MATRIX_ROWS 32 // keycode bit: 3-0
33#define MATRIX_COLS 8 // keycode bit: 6-4
34
35
36/* key combination for command */
37#define IS_COMMAND() ( \
38 keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)) || \
39 keyboard_report->mods == (MOD_BIT(KB_LCTRL) | MOD_BIT(KB_RSHIFT)) \
40)
41
42
43/* mouse keys */
44#ifdef MOUSEKEY_ENABLE
45# define MOUSEKEY_DELAY_TIME 255
46#endif
47
48
49/* PS/2 lines */
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
59
60// synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge
61// set DDR of CLOCK as input to be slave
62#define PS2_USART_INIT() do { \
63 PS2_CLOCK_DDR &= ~(1<<PS2_CLOCK_BIT); \
64 PS2_DATA_DDR &= ~(1<<PS2_DATA_BIT); \
65 UCSR1C = ((1 << UMSEL10) | \
66 (3 << UPM10) | \
67 (0 << USBS1) | \
68 (3 << UCSZ10) | \
69 (0 << UCPOL1)); \
70 UCSR1A = 0; \
71 UBRR1H = 0; \
72 UBRR1L = 0; \
73} while (0)
74#define PS2_USART_RX_INT_ON() do { \
75 UCSR1B = ((1 << RXCIE1) | \
76 (1 << RXEN1)); \
77} while (0)
78#define PS2_USART_RX_POLL_ON() do { \
79 UCSR1B = (1 << RXEN1); \
80} while (0)
81#define PS2_USART_OFF() do { \
82 UCSR1C = 0; \
83 UCSR1B &= ~((1 << RXEN1) | \
84 (1 << TXEN1)); \
85} while (0)
86#define PS2_USART_RX_READY (UCSR1A & (1<<RXC1))
87#define PS2_USART_RX_DATA UDR1
88#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
89#define PS2_USART_RX_VECT USART1_RX_vect
90
91#endif
diff --git a/converter/ps2_usb/keymap_jis.c b/converter/ps2_usb/keymap_jis.c
new file mode 100644
index 000000000..787c9558a
--- /dev/null
+++ b/converter/ps2_usb/keymap_jis.c
@@ -0,0 +1,297 @@
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 "usb_keycodes.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 { KB_NO, KB_##K01, KB_NO, KB_##K03, KB_##K04, KB_##K05, KB_##K06, KB_##K07 }, \
55 { KB_##K08, KB_##K09, KB_##K0A, KB_##K0B, KB_##K0C, KB_##K0D, KB_##K0E, KB_NO }, \
56 { KB_##K10, KB_##K11, KB_##K12, KB_##K13, KB_##K14, KB_##K15, KB_##K16, KB_NO }, \
57 { KB_##K18, KB_NO, KB_##K1A, KB_##K1B, KB_##K1C, KB_##K1D, KB_##K1E, KB_NO }, \
58 { KB_##K20, KB_##K21, KB_##K22, KB_##K23, KB_##K24, KB_##K25, KB_##K26, KB_NO }, \
59 { KB_##K28, KB_##K29, KB_##K2A, KB_##K2B, KB_##K2C, KB_##K2D, KB_##K2E, KB_NO }, \
60 { KB_##K30, KB_##K31, KB_##K32, KB_##K33, KB_##K34, KB_##K35, KB_##K36, KB_NO }, \
61 { KB_##K38, KB_NO, KB_##K3A, KB_##K3B, KB_##K3C, KB_##K3D, KB_##K3E, KB_NO }, \
62 { KB_##K40, KB_##K41, KB_##K42, KB_##K43, KB_##K44, KB_##K45, KB_##K46, KB_NO }, \
63 { KB_##K48, KB_##K49, KB_##K4A, KB_##K4B, KB_##K4C, KB_##K4D, KB_##K4E, KB_NO }, \
64 { KB_##K50, KB_##K51, KB_##K52, KB_NO, KB_##K54, KB_##K55, KB_NO, KB_##K57 }, \
65 { KB_##K58, KB_##K59, KB_##K5A, KB_##K5B, KB_NO, KB_##K5D, KB_NO, KB_##K5F }, \
66 { KB_NO, KB_##K61, KB_NO, KB_NO, KB_##K64, KB_NO, KB_##K66, KB_##K67 }, \
67 { KB_NO, KB_##K69, KB_##K6A, KB_##K6B, KB_##K6C, KB_NO, KB_NO, KB_NO }, \
68 { KB_##K70, KB_##K71, KB_##K72, KB_##K73, KB_##K74, KB_##K75, KB_##K76, KB_##K77 }, \
69 { KB_##K78, KB_##K79, KB_##K7A, KB_##K7B, KB_##K7C, KB_##K7D, KB_##K7E, KB_NO }, \
70 { KB_NO, KB_NO, KB_NO, KB_##K83, KB_NO, KB_NO, KB_NO, KB_NO }, \
71 { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
72 { KB_##K90, KB_##K91, KB_NO, KB_NO, KB_##K94, KB_##K95, KB_NO, KB_NO }, \
73 { KB_##K98, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_##K9F }, \
74 { KB_##KA0, KB_##KA1, KB_NO, KB_##KA3, KB_NO, KB_NO, KB_NO, KB_##KA7 }, \
75 { KB_##KA8, KB_NO, KB_NO, KB_##KAB, KB_NO, KB_NO, KB_NO, KB_##KAF }, \
76 { KB_##KB0, KB_NO, KB_##KB2, KB_NO, KB_##KB4, KB_NO, KB_NO, KB_##KB7 }, \
77 { KB_##KB8, KB_NO, KB_##KBA, KB_##KBB, KB_NO, KB_NO, KB_NO, KB_##KBF }, \
78 { KB_##KC0, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
79 { KB_##KC8, KB_NO, KB_##KCA, KB_NO, KB_NO, KB_##KCD, KB_NO, KB_NO }, \
80 { KB_##KD0, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
81 { KB_NO, KB_NO, KB_##KDA, KB_NO, KB_NO, KB_NO, KB_##KDE, KB_NO }, \
82 { KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO, KB_NO }, \
83 { KB_NO, KB_##KE9, KB_NO, KB_##KEB, KB_##KEC, KB_NO, KB_NO, KB_NO }, \
84 { KB_##KF0, KB_##KF1, KB_##KF2, KB_NO, KB_##KF4, KB_##KF5, KB_NO, KB_NO }, \
85 { KB_NO, KB_NO, KB_##KFA, KB_NO, KB_##KFC, KB_##KFD, KB_##KFE, KB_NO }, \
86}
87
88/* JIS layout */
89#define KEYMAP_JIS( \
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,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \
92 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \
93 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \
94 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \
95 K14,K9F,K11, K67,K29,K64,K13, 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 K51, K13, K6A, K64, K67, \
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#define KEYMAP_JIS_COMPACT( \
117 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, \
118 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, \
119 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, \
120 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, \
121 K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94 \
122) \
123KEYMAP_ALL( \
124 ESC,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10,F11,F12, PSCR,SLCK,BRK, \
125 K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \
126 K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, DEL, END, PGDN, P7, P8, P9, \
127 K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, P4, P5, P6, PPLS, \
128 K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, UP, P1, P2, P3, \
129 K14,K9F,K11, K29, K91,KA7,KAF,K94, LEFT,DOWN,RGHT, P0, PDOT,PENT, \
130 \
131 NUBS, \
132 K51, K13, K6A, K64, K67, \
133 F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \
134 SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \
135 AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \
136 MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \
137 MAIL, CALCULATOR, MY_COMPUTER, \
138 WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \
139 WWW_STOP, WWW_REFRESH, WWW_FAVORITES \
140)
141
142
143// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
144static const uint8_t PROGMEM fn_layer[] = {
145 1, // Fn0
146 2, // Fn1
147 1, // Fn2
148 2, // Fn3
149 3, // Fn4
150 4, // Fn5
151 0, // Fn6
152 0 // Fn7
153};
154
155// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
156// See layer.c for details.
157static const uint8_t PROGMEM fn_keycode[] = {
158 KB_SCLN, // Fn0
159 KB_SLSH, // Fn1
160 KB_BSPC, // Fn2
161 KB_NO, // Fn3
162 KB_NO, // Fn4
163 KB_SPC, // Fn5
164 KB_NO, // Fn6
165 KB_NO // Fn7
166};
167
168
169// The keymap is a 32*8 byte array which convert a PS/2 scan code into a USB keycode.
170// See usb_keycodes.h for USB keycodes. You should omit a 'KB_' prefix of USB keycodes in keymap macro.
171// Use KEYMAP_ISO() or KEYMAP_JIS() instead of KEYMAP() if your keyboard is ISO or JIS.
172static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
173 /* 0: JIS LAYOUT
174 * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
175 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak|
176 * `---' `---------------' `---------------' `---------------' `-----------' `-----------'
177 * ,-----------------------------------------------------------. ,-----------. ,---------------.
178 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| JY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
179 * |-----------------------------------------------------------| |-----------| |---------------|
180 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Ret | |Del|End|PgD| | 7| 8| 9| |
181 * |------------------------------------------------------` | `-----------' |-----------| +|
182 * |CapsLo| A| S| D| F| G| H| J| K| L| ;| :| \| | | 4| 5| 6| |
183 * |-----------------------------------------------------------| ,---. |---------------|
184 * |Shift | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3| |
185 * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
186 * |Ctrl |Gui |Alt |MHEN| Space |HENK|KANA|Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| |
187 * `-----------------------------------------------------------' `-----------' `---------------'
188 */
189/*
190 KEYMAP_JIS(
191 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK,
192 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
193 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, END, PGDN, P7, P8, P9,
194 CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS, ENT, P4, P5, P6, PPLS,
195 LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, RSFT, UP, P1, P2, P3,
196 LCTL,LGUI,LALT, MHEN,SPC, HENK,KANA, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
197 ),
198*/
199 /* 0: HHKB-wise
200 * ,-----------------------------------------------------------.
201 * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `|
202 * |-----------------------------------------------------------|
203 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Bsp |
204 * |------------------------------------------------------` |
205 * |Ctrl | A| S| D| F| G| H| J| K| L| ;| :|Ret| |
206 * |-----------------------------------------------------------|
207 * |Shift | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift |
208 * |-----------------------------------------------------------|
209 * |Ctrl |Gui |Alt |MHEN| Space |HENK|KANA|Alt |Gui |Menu|Ctrl|
210 * `-----------------------------------------------------------'
211 */
212 KEYMAP_JIS_COMPACT(
213 ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC,
214 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,
215 LCTL,A, S, D, F, G, H, J, K, L, FN0, QUOT,GRV, ENT,
216 LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, FN4,
217 LCTL,LGUI,LALT, LALT,FN5, FN2, FN3, RALT,RGUI,APP, LGUI
218 ),
219
220 /* 1: Mouse keys
221 * ,-----------------------------------------------------------.
222 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
223 * |-----------------------------------------------------------|
224 * |Tab |MwL|MwU|McU|WwU|WwR|MwL|MwD|MwU|MwR| | | | \|
225 * |-----------------------------------------------------------|
226 * |CapsLo| |McL|McD|McR| |McL|McD|McU|McR|Fn0| |Return |
227 * |-----------------------------------------------------------|
228 * |Shift |VoD|VoU|Mut|Mb2|Mb3|Mb2|Mb1|VoD|VoU|Mut|Shift |
229 * |-----------------------------------------------------------|
230 * |Ctrl |Gui |Alt | Mb1 |Alt |Gui |Menu|Ctrl|
231 * `-----------------------------------------------------------'
232 * Mc = mouse cursor, Mw = mouse wheel, Mb = mouse button
233 * Vo = Volume, Mut = Mute
234 */
235 KEYMAP_JIS_COMPACT(
236 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
237 TAB, WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO,
238 LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, NO, ENT,
239 LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,BTN2,BTN3,NO, RSFT, RSFT,
240 LCTL,LGUI,LALT, LALT,BTN1,FN2, RALT, RALT,RGUI,APP, LGUI
241 ),
242
243 /* 2: Cursor keys
244 * ,-----------------------------------------------------------.
245 * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
246 * |-----------------------------------------------------------|
247 * |Tab |Hom|PgU| Up|PgU|End|Hom|PgD|PgU|End| | | | \|
248 * |-----------------------------------------------------------|
249 * |CapsLo| |Lef|Dow|Rig| |Lef|Dow| Up|Rig| | |Return |
250 * |-----------------------------------------------------------|
251 * |Shift | | | | | |Hom|PgD|PgU|End|Fn1|Shift |
252 * |-----------------------------------------------------------|
253 * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
254 * `-----------------------------------------------------------'
255 */
256 KEYMAP_JIS_COMPACT(
257 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
258 TAB, HOME,PGUP,UP, PGDN,END, HOME,PGDN,PGUP,END, NO, NO, NO,
259 LCTL,HOME,LEFT,DOWN,RGHT,END, LEFT,DOWN,UP, RGHT,NO, NO, NO, ENT,
260 LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN1, RSFT, RSFT,
261 LCTL,LGUI,LALT, LALT,BTN1,BSPC,FN3, RALT,RGUI,APP, LGUI
262 ),
263
264 /* 3: HHKB Fn layer */
265 KEYMAP_JIS_COMPACT(
266 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
267 CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO,
268 LCTL,VOLD,VOLU,MUTE,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT,NO, ENT,
269 LSFT,NO, NO, NO, NO, NO, NO, NO, END, PGDN,DOWN,RSFT, FN4,
270 LCTL,LGUI,LALT, LALT,SPC, BSPC,NO, RALT,RGUI,APP, LGUI
271 ),
272
273 /* 4: Number */
274 KEYMAP_JIS_COMPACT(
275 GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, INS, DEL,
276 TAB, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
277 LCTL,1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, ENT,
278 LSFT,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, RSFT, RSFT,
279 LCTL,LGUI,LALT, LALT,FN5, BSPC,NO, RALT,RGUI,APP, LGUI
280 ),
281};
282
283
284uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
285{
286 return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
287}
288
289uint8_t keymap_fn_layer(uint8_t fn_bits)
290{
291 return pgm_read_byte(&fn_layer[biton(fn_bits)]);
292}
293
294uint8_t keymap_fn_keycode(uint8_t fn_bits)
295{
296 return pgm_read_byte(&fn_keycode[(biton(fn_bits))]);
297}
diff --git a/converter/ps2_usb/usbconfig.h b/converter/ps2_usb/usbconfig.h
index 9038f1eb8..d0ca4c717 100644
--- a/converter/ps2_usb/usbconfig.h
+++ b/converter/ps2_usb/usbconfig.h
@@ -11,7 +11,6 @@
11#ifndef __usbconfig_h_included__ 11#ifndef __usbconfig_h_included__
12#define __usbconfig_h_included__ 12#define __usbconfig_h_included__
13 13
14#include "config_vusb.h"
15 14
16/* 15/*
17General Description: 16General Description:
diff --git a/protocol/ps2.c b/protocol/ps2.c
index 8a0591621..cf7b1f43c 100644
--- a/protocol/ps2.c
+++ b/protocol/ps2.c
@@ -89,8 +89,9 @@ uint8_t ps2_error = PS2_ERR_NONE;
89 89
90void ps2_host_init(void) 90void ps2_host_init(void)
91{ 91{
92#ifdef PS2_INT_ENABLE 92#ifdef PS2_USE_INT
93 PS2_INT_ENABLE(); 93 PS2_INT_INIT();
94 PS2_INT_ON();
94 idle(); 95 idle();
95#else 96#else
96 inhibit(); 97 inhibit();
@@ -103,8 +104,8 @@ uint8_t ps2_host_send(uint8_t data)
103 uint8_t res = 0; 104 uint8_t res = 0;
104 bool parity = true; 105 bool parity = true;
105 ps2_error = PS2_ERR_NONE; 106 ps2_error = PS2_ERR_NONE;
106#ifdef PS2_INT_DISABLE 107#ifdef PS2_USE_INT
107 PS2_INT_DISABLE(); 108 PS2_INT_OFF();
108#endif 109#endif
109 /* terminate a transmission if we have */ 110 /* terminate a transmission if we have */
110 inhibit(); 111 inhibit();
@@ -144,8 +145,8 @@ uint8_t ps2_host_send(uint8_t data)
144 145
145 res = ps2_host_recv_response(); 146 res = ps2_host_recv_response();
146ERROR: 147ERROR:
147#ifdef PS2_INT_ENABLE 148#ifdef PS2_USE_INT
148 PS2_INT_ENABLE(); 149 PS2_INT_ON();
149 idle(); 150 idle();
150#else 151#else
151 inhibit(); 152 inhibit();
@@ -173,7 +174,7 @@ uint8_t ps2_host_recv_response(void)
173 return data; 174 return data;
174} 175}
175 176
176#ifndef PS2_INT_VECT 177#ifndef PS2_USE_INT
177uint8_t ps2_host_recv(void) 178uint8_t ps2_host_recv(void)
178{ 179{
179 return ps2_host_recv_response(); 180 return ps2_host_recv_response();