Browse Source

port sun_usb converter from tmk

initial import
Yann Hodique 6 years ago
parent
commit
52ecc76e28

+ 64 - 0
keyboards/converter/sun_usb/command_extra.c

@@ -0,0 +1,64 @@
+#include QMK_KEYBOARD_H
+#include "protocol/serial.h"
+
+bool sun_bell = false;
+bool sun_click = false;
+
+
+bool command_extra(uint8_t code)
+{
+    switch (code) {
+        case KC_H:
+        case KC_SLASH: /* ? */
+            print("\n\n----- Sun converter Help -----\n");
+            print("Home:        Toggle Bell\n");
+            print("End:         Toggle Click\n");
+            print("PgUp:        LED all On\n");
+            print("PgDown:      LED all Off\n");
+            print("Insert:      Layout\n");
+            print("Delete:      Reset\n");
+            return false;
+        case KC_DEL:
+            print("Reset\n");
+            serial_send(0x01);
+            break;
+        case KC_HOME:
+	    sun_bell = !sun_bell;
+	    if (sun_bell) {
+                print("Bell On\n");
+	        serial_send(0x02);
+	    } else {
+	        print("Bell Off\n");
+	        serial_send(0x03);
+	    }
+            break;
+        case KC_END:
+	    sun_click = !sun_click;
+	    if (sun_click) {
+	        print("Click On\n");
+		serial_send(0x0A);
+	    } else {
+	        print("Click Off\n");
+                serial_send(0x0B);
+	    }
+	    break;
+        case KC_PGUP:
+            print("LED all on\n");
+            serial_send(0x0E);
+            serial_send(0xFF);
+            break;
+        case KC_PGDOWN:
+            print("LED all off\n");
+            serial_send(0x0E);
+            serial_send(0x00);
+            break;
+        case KC_INSERT:
+            print("layout\n");
+            serial_send(0x0F);
+            break;
+        default:
+            xprintf("Unknown extra command: %02X\n", code);
+            return false;
+    }
+    return true;
+}

+ 88 - 0
keyboards/converter/sun_usb/config.h

@@ -0,0 +1,88 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#define CUSTOM_MATRIX 2
+
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x3333
+#define DEVICE_VER      0x0100
+#define MANUFACTURER    QMK
+#define PRODUCT         Sun keyboard converter
+#define DESCRIPTION     USB converter for Sun type 5 keyboard
+
+/* matrix size */
+#define MATRIX_ROWS 16
+#define MATRIX_COLS 8
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+    keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
+    keyboard_report->mods == (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) || \
+    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+/* Serial(USART) configuration
+ *     asynchronous, negative logic, 1200baud, no flow control
+ *     1-start bit, 8-data bit, non parity, 1-stop bit
+ */
+#define SERIAL_SOFT_BAUD            1200
+#define SERIAL_SOFT_PARITY_NONE
+#define SERIAL_SOFT_BIT_ORDER_LSB
+#define SERIAL_SOFT_LOGIC_NEGATIVE
+/* RXD Port */
+#define SERIAL_SOFT_RXD_ENABLE
+#define SERIAL_SOFT_RXD_DDR         DDRD
+#define SERIAL_SOFT_RXD_PORT        PORTD
+#define SERIAL_SOFT_RXD_PIN         PIND
+#define SERIAL_SOFT_RXD_BIT         2
+#define SERIAL_SOFT_RXD_VECT        INT2_vect
+/* RXD Interupt */
+#define SERIAL_SOFT_RXD_INIT()      do { \
+    /* pin configuration: input with pull-up */ \
+    SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
+    SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
+    /* enable interrupt: INT2(rising edge) */ \
+    EICRA |= ((1<<ISC21)|(1<<ISC20)); \
+    EIMSK |= (1<<INT2); \
+    sei(); \
+} while (0)
+#define SERIAL_SOFT_RXD_INT_ENTER()
+#define SERIAL_SOFT_RXD_INT_EXIT()  do { \
+    /* clear interrupt  flag */ \
+    EIFR = (1<<INTF2); \
+} while (0)
+#define SERIAL_SOFT_RXD_READ()      (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
+/* TXD Port */
+#define SERIAL_SOFT_TXD_ENABLE
+#define SERIAL_SOFT_TXD_DDR         DDRD
+#define SERIAL_SOFT_TXD_PORT        PORTD
+#define SERIAL_SOFT_TXD_PIN         PIND
+#define SERIAL_SOFT_TXD_BIT         3
+#define SERIAL_SOFT_TXD_HI()        do { SERIAL_SOFT_TXD_PORT |=  (1<<SERIAL_SOFT_TXD_BIT); } while (0)
+#define SERIAL_SOFT_TXD_LO()        do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
+#define SERIAL_SOFT_TXD_INIT()      do { \
+    /* pin configuration: output */ \
+    SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
+    /* idle */ \
+    SERIAL_SOFT_TXD_ON(); \
+} while (0)
+
+#endif

