From 47e9e8022359033aa61b159532760e780694aaec Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 2 Jun 2018 19:52:50 +0900 Subject: [PATCH 1/5] pc98_usb: LED control code is disabled by default --- converter/pc98_usb/Makefile | 1 - converter/pc98_usb/config.h | 9 +++++++++ converter/pc98_usb/led.c | 33 --------------------------------- converter/pc98_usb/matrix.c | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 34 deletions(-) delete mode 100644 converter/pc98_usb/led.c diff --git a/converter/pc98_usb/Makefile b/converter/pc98_usb/Makefile index 9892276d..ae6511cd 100644 --- a/converter/pc98_usb/Makefile +++ b/converter/pc98_usb/Makefile @@ -10,7 +10,6 @@ TARGET_DIR = . # keyboard dependent files SRC = keymap.c \ matrix.c \ - led.c \ protocol/serial_uart.c # protocol/serial_soft.c diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h index b8d676e4..16a54ca5 100644 --- a/converter/pc98_usb/config.h +++ b/converter/pc98_usb/config.h @@ -36,6 +36,15 @@ along with this program. If not, see . ) +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* Control LED indicatiors, which doesn't work well with locking support */ +//#define PC98_LED_CONTROL + + /* PC98 Reset Port shared with TXD */ #define PC98_RST_DDR DDRD #define PC98_RST_PORT PORTD diff --git a/converter/pc98_usb/led.c b/converter/pc98_usb/led.c deleted file mode 100644 index 48c3f1c2..00000000 --- a/converter/pc98_usb/led.c +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2012 Jun Wako - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "stdint.h" -#include "serial.h" -#include "led.h" - - -void led_set(uint8_t usb_led) -{ - uint8_t sun_led = 0; - if (usb_led & (1< Date: Sat, 2 Jun 2018 20:37:34 +0900 Subject: [PATCH 2/5] pc98_usb: Configure for TMK Converter --- converter/pc98_usb/Makefile | 4 +++- converter/pc98_usb/config.h | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/converter/pc98_usb/Makefile b/converter/pc98_usb/Makefile index ae6511cd..601e30a9 100644 --- a/converter/pc98_usb/Makefile +++ b/converter/pc98_usb/Makefile @@ -19,9 +19,10 @@ CONFIG_H = config.h # MCU name, you MUST set this to match the board you are using # type "make clean" after changing this, so all files will be rebuilt #MCU = at90usb162 # Teensy 1.0 -MCU = atmega32u4 # Teensy 2.0 +#MCU = atmega32u4 # Teensy 2.0 #MCU = at90usb646 # Teensy++ 1.0 #MCU = at90usb1286 # Teensy++ 2.0 +MCU = atmega32u2 # TMK Converter # Processor frequency. @@ -61,6 +62,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT MOUSEKEY_ENABLE = yes # Mouse keys EXTRAKEY_ENABLE = yes # Audio control and System control CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration #NKRO_ENABLE = yes # USB Nkey Rollover diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h index 16a54ca5..6793c794 100644 --- a/converter/pc98_usb/config.h +++ b/converter/pc98_usb/config.h @@ -32,7 +32,8 @@ along with this program. If not, see . /* key combination for command */ #define IS_COMMAND() ( \ - host_get_first_key() == KC_CANCEL \ + keyboard_report->keys[0] == KC_STOP || \ + keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \ ) @@ -56,7 +57,7 @@ along with this program. If not, see . /* PC98 Retry Port */ #define PC98_RTY_DDR DDRD #define PC98_RTY_PORT PORTD -#define PC98_RTY_BIT 5 +#define PC98_RTY_BIT 1 /* * PC98 Serial(USART) configuration @@ -110,7 +111,7 @@ along with this program. If not, see . /* * Hardware Serial(UART) */ -#ifdef __AVR_ATmega32U4__ +#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) #define SERIAL_UART_BAUD 19200 #define SERIAL_UART_DATA UDR1 #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) From 6ff29ea8fa70f27938e349ec20d866264759e05a Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 2 Jun 2018 20:39:01 +0900 Subject: [PATCH 3/5] pc98_usb: Change keymap --- converter/pc98_usb/keymap.c | 40 ++++++++++++------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/converter/pc98_usb/keymap.c b/converter/pc98_usb/keymap.c index e56a72f1..557e5a27 100644 --- a/converter/pc98_usb/keymap.c +++ b/converter/pc98_usb/keymap.c @@ -89,28 +89,20 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { `-----------------------------------------------' */ KEYMAP( - CANCEL,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, FN6, - ESC, 1, 2, 3, 4, 5, FN4, FN5, 6, 7, 8, 9, 0, BSPC, - TAB, Q, W, E, R, T, UP, Y, U, I, O, P, ENT, - LCTL, A, S, D, F, G, MINS, EQL, H, J, K, L, FN2, - LSFT, Z, X, C, V, B, GRV, BSLS, QUOT, N, M,COMM, DOT, FN1, - LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT + STOP,PSCR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, + ESC, 1, 2, 3, 4, 5, LNUM,LCAP, 6, 7, 8, 9, 0, BSPC, + TAB, Q, W, E, R, T, UP, Y, U, I, O, P, ENT, + LCTL, A, S, D, F, G, LEFT, RGHT, H, J, K, L,SCLN, + LSFT, Z, X, C, V, B, INS, DOWN, DEL, N, M,COMM, DOT,SLSH, + LGUI, LALT, LCTL, FN0, SPC, FN0, RALT ), KEYMAP( - PAUS,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, - GRV, F1, F2, F3, F4, F5, NO, NO, F6, F7, F8, F9, F10, DEL, - TAB, Q, W, E, R, T, UP, HOME,PGDN,PGUP, END, P, ENT, - LCTL, A, S, D, F, G, MINS, EQL, LEFT,DOWN, UP,RGHT,SCLN, - LSFT, Z, X, C, V, B, INS, DOWN, DEL,HOME,PGDN,PGUP, END,TRNS, - LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT - ), - KEYMAP( - PAUS,COPY, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, - GRV, F1, F2, F3, F4, F5, NO, NO, F6, F7, F8, F9, F10, DEL, - TAB, Q, W, E, R, T, UP, WH_L,WH_D,WH_U,WH_R, P, ENT, - LCTL, A, S, D, F, G, MINS, EQL, MS_L,MS_D,MS_U,MS_R,TRNS, - LSFT, Z, X, C, V, B, INS, DOWN, BTN3,BTN2,BTN1,BTN4,BTN5,TRNS, - LGUI, LALT, LCTL, LSFT, SPC, SPC, RALT + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,SLCK,PAUS, + GRV, TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS,MINS, EQL, BSLS, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS, PGUP, TRNS,TRNS,TRNS,LBRC,RBRC, TRNS, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS, HOME, END, TRNS,TRNS,TRNS,TRNS,QUOT, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, PGDN, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS ), }; @@ -162,11 +154,5 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) * Fn actions */ const action_t PROGMEM fn_actions[] = { - ACTION_LAYER_TAP_TOGGLE(0), // FN0 - ACTION_LAYER_TAP_KEY(1, KC_SLASH), // FN1 - ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN2 - ACTION_LAYER_MOMENTARY(2), // FN3 - ACTION_MACRO(LBRACKET), // FN4 - ACTION_MACRO(RBRACKET), // FN5 - ACTION_MACRO(DUMMY), // FN6 + ACTION_LAYER_MOMENTARY(1), // FN0 }; From d6c1643edfc19fe366006d916ed41d991b93e022 Mon Sep 17 00:00:00 2001 From: tmk Date: Sat, 2 Jun 2018 20:40:08 +0900 Subject: [PATCH 4/5] pc98_usb: Update protocol commands --- converter/pc98_usb/config.h | 1 + converter/pc98_usb/matrix.c | 60 +++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 32 deletions(-) diff --git a/converter/pc98_usb/config.h b/converter/pc98_usb/config.h index 6793c794..9341708f 100644 --- a/converter/pc98_usb/config.h +++ b/converter/pc98_usb/config.h @@ -123,6 +123,7 @@ along with this program. If not, see . UCSR1B |= (1<. #include "print.h" #include "util.h" #include "matrix.h" +#include "led.h" #include "debug.h" #include "protocol/serial.h" @@ -47,38 +48,46 @@ static uint8_t matrix[MATRIX_ROWS]; #define COL(code) (code&0x07) +static void pc98_send(uint8_t data) +{ + PC98_RDY_PORT |= (1< Date: Thu, 7 Jun 2018 17:29:13 +0900 Subject: [PATCH 5/5] pc98_usb: Update README --- converter/pc98_usb/README | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/converter/pc98_usb/README b/converter/pc98_usb/README index c9bdf3d8..3fc0a4b9 100644 --- a/converter/pc98_usb/README +++ b/converter/pc98_usb/README @@ -1,6 +1,6 @@ PC98 to USB keyboard protocol converter ======================================= -Target MCU is ATMega32u4 but other USB capable AVR will also work. +Target MCU is ATMega32u2 but other USB capable AVR will also work. Connector @@ -12,7 +12,7 @@ Connector / 8 7 6 \ | 5 4 3 | \_ 2 1 _/ - \_____/ + \_____/ (receptacle) @@ -25,8 +25,8 @@ Wiring: You can change this with editing config.h. 3 ~RDY PD4 4 RXD PD2 5 ~RTY PD5 - 6 NC - 7 NC + 6 NC + 7 NC 8 5V VCC @@ -59,9 +59,31 @@ PC98 to PS/2 http://www.tsp.ne.jp/~sawada/mago/c_gka98at.htm http://www.tsp.ne.jp/~sawada/mago/src/gka98at.asm +scan code: +http://ixsvr.dyndns.org/usb2pc98 + +NEC PC-9801-98-S02 - raku raku keyboard: +https://deskthority.net/photos-f62/nec-pc-9801-98-s02-t5212.html + + + PC98 keyboard commands +---------------------- http://www.webtech.co.jp/company/doc/undocumented_mem/io_kb.txt +response from keyboard: + FAh: ACK + FCh: NACK Inhibit repeating key: -0x9C, 0x70 + 0x9C, 0x70 + +LED control: + 9Dh 7xh + + second byte: + 0111 xxxx + |||`- NumLock + ||`-- ? + |`--- CapsLock + `---- Kana