From: tmk Date: Sun, 22 May 2016 13:49:29 +0000 (+0900) Subject: Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' X-Git-Url: https://git.gir.st/tmk_keyboard.git/commitdiff_plain/3fe8e1c238fc8e15dacda1b03c0c1745a7b8e8e7?hp=20b787fc1284176834cbe7ca2134e4b36bec5828 Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828' --- diff --git a/README.md b/README.md index f460d0ed..7edce607 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,21 @@ -TMK Keyboard Firmware Core Library -================================== -This is a keyboard firmware library with some useful features for Atmel AVR and Cortex-M. +TMK Keyboard Firmware Collection +================================ +This is a keyboard firmware with some useful features for Atmel AVR controller. -Source code is available here: +Source code is available here: Updates ------- #### 2016/02/10 -flabbergast's Chibios protocol was merged from . See [protocol/chibios/README.md](protocol/chibios/README.md). Chibios protocol supports Cortex-M such as STM32 and Kinetis. +core: flabbergast's Chibios protocol was merged from (@72b1668). See [tmk_core/protocol/chibios/README.md](tmk_core/protocol/chibios/README.md). Chibios protocol supports Cortex-M such as STM32 and Kinetis. #### 2015/04/22 -separated with TMK Keyboard Firmware Collection +Core library was separated to other branch `core`. + +In `Makefile` you need to set `TMK_DIR` to indicate core library location now. + + TMK_DIR = ../../tmk_core @@ -37,60 +41,180 @@ These features can be used in your keyboard. -TMK Keyboard Firmware Collection --------------------------------- -Complete firmwares for various keyboards and protocol converters. - - +Projects +-------- +You can find some keyboard specific projects under `converter` and `keyboard` directory. + +### converter +* [ps2_usb](converter/ps2_usb/) - [PS/2 keyboard to USB][GH_ps2] +* [adb_usb](converter/adb_usb/) - [ADB keyboard to USB][GH_adb] +* [m0110_usb](converter/m0110_usb) - [Macintosh 128K/512K/Plus keyboard to USB][GH_m0110] +* [terminal_usb](converter/terminal_usb/) - [IBM Model M terminal keyboard(PS/2 scancode set3) to USB][GH_terminal] +* [news_usb](converter/news_usb/) - [Sony NEWS keyboard to USB][GH_news] +* [x68k_usb](converter/x68k_usb/) - [Sharp X68000 keyboard to USB][GH_x68k] +* [sun_usb](converter/sun_usb/) - [Sun] to USB(type4, 5 and 3?) +* [pc98_usb](converter/pc98_usb/) - [PC98] to USB +* [usb_usb](converter/usb_usb/) - USB to USB(experimental) +* [ascii_usb](converter/ascii_usb/) - ASCII(Serial console terminal) to USB +* [ibm4704_usb](converter/ibm4704_usb) - [IBM 4704 keyboard Converter][GH_ibm4704] + +### keyboard +* [hhkb](keyboard/hhkb/) - [Happy Hacking Keyboard pro][GH_hhkb] **my main board** +* [gh60](keyboard/gh60/) - [GH60] DIY 60% keyboard [prototype][GH60_proto] **my second board** +* [hbkb](keyboard/hbkb/) - [Happy Buckling spring keyboard][GH_hbkb](IBM Model M 60% mod) +* [hid_liber](keyboard/hid_liber/) - [HID liberation][HID_liber] controller (by alaricljs) +* [phantom](keyboard/phantom/) - [Phantom] keyboard (by Tranquilite) +* [IIgs_Standard](keyboard/IIgs/) - Apple [IIGS] keyboard mod(by JeffreySung) +* [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired] +* [KMAC](keyboard/kmac/) - Korean custom keyboard +* [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard +* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity] +* [NerD](keyboard/nerd/) - Korean custom keyboard +* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller +* [Lightpad](keyboard/lightpad) - Korean custom keypad +* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt] + +### External projects using tmk_keyboard +* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org] +* [mcdox][mcdox_tmk] - [mcdox][mcdox] + + +[GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930 +[GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047 +[GH_ps2]: http://geekhack.org/showwiki.php?title=Island:14618 +[GH_adb]: http://geekhack.org/showwiki.php?title=Island:14290 +[GH_hhkb_bt]: http://geekhack.org/showwiki.php?title=Island:20851 +[GH_m0110]: http://geekhack.org/showwiki.php?title=Island:24965 +[GH_news]: http://geekhack.org/showwiki.php?title=Island:25759 +[GH_terminal]: http://geekhack.org/showwiki.php?title=Island:27272 +[GH_x68k]: http://geekhack.org/showwiki.php?title=Island:29060 +[GH_hbkb]: http://geekhack.org/showwiki.php?title=Island:29483 +[GH_ibm4704]: http://geekhack.org/index.php?topic=54706.0 +[HID_liber]: http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions +[Phantom]: http://geekhack.org/index.php?topic=26742 +[GH60]: http://geekhack.org/index.php?topic=34959 +[GH60_proto]: http://geekhack.org/index.php?topic=37570.0 +[PC98]: http://en.wikipedia.org/wiki/NEC_PC-9801 +[Sun]: http://en.wikipedia.org/wiki/Sun-3 +[IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS +[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit +[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid +[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/ +[ergodox_org]: http://ergodox.org/ +[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox +[mcdox]: https://github.com/DavidMcEwan/mcdox +[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox License ------- **GPLv2** or later. Some protocol files are under **Modified BSD License**. -LUFA, PJRC and V-USB stack have their own license respectively. + +Third party libraries like LUFA, PJRC and V-USB have their own license respectively. Build Firmware and Program Controller ------------------------------------- -See [doc/build.md](doc/build.md). +See [tmk_core/doc/build.md](tmk_core/doc/build.md). + + + +Change your keymap +------------------ +See [tmk_core/doc/keymap.md](tmk_core/doc/keymap.md). + + + +Magic Commands +-------------- +To see help press `Magic` + `H`. + +`Magic` key combination is `LShift` + `RShift` in many project, but `Power` key on ADB converter. +`Magic` keybind can be vary on each project, check `config.h` in project directory. + +Following commands can be also executed with `Magic` + key. In console mode `Magic` keybind is not needed. + + ----- Command Help ----- + c: enter console mode + d: toggle debug enable + x: toggle matrix debug + k: toggle keyboard debug + m: toggle mouse debug + v: print device version & info + t: print timer count + s: print status + e: print eeprom config + n: toggle NKRO + 0/F10: switch to Layer0 + 1/F1: switch to Layer1 + 2/F2: switch to Layer2 + 3/F3: switch to Layer3 + 4/F4: switch to Layer4 + PScr: power down/remote wake-up + Caps: Lock Keyboard(Child Proof) + Paus: jump to bootloader + + + +Boot Magic Configuration - Virtual DIP Switch +--------------------------------------------- +Boot Magic are executed during boot up time. Press Magic key below then plug in keyboard cable. +Note that you must use keys of **Layer 0** as Magic keys. These settings are stored in EEPROM so that retain your configure over power cycles. + +To avoid configuring accidentally additive salt key `KC_SPACE` also needs to be pressed along with the following configuration keys. The salt key is configurable in `config.h`. See [tmk_core/common/bootmagic.h](tmk_core/common/bootmagic.h). + +#### General +- Skip reading EEPROM to start with default configuration(`ESC`) +- Clear configuration stored in EEPROM to reset configuration(`Backspace`) + +#### Bootloader +- Kick up Bootloader(`B`) + +#### Debug +- Debug enable(`D`) +- Debug matrix enable(`D`+`X`) +- Debug keyboard enable(`D`+`K`) +- Debug mouse enable(`D`+`M`) + +#### Keymap +- Swap Control and CapsLock(`Left Control`) +- Change CapsLock to Control(`Caps Lock`) +- Swap LeftAlt and Gui(`Left Alt`) +- Swap RightAlt and Gui(`Right Alt`) +- Disable Gui(`Left Gui`) +- Swap Grave and Escape(`Grave`) +- Swap BackSlash and BackSpace(`Back Slash`) +- Enable NKRO on boot(`N`) + +#### Default Layer +- Set Default Layer to 0(`0`) +- Set Default Layer to 1(`1`) +- Set Default Layer to 2(`2`) +- Set Default Layer to 3(`3`) +- Set Default Layer to 4(`4`) +- Set Default Layer to 5(`5`) +- Set Default Layer to 6(`6`) +- Set Default Layer to 7(`7`) + + + +Mechanical Locking support +-------------------------- +This feature makes it possible for you to use mechanical locking switch for `CapsLock`, `NumLock` +or `ScrollLock`. To enable this feature define these macros in `config.h` and use `KC_LCAP`, `KC_LN +UM` or `KC_LSCR` in keymap for locking key instead of normal `KC_CAPS`, `KC_NLCK` or `KC_SLCK`. Res +ync option tries to keep switch state consistent with keyboard LED state. + + #define LOCKING_SUPPORT_ENABLE + #define LOCKING_RESYNC_ENABLE Start Your Own Project ----------------------- **TBD** -### Config.h Options -#### 1. USB vendor/product ID and device description - #define VENDOR_ID 0xFEED - #define PRODUCT_ID 0xBEEF - #define MANUFACTURER t.m.k. - #define PRODUCT Macway mod - #define DESCRIPTION t.m.k. keyboard firmware for Macway mod - -#### 2. Keyboard matrix configuration - #define MATRIX_ROWS 8 - #define MATRIX_COLS 8 - #define MATRIX_HAS_GHOST - - - -Architecture ------------- - Architecture Diagram - +---------------+---------------+-------------+ - | Host | Keyboard | Matrix, LED | - ___________ |-----------+-+ +-------------+ | +-----------| - / /| Keys/Mouse | Protocol |d| | Action | | | Protocol | - /__________/ |<-----------| LUFA |r| | Layer, Tap | | | Matrix | - |.--------.| | LED | V-USB |i| |-------------| | | PS/2,IBM | __________________ - || || |----------->| PJRC |v| | Keymap | | | ADB,M0110| Keys / /_/_/_/_/_/_/_/ /| - || Host || | Console | iWRAP(BT)|e| | Mousekey | | | SUN/NEWS |<----------/ /_/_/_/_/_/_/_/ / / - ||________||/.<-----------| UART |r| | Report | | | X68K/PC98| Control / /_/_/_/_/_/_/_/ / / - `_========_'/| |---------------------------------------------|-------->/___ /_______/ ___/ / - |_o______o_|/ | Sendchar, Print, Debug, Command, ... | |_________________|/ - +---------------------------------------------+ Keyboard @@ -98,53 +222,26 @@ Debugging -------- Use PJRC's `hid_listen` to see debug messages. You can use the tool for debug even if firmware use LUFA stack. -You can use xprintf() to display debug info on `hid_listen`, see `common/xprintf.h`. +You can use xprintf() to display debug info on `hid_listen`, see `tmk_core/common/xprintf.h`. Files and Directories ------------------- ### Top -* common/ - common codes -* protocol/ - keyboard protocol support -* doc/ - documents -* common.mk - Makefile for common -* protocol.mk - Makefile for protocol -* rules.mk - Makefile for build rules - -### Common -* host.h -* host_driver.h -* keyboard.h -* command.h -* keymap.h -* action.h -* keycode.h -* matrix.h -* led.h -* mousekey.h -* report.h -* debug.h -* print.h -* bootloader.h -* sendchar.h -* timer.h -* util.h - -### Keyboard Protocols -* lufa/ - LUFA USB stack -* pjrc/ - PJRC USB stack -* vusb/ - Objective Development V-USB -* iwrap/ - Bluetooth HID for Bluegiga iWRAP -* ps2.c - PS/2 protocol -* adb.c - Apple Desktop Bus protocol -* m0110.c - Macintosh 128K/512K/Plus keyboard protocol -* news.c - Sony NEWS keyboard protocol -* x68k.c - Sharp X68000 keyboard protocol -* serial_soft.c - Asynchronous Serial protocol implemented by software +* keyboard/ - keyboard projects +* converter/ - protocol converter projects +* tmk_core/ - core library +* tmk_core/doc/ - documents Coding Style ------------- - Doesn't use Tab to indent, use 4-spaces instead. + + + +Other Keyboard Firmware Projects +------------------ +You can learn a lot about keyboard firmware from these. See [Other Projects](https://github.com/tmk/tmk_keyboard/wiki/Other-Projects) other than TMK. diff --git a/converter/adb_usb/Makefile b/converter/adb_usb/Makefile new file mode 100644 index 00000000..76e10950 --- /dev/null +++ b/converter/adb_usb/Makefile @@ -0,0 +1,143 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = adb_usb_lufa + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap_common.c \ + matrix.c \ + led.c \ + adb.c + +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_plain.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +# atmega32u4 Teensy2.0 +# atemga32u4 TMK Converter rev.1 +# atemga32u2 TMK Converter rev.2 +MCU = atmega32u2 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 for TMK Converter rev.1/rev.2 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # 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 +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover +ADB_MOUSE_ENABLE = yes + +# ADB Mice need acceleration for todays much bigger screens. +OPT_DEFS += -DADB_MOUSE_MAXACC=8 + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/adb_usb/Makefile.rev1 b/converter/adb_usb/Makefile.rev1 new file mode 100644 index 00000000..1cd539b6 --- /dev/null +++ b/converter/adb_usb/Makefile.rev1 @@ -0,0 +1,143 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = adb_usb_lufa + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap_common.c \ + matrix.c \ + led.c \ + adb.c + +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_ansi.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +# atmega32u4 Teensy2.0 +# atemga32u4 TMK Converter rev.1 +# atemga32u2 TMK Converter rev.2 +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 for TMK Converter rev.1/rev.2 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # 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 +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover +ADB_MOUSE_ENABLE = yes + +# ADB Mice need acceleration for todays much bigger screens. +OPT_DEFS += -DADB_MOUSE_MAXACC=8 + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/adb_usb/Makefile.teensy b/converter/adb_usb/Makefile.teensy new file mode 100644 index 00000000..d97f0eb3 --- /dev/null +++ b/converter/adb_usb/Makefile.teensy @@ -0,0 +1,143 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = adb_usb_lufa + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap_common.c \ + matrix.c \ + led.c \ + adb.c + +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_ansi.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +# atmega32u4 Teensy2.0 +# atemga32u4 TMK Converter rev.1 +# atemga32u2 TMK Converter rev.2 +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 for TMK Converter rev.1/rev.2 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=512 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # 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 +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover +ADB_MOUSE_ENABLE = yes + +# ADB Mice need acceleration for todays much bigger screens. +OPT_DEFS += -DADB_MOUSE_MAXACC=8 + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/adb_usb/README.md b/converter/adb_usb/README.md new file mode 100644 index 00000000..034540c9 --- /dev/null +++ b/converter/adb_usb/README.md @@ -0,0 +1,116 @@ +ADB to USB keyboard converter +============================= +This firmware converts Apple ADB keyboard protocol to USB. You can use TMK Converter, PJRC Teensy2.0 and other USB AVR MCU(ATMega32U4, AT90USB64/128 or etc) for this. But binary size is probably more than 10KB and it won't fit into 8K flash. + +Discuss: http://geekhack.org/showwiki.php?title=Island:14290 + +TMK Converter: https://geekhack.org/index.php?topic=72052.0 + + + +README FIRST +------------ +https://github.com/tmk/tmk_keyboard +https://github.com/tmk/tmk_keyboard/tree/master/converter/adb_usb + +Also check these when you are in trouble. + +https://github.com/tmk/tmk_keyboard/wiki +https://github.com/tmk/tmk_keyboard/labels/NOTE + + +Wiring +------ +Connect ADB pins to controller just by 3 lines(Vcc, GND, Data). By default Data line uses port PD0. + +ADB female socket from the front: + + ,--_--. + / o4 3o \ 1: DATA + | o2 1o | 2: Power SW + - === - 3: VCC + `-___-' 4: GND + +This converter uses AVR's internal pull-up, but it seems to be too weak, in particular when you want to use a long or coiled cable. The external pull-up resistor(1K-10K Ohm) on Data is strongly recommended.(It is almost must!) +https://github.com/tmk/tmk_keyboard/wiki/FAQ#pull-up-resistor + +Pull-up resister: + + Keyboard Conveter + ,------. + 5V------+------|VCC | + | | | + [R] | | + | | | + Signal--+------|PD0 | + | | + GND------------|GND | + `------' + R: 1K Ohm resistor + + +Define following macros for ADB connection in config.h if you use other than port PD0. + + ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT + + +Build firmware and Program microcontroller +------------------------------------------ +See [doc/build.md](../../tmk_core/doc/build.md). + +To build firmware and program TMK Converter run these commands: + + $ make -f Makefile clean + $ make -f Makefile [KEYMAP=(plain|ansi|iso|hasu)] + $ make -f Makefile [KEYMAP=(plain|ansi|iso|hasu)] dfu + +You can select keymap with optional `KEYMAP=` (plain is default). Push button on the converter before running `dfu` target. + +Use **Makefile.rev1** for old TMK Converter rev.1 and **Makefile.teensy** for Teensy2.0 instead of **Makefile**. For TMK Converter rev.2 just use **Makefile**. + +To program Teensy you can use `teensy` target: + + $ make -f Makefile.teensy [KEYMAP=(plain|ansi|iso|hasu)] teensy + + + +Keymap +------ +You can change a keymap by editing code of keymap_[plain|ansi|iso|hasu|yours].c. +How to define the keymap is probably obvious. You can find key symbols in common/keycode.h. And see [doc/keymap.md](../../tmk_core/doc/keymap.md) for more detail. + + +Magic command +------------- +To get help press `h` holding Magic key. Magic key is `Power key`. + + +Locking CapsLock +---------------- +Many of old ADB keyboards have mechanical push-lock switch for Capslock key and this converter supports the locking Capslock key by default. See README in top directory for more detail about this feature. +https://github.com/tmk/tmk_keyboard/blob/master/README.md#mechanical-locking-support + +Also you may want to remove locking pin from the push-lock switch to use capslock as a normal momentary switch. + + +Mouse support +------------- +ADB mouse support was added by @mek-apelsin on Apr,2015. It supports only one button as of now. +https://github.com/tmk/tmk_keyboard/pull/207 + + +Notes +----- +Not-extended ADB keyboards have no discrimination between right modifier and left one, +you will always see left control even if you press right control key. +Apple Extended Keyboard and Apple Extended Keyboard II can discriminate both side +modifiers except for GUI key(Windows/Command). + +And most ADB keyboard has no diodes in its matrix so they are not NKRO, +though ADB protocol itself supports it. See protocol/adb.c for more info. + +If keyboard has ISO layout you may have swapped keys problem, see this for the detail. + +https://github.com/tmk/tmk_keyboard/issues/35 + +EOF diff --git a/converter/adb_usb/config.h b/converter/adb_usb/config.h new file mode 100644 index 00000000..5ce5c221 --- /dev/null +++ b/converter/adb_usb/config.h @@ -0,0 +1,63 @@ +/* +Copyright 2011 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x0ADB +#define DEVICE_VER 0x0101 +#define MANUFACTURER t.m.k. +#define PRODUCT ADB keyboard converter +#define DESCRIPTION convert ADB keyboard to USB + +/* matrix size */ +#define MATRIX_ROWS 16 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + +#define MATRIX_ROW(code) ((code)>>3&0x0F) +#define MATRIX_COL(code) ((code)&0x07) + + +/* 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 + + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + + +/* ADB port setting */ +#define ADB_PORT PORTD +#define ADB_PIN PIND +#define ADB_DDR DDRD +#define ADB_DATA_BIT 0 +//#define ADB_PSW_BIT 1 // optional + +/* key combination for command */ +#ifndef __ASSEMBLER__ +#include "adb.h" +#include "matrix.h" +#define IS_COMMAND() ( \ + matrix_is_on(MATRIX_ROW(ADB_POWER), MATRIX_COL(ADB_POWER)) \ +) +#endif + +#endif diff --git a/converter/adb_usb/keymap_ansi.c b/converter/adb_usb/keymap_ansi.c new file mode 100644 index 00000000..aa993192 --- /dev/null +++ b/converter/adb_usb/keymap_ansi.c @@ -0,0 +1,16 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP_EXT_ANSI( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PMNS, + LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/converter/adb_usb/keymap_common.c b/converter/adb_usb/keymap_common.c new file mode 100644 index 00000000..55a13793 --- /dev/null +++ b/converter/adb_usb/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2011,2012,2013 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 "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/adb_usb/keymap_common.h b/converter/adb_usb/keymap_common.h new file mode 100644 index 00000000..0a917cbc --- /dev/null +++ b/converter/adb_usb/keymap_common.h @@ -0,0 +1,297 @@ +/* +Copyright 2011,2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* Common layout: ANSI+ISO + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr| + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP( \ + K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K2A, K75,K77,K79, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K24, K56,K57,K58,K45, \ + K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \ + K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_PENT, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_F17, KC_##K41, KC_NO, KC_##K43, KC_F18, KC_##K45, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_F18 }, \ + { KC_F19, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_F20, KC_##K5B, KC_##K5C, KC_INT3, KC_INT1, KC_PCMM }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_LANG2, KC_##K67 }, \ + { KC_LANG1, KC_##K69, KC_F16, KC_##K6B, KC_NO, KC_##K6D, KC_APP, KC_##K6F }, \ + { KC_NO, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO, KC_##K7F } \ +} + + +/* M0115 Apple Extended Keyboard ANSI + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr| + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP_EXT_ANSI( \ + K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K2A, K75,K77,K79, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K24, K56,K57,K58,K45, \ + K38,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \ + K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_NUBS, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_PENT, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_F17, KC_##K41, KC_NO, KC_##K43, KC_F18, KC_##K45, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_F18 }, \ + { KC_F19, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_F20, KC_##K5B, KC_##K5C, KC_INT3, KC_INT1, KC_PCMM }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_LANG2, KC_##K67 }, \ + { KC_LANG1, KC_##K69, KC_F16, KC_##K6B, KC_NO, KC_##K6D, KC_APP, KC_##K6F }, \ + { KC_NO, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO, KC_##K7F } \ +} + +/* M0115 Apple Extended Keyboard ISO + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr| + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Retur| |Del|End|PgD| | 7| 8| 9| -| + * |------------------------------------------------------` | `-----------' |---------------| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #| | | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shif| \| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP_EXT_ISO( \ + K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K7F, \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K72,K73,K74, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K24, K75,K77,K79, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A, K56,K57,K58,K45, \ + K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K3E, K53,K54,K55, \ + K36,K3A,K37, K31, K7C,K7D, K3B,K3D,K3C, K52, K41,K4C \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_PENT, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_F17, KC_##K41, KC_NO, KC_##K43, KC_F18, KC_##K45, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_F18 }, \ + { KC_F19, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_F20, KC_##K5B, KC_##K5C, KC_INT3, KC_INT1, KC_PCMM }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_LANG2, KC_##K67 }, \ + { KC_LANG1, KC_##K69, KC_F16, KC_##K6B, KC_NO, KC_##K6D, KC_APP, KC_##K6F }, \ + { KC_NO, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_NO, KC_##K7F } \ +} + + + + +/* M0116 Apple Standard Keyboard ANSI + * +-------+ + * | power | + * +-------+ + * +---+---+---+---+---+---+---+---+---+---+---+---+---+-----+ +---+---+---+---+ + * |esc| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | bks | |clr| = | / | * | + * +---------------------------------------------------------+ +---+---+---+---+ + * | tab | q | w | e | r | t | y | u | i | o | p | [ | ] | | | 7 | 8 | 9 | + | + * +-----------------------------------------------------+ | +---+---+---+---+ + * | ctrl | a | s | d | f | g | h | j | k | l | ; | ' |return| | 4 | 5 | 6 | - | + * +---------------------------------------------------------+ +---+---+---+---+ + * | shift | z | x | c | v | b | n | m | , | . | / | shift | | 1 | 2 | 3 | | + * +---------------------------------------------------------+ +-------+---|ent| + * |cap|opt|comnd| ` | | \ |lef|rig|dwn|up | | 0 | . | | + * +---------------------------------------------------------+ +-------+---+---+ + */ +#define KEYMAP_M0116_ANSI( \ + K7F, \ + K35,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E, K59,K5B,K5C,K45, \ + K36,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K24, K56,K57,K58,K4E, \ + K38,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K7B, K53,K54,K55, \ + K39,K3A,K37,K32, K31, K2A,K3B,K3C,K3D,K3E, K52, K41,K4C \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_NO, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_NO, KC_##K41, KC_NO, KC_##K43, KC_NO, KC_##K45, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_NO }, \ + { KC_NO, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO , KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO , KC_NO, KC_NO , KC_##K7B, KC_NO, KC_NO, KC_NO, KC_##K7F } \ +} + +/* M0118 Apple Standard Keyboard ISO + * +-------+ + * | power | + * +-------+ + * +---+---+---+---+---+---+---+---+---+---+---+---+---+-----+ +---+---+---+---+ + * |esc| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | bks | |clr| = | / | * | + * +---------------------------------------------------------+ +---+---+---+---+ + * | tab | q | w | e | r | t | y | u | i | o | p | [ | ] |Ret| | 7 | 8 | 9 | + | + * +-----------------------------------------------------` | +---+---+---+---+ + * | caps | a | s | d | f | g | h | j | k | l | ; | ' | # | | | 4 | 5 | 6 | - | + * +---------------------------------------------------------+ +---+---+---+---+ + * |shif| \ | z | x | c | v | b | n | m | , | . | / |Shif| up| | 1 | 2 | 3 | | + * +---------------------------------------------------------+ +-------+---|ent| + * |ctrl|opt |comnd| |comnd |lef|rig|dwn| | 0 | . | | + * +---------------------------------------------------------+ +-------+---+---+ + */ +#define KEYMAP_M0118_ISO( \ + K7F, \ + K35,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K51,K4B,K43, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E, K59,K5B,K5C,K45, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K2A,K24, K56,K57,K58,K4E, \ + K38,K0A,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C,K7B,K3E, K53,K54,K55, \ + K36,K3A,K37, K31, K3B,K3C,K3D, K52, K41,K4C \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_NO, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_NO, KC_##K41, KC_NO, KC_##K43, KC_NO, KC_##K45, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K4B, KC_##K4C, KC_NO, KC_##K4E, KC_NO }, \ + { KC_NO, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO , KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO , KC_NO, KC_NO , KC_##K7B, KC_NO, KC_NO, KC_NO, KC_##K7F } \ +} + +#endif + + +/* +ADB ANSI/ISO Keymapping Note +============================ +ANSI +,----------- ----------. +| *a| 1| 2 =|Backspa| +|----------- ----------| +|Tab | Q| | ]| *c| +|----------- ----------| +|CapsLo| A| '|Return | +|----------- ----------| +|Shift | Shift | +`----------- ----------' + +ISO +,----------- ----------. +| *a| 1| 2 =|Backspa| +|----------- ----------| +|Tab | Q| | ]|Retur| +|----------- -----` | +|CapsLo| A| '| *c| | +|----------- ----------| +|Shif| *b| Shift | +`----------- ----------' + +ADB Keyboard scan code: + ADB scan code USB usage + ------------- --------- +Key ANSI ISO ANSI ISO +--------------------------------------------- +*a 0x32 0x0A 0x35 0x35 +*b ---- 0x32 ---- 0x64 +*c 0x2A 0x2A 0x31 0x31(or 0x32) + + +TMK ADB-USB mapping: +ADB USB(ANSI) USB(ISO) +--------------------------------- +0x32 0x35 0x64 +0x0A ---- 0x35 +0x2A 0x31 0x31(or 0x32) + +Note that mappings of ADB code 0x32 are diffrent between ANSI and ISO keyboard. +https://github.com/tmk/tmk_keyboard/issues/35 + */ diff --git a/converter/adb_usb/keymap_hasu.c b/converter/adb_usb/keymap_hasu.c new file mode 100644 index 00000000..a0b3f1fc --- /dev/null +++ b/converter/adb_usb/keymap_hasu.c @@ -0,0 +1,58 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer: plain keymap + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | | + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Fn0| |Del|End|PgD| | 7| 8| 9| -| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Ctrl | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP_EXT_ANSI( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,FN0, DEL, END, PGDN, P7, P8, P9, PMNS, + LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RGUI,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Default Layer: plain keymap + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |` | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| | | + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * |Esc|F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Delete | |Ins|Hom|PgU| |NmL|Mb1|Mb2|Mb3| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U|PrS|ScL|Pau|Up |Ins| Fn0| |Del|End|PgD| |MwD|McU|MwU|MwD| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsLo|VoD|VoU|Mut| F| G| H| J|Hom|PgU|Lef|Rig|Return | |McL|McD|McR|MwU| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M|End|PgD|Dow|Shift | |PgU| |MwL|McD|MwR| | + * |-----------------------------------------------------------| ,-----------. |-----------|Mb3| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Ctrl | |Hom|PgD|End| | Mb1|Mb2| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP_EXT_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3, + TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, FN0, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_D, + LCAP,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U, + LSFT,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R, + LCTL,LGUI,LALT, SPC, RGUI,RCTL, HOME,PGDN,END, BTN1, BTN2,BTN3 + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_BSLS), +}; diff --git a/converter/adb_usb/keymap_iso.c b/converter/adb_usb/keymap_iso.c new file mode 100644 index 00000000..1ccb17e2 --- /dev/null +++ b/converter/adb_usb/keymap_iso.c @@ -0,0 +1,16 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP_EXT_ISO( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,ENT, DEL, END, PGDN, P7, P8, P9, PMNS, + LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6, PPLS, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/converter/adb_usb/keymap_plain.c b/converter/adb_usb/keymap_plain.c new file mode 100644 index 00000000..433a5cb3 --- /dev/null +++ b/converter/adb_usb/keymap_plain.c @@ -0,0 +1,42 @@ +#include "keymap_common.h" + + +/* + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,---. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr| + * `---' `---------------' `---------------' `---------------' `-----------' `---' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -| + * |-----------------------------------------------------------| `-----------' |---------------| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Opt |Cmd | Space | |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, NO, + FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,FN1, DEL, END, PGDN, P7, P8, P9, PMNS, + LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LALT,LGUI, SPC, RALT,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + [1] = KEYMAP( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, NO, + FN0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,BTN1,BTN2,BTN3, + TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, FN1, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_D, + LCAP,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, ENT, MS_L,MS_D,MS_R,WH_U, + LSFT,NUBS,Z, X, C, V, B, N, M, END, PGDN,DOWN, RSFT, PGUP, WH_L,MS_D,WH_R, + LCTL,LGUI,LALT, SPC, RGUI,RCTL, HOME,PGDN,END, BTN1, BTN2,BTN3 + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_GRV), + [1] = ACTION_LAYER_TAP_KEY(1, KC_BSLS), +}; diff --git a/converter/adb_usb/led.c b/converter/adb_usb/led.c new file mode 100644 index 00000000..3ee64a8e --- /dev/null +++ b/converter/adb_usb/led.c @@ -0,0 +1,27 @@ +/* +Copyright 2011 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 +#include +#include "adb.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + adb_host_kbd_led(~usb_led); +} diff --git a/converter/adb_usb/matrix.c b/converter/adb_usb/matrix.c new file mode 100644 index 00000000..abcc0cc9 --- /dev/null +++ b/converter/adb_usb/matrix.c @@ -0,0 +1,362 @@ +/* +Copyright 2011 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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "util.h" +#include "debug.h" +#include "adb.h" +#include "matrix.h" +#include "report.h" +#include "host.h" + + +#if (MATRIX_COLS > 16) +# error "MATRIX_COLS must not exceed 16" +#endif +#if (MATRIX_ROWS > 255) +# error "MATRIX_ROWS must not exceed 255" +#endif + + +static bool is_iso_layout = false; +static bool is_modified = false; +static report_mouse_t mouse_report = {}; + +// matrix state buffer(1:on, 0:off) +#if (MATRIX_COLS <= 8) +static uint8_t matrix[MATRIX_ROWS]; +#else +static uint16_t matrix[MATRIX_ROWS]; +#endif + +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif +static void register_key(uint8_t key); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + adb_host_init(); + // wait for keyboard to boot up and receive command + _delay_ms(1000); + + // Determine ISO keyboard by handle id + // http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L815 + uint16_t handle_id = adb_host_talk(ADB_ADDR_KEYBOARD, 3); + switch (handle_id) { + case 0x04: case 0x05: case 0x07: case 0x09: case 0x0D: + case 0x11: case 0x14: case 0x19: case 0x1D: case 0xC1: + case 0xC4: case 0xC7: + is_iso_layout = true; + break; + default: + is_iso_layout = false; + break; + } + + // Enable keyboard left/right modifier distinction + // Addr:Keyboard(0010), Cmd:Listen(10), Register3(11) + // upper byte: reserved bits 0000, device address 0010 + // lower byte: device handler 00000011 + adb_host_listen(0x2B,0x02,0x03); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + debug_enable = true; + //debug_matrix = true; + //debug_keyboard = true; + //debug_mouse = true; + print("debug enabled.\n"); + + // LED flash + DDRD |= (1<<6); PORTD |= (1<<6); + _delay_ms(500); + DDRD |= (1<<6); PORTD &= ~(1<<6); + + uint16_t handle_id2 = adb_host_talk(ADB_ADDR_KEYBOARD, 3); + xprintf("handle_id: %02X -> %02X\n", handle_id&0xff, handle_id2&0xff); + + return; +} + +#ifdef ADB_MOUSE_ENABLE + +#ifdef MAX +#undef MAX +#endif +#define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) + +void adb_mouse_task(void) +{ + uint16_t codes; + int16_t x, y; + static int8_t mouseacc; + _delay_ms(12); // delay for preventing overload of poor ADB keyboard controller + codes = adb_host_mouse_recv(); + // If nothing received reset mouse acceleration, and quit. + if (!codes) { + mouseacc = 1; + return; + }; + // Bit sixteen is button. + if (~codes & (1 << 15)) + mouse_report.buttons |= MOUSE_BTN1; + if (codes & (1 << 15)) + mouse_report.buttons &= ~MOUSE_BTN1; + // lower seven bits are movement, as signed int_7. + // low byte is X-axis, high byte is Y. + y = (codes>>8 & 0x3F); + x = (codes>>0 & 0x3F); + // bit seven and fifteen is negative + // usb does not use int_8, but int_7 (measuring distance) with sign-bit. + if (codes & (1 << 6)) + x = (x-0x40); + if (codes & (1 << 14)) + y = (y-0x40); + // Accelerate mouse. (They weren't meant to be used on screens larger than 320x200). + x *= mouseacc; + y *= mouseacc; + // Cap our two bytes per axis to one byte. + // Easier with a MIN-function, but since -MAX(-a,-b) = MIN(a,b)... + // I.E. MIN(MAX(x,-127),127) = -MAX(-MAX(x, -127), -127) = MIN(-MIN(-x,127),127) + mouse_report.x = -MAX(-MAX(x, -127), -127); + mouse_report.y = -MAX(-MAX(y, -127), -127); + if (debug_mouse) { + print("adb_host_mouse_recv: "); print_bin16(codes); print("\n"); + print("adb_mouse raw: ["); + phex(mouseacc); print(" "); + phex(mouse_report.buttons); print("|"); + print_decs(mouse_report.x); print(" "); + print_decs(mouse_report.y); print("]\n"); + } + // Send result by usb. + host_mouse_send(&mouse_report); + // increase acceleration of mouse + mouseacc += ( mouseacc < ADB_MOUSE_MAXACC ? 1 : 0 ); + return; +} +#endif + +uint8_t matrix_scan(void) +{ + /* extra_key is volatile and more convoluted than necessary because gcc refused + to generate valid code otherwise. Making extra_key uint8_t and constructing codes + here via codes = extra_key<<8 | 0xFF; would consistently fail to even LOAD + extra_key from memory, and leave garbage in the high byte of codes. I tried + dozens of code variations and it kept generating broken assembly output. So + beware if attempting to make extra_key code more logical and efficient. */ + static volatile uint16_t extra_key = 0xFFFF; + uint16_t codes; + uint8_t key0, key1; + + is_modified = false; + + codes = extra_key; + extra_key = 0xFFFF; + + if ( codes == 0xFFFF ) + { + _delay_ms(12); // delay for preventing overload of poor ADB keyboard controller + codes = adb_host_kbd_recv(); + } + key0 = codes>>8; + key1 = codes&0xFF; + + if (debug_matrix && codes) { + print("adb_host_kbd_recv: "); phex16(codes); print("\n"); + } + + if (codes == 0) { // no keys + return 0; + } else if (codes == 0x7F7F) { // power key press + register_key(0x7F); + } else if (codes == 0xFFFF) { // power key release + register_key(0xFF); + } else if (key0 == 0xFF) { // error + xprintf("adb_host_kbd_recv: ERROR(%d)\n", codes); + // something wrong or plug-in + matrix_init(); + return key1; + } else { + /* Swap codes for ISO keyboard + * + * ANSI + * ,----------- ----------. + * | *a| 1| 2 =|Backspa| + * |----------- ----------| + * |Tab | Q| | ]| *c| + * |----------- ----------| + * |CapsLo| A| '|Return | + * |----------- ----------| + * |Shift | Shift | + * `----------- ----------' + * + * ISO + * ,----------- ----------. + * | *a| 1| 2 =|Backspa| + * |----------- ----------| + * |Tab | Q| | ]|Retur| + * |----------- -----` | + * |CapsLo| A| '| *c| | + * |----------- ----------| + * |Shif| *b| Shift | + * `----------- ----------' + * + * ADB scan code USB usage + * ------------- --------- + * Key ANSI ISO ANSI ISO + * --------------------------------------------- + * *a 0x32 0x0A 0x35 0x35 + * *b ---- 0x32 ---- 0x64 + * *c 0x2A 0x2A 0x31 0x31(or 0x32) + */ + if (is_iso_layout) { + if (key0 == 0x32) { + key0 = 0x0A; + } else if (key0 == 0x0A) { + key0 = 0x32; + } + } + register_key(key0); + if (key1 != 0xFF) // key1 is 0xFF when no second key. + extra_key = key1<<8 | 0xFF; // process in a separate call + } + + return 1; +} + +bool matrix_is_modified(void) +{ + return is_modified; +} + +inline +bool matrix_has_ghost(void) +{ +#ifdef MATRIX_HAS_GHOST + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + if (matrix_has_ghost_in_row(i)) + return true; + } +#endif + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1<>3)&0x0F; + if (key&0x80) { + matrix[row] &= ~(1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x5C01 +#define DEVICE_VER 0x0100 +#define MANUFACTURER t.m.k. +#define PRODUCT ASCII keyboard converter +#define DESCRIPTION converts Serial Console Terminal into USB keyboard + + +/* matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 16 + +/* key combination for command */ +#define IS_COMMAND() ( \ + host_get_first_key() == KC_BRK \ +) + + +/* + * Serial(USART) configuration + * asynchronous, positive logic, 19200baud, bit order: LSB first + * 1-start bit, 8-data bit, odd parity, 1-stop bit + */ +#ifdef __AVR_ATmega32U4__ + #define SERIAL_UART_BAUD 19200 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B |= (1< + +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 +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "action_util.h" +#include "util.h" +#include "print.h" +#include "keymap.h" + + +// Keymap is not used. See matrix.c. + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return KC_NO; +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t) { .code = ACTION_NO }; +} diff --git a/converter/ascii_usb/led.c b/converter/ascii_usb/led.c new file mode 100644 index 00000000..d1c39bc6 --- /dev/null +++ b/converter/ascii_usb/led.c @@ -0,0 +1,25 @@ +/* +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) +{ +} diff --git a/converter/ascii_usb/matrix.c b/converter/ascii_usb/matrix.c new file mode 100644 index 00000000..e1ea8e0a --- /dev/null +++ b/converter/ascii_usb/matrix.c @@ -0,0 +1,195 @@ +/* +Copyright 2014 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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "matrix.h" +#include "debug.h" +#include "action_util.h" +#include "protocol/serial.h" + + +/* + * Not use Matrix. + * + * ROW: 16(4bits) + * COL: 16(4bits) + * + * 8bit wide + * +---------+ + * 0|00 ... 0F| + * 1|08 ... 1F| + * :| ... | + * :| ... | + * E|E0 ... EF| + * F|F0 ... FF| + * +---------+ + */ + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + debug_matrix = true; + serial_init(); + + debug("init\n"); + return; +} + +static void type_key(uint16_t keycode) +{ + if (keycode == 0) return; + + uint8_t mods = keycode>>8; + uint8_t key = keycode&0xFF; + if (mods) { + add_mods(mods); + send_keyboard_report(); + } + + add_key(key); + send_keyboard_report(); + + del_key(key); + send_keyboard_report(); + + if (mods) { + del_mods(mods); + send_keyboard_report(); + } +} +static uint16_t code2key(uint8_t code) +{ + // ASCII to key combination in US laout + switch (code) { + case 0x01 ... 0x08: // Ctrl-[a-z] + return MOD_BIT(KC_LCTRL)<<8 | (KC_A + (code-0x01)); + case 0x09: return KC_TAB; // TAB(Ctrl-i) + case 0x0A ... 0x0C: // Ctrl-[a-z] + return MOD_BIT(KC_LCTRL)<<8 | (KC_A + (code-0x01)); + case 0x0D: return KC_ENTER; // Enter(Ctrl-m) + case 0x0E ... 0x1A: // Ctrl-[a-z] + return MOD_BIT(KC_LCTRL)<<8 | (KC_A + (code-0x01)); + case 0x1B: return KC_ESC; + case 0x1C: return KC_RIGHT; + case 0x1D: return KC_LEFT; + case 0x1E: return KC_UP; + case 0x1F: return KC_DOWN; + case 0x20: return KC_SPACE; + case 0x21: return MOD_BIT(KC_LSHIFT)<<8 | KC_1; // ! + case 0x22: return MOD_BIT(KC_LSHIFT)<<8 | KC_QUOTE; // " + case 0x23: return MOD_BIT(KC_LSHIFT)<<8 | KC_3; // # + case 0x24: return MOD_BIT(KC_LSHIFT)<<8 | KC_4; // $ + case 0x25: return MOD_BIT(KC_LSHIFT)<<8 | KC_5; // % + case 0x26: return MOD_BIT(KC_LSHIFT)<<8 | KC_7; // & + case 0x27: return KC_QUOTE; // ' + case 0x28: return MOD_BIT(KC_LSHIFT)<<8 | KC_9; // ( + case 0x29: return MOD_BIT(KC_LSHIFT)<<8 | KC_0; // ) + case 0x2A: return MOD_BIT(KC_LSHIFT)<<8 | KC_8; // * + case 0x2B: return MOD_BIT(KC_LSHIFT)<<8 | KC_EQUAL; // + + case 0x2C: return KC_COMMA; // , + case 0x2D: return KC_MINUS; // - + case 0x2E: return KC_DOT; // . + case 0x2F: return KC_SLASH; // / + case 0x30: return KC_0; + case 0x31 ... 0x39: // 1-9 + return KC_1 + (code-0x31); + case 0x3A: return MOD_BIT(KC_LSHIFT)<<8 | KC_SCLN; // : + case 0x3B: return KC_SCLN; // ; + case 0x3C: return MOD_BIT(KC_LSHIFT)<<8 | KC_COMMA; // < + case 0x3D: return KC_EQUAL; // = + case 0x3E: return MOD_BIT(KC_LSHIFT)<<8 | KC_DOT; // > + case 0x3F: return MOD_BIT(KC_LSHIFT)<<8 | KC_SLASH; // ? + case 0x40: return MOD_BIT(KC_LSHIFT)<<8 | KC_2; // @ + case 0x41 ... 0x5A: // A-Z + return MOD_BIT(KC_LSHIFT)<<8 | (KC_A + (code-0x41)); + case 0x5B: return KC_LBRACKET; // [ + case 0x5C: return KC_BSLASH; // + case 0x5D: return KC_RBRACKET; // ] + case 0x5E: return MOD_BIT(KC_LSHIFT)<<8 | KC_6; // ^ + case 0x5F: return MOD_BIT(KC_LSHIFT)<<8 | KC_MINUS; // _ + case 0x61 ... 0x7A: // a-z + return KC_A + (code-0x61); + case 0x7B: return MOD_BIT(KC_LSHIFT)<<8 | KC_LBRACKET; // { + case 0x7C: return MOD_BIT(KC_LSHIFT)<<8 | KC_BSLASH; // | + case 0x7D: return MOD_BIT(KC_LSHIFT)<<8 | KC_RBRACKET; // } + case 0x7E: return MOD_BIT(KC_LSHIFT)<<8 | KC_GRAVE; // } + case 0x7F: return KC_DELETE; // + } + return 0; +} + +uint8_t matrix_scan(void) +{ + uint16_t code = serial_recv2(); + if (code == -1) { + return 0; + } + + print_hex8(code); print(" "); + + // echo back + serial_send(code); + type_key(code2key(code)); + + + return code; +} + +inline +bool matrix_has_ghost(void) +{ + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return false; +} + +inline +matrix_row_t matrix_get_row(uint8_t row) +{ + return 0; +} + +void matrix_print(void) +{ + print("\nr/c 0123456789ABCDEF\n"); + for (uint8_t row = 0; row < matrix_rows(); row++) { + phex(row); print(": "); + pbin_reverse(matrix_get_row(row)); + print("\n"); + } +} diff --git a/converter/ibm4704_usb/Makefile b/converter/ibm4704_usb/Makefile new file mode 100644 index 00000000..79f17ec0 --- /dev/null +++ b/converter/ibm4704_usb/Makefile @@ -0,0 +1,93 @@ +# Target file name (without extension). +TARGET = ibm4704_usb + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap_common.c \ + matrix.c \ + led.c \ + protocol/ibm4704.c + +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap_plain.c $(SRC) +endif + +CONFIG_H = config.h + + +# MCU name +# TMK Converter rev.2 +MCU ?= atmega32u2 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # 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 # USB Nkey Rollover - not yet supported in LUFA + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/ibm4704_usb/Makefile.tmk_rev1 b/converter/ibm4704_usb/Makefile.tmk_rev1 new file mode 100644 index 00000000..338b7da5 --- /dev/null +++ b/converter/ibm4704_usb/Makefile.tmk_rev1 @@ -0,0 +1,5 @@ +# TMK Converter rev.1 +# which looks like this: +# https://github.com/tmk/keyboard_converter#pcb-rev1 +MCU = atmega32u4 +include Makefile diff --git a/converter/ibm4704_usb/Makefile.tmk_rev2 b/converter/ibm4704_usb/Makefile.tmk_rev2 new file mode 100644 index 00000000..56c2c2c6 --- /dev/null +++ b/converter/ibm4704_usb/Makefile.tmk_rev2 @@ -0,0 +1,6 @@ +# TMK Converter rev.2 +# which looks like this: +# https://github.com/tmk/keyboard_converter#pcb-rev2 +MCU = atmega32u2 +include Makefile + diff --git a/converter/ibm4704_usb/README.md b/converter/ibm4704_usb/README.md new file mode 100644 index 00000000..45b1f683 --- /dev/null +++ b/converter/ibm4704_usb/README.md @@ -0,0 +1,85 @@ +IBM 4704 to USB keyboard converter +================================== +This firmware converts IBM 4704 keyboard protocol to USB HID. + +Keyboard initialization process takes a few seconds at start up. During that you will hear buzzer from the keyboard. **You need to plug USB cable after hooking up your keyboard to the converter.** + + +Update +------ +- 2015/09/07 Added keymap for Alps 102-key. Thanks, tai @ geekhack! +- 2015/05/05 Added keymaps for 107-key, 77-key and 50-key. Thanks, orihalcon @ geekhack! +- 2015/05/19 Fixed a protocol handling bug. + + + +Supported Keyboard +------------------ +### IBM capacitive switch models: +- 6019273 Model 100 50-key (grid layout) http://kishy.ca/?p=894 +- 6019284 Model 200 62-key Alpha(60% layout) http://kishy.ca/?p=894 +- 6019303 Model 300 77-key Expanded Alpha http://deskthority.net/photos-f62/ibm-6019303-t8502.html +- 6020218 Model 400 107-key Full key http://kishy.ca/?p=894 + +### Alps switch(vintage Green) models: + +- 5954339 Japanese 102-key http://deskthority.net/post87127.html#p87127 +- 6112883 Japanese 102-key http://geekhack.org/index.php?topic=52888.msg1194489#msg1194489 +- 6112884 Japanese 102-key http://geekhack.org/index.php?topic=50437.msg1193047#msg1193047 +- 6341739 Chinese 102-key http://geekhack.org/index.php?topic=52888.msg1176566#msg1176566 + + +Connector +--------- +Keyboard Plug from front: + + DSUB-9 + ------------- + \ N 2 3 4 5 / + \ N N N N / + --------- + 2 GND + 3 VCC 5V + 4 DATA + 5 CLOCK + N No connection/No pin. + + +Connection +---------- +In case of using ATMega32U4/U2 + +1. Supply power with VCC and GND. +2. Connect CLOCK to PD1 and DATA to PD0. You can change pin with config.h. +3. Optionally you may need pull-up register. 1KOhm probably work. + +TMK Converter can supports IBM 4704. +https://github.com/tmk/keyboard_converter + + +Build Firmware +-------------- +Just run `make`: + + $ make -f + +For TMK Converter rev.1 use `Makefile.tmk_rev1` as makefile: + + $ make -f Makefile.tmk_rev1 + +For TMK Converter rev.2 use `Makefile.tmk_rev2` as makefile: + + $ make -f Makefile.tmk_rev2 + +To select keymap: + + $ make -f KEYMAP=[plain|...] + +To indentify your TMK Converter revision see [this](https://github.com/tmk/keyboard_converter#pcb-revisions). + + +Keymap +------ +Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_.c` and see keymap document(you can find in top README.md) and existent keymap files. + +Use `KEYMAP_ALPS102()` to define your keymap for Alps models. diff --git a/converter/ibm4704_usb/config.h b/converter/ibm4704_usb/config.h new file mode 100644 index 00000000..2fee10fd --- /dev/null +++ b/converter/ibm4704_usb/config.h @@ -0,0 +1,61 @@ +/* +Copyright 2014 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x4707 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT IBM 4704 keyboard converter +#define DESCRIPTION convert IBM 4704 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 16 // keycode bit3-6 +#define MATRIX_COLS 8 // keycode bit0-2 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RCTRL)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* Pin configuration */ +#define IBM4704_CLOCK_PORT PORTD +#define IBM4704_CLOCK_PIN PIND +#define IBM4704_CLOCK_DDR DDRD +#define IBM4704_CLOCK_BIT 1 +#define IBM4704_DATA_PORT PORTD +#define IBM4704_DATA_PIN PIND +#define IBM4704_DATA_DDR DDRD +#define IBM4704_DATA_BIT 0 + +/* Pin interrupt on rising edge of clock */ +#define IBM4704_INT_INIT() do { EICRA |= ((1<| Z| X| C| V| B| N| M| ,| ,| /|???|Shift | + |-----------------------------------------------------------| + |Reset|blk|Alt | Space |Alt |blk|Enter| + `-----------------------------------------------------------' + +----------+---------------------+----------+----------+ + |` 00|PD1 04|Caps 20|LShift 30|Reset 31| + |1 18|q 05|a 21|<> 3E|Rblank 41| + |2 19|w 06|s 22|z 32|Alt 3F| + |3 1A|e 13|d 23|x 33|Space 40| + |4 10|r 14|f 24|c 34|Alt 3F| + |5 11|t 15|g 25|v 35|Lblank 42| + |6 12|y 16|h 26|b 36|Enter 2F| + |7 08|u 17|j 27|n 37| | + |8 09|i 01|k 28|m 38| | + |9 0A|o 02|l 29|, 39| | + |0 0F|p 03|; 2A|. 3A| | + |- 1F|¢ 1B|' 2B|/ 3B| | + |= 0D|\ 1C|{} 2C|??? 3C| | + |??? 0C|PD2 1D|PD3 2D|RShift 3D| | + |BS 0E| | | | | + +----------+---------------------+----------+----------+ + Bit7 is 'press flag' which set 1 on press and 0 on release when break code is enabled. + +NOTE: When break code is enabled the key sends scancode with setting 7th bit on press +and without it on release. That is, '`' sends 80h on press and 00h on release. + + +Keyboard command +---------------- +Keyboard accepts these commands from host. + + Description Entry point + ----------------------------------------------------------- + FF Soft Reset 0008h + FE Resend 00e8h + FD Buzzer(emits a short beep) 00edh + FC Set Key Flag 00f6h + FB Soft Reset 0008h + FA Reset 0000h + + +Keyboard response +----------------- +Keyobard sends these bytes to host. + + Description Entry point + ----------------------------------------------------------- + FE Overflow(key event/receive data) 00c5h, 0346h + Memory test error 0224h + FD Command out of bound 00d8h + Key out of bound + 7E Read/Parity error in receive from host 00bch + 80-FB? scan code(make) + 00-7B? scan code(break) + note: Alps model spits scan code 7B(FB) at least. + + +Set Key Flag command(FC) +------------------------ +After 'Power on Reset' firmware enters this command mode and waits for data from host, +so that you don't need to send 'FC' and it doesn't send any scancode until you send 'FF'. +With Alps models you need to send 'FC' command to enter this mode. + +Data sent from host: + + bit: 7 6 ... 0 + en | | + | `-----`--- scan code + `------------- enable bit(0: enable repeat, 1: enable break) + + 00-7B? Enable repeat + 80-FB? Enable break + FE Resend(011ah) no need to use + FF End(0114h) exits FC command mode. + +Response from keyboard: + FD Out of bound - Invalid scancode + -- OK - No response means that command is accepted. + +Examples: + To enable break code of all keys. + + FC 80 81 ... FB FF + diff --git a/converter/ibm4704_usb/keymap_50key.c b/converter/ibm4704_usb/keymap_50key.c new file mode 100644 index 00000000..97294fb4 --- /dev/null +++ b/converter/ibm4704_usb/keymap_50key.c @@ -0,0 +1,17 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + KEYMAP_50( + F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, \ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, \ + Q, W, E, R, T, Y, U, I, O, P, \ + A, S, D, F, G, H, J, K, L, SCLN, \ + Z, X, C, V, B, N, M, COMM,DOT, SLSH \ + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; + + diff --git a/converter/ibm4704_usb/keymap_alps102key.c b/converter/ibm4704_usb/keymap_alps102key.c new file mode 100644 index 00000000..f3dda718 --- /dev/null +++ b/converter/ibm4704_usb/keymap_alps102key.c @@ -0,0 +1,50 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Layer 0: + * ,---------------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|BS |BS |F21| |PSC|SLK|PAU| |F1 |F2 |F3 |F4 | + * |---------------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|F22| |Ins|Hom|PgU| |F5 |F6 |F7 |F8 | + * |---------------------------------------------------------------| |-----------| |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Ret|Ret |F23| |Del|End|PgD| |F9 |F10|F11|F12| + * |---------------------------------------------------------------| |-----------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shf|Shift |F24| | |Up | | |F13|F14|F15|F16| + * |---------------------------------------------------------------| |-----------| |---------------| + * |Fn0 |Gui|Alt | Space |Alt* |Gui|Fn0 | |Lef|Dow|Rig| |F17|F18|F19|F20| + * `---------------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP_ALPS102( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC,BSPC,F21, PSCR,SLCK,PAUS, F1, F2, F3, F4, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, F22, INS, HOME,PGUP, F5, F6, F7, F8, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, F23, DEL, END, PGDN, F9, F10, F11, F12, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,RSFT, F24, NO, UP, NO, F13, F14, F15, F16, \ + FN0, LGUI,LALT, SPC, RALT,RGUI, FN0, LEFT,DOWN,RGHT, F17, F18, F19, F20 \ + ), + + /* Layer 1: + * ,---------------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|BS |BS |F21| |VoD|VoU|Mut| |F1 |F2 |F3 |F4 | + * |---------------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \|F22| |Ins|Hom|PgU| |F5 |F6 |F7 |F8 | + * |---------------------------------------------------------------| |-----------| |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Ret|Ret |F23| |Del|End|PgD| |F9 |F10|F11|F12| + * |---------------------------------------------------------------| |-----------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shf|Shift |F24| | |PgU| | |F13|F14|F15|F16| + * |---------------------------------------------------------------| |-----------| |---------------| + * |Fn0 |Gui|Alt | Space |Alt* |Gui|Fn0 | |Hom|PgD|End| |F17|F18|F19|F20| + * `---------------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP_ALPS102( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, VOLD,VOLU,MUTE, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,PGUP,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, TRNS, HOME,PGDN,END, TRNS,TRNS,TRNS,TRNS \ + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/converter/ibm4704_usb/keymap_common.c b/converter/ibm4704_usb/keymap_common.c new file mode 100644 index 00000000..55a13793 --- /dev/null +++ b/converter/ibm4704_usb/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2011,2012,2013 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 "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/ibm4704_usb/keymap_common.h b/converter/ibm4704_usb/keymap_common.h new file mode 100644 index 00000000..9cb23b0b --- /dev/null +++ b/converter/ibm4704_usb/keymap_common.h @@ -0,0 +1,146 @@ +/* +Copyright 2011,2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +// 32*8(256) byte array which converts PS/2 code into USB code +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* 107-key */ +#define KEYMAP( \ + K46,K64, K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E, K6A,K6B,K6C, K47,K48,K49,K4A, \ + K56,K66, K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D, K6D,K6E,K6F, K4B,K4C,K4D,K4E, \ + K71,K77, K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, K70,K65,K72, K50,K51,K52,K53, \ + K44,K45, K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D, K74,K75,K76, K5E,K58,K59,K5A, \ + K54,K55, K31,K41,K3F, K40, K42,K2F, K78,K67,K79, K5B,K5C,K5D,K57 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_NO, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_NO, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_NO, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_NO, KC_NO, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_NO, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} + +/* 77-key */ +#define KEYMAP_77( \ + K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E, K6A,K6B,K6C, \ + K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D, K6D,K6E,K6F, \ + K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, K70,K65,K72, \ + K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D, K74,K75,K76, \ + K31,K41,K3F, K40, K42,K2F, K78,K67,K79 \ +) KEYMAP( \ + F1, F2, K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E, K6A,K6B,K6C, NLCK,PSLS,PAST,PMNS, \ + F3, F4, K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D, K6D,K6E,K6F, P7, P8, P9, PPLS, \ + F5, F6, K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, K70,K65,K72, P4, P5, P6, PPLS, \ + F7, F8, K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D, K74,K75,K76, P1, P2, P3, PENT, \ + F9, F10, K31,K41,K3F, K40, K42,K2F, K78,K67,K79 P0, P0, PDOT,PENT \ +) + +/* 62-key */ +#define KEYMAP_62( \ + K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E, \ + K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D, \ + K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, \ + K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D, \ + K31,K41,K3F, K40, K42,K2F \ +) KEYMAP( \ + F1, F2, K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ + F3, F4, K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D, DEL, END, PGDN, P7, P8, P9, PPLS, \ + F5, F6, K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, PSCR,SLCK,PAUS, P4, P5, P6, PPLS, \ + F7, F8, K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D, F11, UP, F12, P1, P2, P3, PENT, \ + F9, F10, K31,K41,K3F, K40, K42,K2F, LEFT,DOWN,RGHT, P0, P0, PDOT,PENT \ +) + +/* 50-key */ +#define KEYMAP_50( \ + K00,K01,K02, K03,K04,K05, K20,K21,K22,K23, \ + K08,K09,K0A, K0B,K0C,K0D, K28,K29,K2A,K35, \ + K10,K11,K12, K13,K14,K15, K30,K31,K32,K36, \ + K18,K19,K1A, K1B,K1C,K1D, K38,K39,K3A,K37, \ + K16,K1E,K0E, K0F,K1F,K17, K33,K3B,K2B,K3F \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_NO, KC_NO, }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO, KC_NO, KC_NO, KC_##K3F }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, } \ +} + +/* Alps 102-key */ +#define KEYMAP_ALPS102( \ + K00, K0F, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E, K44, K45, K46, K43, K41, K42, K4A, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K54, K55, K56, K50, K51, K52, K5A, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K64, K65, K66, K60, K61, K62, K6B, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K74, K75, K76, K70, K71, K72, K7B, \ + K31, K47, K3F, K40, K4F, K48, K2F, K77, K67, K57, K73, K63, K53, K4E \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO, }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_NO, KC_##K4A, KC_NO, KC_NO, KC_NO, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_NO, KC_NO, KC_##K5A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K6B, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_NO, KC_NO, KC_NO, KC_##K7B, KC_NO, KC_NO, KC_NO, KC_NO, } \ +} + + +#endif diff --git a/converter/ibm4704_usb/keymap_hasu.c b/converter/ibm4704_usb/keymap_hasu.c new file mode 100644 index 00000000..14c17117 --- /dev/null +++ b/converter/ibm4704_usb/keymap_hasu.c @@ -0,0 +1,85 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,-----------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|???|BS | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|xxx|Ret | + * |-----------------------------------------------------------| + * |Shif|xxx| Z| X| C| V| B| N| M| ,| ,| /|xxx|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui|Alt | Space |Alt |Gui|Ctrl | + * `-----------------------------------------------------------' + */ + KEYMAP_62( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN1, QUOT,NO, ENT, \ + LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, FN2, NO, FN0, \ + LCTL,LGUI,LALT, FN3, RGUI,RCTL \ + ), + + KEYMAP_62( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,NO, TRNS, \ + LCTL,LGUI,LALT, SPC, RGUI,RCTL \ + ), + + KEYMAP_62( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,WSTP,WBAK,WFWD,BSPC, \ + LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, NO, RSFT,\ + LCTL,LGUI,LALT, BTN1, RGUI,RCTL \ + ), + + KEYMAP_62( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS,NO, RSFT, \ + LCTL,LGUI,LALT, SPC, RGUI,RCTL \ + ), + + KEYMAP_62( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN4, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, BTN2,MS_L,MS_D,MS_R,BTN1,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, NO, NO, \ + LCTL,LGUI,LALT, TRNS, RGUI,RCTL \ + ), +}; + +enum macro_id { + ALT_TAB, +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_TAP_KEY(2, KC_SCLN), + [2] = ACTION_LAYER_TAP_KEY(3, KC_SLASH), + [3] = ACTION_LAYER_TAP_KEY(4, KC_SPC), + [4] = ACTION_MACRO(ALT_TAB), +}; + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + keyevent_t event = record->event; + + switch (id) { + case ALT_TAB: + return (event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} diff --git a/converter/ibm4704_usb/keymap_plain.c b/converter/ibm4704_usb/keymap_plain.c new file mode 100644 index 00000000..4aed684e --- /dev/null +++ b/converter/ibm4704_usb/keymap_plain.c @@ -0,0 +1,50 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,-----------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|???|BS | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Ret|Ret | + * |-----------------------------------------------------------| + * |Shif|Shf| Z| X| C| V| B| N| M| ,| ,| /|???|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui|Alt | Space |Alt* |Gui|Fn | + * `-----------------------------------------------------------' + */ + KEYMAP( + F1, F2, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NO, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ + F3, F4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \ + F5, F6, LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, ENT, PSCR,SLCK,PAUS, P4, P5, P6, PPLS, \ + F7, F8, LSFT,LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, F11, UP, F12, P1, P2, P3, PENT, \ + F9, F10, LCTL,LGUI,LALT, SPC, RGUI,FN0, LEFT,DOWN,RGHT, P0, P0, PDOT,PENT \ + ), + + /* 1: HHKB + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|???|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pau| Up| | Ins| + * |-----------------------------------------------------------| + * |Ctrl |VoD|VoU|VoM| | | *| /|Hom|PgU|Lef|Rig|Ret|Ret | + * |-----------------------------------------------------------| + * |Shif|Shi| | | | | | +| -|End|PgD|Dow|???|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui|Alt | Space |Alt* |Gui|Fn | + * `-----------------------------------------------------------' + */ + KEYMAP( + F1, F2, ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ + F3, F4, CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, INS, DEL, END, PGDN, P7, P8, P9, PPLS, \ + F5, F6, TRNS,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, ENT, PSCR,SLCK,PAUS, P4, P5, P6, PPLS, \ + F7, F8, TRNS,TRNS,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,NO, TRNS, F11, UP, F12, P1, P2, P3, PENT, \ + F9, F10, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, LEFT,DOWN,RGHT, P0, P0, PDOT,PENT \ + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/converter/ibm4704_usb/led.c b/converter/ibm4704_usb/led.c new file mode 100644 index 00000000..f76545f0 --- /dev/null +++ b/converter/ibm4704_usb/led.c @@ -0,0 +1,24 @@ +/* +Copyright 2011 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 "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c new file mode 100644 index 00000000..f25452d5 --- /dev/null +++ b/converter/ibm4704_usb/matrix.c @@ -0,0 +1,162 @@ +/* +Copyright 2014 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 +#include +#include +#include +#include "action.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "ibm4704.h" +#include "matrix.h" + + +static void matrix_make(uint8_t code); +static void matrix_break(uint8_t code); +static void matrix_clear(void); + + +/* + * Matrix Array usage: + * IBM 4704 scan codes are assigned into 128(16x8)-cell matrix. + * + * 8bit wide + * +---------+ + * 0| | + * :| XX | 00-7F + * f| | + * +---------+ + * + * Exceptions: + */ +static uint8_t matrix[MATRIX_ROWS]; + +// scan code bits 7654 3210 +// R:row/C:column -RRR RCCC +#define ROW(code) ((code>>3)&0x0f) +#define COL(code) (code&0x07) + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +static void enable_break(void) +{ + print("Enable break: "); + while (ibm4704_send(0xFC)) { _delay_ms(10); } + // valid scancode: 00-79h + for (uint8_t code = 0; code < 0x7F; code++) { + while (ibm4704_send(0x80|code)) _delay_ms(10); + _delay_ms(5); // wait for response + // No response(FF) when ok, FD when out of bound + xprintf("s%02X:r%02X ", code, ibm4704_recv()); + } + while (ibm4704_send(0xFF)) { _delay_ms(10); } // End + print("End\n"); +} + + +void matrix_setup(void) +{ + ibm4704_init(); +} + +void matrix_init(void) +{ + debug_enable = true; + + print("IBM 4704 converter\n"); + matrix_clear(); + _delay_ms(2000); // wait for keyboard starting up + xprintf("Keyboard ID: %02X\n", ibm4704_recv()); + enable_break(); +} + +/* + * IBM 4704 Scan Code + */ +uint8_t matrix_scan(void) +{ + uint8_t code = ibm4704_recv(); + if (code==0xFF) { + // Not receivd + return 0; + } else if ((code&0x7F) >= 0x7C) { + // 0xFF-FC and 0x7F-7C is not scancode + xprintf("Error: %02X\n", code); + matrix_clear(); + return 0; + } else if (code&0x80) { + dprintf("%02X\n", code); + matrix_make(code); + } else { + dprintf("%02X\n", code); + matrix_break(code); + } + return 1; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1< + +Close-up picture of handset cable. You can see one end of plug has reverse color codes against the other. Click to enlarge. +[![4P4C cable](http://i.imgur.com/3S9P1mYm.jpg?1)](http://i.imgur.com/3S9P1mY.jpg?1) + +[Teensy]: http://www.pjrc.com/teensy/ +[TMK converter]: https://github.com/tmk/keyboard_converter + + +### Socket Pinout +- + +![Jack fig](http://www.kbdbabel.org/conn/kbd_connector_macplus.png) + + +### Pull-up Resistor +You may need pull-up resistors on signal lines(`CLOCK`, `DATA`) in particular when you have long or coiled cable. **1k-10k Ohm** will be OK for this purpose. In that case the converter may not read signal from keyboard correctly without pull-up resistors. + + + +Building Firmware +----------------- +To compile firmware you need AVR GCC. You can edit *Makefile* and *config.h* to change compile options and pin configuration. Also `KEYMAP` option can be used to select keymap. + + $ git clone git://github.com/tmk/tmk_keyboard.git (or download source) + $ cd m0110_usb + $ make -f Makefile.rev2 clean + $ make -f Makefile.rev2 [KEYMAP={default|intl|spacefn|hasu}] + +Use `Maefile.tmk_rev1` for TMK converter Rev.1, `Makefile.teensy` for Teensy instead. + + + +Keymap +------ +To create your own keymap copy existent keymap file to `keymap_name.c` and edit it. + + + +Debug +----- +You can use [PJRC HID listen](http://www.pjrc.com/teensy/hid_listen.html) to see debug output. The converter has some functions for debug, press `+H` simultaneously to get help. + +- Magic combo: `Shift+Option+⌘` or `Shift+Option+Ctrl`(`Shift+Alt+Gui` or `Shift+Alt+Control`) diff --git a/converter/m0110_usb/config.h b/converter/m0110_usb/config.h new file mode 100644 index 00000000..801bc4eb --- /dev/null +++ b/converter/m0110_usb/config.h @@ -0,0 +1,62 @@ +/* +Copyright 2011,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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x0110 +#define DEVICE_VER 0x0101 +#define MANUFACTURER t.m.k. +#define PRODUCT M0110 keyboard converter +#define DESCRIPTION convert M0110 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 14 +#define MATRIX_COLS 8 + + +/* 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 + + +/* magic key */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LCTL)) \ +) + +/* boot magic key */ +#define BOOTMAGIC_KEY_SALT KC_FN0 +#define BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL KC_LCAP + + +/* ports */ +#define M0110_CLOCK_PORT PORTD +#define M0110_CLOCK_PIN PIND +#define M0110_CLOCK_DDR DDRD +#define M0110_CLOCK_BIT 1 +#define M0110_DATA_PORT PORTD +#define M0110_DATA_PIN PIND +#define M0110_DATA_DDR DDRD +#define M0110_DATA_BIT 0 + +#endif diff --git a/converter/m0110_usb/keymap_common.c b/converter/m0110_usb/keymap_common.c new file mode 100644 index 00000000..4ac2d717 --- /dev/null +++ b/converter/m0110_usb/keymap_common.c @@ -0,0 +1,37 @@ +/* +Copyright 2011,2012,2014 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 +#include +#include "action.h" +#include "keycode.h" +#include "keymap.h" +#include "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn index to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + return action; +} diff --git a/converter/m0110_usb/keymap_common.h b/converter/m0110_usb/keymap_common.h new file mode 100644 index 00000000..925556d9 --- /dev/null +++ b/converter/m0110_usb/keymap_common.h @@ -0,0 +1,133 @@ +/* +Copyright 2011,2012,2014,2015 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 +#include +#include "keycode.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* Common layout for M0110 and M0110A + * This keymap works with both keyboards. As you can see, the M0110A is + * a superset of M0110 keyboard, only one exception is 'Enter'(34) of M0110 + * does not exist on the M0110A. + * + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| + * |-----------------------------------------------------' | |---------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | + * |---------------------------------------------------------| |-----------|Ent| + * |Opt |Mac | Space |Ent| \|Lft|Rgt|Dn | | 0| .| | + * `---------------------------------------------------------' `---------------' + * + * M0110A scan codes + * ,---------------------------------------------------------. ,---------------. + * | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62| + * |---------------------------------------------------------| |---------------| + * | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| | | 59| 5B| 5C| 4E| + * |-----------------------------------------------------' | |---------------| + * | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 66| + * |---------------------------------------------------------| |---------------| + * | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| 4D| | 53| 54| 55| | + * `---------------------------------------------------------' |-----------| 4C| + * | 3A| 37| 31 | 2A| 46| 42| 48| | 52| 41| | + * `---------------------------------------------------------' `---------------' + * + * M0110 + M0120 scan codes + * ,---------------------------------------------------------. ,---------------. + * | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62| + * |---------------------------------------------------------| |---------------| + * | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| | 59| 5B| 5C| 4E| + * |---------------------------------------------------------| |---------------| + * | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | 56| 57| 58| 66| + * |---------------------------------------------------------| |---------------| + * | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 38| | 53| 54| 55| | + * `---------------------------------------------------------' |-----------| 4C| + * | 3A| 37| 31 | 34| 3A| | 52| 41| | + * `------------------------------------------------' `---------------' + * Two right and left keys of 38 and 3A are identical, you cannot discriminate those two. + */ +#define KEYMAP( \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K68,K6D,K62, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27, K24, K56,K57,K58,K66, \ + K38,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C, K4D, K53,K54,K55,K4C, \ + K3A,K37, K31, K34,K2A,K46,K42,K48, K52, K41 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_NO, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_NO, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_NO, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_NO, KC_NO, KC_NO, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \ + { KC_NO, KC_NO, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##K62, KC_NO, KC_NO, KC_NO, KC_##K66, KC_NO }, \ + { KC_##K68, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K6D, KC_NO, KC_NO }, \ +} + +/* International keyboard layout for M0110 + M0120 + * https://en.wikipedia.org/wiki/File:Apple_Macintosh_Plus_Keyboard.jpg + * Probably International keyboard layout of M0110A doesn't exist. + * + * M0110 + M0120 scan codes + * ,---------------------------------------------------------. ,---------------. + * | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62| + * |---------------------------------------------------------| |---------------| + * | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| | 59| 5B| 5C| 4E| + * |------------------------------------------------------, | |---------------| + * | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| | | 56| 57| 58| 66| + * |---------------------------------------------------------| |---------------| + * | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 0A| 38| | 53| 54| 55| | + * `---------------------------------------------------------' |-----------| 4C| + * | 3A| 37| 34 | 31| 3A| | 52| 41| | + * `------------------------------------------------' `---------------' + * Two right and left keys of 38 and 3A are identical, you cannot discriminate those two. + */ +#define KEYMAP_INTL( \ + K32,K12,K13,K14,K15,K17,K16,K1A,K1C,K19,K1D,K1B,K18,K33, K47,K68,K6D,K62, \ + K30,K0C,K0D,K0E,K0F,K11,K10,K20,K22,K1F,K23,K21,K1E,K2A, K59,K5B,K5C,K4E, \ + K39,K00,K01,K02,K03,K05,K04,K26,K28,K25,K29,K27,K24, K56,K57,K58,K66, \ + K38,K06,K07,K08,K09,K0B,K2D,K2E,K2B,K2F,K2C,K0A, K53,K54,K55,K4C, \ + K3A,K37, K34, K31, K52, K41 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO, KC_NO, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##K41, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K47 }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_##K4C, KC_NO, KC_##K4E, KC_NO }, \ + { KC_NO, KC_NO, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##K62, KC_NO, KC_NO, KC_NO, KC_##K66, KC_NO }, \ + { KC_##K68, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K6D, KC_NO, KC_NO }, \ +} diff --git a/converter/m0110_usb/keymap_default.c b/converter/m0110_usb/keymap_default.c new file mode 100644 index 00000000..0f9b8d27 --- /dev/null +++ b/converter/m0110_usb/keymap_default.c @@ -0,0 +1,137 @@ +/* +Copyright 2011,2012,2015 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 +#include "keycode.h" +#include "keymap_common.h" + + + +#ifdef KEYMAP_SECTION_ENABLE +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +#endif + /* Default: + * M0110 M0120 + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Nlk| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9| -| + * |---------------------------------------------------------| |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| | + * `---------------------------------------------------------' |-----------|Ent| + * |Opt|Mac | Space |Fn |Opt| | 0| .| | + * `-----------------------------------------------' `---------------' + * M0110A + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Nlk| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| + * |-----------------------------------------------------' | |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | + * |---------------------------------------------------------| |-----------|Ent| + * |Opt |Mac | Space | \|Lft|Rgt|Dn | | 0| .| | + * `---------------------------------------------------------' `---------------' + */ + [0] = KEYMAP( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT, + LALT,LGUI, SPC, FN0, FN13,LEFT,RGHT,DOWN, P0, PDOT + ), + /* Cursor Layer: + * M0110 M0120 + * ,---------------------------------------------------------. ,---------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |INS| | | 7| 8| 9| -| + * |---------------------------------------------------------| |---------------| + * |Ctrl |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift |End| |PgD| | | | |End|PgD|Dow|Shift | | 1| 2| 3| | + * `---------------------------------------------------------' |-----------|Ent| + * |Opt|Mac | Space |Fn |Opt| | 0| .| | + * `-----------------------------------------------' `---------------' + * M0110A + * ,---------------------------------------------------------. ,---------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |INS| | | 7| 8| 9| -| + * |-----------------------------------------------------' | |---------------| + * |Ctrl |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift |End| |PgD| | | | |End|PgD|Dow|Shft|PgU| | 1| 2| 3| | + * |---------------------------------------------------------| |-----------|Ent| + * |Opt |Mac | Space | \|Hom|End|PgD| | 0| .| | + * `---------------------------------------------------------' `---------------' + */ + [1] = KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, INS, P7, P8, P9, PMNS, + LCTL,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, + LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT, + LALT,LGUI, SPC, FN0, FN13,HOME,END, PGDN, P0, PDOT + ), +}; + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_MOMENTARY(2), + [2] = ACTION_LAYER_MOMENTARY(3), + [3] = ACTION_LAYER_MOMENTARY(4), + [4] = ACTION_LAYER_MOMENTARY(5), + [5] = ACTION_LAYER_MOMENTARY(6), + [6] = ACTION_LAYER_MOMENTARY(7), + [7] = ACTION_LAYER_TOGGLE(1), + [8] = ACTION_LAYER_TOGGLE(2), + [9] = ACTION_LAYER_TOGGLE(3), + [10] = ACTION_LAYER_TAP_TOGGLE(1), + [11] = ACTION_LAYER_TAP_TOGGLE(2), + [12] = ACTION_LAYER_TAP_TOGGLE(3), + [13] = ACTION_LAYER_TAP_KEY(1, KC_BSLASH), + [14] = ACTION_LAYER_TAP_KEY(2, KC_TAB), + [15] = ACTION_LAYER_TAP_KEY(3, KC_ENTER), + [16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE), + [17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON), + [18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE), + [19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH), + [20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE), + [21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE), + [22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE), + [23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER), + [24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC), + [25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE), + [26] = ACTION_MODS_ONESHOT(MOD_LCTL), + [27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC), + [28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE), + [29] = ACTION_MODS_ONESHOT(MOD_LSFT), + [30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRAVE), + [31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSLASH), +}; diff --git a/converter/m0110_usb/keymap_hasu.c b/converter/m0110_usb/keymap_hasu.c new file mode 100644 index 00000000..11f1a4f3 --- /dev/null +++ b/converter/m0110_usb/keymap_hasu.c @@ -0,0 +1,87 @@ +/* +Copyright 2014 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 +#include "keycode.h" +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default: + * M0110 + * ,---------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| + * |---------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |---------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| Fn| '|Return| + * |---------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| Fn|Shift | + * `---------------------------------------------------------' + * |Fn |alt | Fn |Gui |Fn | + * `-----------------------------------------------' + */ + [0] = KEYMAP( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, UP, P1, P2, P3, PENT, + FN0, LALT, FN2, LGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT + ), + // IJKL cursor + [1] = KEYMAP( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,NO, NO, NO, NO, NO, HOME,PGDN,UP, PGUP,END, NO, NO, P7, P8, P9, PMNS, + LCTL,VOLD,VOLU,MUTE,NO, NO, HOME,LEFT,DOWN,RGHT,END, NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, PGUP, P1, P2, P3, PENT, + TRNS,LALT, SPC, LGUI,BSLS,HOME,END, PGDN, P0, PDOT + ), + // HJKL cursor + [2] = KEYMAP( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,NO, NO, NO, NO, NO, HOME,PGDN,UP, PGUP,END, NO, NO, P7, P8, P9, PMNS, + LCTL,VOLD,VOLU,MUTE,NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, PGUP, P1, P2, P3, PENT, + TRNS,LALT, SPC, LGUI,BSLS,HOME,END, PGDN, P0, PDOT + ), + // Mousekey + [3] = KEYMAP( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,Q, W, E, R, T, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD, P7, P8, P9, PMNS, + LCTL,VOLD,VOLU,MUTE,NO, NO, BTN2,MS_L,MS_D,MS_R,BTN1,NO, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, BTN2,BTN1,BTN4,BTN5,NO, PGUP, P1, P2, P3, PENT, + NO, LALT, TRNS, LGUI,BSLS,HOME,END, PGDN, P0, PDOT + ), + // Mousekey + [4] = KEYMAP( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,Q, W, E, R, T, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD, P7, P8, P9, PMNS, + LCTL,VOLD,VOLU,MUTE,NO, NO, BTN2,MS_L,MS_D,MS_R,TRNS,NO, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, BTN2,BTN1,BTN4,BTN5,NO, PGUP, P1, P2, P3, PENT, + NO, LALT, BTN1, LGUI,BSLS,HOME,END, PGDN, P0, PDOT + ), +}; + + +/* + * Fn action definition + */ +const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), + [2] = ACTION_LAYER_TAP_KEY(3, KC_SPACE), + [3] = ACTION_LAYER_TAP_KEY(4, KC_SCOLON), +}; diff --git a/converter/m0110_usb/keymap_intl.c b/converter/m0110_usb/keymap_intl.c new file mode 100644 index 00000000..6cc251a2 --- /dev/null +++ b/converter/m0110_usb/keymap_intl.c @@ -0,0 +1,73 @@ +/* +Copyright 2015 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 +#include "keycode.h" +#include "keymap_common.h" + + + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* International keyboard + * M0110 M0120 + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Nlk| -| +| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Ret| | 7| 8| 9| /| + * |------------------------------------------------------, | |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| \| | | 4| 5| 6| ,| + * |---------------------------------------------------------| |---------------| + * |Shif| <| Z| X| C| V| B| N| M| ,| ,| /| | | 1| 2| 3| | + * `---------------------------------------------------------' |-----------|Ent| + * |Opt|Mac | Space |Fn | | | 0| .| | + * `-----------------------------------------------' `---------------' + */ + [0] = KEYMAP_INTL( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,EQL, PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,ENT, P7, P8, P9, PMNS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS, P4, P5, P6, PPLS, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, P1, P2, P3, PENT, + LALT,LGUI, SPC, FN0, P0, PDOT + ), + /* Cursor Layer + * ,---------------------------------------------------------. ,---------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| -| +| *| + * |---------------------------------------------------------| |---------------| + * |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up | |Ret| | 7| 8| 9| /| + * |------------------------------------------------------, | |---------------| + * |Ctrl |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Ins| | | 4| 5| 6| ,| + * |---------------------------------------------------------| |---------------| + * |Shif| <|End| |PgD| | | | |End|PgD|Dow| | | 1| 2| 3| | + * `---------------------------------------------------------' |-----------|Ent| + * |Opt|Mac | Space |Fn | | | 0| .| | + * `-----------------------------------------------' `---------------' + */ + [1] = KEYMAP_INTL( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + CAPS,HOME,UP, PGUP,NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, ENT, P7, P8, P9, PMNS, + LCTL,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT,INS, P4, P5, P6, PPLS, + LSFT,NO, END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, P1, P2, P3, PENT, + LALT,LGUI, SPC, FN0, P0, PDOT + ), +}; + + +/* + * Fn action definition + */ +const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/converter/m0110_usb/keymap_spacefn.c b/converter/m0110_usb/keymap_spacefn.c new file mode 100644 index 00000000..5017861a --- /dev/null +++ b/converter/m0110_usb/keymap_spacefn.c @@ -0,0 +1,71 @@ +/* +Copyright 2014 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 +#include "keycode.h" +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default: + * M0110 M0120 + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Nlk| -| +| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| | 7| 8| 9| /| + * |---------------------------------------------------------| |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| ,| + * |---------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| | + * `---------------------------------------------------------' |-----------|Ent| + * |Opt|Mac | Space |Mac |Opt| | 0| .| | + * `-----------------------------------------------' `---------------' + * M0110A + * ,---------------------------------------------------------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Nlk| =| /| *| + * |---------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7| 8| 9| -| + * |-----------------------------------------------------' | |---------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return| | 4| 5| 6| +| + * |---------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| | + * |---------------------------------------------------------' |-----------|Ent| + * |Opt |Mac | Space | \|Lft|Rgt|Dn | | 0| .| | + * `---------------------------------------------------------' `---------------' + */ + [0] = KEYMAP( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, NLCK,PEQL,PSLS,PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT, + LALT,LGUI, FN0, RGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT + ), + [1] = KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, NLCK,EQL, PSLS,PAST, + TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS, P7, P8, P9, PMNS, + LCTL,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS, P4, P5, P6, PPLS, + TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP, PGUP, P1, P2, P3, PENT, + TRNS,TRNS, TRNS, TRNS,INS, HOME,END, PGDN, P0, PDOT + ), +}; + +/* + * Fn action definition + */ +const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde +}; diff --git a/converter/m0110_usb/led.c b/converter/m0110_usb/led.c new file mode 100644 index 00000000..3822a131 --- /dev/null +++ b/converter/m0110_usb/led.c @@ -0,0 +1,32 @@ +/* +Copyright 2011 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 +#include +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "util.h" +#include "debug.h" +#include "host.h" +#include "led.h" +#include "m0110.h" +#include "matrix.h" + + +#define CAPS 0x39 +#define CAPS_BREAK (CAPS | 0x80) +#define ROW(key) ((key)>>3&0x0F) +#define COL(key) ((key)&0x07) + + +static bool is_modified = false; + +// matrix state buffer(1:on, 0:off) +static uint8_t *matrix; +static uint8_t _matrix0[MATRIX_ROWS]; + +static void register_key(uint8_t key); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + m0110_init(); + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; + matrix = _matrix0; + + // LED flash + DDRD |= (1<<6); PORTD |= (1<<6); + _delay_ms(500); + DDRD |= (1<<6); PORTD &= ~(1<<6); + + return; +} + +uint8_t matrix_scan(void) +{ + uint8_t key; + + is_modified = false; + key = m0110_recv_key(); + + if (key == M0110_NULL) { + return 0; + } else if (key == M0110_ERROR) { + return 0; + } else { + is_modified = true; + register_key(key); + } + + if (debug_enable) { + print("["); phex(key); print("]\n"); + } + return 1; +} + +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< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x5021 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT SONY NEWS keyboard converter +#define DESCRIPTION converts SONY NEWS protocol into USB + + +/* matrix size */ +#define MATRIX_ROWS 16 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ +) + + +/* Asynchronous USART + * 8-data bit, non parity, 1-stop bit, no flow control + */ +#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) +# define NEWS_KBD_RX_VECT USART1_RX_vect +# define NEWS_KBD_RX_DATA UDR1 +# define NEWS_KBD_RX_BAUD 9600 +# define NEWS_KBD_RX_UBBR ((F_CPU/(16UL*NEWS_KBD_RX_BAUD))-1) +# define NEWS_KBD_RX_INIT() do { \ + UBRR1L = (uint8_t) NEWS_KBD_RX_UBBR; \ + UBRR1H = (uint8_t) (NEWS_KBD_RX_UBBR>>8); \ + UCSR1B |= (1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x5021 +#define MANUFACTURER t.m.k. +#define PRODUCT SONY NEWS keyboard converter +#define DESCRIPTION converts SONY NEWS protocol into USB + + +/* matrix size */ +#define MATRIX_ROWS 16 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ +) + + +/* Asynchronous USART + * 8-data bit, non parity, 1-stop bit, no flow control + */ +#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) +# define NEWS_KBD_RX_VECT USART1_RX_vect +# define NEWS_KBD_RX_DATA UDR1 +# define NEWS_KBD_RX_BAUD 9600 +# define NEWS_KBD_RX_UBBR ((F_CPU/(16UL*NEWS_KBD_RX_BAUD))-1) +# define NEWS_KBD_RX_INIT() do { \ + UBRR1L = (uint8_t) NEWS_KBD_RX_UBBR; \ + UBRR1H = (uint8_t) (NEWS_KBD_RX_UBBR>>8); \ + UCSR1B |= (1< + +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 +#include +#include +#include "keycode.h" +#include "util.h" +#include "keymap.h" + + + + +// Following macros help you to define a keymap with the form of actual keyboard layout. + +/* SONY NEWS NWP-5461 */ +#define KEYMAP( \ + K7A, K01,K02,K03,K04,K05, K06,K07,K08,K09,K0A, K68,K69, K64,K65,K52, \ + K0B,K0C,K0D,K0E,K0F,K10,K11,K12,K13,K14,K15,K16,K17,K18,K19, K6A, K4B,K4C,K4D,K4E, \ + K1A,K1B,K1C,K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27, K6B, K4F,K50,K51,K56, \ + K28,K29,K2A,K2B,K2C,K2D,K2E,K2F,K30,K31,K32,K33,K34, K35, K6C, K53,K54,K55,K5A, \ + K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K42, K6D, K57,K59,K58, \ + K43,K44,K45, K46, K47, K48,K49,K4A, K6E, K66,K5B,K5C,K5D \ +) { \ + { KC_NO, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_##K7A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} + + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 0, // Fn0 + 0, // Fn1 + 0, // Fn2 + 0, // Fn3 + 0, // Fn4 + 0, // Fn5 + 0, // Fn6 + 0 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_NO, // Fn1 + KC_NO, // Fn2 + KC_NO, // Fn3 + KC_NO, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,------------------------, ,------------------------. ,---------. + * |Pow| | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10| | F11| F12| ,-----------. + * `---' `------------------------' `------------------------' `---------' | *| /| +| + * ,-------------------------------------------------------------. ,---. ,---------------| + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| BS | |Hlp| | 7| 8| 9| -| + * |-------------------------------------------------------------| |---| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Del| | |Ins| | 4| 5| 6| ,| + * |---------------------------------------------------------' | |---| |---------------| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| `|Return| |Clr| | 1| 2| 3| | + * |-------------------------------------------------------------| |---| |-----------|Ent| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /| |Shift | |PgU| | 0| .| Up| | + * |-------------------------------------------------------------| |---| |---------------| + * |Alt |Gui |Alt | Space | |Gui|App|Ctrl | |PgD| |Tab|Lef|Dow|Rig| + * `-------------------------------------------------------------' `---' `---------------' + */ + KEYMAP( + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PAST,PSLS,PPLS, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC, HELP, P7, P8, P9, PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,DEL, INS, P4, P5, P6, PCMM, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,GRV, ENT, CLR, P1, P2, P3, PENT, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, RSFT, PGUP, P0, PDOT,UP, + LALT,CAPS,LALT, SPC, ERAS, RALT,RGUI,RCTL, PGDN, TAB, LEFT,DOWN,RGHT + ), +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/converter/news_usb/led.c b/converter/news_usb/led.c new file mode 100644 index 00000000..51e60131 --- /dev/null +++ b/converter/news_usb/led.c @@ -0,0 +1,26 @@ +/* +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 "news.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + // not supported now +} diff --git a/converter/news_usb/matrix.c b/converter/news_usb/matrix.c new file mode 100644 index 00000000..f0d5b586 --- /dev/null +++ b/converter/news_usb/matrix.c @@ -0,0 +1,142 @@ +/* +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "news.h" +#include "matrix.h" +#include "debug.h" + + +/* + * Matrix Array usage: + * + * ROW: 16 + * COL:8 + * + * 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; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + news_init(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + return; +} + +uint8_t matrix_scan(void) +{ + is_modified = false; + + uint8_t code; + code = news_recv(); + if (code == 0) { + return 0; + } + + phex(code); print(" "); + if (code&0x80) { + // break code + if (matrix_is_on(ROW(code), COL(code))) { + matrix[ROW(code)] &= ~(1< +Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xBCBC +#define DEVICE_VER 0x0500 +#define MANUFACTURER t.m.k. +#define PRODUCT NeXT Keyboard to USB converter +#define DESCRIPTION USB converter for NeXT non-ADB Keyboard + +/* matrix size */ +#define MATRIX_ROWS 12 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + +#define DEBUG_ON_INIT 1 + +//#define TEENSY_CONFIG 1 +//#define PRO_MICRO_CONFIG 1 +#define TMK_CONFIG 1 + +// comment out if you don't want the keyboard's LEDs to flash upon initialization or pressing shift +//#define NEXT_KBD_INIT_FLASH_LEDS +//#define NEXT_KBD_SHIFT_FLASH_LEDS + +//============= Start of Arduino Pro Micro Configuration ============== +#ifdef PRO_MICRO_CONFIG + +// this is the debugging LED that flashes when a key is being pressed +// comment out in order to disable debugging LED +#define NEXT_KBD_LED1_PORT PORTD +#define NEXT_KBD_LED1_PIN PIND +#define NEXT_KBD_LED1_DDR DDRD +#define NEXT_KBD_LED1_BIT 5 + +#define NEXT_KBD_LED1_ON NEXT_KBD_LED1_PORT &= ~(1<mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) || \ + (keyboard_report->mods == (MOD_BIT(KC_RALT) | MOD_BIT(KC_RALT))) || \ + (keyboard_report->mods == (MOD_BIT(KC_RGUI) | MOD_BIT(KC_RGUI))) \ +) diff --git a/converter/next_usb/keymap.c b/converter/next_usb/keymap.c new file mode 100644 index 00000000..0041df54 --- /dev/null +++ b/converter/next_usb/keymap.c @@ -0,0 +1,177 @@ +/* +NeXT non-ADB Keyboard USB Converter + +Copyright 2013, Benjamin Gould (bgould@github.com) + +Based on: +--------- +* TMK firmware code Copyright 2011,2012 Jun WAKO +* Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/) \ + released under BSD license \ + https://github.com/adafruit/USB-NeXT-Keyboard + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +#include "keycode.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "keymap.h" +#include "keycode.h" + +// 32*8(256) byte array which converts PS/2 code into USB code +static const uint16_t PROGMEM fn_actions[] = { + ACTION_LAYER_MOMENTARY(1), // FN0 - left command key + ACTION_LAYER_MOMENTARY(1), // FN1 - right command key + ACTION_KEY(KC_BSLS), // FN2 - number pad slash & backslash + ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // FN3 - number pad equals & pipe + ACTION_MODS_KEY(MOD_LCTL, KC_Z), // FN4 - cmd+undo on layer 1 + ACTION_MODS_KEY(MOD_LCTL, KC_X), // FN5 - cmd+cut on layer 1 + ACTION_MODS_KEY(MOD_LCTL, KC_C), // FN6 - cmd+copy on layer 1 + ACTION_MODS_KEY(MOD_LCTL, KC_V), // FN7 - cmd+paste on layer 1 +}; + +/* This is the physical layout that I am starting with: + * Note: there is some strangeness on the number pad; + * the equal sign shifts to pipe and forward slash shifts to backslash + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| BS | |VUp|Pwr|BrU| |` | =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |VDn| |BrD| | 7| 8| 9| -| + * |------------------------------------------------------ | `---' `---' |-----------|---| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| Return| | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Alt |Cmd | Space |Cmd |Alt | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + * + * Keymap array: + * 8 bytes + * +---------+ + * 0| | + * :| | 0x00-0x87 + * ;| | + * 11| | + * +---------+ + */ +#define KEYMAP( \ + K49,K4A,K4B,K4C,K4D,K50,K4F,K4E,K1E,K1F,K20,K1D,K1C,K1B, K1A,K58,K19, K26,K27,K28,K25, \ + K41,K42,K43,K44,K45,K48,K47,K46,K06,K07,K08,K05,K04,K03, K02, K01, K21,K22,K23,K24, \ + K57,K39,K3A,K3B,K3C,K3D,K40,K3F,K3E,K2D,K2C,K2B, K2A, K12,K18,K13,K15, \ + K56, K31,K32,K33,K34,K35,K37,K36,K2E,K2F,K30, K55, K16, K11,K17,K14, \ + K52,K54, K38, K53,K51, K09,K0F,K10, K0B, K0C,K0D \ +) { \ + { KC_NO, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K10, KC_##K0B, KC_##K0C, KC_##K0D, KC_NO, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_NO, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, }, \ +} + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Layer 0: default + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| BS | |Ins|Ref|Hom| |` | =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |Del| |End| | 7| 8| 9| -| + * |-----------------------------------------------------' | `---' `---' |-----------|---| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| Return| | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Fn0 |Alt | Space |LGui |Fn1 | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, WREF,HOME, GRV, FN3, FN2, PAST, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,NO, DEL, END, P7, P8, P9, PMNS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + FN0, LALT, SPC, LGUI,FN1, LEFT,DOWN,RGHT, P0, PDOT,PENT + + ), + + /* Layer 1: extra keys + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * |Grv| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| BS | |VUp|VMu|PgU| |` | =| /| *| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab |Pau| W| E| R| T| Y| U| I| O|PSc| \| ]| | |VDn| |PgD| | 7| 8| 9| -| + * |-----------------------------------------------------' | `---' `---' |-----------|---| + * |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| Return| | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift |UND|CUT|COP|PST| B| N| M| ,| .| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Fn0 |Alt | Space |RGui |Fn1 | |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP( + + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, VOLU,MUTE,PGUP, TRNS,TRNS,TRNS,TRNS, + TRNS,PAUS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,FN3, BSLS,TRNS, VOLD, PGDN, BTN1,MS_U,BTN2,WH_U, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, MS_L,MS_D,MS_R,WH_D, + TRNS, FN4, FN5, FN6, FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS, TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS + + ) +}; + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/next_usb/led.c b/converter/next_usb/led.c new file mode 100644 index 00000000..2bd0ef6d --- /dev/null +++ b/converter/next_usb/led.c @@ -0,0 +1,60 @@ +/* +NeXT non-ADB Keyboard USB Converter + +Copyright 2013, Benjamin Gould (bgould@github.com) + +Based on: +TMK firmware code Copyright 2011,2012 Jun WAKO +Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "stdint.h" +#include "led.h" +#include "next_kbd.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< +Arduino code by "Ladyada" Limor Fried (http://ladyada.net/, http://adafruit.com/), released under BSD license + +Timing reference thanks to http://m0115.web.fc2.com/ (dead link), http://cfile7.uf.tistory.com/image/14448E464F410BF22380BB +Pinouts thanks to http://www.68k.org/~degs/nextkeyboard.html +Keycodes from http://ftp.netbsd.org/pub/NetBSD/NetBSD-release-6/src/sys/arch/next68k/dev/ + +This software is licensed with a Modified BSD License. +All of this is supposed to be Free Software, Open Source, DFSG-free, +GPL-compatible, and OK to use in both free and proprietary applications. +Additions and corrections to this file are welcome. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +* Neither the name of the copyright holders nor the names of + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include +#include +#include +#include +#include "print.h" +#include "util.h" +#include "serial.h" +#include "matrix.h" +#include "debug.h" +#include "matrix.h" +#include "next_kbd.h" + +static void matrix_make(uint8_t code); +static void matrix_break(uint8_t code); + +static uint8_t matrix[MATRIX_ROWS]; +#define ROW(code) ((code>>3)&0xF) +#define COL(code) (code&0x07) + +static bool is_modified = false; + +/* number of matrix rows */ +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +/* number of matrix columns */ +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +#ifndef NEXT_KBD_LED1_ON +#define NEXT_KBD_LED1_ON +#endif + +#ifndef NEXT_KBD_LED1_OFF +#define NEXT_KBD_LED1_OFF +#endif + +#define NEXT_KBD_PWR_READ (NEXT_KBD_PWR_PIN&(1<>1) +#define NEXT_KBD_PRESSED_KEYCODE(response) (uint8_t)(((response)&0xF00)==0x400) +#define NEXT_KBD_PRESSED(response, mask) (uint8_t)(((response)&mask)>0) +#define NEXT_KBD_PRESSED_CONTROL(response) NEXT_KBD_PRESSED(response,0x01000) +#define NEXT_KBD_PRESSED_SHIFT_LEFT(response) NEXT_KBD_PRESSED(response,0x02000) +#define NEXT_KBD_PRESSED_SHIFT_RGHT(response) NEXT_KBD_PRESSED(response,0x04000) +#define NEXT_KBD_PRESSED_CMD_LEFT(response) NEXT_KBD_PRESSED(response,0x08000) +#define NEXT_KBD_PRESSED_CMD_RGHT(response) NEXT_KBD_PRESSED(response,0x10000) +#define NEXT_KBD_PRESSED_ALT_LEFT(response) NEXT_KBD_PRESSED(response,0x20000) +#define NEXT_KBD_PRESSED_ALT_RGHT(response) NEXT_KBD_PRESSED(response,0x40000) +#define NEXT_KBD_MAKE_OR_BREAK(key, code) \ + do { \ + if (NEXT_KBD_PRESSED_##key(resp) > 0) \ + matrix_make(code); \ + else \ + matrix_break(code); \ + } while (0); + +#define NEXT_KBD_PWR_KEYCODE 0x58 + +/* scan all key states on matrix */ +uint8_t matrix_scan(void) +{ + _delay_ms(5); + + //next_kbd_set_leds(false, false); + NEXT_KBD_LED1_OFF; + + is_modified = false; + + if (!NEXT_KBD_PWR_READ) { + matrix_make(NEXT_KBD_PWR_KEYCODE); + power_state = 1; + if (is_modified) + { + dprintf("Power state 1\n"); + + } + } else { + matrix_break(NEXT_KBD_PWR_KEYCODE); + power_state = 0; + if (is_modified) + { + dprintf("Power state 0\n"); + + } + } + + uint32_t resp = (next_kbd_recv()); + + if (!resp || resp == NEXT_KBD_KMBUS_IDLE) + { + return 0; + } + + NEXT_KBD_LED1_ON; + +#ifdef NEXT_KBD_SHIFT_FLASH_LEDS + next_kbd_set_leds( + NEXT_KBD_PRESSED_SHIFT_LEFT(resp) ? true : false, + NEXT_KBD_PRESSED_SHIFT_RGHT(resp) ? true : false + ); +#endif + + dprintf("[ r=%04lX keycode=%02X pressed=%X CTRL=%X SHIFT_LEFT=%X SHIFT_RGHT=%X CMD_LEFT=%X CMD_RGHT=%X ALT_LEFT=%X ALT_RGHT=%X ]\n", \ + resp, \ + NEXT_KBD_KEYCODE(resp), \ + NEXT_KBD_PRESSED_KEYCODE(resp), \ + NEXT_KBD_PRESSED_CONTROL(resp), \ + NEXT_KBD_PRESSED_SHIFT_LEFT(resp), \ + NEXT_KBD_PRESSED_SHIFT_RGHT(resp), \ + NEXT_KBD_PRESSED_CMD_LEFT(resp), \ + NEXT_KBD_PRESSED_CMD_RGHT(resp), \ + NEXT_KBD_PRESSED_ALT_LEFT(resp), \ + NEXT_KBD_PRESSED_ALT_RGHT(resp) \ + ); + + // Modifier keys don't return keycode; have to check the upper bits + NEXT_KBD_MAKE_OR_BREAK(ALT_RGHT, 0x51); + NEXT_KBD_MAKE_OR_BREAK(ALT_LEFT, 0x52); + NEXT_KBD_MAKE_OR_BREAK(CMD_RGHT, 0x53); + NEXT_KBD_MAKE_OR_BREAK(CMD_LEFT, 0x54); + NEXT_KBD_MAKE_OR_BREAK(SHIFT_RGHT, 0x55); + NEXT_KBD_MAKE_OR_BREAK(SHIFT_LEFT, 0x56); + NEXT_KBD_MAKE_OR_BREAK(CONTROL, 0x57); + NEXT_KBD_MAKE_OR_BREAK(KEYCODE, NEXT_KBD_KEYCODE(resp)); + + return 1; +} + +/* whether modified from previous scan. used after matrix_scan. */ +bool matrix_is_modified() +{ + return is_modified; +} + +/* whether a switch is on */ +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x9898 +#define DEVICE_VER 0x0100 +#define MANUFACTURER t.m.k. +#define PRODUCT PC98 keyboard converter +#define DESCRIPTION converts PC98 keyboard protocol into USB + + +/* matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 8 + +/* key combination for command */ +#define IS_COMMAND() ( \ + host_get_first_key() == KC_CANCEL \ +) + + +/* PC98 Reset Port shared with TXD */ +#define PC98_RST_DDR DDRD +#define PC98_RST_PORT PORTD +#define PC98_RST_BIT 3 +/* PC98 Ready Port */ +#define PC98_RDY_DDR DDRD +#define PC98_RDY_PORT PORTD +#define PC98_RDY_BIT 4 +/* PC98 Retry Port */ +#define PC98_RTY_DDR DDRD +#define PC98_RTY_PORT PORTD +#define PC98_RTY_BIT 5 + +/* + * PC98 Serial(USART) configuration + * asynchronous, positive logic, 19200baud, bit order: LSB first + * 1-start bit, 8-data bit, odd parity, 1-stop bit + */ +/* + * Software Serial + */ +#define SERIAL_SOFT_BAUD 19200 +#define SERIAL_SOFT_PARITY_ODD +#define SERIAL_SOFT_BIT_ORDER_LSB +#define SERIAL_SOFT_LOGIC_POSITIVE +/* RXD Port */ +#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_READ() (SERIAL_SOFT_RXD_PIN&(1<>8); /* baud rate */ \ + UCSR1B |= (1< + +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 +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "util.h" +#include "keymap.h" + + + + +/* PC-9801-98-S02 Raku Raku keyboard(Luckyboard) Normal Mode + ,---------------------------------------------------------------. + | 60| 61| 62| 63| 64| 65| 66| 67| 68| 69| 6A| 6B| 36| 37| 3F| 3E| + `---------------------------------------------------------------' + ,---------------------------------------------------------------. + | 00| 01| 02| 03| 04| 05| 58| 71| 06| 07| 08| 09| 0A| 0E| + |---------------------------------------------------------------| + | 0F| 10| 11| 12| 13| 14| 3A | 15| 16| 17| 18| 19| 1C| + |---------------------------------------------------------'. | + | 74| 20| 21| 22| 23| 24| 3B | 3C | 25| 26| 27| 28| 29| | + |---------------------------------------------------------------| + | 70| 2A| 2B| 2C| 2D| 2E| 38| 3D | 39| 2F| 30| 31| 32| 33| 70| + `---------------------------------------------------------------' + | 73| 51| 5B| 59| 34| 5A| 35| xx| + `-----------------------------------------------' + xx: 74 35 F4 B5 +*/ +#define KEYMAP( \ + K60, K61, K62, K63, K64, K65, K66, K67, K68, K69, K6A, K6B, K36, K37, K3F, K3E, \ + K00, K01, K02, K03, K04, K05, K58, K71, K06, K07, K08, K09, K0A, K0E, \ + K0F, K10, K11, K12, K13, K14, K3A, K15, K16, K17, K18, K19, K1C, \ + K74, K20, K21, K22, K23, K24, K3B, K3C, K25, K26, K27, K28, K29, \ + K70,K2A, K2B, K2C, K2D, K2E, K38, K3D, K39, K2F, K30, K31, K32, K33, \ + K73, K51, K5B, K59, K34, K5A, K35 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_NO, KC_NO, KC_NO, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_NO, KC_NO, KC_##K1C, KC_NO, KC_NO, KC_NO }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##K51, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##K70, KC_##K71, KC_NO, KC_##K73, KC_##K74, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} + + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* + ,---------------------------------------------------------------. + | 60| 61| 62| 63| 64| 65| 66| 67| 68| 69| 6A| 6B| 36| 37| 3F| 3E| + `---------------------------------------------------------------' + ,---------------------------------------------------------------. + | 00| 01| 02| 03| 04| 05| 58| 71| 06| 07| 08| 09| 0A| 0E| + |---------------------------------------------------------------| + | 0F| 10| 11| 12| 13| 14| 3A | 15| 16| 17| 18| 19| 1C| + |---------------------------------------------------------------| + | 74| 20| 21| 22| 23| 24| MINS| EQL| 25| 26| 27| 28| 29| | + |---------------------------------------------------------------| + | 70| 2A| 2B| 2C| 2D| 2E| 38| 3D | 39| 2F| 30| 31| 32| 33| 70| + `---------------------------------------------------------------' + | 73| 51| 5B| 59| 34| 5A| 35| xx| + `-----------------------------------------------' + */ + 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 + ), + 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 + ), +}; +static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {}; + +/* + * Macro definition + */ +enum macro_id { + LBRACKET, + RBRACKET, + DUMMY, +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + keyevent_t event = record->event; + //uint8_t tap_count = record->tap_count; + + switch (id) { + case LBRACKET: + return (event.pressed ? + MACRO( T(LBRC), END ) : + MACRO( T(LBRC), END ) ); + case RBRACKET: + return (event.pressed ? + MACRO( T(RBRC), END ) : + MACRO( T(RBRC), END ) ); + } + return MACRO_NONE; +} + +/* + * Action function + */ +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ +/* + keyevent_t event = record->event; + uint8_t tap_count = record->tap_count; + switch (id) { + case 0xFF: + action_macro_play(get_macro(opt, event.pressed)); + break; + } +*/ +} + + +/* + * Fn actions + */ +static const uint16_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 +}; + + + + + + +/* + * No need to edit. + */ +#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + if (layer < KEYMAPS_SIZE) { + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); + } else { + // fall back to layer 0 + return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); + } +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} diff --git a/converter/pc98_usb/led.c b/converter/pc98_usb/led.c new file mode 100644 index 00000000..48c3f1c2 --- /dev/null +++ b/converter/pc98_usb/led.c @@ -0,0 +1,33 @@ +/* +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< + +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "matrix.h" +#include "debug.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; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +static void pc98_inhibit_repeat(void) +{ + uint8_t code; + + while (serial_recv()) ; +RETRY: + PC98_RDY_PORT |= (1< +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBasp 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=2048 + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/ps2_usb/README.md b/converter/ps2_usb/README.md new file mode 100644 index 00000000..74464e26 --- /dev/null +++ b/converter/ps2_usb/README.md @@ -0,0 +1,84 @@ +PS/2 to USB keyboard converter +============================== +This firmware converts PS/2 keyboard protocol to USB.(It supports Scan Code Set 2.) + + +Connect Wires +------------- +In case of Teensy2.0(ATMega32U4): + +1. Connect **Vcc** and **GND**. +2. Connect **Clock** and **Data** line. + - **Interrupt**: **Clock** is on `PD1` and **Data** on `PD0`.(Recommended. Soarer's converter compatible) + - **Busywait**: **Clock** is on `PD1` and **Data** on `PD0`. + - **USART**: **Clock** is on `PD5` and **Data** on `PD2`. +3. Optionally you need pull-up resistor. 1K-10K Ohm is OK. + +To change pin configuration edit **config.h** and **Makefile**. + + +Build Firmware +-------------- +For **PJRC Teensy** just run `make`: + + $ make clean + $ make + +To select keymap: + + $ make clean + $ make KEYMAP=[plain|jis|spacefn|...] + +After that you will find HEX file `ps2_usb_lufa.hex` in current directory. + + +- For **TMK converter Rev.1** use `make -f Makefile.tmk_rev1` instead of `make` and HEX file is `ps2_usb_tmk_rev1.hex`. + +- For **TMK converter Rev.2** use `make -f Makefile.tmk_rev2` instead of `make` and HEX file is `ps2_usb_tmk_rev2.hex`. + + +Keymap +------ +Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_.c` and see keymap document(you can find in README.md of top directory) and existent keymap files. + + +PS/2 signal handling implementations +------------------------------------ +Following three methods can be used to implement PS/2 signal handling. + +### Simple and stupid busy-wait(ps2_busywait.c) + This is expected to implemented with portable C code for reference. +### Interrupt driven(ps2_interrupt.c) + Uses pin interrupt to detect falling edge of clock line. +### USART hardware module(ps2_usart.c) + Uses AVR USART engine to receive PS/2 signal. + +To select method edit Makefile. + + +V-USB Support +------------- +With V-USB you can use this converter on ATmega(168/328) but it doesn't support NKRO at this time. + +Circuit: + + +---+ +---------------+ + USB GND | | ATmega168 | + === C3 | | + 5V <-------+--------+---|Vcc,AVCC | PS/2 + R1 | | ==== + D- <----+--+-----R2-----|INT1 RXD|------->DATA + D+ <----|---+----R3-----|INT0 XCK|------->CLOCK + Z1 Z2 | | ->5V + GND<----+---+--+--+-----|GND | ->GND + | | | | + | C2-+--|XTAL1 | + | X1 | | + +--C3-+--|XTAL2 | + +---------------+ + R1: 1.5K Ohm + R2,R3: 68 Ohm + Z1,Z2: Zenner 3.6V + C1,C2: 22pF + C3: 0.1uF + X1: Crystal 20MHz(16MHz/12MHz) diff --git a/converter/ps2_usb/config.h b/converter/ps2_usb/config.h new file mode 100644 index 00000000..35eb414f --- /dev/null +++ b/converter/ps2_usb/config.h @@ -0,0 +1,196 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6512 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT PS/2 keyboard converter +#define DESCRIPTION convert PS/2 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 32 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ +) + + +//#define NO_SUSPEND_POWER_DOWN + + +/* + * PS/2 Busywait + */ +#ifdef PS2_USE_BUSYWAIT +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 1 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 0 +#endif + +/* + * PS/2 Pin interrupt + */ +#ifdef PS2_USE_INT +#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) +/* uses INT1 for clock line(ATMega32U4) */ +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 1 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 0 +#define PS2_INT_INIT() do { \ + EICRA |= ((1< + +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 . +*/ + +#ifndef CONFIG_MBED_H +#define CONFIG_MBED_H + + +#if 0 +// duplicated name against mbed USBDeivce +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6512 +#endif +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT PS/2 keyboard converter +#define DESCRIPTION convert PS/2 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 32 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ +) + + +/* + * PS/2 Busywait + */ +#ifdef PS2_USE_BUSYWAIT +# define PS2_CLOCK_PORT PORTD +# define PS2_CLOCK_PIN PIND +# define PS2_CLOCK_DDR DDRD +# define PS2_CLOCK_BIT 5 +# define PS2_DATA_PORT PORTD +# define PS2_DATA_PIN PIND +# define PS2_DATA_DDR DDRD +# define PS2_DATA_BIT 2 +#endif + + +#endif diff --git a/converter/ps2_usb/config_tmk_rev1.h b/converter/ps2_usb/config_tmk_rev1.h new file mode 100644 index 00000000..75dc97df --- /dev/null +++ b/converter/ps2_usb/config_tmk_rev1.h @@ -0,0 +1,147 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6512 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT PS/2 keyboard converter +#define DESCRIPTION convert PS/2 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 32 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) || \ + keyboard_report->mods == (MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RSHIFT)) \ +) + + +//#define NO_SUSPEND_POWER_DOWN + + +/* + * PS/2 Busywait + */ +#ifdef PS2_USE_BUSYWAIT +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 5 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 2 +#endif + +/* + * PS/2 USART + */ +#ifdef PS2_USE_USART +#if defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) +/* XCK for clock line and RXD for data line */ +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 5 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 2 +/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ +/* set DDR of CLOCK as input to be slave */ +#define PS2_USART_INIT() do { \ + PS2_CLOCK_DDR &= ~(1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6512 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT PS/2 keyboard converter +#define DESCRIPTION convert PS/2 keyboard to USB + + +/* matrix size */ +#define MATRIX_ROWS 32 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + +//#define NO_SUSPEND_POWER_DOWN + + +/* + * PS/2 Busywait + */ +#ifdef PS2_USE_BUSYWAIT +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 1 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 0 +#endif + +/* + * PS/2 Pin interrupt + */ +#ifdef PS2_USE_INT +/* uses INT1 for clock line(ATMega32U4) */ +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 1 +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 0 +#define PS2_INT_INIT() do { \ + EICRA |= ((1< + +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 "keymap_common.h" +#include "progmem.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/ps2_usb/keymap_common.h b/converter/ps2_usb/keymap_common.h new file mode 100644 index 00000000..d783e01d --- /dev/null +++ b/converter/ps2_usb/keymap_common.h @@ -0,0 +1,173 @@ +/* +Copyright 2011,2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +// 32*8(256) byte array which converts PS/2 code into USB code +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* All keys */ +#define KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + K61, /* for European ISO */ \ + K51, K13, K6A, K64, K67, /* for Japanese JIS */ \ + K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \ + KB7, KBF, KDE, /* System Power, Sleep, Wake */ \ + KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \ + KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \ + KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \ + K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \ + KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \ +) { \ + { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \ + { KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \ + { KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \ + { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \ + { KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \ + { KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \ + { KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \ + { KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \ + { KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \ + { KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \ + { KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \ + { KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \ + { KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \ +} + +/* US layout */ +#define KEYMAP( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + NUBS, \ + RO, KANA, JYEN, HENK, MHEN, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +/* ISO layout */ +#define KEYMAP_ISO( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \ + K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + K61, \ + RO, KANA, JYEN, HENK, MHEN, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +/* JIS layout */ +#define KEYMAP_JIS( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + NUBS, \ + K51, K13, K6A, K64, K67, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +#endif diff --git a/converter/ps2_usb/keymap_jis.c b/converter/ps2_usb/keymap_jis.c new file mode 100644 index 00000000..02585150 --- /dev/null +++ b/converter/ps2_usb/keymap_jis.c @@ -0,0 +1,34 @@ +/* + * JIS layout Japanese keyboard + */ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: JIS LAYOUT + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| + * `---' `---------------' `---------------' `---------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| JY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Ret | |Del|End|PgD| | 7| 8| 9| | + * |------------------------------------------------------` | `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| :| \| | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Gui |Alt |MHEN| Space |HENK|KANA|Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP_JIS( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, END, PGDN, P7, P8, P9, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, MHEN,SPC, HENK,KANA, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/converter/ps2_usb/keymap_plain.c b/converter/ps2_usb/keymap_plain.c new file mode 100644 index 00000000..51b2fddb --- /dev/null +++ b/converter/ps2_usb/keymap_plain.c @@ -0,0 +1,32 @@ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| + * `---' `---------------' `---------------' `---------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/converter/ps2_usb/keymap_spacefn.c b/converter/ps2_usb/keymap_spacefn.c new file mode 100644 index 00000000..bffd2bc6 --- /dev/null +++ b/converter/ps2_usb/keymap_spacefn.c @@ -0,0 +1,61 @@ +/* + * SpaceFN layout + * http://geekhack.org/index.php?topic=51069.0 + */ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| + * `---' `---------------' `---------------' `---------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, FN0, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* 1: SpaceFN + * ,-----------------------------------------------------------. + * |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins | + * |-----------------------------------------------------------| + * | | | | | | |PgU|Lef|Dow|Rig| | | | + * |-----------------------------------------------------------| + * | | | | | |Spc|PgD|` |~ | |Men| | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + */ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS,INS, DEL, END, PGDN, P7, P8, P9, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS, P4, P5, P6, PPLS, + TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP, TRNS, UP, P1, P2, P3, + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde +}; + diff --git a/converter/ps2_usb/led.c b/converter/ps2_usb/led.c new file mode 100644 index 00000000..e448e84e --- /dev/null +++ b/converter/ps2_usb/led.c @@ -0,0 +1,33 @@ +/* +Copyright 2011 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 "ps2.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + uint8_t ps2_led = 0; + if (usb_led & (1< + +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 +#include +#include "action.h" +#include "print.h" +#include "util.h" +#include "debug.h" +#include "ps2.h" +#include "matrix.h" + + +static void matrix_make(uint8_t code); +static void matrix_break(uint8_t code); +static void matrix_clear(void); +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif + + +/* + * Matrix Array usage: + * 'Scan Code Set 2' is assigned into 256(32x8)cell matrix. + * Hmm, it is very sparse and not efficient :( + * + * Notes: + * Both 'Hanguel/English'(F1) and 'Hanja'(F2) collide with 'Delete'(E0 71) and 'Down'(E0 72). + * These two Korean keys need exceptional handling and are not supported for now. Sorry. + * + * 8bit wide + * +---------+ + * 0| | + * :| XX | 00-7F for normal codes(without E0-prefix) + * f|_________| + * 10| | + * :| E0 YY | 80-FF for E0-prefixed codes + * 1f| | (|0x80) is used as matrix position. + * +---------+ + * + * Exceptions: + * 0x83: F7(0x83) This is a normal code but beyond 0x7F. + * 0xFC: PrintScreen + * 0xFE: Pause + */ +static uint8_t matrix[MATRIX_ROWS]; +#define ROW(code) (code>>3) +#define COL(code) (code&0x07) + +// matrix positions for exceptional keys +#define F7 (0x83) +#define PRINT_SCREEN (0xFC) +#define PAUSE (0xFE) + +static bool is_modified = false; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + debug_enable = true; + ps2_host_init(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + return; +} + +/* + * PS/2 Scan Code Set 2: Exceptional Handling + * + * There are several keys to be handled exceptionally. + * The scan code for these keys are varied or prefix/postfix'd + * depending on modifier key state. + * + * Keyboard Scan Code Specification: + * http://www.microsoft.com/whdc/archive/scancode.mspx + * http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc + * + * + * 1) Insert, Delete, Home, End, PageUp, PageDown, Up, Down, Right, Left + * a) when Num Lock is off + * modifiers | make | break + * ----------+---------------------------+---------------------- + * Ohter | | + * LShift | E0 F0 12 | E0 12 + * RShift | E0 F0 59 | E0 59 + * L+RShift | E0 F0 12 E0 F0 59 | E0 59 E0 12 + * + * b) when Num Lock is on + * modifiers | make | break + * ----------+---------------------------+---------------------- + * Other | E0 12 | E0 F0 12 + * Shift'd | | + * + * Handling: These prefix/postfix codes are ignored. + * + * + * 2) Keypad / + * modifiers | make | break + * ----------+---------------------------+---------------------- + * Ohter | | + * LShift | E0 F0 12 | E0 12 + * RShift | E0 F0 59 | E0 59 + * L+RShift | E0 F0 12 E0 F0 59 | E0 59 E0 12 + * + * Handling: These prefix/postfix codes are ignored. + * + * + * 3) PrintScreen + * modifiers | make | break + * ----------+--------------+----------------------------------- + * Other | E0 12 E0 7C | E0 F0 7C E0 F0 12 + * Shift'd | E0 7C | E0 F0 7C + * Control'd | E0 7C | E0 F0 7C + * Alt'd | 84 | F0 84 + * + * Handling: These prefix/postfix codes are ignored, and both scan codes + * 'E0 7C' and 84 are seen as PrintScreen. + * + * 4) Pause + * modifiers | make(no break code) + * ----------+-------------------------------------------------- + * Other | E1 14 77 E1 F0 14 F0 77 + * Control'd | E0 7E E0 F0 7E + * + * Handling: Both code sequences are treated as a whole. + * And we need a ad hoc 'pseudo break code' hack to get the key off + * because it has no break code. + * + */ +uint8_t matrix_scan(void) +{ + + // scan code reading states + static enum { + INIT, + F0, + E0, + E0_F0, + // Pause + E1, + E1_14, + E1_14_77, + E1_14_77_E1, + E1_14_77_E1_F0, + E1_14_77_E1_F0_14, + E1_14_77_E1_F0_14_F0, + // Control'd Pause + E0_7E, + E0_7E_E0, + E0_7E_E0_F0, + } state = INIT; + + + is_modified = false; + + // 'pseudo break code' hack + if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) { + matrix_break(PAUSE); + } + + uint8_t code = ps2_host_recv(); + if (code) xprintf("%i\r\n", code); + if (!ps2_error) { + switch (state) { + case INIT: + switch (code) { + case 0xE0: + state = E0; + break; + case 0xF0: + state = F0; + break; + case 0xE1: + state = E1; + break; + case 0x83: // F7 + matrix_make(F7); + state = INIT; + break; + case 0x84: // Alt'd PrintScreen + matrix_make(PRINT_SCREEN); + state = INIT; + break; + case 0x00: // Overrun [3]p.25 + matrix_clear(); + clear_keyboard(); + print("Overrun\n"); + state = INIT; + break; + default: // normal key make + if (code < 0x80) { + matrix_make(code); + } else { + matrix_clear(); + clear_keyboard(); + xprintf("unexpected scan code at INIT: %02X\n", code); + } + state = INIT; + } + break; + case E0: // E0-Prefixed + switch (code) { + case 0x12: // to be ignored + case 0x59: // to be ignored + state = INIT; + break; + case 0x7E: // Control'd Pause + state = E0_7E; + break; + case 0xF0: + state = E0_F0; + break; + default: + if (code < 0x80) { + matrix_make(code|0x80); + } else { + matrix_clear(); + clear_keyboard(); + xprintf("unexpected scan code at E0: %02X\n", code); + } + state = INIT; + } + break; + case F0: // Break code + switch (code) { + case 0x83: // F7 + matrix_break(F7); + state = INIT; + break; + case 0x84: // Alt'd PrintScreen + matrix_break(PRINT_SCREEN); + state = INIT; + break; + case 0xF0: + matrix_clear(); + clear_keyboard(); + xprintf("unexpected scan code at F0: F0(clear and cont.)\n"); + break; + default: + if (code < 0x80) { + matrix_break(code); + } else { + matrix_clear(); + clear_keyboard(); + xprintf("unexpected scan code at F0: %02X\n", code); + } + state = INIT; + } + break; + case E0_F0: // Break code of E0-prefixed + switch (code) { + case 0x12: // to be ignored + case 0x59: // to be ignored + state = INIT; + break; + default: + if (code < 0x80) { + matrix_break(code|0x80); + } else { + matrix_clear(); + clear_keyboard(); + xprintf("unexpected scan code at E0_F0: %02X\n", code); + } + state = INIT; + } + break; + // following are states of Pause + case E1: + switch (code) { + case 0x14: + state = E1_14; + break; + default: + state = INIT; + } + break; + case E1_14: + switch (code) { + case 0x77: + state = E1_14_77; + break; + default: + state = INIT; + } + break; + case E1_14_77: + switch (code) { + case 0xE1: + state = E1_14_77_E1; + break; + default: + state = INIT; + } + break; + case E1_14_77_E1: + switch (code) { + case 0xF0: + state = E1_14_77_E1_F0; + break; + default: + state = INIT; + } + break; + case E1_14_77_E1_F0: + switch (code) { + case 0x14: + state = E1_14_77_E1_F0_14; + break; + default: + state = INIT; + } + break; + case E1_14_77_E1_F0_14: + switch (code) { + case 0xF0: + state = E1_14_77_E1_F0_14_F0; + break; + default: + state = INIT; + } + break; + case E1_14_77_E1_F0_14_F0: + switch (code) { + case 0x77: + matrix_make(PAUSE); + state = INIT; + break; + default: + state = INIT; + } + break; + // Following are states of Control'd Pause + case E0_7E: + if (code == 0xE0) + state = E0_7E_E0; + else + state = INIT; + break; + case E0_7E_E0: + if (code == 0xF0) + state = E0_7E_E0_F0; + else + state = INIT; + break; + case E0_7E_E0_F0: + if (code == 0x7E) + matrix_make(PAUSE); + state = INIT; + break; + default: + state = INIT; + } + } + + // TODO: request RESEND when error occurs? +/* + if (PS2_IS_FAILED(ps2_error)) { + uint8_t ret = ps2_host_send(PS2_RESEND); + xprintf("Resend: %02X\n", ret); + } +*/ + return 1; +} + +bool matrix_is_modified(void) +{ + return is_modified; +} + +inline +bool matrix_has_ghost(void) +{ +#ifdef MATRIX_HAS_GHOST + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + if (matrix_has_ghost_in_row(i)) + return true; + } +#endif + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1<> 8) & 0xFF) +/* USB vendor ID for the device, low byte first. If you have registered your + * own Vendor ID, define it here. Otherwise you may use one of obdev's free + * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF) +/* This is the ID of the product, low byte first. It is interpreted in the + * scope of the vendor ID. If you have registered your own VID with usb.org + * or if you have licensed a PID from somebody else, define it here. Otherwise + * you may use one of obdev's free shared VID/PID pairs. See the file + * USB-IDs-for-free.txt for details! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_VERSION 0x00, 0x01 +/* Version number of the device: Minor number first, then major number. + */ +#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.' +#define USB_CFG_VENDOR_NAME_LEN 6 +/* These two values define the vendor name returned by the USB device. The name + * must be given as a list of characters under single quotes. The characters + * are interpreted as Unicode (UTF-16) entities. + * If you don't want a vendor name string, undefine these macros. + * ALWAYS define a vendor name containing your Internet domain name if you use + * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for + * details. + */ +#define USB_CFG_DEVICE_NAME 'P', 'S', '/', '2', ' ', 'k', 'e', 'y', 'b', 'o', 'a', 'r', 'd', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', 'e', 'r' +#define USB_CFG_DEVICE_NAME_LEN 23 +/* Same as above for the device name. If you don't want a device name, undefine + * the macros. See the file USB-IDs-for-free.txt before you assign a name if + * you use a shared VID/PID. + */ +/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ +/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ +/* Same as above for the serial number. If you don't want a serial number, + * undefine the macros. + * It may be useful to provide the serial number through other means than at + * compile time. See the section about descriptor properties below for how + * to fine tune control over USB descriptors such as the string descriptor + * for the serial number. + */ +#define USB_CFG_DEVICE_CLASS 0 +#define USB_CFG_DEVICE_SUBCLASS 0 +/* See USB specification if you want to conform to an existing device class. + * Class 0xff is "vendor specific". + */ +#define USB_CFG_INTERFACE_CLASS 3 /* HID */ +#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */ +#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */ +/* See USB specification if you want to conform to an existing device class or + * protocol. The following classes must be set at interface level: + * HID class is 3, no subclass and protocol required (but may be useful!) + * CDC class is 2, use subclass 2 and protocol 1 for ACM + */ +#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 +/* Define this to the length of the HID report descriptor, if you implement + * an HID device. Otherwise don't define it or define it to 0. + * If you use this define, you must add a PROGMEM character array named + * "usbHidReportDescriptor" to your code which contains the report descriptor. + * Don't forget to keep the array and this define in sync! + */ + +/* #define USB_PUBLIC static */ +/* Use the define above if you #include usbdrv.c instead of linking against it. + * This technique saves a couple of bytes in flash memory. + */ + +/* ------------------- Fine Control over USB Descriptors ------------------- */ +/* If you don't want to use the driver's default USB descriptors, you can + * provide our own. These can be provided as (1) fixed length static data in + * flash memory, (2) fixed length static data in RAM or (3) dynamically at + * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more + * information about this function. + * Descriptor handling is configured through the descriptor's properties. If + * no properties are defined or if they are 0, the default descriptor is used. + * Possible properties are: + * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched + * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is + * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if + * you want RAM pointers. + * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found + * in static memory is in RAM, not in flash memory. + * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), + * the driver must know the descriptor's length. The descriptor itself is + * found at the address of a well known identifier (see below). + * List of static descriptor names (must be declared PROGMEM if in flash): + * char usbDescriptorDevice[]; + * char usbDescriptorConfiguration[]; + * char usbDescriptorHidReport[]; + * char usbDescriptorString0[]; + * int usbDescriptorStringVendor[]; + * int usbDescriptorStringDevice[]; + * int usbDescriptorStringSerialNumber[]; + * Other descriptors can't be provided statically, they must be provided + * dynamically at runtime. + * + * Descriptor properties are or-ed or added together, e.g.: + * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) + * + * The following descriptors are defined: + * USB_CFG_DESCR_PROPS_DEVICE + * USB_CFG_DESCR_PROPS_CONFIGURATION + * USB_CFG_DESCR_PROPS_STRINGS + * USB_CFG_DESCR_PROPS_STRING_0 + * USB_CFG_DESCR_PROPS_STRING_VENDOR + * USB_CFG_DESCR_PROPS_STRING_PRODUCT + * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER + * USB_CFG_DESCR_PROPS_HID + * USB_CFG_DESCR_PROPS_HID_REPORT + * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) + * + * Note about string descriptors: String descriptors are not just strings, they + * are Unicode strings prefixed with a 2 byte header. Example: + * int serialNumberDescriptor[] = { + * USB_STRING_DESCRIPTOR_HEADER(6), + * 'S', 'e', 'r', 'i', 'a', 'l' + * }; + */ + +#define USB_CFG_DESCR_PROPS_DEVICE 0 +#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 +#define USB_CFG_DESCR_PROPS_STRINGS 0 +#define USB_CFG_DESCR_PROPS_STRING_0 0 +#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 +#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 +#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 +//#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC +#define USB_CFG_DESCR_PROPS_HID 0 +#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_HID_REPORT 0 +#define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +/* ----------------------- Optional MCU Description ------------------------ */ + +/* The following configurations have working defaults in usbdrv.h. You + * usually don't need to set them explicitly. Only if you want to run + * the driver on a device which is not yet supported or with a compiler + * which is not fully supported (such as IAR C) or if you use a differnt + * interrupt than INT0, you may have to define some of these. + */ +/* #define USB_INTR_CFG MCUCR */ +/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE GIMSK */ +/* #define USB_INTR_ENABLE_BIT INT0 */ +/* #define USB_INTR_PENDING GIFR */ +/* #define USB_INTR_PENDING_BIT INTF0 */ +/* #define USB_INTR_VECTOR INT0_vect */ + +#endif /* __usbconfig_h_included__ */ diff --git a/converter/serialmouse_usb/Makefile b/converter/serialmouse_usb/Makefile new file mode 100644 index 00000000..34f550b3 --- /dev/null +++ b/converter/serialmouse_usb/Makefile @@ -0,0 +1,106 @@ +# +# Makefile for Teensy +# +# Target file name (without extension). +TARGET = serialmouse_usb + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + + +# MCU name +#MCU = at90usb1287 +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=512 + + +# Build Options +# comment out to disable the options. +# +#BOOTMAGIC_ENABLE = yes # 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 # USB Nkey Rollover - not yet supported in LUFA + + +# Serial Mouse Options +# You can choose a mouse protocol and the implementation of +# the underlying serial connection. +# +SERIAL_MOUSE_MICROSOFT_ENABLE = yes # Enable support for Microsoft-compatible mice +#SERIAL_MOUSE_MOUSESYSTEMS_ENABLE = yes # Enable support for Mousesystems-compatible mice +#SERIAL_MOUSE_USE_UART = yes # use hardware UART for serial connection +SERIAL_MOUSE_USE_SOFT = yes # use software serial implementation + +# Optional serial mouse driver features +# Support scrolling while holding the middle mouse button +# (currently only supported for Mousesystems mice): +#OPT_DEFS += -DSERIAL_MOUSE_CENTER_SCROLL + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/serialmouse_usb/README.md b/converter/serialmouse_usb/README.md new file mode 100644 index 00000000..ef8a0067 --- /dev/null +++ b/converter/serialmouse_usb/README.md @@ -0,0 +1,11 @@ +Serial mouse converter +====================== +See https://github.com/tmk/tmk_keyboard/pull/131 + + +Supported protocols +------------------- +### Microsoft +Not tested. + +### Mousesystems diff --git a/converter/serialmouse_usb/config.h b/converter/serialmouse_usb/config.h new file mode 100644 index 00000000..b257d997 --- /dev/null +++ b/converter/serialmouse_usb/config.h @@ -0,0 +1,119 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x2222 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT serial mouse converter +#define DESCRIPTION convert serial mouse into USB + + +/* matrix size */ +#define MATRIX_ROWS 0 +#define MATRIX_COLS 0 + + +/* key combination for command */ +#define IS_COMMAND() false + + + +#ifdef SERIAL_MOUSE_MICROSOFT + /* + * Serial(USART) configuration (for Microsoft serial mice) + * asynchronous, positive logic, 1200baud, bit order: LSB first + * 1-start bit, 7-data bit, no parity, 1-stop bit + */ + #define SERIAL_UART_BAUD 1200 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B |= (1<>8); /* baud rate */ \ + UCSR1B |= (1< + +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 +#include +#include "keymap.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return KC_NO; +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){}; +} + diff --git a/converter/serialmouse_usb/keymap_common.c b/converter/serialmouse_usb/keymap_common.c new file mode 100644 index 00000000..55a13793 --- /dev/null +++ b/converter/serialmouse_usb/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2011,2012,2013 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 "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/serialmouse_usb/keymap_common.h b/converter/serialmouse_usb/keymap_common.h new file mode 100644 index 00000000..216a8dc0 --- /dev/null +++ b/converter/serialmouse_usb/keymap_common.h @@ -0,0 +1,174 @@ +/* +Copyright 2011,2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +// 32*8(256) byte array which converts PS/2 code into USB code +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* All keys */ +#define KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + K61, /* for European ISO */ \ + K51, K13, K6A, K64, K67, /* for Japanese JIS */ \ + K08, K10, K18, K20, K28, K30, K38, K40, K48, K50, K57, K5F, /* F13-24 */ \ + KB7, KBF, KDE, /* System Power, Sleep, Wake */ \ + KA3, KB2, KA1, /* Mute, Volume Up, Volume Down */ \ + KCD, K95, KBB, KB4, KD0, /* Next, Previous, Stop, Pause, Media Select */ \ + KC8, KAB, KC0, /* Mail, Calculator, My Computer */ \ + K90, KBA, KB8, KB0, /* WWW Search, Home, Back, Forward */ \ + KA8, KA0, K98 /* WWW Stop, Refresh, Favorites */ \ +) { \ + { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \ + { KC_##K18, KC_NO, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_NO }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \ + { KC_##K38, KC_NO, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_NO }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_NO, KC_##K54, KC_##K55, KC_NO, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_NO, KC_##K5D, KC_NO, KC_##K5F }, \ + { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_NO, KC_##K66, KC_##K67 }, \ + { KC_NO, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K83, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_##K94, KC_##K95, KC_NO, KC_NO }, \ + { KC_##K98, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K9F }, \ + { KC_##KA0, KC_##KA1, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_##KA7 }, \ + { KC_##KA8, KC_NO, KC_NO, KC_##KAB, KC_NO, KC_NO, KC_NO, KC_##KAF }, \ + { KC_##KB0, KC_NO, KC_##KB2, KC_NO, KC_##KB4, KC_NO, KC_NO, KC_##KB7 }, \ + { KC_##KB8, KC_NO, KC_##KBA, KC_##KBB, KC_NO, KC_NO, KC_NO, KC_##KBF }, \ + { KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_##KC8, KC_NO, KC_##KCA, KC_NO, KC_NO, KC_##KCD, KC_NO, KC_NO }, \ + { KC_##KD0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##KDA, KC_NO, KC_NO, KC_NO, KC_##KDE, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_##KE9, KC_NO, KC_##KEB, KC_##KEC, KC_NO, KC_NO, KC_NO }, \ + { KC_##KF0, KC_##KF1, KC_##KF2, KC_NO, KC_##KF4, KC_##KF5, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##KFA, KC_NO, KC_##KFC, KC_##KFD, KC_##KFE, KC_NO }, \ +} + +/* US layout */ +#define KEYMAP( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + NUBS, \ + RO, KANA, JYEN, HENK, MHEN, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +/* ISO layout */ +#define KEYMAP_ISO( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D,K5A, K6B,K73,K74,K79, \ + K12,K61,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + K61, \ + RO, KANA, JYEN, HENK, MHEN, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +/* JIS layout */ +#define KEYMAP_JIS( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K6A,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52,K5D, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A,K51, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K67,K29,K64,K13, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA \ +) \ +KEYMAP_ALL( \ + K76,K05,K06,K04,K0C,K03,K0B,K83,K0A,K01,K09,K78,K07, KFC,K7E,KFE, \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, KF0,KEC,KFD, K77,KCA,K7C,K7B, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5D, KF1,KE9,KFA, K6C,K75,K7D, \ + K58,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K79, \ + K12,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, KF5, K69,K72,K7A, \ + K14,K9F,K11, K29, K91,KA7,KAF,K94, KEB,KF2,KF4, K70, K71,KDA, \ + \ + NUBS, \ + K51, K13, K6A, K64, K67, \ + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, \ + SYSTEM_POWER, SYSTEM_SLEEP, SYSTEM_WAKE, \ + AUDIO_MUTE, AUDIO_VOL_UP, AUDIO_VOL_DOWN, \ + MEDIA_NEXT_TRACK, MEDIA_PREV_TRACK, MEDIA_STOP, MEDIA_PLAY_PAUSE, MEDIA_SELECT, \ + MAIL, CALCULATOR, MY_COMPUTER, \ + WWW_SEARCH, WWW_HOME, WWW_BACK, WWW_FORWARD, \ + WWW_STOP, WWW_REFRESH, WWW_FAVORITES \ +) + +#endif diff --git a/converter/serialmouse_usb/led.c b/converter/serialmouse_usb/led.c new file mode 100644 index 00000000..f76545f0 --- /dev/null +++ b/converter/serialmouse_usb/led.c @@ -0,0 +1,24 @@ +/* +Copyright 2011 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 "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/converter/serialmouse_usb/matrix.c b/converter/serialmouse_usb/matrix.c new file mode 100644 index 00000000..0e0d87f8 --- /dev/null +++ b/converter/serialmouse_usb/matrix.c @@ -0,0 +1,83 @@ +/* +Copyright 2011 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 +#include +#include +#include +#include "action.h" +#include "print.h" +#include "util.h" +#include "debug.h" +#include "matrix.h" + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + debug_enable = true; + debug_mouse=true; + return; +} + +uint8_t matrix_scan(void) +{ + return 0; +} + +bool matrix_is_modified(void) +{ + return false; +} + +inline +bool matrix_has_ghost(void) +{ + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return false; +} + +inline +uint8_t matrix_get_row(uint8_t row) +{ + return 0; +} + +void matrix_print(void) +{ +} + +uint8_t matrix_key_count(void) +{ + return 0; +} diff --git a/converter/sun_usb/Makefile b/converter/sun_usb/Makefile new file mode 100644 index 00000000..12eceb5e --- /dev/null +++ b/converter/sun_usb/Makefile @@ -0,0 +1,92 @@ +# Target file name (without extension). +TARGET = sun_usb + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# keyboard dependent files +SRC = keymap.c \ + matrix.c \ + led.c \ + command_extra.c + + +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 = at90usb646 # Teensy++ 1.0 +#MCU = at90usb1286 # Teensy++ 2.0 +MCU = atmega32u2 + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Build Options +# *Comment out* to disable the options. +# +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 +#HARDWARE_SERIAL = yes # Use hardware serial (requires inverted serial, see README) +#NKRO_ENABLE = yes # USB Nkey Rollover + +ifdef HARDWARE_SERIAL + SRC := protocol/serial_uart.c $(SRC) + OPT_DEFS += -DHARDWARE_SERIAL +else + SRC := protocol/serial_soft.c $(SRC) +endif + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/sun_usb/README b/converter/sun_usb/README new file mode 100644 index 00000000..405a86ba --- /dev/null +++ b/converter/sun_usb/README @@ -0,0 +1,108 @@ +Sun to USB keyboard protocol converter +====================================== +Target MCU is ATMega32u4 but other USB capable AVR will also work. + +This converter will work with Sun Type 2-5 Keyboards. + + +Tested on: +Sun Type 3 Keyboard: http://blog.daveastels.com.s3-website-us-west-2.amazonaws.com/2014/12/27/type-3-keyboard.html +CTCSP SHORT TYPE KEYBOARD(Type 5): http://imgur.com/a/QIv6p + + +Keymap of Type 3(keymap_sun3.c) were impoted from dastels's repository. +https://github.com/dastels/tmk_keyboard/tree/master/converter/sun3_usb + + + +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 by default, so you don't need any inverter part. But +it can also be built with 'make HARDWARE_SERIAL=y' to enable hardware serial if there +is an inverter present. Good results have been obtained using a 74LS04 and hardware serial. + + +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) + +Reference + http://kentie.net/article/sunkbd/page2.htm + http://kentie.net/article/sunkbd/KBD.pdf + + +Build Firmware +-------------- +Just use 'make' + $ cd sun_usb + $ make +Then, load the binary to MCU with your favorite programmer. + + +Sun commands +------------ +You can send Sun protocol commands with TMK `Magic` key combo. By default `Magic` key is `LShift` + `RShift`, `LAlt` + `RAlt' or `LMeta` + `RMeta`. +https://github.com/tmk/tmk_keyboard#magic-commands + +Following Sun specific commands are available. For example, to send 'Bell On' you can press `LShift` + `RShift` + `Up` keys simultaneously. + +``` +----- Sun converter Help ----- +Up: Bell On +Down: Bell Off +Left: Click On +Right: Click Off +PgUp: LED all On +PgDown: LED all On +Insert: Layout +Delete: Reset +``` diff --git a/converter/sun_usb/command_extra.c b/converter/sun_usb/command_extra.c new file mode 100644 index 00000000..08f3a710 --- /dev/null +++ b/converter/sun_usb/command_extra.c @@ -0,0 +1,68 @@ +#include "stdbool.h" +#include "stdint.h" +#include "keycode.h" +#include "serial.h" +#include "print.h" +#include "command.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 On\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; +} diff --git a/converter/sun_usb/config.h b/converter/sun_usb/config.h new file mode 100644 index 00000000..414fd563 --- /dev/null +++ b/converter/sun_usb/config.h @@ -0,0 +1,126 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x3333 +#define DEVICE_VER 0x0100 +#define MANUFACTURER t.m.k. +#define PRODUCT Sun keyboard converter +#define DESCRIPTION converts Sun keyboard protocol into USB + +/* 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)) \ +) + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + +/* HARDWARE_SERAIL assumes that a logic inverter (7404) is placed + * in front of RX/TX to produce the positive logic the MCU expects. + * The default is Software Serial. + */ +#if defined(HARDWARE_SERIAL) + + /* Hardware Serial (USART) configuration + * asynchronous, negative logic, 1200baud, no flow control + * 1-start bit, 8-data bit, non parity, 1-stop bit + * + */ + #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) + #define SERIAL_UART_BAUD 1200 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B = (1< + +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 +#include +#include +#include "keycode.h" +#include "util.h" +#include "keymap.h" + + + + +/* Sun type 5 keyboard +,-------. ,---, ,---------------. ,---------------. ,---------------. ,-----------. ,---------------. +| 76 | | | | 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 KEYMAP( \ + K76, 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, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_NO, }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_NO, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_NO }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_NO, KC_##K7D, KC_NO, KC_NO } \ +} + +/* CTCSP SHORT TYPE KEYBOARD */ +#define SHORT_TYPE( \ + K01, K05,K06,K08,K0A,K0C,K0E, K61,K49,K33, K30, K2C,K34,K60, \ + K10,K11,K12,K07,K09,K0B, K42,K4A,K7B, \ + K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A, \ + K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K2B, \ + K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, \ + K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K0D,K14,K6E, \ + K77,K13, K78, K79, K7A,K43,K62,K18,K1B,K1C \ +) KEYMAP( \ + HELP, K05,K06,K08,K0A, K0C,K0E,K10,K11, K12,K07,K09,K0B, PSCR,SLCK,PAUS, MUTE,VOLD,VOLU,K30, \ + K01, AGAIN, K1D,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K58,K2A, K2C, K34, K60, K62, PSLS,PAST,PMNS, \ + MENU, UNDO, K35, K36,K37,K38,K39,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41, K2B, K42, K4A, K7B, P7, P8, P9, PPLS, \ + SELECT, K33, K4C, K4D,K4E,K4F,K50,K51,K52,K53,K54,K55,K56,K57, K59, P4, P5, P6, \ + EXECUTE,K49, K63, K64,K65,K66,K67,K68,K69,K6A,K6B,K6C,K6D, K6E, K14, P1, P2, P3, PENT, \ + FIND, K61, K77,K13, K78, HENK, K79, MHEN, KANA, K7A,K43,K0D, K18, K1B, K1C, P0, PDOT \ +) + + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 2, // Fn0 + 3, // Fn1 + 4, // Fn2 + 0, // Fn3 + 0, // Fn4 + 0, // Fn5 + 0, // Fn6 + 0 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_SCLN, // Fn1 + KC_SLSH, // Fn2 + KC_NO, // Fn3 + KC_NO, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* + KEYMAP( + HELP, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10,F11,F12, PSCR,SLCK,PAUS, MUTE,VOLD,VOLU,PWR, + STOP, AGAIN, ESC,1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + MENU, UNDO, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, DEL, END, PGDN, P7, P8, P9, PPLS, + SELECT, COPY, LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, + EXECUTE,PASTE, LSFT, Z, X, C, V, B, N, M, COMM,DOT,SLSH, RSFT, UP, P1, P2, P3, PENT, + FIND, CUT, CAPS, LALT, LGUI,HENK, SPC, MHEN,KANA,RGUI,APP, RALT, LEFT,DOWN,RGHT, P0, PDOT + ), +*/ + // 0: default + SHORT_TYPE( + STOP, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RALT,UP, RSFT, + CAPS,LALT,LGUI, SPC, RGUI,APP, NLCK,LEFT,DOWN,RGHT + ), + // 1: with layer keys + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL, A, S, D, F, G, H, J, K, L, FN1, QUOT, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,UP, FN0, + CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, LEFT,DOWN,RGHT + ), + // 2: HHKB + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, BSPC, + LCTL, VOLD,VOLU,MUTE,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, + LSFT, Z, X, C, V, B, NO, NO, END, PGDN,DOWN, RSFT,PGUP,FN0, + CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, HOME,PGDN,END + ), + // 3: Mousekey + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, + LCTL, NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN1, NO, ENT, + LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, RSFT,UP, NO, + CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT + ), + // 4: Cursor + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, + LCTL, NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, + LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,UP, NO, + CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT + ), +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/converter/sun_usb/keymap_sun3.c b/converter/sun_usb/keymap_sun3.c new file mode 100644 index 00000000..273cd944 --- /dev/null +++ b/converter/sun_usb/keymap_sun3.c @@ -0,0 +1,173 @@ +/* +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 +#include +#include +#include "keycode.h" +#include "util.h" +#include "keymap.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 KEYMAP( \ + 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, KC_##K01, KC_NO, KC_##K03, KC_NO, KC_##K05, KC_##K06, KC_NO }, \ + { KC_##K08, KC_NO, KC_##K0A, KC_NO, KC_##K0C, KC_NO, KC_##K0E, KC_NO }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_NO, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_NO, KC_##K19, KC_##K1A, KC_NO, KC_NO, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_NO, KC_##K31, KC_NO, KC_##K33, KC_NO, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ + { KC_##K48, KC_##K49, KC_NO, KC_NO, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_NO, KC_##K5B, KC_##K5C, KC_##K5D, KC_NO, KC_##K5F }, \ + { KC_NO, KC_##K61, KC_NO, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 2, // Fn0 + 3, // Fn1 + 4, // Fn2 + 0, // Fn3 + 0, // Fn4 + 0, // Fn5 + 0, // Fn6 + 0 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_SCLN, // Fn1 + KC_SLSH, // Fn2 + KC_NO, // Fn3 + KC_NO, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + KEYMAP( + F10, F11, F1, F2, F3, F4, F5, F6, F7, F8, F9, BSPC, VOLD, MUTE, VOLU, + F12, F13, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,MINS, EQL, BSLS, GRV, MPRV, MPLY, MNXT, + F14, F15, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, DEL, HOME, UP, PGUP, + F16, F17, LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, LEFT, INSERT, RIGHT, + F18, F19, LSFT, Z, X, C, V, B, N, M, COMM,DOT,SLSH, RSFT,RCTL, END, DOWN, PGDOWN, + LGUI, LALT, SPC, RALT,RGUI + ), + /* + // 0: default + SHORT_TYPE( + STOP, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL, A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RALT,UP, RSFT, + CAPS,LALT,LGUI, SPC, RGUI,APP, NLCK,LEFT,DOWN,RGHT + ), + // 1: with layer keys + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSPC, + LCTL, A, S, D, F, G, H, J, K, L, FN1, QUOT, ENT, + LSFT, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,UP, FN0, + CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, LEFT,DOWN,RGHT + ), + // 2: HHKB + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, BSPC, + LCTL, VOLD,VOLU,MUTE,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, ENT, + LSFT, Z, X, C, V, B, NO, NO, END, PGDN,DOWN, RSFT,PGUP,FN0, + CAPS,LALT,LGUI, SPC, RGUI,RALT,FN0, HOME,PGDN,END + ), + // 3: Mousekey + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, + LCTL, NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,FN1, NO, ENT, + LSFT, NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, RSFT,UP, NO, + CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT + ), + // 4: Cursor + SHORT_TYPE( + ESC, F1,F2,F3,F4, F5, F6, CUT,PASTE,COPY,PWR, INS, HOME,PGUP, + F7,F8,F9,F10,F11,F12, DEL, END, PGDN, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, + CAPS, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, + LCTL, NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, + LSFT, NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,UP, NO, + CAPS,LALT,LGUI, BTN1, RGUI,RALT,NO, LEFT,DOWN,RGHT + ), + */ +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/converter/sun_usb/led.c b/converter/sun_usb/led.c new file mode 100644 index 00000000..809398fa --- /dev/null +++ b/converter/sun_usb/led.c @@ -0,0 +1,35 @@ +/* +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" +#include "debug.h" + + +void led_set(uint8_t usb_led) +{ + uint8_t sun_led = 0; + if (usb_led & (1< + +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "matrix.h" +#include "debug.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; + + +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"); + return; +} + +uint8_t matrix_scan(void) +{ + is_modified = false; + + 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 + 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< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6535 +#define DEVICE_VER 0x0100 +#define MANUFACTURER t.m.k. +#define PRODUCT 70% IBM Terminal Keyboard Converter w/ Bluetooth +#define DESCRIPTION USB converter for IBM Terminal Keyboard w/ Bluetooth + + +/* matrix size */ +#define MATRIX_ROWS 17 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* legacy keymap support */ +// #define USE_LEGACY_KEYMAP + + +/* key combination for command */ +#define IS_COMMAND() ( \ + (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) || \ + (keyboard_report->mods == (MOD_BIT(KC_RALT) | MOD_BIT(KC_RCTL))) \ +) + +/* USART configuration + * asynchronous, 9600baud, 8-data bit, non parity, 1-stop bit, no flow control + */ +#ifdef __AVR_ATmega32U4__ + #define SERIAL_UART_BAUD 9600 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B = (1< + +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 +#include +#include +#include "keycode.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "keymap.h" + + + + +/* + * IBM Terminal keyboard 6110345(122keys)/1392595(102keys) + * http://geekhack.org/showthread.php?10737-What-Can-I-Do-With-a-Terminal-Model-M + * http://www.seasip.info/VintagePC/ibm_1391406.html + * + * Keymap array: + * 8 bytes + * +---------+ + * 0| | + * :| | 0x00-0x87 + * ;| | + * 17| | + * +---------+ + */ +#define KEYMAP( \ + K08,K10,K18,K20,K28,K30,K38,K40,K48,K50,K57,K5F, \ + K07,K0F,K17,K1F,K27,K2F,K37,K3F,K47,K4F,K56,K5E, \ + \ + K05,K06, K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K5D,K66, K67,K6E,K6F, K76,K77,K7E,K84, \ + K04,K0C, K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, K5C, K64,K65,K6D, K6C,K75,K7D,K7C, \ + K03,K0B, K14,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K53,K5A, K63, K6B,K73,K74,K7B, \ + K83,K0A, K12,K13,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K51,K59, K61,K62,K6A, K69,K72,K7A,K79, \ + K01,K09, K11, K19, K29, K39, K58, K60, K68,K70,K71,K78 \ +) { \ + { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K83, KC_##K84, KC_NO, KC_NO, KC_NO, }, \ +} + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \|BS | |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #|Retu| | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shif| \| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl| |Alt | Space |Alt | |Ctrl| |Lef|Dow|Rig| | 0| .| | + * `----' `---------------------------------------' `----' `-----------' `---------------' + */ +/* + KEYMAP( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, + + PSCR,ESC, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + SLCK,INT4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, + PAUS,INT5, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, UP, P4, P5, P6, PCMM, + APP, INT6, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, LEFT,INT2,RGHT, P1, P2, P3, PENT, + RGUI,LGUI, LCTL, LALT, SPC, RALT, RCTL, DOWN, NO, P0, PDOT,NO + ), +*/ + /* + KEYMAP( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS + ), + */ + // pseudo ANSI + + KEYMAP( + FN0, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, + PSCR,PAUS,PGUP,PGDN,HOME,END, INS, DEL, LEFT,DOWN,UP, RGHT, + + NO, NO, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, GRV, BSPC, NO, NO, NO, NO, NO, NO, NO, + NO, NO, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, NO, NO, NO, NO, NO, NO, NO, + NO, NO, LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, BSLS,ENT, NO, NO, NO, NO, NO, + NO, NO, LSFT,FN1 ,Z, X, C, V, B, N, M, COMM,DOT, SLSH, FN1, RSFT, NO, NO, NO, NO, NO, NO, NO, + NO, NO, LCTL, LALT, SPC, LGUI, APP, NO, NO, NO, NO, NO + ), + + // Momentary Function Layer + KEYMAP( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS,MUTE,VOLD,VOLU,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + + TRNS,TRNS, TRNS,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,UP ,END, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,MS_L,MS_D,MS_U,MS_R,LEFT,DOWN, RGHT,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,PGDN,TRNS, TRNS,RSFT, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, BTN2, TRNS, BTN1, RALT, RCTL, TRNS, TRNS,TRNS,TRNS,TRNS + ), + + // Mouse Layer + KEYMAP( + FN0, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,NO, TRNS, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS,NO, NO, MS_U,NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, TRNS, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, BTN2,BTN1,MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,NO, NO, NO, ENT, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS,TRNS,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, RSFT, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS, TRNS, BTN1, BTN2, TRNS, NO, NO, NO, NO, NO + ), + + // vi Layer + KEYMAP( + FN0, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,NO, TRNS, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, TRNS, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, NO, ENT, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS,TRNS,NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, RSFT, NO, NO, NO, NO, NO, NO, NO, + TRNS,TRNS, TRNS, TRNS, SPC, RALT, RCTL, NO, NO, NO, NO, NO + ), + + // num lock layer + KEYMAP( + FN0, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, + TRNS,TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS + ), + +}; + + +static const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_DEFAULT_LAYER_SET(0), + [1] = ACTION_LAYER_MOMENTARY(1), + [2] = ACTION_LAYER_MOMENTARY(2), //ACTION_LAYER_ON(2, ON_RELEASE), + [3] = KC_NO, //ACTION_LAYER_ON(3, ON_RELEASE), + [4] = KC_NO, //ACTION_LAYER_ON(4, ON_RELEASE), + [5] = KC_NO, + [6] = KC_NO, + [7] = KC_NO, +}; + +/* +enum macro_id { + MS_UL, + MS_UR, + MS_DL, + MS_DR, +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + keyevent_t event = record->event; + + switch (id) { + case MS_UL: + return (event.pressed ? MACRO( D(MS_L), D(MS_U), END ) : MACRO( U(MS_L), U(MS_U), END ) ); + case MS_UR: + return (event.pressed ? MACRO( D(MS_R), D(MS_U), END ) : MACRO( U(MS_L), U(MS_U), END ) ); + case MS_DL: + return (event.pressed ? MACRO( D(MS_L), D(MS_D), END ) : MACRO( U(MS_L), U(MS_U), END ) ); + case MS_DR: + return (event.pressed ? MACRO( D(MS_R), D(MS_D), END ) : MACRO( U(MS_L), U(MS_U), END ) ); + } + return MACRO_NONE; +} +*/ + +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + return action; +} diff --git a/converter/terminal_bluefruit/led.c b/converter/terminal_bluefruit/led.c new file mode 100644 index 00000000..e5bf41d4 --- /dev/null +++ b/converter/terminal_bluefruit/led.c @@ -0,0 +1,35 @@ +/* +Converter for 70% IBM Terminal Keyboard +Author: Benjamin Gould, 2013 +Based on code Copyright 2011 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 "ps2.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + uint8_t ps2_led = 0; + if (usb_led & (1< + +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "debug.h" +#include "ps2.h" +#include "matrix.h" + + +static void matrix_make(uint8_t code); +static void matrix_break(uint8_t code); +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif + + +/* + * Matrix Array usage: + * 'Scan Code Set 3' is assigned into 17x8 cell matrix. + * + * 8bit wide + * +---------+ + * 0| | + * :| | 0x00-0x87 + * ;| | + * 17| | + * +---------+ + */ +static uint8_t matrix[MATRIX_ROWS]; +#define ROW(code) (code>>3) +#define COL(code) (code&0x07) + +static bool is_modified = false; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + debug_enable = true; + //debug_matrix = true; + //debug_keyboard = true; + //debug_mouse = false; + + ps2_host_init(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + return; +} + +uint8_t matrix_scan(void) +{ + + // scan code reading states + static enum { + RESET, + RESET_RESPONSE, + KBD_ID0, + KBD_ID1, + CONFIG, + READY, + F0, + } state = RESET; + + is_modified = false; + + uint8_t code; + if ((code = ps2_host_recv())) { + debug("r"); debug_hex(code); debug(" "); + } + + switch (state) { + case RESET: + debug("wFF "); + if (ps2_host_send(0xFF) == 0xFA) { + debug("[ack]\nRESET_RESPONSE: "); + state = RESET_RESPONSE; + } + break; + case RESET_RESPONSE: + if (code == 0xAA) { + debug("[ok]\nKBD_ID: "); + state = KBD_ID0; + } else if (code) { + debug("err\nRESET: "); + state = RESET; + } + break; + // after reset receive keyboad ID(2 bytes) + case KBD_ID0: + if (code) { + state = KBD_ID1; + } + break; + case KBD_ID1: + if (code) { + debug("\nCONFIG: "); + state = CONFIG; + } + break; + case CONFIG: + debug("wF8 "); + if (ps2_host_send(0xF8) == 0xFA) { + debug("[ack]\nREADY\n"); + state = READY; + } + break; + case READY: + switch (code) { + case 0x00: + break; + case 0xF0: + state = F0; + debug(" "); + break; + default: // normal key make + if (code < 0x88) { + matrix_make(code); + } else { + debug("unexpected scan code at READY: "); debug_hex(code); debug("\n"); + } + state = READY; + debug("\n"); + } + break; + case F0: // Break code + switch (code) { + case 0x00: + break; + default: + if (code < 0x88) { + matrix_break(code); + } else { + debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); + } + state = READY; + debug("\n"); + } + break; + } + return 1; +} + +bool matrix_is_modified(void) +{ + return is_modified; +} + +inline +bool matrix_has_ghost(void) +{ +#ifdef MATRIX_HAS_GHOST + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + if (matrix_has_ghost_in_row(i)) + return true; + } +#endif + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6535 +#define DEVICE_VER 0x0100 +#define MANUFACTURER t.m.k. +#define PRODUCT PS/2(Set3)-USB Keyboard converter(IBM 122keys) +#define DESCRIPTION USB converter for IBM Terminal Keyboard 122keys + + +/* matrix size */ +#define MATRIX_ROWS 17 // keycode bit: 3-0 +#define MATRIX_COLS 8 // keycode bit: 6-4 + + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + + +/* key combination for command */ +#define IS_COMMAND() ( \ + (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) || \ + (keyboard_report->mods == (MOD_BIT(KC_RALT) | MOD_BIT(KC_RCTL))) \ +) + + +/* + * PS/2 USART configuration for ATMega32U4 + */ +#ifdef PS2_USE_USART +/* XCK for clock line */ +#define PS2_CLOCK_PORT PORTD +#define PS2_CLOCK_PIN PIND +#define PS2_CLOCK_DDR DDRD +#define PS2_CLOCK_BIT 5 +/* RXD for data line */ +#define PS2_DATA_PORT PORTD +#define PS2_DATA_PIN PIND +#define PS2_DATA_DDR DDRD +#define PS2_DATA_BIT 2 + +/* synchronous, odd parity, 1-bit stop, 8-bit data, sample at falling edge */ +/* set DDR of CLOCK as input to be slave */ +#define PS2_USART_INIT() do { \ + PS2_CLOCK_DDR &= ~(1< + +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 +#include +#include +#include "keycode.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "keymap.h" + + + + +/* + * IBM Terminal keyboard 6110345(122keys)/1392595(102keys) + * http://geekhack.org/showthread.php?10737-What-Can-I-Do-With-a-Terminal-Model-M + * http://www.seasip.info/VintagePC/ibm_1391406.html + * + * Keymap array: + * 8 bytes + * +---------+ + * 0| | + * :| | 0x00-0x87 + * ;| | + * 17| | + * +---------+ + */ +#define KEYMAP( \ + K08,K10,K18,K20,K28,K30,K38,K40,K48,K50,K57,K5F, \ + K07,K0F,K17,K1F,K27,K2F,K37,K3F,K47,K4F,K56,K5E, \ + \ + K05,K06, K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K5D,K66, K67,K6E,K6F, K76,K77,K7E,K84, \ + K04,K0C, K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B, K5C, K64,K65,K6D, K6C,K75,K7D,K7C, \ + K03,K0B, K14,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K53,K5A, K63, K6B,K73,K74,K7B, \ + K83,K0A, K12,K13,K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K51,K59, K61,K62,K6A, K69,K72,K7A,K79, \ + K01,K09, K11, K19, K29, K39, K58, K60, K68,K70,K71,K78 \ +) { \ + { KC_NO, KC_##K01, KC_NO, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K83, KC_##K84, KC_NO, KC_NO, KC_NO, }, \ +} + +/* + * IBM Terminal keyboard 1399625, 101-key + */ +#define KEYMAP_101( \ + K08, K07,K0F,K17,K1F,K27,K2F,K37,K3F,K47,K4F,K56,K5E, K57,K5F,K62, \ + \ + K0E,K16,K1E,K26,K25,K2E,K36,K3D,K3E,K46,K45,K4E,K55,K66, K67,K6E,K6F, K76,K77,K7E,K84, \ + K0D,K15,K1D,K24,K2D,K2C,K35,K3C,K43,K44,K4D,K54,K5B,K5C, K64,K65,K6D, K6C,K75,K7D, \ + K14,K1C,K1B,K23,K2B,K34,K33,K3B,K42,K4B,K4C,K52, K5A, K6B,K73,K74,K7C, \ + K12, K1A,K22,K21,K2A,K32,K31,K3A,K41,K49,K4A, K59, K63, K69,K72,K7A, \ + K11, K19, K29, K39, K58, K61,K60,K6A, K70, K71,K79 \ +) { \ + { KC_NO, KC_NO , KC_NO, KC_NO , KC_NO , KC_NO , KC_NO , KC_##K07 }, \ + { KC_##K08, KC_NO , KC_NO , KC_NO , KC_NO , KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_NO , KC_##K11, KC_##K12, KC_NO , KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_NO , KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_NO , KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_NO , KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_NO , KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_NO , KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_NO , KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_NO , KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_NO , KC_NO , KC_##K52, KC_NO , KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_NO , KC_##K5E, KC_##K5F }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_NO , KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_NO , KC_##K79, KC_##K7A, KC_NO , KC_##K7C, KC_##K7D, KC_##K7E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO , KC_##K84, KC_NO, KC_NO, KC_NO, }, \ +} + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 0, // Fn0 + 0, // Fn1 + 0, // Fn2 + 0, // Fn3 + 0, // Fn4 + 0, // Fn5 + 0, // Fn6 + 0 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_NO, // Fn1 + KC_NO, // Fn2 + KC_NO, // Fn3 + KC_NO, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \|BS | |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '| #|Retu| | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shif| \| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl| |Alt | Space |Alt | |Ctrl| |Lef|Dow|Rig| | 0| .| | + * `----' `---------------------------------------' `----' `-----------' `---------------' + */ +/* + KEYMAP( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, + + PSCR,ESC, GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + SLCK,INT4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, + PAUS,INT5, CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, UP, P4, P5, P6, PCMM, + APP, INT6, LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, LEFT,INT2,RGHT, P1, P2, P3, PENT, + RGUI,LGUI, LCTL, LALT, SPC, RALT, RCTL, DOWN, NO, P0, PDOT,NO + ), +*/ + // pseudo ANSI + KEYMAP( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, + + PSCR,ESC, ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NO, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + SLCK,INT4, TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, NO, DEL, END, PGDN, P7, P8, P9, PPLS, + PAUS,INT5, LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, BSLS,ENT, UP, P4, P5, P6, PCMM, + APP, INT6, LSFT,LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, NO, RSFT, LEFT,INT2,RGHT, P1, P2, P3, PENT, + RGUI,LGUI, LCTL, LALT, SPC, LGUI, GRV, DOWN, NO, P0, PDOT,NO + ), + +/* 101-key keymaps + */ + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl| |Alt | Space |Alt | |Ctrl| |Lef|Dow|Rig| | 0| .| | + * `----' `---------------------------------------' `----' `-----------' `---------------' + */ +/* + KEYMAP_101( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK, BRK, + + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,MINS, EQL,BSPC, INS,HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P,LBRC,RBRC,BSLS, DEL, END,PGDN, P7, P8, P9, + CAPS, A, S, D, F, G, H, J, K, L,SCLN,QUOT, ENT, P4, P5, P6,PPLS, + LSFT, Z, X, C, V, B, N, M,COMM, DOT,SLSH, RSFT, UP, P1, P2, P3, + LCTL, LALT, SPC, RALT, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +*/ +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/converter/terminal_usb/led.c b/converter/terminal_usb/led.c new file mode 100644 index 00000000..e448e84e --- /dev/null +++ b/converter/terminal_usb/led.c @@ -0,0 +1,33 @@ +/* +Copyright 2011 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 "ps2.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + uint8_t ps2_led = 0; + if (usb_led & (1< + +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "debug.h" +#include "ps2.h" +#include "matrix.h" + + +static void matrix_make(uint8_t code); +static void matrix_break(uint8_t code); +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif + + +/* + * Matrix Array usage: + * 'Scan Code Set 3' is assigned into 17x8 cell matrix. + * + * 8bit wide + * +---------+ + * 0| | + * :| | 0x00-0x87 + * ;| | + * 17| | + * +---------+ + */ +static uint8_t matrix[MATRIX_ROWS]; +#define ROW(code) (code>>3) +#define COL(code) (code&0x07) + +static bool is_modified = false; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + debug_enable = true; + //debug_matrix = true; + //debug_keyboard = true; + //debug_mouse = false; + + ps2_host_init(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + return; +} + +uint8_t matrix_scan(void) +{ + + // scan code reading states + static enum { + RESET, + RESET_RESPONSE, + KBD_ID0, + KBD_ID1, + CONFIG, + READY, + F0, + } state = RESET; + + is_modified = false; + + uint8_t code; + if ((code = ps2_host_recv())) { + debug("r"); debug_hex(code); debug(" "); + } + + switch (state) { + case RESET: + debug("wFF "); + if (ps2_host_send(0xFF) == 0xFA) { + debug("[ack]\nRESET_RESPONSE: "); + state = RESET_RESPONSE; + } + break; + case RESET_RESPONSE: + if (code == 0xAA) { + debug("[ok]\nKBD_ID: "); + state = KBD_ID0; + } else if (code) { + debug("err\nRESET: "); + state = RESET; + } + break; + // after reset receive keyboad ID(2 bytes) + case KBD_ID0: + if (code) { + state = KBD_ID1; + } + break; + case KBD_ID1: + if (code) { + debug("\nCONFIG: "); + state = CONFIG; + } + break; + case CONFIG: + debug("wF8 "); + if (ps2_host_send(0xF8) == 0xFA) { + debug("[ack]\nREADY\n"); + state = READY; + } + break; + case READY: + switch (code) { + case 0x00: + break; + case 0xF0: + state = F0; + debug(" "); + break; + default: // normal key make + if (code < 0x88) { + matrix_make(code); + } else { + debug("unexpected scan code at READY: "); debug_hex(code); debug("\n"); + } + state = READY; + debug("\n"); + } + break; + case F0: // Break code + switch (code) { + case 0x00: + break; + default: + if (code < 0x88) { + matrix_break(code); + } else { + debug("unexpected scan code at F0: "); debug_hex(code); debug("\n"); + } + state = READY; + debug("\n"); + } + break; + } + return 1; +} + +bool matrix_is_modified(void) +{ + return is_modified; +} + +inline +bool matrix_has_ghost(void) +{ +#ifdef MATRIX_HAS_GHOST + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + if (matrix_has_ghost_in_row(i)) + return true; + } +#endif + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x005B +#define DEVICE_VER 0x0814 +#define MANUFACTURER t.m.k. +#define PRODUCT USB to USB keyboard converter + + +#define DESCRIPTION Product from t.m.k. keyboard firmware project + + +/* matrix size */ +#define MATRIX_ROWS 16 +#define MATRIX_COLS 16 + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + +#endif diff --git a/converter/usb_usb/keymap.c b/converter/usb_usb/keymap.c new file mode 100644 index 00000000..f1211147 --- /dev/null +++ b/converter/usb_usb/keymap.c @@ -0,0 +1,122 @@ +/* +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 "keymap_common.h" + + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* 0: plain Qwerty without layer switching + * ,---------------. ,---------------. ,---------------. + * |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24| + * ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help | + * `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn| + * |-----------------------------------------------------------| |-----------| |---------------| |-------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und| + * |-----------------------------------------------------------| `-----------' |---------------| |-------| + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy| + * |-----------------------------------------------------------| ,---. |---------------| |-------| + * |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst| + * |-----------------------------------------------------------| ,-----------. |---------------| |-------| + * |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut| + * `-----------------------------------------------------------' `-----------' `---------------' `-------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), + +#if 0 + /* Colemak http://colemak.com + * ,-----------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| + * |-----------------------------------------------------------| + * |Tab | Q| W| F| P| G| J| L| U| Y| ;| [| ]| \| + * |-----------------------------------------------------------| + * |BackSp| A| R| S| T| D| H| N| E| I| O| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| K| M| ,| ,| /|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| + * `----------------------------------------------------------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), + + /* Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard + * ,-----------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa| + * |-----------------------------------------------------------| + * |Tab | '| ,| .| P| Y| F| G| C| R| L| /| =| \| + * |-----------------------------------------------------------| + * |BackSp| A| O| E| U| I| D| H| T| N| S| -|Return | + * |-----------------------------------------------------------| + * |Shift | ;| Q| J| K| X| B| M| Wl V| Z|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| + * `-----------------------------------------------------------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + CAPS,A, O, E, U, I, D, H, T, N, S, MINS, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,SCLN,Q, J, K, X, B, M, W, V, Z, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), + + /* Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/ + * ,-----------------------------------------------------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| + * |-----------------------------------------------------------| + * |Tab | Q| D| R| W| B| J| F| U| P| ;| [| ]| \| + * |-----------------------------------------------------------| + * |CapsLo| A| S| H| T| G| Y| N| E| O| I| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| M| C| V| K| L| ,| ,| /|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| + * `-----------------------------------------------------------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + CAPS,A, S, H, T, G, Y, N, E, O, I, QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), +#endif +}; + +const uint16_t fn_actions[] PROGMEM = {}; diff --git a/converter/usb_usb/keymap_common.c b/converter/usb_usb/keymap_common.c new file mode 100644 index 00000000..8ab5ba92 --- /dev/null +++ b/converter/usb_usb/keymap_common.c @@ -0,0 +1,31 @@ +/* +Copyright 2014 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 "keymap_common.h" +#include "progmem.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/usb_usb/keymap_common.h b/converter/usb_usb/keymap_common.h new file mode 100644 index 00000000..ee1c7c4d --- /dev/null +++ b/converter/usb_usb/keymap_common.h @@ -0,0 +1,213 @@ +/* +Copyright 2014 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* ,---------------. ,---------------. ,---------------. + * |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24| + * ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help | + * `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn| + * |-----------------------------------------------------------| |-----------| |---------------| |-------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und| + * |-----------------------------------------------------------| `-----------' |---------------| |-------| + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy| + * |-----------------------------------------------------------| ,---. |---------------| |-------| + * |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst| + * |-----------------------------------------------------------| ,-----------. |---------------| |-------| + * |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut| + * `-----------------------------------------------------------' `-----------' `---------------' `-------' + * + * + * App: Windows Menu key + * Gui: Windows key, Mac ⌘ key or Meta key + * + * Pwr: Power for Unix and Mac + * VDn,Vup,Mut: Volume control for Unix and Mac + * Stp,Agn..: for Unix + * + * KP,: Brazilian Keypad Comma + * KP=: Keypad = for Mac + * <,#: ISO keys(UK legend) + * JPY: Japanese Yen(¥) + * RO: Japanese ろ or Brazilian / + * MHEN: Japanese 無変換 Non Conversion + * HENK: Japanese 変換 Conversion + * KANA: Japanese かな Hiragana/Katakana + * https://en.wikipedia.org/wiki/Keyboard_layout#Japanese + * H/E: Korean 한/영 Hangul/English + * HNJ: Korean 한자 Hanja + * https://en.wikipedia.org/wiki/Keyboard_layout#Hangul_.28for_Korean.29 + * + * TODO: use same keycode to pass through instead of KC_NO? + */ +#define KEYMAP_ALL( \ + K68,K69,K6A,K6B,K6C,K6D,K6E,K6F,K70,K71,K72,K73, \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, K81,K80,K7F,K66, K75, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K89,K2A, K49,K4A,K4B, K53,K54,K55,K56, K78,K79, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, K76,K7A, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,K85, K77,K7C, \ + KE1,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K87,KE5, K52, K59,K5A,K5B,K67, K74,K7D, \ + KE0,KE3,KE2,K8B,K91, K2C, K90,K8A,K88,KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63,K58, K7E,K7B \ +) { \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_##K04, KC_##K05, KC_##K06, KC_##K07, /* 00-07 */ \ + KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, /* 08-0F */ \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, /* 10-17 */ \ + KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, /* 18-1F */ \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, /* 20-27 */ \ + KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, /* 28-2F */ \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, /* 30-37 */ \ + KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, /* 38-3F */ \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, /* 40-47 */ \ + KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, /* 48-4F */ \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, /* 50-57 */ \ + KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, /* 58-5F */ \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, /* 60-67 */ \ + KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, /* 68-6F */ \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, /* 70-77 */ \ + KC_##K78, KC_##K79, KC_##K7A, KC_##K7B, KC_##K7C, KC_##K7D, KC_##K7E, KC_##K7F }, /* 78-7F */ \ + { KC_##K80, KC_##K81, KC_NO, KC_NO, KC_NO, KC_##K85, KC_NO, KC_##K87, /* 80-87 */ \ + KC_##K88, KC_##K89, KC_##K8A, KC_##K8B, KC_NO, KC_NO, KC_NO, KC_NO }, /* 88-8F */ \ + { KC_##K90, KC_##K91, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* 90-97 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 98-9F */ \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* A0-A7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* A8-AF */ \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* B0-B7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* B8-BF */ \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* C0-C7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* C8-CF */ \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* D0-D7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* D8-DF */ \ + { KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7, /* E0-E7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* E8-EF */ \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, /* F0-F7 */ \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* F8-FF */ \ +} + +/* ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| + * |-----------------------------------------------------------| `-----------' |-----------| | + * |CapsL | A| S| D| F| G| H| J| K| L| ;| '| Return| | 4| 5| 6| +| + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------| | + * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .|Ent| + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP( \ + K29,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K49,K4A,K4B, K53,K54,K55,K56, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,K31, K4C,K4D,K4E, K5F,K60,K61, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K28, K5C,K5D,K5E,K57, \ + KE1,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, KE5, K52, K59,K5A,K5B, \ + KE0,KE3,KE2, K2C, KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63,K58 \ +) KEYMAP_ALL( \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, NO, NO, NO, NO, NO, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,NO, K2A, K49,K4A,K4B, K53,K54,K55,K56, NO, NO, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, NO, NO, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, NO, K28, K5C,K5D,K5E,NO, NO, NO, \ + KE1,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, NO, KE5, K52, K59,K5A,K5B,NO, NO, NO, \ + KE0,KE3,KE2,NO, NO, K2C, NO, NO, NO, KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63,K58, NO, NO \ +) + +/* ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Retn| |Del|End|PgD| | 7| 8| 9| +| + * |------------------------------------------------------` | `-----------' |-----------| | + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #| | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft| <| Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3|Ent| + * |-----------------------------------------------------------| ,-----------. |-----------| | + * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP_ISO( \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K49,K4A,K4B, K53,K54,K55,K56, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,K28, K4C,K4D,K4E, K5F,K60,K61,K57, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,K32, K5C,K5D,K5E, \ + KE1,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, KE5, K52, K59,K5A,K5B,K58, \ + KE0,KE3,KE2, K2C, KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63 \ +) KEYMAP_ALL( \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, NO, NO, NO, NO, NO, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,NO, K2A, K49,K4A,K4B, K53,K54,K55,K56, NO, NO, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K32, K4C,K4D,K4E, K5F,K60,K61,K57, NO, NO, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,NO, NO, NO, \ + KE1,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, NO, KE5, K52, K59,K5A,K5B,NO, NO, NO, \ + KE0,KE3,KE2,NO, NO, K2C, NO, NO, NO, KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63,K58, NO, NO \ +) + +/* ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| ^|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| @| [| Retn| |Del|End|PgD| | 7| 8| 9| +| + * |------------------------------------------------------` | `-----------' |-----------| | + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| ]| | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|Ent| + * |-----------------------------------------------------------| ,-----------. |-----------| | + * |Ctl|Gui|Alt|MHEN| Space |HENK|KNA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ +#define KEYMAP_JIS( \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K89,K2A, K49,K4A,K4B, K53,K54,K55,K56, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K28, K4C,K4D,K4E, K5F,K60,K61,K57, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,K32, K5C,K5D,K5E, \ + KE1,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K87,KE5, K52, K59,K5A,K5B,K58, \ + KE0,KE3,KE2,K8B, K2C, K8A,K88,KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63 \ +) KEYMAP_ALL( \ + NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \ + K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, NO, NO, NO, NO, NO, \ + K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K89,K2A, K49,K4A,K4B, K53,K54,K55,K56, NO, NO, \ + K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K32, K4C,K4D,K4E, K5F,K60,K61,K57, NO, NO, \ + K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,NO, NO, NO, \ + KE1,NO, K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K87,KE5, K52, K59,K5A,K5B,NO, NO, NO, \ + KE0,KE3,KE2,K8B,NO, K2C, NO, K8A,K88,KE6,KE7,K65,KE4, K50,K51,K4F, K62, K63,K58, NO, NO \ +) +#endif diff --git a/converter/usb_usb/keymap_editor.c b/converter/usb_usb/keymap_editor.c new file mode 100644 index 00000000..bd63ea23 --- /dev/null +++ b/converter/usb_usb/keymap_editor.c @@ -0,0 +1,88 @@ +/* +Copyright 2016 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 "keymap_common.h" + + +#ifndef KEYMAP_SECTION_ENABLE + #error "KEYMAP_SECTION_ENABLE is not defined." +#endif + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { + /* 0: plain Qwerty without layer switching + * ,---------------. ,---------------. ,---------------. + * |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24| + * ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help | + * `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn| + * |-----------------------------------------------------------| |-----------| |---------------| |-------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und| + * |-----------------------------------------------------------| `-----------' |---------------| |-------| + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy| + * |-----------------------------------------------------------| ,---. |---------------| |-------| + * |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst| + * |-----------------------------------------------------------| ,-----------. |---------------| |-------| + * |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut| + * `-----------------------------------------------------------' `-----------' `---------------' `-------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, SPC, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), +}; + +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_MOMENTARY(2), + [2] = ACTION_LAYER_MOMENTARY(3), + [3] = ACTION_LAYER_MOMENTARY(4), + [4] = ACTION_LAYER_MOMENTARY(5), + [5] = ACTION_LAYER_MOMENTARY(6), + [6] = ACTION_LAYER_MOMENTARY(7), + [7] = ACTION_LAYER_TOGGLE(1), + [8] = ACTION_LAYER_TOGGLE(2), + [9] = ACTION_LAYER_TOGGLE(3), + [10] = ACTION_LAYER_TAP_TOGGLE(1), + [11] = ACTION_LAYER_TAP_TOGGLE(2), + [12] = ACTION_LAYER_TAP_TOGGLE(3), + [13] = ACTION_LAYER_TAP_KEY(1, KC_BSLASH), + [14] = ACTION_LAYER_TAP_KEY(2, KC_TAB), + [15] = ACTION_LAYER_TAP_KEY(3, KC_ENTER), + [16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE), + [17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON), + [18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE), + [19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH), + [20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE), + [21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE), + [22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE), + [23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER), + [24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC), + [25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE), + [26] = ACTION_MODS_ONESHOT(MOD_LCTL), + [27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC), + [28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE), + [29] = ACTION_MODS_ONESHOT(MOD_LSFT), + [30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRAVE), + [31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSLASH), +}; diff --git a/converter/usb_usb/keymap_hasu.c b/converter/usb_usb/keymap_hasu.c new file mode 100644 index 00000000..de19e230 --- /dev/null +++ b/converter/usb_usb/keymap_hasu.c @@ -0,0 +1,158 @@ +#include "keymap_common.h" + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 | + * |-----------------------------------------------------------| + * |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| + * `-----------------------------------------------------------' + * |Gui|Alt | Fn4 |Fn5 |Gui| + * `-------------------------------------------' + */ + [0] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT, FN6, P4, P5, P6, PPLS, + FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, FN4, RALT,FN5, FN5, FN1, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 1: HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [1] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, TRNS, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 2: Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [2] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 3: Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + */ + [3] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, FN8, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, DEL, END, PGDN, P7, P8, P9, + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, BTN1, RALT,TRNS,TRNS,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 5: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + */ + [4] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, FN8, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, DEL, END, PGDN, P7, P8, P9, + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, TRNS, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + + +/* + * Macro definition + */ +enum macro_id { + ALT_TAB, +}; +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) + [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer + [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching +}; diff --git a/converter/usb_usb/keymap_iso.c b/converter/usb_usb/keymap_iso.c new file mode 100644 index 00000000..f22a8405 --- /dev/null +++ b/converter/usb_usb/keymap_iso.c @@ -0,0 +1,36 @@ +#include "keymap_common.h" + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* Layer 0: Default Layer + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| ^| Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| Retn| |Del|End|PgD| | 7| 8| 9| +| + * |------------------------------------------------------` | `-----------' |-----------| | + * |CapsL | A| S| D| F| G| H| J| K| L| ;| '| #| | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft|\ | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|Ent| + * |-----------------------------------------------------------| ,-----------. |-----------| | + * |Ctl|Gui|Alt| Space |HNK|KNA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + [0] = \ + KEYMAP_ISO( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,ENT, DEL, END, PGDN, P7, P8, P9, PPLS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT + ), +}; + + +/* + * Fn action definition + */ +const uint16_t fn_actions[] PROGMEM = { +}; diff --git a/converter/usb_usb/keymap_jis.c b/converter/usb_usb/keymap_jis.c new file mode 100644 index 00000000..d164dcec --- /dev/null +++ b/converter/usb_usb/keymap_jis.c @@ -0,0 +1,36 @@ +#include "keymap_common.h" + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* Layer 0: Default Layer + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| + * `---' `---------------' `---------------' `---------------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| ^|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| @| [| Retn| |Del|End|PgD| | 7| 8| 9| +| + * |------------------------------------------------------` | `-----------' |-----------| | + * |CapsL | A| S| D| F| G| H| J| K| L| ;| :| ]| | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shft | Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|Ent| + * |-----------------------------------------------------------| ,-----------. |-----------| | + * |Ctl|Gui|Alt|MHEN| Space |HENK|KNA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + [0] = \ + KEYMAP_JIS( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JPY, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, DEL, END, PGDN, P7, P8, P9, PPLS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, P4, P5, P6, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PENT, + LCTL,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT + ), +}; + + +/* + * Fn action definition + */ +const uint16_t fn_actions[] PROGMEM = { +}; diff --git a/converter/usb_usb/keymap_spacefn.c b/converter/usb_usb/keymap_spacefn.c new file mode 100644 index 00000000..69f8693e --- /dev/null +++ b/converter/usb_usb/keymap_spacefn.c @@ -0,0 +1,65 @@ +/* + * SpaceFN layout + * http://geekhack.org/index.php?topic=51069.0 + */ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: plain Qwerty + * ,---------------. ,---------------. ,---------------. + * |F13|F14|F15|F16| |F17|F18|F19|F20| |F21|F22|F23|F24| + * ,---. |---------------| |---------------| |---------------| ,-----------. ,---------------. ,-------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|Pwr| | Help | + * `---' `---------------' `---------------' `---------------' `-----------' `---------------' `-------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. ,-------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -| |Stp|Agn| + * |-----------------------------------------------------------| |-----------| |---------------| |-------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +| |Mnu|Und| + * |-----------------------------------------------------------| `-----------' |---------------| |-------| + * |LCtrl | A| S| D| F| G| H| J| K| L| ;| :| #|Retn| | 4| 5| 6|KP,| |Sel|Cpy| + * |-----------------------------------------------------------| ,---. |---------------| |-------| + * |Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=| |Exe|Pst| + * |-----------------------------------------------------------| ,-----------. |---------------| |-------| + * |Ctl|Gui|Alt|MHEN|HNJ| Space |H/E|HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent| |Fnd|Cut| + * `-----------------------------------------------------------' `-----------' `---------------' `-------' + */ + KEYMAP_ALL( + F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,PWR, HELP, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, STOP,AGIN, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, MENU,UNDO, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM, SLCT,COPY, + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL, EXEC,PSTE, + LCTL,LGUI,LALT,MHEN,HANJ, FN0, HAEN,HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT, FIND,CUT + ), + + /* 1: SpaceFN + * ,-----------------------------------------------------------. + * |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * |Caps | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins | + * |-----------------------------------------------------------| + * | | | | | | |PgU|Lef|Dow|Rig| | | | + * |-----------------------------------------------------------| + * | | | | | |Spc|PgD|` |~ | |Men| | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + */ + KEYMAP_ALL( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, + TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, + CAPS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS, INS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP, TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS, + TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS, TRNS,TRNS + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde +}; + diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp new file mode 100644 index 00000000..652c8057 --- /dev/null +++ b/converter/usb_usb/main.cpp @@ -0,0 +1,132 @@ +#include +#include +#include +#include + +// USB HID host +#include "Usb.h" +#include "usbhub.h" +#include "hid.h" +#include "hidboot.h" +#include "parser.h" + +// LUFA +#include "lufa.h" + +#include "timer.h" +#include "sendchar.h" +#include "debug.h" +#include "keyboard.h" +#include "led.h" + + +/* LED ping configuration */ +#define TMK_LED +//#define LEONARDO_LED +#if defined(TMK_LED) +// For TMK converter and Teensy +#define LED_TX_INIT (DDRD |= (1<<6)) +#define LED_TX_ON (PORTD |= (1<<6)) +#define LED_TX_OFF (PORTD &= ~(1<<6)) +#define LED_TX_TOGGLE (PORTD ^= (1<<6)) +#elif defined(LEONARDO_LED) +// For Leonardo(TX LED) +#define LED_TX_INIT (DDRD |= (1<<5)) +#define LED_TX_ON (PORTD &= ~(1<<5)) +#define LED_TX_OFF (PORTD |= (1<<5)) +#define LED_TX_TOGGLE (PORTD ^= (1<<5)) +#else +#define LED_TX_INIT +#define LED_TX_ON +#define LED_TX_OFF +#define LED_TX_TOGGLE +#endif + + +static void LUFA_setup(void) +{ + /* Disable watchdog if enabled by bootloader/fuses */ + MCUSR &= ~(1 << WDRF); + wdt_disable(); + + /* Disable clock division */ + clock_prescale_set(clock_div_1); + + // Leonardo needs. Without this USB device is not recognized. + USB_Disable(); + + USB_Init(); + + // for Console_Task + USB_Device_EnableSOFEvents(); + print_set_sendchar(sendchar); +} + + + +/* + * USB Host Shield HID keyboard + */ +USB usb_host; +USBHub hub1(&usb_host); +HIDBoot kbd(&usb_host); +KBDReportParser kbd_parser; + + +void led_set(uint8_t usb_led) +{ + kbd.SetReport(0, 0, 2, 0, 1, &usb_led); +} + + + +int main(void) +{ + // LED for debug + LED_TX_INIT; + LED_TX_ON; + + debug_enable = true; + debug_keyboard = true; + + host_set_driver(&lufa_driver); + keyboard_init(); + + LUFA_setup(); + + // USB Host Shield setup + usb_host.Init(); + kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser); + + /* NOTE: Don't insert time consuming job here. + * It'll cause unclear initialization failure when DFU reset(worm start). + */ + sei(); + + // wait for startup of sendchar routine + while (USB_DeviceState != DEVICE_STATE_Configured) ; + if (debug_enable) { + _delay_ms(1000); + } + + debug("init: done\n"); + +uint16_t timer; + for (;;) { + keyboard_task(); + +timer = timer_read(); + usb_host.Task(); +timer = timer_elapsed(timer); +if (timer > 100) { + debug("host.Task: "); debug_hex16(timer); debug("\n"); +} + +#if !defined(INTERRUPT_CONTROL_ENDPOINT) + // LUFA Task for control request + USB_USBTask(); +#endif + } + + return 0; +} diff --git a/converter/usb_usb/matrix.c b/converter/usb_usb/matrix.c new file mode 100644 index 00000000..184933ac --- /dev/null +++ b/converter/usb_usb/matrix.c @@ -0,0 +1,133 @@ +/* +Copyright 2011 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 +#include +#include "usb_hid.h" +#include "keycode.h" +#include "util.h" +#include "print.h" +#include "debug.h" +#include "matrix.h" + +/* KEY CODE to Matrix + * + * HID keycode(1 byte): + * Higher 5 bits indicates ROW and lower 3 bits COL. + * + * 7 6 5 4 3 2 1 0 + * +---------------+ + * | ROW | COL | + * +---------------+ + * + * Matrix space(16 * 16): + * r\c0123456789ABCDEF + * 0 +----------------+ + * : | | + * : | | + * 16 +----------------+ + */ +#define ROW_MASK 0xF0 +#define COL_MASK 0x0F +#define CODE(row, col) (((row) << 4) | (col)) +#define ROW(code) (((code) & ROW_MASK) >> 4) +#define COL(code) ((code) & COL_MASK) +#define ROW_BITS(code) (1 << COL(code)) + + +uint8_t matrix_rows(void) { return MATRIX_ROWS; } +uint8_t matrix_cols(void) { return MATRIX_COLS; } +void matrix_init(void) {} +bool matrix_has_ghost(void) { return false; } + +static bool matrix_is_mod =false; + +uint8_t matrix_scan(void) { + static uint16_t last_time_stamp = 0; + + if (last_time_stamp != usb_hid_time_stamp) { + last_time_stamp = usb_hid_time_stamp; + matrix_is_mod = true; + } else { + matrix_is_mod = false; + } + return 1; +} + +bool matrix_is_modified(void) { + + return matrix_is_mod; +} + +bool matrix_is_on(uint8_t row, uint8_t col) { + uint8_t code = CODE(row, col); + + if (IS_MOD(code)) { + if (usb_hid_keyboard_report.mods & ROW_BITS(code)) { + return true; + } + } + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + if (usb_hid_keyboard_report.keys[i] == code) { + return true; + } + } + return false; +} + +matrix_row_t matrix_get_row(uint8_t row) { + uint16_t row_bits = 0; + + if (IS_MOD(CODE(row, 0)) && usb_hid_keyboard_report.mods) { + row_bits |= usb_hid_keyboard_report.mods; + } + + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + if (IS_ANY(usb_hid_keyboard_report.keys[i])) { + if (row == ROW(usb_hid_keyboard_report.keys[i])) { + row_bits |= ROW_BITS(usb_hid_keyboard_report.keys[i]); + } + } + } + return row_bits; +} + +uint8_t matrix_key_count(void) { + uint8_t count = 0; + + count += bitpop(usb_hid_keyboard_report.mods); + for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { + if (IS_ANY(usb_hid_keyboard_report.keys[i])) { + count++; + } + } + return count; +} + +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)); +#ifdef MATRIX_HAS_GHOST + if (matrix_has_ghost_in_row(row)) { + print(" +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +#AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + + +include $(TMK_DIR)/protocol.mk +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/converter/x68k_usb/README b/converter/x68k_usb/README new file mode 100644 index 00000000..516fcd24 --- /dev/null +++ b/converter/x68k_usb/README @@ -0,0 +1,151 @@ +X68000 to USB keyboard protocol converter +========================================= +SHARP X68000 is a hobby computer released in Japan.(1987-93) +http://en.wikipedia.org/wiki/Sharp_X68000 + +X68000 keyboard has ALPS linear switches. +- DSETK0016CE01 green linear +- DSETK0022CE02 yellow linear +- DSETK0023CE03 yellow linear + + +Hardware +-------- +Target MCU is ATMega32u4 but other USB capable AVR will also work. +You can use PJRC Teensy as development board. + http://www.pjrc.com/teensy/ + +Wiring: + Mini-DIN Teensy + ----------------------------------------------------- + pin1 +5V VCC + pin2 MOUSE - + pin3 RXD PD2(RXD) + pin4 TXD PD3(TXD) NOTE: Not supported yet. + pin5 READY - + pin6 REMOTE - + pin7 GND GND + + +Firmware +-------- +Build: + $ cd x68k_usb + $ make + +And load the binary to MCU with your favorite programmer. +If you use Teensy you can load with PJRC Teensy Loader tool. + http://www.pjrc.com/teensy/loader.html + + +* * * * * * * * * * * * * * * * * * + + +X68000 Keyboard Protocol +======================== +http://kyoutan.jpn.org/uts/pc/pic/x68key/ + + +Connector +--------- +Mini DIN 7pin(female connector on computer side) + 7 6 5 + o o o + 4 o = o 3 + o o + 2 1 + + Mini-DIN + ------------- + pin1 +5V + pin2 MOUSE + pin3 RXD + pin4 TXD + pin5 READY + pin6 REMOTE + pin7 GND + + +Signaling +--------- +- TXD,RXD + Asynchronous, 2400baud, 1-startbit(L), 8-databit, 1-stopbit(H) + +- READY + ready/not ready(1/0) + + +Data from keyboard +------------------ +bit 7 make/break flag(0/1) +bit 6-0 following scan code + + +Data from computer +------------------ +- LED control ON/OFF(0/1) + bit 7 1(fixed) + bit 6 全角 + bit 5 ひらがな + bit 4 INS + bit 3 CAPS + bit 2 コード入力 + bit 1 ローマ字 + bit 0 かな + +- Repeat delay + bit 7 0(fixed) + bit 6 1(fixed) + bit 5 1(fixed) + bit 4 0(fixed) + bit 3-0 delay + REPEAT_DELAY = 200+delay*100 ms + default: 500ms + +- Repeat time + bit 7 0(fixed) + bit 6 1(fixed) + bit 5 1(fixed) + bit 4 1(fixed) + bit 3-0 time + REPEAT_TIME = 30+time^2*5 ms + default: 110ms + + +Scan Codes +---------- +,---. ,---. ,-------------------, ,-------------------. ,-----------. ,---------------. +| 61| | 62| | 63| 64| 65| 66| 67| | 68| 69| 6A| 6B| 6C| | 5A| 5B| 5C| | 5D| 52| 53| 54| +`---' `---' `-------------------' `-------------------' `-----------' `---------------' +,-----------------------------------------------------------. ,-----------. ,---------------. +| 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 0E| 0F| | 36| 5E| 37| | 3F| 40| 41| 42| +|-----------------------------------------------------------| |------------ |---------------| +| 10 | 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 1C| | | 38| 39| 3A| | 43| 44| 45| 46| +|------------------------------------------------------. 1D | `---=====---' |---------------| +| 71 | 1E| 1F| 20| 21| 2l| 23| 24| 25| 26| 27| 28| 29| | ___| 3C|___ | 47| 48| 49| 4A| +|-----------------------------------------------------------| | 3B|---| 3D| |-----------|---| +| 70 | 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 70 | `---| 3E|---' | 4B| 4C| 4D| | +`-----------------------------------------------------------| .---=====---. |-----------| 4E| + | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| | + `---------------------------------------------' `-----------' `---------------' + + + +LED Special Functions +--------------------- +http://homepage2.nifty.com/m_kamada/docs/unlistedx68k.htm#keyboard + +1. Random Illumination + Plug in with pressing F1, F2 and F3. + +2. Sequential Illumination + Plug in with pressing 記号入力(52), 登録(53) and HELP. + +3. Scan code Display + Plug in with pressing かな(5A), ローマ字(5B) and コード入力(5C). + You can see its scan code on LEDs by pressing a key. + +---------------------------------------------------+ + |bit|6 |5 |4 |3 |2 |1 |0 | + |---+----+--------+---+----+----------+--------+----| + |LED|全角|ひらがな|INS|CAPS|コード入力|ローマ字|かな| + +---------------------------------------------------+ diff --git a/converter/x68k_usb/config.h b/converter/x68k_usb/config.h new file mode 100644 index 00000000..b552223a --- /dev/null +++ b/converter/x68k_usb/config.h @@ -0,0 +1,65 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6800 +#define DEVICE_VER 0x0001 +#define MANUFACTURER t.m.k. +#define PRODUCT SHARP X68000 keyboard converter +#define DESCRIPTION converts SHARP X68000 keyboard protocol into USB + + +/* 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_LCTL) | MOD_BIT(KC_RCTL)) \ +) + + +/* USART configuration + * asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control + */ +#if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega32U2__) + #define SERIAL_UART_BAUD 2400 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16UL*SERIAL_UART_BAUD))-1) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B = (1< + +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 +#include +#include +#include "keycode.h" +#include "action.h" +#include "util.h" +#include "serial.h" +#include "keymap.h" + + + + +// Following macros help you to define a keymap with the form of actual keyboard layout. + +/* X68000 Keyboard Scan codes + ,---. ,---. ,-------------------, ,-------------------. ,-----------. ,---------------. + | 61| | 62| | 63| 64| 65| 66| 67| | 68| 69| 6A| 6B| 6C| | 5A| 5B| 5C| | 5D| 52| 53| 54| + `---' `---' `-------------------' `-------------------' `-----------' `---------------' + ,-----------------------------------------------------------. ,-----------. ,---------------. + | 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 0E| 0F| | 36| 5E| 37| | 3F| 40| 41| 42| + |-----------------------------------------------------------| |------------ |---------------| + | 10 | 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 1C| | | 38| 39| 3A| | 43| 44| 45| 46| + |------------------------------------------------------. 1D | `---=====---' |---------------| + | 71 | 1E| 1F| 20| 21| 2l| 23| 24| 25| 26| 27| 28| 29| | ___| 3C|___ | 47| 48| 49| 4A| + |-----------------------------------------------------------| | 3B|---| 3D| |-----------|---| + | 70 | 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 70 | `---| 3E|---' | 4B| 4C| 4D| | + `-----------------------------------------------------------| .---=====---. |-----------| 4E| + | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| | + `---------------------------------------------' `-----------' `---------------' +*/ +#define KEYMAP( \ + K61,K62, K63,K64,K65,K66,K67, K68,K69,K6A,K6B,K6C, K5A,K5B,K5C, K5D,K52,K53,K54, \ + K01,K02,K03,K04,K05,K06,K07,K08,K09,K0A,K0B,K0C,K0D,K0E,K0F, K36,K5E,K37, K3F,K40,K41,K42, \ + K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K1A,K1B,K1C, K1D, K38,K39,K3A, K43,K44,K45,K46, \ + K71,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K28,K29, K3C, K47,K48,K49,K4A, \ + K70,K2A,K2B,K2C,K2D,K2E,K2F,K30,K31,K32,K33,K34, K3B,K3E,K3D, K4B,K4C,K4D,K4E, \ + K5F,K55,K56, K35, K57,K58,K59,K60, K72, K73, K4F,K50,K51 \ +) { \ + { KC_NO, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K68, KC_##K69, KC_##K6A, KC_##K6B, KC_##K6C, KC_NO, KC_NO, KC_NO }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_NO, KC_NO, KC_NO, KC_NO, }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} + + +static const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_FUNCTION(0), // toggle all LEDs +}; + +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + static bool led = false; + switch (id) { + case 0: + if (record->event.pressed) { + if ((led = !led)) + serial_send(0x80); // all on + else + serial_send(0xff); // all off + } + break; + } +} + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* X68000 Keyboard Scan codes + ,---. ,---. ,-------------------, ,-------------------. ,-----------. ,---------------. + | 61| | 62| | 63| 64| 65| 66| 67| | 68| 69| 6A| 6B| 6C| | 5A| 5B| 5C| | 5D| 52| 53| 54| + `---' `---' `-------------------' `-------------------' `-----------' `---------------' + ,-----------------------------------------------------------. ,-----------. ,---------------. + | 01| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 0E| 0F| | 36| 5E| 37| | 3F| 40| 41| 42| + |-----------------------------------------------------------| |------------ |---------------| + | 10 | 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| 1C| | | 38| 39| 3A| | 43| 44| 45| 46| + |------------------------------------------------------. 1D | `---=====---' |---------------| + | 71 | 1E| 1F| 20| 21| 2l| 23| 24| 25| 26| 27| 28| 29| | ___| 3C|___ | 47| 48| 49| 4A| + |-----------------------------------------------------------| | 3B|---| 3D| |-----------|---| + | 70 | 2A| 2B| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 70 | `---| 3E|---' | 4B| 4C| 4D| | + `-----------------------------------------------------------| .---=====---. |-----------| 4E| + | 5F| 55 | 56 | 35 | 57 | 58 | 59 | 60| | 72 | 73 | | 4F| 50| 51| | + `---------------------------------------------' `-----------' `---------------' +*/ + /* ANSI */ + KEYMAP( + FN0, F17, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,F11, F12, F13, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC, HOME,INS, DEL, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, PGDN,PGUP,END, P7, P8, P9, PPLS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,F18, UP, P4, P5, P6, PEQL, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,GRV, LEFT,DOWN,RGHT, P1, P2, P3, PENT, + F19, LGUI,LALT, SPC, RALT,RGUI,RCTL,APP, F14, F15, P0, PCMM,PDOT + ), + /* JIS */ + KEYMAP( + F16, F17, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,F11, F12, F13, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, HOME,INS, DEL, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, ENT, PGDN,PGUP,END, P7, P8, P9, PPLS, + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NUHS, UP, P4, P5, P6, PEQL, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, LEFT,DOWN,RGHT, P1, P2, P3, PENT, + LGUI,LALT,MHEN, SPC, HENK,KANA,APP, ZKHK, F14, F15, P0, PCMM,PDOT + ), +}; + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/x68k_usb/led.c b/converter/x68k_usb/led.c new file mode 100644 index 00000000..ccc38699 --- /dev/null +++ b/converter/x68k_usb/led.c @@ -0,0 +1,43 @@ +/* +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" +#include "debug.h" + + +void led_set(uint8_t usb_led) +{ + /* X68000 LED bits 0: on, 1: off + * bit 7 1(fixed) + * bit 6 全角 + * bit 5 ひらがな + * bit 4 INS + * bit 3 CAPS + * bit 2 コード入力 + * bit 1 ローマ字 + * bit 0 かな + */ + uint8_t led = 0xFF; + if (usb_led&(1< + +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 +#include +#include +#include +#include "print.h" +#include "util.h" +#include "serial.h" +#include "matrix.h" +#include "debug.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; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + serial_init(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00; + + return; +} + +uint8_t matrix_scan(void) +{ + is_modified = false; + + uint16_t code; + code = serial_recv2(); + if (code == -1) { + return 0; + } + + dprintf("%02X\n", code); + if (code&0x80) { + // break code + if (matrix_is_on(ROW(code), COL(code))) { + matrix[ROW(code)] &= ~(1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +/* for Apple +#define VENDOR_ID 0x05AC +#define PRODUCT_ID 0xBEE0 +*/ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xBEE0 +#define DEVICE_VER 0x0202 +#define MANUFACTURER t.m.k. +#define PRODUCT Apple Desktop Bus Keyboard + + +/* message strings */ +#define DESCRIPTION Apple M0116/A9M0660 keyboard firmware + + +/* matrix size */ +#define MATRIX_ROWS 11 // last row is virtual for modifier +#define MATRIX_COLS 8 +/* define if matrix has ghost */ +#define MATRIX_HAS_GHOST +/* Set 0 if need no debouncing */ +#define DEBOUNCE 5 + + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + +/* layer switching */ +#define LAYER_SWITCH_DELAY 100 +#define LAYER_SEND_FN_TERM 300 + + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + + +#endif diff --git a/keyboard/IIgs/doc/PIN_BYPASS.jpg b/keyboard/IIgs/doc/PIN_BYPASS.jpg new file mode 100644 index 00000000..2998f0c3 Binary files /dev/null and b/keyboard/IIgs/doc/PIN_BYPASS.jpg differ diff --git a/keyboard/IIgs/doc/Teensy++_Mod.jpg b/keyboard/IIgs/doc/Teensy++_Mod.jpg new file mode 100644 index 00000000..146c1ab9 Binary files /dev/null and b/keyboard/IIgs/doc/Teensy++_Mod.jpg differ diff --git a/keyboard/IIgs/hid_listen.mac b/keyboard/IIgs/hid_listen.mac new file mode 100755 index 00000000..8758fdf8 Binary files /dev/null and b/keyboard/IIgs/hid_listen.mac differ diff --git a/keyboard/IIgs/keymap.c b/keyboard/IIgs/keymap.c new file mode 100644 index 00000000..cd33e223 --- /dev/null +++ b/keyboard/IIgs/keymap.c @@ -0,0 +1,142 @@ +/* +Copyright 2012 Jeffrey Sung + +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 . +*/ + +/* + * Keymap for Apple IIgs/Standard Keyboard + */ +#include +#include +#include +#include "keycode.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "keymap.h" + + +// Convert physical keyboard layout to matrix array. +// This is a macro to define keymap easily in keyboard layout form. +#define KEYMAP( R10C5, \ + R3C7, R3C6, R3C5, R3C4, R3C3, R3C2, R3C1, R8C1, R8C0, R3C0, R0C0, R0C1, R0C2, R0C3, R4C4, R4C5, R4C6, R4C7, \ + R9C7, R9C6, R9C5, R9C4, R9C3, R9C2, R9C1, R9C0, R1C0, R1C1, R1C2, R1C3, R1C4, R2C4, R2C5, R2C6, R2C3, \ + R10C0,R7C7, R7C6, R7C5, R7C4, R7C3, R7C2, R7C1, R7C0, R0C4, R1C6, R1C7, R1C5, R2C0, R2C1, R2C2, R2C7, \ + R10C1,R6C7, R6C6, R6C5, R6C4, R6C3, R6C2, R6C1, R6C0, R0C5, R0C6, R4C0, R4C1, R4C2, \ + R10C4,R10C2,R10C3,R5C4, R5C7, R5C5, R5C6, R5C0, R5C2, R0C7, R5C1, R5C3, R4C3 \ +) { \ + { R0C0, R0C1, R0C2, R0C3, R0C4, R0C5, R0C6, R0C7 }, \ + { R1C0, R1C1, R1C2, R1C3, R1C4, R1C5, R1C6, R1C7 }, \ + { R2C0, R2C1, R2C2, R2C3, R2C4, R2C5, R2C6, R2C7 }, \ + { R3C0, R3C1, R3C2, R3C3, R3C4, R3C5, R3C6, R3C7 }, \ + { R4C0, R4C1, R4C2, R4C3, R4C4, R4C5, R4C6, R4C7 }, \ + { R5C0, R5C1, R5C2, R5C3, R5C4, R5C5, R5C6, R5C7 }, \ + { R6C0, R6C1, R6C2, R6C3, R6C4, R6C5, R6C6, R6C7 }, \ + { R7C0, R7C1, R7C2, R7C3, R7C4, R7C5, R7C6, R7C7 }, \ + { R8C0, R8C1, KC_NO, KC_NO, KC_NO,KC_NO, KC_NO, KC_NO }, \ + { R9C0, R9C1, R9C2, R9C3, R9C4, R9C5, R9C6, R9C7 }, \ + { R10C0,R10C1, R10C2, R10C3, R10C4,R10C5, KC_NO, KC_NO} \ +} + +#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) + + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 0, // Fn0 + 1, // Fn1 + 2, // Fn2 + 3, // Fn3 + 4, // Fn4 + 0, // Fn5 + 3, // Fn6 + 3 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_NO, // Fn1 + KC_SLSH, // Fn2 + KC_SCLN, // Fn3 + KC_SPC, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. ,---------------, + * | POWER | | | + * |-----------------------------------------------------------| |---------------| + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |FN0| = | / | * | + * |-----------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | | 7 | 8 | 9 | + | + * |-----------------------------------------------------' | |---------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | | 4 | 5 | 6 | - | + * |-----------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | | 1 | 2 | 3 | E | + * |-----------------------------------------------------------| |-----------| N | + * |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T | + * `-----------------------------------------------------------' |---------------' + */ + KEYMAP( KC_PWR, + 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_BSPC, KC_FN1, KC_PEQL, KC_PSLS, KC_PAST, \ + 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_P7, KC_P8, KC_P9, KC_PPLS, \ + 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_PMNS, \ + KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_P1, KC_P2, KC_P3, \ + KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT), + + + /* Layer 1: Tenkey use Layer + * ,-----------------------------------------------------------. ,---------------, + * | POWER | | | + * |-----------------------------------------------------------| |---------------| + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |NLK| = | / | * | + * |-----------------------------------------------------------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| | |INS| 8 |PGU|V+ | + * |-----------------------------------------------------' | |---------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | |DEL|UP |PGD|V- | + * |-----------------------------------------------------------| |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| / |Shift | |LFT|DN |RGT| E | + * |-----------------------------------------------------------| |-----------| N | + * |CAPS|Alt |Gui |` |SPC |BSLS |LFT|RGT|DN|UP| | 0 | . | T | + * `-----------------------------------------------------------' `---------------' + */ + KEYMAP( KC_PWR, \ + 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_BSPC, KC_FN1, KC_PEQL, KC_PSLS, KC_MUTE, \ + 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_INS, KC_P8, KC_PGUP, KC_VOLU, \ + 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_DEL, KC_UP, KC_PGDN, KC_VOLD, \ + KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_LEFT, KC_DOWN, KC_RIGHT, \ + KC_CAPS,KC_LALT,KC_LGUI,KC_GRV, KC_SPC, KC_BSLS,KC_LEFT,KC_RGHT,KC_DOWN,KC_UP, KC_P0, KC_PDOT, KC_PENT), +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return KEYCODE(layer, row, col); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/keyboard/IIgs/led.c b/keyboard/IIgs/led.c new file mode 100644 index 00000000..f76545f0 --- /dev/null +++ b/keyboard/IIgs/led.c @@ -0,0 +1,24 @@ +/* +Copyright 2011 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 "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/keyboard/IIgs/matrix.c b/keyboard/IIgs/matrix.c new file mode 100644 index 00000000..6ca55b7e --- /dev/null +++ b/keyboard/IIgs/matrix.c @@ -0,0 +1,363 @@ +/* +Copyright 2011 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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "led.h" + + +#if (MATRIX_COLS > 16) +# error "MATRIX_COLS must not exceed 16" +#endif +#if (MATRIX_ROWS > 255) +# error "MATRIX_ROWS must not exceed 255" +#endif + + +#ifndef DEBOUNCE +# define DEBOUNCE 0 +#endif +static uint8_t debouncing = DEBOUNCE; + +// matrix state buffer(1:on, 0:off) +#if (MATRIX_COLS <= 8) +static uint8_t *matrix; +static uint8_t *matrix_prev; +static uint8_t _matrix0[MATRIX_ROWS]; +static uint8_t _matrix1[MATRIX_ROWS]; +#else +static uint16_t *matrix; +static uint16_t *matrix_prev; +static uint16_t _matrix0[MATRIX_ROWS]; +static uint16_t _matrix1[MATRIX_ROWS]; +#endif + +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif +static uint8_t read_col(uint8_t row); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + // Input with pull-up(DDR:0, PORT:1) + // Column C1 ~ C7 (PortC0-6) + // Column C0(Port E1) + DDRC &= ~0b01111111; + PORTC |= 0b01111111; + DDRE &= ~0b00000010; + PORTE |= 0b00000010; + //DDRB &= ~0b00000100; + //PORTB |= 0b00000100; + // modifier B3/4,F4/5,E4 always input + // A0 + //DDRA |= 0b00000001; + //PORTA &= 0b00000001; + //DDRB |= 0b00011000; + //PORTB &= 0b00011000; + //DDRF |= ~0b00110000; + //PORTF &= 0b00110000; + //DDRB &= ~0b00011000; + //PORTB |= 0b00011000; + //DDRF &= ~0b00110000; + //PORTF |= 0b00110000; + //DDRE &= ~0b00010000; + //PORTE |= 0b00010000; + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; + matrix = _matrix0; + matrix_prev = _matrix1; +} + +uint8_t matrix_scan(void) +{ + if (!debouncing) { + uint8_t *tmp = matrix_prev; + matrix_prev = matrix; + matrix = tmp; + } + + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + unselect_rows(); + select_row(i); + _delay_us(30); // without this wait read unstable value. + if ( i == ( MATRIX_ROWS - 1 ) ) { // CHECK CAPS LOCK + if (host_keyboard_leds() & (1<");debug_hex(matrix[row]);debug("\n"); +// } +// } +// } + return (matrix[row] & (1<mods except E4(CAPSLOCK) + uint8_t tmp; + if ( row == 10 ) { + tmp = 0xC0; + tmp |= (PINB >> 3 ) & 0b00000011; // LEFT CTRL is 0bit in modifier (HID Spec) + // LEFT SHIFT is 1bit in modifier (HID Spec) + tmp |= (PINF >> 3 ) & 0b00000100; // LEFT ALT is 2bit in modifier (HID Spec) + tmp |= (PINF >> 1 ) & 0b00001000; // LEFT GUI is 3bit in modifier (HID Spec) + tmp |= (PINA << 4 ) & 0b00010000; // CAPSLOCK + tmp |= (PINB << 3 ) & 0b00100000; // POWER + } else { + tmp = 0x00; + tmp = (PINE >> 1)&0b00000001; + tmp |= PINC << 1 ; + } + return tmp; +} + +inline +static void unselect_rows(void) +{ + // Hi-Z(DDR:0, PORT:0) to unselect + // DDR : 1, output 0, input + DDRB &= ~0b00000011; // PB: 1,0 + PORTB &= ~0b00000011; + DDRD &= ~0b00010000; // PD: 4 + PORTD &= ~0b00010000; + DDRE &= ~0b11000000; // PE: 7,6 + PORTE &= ~0b11000000; + DDRF &= ~0b11000111; // PF: 7,6,2,1,0 + PORTF &= ~0b11000111; + // to unselect virtual row(modifier), set port to output with low + DDRA |= 0b00000001; // PA: 0 for CAPSLOCK + PORTA &= ~0b00000001; + DDRB |= 0b00011100; // PB: 3,4 for modifier(row10) + PORTB &= ~0b00011100; // PB: 2 for power + DDRF |= 0b00110000; // PF: 4,5 for modifier + PORTF &= ~0b00110000; +} + +inline +static void select_row(uint8_t row) +{ + // Output low(DDR:1, PORT:0) to select + // with row enable, column could send low to AVR when pressed + // row: 0 1 2 3 4 5 6 7 8 9 + // pin: PB1, PB0, PE7, PE6, PD4, PF2, PF0, PF1, PF6 PF7 + switch (row) { + case 0: + DDRB |= (1<<1); + PORTB &= ~(1<<1); + break; + case 1: + DDRB |= (1<<0); + PORTB &= ~(1<<0); + break; + case 2: + DDRE |= (1<<7); + PORTE &= ~(1<<7); + break; + case 3: + DDRE |= (1<<6); + PORTE &= ~(1<<6); + break; + case 4: + DDRD |= (1<<4); + PORTD &= ~(1<<4); + break; + case 5: + DDRF |= (1<<2); + PORTF &= ~(1<<2); + break; + case 6: + DDRF |= (1<<0); + PORTF &= ~(1<<0); + break; + case 7: + DDRF |= (1<<1); + PORTF &= ~(1<<1); + break; + case 8: + DDRF |= (1<<6); + PORTF &= ~(1<<6); + break; + case 9: + DDRF |= (1<<7); + PORTF &= ~(1<<7); + break; + case 10: + // modifier has no row enable + // to select virtual row, set port as input + DDRA &= ~0b00000001; + PORTA |= 0b00000001; + DDRB &= ~0b00011100; + PORTB |= 0b00011100; + DDRF &= ~0b00110000; + PORTF |= 0b00110000; + break; + + } +} diff --git a/keyboard/alps64/Makefile b/keyboard/alps64/Makefile new file mode 100644 index 00000000..c82c126b --- /dev/null +++ b/keyboard/alps64/Makefile @@ -0,0 +1,141 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# make program = Download the hex file to the device. +# Please customize your programmer settings(PROGRAM_CMD) +# +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +# make dfu = Download the hex file to the device, using dfu-programmer (must +# have dfu-programmer installed). +# +# make flip = Download the hex file to the device, using Atmel FLIP (must +# have Atmel FLIP installed). +# +# make dfu-ee = Download the eeprom file to the device, using dfu-programmer +# (must have dfu-programmer installed). +# +# make flip-ee = Download the eeprom file to the device, using Atmel FLIP +# (must have Atmel FLIP installed). +# +# make debug = Start either simulavr or avarice as specified for debugging, +# with avr-gdb or avr-insight as the front end for debugging. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + +# Target file name (without extension). +TARGET = alps64 + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# project specific files +SRC = matrix.c \ + led.c + +CONFIG_H = config.h + + +# MCU name +MCU = atmega32u2 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # 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 +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +#ACTIONMAP_ENABLE = yes # Use 16bit action codes in keymap instead of 8bit keycodes + + +ifdef ACTIONMAP_ENABLE + KEYMAP_FILE = actionmap +else + KEYMAP_FILE = keymap + SRC := keymap_common.c $(SRC) +endif +ifdef KEYMAP + SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC) +else + SRC := $(KEYMAP_FILE)_plain.c $(SRC) +endif + + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/lufa.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/alps64/Makefile.keymap_editor b/keyboard/alps64/Makefile.keymap_editor new file mode 100644 index 00000000..08293d5d --- /dev/null +++ b/keyboard/alps64/Makefile.keymap_editor @@ -0,0 +1,5 @@ +# build firmware for keymap editor +# +KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor +KEYMAP = editor +include Makefile diff --git a/keyboard/alps64/actionmap_common.h b/keyboard/alps64/actionmap_common.h new file mode 100644 index 00000000..cc45edb0 --- /dev/null +++ b/keyboard/alps64/actionmap_common.h @@ -0,0 +1,54 @@ +/* +Copyright 2015 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 . +*/ +#ifndef ACTIONMAP_COMMON_H +#define ACTIONMAP_COMMON_H + + +/* Alps64 keymap definition macro */ +#define ACTIONMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \ + K30, K40, K50, K60, K70, K00, K10, K20 \ +) { \ + { AC_##K00, AC_##K01, AC_##K02, AC_##K03, AC_##K04, AC_##K05, AC_##K06, AC_##K07 }, \ + { AC_##K10, AC_##K11, AC_##K12, AC_##K13, AC_##K14, AC_##K15, AC_##K16, AC_##K17 }, \ + { AC_##K20, AC_##K21, AC_##K22, AC_##K23, AC_##K24, AC_##K25, AC_##K26, AC_##K27 }, \ + { AC_##K30, AC_##K31, AC_##K32, AC_##K33, AC_##K34, AC_##K35, AC_##K36, AC_##K37 }, \ + { AC_##K40, AC_##K41, AC_##K42, AC_##K43, AC_##K44, AC_##K45, AC_##K46, AC_##K47 }, \ + { AC_##K50, AC_##K51, AC_##K52, AC_##K53, AC_##K54, AC_##K55, AC_##K56, AC_##K57 }, \ + { AC_##K60, AC_##K61, AC_##K62, AC_##K63, AC_##K64, AC_##K65, AC_##K66, AC_##K67 }, \ + { AC_##K70, AC_##K71, AC_##K72, AC_##K73, AC_##K74, AC_##K75, AC_##K76, AC_##K77 } \ +} + +/* AEK US */ +#define ACTIONMAP_AEK( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \ + K30, K40, K50, K60, K00, K10, K20 \ +) ACTIONMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \ + K30, K40, K50, K60, APP, K00, K10, K20 \ +) + +#endif diff --git a/keyboard/alps64/actionmap_hasu.c b/keyboard/alps64/actionmap_hasu.c new file mode 100644 index 00000000..e5aee15d --- /dev/null +++ b/keyboard/alps64/actionmap_hasu.c @@ -0,0 +1,149 @@ +#include +#include "actionmap.h" +#include "action_code.h" +#include "actionmap_common.h" + + +/* + * Actions + */ +#define AC_LM1 ACTION_LAYER_MOMENTARY(1) // HHKB layer +#define AC_LT1 ACTION_LAYER_TAP_KEY(1, KC_ENTER) // HHKB layer +#define AC_LT2 ACTION_LAYER_TAP_KEY(2, KC_SLASH) // Cursor layer with Slash* +#define AC_LT3 ACTION_LAYER_TAP_KEY(3, KC_SCLN) // Mousekey layer with Semicolon* +#define AC_LT4 ACTION_LAYER_TAP_KEY(4, KC_SPC) // Space Fn +#define AC_LM3 ACTION_LAYER_MOMENTARY(3) // Mousekey layer(IJKL) +#define AC_APSW ACTION_MACRO(ALT_TAB) // Application switching +#define AC_BACK ACTION_MODS_KEY(MOD_LALT, KC_LEFT) +#define AC_FRWD ACTION_MODS_KEY(MOD_LALT, KC_RIGHT) +#define AC_LM5 ACTION_LAYER_MOMENTARY(5) + + +/* + * Macro definition + */ +enum macro_id { + ALT_TAB, +}; +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} + + +const uint16_t PROGMEM actionmaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = ACTIONMAP_AEK( \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, LT3, QUOT,LT1, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, LT2, RSFT, \ + LCTL,LGUI,LALT, LT4, LM5, LM3, LM1), + /* HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del | + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [1] = ACTIONMAP_AEK( \ + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,DEL, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS), + + /* Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [2] = ACTIONMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, TRNS,TRNS,TRNS,DEL, \ + TRNS,TRNS,LEFT,DOWN,RGHT,TRNS,LEFT,DOWN,UP, RGHT,TRNS,TRNS,ENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGDN,PGUP,END, TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS), + + /* Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [3] = ACTIONMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,WH_D,MS_U,WH_U,RGHT,BACK,FRWD,APSW, \ + TRNS,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,TRNS,TRNS,\ + TRNS,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BACK,FRWD,TRNS,TRNS, \ + TRNS,TRNS,TRNS, BTN1, TRNS,TRNS,TRNS), + + /* Layer 4: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [4] = ACTIONMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + APSW,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,WH_D,MS_U,WH_U,RGHT,BACK,FRWD,APSW, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,TRNS,MS_L,MS_D,MS_R,BTN1,TRNS,ENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BACK,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS), + + /* 40% */ + [5] = ACTIONMAP_AEK( \ + TRNS,1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS,TRNS,TRNS, \ + TRNS,s(1),s(2),s(3),s(4),s(5),s(6),s(7),s(8),s(9),s(0),TRNS,TRNS,TRNS, \ + TRNS,1, 2, 3, 4, 5, 6, 7, 8, 9, 0, TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS), +}; diff --git a/keyboard/alps64/actionmap_plain.c b/keyboard/alps64/actionmap_plain.c new file mode 100644 index 00000000..4a78b7a1 --- /dev/null +++ b/keyboard/alps64/actionmap_plain.c @@ -0,0 +1,52 @@ +#include +#include "actionmap.h" +#include "action_code.h" +#include "actionmap_common.h" + + +/* + * Actions + */ +#define AC_LM1 ACTION_LAYER_MOMENTARY(1) // HHKB layer + + +const uint16_t PROGMEM actionmaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|BSpc | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = ACTIONMAP_AEK( \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,LM1), + /* HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del | + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [1] = ACTIONMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,DEL, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS), +}; diff --git a/keyboard/alps64/config.h b/keyboard/alps64/config.h new file mode 100644 index 00000000..824d3e83 --- /dev/null +++ b/keyboard/alps64/config.h @@ -0,0 +1,70 @@ +/* +Copyright 2015 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6464 +#define DEVICE_VER 0x0001 +#define MANUFACTURER TMK +#define PRODUCT Alps64 +#define DESCRIPTION TMK keyboard firmware for Alps64 + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* 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 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/alps64/keymap_common.c b/keyboard/alps64/keymap_common.c new file mode 100644 index 00000000..fdb1769e --- /dev/null +++ b/keyboard/alps64/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2012,2013 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 "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/alps64/keymap_common.h b/keyboard/alps64/keymap_common.h new file mode 100644 index 00000000..957db579 --- /dev/null +++ b/keyboard/alps64/keymap_common.h @@ -0,0 +1,70 @@ +/* +Copyright 2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* Alps64 keymap definition macro */ +#define KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K26, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K41, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, K22, \ + K30, K40, K50, K60, K70, K00, K10, K20 \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 } \ +} + +/* AEK US */ +#define KEYMAP_AEK( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, \ + K30, K40, K50, K60, K00, K10, K20 \ +) KEYMAP( \ + K36, K37, K46, K47, K56, K57, K66, K67, K76, K77, K06, K07, K17, NUHS,K27, \ + K34, K35, K44, K45, K54, K55, K64, K65, K75, K05, K15, K16, K25, K24, \ + K32, K33, K43, K52, K53, K63, K73, K74, K03, K04, K13, K14, K23, \ + K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \ + K30, K40, K50, K60, APP, K00, K10, K20 \ +) + +#endif diff --git a/keyboard/alps64/keymap_editor.c b/keyboard/alps64/keymap_editor.c new file mode 100644 index 00000000..68c629f0 --- /dev/null +++ b/keyboard/alps64/keymap_editor.c @@ -0,0 +1,66 @@ +#include "keymap_common.h" + +#ifdef KEYMAP_SECTION_ENABLE +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +#endif + /* 0: qwerty + * ,-----------------------------------------------------------. + * |` | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| #|Bsp| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | + * |-----------------------------------------------------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | + * |-----------------------------------------------------------| + * |Shft| \| Z| X| C| V| B| N| M| ,| .| /|Shift |Esc| + * |-----------------------------------------------------------' + * |Ctrl|Gui |Alt | Space |App |Alt |Gui |Ctrl | + * `-----------------------------------------------------------' + */ + KEYMAP( \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,ESC, \ + LCTL,LGUI,LALT, SPC, APP, RALT,RGUI,RCTL), +}; + +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_MOMENTARY(2), + [2] = ACTION_LAYER_MOMENTARY(3), + [3] = ACTION_LAYER_MOMENTARY(4), + [4] = ACTION_LAYER_MOMENTARY(5), + [5] = ACTION_LAYER_MOMENTARY(6), + [6] = ACTION_LAYER_MOMENTARY(7), + [7] = ACTION_LAYER_TOGGLE(1), + [8] = ACTION_LAYER_TOGGLE(2), + [9] = ACTION_LAYER_TOGGLE(3), + [10] = ACTION_LAYER_TAP_TOGGLE(1), + [11] = ACTION_LAYER_TAP_TOGGLE(2), + [12] = ACTION_LAYER_TAP_TOGGLE(3), + [13] = ACTION_LAYER_TAP_KEY(1, KC_BSLASH), + [14] = ACTION_LAYER_TAP_KEY(2, KC_TAB), + [15] = ACTION_LAYER_TAP_KEY(3, KC_ENTER), + [16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE), + [17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON), + [18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE), + [19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH), + [20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE), + [21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE), + [22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE), + [23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER), + [24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC), + [25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE), + [26] = ACTION_MODS_ONESHOT(MOD_LCTL), + [27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC), + [28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE), + [29] = ACTION_MODS_ONESHOT(MOD_LSFT), + [30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRAVE), + [31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSLASH), +}; diff --git a/keyboard/alps64/keymap_hasu.c b/keyboard/alps64/keymap_hasu.c new file mode 100644 index 00000000..d297d72f --- /dev/null +++ b/keyboard/alps64/keymap_hasu.c @@ -0,0 +1,151 @@ +#include "keymap_common.h" + +/* + * Hasu + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \ | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|FN1 | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = KEYMAP_AEK( \ + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN1, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, \ + LCTL,LGUI,LALT, FN4, RALT,FN5, FN0), + + /* HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| ` | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Del | + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [1] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS,UP, NO, DEL, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT, \ + LCTL,LGUI,LALT, TRNS, RALT,RGUI,TRNS), + + /* Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Del | + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + */ + [2] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, DEL, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,RCTL), + + /* Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [3] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS), + + /* Layer 4: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * |-----------------------------------------------------------| + * |Ctrl |Gui |Alt | Space |Alt |Fn5 |Ctrl | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [4] = KEYMAP_AEK( \ + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, GRV, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT, \ + LCTL,LGUI,LALT, TRNS, TRNS,TRNS,TRNS), +}; + + +/* id for user defined function/macro */ +enum function_id { + NONE, +}; + +enum macro_id { + ALT_TAB, +}; + + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), // HHKB layer + [1] = ACTION_LAYER_TAP_KEY(1, KC_ENTER), // HHKB layer + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer(IJKL) + [6] = ACTION_LAYER_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), +}; + + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} diff --git a/keyboard/alps64/keymap_plain.c b/keyboard/alps64/keymap_plain.c new file mode 100644 index 00000000..11a43d59 --- /dev/null +++ b/keyboard/alps64/keymap_plain.c @@ -0,0 +1,33 @@ +#include "keymap_common.h" + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* 0: qwerty + * ,-----------------------------------------------------------. + * |` | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| #|Bsp| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | + * |-----------------------------------------------------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Enter | + * |-----------------------------------------------------------| + * |Shft| \| Z| X| C| V| B| N| M| ,| .| /|Shift |Esc| + * |-----------------------------------------------------------' + * |Ctrl|Gui |Alt | Space |App |Alt |Gui |Ctrl | + * `-----------------------------------------------------------' + */ + [0] = KEYMAP( \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, NUHS, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ + LCTL,LGUI,LALT, SPC, APP, RALT,RGUI,FN0), + [1] = KEYMAP( \ + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS,BSPC, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), +}; + +const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/keyboard/alps64/led.c b/keyboard/alps64/led.c new file mode 100644 index 00000000..d20c51aa --- /dev/null +++ b/keyboard/alps64/led.c @@ -0,0 +1,34 @@ +/* +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 +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +#define LED_ON() do { DDRC |= (1<<5); PORTC |= (1<<5); } while (0) +#define LED_OFF() do { DDRC &= ~(1<<5); PORTC &= ~(1<<5); } while (0) +#define LED_TGL() do { DDRC |= (1<<5); PINC |= (1<<5); } while (0) + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + + //debug + debug_matrix = true; + LED_ON(); + _delay_ms(500); + LED_OFF(); +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + _delay_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + _delay_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + return 1; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<.c` and see keymap document(you can find in top README.md) and existent keymap files. + +To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like: + + $ make KEYMAP=[poker|poker_set|poker_bit|plain|hasu|spacefn|hhkb|] + + +### 1 Poker +[keymap_poker.c](keymap_poker.c) emulates original Poker layers +while both [keymap_poker_bit.c](keymap_poker_bit.c) and [keymap_poker_set.c](keymap_poker_set.c) implements same layout in different way and they fix a minor issue of original Poker and enhance arrow keys. + + Fn + Esc = ` + Fn + {left, down, up, right} = {home, pgdown, pgup, end} + +#### 1.0 Default layer + ,-----------------------------------------------------------. + | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space |Fn |Gui |App |Ctrl| + `-----------------------------------------------------------' +#### 1.1 Poker Fn layer + ,-----------------------------------------------------------. + |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | + |-----------------------------------------------------------| + | |FnQ| Up| | | | | | |Cal| |Hom|Ins| | + |-----------------------------------------------------------| + | |Lef|Dow|Rig| | |Psc|Slk|Pau| |Tsk|End| | + |-----------------------------------------------------------| + | |Del| |Web|Mut|VoU|VoD| |PgU|PgD|Del| Up | + |-----------------------------------------------------------| + | | | | FnS |Fn |Left|Down|Righ| + `-----------------------------------------------------------' + + +### 2. Plain +Without any Fn layer this will be useful if you want to use key remapping tool like AHK on host. +See [keymap_plain.c](keymap_plain.c) for detail. + +#### 1.0 Plain Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| + `-----------------------------------------------------------' + + +### 3. Hasu +This is my favorite keymap with HHKB Fn, Vi cursor and Mousekey layer. See [keymap_hasu.c](keymap_hasu.c) for detail. + + +### 4. SpaceFN +This layout proposed by spiceBar uses space bar to change layer with using Dual role key technique. See [keymap_spacefn.c](keymap_spacefn.c) and [SpaceFN discussion](http://geekhack.org/index.php?topic=51069.0). + +#### 4.0 Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space/Fn |Alt |Gui |App |Ctrl| + `-----------------------------------------------------------' +#### 4.1 SpaceFN layer + ,-----------------------------------------------------------. + |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + |-----------------------------------------------------------| + | | | | | | | |Hom|Up |End|Psc|Slk|Pau|Ins | + |-----------------------------------------------------------| + | | | | | | |PgU|Lef|Dow|Rig| | | | + |-----------------------------------------------------------| + | | | | | |Spc|PgD|` |~ | | | | + |-----------------------------------------------------------| + | | | | Fn | | | | | + `-----------------------------------------------------------' + + +### 5. HHKB +[keymap_hhkb.c](keymap_hhkb.c) emulates original HHKB layers. +#### 5.0: Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + |-----------------------------------------------------------| + |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn | + |-----------------------------------------------------------| + | |Gui |Alt | Space | |Alt |Gui | | + `-----------------------------------------------------------' +#### 5.1: HHKB Fn layer + ,-----------------------------------------------------------. + |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + |-----------------------------------------------------------| + |Caps | | | | | | | |Psc|Slk|Pus|Up | | | + |-----------------------------------------------------------| + | |VoD|VoU|Mut|Ejc| | *| /|Hom|PgU|Lef|Rig|Enter | + |-----------------------------------------------------------| + | | | | | | | +| -|End|PgD|Dow| | | + |-----------------------------------------------------------| + | | | | | | | | | + `-----------------------------------------------------------' + diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h new file mode 100644 index 00000000..e9c0f436 --- /dev/null +++ b/keyboard/gh60/config.h @@ -0,0 +1,70 @@ +/* +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER geekhack +#define PRODUCT GH60 +#define DESCRIPTION t.m.k. keyboard firmware for GH60 + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* 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 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/gh60/keymap_common.c b/keyboard/gh60/keymap_common.c new file mode 100644 index 00000000..fdb1769e --- /dev/null +++ b/keyboard/gh60/keymap_common.c @@ -0,0 +1,30 @@ +/* +Copyright 2012,2013 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 "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h new file mode 100644 index 00000000..896badd7 --- /dev/null +++ b/keyboard/gh60/keymap_common.h @@ -0,0 +1,84 @@ +/* +Copyright 2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +/* GH60 keymap definition macro + * K2C, K31 and K3C are extra keys for ISO + */ +#define KEYMAP( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ + K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \ +) { \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_NO, KC_NO, KC_##K45, KC_NO, KC_NO, KC_NO, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D } \ +} + +/* ANSI valiant. No extra keys for ISO */ +#define KEYMAP_ANSI( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, \ + K40, K41, K42, K45, K4A, K4B, K4C, K4D \ +) KEYMAP( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ + K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, NO, K3D, \ + K40, K41, K42, K45, NO, K4A, K4B, K4C, K4D \ +) + + +#define KEYMAP_HHKB( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K49,\ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3C, \ + K40, K41, K42, K45, K4A, K4B, K4C, K4D \ +) KEYMAP( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, NO, K2D, \ + K30, NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, \ + K40, K41, K42, K45, K49, K4A, K4B, K4C, K4D \ +) + +#endif diff --git a/keyboard/gh60/keymap_hasu.c b/keyboard/gh60/keymap_hasu.c new file mode 100644 index 00000000..e6af2858 --- /dev/null +++ b/keyboard/gh60/keymap_hasu.c @@ -0,0 +1,145 @@ +#include "keymap_common.h" + +/* + * Hasu + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Caps | A| S| D| F| G| H| J| K| L|Fn3| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl|Gui |Alt | Space |Alt |Fn4 |Fn4 |Fn1 | + * `-----------------------------------------------------------' + */ + KEYMAP_ANSI( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, FN2, QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, FN9, \ + LCTL,LGUI,LALT, SPC, RALT,FN3, FN3, FN0), + /* Keymap 1: colemak */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, \ + BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, \ + LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0), + /* Keymap 2: dvorak */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, \ + TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, \ + CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, \ + LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0), + /* Keymap 3: workman */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, \ + BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, \ + LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, FN0), + + /* Overlay 4: HHKB mode + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Inser| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl|Gui |Alt | Space |Alt |Gui |App | | + * `-----------------------------------------------------------' + */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,INS, \ + LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, \ + LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,FN4, TRNS), + /* Overlay 5: Vi mode (Slash) + * ,-----------------------------------------------------------. + * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgU|End| |Shift | + * |-----------------------------------------------------------| + * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| + * `-----------------------------------------------------------' + */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, TRNS,TRNS,TRNS,TRNS, \ + LCTL,TRNS,LEFT,DOWN,RGHT,TRNS,LEFT,DOWN,UP, RGHT,TRNS,TRNS, ENT, \ + LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGDN,PGUP,END, TRNS, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL), + /* Overlay 6: Mouse mode (Semicolon/App) + * ,-----------------------------------------------------------. + * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp | + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|MwU|MwR| | | | | + * |-----------------------------------------------------------| + * |Contro| |Ac0|Ac1|Ac1| |McL|McD|McU|McR| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | + * |-----------------------------------------------------------| + * |Ctrl|Gui |Alt | Space | | | | | + * `-----------------------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ + TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,TRNS, \ + LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,TRNS, ENT, \ + LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,TRNS, RSFT, \ + LCTL,LGUI,LALT, BTN1, TRNS,TRNS,TRNS,RCTL), + /* Overlay 7: Layout selector + * ,-----------------------------------------------------------. + * | Lq| Lc| Ld| Lw| | | | | | | | | | | + * |-----------------------------------------------------------| + * | |Lq |Lw | | | | | | | | | | | | + * |-----------------------------------------------------------| + * | | | |Ld | | | | | | | | | | + * |-----------------------------------------------------------| + * | | | |Lc | | | | | | | | | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + * Lq: set Qwerty layout + * Lc: set Colemak layout + * Ld: set Dvorak layout + * Lw: set Workman layout + */ + KEYMAP_ANSI( + FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), +}; + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(4), + [1] = ACTION_LAYER_TAP_KEY(5, KC_SLASH), + [2] = ACTION_LAYER_TAP_KEY(6, KC_SCLN), + [3] = ACTION_LAYER_MOMENTARY(6), + [4] = ACTION_LAYER_MOMENTARY(7), // to Layout selector + [5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout + [6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout + [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout + [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout + [9] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV), +}; diff --git a/keyboard/gh60/keymap_hhkb.c b/keyboard/gh60/keymap_hhkb.c new file mode 100644 index 00000000..ce1b816e --- /dev/null +++ b/keyboard/gh60/keymap_hhkb.c @@ -0,0 +1,52 @@ +#include "keymap_common.h" + +/* + * HHKB Layout + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: Default layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + * |-----------------------------------------------------------| + * |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn | + * |-----------------------------------------------------------| + * | |Gui |Alt | Space | |Alt |Gui | | + * `-----------------------------------------------------------' + */ + KEYMAP_HHKB( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS, GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT,FN0, \ + NO, LGUI,LALT, SPC, NO, RALT,RGUI,NO), + /* 1: HHKB Fn layer + * ,-----------------------------------------------------------. + * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | + * |-----------------------------------------------------------| + * | |VoD|VoU|Mut|Ejc| | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * | | | | | | | +| -|End|PgD|Dow| | | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + */ + KEYMAP_HHKB( + PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS,TRNS, \ + TRNS,VOLD,VOLU,MUTE,EJCT,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, PENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), +}; + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/keyboard/gh60/keymap_plain.c b/keyboard/gh60/keymap_plain.c new file mode 100644 index 00000000..3138c180 --- /dev/null +++ b/keyboard/gh60/keymap_plain.c @@ -0,0 +1,11 @@ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT,NO, ENT, \ + LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH,NO, RSFT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL), +}; +const uint16_t PROGMEM fn_actions[] = {}; diff --git a/keyboard/gh60/keymap_poker.c b/keyboard/gh60/keymap_poker.c new file mode 100644 index 00000000..7a612ee4 --- /dev/null +++ b/keyboard/gh60/keymap_poker.c @@ -0,0 +1,104 @@ +#include "keymap_common.h" + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 1: colemak */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, \ + BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, \ + LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 2: dvorak */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC,RBRC,BSPC, \ + TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, \ + CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, \ + LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 3: workman */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, \ + BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, \ + LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 4: Poker with Arrow */ + KEYMAP_ANSI( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \ + TRNS,TRNS,TRNS, TRNS, TRNS,LEFT,DOWN,RGHT), + /* 5: Poker with Esc */ + KEYMAP_ANSI( + ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), + /* 6: Poker Fn + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | + * |-----------------------------------------------------------| + * | |FnQ| Up| | | | | | |Cal| |Hom|Ins|FnL | + * |-----------------------------------------------------------| + * | |Lef|Dow|Rig| | |Psc|Slk|Pau| |Tsk|End| | + * |-----------------------------------------------------------| + * | |Del| |Web|Mut|VoU|VoD| |PgU|PgD|Del| | + * |-----------------------------------------------------------| + * | | | | FnS | | | | | + * `-----------------------------------------------------------' + * Fn: to Fn overlay + * FnL: to Layout selector overaly + * FnQ: toggle Esc overlay + * FnS: toggle Arrow overlay + */ + KEYMAP_ANSI( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + TRNS,FN2, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, FN4, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \ + TRNS,TRNS,TRNS, FN1, TRNS,TRNS,TRNS,TRNS), + /* 7: Layout selector + * ,-----------------------------------------------------------. + * | Lq| Lc| Ld| Lw| | | | | | | | | | | + * |-----------------------------------------------------------| + * | |Lq |Lw | | | | | | | | | | | | + * |-----------------------------------------------------------| + * | | | |Ld | | | | | | | | | | + * |-----------------------------------------------------------| + * | | | |Lc | | | | | | | | | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + * Lq: set Qwerty layout + * Lc: set Colemak layout + * Ld: set Dvorak layout + * Lw: set Workman layout + */ + KEYMAP_ANSI( + FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), +}; +const uint16_t PROGMEM fn_actions[] = { + /* Poker Layout */ + [0] = ACTION_LAYER_MOMENTARY(6), // to Fn overlay + [1] = ACTION_LAYER_TOGGLE(4), // toggle arrow overlay + [2] = ACTION_LAYER_TOGGLE(5), // toggle Esc overlay + [3] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // Task(RControl,RShift+Esc) + [4] = ACTION_LAYER_MOMENTARY(7), // to Layout selector + [5] = ACTION_DEFAULT_LAYER_SET(0), // set qwerty layout + [6] = ACTION_DEFAULT_LAYER_SET(1), // set colemak layout + [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout + [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout +}; diff --git a/keyboard/gh60/keymap_poker_bit.c b/keyboard/gh60/keymap_poker_bit.c new file mode 100644 index 00000000..b8870fdd --- /dev/null +++ b/keyboard/gh60/keymap_poker_bit.c @@ -0,0 +1,50 @@ +#include "keymap_common.h" + +// Poker fix with toggle and bit operation +// Fn + Esc = ` +// Fn + {left, down, up, right} = {home, pgdown, pgup, end} +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 4: Poker Default + Fn'd */ + [4] = KEYMAP_ANSI( + TRNS,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + CAPS,FN2, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN4, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \ + TRNS,TRNS,TRNS, FN1, TRNS,TRNS,TRNS,TRNS), + /* 5: Poker with Arrow */ + KEYMAP_ANSI( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, PGUP, \ + TRNS,TRNS,TRNS, TRNS, FN3, HOME,PGDN,END), + /* 6: Poker with Esc */ + KEYMAP_ANSI( + ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), + /* 7: Poker with Arrow + Fn'd */ + KEYMAP_ANSI( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \ + TRNS,TRNS,TRNS, TRNS, TRNS,LEFT,DOWN,RGHT), +}; +const uint16_t PROGMEM fn_actions[] = { + /* Poker Layout */ + [0] = ACTION_LAYER_BIT_XOR(1, 0b0101, ON_BOTH), // Poker Fn(with fix for Esc) + [1] = ACTION_LAYER_TOGGLE(5), // Poker Arrow toggle + [2] = ACTION_LAYER_TOGGLE(6), // Poker Esc toggle + [3] = ACTION_LAYER_BIT_XOR(1, 0b1101, ON_BOTH), // Poker Fn(with fix for Arrow) + [4] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN3 Task(RControl,RShift+Esc) +}; diff --git a/keyboard/gh60/keymap_poker_set.c b/keyboard/gh60/keymap_poker_set.c new file mode 100644 index 00000000..aaa31fc5 --- /dev/null +++ b/keyboard/gh60/keymap_poker_set.c @@ -0,0 +1,82 @@ +#include "keymap_common.h" + +// Poker fix with set(state transition) +// Fn + Esc = ` +// Fn + {left, down, up, right} = {home, pgdown, pgup, end} +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + KEYMAP_ANSI( + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, SPC, FN0, RGUI,APP, RCTL), + /* 1: Poker with Arrow */ + KEYMAP_ANSI( + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \ + TRNS,TRNS,TRNS, TRNS, FN1, LEFT,DOWN,RGHT), + /* 2: Poker with Esc */ + KEYMAP_ANSI( + ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, FN2, TRNS,TRNS,TRNS), + /* 3: Poker with Arrow and Esc */ + KEYMAP_ANSI( + ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, UP, \ + TRNS,TRNS,TRNS, TRNS, FN3, LEFT,DOWN,RGHT), + /* 4: Poker Fn'd */ + KEYMAP_ANSI( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + TRNS,FN6, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \ + TRNS,TRNS,TRNS, FN5, FN4, TRNS,TRNS,TRNS), + /* 5: Poker Fn'd arrow */ + KEYMAP_ANSI( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + TRNS,FN7, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, PGUP, \ + TRNS,TRNS,TRNS, FN4, FN5, HOME,PGDN,END), + /* 6: Poker Fn'd Esc */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + TRNS,FN4, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, TRNS, \ + TRNS,TRNS,TRNS, FN7, FN6, TRNS,TRNS,TRNS), + /* 7: Poker Fn'd Arrow + Esc */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS, \ + TRNS,FN5, UP, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \ + TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END, TRNS, \ + TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL, PGUP, \ + TRNS,TRNS,TRNS, FN6, FN7, HOME,PGDN,END), +}; + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + /* Poker Layout */ + [0] = ACTION_LAYER_SET(4, ON_PRESS), // FN0 move to Fn'd when press + [1] = ACTION_LAYER_SET(5, ON_PRESS), // FN1 move to Fn'd arrow when press + [2] = ACTION_LAYER_SET(6, ON_PRESS), // FN2 move to Fn'd Esc when press + [3] = ACTION_LAYER_SET(7, ON_PRESS), // FN3 move to Fn'd arrow + Esc when press + + //[4] = ACTION_LAYER_CLEAR(ON_RELEASE), // FN4 clear overlay when release + [4] = ACTION_LAYER_SET(0, ON_RELEASE), // FN4 clear overlay when release + [5] = ACTION_LAYER_SET(1, ON_RELEASE), // FN5 move to arrow when release + [6] = ACTION_LAYER_SET(2, ON_RELEASE), // FN6 move to Esc when release + [7] = ACTION_LAYER_SET(3, ON_RELEASE), // FN7 move to arrow + Esc when release + + [8] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN8 Task(RControl,RShift+Esc) +}; diff --git a/keyboard/gh60/keymap_spacefn.c b/keyboard/gh60/keymap_spacefn.c new file mode 100644 index 00000000..8077dcee --- /dev/null +++ b/keyboard/gh60/keymap_spacefn.c @@ -0,0 +1,55 @@ +#include "keymap_common.h" + +/* + * SpaceFN + * http://geekhack.org/index.php?topic=51069.0 + */ +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + * |-----------------------------------------------------------| + * |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| + * `-----------------------------------------------------------' + */ + KEYMAP_ANSI( + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, \ + LCTL,LGUI,LALT, FN0, RALT,RGUI,APP, RCTL), + + /* Overlay 1: SpaceFN + * ,-----------------------------------------------------------. + * |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * | | | | | | | |Hom|Up |End|Psc|Slk|Pau|Ins | + * |-----------------------------------------------------------| + * | | | | | | |PgU|Lef|Dow|Rig| | | | + * |-----------------------------------------------------------| + * | | | | | |Spc|PgD|` |~ | | | | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + */ + KEYMAP_ANSI( + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ + TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS,INS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,TRNS, TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS), +}; + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde +}; diff --git a/keyboard/gh60/led.c b/keyboard/gh60/led.c new file mode 100644 index 00000000..62abcd79 --- /dev/null +++ b/keyboard/gh60/led.c @@ -0,0 +1,34 @@ +/* +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 +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + _delay_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + _delay_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + return 1; +} + +bool matrix_is_modified(void) +{ + if (debouncing) return false; + return true; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED // 0x2516 (original CM XT value) +#define PRODUCT_ID 0x001A +#define DEVICE_VER 0x0000 +#define MANUFACTURER Cooler Master +#define PRODUCT Cooler Master QuickFire XT + +/* message strings */ +#define DESCRIPTION t.m.k. keyboard firmware for Cooler Master QuickFire XT + +/* matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 18 + +/* Set 0 if need no debouncing */ +#define DEBOUNCE 5 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +#endif diff --git a/keyboard/ghost_squid/keymap.c b/keyboard/ghost_squid/keymap.c new file mode 100644 index 00000000..e9ad9efe --- /dev/null +++ b/keyboard/ghost_squid/keymap.c @@ -0,0 +1,102 @@ +/* +Copyright 2014 Ralf Schmitt + +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 +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "debug.h" +#include "keymap.h" + +/* + Matrix col/row mapping + + ,----. ,-------------------. ,-------------------. ,-------------------. ,--------------. + |06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7| + `----' `-------------------' `-------------------' `-------------------' `--------------' + ,-------------------------------------------------------------------------. ,--------------. ,-------------------. + |06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0| + |-------------------------------------------------------------------------| |--------------| |-------------------| + |06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| | + |-------------------------------------------------------------------------| '--------------' |-------------- 02/7| + |02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| | + |-------------------------------------------------------------------------| ,----. |-------------------| + |01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| | + |-------------------------------------------------------------------------| ,--------------. |-------------- 02/3| + |15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| | + `-------------------------------------------------------------------------' `--------------' `-------------------' +*/ + +#define KEYMAP( \ + KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \ + KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \ + KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \ + KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \ + KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \ + KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \ +) { \ +/* 0 1 2 3 4 5 6 7 */ \ +/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\ +/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\ +/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\ +/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\ +/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\ +/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\ +/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\ +/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\ +/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\ +/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\ +/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\ +/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\ +/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\ +/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\ +/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \ +} + +#include "keymap_ansi.h" + +#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + if (layer < KEYMAPS_SIZE) { + return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]); + } else { + return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]); + } +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} diff --git a/keyboard/ghost_squid/keymap_ansi.h b/keyboard/ghost_squid/keymap_ansi.h new file mode 100644 index 00000000..ed1088ba --- /dev/null +++ b/keyboard/ghost_squid/keymap_ansi.h @@ -0,0 +1,23 @@ + +static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = { + /* Layer 0: Standard ANSI layer */ + KEYMAP(\ + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \ + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \ + /* Layer 1: Function layer */ + KEYMAP(\ + CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS) +}; + +static const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1) +}; diff --git a/keyboard/ghost_squid/led.c b/keyboard/ghost_squid/led.c new file mode 100644 index 00000000..da5dbd7a --- /dev/null +++ b/keyboard/ghost_squid/led.c @@ -0,0 +1,60 @@ +/* +Copyright 2014 Ralf Schmitt + +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 +#include "stdint.h" +#include "led.h" + +/* LED pin configuration + * + * Scroll Lock PB7 + * CAPS PC6 + * NUMLOCK PC5 + * + */ +void led_set(uint8_t usb_led) +{ + DDRB |= (1<<7); + DDRC |= (1<<5) | (1<<6); + + if (usb_led & (1< + +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 +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +#ifndef DEBOUNCE +# define DEBOUNCE 0 +#endif +static uint8_t debouncing = DEBOUNCE; + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(void); +static void init_rows(void); +static void unselect_cols(void); +static void select_col(uint8_t col); + +inline uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + unselect_cols(); + init_rows(); + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + uint8_t rows = read_rows(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1< + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xBB00 +#define MANUFACTURER t.m.k. +#define DEVICE_VER 0x0100 +#define PRODUCT Happy Buckling Keyboard + +#define DESCRIPTION mod version of IBM Model M keyboard + +/* matrix size */ +#define MATRIX_ROWS 12 +#define MATRIX_COLS 8 + +/* define if matrix has ghost */ +#define MATRIX_HAS_GHOST + +/* Set 0 if need no debouncing */ +#define DEBOUNCE 5 + +/* legacy keymap support */ +#define USE_LEGACY_KEYMAP + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_LALT) | MOD_BIT(KC_LGUI)) || \ + keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) \ +) + +#endif diff --git a/keyboard/hbkb/keymap.c b/keyboard/hbkb/keymap.c new file mode 100644 index 00000000..b89bdf8e --- /dev/null +++ b/keyboard/hbkb/keymap.c @@ -0,0 +1,231 @@ +/* +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 . +*/ + +/* + * Keymap for Macway mod + */ +#include +#include +#include +#include "keycode.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "keymap.h" + + +/* + * Layout: 59key + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS | + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Fn4 |Alt | |Fn1 | + * `-----' `---------------------------------------' `-----' + * + * Matrix: 12x8 + * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 + * ---+---------+---------+---------+---------+---------+---------+---------+--------- + * 0 | | | LCTRL | | | | RCTRL | + * 1 | | LSHIFT | | | | | RSHIFT | + * 2 | | Tab | Grave | 1 | Q | A | Z | + * 3 | | Cpslck | | 2 | W | S | X | + * 4 | | | | 3 | E | D | C | + * 5 | G | T | 5 | 4 | R | F | V | B + * 6 | | Bckspc | | | Key*1 | Bckslsh | Enter | Space + * 7 | H | Y | 6 | 7 | U | J | M | N + * 8 | | Rbrckt | Equal | 8 | I | K | Comma | + * 9 | | | | 9 | O | L | Dot | + * A | | Lbrckt | Minus | 0 | P | Smcolon | | Slash + * B | LALT | | | | | | | RALT + * Key*1 This key locates between Equal and Backspace. + * + * Original matrix here: http://geekhack.org/showthread.php?7767-Wireless-Model-M&p=133911&viewfull=1#post133911 + */ +#define KEYMAP( \ + K22, K23, K33, K43, K53, K52, K72, K73, K83, K93, KA3, KA2, K82, K64, K61, \ + K21, K24, K34, K44, K54, K51, K71, K74, K84, K94, KA4, KA1, K81, K65, \ + K31, K25, K35, K45, K55, K50, K70, K75, K85, K95, KA5, KA0, K66, \ + K11, K26, K36, K46, K56, K57, K77, K76, K86, K96, KA7, K16, \ + K02, KB0, K67, KB7, K06 \ +) { \ + { KC_NO, KC_NO, KC_##K02, KC_NO, KC_NO, KC_NO, KC_##K06, KC_NO }, \ + { KC_NO, KC_##K11, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K16, KC_NO }, \ + { KC_NO, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ + { KC_NO, KC_##K31, KC_NO, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_NO, KC_##K61, KC_NO, KC_NO, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \ + { KC_NO, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \ + { KC_##KA0, KC_##KA1, KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_NO, KC_##KA7 }, \ + { KC_##KB0, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KB7 }, \ +} + +#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) + + +// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. +static const uint8_t PROGMEM fn_layer[] = { + 0, // Fn0 + 1, // Fn1 + 2, // Fn2 + 3, // Fn3 + 4, // Fn4 + 0, // Fn5 + 0, // Fn6 + 0 // Fn7 +}; + +// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer. +// See layer.c for details. +static const uint8_t PROGMEM fn_keycode[] = { + KC_NO, // Fn0 + KC_NO, // Fn1 + KC_SLSH, // Fn2 + KC_SCLN, // Fn3 + KC_SPC, // Fn4 + KC_NO, // Fn5 + KC_NO, // Fn6 + KC_NO // Fn7 +}; + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| BS | + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Return | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .|Fn2|Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Fn4 |Alt | |Fn1 | + * `-----' `---------------------------------------' `-----' + */ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN2, FN1, \ + LGUI, LALT, FN4, RALT, FN1), + + + /* Layer 1: HHKB mode (HHKB Fn) + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Space |Alt | |Fn1 | + * `-----' `---------------------------------------' `-----' + */ + KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, NO, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,NO, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,FN1, \ + LGUI, LALT, SPC, RALT, FN1), + + + /* Layer 2: Vi mode (Quote/Rmeta) + * ,-----------------------------------------------------------. + * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | | + * |-----------------------------------------------------------| + * | \ |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End| | | | | + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | | | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgU|End|xxx|Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Space |Alt | |Fn1 | + * `-----' `---------------------------------------' `-----' + */ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \ + BSLS,HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, NO, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, NO, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT, \ + LGUI, LALT, SPC, RALT, NO), + + + + /* Layer 3: Mouse mode (Semicolon) + * ,-----------------------------------------------------------. + * | `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | | + * |-----------------------------------------------------------| + * | \ |MwL|MwD|McU|MwU|MwR|MwL|MwD|MwU|MwR| | | | | + * |-----------------------------------------------------------| + * |Contro| |McL|McD|McR| |McL|McD|McU|McR|xxx| | | + * |-----------------------------------------------------------| + * |Shift | | |Mb1|Mb2|Mb3|Mb2|Mb1| | | |Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Space |Alt | | | + * `-----' `---------------------------------------' `-----' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, NO, NO, \ + BSLS,WH_L,WH_D,MS_U,WH_U,WH_R,WH_L,WH_D,WH_U,WH_R,NO, NO, NO, NO, \ + LCTL,NO, MS_L,MS_D,MS_R,NO, MS_L,MS_D,MS_U,MS_R,FN3, NO, NO, \ + LSFT,NO, NO, BTN1,BTN2,BTN3,BTN2,BTN1,NO, NO, NO, RSFT, \ + LGUI, LALT, BTN1, RALT, NO), + + + /* Layer 4: Matias half keyboard style (Space) + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab | + * |-----------------------------------------------------------| + * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control | + * |-----------------------------------------------------------| + * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | + * |-----------------------------------------------------------| + * |Ctrl | |Alt | Fn4 |Alt | | | + * `-----' `---------------------------------------' `-----' + */ + KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \ + BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \ + LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \ + LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT, \ + LGUI, LALT, FN4, RALT, NO), + +}; + + +uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) +{ + return KEYCODE(layer, row, col); +} + +uint8_t keymap_fn_layer(uint8_t index) +{ + return pgm_read_byte(&fn_layer[index]); +} + +uint8_t keymap_fn_keycode(uint8_t index) +{ + return pgm_read_byte(&fn_keycode[index]); +} diff --git a/keyboard/hbkb/led.c b/keyboard/hbkb/led.c new file mode 100644 index 00000000..fc0eeb0f --- /dev/null +++ b/keyboard/hbkb/led.c @@ -0,0 +1,24 @@ +/* +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 "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/keyboard/hbkb/matrix.c b/keyboard/hbkb/matrix.c new file mode 100644 index 00000000..ee32312d --- /dev/null +++ b/keyboard/hbkb/matrix.c @@ -0,0 +1,206 @@ +/* +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 +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +/* + * Happy Buckling Keyboard(IBM Model M mod) + * + * Pin usage: + * COL: PD0-7 + * ROW: PB0-7, PF4-7 + */ +#ifndef DEBOUNCE +# define DEBOUNCE 10 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +#ifdef MATRIX_HAS_GHOST +static bool matrix_has_ghost_in_row(uint8_t row); +#endif +static matrix_row_t read_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // JTAG disable for PORT F. write JTD bit twice within four cycles. + MCUCR |= (1< KEYMAP=(hasu|hhkb|spacefn|) + +You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**. + + +### Program +First, push reset button on board to start bootloader. + +This command programs the controller with [dfu-programmer] if the tool is installed and configured properly. + + $ make -f Makefile. KEYMAP= dfu + +Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available. + + $ make -f Makefile. KEYMAP= flip + +Use [Teensy Loader] if your controller is Teensy/Teensy++. + + +##Keymap +To define your own keymap create file named `keymap_.c` and see [keymap document](../../doc/keymap.md) and existent keymap files. + + +##Hardware +You have some options for hardware. Development boards with USB AVR family(ATMega32U4, AT90USB1286) like Teensy will work while MegaAVR with [V-USB] library is also cheaper option for DIY. + +###1. TMK Alt Controller Board +Design files are available at [Keyboard Controller Board for HHKB(KiCad project)](https://github.com/tmk/HHKB_controller) and see [Controller Distribution thread](http://geekhack.org/index.php?topic=56494.0) if you get an assembled one. + + +###2. PJRC Teensy +See [this thread](http://geekhack.org/index.php?topic=57008.0). + + +###3. V-USB version +See [V-USB controller for HHKB](doc/V-USB.md). + + +[LUFA]: http://www.fourwalledcubicle.com/LUFA.php +[PJRC]: http://www.pjrc.com/teensy/usb_keyboard.html +[dfu-programmer]: http://dfu-programmer.sourceforge.net/ +[FLIP]: http://www.atmel.com/tools/FLIP.aspx +[Teensy Loader]: http://www.pjrc.com/teensy/loader.html +[V-USB]: http://www.obdev.at/products/vusb/index.html diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h new file mode 100644 index 00000000..c0acc0a7 --- /dev/null +++ b/keyboard/hhkb/config.h @@ -0,0 +1,71 @@ +/* +Copyright 2011 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xCAFE +#define DEVICE_VER 0x0104 +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + + +/* matrix size */ +#ifdef HHKB_JP +# define MATRIX_ROWS 16 +#else +# define MATRIX_ROWS 8 +#endif +#define MATRIX_COLS 8 + + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + + +/* period of tapping(ms) */ +#define TAPPING_TERM 300 +/* tap count needed for toggling a feature */ +#define TAPPING_TOGGLE 5 +/* Oneshot timeout(ms) */ +#define ONESHOT_TIMEOUT 300 + +/* Boot Magic salt key: Space */ +#define BOOTMAGIC_KEY_SALT KC_SPACE + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/hhkb/config_rn42.h b/keyboard/hhkb/config_rn42.h new file mode 100644 index 00000000..df75fba5 --- /dev/null +++ b/keyboard/hhkb/config_rn42.h @@ -0,0 +1,112 @@ +/* +Copyright 2011 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x4242 +#define DEVICE_VER 0x0104 +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + + +/* matrix size */ +#ifdef HHKB_JP +# define MATRIX_ROWS 16 +#else +# define MATRIX_ROWS 8 +#endif +#define MATRIX_COLS 8 + + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + + +/* period of tapping(ms) */ +#define TAPPING_TERM 300 +/* tap count needed for toggling a feature */ +#define TAPPING_TOGGLE 5 +/* Oneshot timeout(ms) */ +#define ONESHOT_TIMEOUT 300 + +/* Boot Magic salt key: Space */ +#define BOOTMAGIC_KEY_SALT KC_SPACE + +/* power control of key switch board */ +#define HHKB_POWER_SAVING + +/* + * Hardware Serial(UART) + * Baud rate are calculated with round off(+0.5). + */ +#ifdef __AVR_ATmega32U4__ + /* iom32u4.h has no definition of UCSR1D. copy from iom32u2.h */ + #define UCSR1D _SFR_MEM8(0xCB) + #define RTSEN 0 + #define CTSEN 1 + + #define SERIAL_UART_BAUD 115200 + #define SERIAL_UART_DATA UDR1 + #define SERIAL_UART_UBRR ((F_CPU/(16.0*SERIAL_UART_BAUD)-1+0.5)) + #define SERIAL_UART_RXD_VECT USART1_RX_vect + #define SERIAL_UART_TXD_READY (UCSR1A&(1<>8); /* baud rate */ \ + UCSR1B |= (1< select row 0-7 PB1 output + 7 7 8 HC4051 C(bit2)/ PB2 output + 8 8 9 LS145 A(bit0)\ PB3 output + 9 9 10 LS145 B(bit1) > select column 0-7 PB4 output + 10 10 11 LS145 C(bit2)/ PB5 output + 11 11 12 LS145 ~D(enable) Low(0) enables selected column PB6 output + 12 12 13 GND GND + 13 13 14 GND GND + 15 GND + 14 HC4051(Z2) ~Enable of Z2 row0-7 PC6 + 15 HC4051(Z3) ~Enable of Z3 row8-15 PC7 + + NOTE: Probably HYS changes threshold for upstroke and makes hysteresis in the result. + NOTE: HYS should be given High(1) when previous KEY state is Low(0). + NOTE: 1KOhm didn't work as pullup resistor on KEY. AVR internal pullup or 10KOhm resistor was OK. + NOTE: JP has two HC4051(Z2,Z3) and line 5, 6 and 7 are connected to both of them. + + (HHKB_connector.jpg) + + +Keyswitch matrix +---------------- +HHKB switch matrix is ghost-free and bounce-free. + + Pro/Pro2(8x8): + COL 0 1 2 3 4 5 6 7 + ROW --------------------------------------------------------------- + 0| 2 q w s a z x c + 1| 3 4 r e d f v b + 2| 5 6 y t g h n _NONE_ + 3| 1 Esc Tab Control LShift LAlt LMeta Space + 4| 7 8 u i k j m _NONE_ + 5| \ ` Delete Return Fn RShift RAlt RMeta + 6| 9 0 o p ; l , _NONE_ + 7| - + ] [ ' / . _NONE_ + + + JP(16x8): + COL 0 1 2 3 4 5 6 7 + ROW --------------------------------------------------------------- + 0| ESC TAB LFn LShift LCtrl + 1| 4 E MuHKN C D + 2| 3 W LAlt X S + 3| 1 HHK + 4| + 5| 5 R V F + 6| 2 Q LGui Z A + 7| 6 T Space B G + 8| 9 I Kana , K + 9| 8 U Henkan M J + A| 7 Y N H + B| 0 O RAlt . L + C| BS Right RShift Enter + D| \ [ Down Up ] + E| - P RFn / ; + F| ~ @ Left Ro : + + +Matrix diagram: + + Pro/Pro2: + +-------------------------+-+-+-+-+-+-+-+ Vcc + |bias control? - - - - - - - - --- + | 3.9K*8 R R R R R R R R | + +--------^+ +--------+ - - - - - - - - | + | 2| | HC4051 <0-------|-|-|-|-|-|-|-|--|R|-+ + | |capa. | <1-------|-|-|-|-|-|-|-|--|R|-+ + | TP1684 |sense | <2-------|-|-|-|-|-|-|-|--|R|-+ + | 11<------| <3-------|-|-|-|-|-|-|-|--|R|-+ + | | | <4-------|-|-|-|-|-|-|-|--|R|-+ + | | | <5-------|-|-|-|-|-|-|-|--|R|-+ + | <-+ | <6-------|-|-|-|-|-|-|-|--|R|-+ + | 1 4 | | | <7-------|-|-|-|-|-|-|-|--|R|-+ + +---V---^-+ | +-^-^-^--+ 0 1 2 3 4 5 6 7 33K*8 + KEY HYS | A B C +-----------------+ + | | +-^----+ | | | | LS145 | + Vcc | | |BU9831| | | | +-^--^--^--^------+ + --- | | +------+ | | | A B C D +-------+ + | | | | | | | | | | | | + 1-3 4 5 6 7 8 9 10 11 12 13-15 Pro | + 1-2 3 4 5 6 7 8 9 10 11 12-13 Pro2| + +--------------------------------------------------+ | + | connector | --- + +--------------------------------------------------+ GND + + + JP: + +-----------------------------+-+-+-+-+ Vcc + |bias control? - - - - - --- + | 3.9K*5 R R R R R | + +--------^+ +--------+ - - - - - | + | | | HC4051 <0-----------|-|-|-|-|----|R|-+ + | |capa. | Z2 <1-----------|-|-|-|-|----|R|-+ + | TP1684 |sense | <2-----------|-|-|-|-|----|R|-+ + | <---+--| <3-----------|-|-|-|-|----|R|-+ + | | | | <4-----------|-|-|-|-|----|R|-+ + | | ~En| <5-----------|-|-|-|-|----|R|-+ + | | +----> <6-----------|-|-|-|-|----|R|-+ + | | | | | A B C <7-----------|-|-|-|-|----|R|-+ + +---V---^-+ | | +-^-^-^--+ | | | | | | + KEY HYS | | | | | | | | | | | + | | | | +--------+ | | | | | | + | | | | | HC4051 <8-----------|-|-|-|-|----|R|-+ + | | | | | Z3 <9-----------|-|-|-|-|----|R|-+ + | | | +--| Prescaler-------> System Clock + | + +---------------------> USB PLL + +Design Decision: Install 16MHz crystal on board with using clock rescaler. diff --git a/keyboard/hhkb/doc/V-USB.md b/keyboard/hhkb/doc/V-USB.md new file mode 100644 index 00000000..7ae86f45 --- /dev/null +++ b/keyboard/hhkb/doc/V-USB.md @@ -0,0 +1,39 @@ +V-USB controller for HHKB +========================= +Not supported actively any more. + +## Build +Use `Makefile.vusb` for [V-USB] controller. + $ make -f Makefile.vusb + +##Hardware +###3. V-USB connection + +---+ +---------------+ + USB GND | | ATmega328p | + ~~~ C3 | | + 5V <-------+--------+---|Vcc,AVCC | HHKB pro pro2 + R1 | | ~~~~~~~~ ~~~~ + D- <----+--+-----R2-----|INT1 PB2-4|------->ROW (6-8) (5-7) + D+ <----|---+----R3-----|INT0 PC0-2|------->COL (9-11) (8-10) + Z1 Z2 | PC3|------->ENABLE (12) (11) + GND<----+---+-----------|GND PB0|<-------KEY (4) (3) + | PB1|------->PREV (5) (4) + | | + GND+-C2--+--|XTAL1 RXD|------->Debug Console + X1 | TXD|<-------Debug Console + GND+-C3--+--|XTAL2 RST|---SW--+GND + +---------------+ + R1: 1.5K Ohm + R2,R3: 68 Ohm + Z1,Z2: Zener 3.6V + C1,C2: 22pF + C3: 0.1uF + X1: Crystal 12MHz + SW: Push Switch(for bootloader) + +- NOTE: See [V-USB] documentation for more detail of hardware and the USB stack. +- NOTE: [USBaspLoader] is very useful for firmware update. + + +[V-USB]: http://www.obdev.at/products/vusb/index.html +[USBaspLoader]: http://www.obdev.at/products/vusb/usbasploader.html diff --git a/keyboard/hhkb/hhkb_avr.h b/keyboard/hhkb/hhkb_avr.h new file mode 100644 index 00000000..7ea6322c --- /dev/null +++ b/keyboard/hhkb/hhkb_avr.h @@ -0,0 +1,167 @@ +#ifndef HHKB_AVR_H +#define HHKB_AVR_H + +#include +#include +#include +#include +#include + + +// Timer resolution check +#if (1000000/TIMER_RAW_FREQ > 20) +# error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB." +#endif + + +/* + * HHKB Matrix I/O + * + * row: HC4051[A,B,C] selects scan row0-7 + * row-ext: [En0,En1] row extention for JP + * col: LS145[A,B,C,D] selects scan col0-7 and enable(D) + * key: on: 0/off: 1 + * prev: hysteresis control: assert(1) when previous key state is on + */ + + +#if defined(__AVR_ATmega32U4__) +/* + * For TMK HHKB alt controller(ATMega32U4) + * + * row: PB0-2 + * col: PB3-5,6 + * key: PD7(pull-uped) + * prev: PB7 + * power: PD4(L:off/H:on) + * row-ext: PC6,7 for HHKB JP(active low) + */ +static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); } +static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); } +static inline bool KEY_STATE(void) { return (PIND & (1<<7)); } +static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); } +static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); } +#ifdef HHKB_POWER_SAVING +static inline void KEY_POWER_ON(void) { + DDRB = 0xFF; PORTB = 0x40; // change pins output + DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on + /* Without this wait you will miss or get false key events. */ + _delay_ms(5); // wait for powering up +} +static inline void KEY_POWER_OFF(void) { + /* input with pull-up consumes less than without it when pin is open. */ + DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up + DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off +} +static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); } +#else +static inline void KEY_POWER_ON(void) {} +static inline void KEY_POWER_OFF(void) {} +static inline bool KEY_POWER_STATE(void) { return true; } +#endif +static inline void KEY_INIT(void) +{ + /* row,col,prev: output */ + DDRB = 0xFF; + PORTB = 0x40; // unable + /* key: input with pull-up */ + DDRD &= ~0x80; + PORTD |= 0x80; +#ifdef HHKB_JP + /* row extention for HHKB JP */ + DDRC |= (1<<6|1<<7); + PORTC |= (1<<6|1<<7); +#endif + KEY_UNABLE(); + KEY_PREV_OFF(); + + KEY_POWER_OFF(); +} +static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) +{ + PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07); +#ifdef HHKB_JP + if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6); + else PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7); +#endif +} + + +#elif defined(__AVR_AT90USB1286__) +/* + * For Teensy++(AT90USB1286) + * + * HHKB pro HHKB pro2 + * row: PB0-2 (6-8) (5-7) + * col: PB3-5,6 (9-12) (8-11) + * key: PE6(pull-uped) (4) (3) + * prev: PE7 (5) (4) + * + * TODO: convert into 'staitc inline' function + */ +#define KEY_INIT() do { \ + DDRB |= 0x7F; \ + DDRE |= (1<<7); \ + DDRE &= ~(1<<6); \ + PORTE |= (1<<6); \ +} while (0) +#define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ + (((COL) & 0x07)<<3) | \ + ((ROW) & 0x07)) +#define KEY_ENABLE() (PORTB &= ~(1<<6)) +#define KEY_UNABLE() (PORTB |= (1<<6)) +#define KEY_STATE() (PINE & (1<<6)) +#define KEY_PREV_ON() (PORTE |= (1<<7)) +#define KEY_PREV_OFF() (PORTE &= ~(1<<7)) +#define KEY_POWER_ON() +#define KEY_POWER_OFF() +#define KEY_POWER_STATE() true + + +#else +# error "define code for matrix scan" +#endif + + +#if 0 +// For ATMega328P with V-USB +// +// #elif defined(__AVR_ATmega328P__) +// Ports for V-USB +// key: PB0(pull-uped) +// prev: PB1 +// row: PB2-4 +// col: PC0-2,3 +// power: PB5(Low:on/Hi-z:off) +#define KEY_INIT() do { \ + DDRB |= 0x3E; \ + DDRB &= ~(1<<0); \ + PORTB |= 1<<0; \ + DDRC |= 0x0F; \ + KEY_UNABLE(); \ + KEY_PREV_OFF(); \ +} while (0) +#define KEY_SELECT(ROW, COL) do { \ + PORTB = (PORTB & 0xE3) | ((ROW) & 0x07)<<2; \ + PORTC = (PORTC & 0xF8) | ((COL) & 0x07); \ +} while (0) +#define KEY_ENABLE() (PORTC &= ~(1<<3)) +#define KEY_UNABLE() (PORTC |= (1<<3)) +#define KEY_STATE() (PINB & (1<<0)) +#define KEY_PREV_ON() (PORTB |= (1<<1)) +#define KEY_PREV_OFF() (PORTB &= ~(1<<1)) +// Power supply switching +#define KEY_POWER_ON() do { \ + KEY_INIT(); \ + PORTB &= ~(1<<5); \ + _delay_ms(1); \ +} while (0) +#define KEY_POWER_OFF() do { \ + DDRB &= ~0x3F; \ + PORTB &= ~0x3F; \ + DDRC &= ~0x0F; \ + PORTC &= ~0x0F; \ +} while (0) +#endif + +#endif diff --git a/keyboard/hhkb/keymap_common.c b/keyboard/hhkb/keymap_common.c new file mode 100644 index 00000000..e938fb62 --- /dev/null +++ b/keyboard/hhkb/keymap_common.c @@ -0,0 +1,33 @@ +/* +Copyright 2012,2013 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 +#include "action.h" +#include +#include "keymap_common.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/keyboard/hhkb/keymap_common.h b/keyboard/hhkb/keymap_common.h new file mode 100644 index 00000000..3622665f --- /dev/null +++ b/keyboard/hhkb/keymap_common.h @@ -0,0 +1,84 @@ +/* +Copyright 2012,2013 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 . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_code.h" +#include "action_layer.h" +#include "action_macro.h" +#include "action_util.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +#define KEYMAP( \ + K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \ + K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \ + K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \ + K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \ + K35, K36, K37, K57, K56 \ +) \ +{ \ + { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ + { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ + { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ + { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ + { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ + { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ + { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \ +} + + +#define KEYMAP_JP( \ + K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \ + K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \ + K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \ + K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \ + K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4 \ +) \ +{ \ + { KC_NO, KC_NO, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO }, \ + { KC_NO, KC_NO, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \ + { KC_NO, KC_NO, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ + { KC_NO, KC_NO, KC_##K32, KC_NO, KC_##K34, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_##K52, KC_##K53, KC_NO, KC_##K55, KC_##K56, KC_NO }, \ + { KC_NO, KC_NO, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ + { KC_NO, KC_NO, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \ + { KC_NO, KC_NO, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \ + { KC_NO, KC_NO, KC_##K92, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \ + { KC_NO, KC_NO, KC_##KA2, KC_##KA3, KC_NO, KC_##KA5, KC_##KA6, KC_NO }, \ + { KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO }, \ + { KC_NO, KC_NO, KC_##KC2, KC_NO, KC_##KC4, KC_##KC5, KC_##KC6, KC_NO }, \ + { KC_NO, KC_NO, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_NO }, \ + { KC_NO, KC_NO, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_NO }, \ + { KC_NO, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_NO } \ +} + +#endif diff --git a/keyboard/hhkb/keymap_hasu.c b/keyboard/hhkb/keymap_hasu.c new file mode 100644 index 00000000..a5602ded --- /dev/null +++ b/keyboard/hhkb/keymap_hasu.c @@ -0,0 +1,282 @@ +/* + * Hasu: my personal keymap + */ +#include "keymap_common.h" + + +#ifdef KEYMAP_SECTION_ENABLE +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +#endif + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 | + * |-----------------------------------------------------------| + * |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| + * `-----------------------------------------------------------' + * |Gui|Alt | Fn4 |Fn5 |Gui| + * `-------------------------------------------' + */ + [0] = \ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \ + FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ + LGUI,LALT, FN4, FN5, RGUI), + + /* Layer 1: HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [1] = \ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ + LGUI,LALT, TRNS, RALT,RGUI), + + /* Layer 2: Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [2] = \ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \ + LGUI,LALT, SPC, RALT,RGUI), + + /* Layer 3: Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [3] = \ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ + LGUI,LALT, BTN1, TRNS,TRNS), + + /* Layer 4: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + [4] = \ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,BTN4,BTN5,FN8, \ + LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ + LGUI,LALT, TRNS, TRNS,TRNS), + +#if 0 + /* Layer 3: Mouse mode(HJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Alt |Fn0| + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \ + LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \ + LGUI,LALT, BTN1, RALT,TRNS), + + /* Layer4: Mouse mode(HJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Fn0 |Alt |Fn0| + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel + */ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \ + LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \ + LGUI,LALT, TRNS, RALT,RGUI), +#endif +#if 0 + /* Layer x: Matias half-qwerty keyboard style[Space] + * ,-----------------------------------------------------------. + * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc| + * |-----------------------------------------------------------| + * |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab | + * |-----------------------------------------------------------| + * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control | + * |-----------------------------------------------------------| + * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Fn0 |Alt |Gui| + * `--------------------------------------------' + */ + KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \ + BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \ + LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \ + LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \ + LGUI,LALT, TRNS, RALT,RGUI), +#endif +}; + + + +/* id for user defined functions */ +enum function_id { + LSHIFT_LPAREN, +}; + +enum macro_id { + HELLO, + VOLUP, + ALT_TAB, +}; + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) + [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL) + [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), + +// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace +// [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc +// [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '(' +// [x] = ACTION_MACRO(HELLO), // Macro: say hello +// [x] = ACTION_MACRO(VOLUP), // Macro: media key +}; + + +/* + * Macro definition + */ +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case HELLO: + return (record->event.pressed ? + MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : + MACRO_NONE ); + case VOLUP: + return (record->event.pressed ? + MACRO( D(VOLU), U(VOLU), END ) : + MACRO_NONE ); + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} + + + +/* + * user defined action function + */ +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + if (record->event.pressed) dprint("P"); else dprint("R"); + dprintf("%d", record->tap.count); + if (record->tap.interrupted) dprint("i"); + dprint("\n"); + + switch (id) { + case LSHIFT_LPAREN: + // Shift parentheses example: LShft + tap '(' + // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses + // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899 + if (record->event.pressed) { + if (record->tap.count > 0 && !record->tap.interrupted) { + if (record->tap.interrupted) { + dprint("tap interrupted\n"); + register_mods(MOD_BIT(KC_LSHIFT)); + } + } else { + register_mods(MOD_BIT(KC_LSHIFT)); + } + } else { + if (record->tap.count > 0 && !(record->tap.interrupted)) { + add_weak_mods(MOD_BIT(KC_LSHIFT)); + send_keyboard_report(); + register_code(KC_9); + unregister_code(KC_9); + del_weak_mods(MOD_BIT(KC_LSHIFT)); + send_keyboard_report(); + record->tap.count = 0; // ad hoc: cancel tap + } else { + unregister_mods(MOD_BIT(KC_LSHIFT)); + } + } + break; + } +} diff --git a/keyboard/hhkb/keymap_hhkb.c b/keyboard/hhkb/keymap_hhkb.c new file mode 100644 index 00000000..7807f436 --- /dev/null +++ b/keyboard/hhkb/keymap_hhkb.c @@ -0,0 +1,95 @@ +/* + * HHKB Layout + */ +#include "keymap_common.h" + + +#ifdef KEYMAP_SECTION_ENABLE +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +#endif + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| + * `-----------------------------------------------------------' + * |Alt|Gui | Space |Gui |Alt| + * `-------------------------------------------' + */ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ + LALT,LGUI, SPC, RGUI,RALT), + + /* Layer 1: HHKB mode (HHKB Fn) + * ,-----------------------------------------------------------. + * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * | | | | | | | +| -|End|PgD|Dow| | | + * `-----------------------------------------------------------' + * | | | | | | + * `-------------------------------------------' + */ + KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \ + TRNS,TRNS, TRNS, TRNS,TRNS), +}; + + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_MOMENTARY(2), + [2] = ACTION_LAYER_MOMENTARY(3), + [3] = ACTION_LAYER_MOMENTARY(4), + [4] = ACTION_LAYER_MOMENTARY(5), + [5] = ACTION_LAYER_MOMENTARY(6), + [6] = ACTION_LAYER_MOMENTARY(7), + [7] = ACTION_LAYER_TOGGLE(1), + [8] = ACTION_LAYER_TOGGLE(2), + [9] = ACTION_LAYER_TOGGLE(3), + [10] = ACTION_LAYER_TAP_TOGGLE(1), + [11] = ACTION_LAYER_TAP_TOGGLE(2), + [12] = ACTION_LAYER_TAP_TOGGLE(3), + [13] = ACTION_LAYER_TAP_KEY(1, KC_BSLASH), + [14] = ACTION_LAYER_TAP_KEY(2, KC_TAB), + [15] = ACTION_LAYER_TAP_KEY(3, KC_ENTER), + [16] = ACTION_LAYER_TAP_KEY(4, KC_SPACE), + [17] = ACTION_LAYER_TAP_KEY(5, KC_SCOLON), + [18] = ACTION_LAYER_TAP_KEY(6, KC_QUOTE), + [19] = ACTION_LAYER_TAP_KEY(7, KC_SLASH), + [20] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_SPACE), + [21] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_SPACE), + [22] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_QUOTE), + [23] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENTER), + [24] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_ESC), + [25] = ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPACE), + [26] = ACTION_MODS_ONESHOT(MOD_LCTL), + [27] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_ESC), + [28] = ACTION_MODS_TAP_KEY(MOD_LSFT, KC_BSPACE), + [29] = ACTION_MODS_ONESHOT(MOD_LSFT), + [30] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRAVE), + [31] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_BSLASH), +}; +#else +const uint16_t fn_actions[] PROGMEM = { + [0] = ACTION_LAYER_MOMENTARY(1), +}; +#endif diff --git a/keyboard/hhkb/keymap_jp.c b/keyboard/hhkb/keymap_jp.c new file mode 100644 index 00000000..48d0ee70 --- /dev/null +++ b/keyboard/hhkb/keymap_jp.c @@ -0,0 +1,50 @@ +/* + * HHKB JP Layout + */ +#include "keymap_common.h" + + +#ifdef KEYMAP_SECTION_ENABLE +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +#else +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +#endif + /* Layer 0: Default Layer */ + KEYMAP_JP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, UP, RSFT, \ + FN0, ZKHK,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,FN0, LEFT,DOWN,RGHT), + + /* Layer 1: HHKB mode (HHKB Fn) + * ,-----------------------------------------------------------. + * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | + * |------------------------------------------------------` | + * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | | + * |-----------------------------------------------------------| + * | | | | | | | +| -|End|PgD|Dow| | | | + * |-----------------------------------------------------------| + * | || | | | | | | | | || | | | + * `-----------------------------------------------------------' + */ + KEYMAP_JP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS,PENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS), +}; + + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_LAYER_MOMENTARY(1), +}; diff --git a/keyboard/hhkb/keymap_spacefn.c b/keyboard/hhkb/keymap_spacefn.c new file mode 100644 index 00000000..deff920a --- /dev/null +++ b/keyboard/hhkb/keymap_spacefn.c @@ -0,0 +1,116 @@ +/* + * SpaceFN + * http://geekhack.org/index.php?topic=51069.0 + */ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| `|BSp| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter | + * |-----------------------------------------------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| + * `-----------------------------------------------------------' + * |Gui|Alt | SpaceFN |Alt |Gui| + * `-------------------------------------------' + */ + KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, GRV, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, \ + LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ + LGUI,LALT, FN1, RALT,RGUI), + + /* Layer 1: HHKB mode (HHKB Fn) + * ,-----------------------------------------------------------. + * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * | | | | | | | +| -|End|PgD|Dow| | | + * `-----------------------------------------------------------' + * | | | | | | + * `-------------------------------------------' + */ + KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ + CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \ + TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \ + TRNS,TRNS, SPC, TRNS,TRNS), + + /* Layer 2: SpaceFN + * ,-----------------------------------------------------------. + * |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| |Del| + * |-----------------------------------------------------------| + * | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins | + * |-----------------------------------------------------------| + * | | | | | | |PgU|Lef|Dow|Rig| | | | + * |-----------------------------------------------------------| + * | | | | | |Spc|PgD|` |~ | | | | | + * `-----------------------------------------------------------' + * | | | | | | + * `-------------------------------------------' + */ + KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, TRNS,DEL, \ + TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,FN3, END, PSCR,SLCK,PAUS,INS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN2, TRNS,TRNS,TRNS,NO, \ + TRNS,TRNS, TRNS, TRNS,TRNS), +}; + + +/* + * user defined action function + */ +enum function_id { + CTRL_SPACE_I, // Ctrl + Up(SpaceFN) -> PgUp +}; + +void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) +{ +# define MODS_CTRL_MASK (MOD_BIT(KC_LCTRL)|MOD_BIT(KC_RCTRL)) + static uint8_t ctrl_space_i_prev_ctrl; + + switch (id) { + // Ctrl + Up(SpaceFN) -> PgUp + case CTRL_SPACE_I: + ctrl_space_i_prev_ctrl = get_mods()&MODS_CTRL_MASK; + if (record->event.pressed) { + if (ctrl_space_i_prev_ctrl) { + del_mods(ctrl_space_i_prev_ctrl); // remove Ctrl + add_key(KC_PGUP); + send_keyboard_report(); // send PgUp without Ctrl + add_mods(ctrl_space_i_prev_ctrl); // return Ctrl but not sent + } else { + add_key(KC_UP); + send_keyboard_report(); + } + } else { + if (ctrl_space_i_prev_ctrl) { + del_key(KC_PGUP); + send_keyboard_report(); + } else { + del_key(KC_UP); + send_keyboard_report(); + } + } + break; + } +} + + +/* + * Fn action definition + */ +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1), + [1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE), + [2] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde + [3] = ACTION_FUNCTION(CTRL_SPACE_I), // Ctrl + Up(SpaceFN) -> PgUp +}; diff --git a/keyboard/hhkb/led.c b/keyboard/hhkb/led.c new file mode 100644 index 00000000..8a08fe27 --- /dev/null +++ b/keyboard/hhkb/led.c @@ -0,0 +1,33 @@ +/* +Copyright 2011 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 +#include "stdint.h" +#include "led.h" + + +/* HHKB has no LEDs */ +void led_set(uint8_t usb_led) +{ + if (usb_led & (1< + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "timer.h" +#include "matrix.h" +#include "hhkb_avr.h" +#include +#include "suspend.h" +#include "lufa.h" + + +// matrix power saving +#define MATRIX_POWER_SAVE 10000 +static uint32_t matrix_last_modified = 0; + +// matrix state buffer(1:on, 0:off) +static matrix_row_t *matrix; +static matrix_row_t *matrix_prev; +static matrix_row_t _matrix0[MATRIX_ROWS]; +static matrix_row_t _matrix1[MATRIX_ROWS]; + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ +#ifdef DEBUG + debug_enable = true; + debug_keyboard = true; +#endif + + KEY_INIT(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; + matrix = _matrix0; + matrix_prev = _matrix1; +} + +uint8_t matrix_scan(void) +{ + uint8_t *tmp; + + tmp = matrix_prev; + matrix_prev = matrix; + matrix = tmp; + + // power on + if (!KEY_POWER_STATE()) KEY_POWER_ON(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + KEY_SELECT(row, col); + _delay_us(5); + + // Not sure this is needed. This just emulates HHKB controller's behaviour. + if (matrix_prev[row] & (1< 20/(1000000/TIMER_RAW_FREQ)) { + matrix[row] = matrix_prev[row]; + } + + _delay_us(5); + KEY_PREV_OFF(); + KEY_UNABLE(); + + // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE. + // This takes 25us or more to make sure KEY_STATE returns to idle state. +#ifdef HHKB_JP + // Looks like JP needs faster scan due to its twice larger matrix + // or it can drop keys in fast key typing + _delay_us(30); +#else + _delay_us(75); +#endif + } + if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); + } + // power off + if (KEY_POWER_STATE() && + (USB_DeviceState == DEVICE_STATE_Suspended || + USB_DeviceState == DEVICE_STATE_Unattached ) && + timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) { + KEY_POWER_OFF(); + suspend_power_down(); + } + return 1; +} + +bool matrix_is_modified(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + if (matrix[i] != matrix_prev[i]) + return true; + } + return false; +} + +inline +bool matrix_has_ghost(void) +{ + return false; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & (1< +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/iwrap.mk +# TODO: to be selectable: V-USB, LUFA or PJRC +#include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk diff --git a/keyboard/hhkb/not_supported/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb new file mode 100644 index 00000000..1f8d8468 --- /dev/null +++ b/keyboard/hhkb/not_supported/Makefile.vusb @@ -0,0 +1,97 @@ +# +# Makefile for V-USB +# + + +# Target file name (without extension). +TARGET = hhkb_vusb + +# Directory common source filess exist +TMK_DIR = ../../tmk_core + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# keyboard dependent files +SRC = \ + keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config_vusb.h + + +# V-USB debug level: To use ps2_usart.c level must be 0 +# ps2_usart.c requires USART to receive PS/2 signal. +OPT_DEFS = -DDEBUG_LEVEL=0 + + +# 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 = atmega328p +# avrdude doesn't know atmega168p +AVRDUDE_MCU = $(MCU) + + +# Processor frequency. +# Normally the first thing your program should do is set the clock prescaler, +# so your program will run at the correct speed. You should also set this +# variable to same clock speed. The _delay_ms() macro uses this, and many +# examples use this variable to calculate timings. Do not add a "UL" here. +F_CPU = 12000000 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +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 + + + +#---------------- Programming Options -------------------------- +AVRDUDE = avrdude +# Type: avrdude -c ? to get a full listing. +AVRDUDE_PROGRAMMER = usbasp +AVRDUDE_PORT = +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +#AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(AVRDUDE_MCU) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + +PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) + + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TMK_DIR) + +include $(TMK_DIR)/protocol/vusb.mk +include $(TMK_DIR)/common.mk +include $(TMK_DIR)/rules.mk + +debug-on: EXTRAFLAGS += -DDEBUG +debug-on: all diff --git a/keyboard/hhkb/not_supported/config_iwrap.h b/keyboard/hhkb/not_supported/config_iwrap.h new file mode 100644 index 00000000..747c7551 --- /dev/null +++ b/keyboard/hhkb/not_supported/config_iwrap.h @@ -0,0 +1,54 @@ +/* +Copyright 2011 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xBEEA +// TODO: share these strings with usbconfig.h +// Edit usbconfig.h to change these. +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + + +/* matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + +/* pins for Software UART */ +#define SUART_IN_PIN PINC +#define SUART_IN_BIT 5 +#define SUART_OUT_PORT PORTC +#define SUART_OUT_BIT 4 + + +#define DEBUG_LED 1 +#define DEBUG_LED_CONFIG (DDRD |= (1<<4)) +#define DEBUG_LED_OFF (PORTD |= (1<<4)) +#define DEBUG_LED_ON (PORTD &= ~(1<<4)) + +/* period of tapping(ms) */ +#define TAPPING_TERM 300 +/* tap count needed for toggling a feature */ +#define TAPPING_TOGGLE 5 + +#endif diff --git a/keyboard/hhkb/not_supported/config_vusb.h b/keyboard/hhkb/not_supported/config_vusb.h new file mode 100644 index 00000000..44f7acd6 --- /dev/null +++ b/keyboard/hhkb/not_supported/config_vusb.h @@ -0,0 +1,38 @@ +/* +Copyright 2011 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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0xC0FE +// TODO: share these strings with usbconfig.h +// Edit usbconfig.h to change these. +#define MANUFACTURER t.m.k. +#define PRODUCT HHKB mod +#define DESCRIPTION t.m.k. keyboard firmware for HHKB mod + + +/* matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 8 + + +/* key combination for command */ +#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) + +#endif diff --git a/keyboard/hhkb/not_supported/iwrap.txt b/keyboard/hhkb/not_supported/iwrap.txt new file mode 100644 index 00000000..20a2420a --- /dev/null +++ b/keyboard/hhkb/not_supported/iwrap.txt @@ -0,0 +1,32 @@ + +iWRAP +----- + +---------------+ WT12 + 5V | ATmega168 | 5V/3.3V~~~~ + +-----+---|Vcc,AVCC PC4|---/--->iWRAP(RxD) +USB | C3 | PC5|<--/----iWRAP(TxD) +~~~ | + | | +5V <--BATT + GND | | HHKB + R1 | | ~~~~ +D- <----+-----+--R2-----|INT1 PB2-4|------->ROW(6-8) +D+ <----|---+----R3-----|INT0 PC0-2|------->COL(9-11) + Z1 Z2 | PC3|------->ENABLE(12) +GND<----+---+-----------|GND PB0|<-------KEY(4) + | PB1|------->PREV(5) + | | + GND+-C2--+--|XTAL1 RXD|------->Debug Console + X1 | TXD|<-------Debug Console + GND+-C3--+--|XTAL2 RST|---SW--+GND + +---------------+ + +R1: 1.5K Ohm +R2,R3: 68 Ohm +Z1,Z2: Zener 3.6V +C1,C2: 22pF +C3: 0.1uF +X1: Crystal 12MHz +SW: Push Switch(Optional) +BATT: Li-Po Battery, Battery Charger and Voltage Regulator(5V and 3.3V). + + + diff --git a/keyboard/hhkb/not_supported/usbconfig.h b/keyboard/hhkb/not_supported/usbconfig.h new file mode 100644 index 00000000..c3aad34b --- /dev/null +++ b/keyboard/hhkb/not_supported/usbconfig.h @@ -0,0 +1,388 @@ +/* Name: usbconfig.h + * Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers + * Author: Christian Starkjohann + * Creation Date: 2005-04-01 + * Tabsize: 4 + * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH + * License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt) + * This Revision: $Id: usbconfig-prototype.h 785 2010-05-30 17:57:07Z cs $ + */ + +#ifndef __usbconfig_h_included__ +#define __usbconfig_h_included__ + +#include "config_vusb.h" + +/* +General Description: +This file is an example configuration (with inline documentation) for the USB +driver. It configures V-USB for USB D+ connected to Port D bit 2 (which is +also hardware interrupt 0 on many devices) and USB D- to Port D bit 4. You may +wire the lines to any other port, as long as D+ is also wired to INT0 (or any +other hardware interrupt, as long as it is the highest level interrupt, see +section at the end of this file). +*/ + +/* ---------------------------- Hardware Config ---------------------------- */ + +#define USB_CFG_IOPORTNAME D +/* This is the port where the USB bus is connected. When you configure it to + * "B", the registers PORTB, PINB and DDRB will be used. + */ +#define USB_CFG_DMINUS_BIT 3 +/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected. + * This may be any bit in the port. + */ +#define USB_CFG_DPLUS_BIT 2 +/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected. + * This may be any bit in the port. Please note that D+ must also be connected + * to interrupt pin INT0! [You can also use other interrupts, see section + * "Optional MCU Description" below, or you can connect D- to the interrupt, as + * it is required if you use the USB_COUNT_SOF feature. If you use D- for the + * interrupt, the USB interrupt will also be triggered at Start-Of-Frame + * markers every millisecond.] + */ +#define USB_CFG_CLOCK_KHZ (F_CPU/1000) +/* Clock rate of the AVR in kHz. Legal values are 12000, 12800, 15000, 16000, + * 16500, 18000 and 20000. The 12.8 MHz and 16.5 MHz versions of the code + * require no crystal, they tolerate +/- 1% deviation from the nominal + * frequency. All other rates require a precision of 2000 ppm and thus a + * crystal! + * Since F_CPU should be defined to your actual clock rate anyway, you should + * not need to modify this setting. + */ +#define USB_CFG_CHECK_CRC 0 +/* Define this to 1 if you want that the driver checks integrity of incoming + * data packets (CRC checks). CRC checks cost quite a bit of code size and are + * currently only available for 18 MHz crystal clock. You must choose + * USB_CFG_CLOCK_KHZ = 18000 if you enable this option. + */ + +/* ----------------------- Optional Hardware Config ------------------------ */ + +/* #define USB_CFG_PULLUP_IOPORTNAME D */ +/* If you connect the 1.5k pullup resistor from D- to a port pin instead of + * V+, you can connect and disconnect the device from firmware by calling + * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). + * This constant defines the port on which the pullup resistor is connected. + */ +/* #define USB_CFG_PULLUP_BIT 4 */ +/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined + * above) where the 1.5k pullup resistor is connected. See description + * above for details. + */ + +/* --------------------------- Functional Range ---------------------------- */ + +#define USB_CFG_HAVE_INTRIN_ENDPOINT 1 +/* Define this to 1 if you want to compile a version with two endpoints: The + * default control endpoint 0 and an interrupt-in endpoint (any other endpoint + * number). + */ +#define USB_CFG_HAVE_INTRIN_ENDPOINT3 1 +/* Define this to 1 if you want to compile a version with three endpoints: The + * default control endpoint 0, an interrupt-in endpoint 3 (or the number + * configured below) and a catch-all default interrupt-in endpoint as above. + * You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature. + */ +#define USB_CFG_EP3_NUMBER 3 +/* If the so-called endpoint 3 is used, it can now be configured to any other + * endpoint number (except 0) with this macro. Default if undefined is 3. + */ +/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */ +/* The above macro defines the startup condition for data toggling on the + * interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1. + * Since the token is toggled BEFORE sending any data, the first packet is + * sent with the oposite value of this configuration! + */ +#define USB_CFG_IMPLEMENT_HALT 0 +/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature + * for endpoint 1 (interrupt endpoint). Although you may not need this feature, + * it is required by the standard. We have made it a config option because it + * bloats the code considerably. + */ +#define USB_CFG_SUPPRESS_INTR_CODE 0 +/* Define this to 1 if you want to declare interrupt-in endpoints, but don't + * want to send any data over them. If this macro is defined to 1, functions + * usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if + * you need the interrupt-in endpoints in order to comply to an interface + * (e.g. HID), but never want to send any data. This option saves a couple + * of bytes in flash memory and the transmit buffers in RAM. + */ +#define USB_CFG_INTR_POLL_INTERVAL 10 +/* If you compile a version with endpoint 1 (interrupt-in), this is the poll + * interval. The value is in milliseconds and must not be less than 10 ms for + * low speed devices. + */ +#define USB_CFG_IS_SELF_POWERED 0 +/* Define this to 1 if the device has its own power supply. Set it to 0 if the + * device is powered from the USB bus. + */ +#define USB_CFG_MAX_BUS_POWER 100 +/* Set this variable to the maximum USB bus power consumption of your device. + * The value is in milliamperes. [It will be divided by two since USB + * communicates power requirements in units of 2 mA.] + */ +#define USB_CFG_IMPLEMENT_FN_WRITE 1 +/* Set this to 1 if you want usbFunctionWrite() to be called for control-out + * transfers. Set it to 0 if you don't need it and want to save a couple of + * bytes. + */ +#define USB_CFG_IMPLEMENT_FN_READ 0 +/* Set this to 1 if you need to send control replies which are generated + * "on the fly" when usbFunctionRead() is called. If you only want to send + * data from a static buffer, set it to 0 and return the data from + * usbFunctionSetup(). This saves a couple of bytes. + */ +#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0 +/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints. + * You must implement the function usbFunctionWriteOut() which receives all + * interrupt/bulk data sent to any endpoint other than 0. The endpoint number + * can be found in 'usbRxToken'. + */ +#define USB_CFG_HAVE_FLOWCONTROL 0 +/* Define this to 1 if you want flowcontrol over USB data. See the definition + * of the macros usbDisableAllRequests() and usbEnableAllRequests() in + * usbdrv.h. + */ +#define USB_CFG_DRIVER_FLASH_PAGE 0 +/* If the device has more than 64 kBytes of flash, define this to the 64 k page + * where the driver's constants (descriptors) are located. Or in other words: + * Define this to 1 for boot loaders on the ATMega128. + */ +#define USB_CFG_LONG_TRANSFERS 0 +/* Define this to 1 if you want to send/receive blocks of more than 254 bytes + * in a single control-in or control-out transfer. Note that the capability + * for long transfers increases the driver size. + */ +/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */ +/* This macro is a hook if you want to do unconventional things. If it is + * defined, it's inserted at the beginning of received message processing. + * If you eat the received message and don't want default processing to + * proceed, do a return after doing your things. One possible application + * (besides debugging) is to flash a status LED on each packet. + */ +/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */ +/* This macro is a hook if you need to know when an USB RESET occurs. It has + * one parameter which distinguishes between the start of RESET state and its + * end. + */ +/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */ +/* This macro (if defined) is executed when a USB SET_ADDRESS request was + * received. + */ +#define USB_COUNT_SOF 1 +/* define this macro to 1 if you need the global variable "usbSofCount" which + * counts SOF packets. This feature requires that the hardware interrupt is + * connected to D- instead of D+. + */ +/* #ifdef __ASSEMBLER__ + * macro myAssemblerMacro + * in YL, TCNT0 + * sts timer0Snapshot, YL + * endm + * #endif + * #define USB_SOF_HOOK myAssemblerMacro + * This macro (if defined) is executed in the assembler module when a + * Start Of Frame condition is detected. It is recommended to define it to + * the name of an assembler macro which is defined here as well so that more + * than one assembler instruction can be used. The macro may use the register + * YL and modify SREG. If it lasts longer than a couple of cycles, USB messages + * immediately after an SOF pulse may be lost and must be retried by the host. + * What can you do with this hook? Since the SOF signal occurs exactly every + * 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in + * designs running on the internal RC oscillator. + * Please note that Start Of Frame detection works only if D- is wired to the + * interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES! + */ +#define USB_CFG_CHECK_DATA_TOGGLING 0 +/* define this macro to 1 if you want to filter out duplicate data packets + * sent by the host. Duplicates occur only as a consequence of communication + * errors, when the host does not receive an ACK. Please note that you need to + * implement the filtering yourself in usbFunctionWriteOut() and + * usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable + * for each control- and out-endpoint to check for duplicate packets. + */ +#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0 +/* define this macro to 1 if you want the function usbMeasureFrameLength() + * compiled in. This function can be used to calibrate the AVR's RC oscillator. + */ +#define USB_USE_FAST_CRC 0 +/* The assembler module has two implementations for the CRC algorithm. One is + * faster, the other is smaller. This CRC routine is only used for transmitted + * messages where timing is not critical. The faster routine needs 31 cycles + * per byte while the smaller one needs 61 to 69 cycles. The faster routine + * may be worth the 32 bytes bigger code size if you transmit lots of data and + * run the AVR close to its limit. + */ + +/* -------------------------- Device Description --------------------------- */ + +#define USB_CFG_VENDOR_ID (VENDOR_ID & 0xFF), ((VENDOR_ID >> 8) & 0xFF) +/* USB vendor ID for the device, low byte first. If you have registered your + * own Vendor ID, define it here. Otherwise you may use one of obdev's free + * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_ID (PRODUCT_ID & 0xFF), ((PRODUCT_ID >> 8) & 0xFF) +/* This is the ID of the product, low byte first. It is interpreted in the + * scope of the vendor ID. If you have registered your own VID with usb.org + * or if you have licensed a PID from somebody else, define it here. Otherwise + * you may use one of obdev's free shared VID/PID pairs. See the file + * USB-IDs-for-free.txt for details! + * *** IMPORTANT NOTE *** + * This template uses obdev's shared VID/PID pair for Vendor Class devices + * with libusb: 0x16c0/0x5dc. Use this VID/PID pair ONLY if you understand + * the implications! + */ +#define USB_CFG_DEVICE_VERSION 0x00, 0x01 +/* Version number of the device: Minor number first, then major number. + */ +#define USB_CFG_VENDOR_NAME 't', '.', 'm', '.', 'k', '.' +#define USB_CFG_VENDOR_NAME_LEN 6 +/* These two values define the vendor name returned by the USB device. The name + * must be given as a list of characters under single quotes. The characters + * are interpreted as Unicode (UTF-16) entities. + * If you don't want a vendor name string, undefine these macros. + * ALWAYS define a vendor name containing your Internet domain name if you use + * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for + * details. + */ +#define USB_CFG_DEVICE_NAME 'H', 'H', 'K', 'B', ' ', 'm', 'o', 'd' +#define USB_CFG_DEVICE_NAME_LEN 8 +/* Same as above for the device name. If you don't want a device name, undefine + * the macros. See the file USB-IDs-for-free.txt before you assign a name if + * you use a shared VID/PID. + */ +/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */ +/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */ +/* Same as above for the serial number. If you don't want a serial number, + * undefine the macros. + * It may be useful to provide the serial number through other means than at + * compile time. See the section about descriptor properties below for how + * to fine tune control over USB descriptors such as the string descriptor + * for the serial number. + */ +#define USB_CFG_DEVICE_CLASS 0 +#define USB_CFG_DEVICE_SUBCLASS 0 +/* See USB specification if you want to conform to an existing device class. + * Class 0xff is "vendor specific". + */ +#define USB_CFG_INTERFACE_CLASS 3 /* HID */ +#define USB_CFG_INTERFACE_SUBCLASS 1 /* Boot */ +#define USB_CFG_INTERFACE_PROTOCOL 1 /* Keyboard */ +/* See USB specification if you want to conform to an existing device class or + * protocol. The following classes must be set at interface level: + * HID class is 3, no subclass and protocol required (but may be useful!) + * CDC class is 2, use subclass 2 and protocol 1 for ACM + */ +#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 +/* Define this to the length of the HID report descriptor, if you implement + * an HID device. Otherwise don't define it or define it to 0. + * If you use this define, you must add a PROGMEM character array named + * "usbHidReportDescriptor" to your code which contains the report descriptor. + * Don't forget to keep the array and this define in sync! + */ + +/* #define USB_PUBLIC static */ +/* Use the define above if you #include usbdrv.c instead of linking against it. + * This technique saves a couple of bytes in flash memory. + */ + +/* ------------------- Fine Control over USB Descriptors ------------------- */ +/* If you don't want to use the driver's default USB descriptors, you can + * provide our own. These can be provided as (1) fixed length static data in + * flash memory, (2) fixed length static data in RAM or (3) dynamically at + * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more + * information about this function. + * Descriptor handling is configured through the descriptor's properties. If + * no properties are defined or if they are 0, the default descriptor is used. + * Possible properties are: + * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched + * at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is + * used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if + * you want RAM pointers. + * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found + * in static memory is in RAM, not in flash memory. + * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash), + * the driver must know the descriptor's length. The descriptor itself is + * found at the address of a well known identifier (see below). + * List of static descriptor names (must be declared PROGMEM if in flash): + * char usbDescriptorDevice[]; + * char usbDescriptorConfiguration[]; + * char usbDescriptorHidReport[]; + * char usbDescriptorString0[]; + * int usbDescriptorStringVendor[]; + * int usbDescriptorStringDevice[]; + * int usbDescriptorStringSerialNumber[]; + * Other descriptors can't be provided statically, they must be provided + * dynamically at runtime. + * + * Descriptor properties are or-ed or added together, e.g.: + * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18)) + * + * The following descriptors are defined: + * USB_CFG_DESCR_PROPS_DEVICE + * USB_CFG_DESCR_PROPS_CONFIGURATION + * USB_CFG_DESCR_PROPS_STRINGS + * USB_CFG_DESCR_PROPS_STRING_0 + * USB_CFG_DESCR_PROPS_STRING_VENDOR + * USB_CFG_DESCR_PROPS_STRING_PRODUCT + * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER + * USB_CFG_DESCR_PROPS_HID + * USB_CFG_DESCR_PROPS_HID_REPORT + * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver) + * + * Note about string descriptors: String descriptors are not just strings, they + * are Unicode strings prefixed with a 2 byte header. Example: + * int serialNumberDescriptor[] = { + * USB_STRING_DESCRIPTOR_HEADER(6), + * 'S', 'e', 'r', 'i', 'a', 'l' + * }; + */ + +#define USB_CFG_DESCR_PROPS_DEVICE 0 +#define USB_CFG_DESCR_PROPS_CONFIGURATION USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_CONFIGURATION 0 +#define USB_CFG_DESCR_PROPS_STRINGS 0 +#define USB_CFG_DESCR_PROPS_STRING_0 0 +#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0 +#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0 +#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0 +#define USB_CFG_DESCR_PROPS_HID USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_HID 0 +#define USB_CFG_DESCR_PROPS_HID_REPORT USB_PROP_IS_DYNAMIC +//#define USB_CFG_DESCR_PROPS_HID_REPORT 0 +#define USB_CFG_DESCR_PROPS_UNKNOWN 0 + +/* ----------------------- Optional MCU Description ------------------------ */ + +/* The following configurations have working defaults in usbdrv.h. You + * usually don't need to set them explicitly. Only if you want to run + * the driver on a device which is not yet supported or with a compiler + * which is not fully supported (such as IAR C) or if you use a differnt + * interrupt than INT0, you may have to define some of these. + */ +/* #define USB_INTR_CFG MCUCR */ +/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */ +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE GIMSK */ +/* #define USB_INTR_ENABLE_BIT INT0 */ +/* #define USB_INTR_PENDING GIFR */ +/* #define USB_INTR_PENDING_BIT INTF0 */ +/* #define USB_INTR_VECTOR INT0_vect */ + +/* Set INT1 for D- falling edge to count SOF */ +/* #define USB_INTR_CFG EICRA */ +#define USB_INTR_CFG_SET ((1 << ISC11) | (0 << ISC10)) +/* #define USB_INTR_CFG_CLR 0 */ +/* #define USB_INTR_ENABLE EIMSK */ +#define USB_INTR_ENABLE_BIT INT1 +/* #define USB_INTR_PENDING EIFR */ +#define USB_INTR_PENDING_BIT INTF1 +#define USB_INTR_VECTOR INT1_vect + +#endif /* __usbconfig_h_included__ */ diff --git a/keyboard/hhkb/rn42.mk b/keyboard/hhkb/rn42.mk new file mode 100644 index 00000000..fd6f7db1 --- /dev/null +++ b/keyboard/hhkb/rn42.mk @@ -0,0 +1,12 @@ +RN42_DIR = rn42 + +SRC += serial_uart.c \ + rn42/suart.S \ + rn42/rn42.c \ + rn42/rn42_task.c \ + rn42/battery.c \ + rn42/main.c + +OPT_DEFS += -DPROTOCOL_RN42 + +VPATH += $(RN42_DIR) diff --git a/keyboard/hhkb/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt new file mode 100644 index 00000000..a86c49c4 --- /dev/null +++ b/keyboard/hhkb/rn42/MEMO.txt @@ -0,0 +1,262 @@ +Memo of deveopment +================== +just memo, NOT WORTH READING + +2015/11/24 +JP Bluetooth: + RN-42 cannot send Japanese keys like; henkan, mu-henkan and kana, JPY and RO. + It seems HID usage more than 0x65 cannot be send with the module. + http://shiki.esrille.com/2014/07/bluetoothnisse.html + + +Bug: +- Factory Reset PIO4 doesn't work + - the reason is unclear - 12/08 NOT LOOK INTO ANY MORE + - WORKAROUND: use serial pins(3.3V, GND, RX and TX) + - SF,1 and R,1 to set factory defalult + + +Todo: +- LED cover and switch knob and new Slide Switch +- RN42 auto configuration + - configure the module as HID device every time powering up + - this'll reduce work load of assembly + +- move rn42 to protocol directory when it becomes reusable stack + +- sendchar() in lufa.c no buffer + - no buffering. character lost can be caused. +- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256). + +- BT operations + - disconnect + - new connection + - remove connection + +- sendchar() in lufa.c block loop - DONE 11/29 + - block loop when powered with AC adapter + - FrameNumber is not updated when adapter powered + +Improving: +- ADC resolution + AVR120 + AVR32138 + - Enhancing ADC resolution by oversampling + AVR121 http://www.atmel.com/images/doc8003.pdf + - disable digital input buffer DIDR(7.8.6) + +Design: +- suspend.h - DONE 11/26 + - remove argument from suspend_power_down() for backward compatitibility +- remove MCU dependent power saving code from core/keyboard - DONE 11/23 + - it should be located in project matrix.c +- HHKB matrix.c needs matrix_prev? + - is_modified() is obsolete now. really needs? +- ADC: removing AREF capacitor C10 + - seems to be better while usb powered + - still bad while battery powered + http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc +- ADC: smaller resistors for voltage dividor + - 1K + 1K: not improved. - 11/27 + + +LUFA: +USB connection check: state of USB deivce +- USB_DeviceState: + USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* } + Unattached: unpluged + Powered: pluged with power adapter + Default: enumerate process bigin + Addressed: addressed + Configured: enumerated + Suspended: suspended + +- USB_IsInitialized: state of LUFA core setup + becomes true in USB_Init() USBController_AVR8.c + becomes false in USB_Disable() USBController_AVR8.c +- USB_VBUS_GetStatus(): state of VBUS(power/connection) +- USB_Disable() detaches, disables all interrupts, controller, PLL, regulater. + +- When connect to power adapter + - event happened: CW or CSW or C or DDC + - USB state: not configured + +- USB evnets + - USB connect: CSWRWRW + - USB connect but fail to enumeration: CWRWRWRWS + - USB disconnect: D + - Power adapter connect: CW, CSW, C + - Power adapter disconnect: D + + +Power saving: +- Pro2 current consumption + - active: 138.2mA(no device on Hub) + - suspended: 30.9mA(WakeUp enabled DIPSW6) + - suspended: 0mA->46.0mA(WakeUp disabled DIPSW6) +- Pro current consumption + - active: 54.0mA + - suspended: 40.5mA(WakeUp enabled DIPSW6) + - suspended: 0.3mA(WakeUp disabled DIPSW6) + +- RN42 3.3V + - disconnected(Idle): 5mA (config mode) + - connected(Active): + SW,0000: 23-26mA + SW,0010: 27-29mA worse than 0000 for unknown reason + SW,0020: 17-19mA mouse NG + SW,0030: 13-16mA laggy mouse NG + SW,0050: 10-13mA laggy mouse NG + +- matrix power saving + - power saving while externally powered and not while unpluged +- confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition +- 8MHz clock +- When not connected in a few minutes get into deep sleep to save battery life +- CTS is needed for waking up from deep sleep? How deep sleep is activated? +- firmware controlled 3.3V DC converter to switch on/off BT module +- sleep MCU and BT module(keyboard is not used) +- deep sleep MCU and BT module(keyboard is not used for long time) +- deep sleep MCU and turn off BT module(keyboard is not used and not connected) +- Battery ADC; switching, high resistance + - switching gnd end of divider with PF4 + - high resistor 100K/1M? + capacitor 10nF + http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/ +- During USB suspend change clock source to internal RC from external Xtal(6.8) +- FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3) +- Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13) +- Voltage reference(8.1.1) + - to reduce power consumption while power down mode +- unset ADEN before sleep(24.7) + + + + + + + +Lipo +---- +850mA lasts around 9 hours(07/28) + +Sparkfun Polymer Lithium Ion Battery 850mAh: +https://www.sparkfun.com/products/341 +Lipo Cell spec: +https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf +Protection spec: +http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf + min typical max + over-charge 4.255 4.280 4.305 + over-charge discover? 4.030 4.080 4.130 + over-discharge 2.827 2.900 2.973 + over-discharge discover 3.022 3.100 3.178 + +ADC voltage monitor: voltage divider 10K+10K(0.5) + ADC=V*0.5/2.56*1024 + + V ADC + ------------------ + 4.20 0x347(839) + 3.10 0x26b(619) + + + + +TROUBLE SHOOT +------------- +07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive. + Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before. + +07/18 On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it. + +12/07 rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered. + It resolved with resoldering PF1 and new resistor on R12. + + + + +Done: +- low battery alert(solid light) 09/04 +- *** Rev.E BT test *** - DONE + - with MCP73832, new Schottky, tantalum caps - DONE 12/07 + * MCP73832 doesn't leak from Vcc pin when unpluged and battery powered + 34mV vs 2.07V(MCP73831) at Vcc pin + MCP73832 doesn't need revese protection diode D5 + * PMEG2010ER is very low VF while reverse current/voltage is high + VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175 + Anode of D11 is 680mV vs 20mV(RB160M-30TR) + 780mV is still low < 1.4V VBUS plugin detection(21.11) + this doesn't cause false VBUS detect + and 780mV on MCP73832 Vcc pin is also no problem. + D5 can be removed. + - ADC divider switching - DONE 12/07 + * Drain and Source of Q4 Pch was reversed wrongly on Rev.E. + + - reverse current from Lipo charger - DONE 12/07 + * MCP73832 has no recverse current from Vcc pin unlike MCP73831 + + +- Rev.F design - DONE + - current measure point - DONE 12/08 + - change value of cap 68->47 - DONE 12/08 + - PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08 + - Q4 Pch FET: wrong Drain and Source - DONE 12/08 + - D5 can be removed. - DONE 12/08 + + + +- BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30 +- Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm +- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB +- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done +- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done +- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24 +- LINKED: add trace on PIO2 to PF6 07.24 +- Lipo voltage ADC sensing +- Lipo charger MCP73831: needs capacitor 4.7uF *2 +- USB connection check - 07.01 +- BT on/off check: whether RX line is pulled up? - checking RTS 07.01 +- USB/BT switching BT is on -> BT, BT is off -> USB - 07.01 +- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01 +- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01 +- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04 + +- wrongly suspended when powered from adapter without USB connection - DONE + - suspend event may occur when plug into adapter + - and never wake until conected to real USB line + - without debug print via USB no problem; CSW(wake just after suspend as real USB line) + - seems like USB print causes this problem after suspended + +- lose USB connection during power-down mode - DONE + - USB initialize code in main() causes this - WRONG + - Do not power-down during USB connection is active - DONE 11/11 + (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection + matrix_power_down() matrix.c - 11/23 + +- with Nexus5 keyboard and mouse are very laggy. + Not confirmed. 01/15 + +- switch BT host connections - CANCEL 01/15 + - switch next connection + cannot switch connection with version 6.15 at least + +- When given power only from wall wart adapter - DONE? not confirmed 01/15 + - it sleeps. it should not sleep + - Configured state without USB connection? + +- timer is slow while power down - DONE 11/26 + - time out interrupt is lost while power down? + - interrupt of watchdog timer compensates timer counter(avr/suspend.c) + +- repeated CHARGING/FULL_CHARGED - No longer problem 01/15 + - In LTC sharp pulses are observed. + - MCP has no pulse but still has a problem. + - needs more wait before read pin state? - NO + +- USB plug-in fails while BT - No longer problem 01/15 + - it ends in suspend state + - maybe, not responsive to host enumeration process due to power-down. + - matrix_power_down() only when state is unattached - 11/26 + - need to observe a while + diff --git a/keyboard/hhkb/rn42/PowerSave.txt b/keyboard/hhkb/rn42/PowerSave.txt new file mode 100644 index 00000000..4b9c8f41 --- /dev/null +++ b/keyboard/hhkb/rn42/PowerSave.txt @@ -0,0 +1,88 @@ +Power Saving +============ + + +MCU+HHKB Power Comsumption +-------------------------- +Battery drive: + idle 18.9mA + active 35.8mA + +USB powered: + 40.0mA + 52mA 01/17 + +Other keyboards: +HHKB Pro 55mA +HHKB Pro2 140mA +HHKB Pro 42mA(Alt) +HHKB Pro2 52mA(Alt BT controller USB mode) +HHKB Pro2 88mA(Alt BT controller BT mode connected) +HHKB Pro2 68mA(Alt BT controller BT mode config mode) +Poker X 6mA +Infinity 24mA(TMK) + 65mA(kiibohd) + + +HHKB key switch power control +----------------------------- +MOS FET Nch: BSS138 or IRLML6344T, either works and no apparent difference. +Normally on(pull-up) or off(pull-down)? interms of power saving it prefers pull-down? + +Pull-down will be better for power saving, normally off. + + + +Used Timer +---------- + +8MHz clock +---------- +1) 16MHz xtal with system prescaler div2: F_CPU=8MHz, F_USB=16MHz +2) 8MHz xtal with div1: F_CPU=8MHz, F_USB=8MHz +Hardware USART doesn't work at 115200bps with 8MHz(F_CPU). + +workaround: +a) use Sotwre serial for communcation with RN-42 +b) reduce baud of RN-42 to lower rate;(factory default is 115200bps) +10/03 + + + +Slave mode +---------- +Discovery/Inquire +Connect/Page + +SI,0012 +SJ,0012 +InqWindw=0100 +PagWindw=0100 + + +Sniff mode +---------- +0.625ms * +SW,0320 Very sluggish. Type is not lost but very slow to register. +SW,0160 Still sluggish. may transposed? can type but ... + Mouse point move intermittently +SW,0020 feel a bit late like stumble(20ms) +SW,0010 feel no latency(10ms) + + +Deep sleep +---------- +SW,8010 + + +TX power +-------- +SY,fff4 + + +IO pins +------- +S%,1000 status led and connection control don't work + GPIO5: status LED + GPIO6: Connection control + GPIO2: linked status diff --git a/keyboard/hhkb/rn42/RN42.txt b/keyboard/hhkb/rn42/RN42.txt new file mode 100644 index 00000000..64c3fdd4 --- /dev/null +++ b/keyboard/hhkb/rn42/RN42.txt @@ -0,0 +1,408 @@ +RN-42 Bluetooth Module Support +============================== +Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board. + + +RN-42: +http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42 + + +Capabitlities: +- USB keyboard functions + completely equivarent to USB controller including mouse keys and NKRO. +- Switching between USB and Bluetooth + You can switch the two connections with BT switch or key combination. +- RN-42 config mode + You can change power/connection configuration of the module if needed. +- Low battery alert + Red LED turns on when low voltage. +- RN-42 status indicator + LED indicates status of Bluetooth connection. +- Pairing + The module stores up to 8 connections. +- Auto connect + The module connects the last connected device automatically. +- iOS support + works as keyboard with iPhone5. No tested completely. +- Android support + works as keyboard and mouse with Nexus5. No tested completely. +- Mouse keys over BT + Note that iOS doesn't accept mouse device. + + +Limitations: +- Short battery life + Around 12hr with 1000mAh +- No connection switching + RN-42 auto-connects to the last connected device. + Some of consumer products can switch between devices, for example Logitech K480. + http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26 +- HHKB JP requires case modification for BT switch and LEDs. + without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled. + +NOTE: +- LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY. +- RN-42 version 6.15 is supported. +- No NKRO over Bluetooth +- Check you country's wiress regulation and certification of RN-42. + +Bugs: + +Todos: + + +Lipo Battery +------------ +You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit. +Battery space inside HHKB is around 54mm x 50mm and its height is 7mm. + +Sparkfun 850mAh +https://www.sparkfun.com/products/341 +Sparkfun 1000mAh +https://www.sparkfun.com/products/339 + +Sparkfun 2000mAh battery won't fit due to its size. + +Learn about Lipo battery: +https://learn.adafruit.com/li-ion-and-lipoly-batteries + + + + + +LED Status +---------- +Configuring 10 times per sec +Startup/configuration timer 2 times per sec +Discoverable/Inquiring/Idle once per sec +Connected solid on + + +RN-42 Magic Command +-------------------- +Magic key combination is 'LShift+RShift' by default in case of HHKB. + +Here is help. + + ----- Bluetooth RN-42 Help ----- + i: RN-42 info + b: battery voltage + Del: enter/exit RN-42 config mode + Slck: RN-42 initialize + p: pairing + u: toggle Force USB mode + + RN-42 info: displays information of the module on console. + battery voltage: displays current voltage of battery and uptime. + RN-42 initialize: does factory reset and configures RN-42 + pairing: enters Pairing mode. + toggle Force USB mode: switch between USB and Bluetooth + + +RN-42 Config mode +----------------- +You can tune/operate RN-42 yourself with config(command) mode. + +1. hook up USB cable +2. run `hid_listen` command in console +3. turn on Bluetooth switch +4. press LShift+RShift+Delete(Fn+~) you will see output like followings: + + Entering config mode ... + CMD + v + Ver 6.15 04/26/2013 + (c) Roving Networks + +5. do config with RN-42 commands. See documentations of RN-42. +6. to exit also press LShift+RShift+Delete(Fn+~) + + Exiting config mode ... + --- + END + + +RN-42 Initial Configuration +--------------------------- +RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time. + +1. hook up USB cable +2. run `hid_listen` command in console +3. turn on Bluetooth switch +4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings: + + Entering config mode ... + CMD + Ver 6.15 04/26/2013 + (c) Roving Networks + ECHO ON + SF,1 + AOK + S-,TmkBT + AOK + SS,Keyboard/Mouse + AOK + SM,4 + AOK + SW,8000 + AOK + S~,6 + AOK + SH,003C + AOK + SY,FFF4 + AOK + R,1 + Reboot! + Exiting config mode ... + +5. output of command 'X' after cofiguration + + Ver 6.15 04/26/2013 + (c) Roving Networks + ***Settings*** + BTA=00066667BBE9 + BTName=TmkBT-BBE9 + Baudrt(SW4)=115K + Mode =DTR + Authen=1 + PinCod=1234 + Bonded=0 + Rem=NONE SET + ***ADVANCED Settings*** + SrvName= Keyboard/Mouse + SrvClass=0000 + DevClass=1F00 + InqWindw=0100 + PagWindw=0100 + CfgTimer=255 + StatuStr=NULL + HidFlags=3c + DTRtimer=8 + KeySwapr=0 + ***OTHER Settings*** + Profile= HID + CfgChar= $ + SniffEna=8000 + LowPower=0 + TX Power=fff4 + IOPorts= 0 + IOValues=0 + Sleeptmr=0 + DebugMod=0 + RoleSwch=0 + + +Switch to USB mode +------------------ +You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'. + + +Pairing mode +------------ +This disconnects current connect and enter pairing mode. + + + + +For deveropment +=============== + +RN-42 Serial Connection +----------------------- +UART: 115200bps, 8bit, 1-stopbit, non-parity, no flow control +SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth) + +To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END'). + + +RN-42 Commands +-------------- +S-,tmkBT // Device name +SS,keyboard/mouse // service name +SM,4 // Auto Connect DTR mode +SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save +S~,6 // HID profile +S~,0 // SPP profile +SH,003C // HID register +SY,0004 // Transmit power +SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc) +SD,05C0 // bit 12-8 7 6 5-0 + // 00101 1 1 0 + // peripheral pointing keybaord joystick, gamepad, ... +SM,6 // Pairing mode: auto connect +SM,4 // Master mode: Connection can be controled with GPIO6 +SF,1 // Factroy reset +R,1 // reboot +SR,Z // removes all remote addresses for reconnecting. + // can be used to connect another host +SR,I // registers last inquiry address + + +Operation Modes +--------------- +SM,3 Auto Connect Master mode +SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR) + confirm: auto connect works and control connection with GPIO6 +SM,5 Auto Connect ANY Mode (Mode =ANY) + each time GPIO is set, make inquiry and connect to the first found device +SM,6 automatically reconnect(Mode =Pair) + confirm: auto connect works well but difficult to enter command mode. + + +HID flag register +----------------- +SH,0200 +GH + +10 0000 0000(0200) default +00 0011 1000(0038) Combo +|| | | |\_\____ number of paired devices to which the module can reconnect +|| | | \_______ send out reports over UART (0xFF ) +|| \__\_________ descriptor type +|\______________ toggle virtual keyboard on iOS when first connected +\_______________ Force HID mode if GPIO11 is high on power-up + + Descriptor type: + 0000: keybaord + 0001: Game Pad + 0010: Mouse + 0011: Combo + 0100: Joystick + 1xxx: reserved + + +Out report - Indicator +---------------------- +0xFE 0x02 0x01 + + +Apple iOS +--------- +Keyboard can be used with iPhone, but mouse cannot. + + +Android +------- +3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds. + + +Power Management +---------------- +Inquiry and Page window Idle or Active (3.1.1) + Downside: delay in discovery or connection time + SI, // set inquiry scan window(discovery) on/off duty? + SJ, // set page scan window(connection) + This reduces averaege power >20mA to 5mA(3mA in Sniff mode) + +Sniff mode Transmit + Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA) + In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA) + SW, // set interval timer(*0.625ms) 0000-7FFF + +Deep sleep Idle (3.1.2) + In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer. + SW,8320 // deep sleep enable(interval=0x320*0.625=500ms) + In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second. + To wake from deep sleep there are three ways: (in worst case wake up takes 5ms) + *send a charactor to the UART(first charactor will be lost) + *toggle CTS low to high and wait 5ms + *wake automatically every slot time(*0.625ms) + Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again. + Downside: latency and data loss + +Disable Output driver Idle or Active (3.1.3) + S%,1000 // set all GPIO pins(0-11) to inputs. + +Lower Transmit Power Idle or Active (3.1.4) + SY, // transmit power setting(takes effect after a power cycle and reboot) + Downside: reducing effective range + + +Optimizig for Latency +--------------------- +By default the firmware is optimized for throughput. +SQ,16 // set latency bit +SQ,0 // unset latency bit + + +Configuration timer settings +---------------------------- +Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?). + +The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.) + ST,0 // no remote, no local when connected + ST,<1-252> // local and remote with timeout in seconds from power up + ST,253 // local only without timeout + ST,254 // remote only without timeout + ST,255 // local and remote without timeout + + +Commands +-------- +S7, 7bit mode +SA, Authenticaiton +SB, Send break +SC, Service class +SD, Device class +SM, Operation mode +SP, Pin code(alpahnumeric) +SQ, Special configuration(GPIO, discovery mode, low latency, reboot, UART) +SR, Store remote address +SR,Z Erase all address +SS, Set service name(1-20)** +ST, Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer) +SU, UART baud rate +SW, low-power sniff mode** deep sleep and wake up every 625us * +SX,<0|1> bonding enable only acceps device that matches the stored address +SY, power setting** +SZ, non-standard raw baud rate =baud*0.004096 +S~, Profile 0:SPP, 5:APL, 6:HID +S-, Device name -15 alphanumeric charactors +S?,<0|1> role switch enable +S$, command mode char +$|, low-power connect mode deep sleep/active(discoverable and connectable) cycle +D display basic setting +E display extended setting +GB display the device's Bluetooth address +GF display Bluetooth address of connected device +GK show connection status +GR show remote address for reconnecting +G& show GPIO pin +G show stored setting ++ toggle local echo on/off +& show GPIO 3,4,6,7(DIP switch) +C connect to stored remote address +C,
connect last address +CFI connect and go into fast data mode +CFR connect and go into fast data mode +CT,
, connect to the address and disconnect after val? +F,1 fast data mod: +H display help +I,