+ 32 - 0
keyboards/converter/sun_usb/led.c

@@ -0,0 +1,32 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include QMK_KEYBOARD_H
+#include "protocol/serial.h"
+
+void led_set(uint8_t usb_led)
+{
+    uint8_t sun_led = 0;
+    if (usb_led & (1<<USB_LED_NUM_LOCK))    sun_led |= (1<<0);
+    if (usb_led & (1<<USB_LED_COMPOSE))     sun_led |= (1<<1);
+    if (usb_led & (1<<USB_LED_SCROLL_LOCK)) sun_led |= (1<<2);
+    if (usb_led & (1<<USB_LED_CAPS_LOCK))   sun_led |= (1<<3);
+    xprintf("LED: %02X\n", usb_led);
+
+    serial_send(0x0E);
+    serial_send(sun_led);
+}

+ 197 - 0
keyboards/converter/sun_usb/matrix.c

@@ -0,0 +1,197 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include QMK_KEYBOARD_H
+#include "protocol/serial.h"
+
+/*
+ * Matrix Array usage:
+ *
+ * ROW: 16(4bits)
+ * COL:  8(3bits)
+ *
+ *    8bit wide
+ *   +---------+
+ *  0|00 ... 07|
+ *  1|08 ... 0F|
+ *  :|   ...   |
+ *  :|   ...   |
+ *  E|70 ... 77|
+ *  F|78 ... 7F|
+ *   +---------+
+ */
+static uint8_t matrix[MATRIX_ROWS];
+#define ROW(code)      ((code>>3)&0xF)
+#define COL(code)      (code&0x07)
+
+static bool is_modified = false;
+
+__attribute__ ((weak))
+void matrix_init_kb(void) {
+    matrix_init_user();
+}
+
+__attribute__ ((weak))
+void matrix_scan_kb(void) {
+    matrix_scan_user();
+}
+
+__attribute__ ((weak))
+void matrix_init_user(void) {
+}
+
+__attribute__ ((weak))
+void matrix_scan_user(void) {
+}
+
+inline
+uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+    /* DDRD |= (1<<6); */
+    /* PORTD |= (1<<6); */
+    debug_enable = true;
+
+    serial_init();
+
+    // initialize matrix state: all keys off
+    for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
+
+    /* // wait for keyboard coming up */
+    /* // otherwise LED status update fails */
+    /* print("Reseting "); */
+    /* while (1) { */
+    /*     print("."); */
+    /*     while (serial_recv()); */
+    /*     serial_send(0x01); */
+    /*     _delay_ms(500); */
+    /*     if (serial_recv() == 0xFF) { */
+    /*         _delay_ms(500); */
+    /*         if (serial_recv() == 0x04) */
+    /*             break; */
+    /*     } */
+    /* } */
+    /* print(" Done\n"); */
+
+    /* PORTD &= ~(1<<6); */
+
+    matrix_init_quantum();
+    return;
+}
+
+uint8_t matrix_scan(void)
+{
+    uint8_t code;
+    code = serial_recv();
+    if (!code) return 0;
+
+    debug_hex(code); debug(" ");
+
+    switch (code) {
+        case 0xFF:  // reset success: FF 04
+            print("reset: ");
+            _delay_ms(500);
+            code = serial_recv();
+            xprintf("%02X\n", code);
+            if (code == 0x04) {
+                // LED status
+                led_set(host_keyboard_leds());
+            }
+            return 0;
+        case 0xFE:  // layout: FE <layout>
+            print("layout: ");
+            _delay_ms(500);
+            xprintf("%02X\n", serial_recv());
+            return 0;
+        case 0x7E:  // reset fail: 7E 01
+            print("reset fail: ");
+            _delay_ms(500);
+            xprintf("%02X\n", serial_recv());
+            return 0;
+        case 0x7F:
+            // all keys up
+            for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
+            return 0;
+    }
+
+    if (code&0x80) {
+        // break code
+        if (matrix_is_on(ROW(code), COL(code))) {
+            matrix[ROW(code)] &= ~(1<<COL(code));
+        }
+    } else {
+        // make code
+        if (!matrix_is_on(ROW(code), COL(code))) {
+            matrix[ROW(code)] |=  (1<<COL(code));
+        }
+    }
+
+    matrix_scan_quantum();
+    return code;
+}
+
+bool matrix_is_modified(void)
+{
+    return is_modified;
+}
+
+inline
+bool matrix_has_ghost(void)
+{
+    return false;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & (1<<col));
+}
+
+inline
+uint8_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 01234567\n");
+    for (uint8_t row = 0; row < matrix_rows(); row++) {
+        phex(row); print(": ");
+        pbin_reverse(matrix_get_row(row));
+        print("\n");
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop(matrix[i]);
+    }
+    return count;
+}

+ 89 - 0
keyboards/converter/sun_usb/readme.md

@@ -0,0 +1,89 @@
+# Sun to USB keyboard protocol converter
+
+A converter for using non-USB Sun keyboards.
+
+Original code from the [TMK firmware](https://github.com/tmk/tmk_keyboard/tree/master/converter/sun_usb). Ported to QMK by [Yann Hodique](https://github.com/sigma).
+
+Keyboard Maintainer: [Yann Hodique](https://github.com/sigma)  
+Hardware Supported: See hardware section below  
+Hardware Availability: self-built
+
+Make example for this keyboard (after setting up your build environment):
+
+    make converter/sun_usb/type5:default
+
+See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information.
+
+
+## Hardware
+
+Target MCU is ATMega32u4 but other USB capable AVR will also work. The maintainer mostly uses Teensy 2.0 boards.
+Supported keyboards: Sun Type 3 and 5 Keyboards,
+
+### Connector
+
+8Pin mini DIN
+
+       ___ ___
+      /  |_|  \
+     / 8  7  6 \
+    | 5    4  3 |
+     \_ 2   1 _/
+       \_____/
+    (receptacle)
+
+
+Wiring:
+
+    Pin mini DIN        MCU
+    ----------------------------------
+    1   GND             GND
+    2   GND             GND
+    3   5V
+    4   RX/TX(Mouse)
+    5   RX              PD3
+    6   TX              PD2
+    7   GND             GND
+    8   5V              VCC
+
+
+### Protocol
+
+    Signal: Asynchronous, Negative logic, 1200baud, No Flow control
+    Frame format: 1-Start bit, 8-Data bits, No-Parity, 1-Stop bit
+
+    AVR USART engine expects positive logic while Sun keyboard signal is negative.
+    To use AVR UART engine you need external inverter in front of RX and TX pin.
+    Otherwise you can software serial routine to communicate the keyboard.
+
+This converter uses software method, you doesn't need any inverter part.
+
+
+Commands From System To Keyboard
+
+    0x01 Reset
+            Keyboard responds with following byte sequence:
+            Success: 0xFF 0x04 0x7F
+            Fail:    0x7E 0x01 0x7F
+    0x02 Bell On
+    0x03 Bell Off
+    0x0A Click On
+    0x0B Click Off
+    0x0E LED
+            followed by LED status byte:
+            bit: 3       2       1       0
+            LED: CapsLk  ScrLk   Compose NumLk
+    0x0F Layout
+            Keyboard responds with 'Layout Response' 0xFE 0xXX
+
+Commands From Keyboard To System
+
+    0x7F Idle
+            means no keys pressed.
+    0xFE Layout Response
+    0xFF Reset Response(followed by 0x04)
+     
+References
+
+* http://kentie.net/article/sunkbd/page2.htm
+* http://kentie.net/article/sunkbd/KBD.pdf

+ 42 - 0
keyboards/converter/sun_usb/rules.mk

@@ -0,0 +1,42 @@
+MCU = atmega32u4       # Teensy 2.0
+F_CPU = 16000000
+ARCH = AVR8
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+BOOTLOADER = lufa-dfu
+
+# Build Options
+#   change to "no" to disable the options, or define them in the Makefile in 
+#   the appropriate keymap folder that will get included automatically
+#
+BOOTMAGIC_ENABLE = no       # Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes        # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes       # Audio control and System control(+450)
+CONSOLE_ENABLE = yes         # Console for debug(+400)
+COMMAND_ENABLE = yes         # Commands for debug and configuration
+NKRO_ENABLE = yes           # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+MIDI_ENABLE = no            # MIDI controls
+AUDIO_ENABLE = no           # Audio output on port C6
+UNICODE_ENABLE = no         # Unicode
+UNICODEMAP_ENABLE = yes
+BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
+RGBLIGHT_ENABLE = no        # Enable WS2812 RGB underlight.  Do not enable this with audio at the same time.
+CUSTOM_MATRIX = yes
+
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend
+
+#HARDWARE_SERIAL = yes
+
+SRC += matrix.c led.c
+
+ifdef HARDWARE_SERIAL
+        SRC += protocol/serial_uart.c
+        OPT_DEFS += -DHARDWARE_SERIAL
+else
+        SRC += protocol/serial_soft.c
+endif

+ 29 - 0
keyboards/converter/sun_usb/type3/keymaps/default/keymap.c

@@ -0,0 +1,29 @@
+/*
+  Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  LAYOUT(
+      KC_F10,KC_F11,  KC_F1, KC_F2, KC_F3,   KC_F4,     KC_F5,    KC_F6,     KC_F7,    KC_F8, KC_F9, KC_BSPC,  KC_VOLD, KC_MUTE, KC_VOLU,
+      KC_F12,KC_F13,  KC_ESC,KC_1,KC_2,KC_3,KC_4,KC_5,KC_6,KC_7,KC_8,KC_9,KC_0,KC_MINS,KC_EQL,KC_BSLS,KC_GRV,  KC_MPRV, KC_MPLY, KC_MNXT,
+      KC_F14,KC_F15,  KC_TAB,  KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_O,KC_P, KC_LBRC,KC_RBRC,   KC_DEL,   KC_HOME, KC_UP,   KC_PGUP,
+      KC_F16,KC_F17,  KC_LCTL,   KC_A,KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_SCLN,KC_QUOT,        KC_ENT,  KC_LEFT,KC_INSERT,KC_RIGHT,
+      KC_F18,KC_F19,  KC_LSFT,     KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT,KC_SLSH,KC_RSFT,KC_RCTL,  KC_END,  KC_DOWN,KC_PGDOWN,
+                      KC_LGUI,KC_LALT,                      KC_SPC,                        KC_RALT,KC_RGUI
+         ),
+};

+ 0 - 0
keyboards/converter/sun_usb/type3/rules.mk


+ 66 - 0
keyboards/converter/sun_usb/type3/type3.h

@@ -0,0 +1,66 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef TYPE3_H
+#define TYPE3_H
+
+#include "quantum.h"
+
+/* Sun type 3 keyboard
+,-------.  ,-----------------------------------------------------------.  ,-----------.
+| 01| 03|  | 05| 06|     08|     0A|     0C|     0E|     10| 11| 12| 2B|  | 15| 16| 17|
+|-------|  |-----------------------------------------------------------|  |-----------|
+| 19| 1A|  | 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 58| 2A|  | 2D| 2E| 2F|
+|-------|  |-----------------------------------------------------------|  |-----------|
+| 31| 33|  |  35 | 36| 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 42  |  | 44| 45| 46|
+|-------|  |-----------------------------------------------------------|  |-----------|
+| 48| 49|  |  4C  | 4D| 4E| 4F| 50| 51| 52| 53| 54| 55| 56| 57|   59   |  | 5B| 5C| 5D|
+|-------|  |-----------------------------------------------------------|  |-----------|
+| 5F| 61|  |   63   | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D|    6E| 6F|  | 70| 71| 72|
+`-------'  |-----------------------------------------------------------|  `-----------'
+           | 77 | 78  |               79                  | 7A  |   13 |
+           `-----------------------------------------------------------'
+*/
+
+
+#define LAYOUT(                                                         \
+    K01,K03,  K05,K06,    K08,    K0A,    K0C,    K0E,    K10,K11,K12,K2B,  K15,K16,K17, \
+    K19,K1A,  K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A,  K2D,K2E,K2F, \
+    K31,K33,  K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,   K42,  K44,K45,K46, \
+    K48,K49,  K4C,  K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57,      K59,  K5B,K5C,K5D, \
+    K5F,K61,  K63,   K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D,     K6E,K6F,  K70,K71,K72, \
+              K77,K78,                    K79,                    K7A,K13                \
+) { \
+    { KC_NO,  K01 , KC_NO,  K03 , KC_NO,  K05 ,  K06 , KC_NO }, \
+    {  K08 , KC_NO,  K0A , KC_NO,  K0C , KC_NO,  K0E , KC_NO }, \
+    {  K10 ,  K11 ,  K12 ,  K13 , KC_NO,  K15 ,  K16 ,  K17  }, \
+    { KC_NO,  K19 ,  K1A , KC_NO, KC_NO,  K1D ,  K1E ,  K1F  }, \
+    {  K20 ,  K21 ,  K22 ,  K23 ,  K24 ,  K25 ,  K26 ,  K27  }, \
+    {  K28 ,  K29 ,  K2A ,  K2B , KC_NO,  K2D ,  K2E ,  K2F  }, \
+    { KC_NO,  K31 , KC_NO,  K33 , KC_NO,  K35 ,  K36 ,  K37  }, \
+    {  K38 ,  K39 ,  K3A ,  K3B ,  K3C ,  K3D ,  K3E ,  K3F  }, \
+    {  K40 ,  K41 ,  K42 , KC_NO,  K44 ,  K45 ,  K46 , KC_NO }, \
+    {  K48 ,  K49 , KC_NO, KC_NO,  K4C ,  K4D ,  K4E ,  K4F  }, \
+    {  K50 ,  K51 ,  K52 ,  K53 ,  K54 ,  K55 ,  K56 ,  K57  }, \
+    {  K58 ,  K59 , KC_NO,  K5B ,  K5C ,  K5D , KC_NO,  K5F  }, \
+    { KC_NO,  K61 , KC_NO,  K63 ,  K64 ,  K65 ,  K66 ,  K67  }, \
+    {  K68 ,  K69 ,  K6A ,  K6B ,  K6C ,  K6D ,  K6E ,  K6F  }, \
+    {  K70 ,  K71 ,  K72 , KC_NO, KC_NO, KC_NO, KC_NO,  K77  }, \
+    {  K78 ,  K79 ,  K7A , KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }  \
+}
+
+#endif

+ 30 - 0
keyboards/converter/sun_usb/type5/keymaps/default/keymap.c

@@ -0,0 +1,30 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+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 <http://www.gnu.org/licenses/>.
+*/
+
+#include QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  /* LAYOUT_jp_unix is a superset of the other layouts, hence the default */
+  LAYOUT_jp_unix(
+      KC_HELP,              KC_NO,   KC_F1,KC_F2,KC_F3,KC_F4, KC_F5,KC_F6,KC_F7,KC_F8, KC_F9,KC_F10,KC_F11,KC_F12,   KC_PSCR,KC_SLCK,KC_PAUS,  KC_MUTE,KC_VOLD,KC_VOLU,KC_PWR,
+      KC_STOP,   KC_AGAIN,  KC_ESC,KC_1,KC_2,KC_3,KC_4,KC_5,KC_6,KC_7,KC_8,KC_9,KC_0,KC_MINS,KC_EQL,KC_BSLS,KC_GRV,  KC_INS, KC_HOME,KC_PGUP,  KC_NLCK,KC_PSLS,KC_PAST,KC_PMNS,
+      KC_MENU,   KC_UNDO,   KC_TAB,  KC_Q,KC_W,KC_E,KC_R,KC_T,KC_Y,KC_U,KC_I,KC_O,KC_P,KC_LBRC,KC_RBRC,  KC_BSPC,    KC_DEL, KC_END, KC_PGDN,  KC_P7,  KC_P8, KC_P9,  KC_PPLS,
+      KC_SELECT, KC_COPY,   KC_LCTL,   KC_A,KC_S,KC_D,KC_F,KC_G,KC_H,KC_J,KC_K,KC_L,KC_SCLN,KC_QUOT,     KC_ENT,                               KC_P4,  KC_P5, KC_P6,
+      KC_EXECUTE,KC_PASTE,  KC_LSFT,     KC_Z,KC_X,KC_C,KC_V,KC_B,KC_N,KC_M,KC_COMM,KC_DOT,KC_SLSH,      KC_RSFT,            KC_UP,            KC_P1,  KC_P2, KC_P3,  KC_PENT,
+      KC_FIND,   KC_CUT,    KC_CAPS,KC_LALT,KC_LGUI,KC_HENK,    KC_SPC,     KC_MHEN,KC_KANA,KC_RGUI,KC_APP,KC_RALT,  KC_LEFT,KC_DOWN,KC_RGHT,      KC_P0,     KC_PDOT
+                 ),
+};

+ 0 - 0
keyboards/converter/sun_usb/type5/rules.mk


+ 148 - 0
keyboards/converter/sun_usb/type5/type5.h

@@ -0,0 +1,148 @@
+/*
+  Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+  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 <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef TYPE5_H
+#define TYPE5_H
+
+#include "quantum.h"
+
+/* sun type 5 keyboard, JP Unix-style
+,-------.  ,---,  ,---------------. ,---------------. ,---------------.   ,-----------. ,---------------.
+|   76  |  | 0F|  | 05| 06| 08| 0A| | 0C| 0E| 10| 11| | 12| 07| 09| 0B|   | 16| 17| 15| | 2D| 02| 04| 30|
+`-------'  `---'  `---------------' `---------------' `---------------'   `-----------' `---------------'
+,-------.  ,-----------------------------------------------------------.  ,-----------. ,---------------.
+| 01| 03|  | 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 58| 2A|  | 2C| 34| 60| | 62| 2E| 2F| 47|
+|-------|  |-----------------------------------------------------------|  |------------ |---------------|
+| 19| 1A|  |  35 | 36| 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 2B  |  | 42| 4A| 7B| | 44| 45| 46|   |
+|-------|  |-----------------------------------------------------------|  `-----------' |-----------| 7D|
+| 31| 33|  |  4C  | 4D| 4E| 4F| 50| 51| 52| 53| 54| 55| 56| 57|   59   |                | 5B| 5C| 5D|   |
+|-------|  |-----------------------------------------------------------|      ,---.     |-----------|---|
+| 48| 49|  |   63   | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D|    6E    |      | 14|     | 70| 71| 72|   |
+|-------|  |-----------------------------------------------------------|  .-----------. |-----------| 5A|
+| 5F| 61|  | 77 | 13| 78 |*73 |       79         |*74 |*75| 7A | 43| 0D|  | 18| 1B| 1C| |   5E  | 32|   |
+`-------'  `-----------------------------------------------------------'  `-----------' `---------------'
+*/
+#define LAYOUT_jp_unix(                                                 \
+      K76,    K0F,  K05,K06,K08,K0A,   K0C,K0E,K10,K11,   K12,K07,K09,K0B,  K16,K17,K15,  K2D,K02,K04,K30, \
+    K01,K03,  K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A,  K2C,K34,K60,  K62,K2E,K2F,K47, \
+    K19,K1A,  K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,   K2B,  K42,K4A,K7B,  K44,K45,K46,K7D, \
+    K31,K33,  K4C,  K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57,      K59,                K5B,K5C,K5D,     \
+    K48,K49,  K63,   K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D,         K6E,      K14,      K70,K71,K72,K5A, \
+    K5F,K61,  K77,K13, K78, K73,        K79,      K74, K75, K7A, K43, K0D,  K18,K1B,K1C,  K5E,    K32      \
+) { \
+    { KC_NO,  K01 ,  K02 ,  K03 ,  K04 ,  K05 ,  K06 ,  K07  }, \
+    {  K08 ,  K09 ,  K0A ,  K0B ,  K0C ,  K0D ,  K0E ,  K0F ,}, \
+    {  K10 ,  K11 ,  K12 ,  K13 ,  K14 ,  K15 ,  K16 ,  K17  }, \
+    {  K18 ,  K19 ,  K1A ,  K1B ,  K1C ,  K1D ,  K1E ,  K1F  }, \
+    {  K20 ,  K21 ,  K22 ,  K23 ,  K24 ,  K25 ,  K26 ,  K27  }, \
+    {  K28 ,  K29 ,  K2A ,  K2B ,  K2C ,  K2D ,  K2E ,  K2F  }, \
+    {  K30 ,  K31 ,  K32 ,  K33 ,  K34 ,  K35 ,  K36 ,  K37  }, \
+    {  K38 ,  K39 ,  K3A ,  K3B ,  K3C ,  K3D ,  K3E ,  K3F  }, \
+    {  K40 ,  K41 ,  K42 ,  K43 ,  K44 ,  K45 ,  K46 ,  K47  }, \
+    {  K48 ,  K49 ,  K4A , KC_NO,  K4C ,  K4D ,  K4E ,  K4F  }, \
+    {  K50 ,  K51 ,  K52 ,  K53 ,  K54 ,  K55 ,  K56 ,  K57  }, \
+    {  K58 ,  K59 ,  K5A ,  K5B ,  K5C ,  K5D ,  K5E ,  K5F  }, \
+    {  K60 ,  K61 ,  K62 ,  K63 ,  K64 ,  K65 ,  K66 ,  K67  }, \
+    {  K68 ,  K69 ,  K6A ,  K6B ,  K6C ,  K6D ,  K6E , KC_NO }, \
+    {  K70 ,  K71 ,  K72 ,  K73 ,  K74 ,  K75 ,  K76 ,  K77  }, \
+    {  K78 ,  K79 ,  K7A ,  K7B , KC_NO,  K7D , KC_NO, KC_NO }  \
+}
+
+/* Sun type 5 keyboard, US Unix-style
+,-------.  ,---,  ,---------------. ,---------------. ,---------------.   ,-----------. ,---------------.
+|   76  |  | 0F|  | 05| 06| 08| 0A| | 0C| 0E| 10| 11| | 12| 07| 09| 0B|   | 16| 17| 15| | 2D| 02| 04| 30|
+`-------'  `---'  `---------------' `---------------' `---------------'   `-----------' `---------------'
+,-------.  ,-----------------------------------------------------------.  ,-----------. ,---------------.
+| 01| 03|  | 1D| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29| 58| 2A|  | 2C| 34| 60| | 62| 2E| 2F| 47|
+|-------|  |-----------------------------------------------------------|  |------------ |---------------|
+| 19| 1A|  |  35 | 36| 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 2B  |  | 42| 4A| 7B| | 44| 45| 46|   |
+|-------|  |-----------------------------------------------------------|  `-----------' |-----------| 7D|
+| 31| 33|  |  4C  | 4D| 4E| 4F| 50| 51| 52| 53| 54| 55| 56| 57|   59   |                | 5B| 5C| 5D|   |
+|-------|  |-----------------------------------------------------------|      ,---.     |-----------|---|
+| 48| 49|  |   63   | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D|    6E    |      | 14|     | 70| 71| 72|   |
+|-------|  |-----------------------------------------------------------|  .-----------. |-----------| 5A|
+| 5F| 61|  | 77 | 13| 78 |            79                 |  7A | 43| 0D|  | 18| 1B| 1C| |   5E  | 32|   |
+`-------'  `-----------------------------------------------------------'  `-----------' `---------------'
+*/
+#define LAYOUT_us_unix(                                                 \
+      K76,    K0F,  K05,K06,K08,K0A,   K0C,K0E,K10,K11,   K12,K07,K09,K0B,  K16,K17,K15,  K2D,K02,K04,K30, \
+    K01,K03,  K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A,  K2C,K34,K60,  K62,K2E,K2F,K47, \
+    K19,K1A,  K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,   K2B,  K42,K4A,K7B,  K44,K45,K46,K7D, \
+    K31,K33,  K4C,  K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57,      K59,                K5B,K5C,K5D,     \
+    K48,K49,  K63,   K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D,         K6E,      K14,      K70,K71,K72,K5A, \
+    K5F,K61,  K77,K13, K78,             K79,                K7A, K43, K0D,  K18,K1B,K1C,  K5E,    K32      \
+) { \
+    { KC_NO,  K01 ,  K02 ,  K03 ,  K04 ,  K05 ,  K06 ,  K07  }, \
+    {  K08 ,  K09 ,  K0A ,  K0B ,  K0C ,  K0D ,  K0E ,  K0F ,}, \
+    {  K10 ,  K11 ,  K12 ,  K13 ,  K14 ,  K15 ,  K16 ,  K17  }, \
+    {  K18 ,  K19 ,  K1A ,  K1B ,  K1C ,  K1D ,  K1E ,  K1F  }, \
+    {  K20 ,  K21 ,  K22 ,  K23 ,  K24 ,  K25 ,  K26 ,  K27  }, \
+    {  K28 ,  K29 ,  K2A ,  K2B ,  K2C ,  K2D ,  K2E ,  K2F  }, \
+    {  K30 ,  K31 ,  K32 ,  K33 ,  K34 ,  K35 ,  K36 ,  K37  }, \
+    {  K38 ,  K39 ,  K3A ,  K3B ,  K3C ,  K3D ,  K3E ,  K3F  }, \
+    {  K40 ,  K41 ,  K42 ,  K43 ,  K44 ,  K45 ,  K46 ,  K47  }, \
+    {  K48 ,  K49 ,  K4A , KC_NO,  K4C ,  K4D ,  K4E ,  K4F  }, \
+    {  K50 ,  K51 ,  K52 ,  K53 ,  K54 ,  K55 ,  K56 ,  K57  }, \
+    {  K58 ,  K59 ,  K5A ,  K5B ,  K5C ,  K5D ,  K5E ,  K5F  }, \
+    {  K60 ,  K61 ,  K62 ,  K63 ,  K64 ,  K65 ,  K66 ,  K67  }, \
+    {  K68 ,  K69 ,  K6A ,  K6B ,  K6C ,  K6D ,  K6E , KC_NO }, \
+    {  K70 ,  K71 ,  K72 , KC_NO, KC_NO, KC_NO,  K76 ,  K77  }, \
+    {  K78 ,  K79 ,  K7A ,  K7B , KC_NO,  K7D , KC_NO, KC_NO }  \
+}
+
+/* Sun type 5 keyboard, US ANSI-style
+   ,-------.  ,---,  ,---------------. ,---------------. ,---------------.   ,-----------. ,---------------.
+   |   76  |  | 1D|  | 05| 06| 08| 0A| | 0C| 0E| 10| 11| | 12| 07| 09| 0B|   | 16| 17| 15| | 2D| 02| 04| 30|
+   `-------'  `---'  `---------------' `---------------' `---------------'   `-----------' `---------------'
+   ,-------.  ,-----------------------------------------------------------.  ,-----------. ,---------------.
+   | 01| 03|  | 2A| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 29|   2B  |  | 2C| 34| 60| | 62| 2E| 2F| 47|
+   |-------|  |-----------------------------------------------------------|  |------------ |---------------|
+   | 19| 1A|  |  35 | 36| 37| 38| 39| 3A| 3B| 3C| 3D| 3E| 3F| 40| 41| 58  |  | 42| 4A| 7B| | 44| 45| 46|   |
+   |-------|  |-----------------------------------------------------------|  `-----------' |-----------| 7D|
+   | 31| 33|  |  77  | 4D| 4E| 4F| 50| 51| 52| 53| 54| 55| 56| 57|   59   |                | 5B| 5C| 5D|   |
+   |-------|  |-----------------------------------------------------------|      ,---.     |-----------|---|
+   | 48| 49|  |   63   | 64| 65| 66| 67| 68| 69| 6A| 6B| 6C| 6D|    6E    |      | 14|     | 70| 71| 72|   |
+   |-------|  |-----------------------------------------------------------|  .-----------. |-----------| 5A|
+   | 5F| 61|  |  4C  | 13| 78 |              79              | 7A | 43| 0D|  | 18| 1B| 1C| |   5E  | 32|   |
+   `-------'  `-----------------------------------------------------------'  `-----------' `---------------'
+*/
+#define LAYOUT_ansi(                                                    \
+      K76,    K1D,  K05,K06,K08,K0A,   K0C,K0E,K10,K11,   K12,K07,K09,K0B,  K16,K17,K15,  K2D,K02,K04,K30, \
+    K01,K03,  K2A,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,    K2B,  K2C,K34,K60,  K62,K2E,K2F,K47, \
+    K19,K1A,  K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,   K58,  K42,K4A,K7B,  K44,K45,K46,K7D, \
+    K31,K33,  K77,  K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57,      K59,                K5B,K5C,K5D,     \
+    K48,K49,  K63,   K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D,         K6E,      K14,      K70,K71,K72,K5A, \
+    K5F,K61,  K4C,K13, K78,              K79,               K7A, K43, K0D,  K18,K1B,K1C,  K5E,    K32      \
+) { \
+    { KC_NO,  K01 ,  K02 ,  K03 ,  K04 ,  K05 ,  K06 ,  K07  }, \
+    {  K08 ,  K09 ,  K0A ,  K0B ,  K0C ,  K0D ,  K0E , KC_NO,}, \
+    {  K10 ,  K11 ,  K12 ,  K13 ,  K14 ,  K15 ,  K16 ,  K17  }, \
+    {  K18 ,  K19 ,  K1A ,  K1B ,  K1C ,  K1D ,  K1E ,  K1F  }, \
+    {  K20 ,  K21 ,  K22 ,  K23 ,  K24 ,  K25 ,  K26 ,  K27  }, \
+    {  K28 ,  K29 ,  K2A ,  K2B ,  K2C ,  K2D ,  K2E ,  K2F  }, \
+    {  K30 ,  K31 ,  K32 ,  K33 ,  K34 ,  K35 ,  K36 ,  K37  }, \
+    {  K38 ,  K39 ,  K3A ,  K3B ,  K3C ,  K3D ,  K3E ,  K3F  }, \
+    {  K40 ,  K41 ,  K42 ,  K43 ,  K44 ,  K45 ,  K46 ,  K47  }, \
+    {  K48 ,  K49 ,  K4A , KC_NO,  K4C ,  K4D ,  K4E ,  K4F  }, \
+    {  K50 ,  K51 ,  K52 ,  K53 ,  K54 ,  K55 ,  K56 ,  K57  }, \
+    {  K58 ,  K59 ,  K5A ,  K5B ,  K5C ,  K5D ,  K5E ,  K5F  }, \
+    {  K60 ,  K61 ,  K62 ,  K63 ,  K64 ,  K65 ,  K66 ,  K67  }, \
+    {  K68 ,  K69 ,  K6A ,  K6B ,  K6C ,  K6D ,  K6E , KC_NO }, \
+    {  K70 ,  K71 ,  K72 , KC_NO, KC_NO, KC_NO,  K76 ,  K77  }, \
+    {  K78 ,  K79 ,  K7A ,  K7B , KC_NO,  K7D , KC_NO, KC_NO }  \
+}
+#endif