Browse Source

Merge remote-tracking branch 'upstream/master'

master
Kai Ryu 7 years ago
parent
commit
55c3937ca0
100 changed files with 3262 additions and 3140 deletions
  1. 1
    0
      .gitignore
  2. 9
    6
      README.md
  3. 27
    0
      converter/adb_usb/MEMO.txt
  4. 6
    4
      converter/adb_usb/Makefile
  5. 0
    73
      converter/adb_usb/Makefile.pjrc
  6. 143
    0
      converter/adb_usb/Makefile.rev1
  7. 143
    0
      converter/adb_usb/Makefile.teensy
  8. 27
    14
      converter/adb_usb/README.md
  9. 1
    1
      converter/adb_usb/keymap_ansi.c
  10. 100
    15
      converter/adb_usb/keymap_common.h
  11. 1
    1
      converter/adb_usb/keymap_iso.c
  12. 42
    0
      converter/adb_usb/keymap_plain.c
  13. 1
    1
      converter/adb_usb/led.c
  14. 147
    13
      converter/adb_usb/matrix.c
  15. 2
    2
      converter/ibm4704_usb/Makefile
  16. 5
    0
      converter/ibm4704_usb/Makefile.tmk_rev1
  17. 6
    0
      converter/ibm4704_usb/Makefile.tmk_rev2
  18. 21
    5
      converter/ibm4704_usb/README.md
  19. 7
    3
      converter/ibm4704_usb/ibm4704.txt
  20. 50
    0
      converter/ibm4704_usb/keymap_alps102key.c
  21. 27
    0
      converter/ibm4704_usb/keymap_common.h
  22. 4
    3
      converter/ibm4704_usb/matrix.c
  23. 32
    9
      converter/m0110_usb/Makefile.tmk_rev1
  24. 96
    0
      converter/m0110_usb/Makefile.tmk_rev2
  25. 4
    7
      converter/m0110_usb/README.md
  26. 48
    58
      converter/m0110_usb/keymap_common.h
  27. 62
    10
      converter/m0110_usb/keymap_default.c
  28. 0
    118
      converter/m0110_usb/keymap_for_editor.c
  29. 8
    20
      converter/m0110_usb/keymap_intl.c
  30. 0
    64
      converter/m0110_usb/keymap_plain.c
  31. 6
    0
      converter/m0110_usb/matrix.c
  32. 93
    0
      converter/news_usb/Makefile
  33. 2
    1
      converter/news_usb/Makefile.pjrc
  34. 63
    0
      converter/news_usb/config.h
  35. 1
    1
      converter/news_usb/config_pjrc.h
  36. 2
    2
      converter/next_usb/Makefile
  37. 10
    8
      converter/next_usb/config.h
  38. 1
    1
      converter/next_usb/keymap.c
  39. 6
    1
      converter/next_usb/led.c
  40. 4
    2
      converter/next_usb/matrix.c
  41. 3
    6
      converter/ps2_usb/Makefile.mbed
  42. 7
    6
      converter/ps2_usb/Makefile.vusb
  43. 23
    0
      converter/ps2_usb/config.h
  44. 9
    2
      converter/sun_usb/Makefile
  45. 3
    1
      converter/sun_usb/README
  46. 30
    23
      converter/sun_usb/command_extra.c
  47. 83
    46
      converter/sun_usb/config.h
  48. 2
    0
      converter/sun_usb/led.c
  49. 34
    10
      converter/sun_usb/matrix.c
  50. 0
    1
      converter/usb_usb/Makefile
  51. 5
    0
      converter/usb_usb/Makefile.keymap_editor
  52. 2
    2
      converter/usb_usb/config.h
  53. 55
    48
      converter/usb_usb/keymap.c
  54. 175
    39
      converter/usb_usb/keymap_common.h
  55. 88
    0
      converter/usb_usb/keymap_editor.c
  56. 36
    0
      converter/usb_usb/keymap_iso.c
  57. 36
    0
      converter/usb_usb/keymap_jis.c
  58. 34
    30
      converter/usb_usb/keymap_spacefn.c
  59. 22
    22
      converter/usb_usb/main.cpp
  60. 13
    13
      converter/usb_usb/matrix.c
  61. 29
    7
      converter/x68k_usb/Makefile
  62. 2
    4
      converter/x68k_usb/config.h
  63. 25
    32
      converter/x68k_usb/keymap.c
  64. 103
    0
      converter/xt_usb/Makefile
  65. 36
    0
      converter/xt_usb/README.md
  66. 71
    0
      converter/xt_usb/config.h
  67. 31
    0
      converter/xt_usb/keymap_common.c
  68. 144
    0
      converter/xt_usb/keymap_common.h
  69. 34
    0
      converter/xt_usb/keymap_jis.c
  70. 32
    0
      converter/xt_usb/keymap_plain.c
  71. 61
    0
      converter/xt_usb/keymap_spacefn.c
  72. 20
    0
      converter/xt_usb/led.c
  73. 333
    0
      converter/xt_usb/matrix.c
  74. 0
    339
      doc/COPYING.GPLv2
  75. 0
    674
      doc/COPYING.GPLv3
  76. 0
    40
      doc/FUSE.txt
  77. 0
    62
      doc/POWER.txt
  78. 0
    160
      doc/USB_NKRO.txt
  79. 0
    187
      doc/build.md
  80. 0
    261
      doc/keycode.txt
  81. 0
    593
      doc/keymap.md
  82. 0
    62
      doc/other_projects.md
  83. 15
    8
      keyboard/alps64/Makefile
  84. 5
    0
      keyboard/alps64/Makefile.keymap_editor
  85. 54
    0
      keyboard/alps64/actionmap_common.h
  86. 149
    0
      keyboard/alps64/actionmap_hasu.c
  87. 52
    0
      keyboard/alps64/actionmap_plain.c
  88. 2
    2
      keyboard/alps64/config.h
  89. 3
    3
      keyboard/alps64/keymap_common.h
  90. 66
    0
      keyboard/alps64/keymap_editor.c
  91. 29
    8
      keyboard/alps64/keymap_plain.c
  92. 11
    1
      keyboard/alps64/matrix.c
  93. 5
    0
      keyboard/hhkb/Makefile.keymap_editor
  94. 2
    2
      keyboard/hhkb/Makefile.rn42
  95. 3
    0
      keyboard/hhkb/Makefile.rn42.jp
  96. 5
    0
      keyboard/hhkb/Makefile.rn42.keymap_editor
  97. 2
    2
      keyboard/hhkb/README.md
  98. 1
    1
      keyboard/hhkb/config_rn42.h
  99. 69
    0
      keyboard/hhkb/doc/HHKB_keycodes.txt
  100. 0
    0
      keyboard/hhkb/keymap_hhkb.c

+ 1
- 0
.gitignore View File

@@ -11,3 +11,4 @@ tags
*~
build/
*.bak
.DS_Store

+ 9
- 6
README.md View File

@@ -7,6 +7,9 @@ Source code is available here: <http://github.com/tmk/tmk_keyboard>

Updates
-------
#### 2016/02/10
core: flabbergast's Chibios protocol was merged from <https://github.com/flabbergast/tmk_keyboard/tree/chibios> (@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
Core library was separated to other branch `core`. <https://github.com/tmk/tmk_keyboard/tree/core>

@@ -71,7 +74,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
* [Lightpad](keyboard/lightpad) - Korean custom keypad
* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]

### Extenal projects using tmk_keyboard
### External projects using tmk_keyboard
* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org]
* [mcdox][mcdox_tmk] - [mcdox][mcdox]

@@ -114,13 +117,13 @@ Third party libraries like LUFA, PJRC and V-USB have their own license respectiv

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 [doc/keymap.md](doc/keymap.md).
See [tmk_core/doc/keymap.md](tmk_core/doc/keymap.md).



@@ -226,10 +229,10 @@ You can use xprintf() to display debug info on `hid_listen`, see `tmk_core/commo
Files and Directories
-------------------
### Top
* tmk_core/ - core library
* keyboard/ - keyboard projects
* converter/ - protocol converter projects
* doc/ - documents
* tmk_core/ - core library
* tmk_core/doc/ - documents



@@ -241,4 +244,4 @@ Coding Style

Other Keyboard Firmware Projects
------------------
You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md).
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.

+ 27
- 0
converter/adb_usb/MEMO.txt View File

@@ -0,0 +1,27 @@
ADB keyboard handle id
======================
0x01 Apple Standard keyboard M0116 ANSI
0x01 Apple Desktop Bus keyboard 658-4081 ANSI
0x02 Apple Extended Keyboard M0115 ANSI
0x02 Apple Extended Keyboard II M3501 ANSI
0x03 Logical id for Extended Protocol
0x10 Apple Adjustable keyboard M1242 ANSI


Adjustable Keyboard media key
=============================
Media key part has different address than the main keyboard(0x02).

Device Address: 0x07(Appliances/Misc devices)
Handler ID: 0x02

Scan Codes
----------
Media key ADB Code Code in Matix
-----------------------------------------
Volume Up: 0x03 0x48
Volume Down: 0x02 0x49
Mute: 0x01 0x4a
Mic: 0x00 0x42

As for these keys raw ADB codes are translate into logical codes in matrix.

+ 6
- 4
converter/adb_usb/Makefile View File

@@ -56,15 +56,17 @@ SRC = keymap_common.c \
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_ansi.c $(SRC)
SRC := keymap_plain.c $(SRC)
endif

CONFIG_H = config.h


# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# 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
@@ -106,7 +108,7 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in *bytes*
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# Atmel DFU loader 4096 for TMK Converter rev.1/rev.2
# LUFA bootloader 4096
# USBaspLoader 2048
OPT_DEFS += -DBOOTLOADER_SIZE=4096

+ 0
- 73
converter/adb_usb/Makefile.pjrc View File

@@ -1,73 +0,0 @@
# Target file name (without extension).
TARGET = adb_usb_pjrc

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# keyboard dependent 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, 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


# 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


# 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(+5000)
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)
ADB_MOUSE_ENABLE = yes

# ADB Mice need acceleration for todays much bigger screens.
OPT_DEFS += -DADB_MOUSE_MAXACC=8


# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/protocol.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

+ 143
- 0
converter/adb_usb/Makefile.rev1 View File

@@ -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

+ 143
- 0
converter/adb_usb/Makefile.teensy View File

@@ -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

+ 27
- 14
converter/adb_usb/README.md View File

@@ -1,11 +1,11 @@
ADB to USB keyboard converter
=============================
This firmware converts ADB keyboard protocol to USB.
You can use PJRC Teensy for this converter, though, other USB AVR(ATMega32U4, AT90USB64/128 or etc) should work.
But binary size is about 10KB or more it doesn't fit into 8K flash like ATMega8U2.
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
@@ -54,22 +54,30 @@ Define following macros for ADB connection in config.h if you use other than por
ADB_PORT, ADB_PIN, ADB_DDR, ADB_DATA_BIT


Build
-----
See doc/build.md. In short,
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.

$ make clean
$ make
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**.

You can select keymap(ansi is default) like this:
To program Teensy you can use `teensy` target:

$ make -f Makefile.teensy [KEYMAP=(plain|ansi|iso|hasu)] teensy

$ make KEYMAP=[ansi|iso|hasu]


Keymap
------
You can change a keymap by editing code of keymap_[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 for more detail.
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
@@ -85,6 +93,12 @@ https://github.com/tmk/tmk_keyboard/blob/master/README.md#mechanical-locking-sup
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,
@@ -95,8 +109,7 @@ 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 need to use ISO keymap with `make KEYMAP=iso`. With ANSI
keymap you will suffer from swapped keys problem.
If keyboard has ISO layout you may have swapped keys problem, see this for the detail.

https://github.com/tmk/tmk_keyboard/issues/35


+ 1
- 1
converter/adb_usb/keymap_ansi.c View File

@@ -4,7 +4,7 @@
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,PEQL,PSLS,PAST,
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,

+ 100
- 15
converter/adb_usb/keymap_common.h View File

@@ -33,6 +33,49 @@ 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| |VDn|VUp|Mut|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 |App |Opt |Ctrl | |Lef|Dow|Rig| | 0| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
*/
#define KEYMAP( \
K35, K7A,K78,K63,K76, K60,K61,K62,K64, K65,K6D,K67,K6F, K69,K6B,K71, K49,K48,K4A,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, K42,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_##K42, KC_##K43, KC_F18, KC_##K45, KC_NO, KC_##K47 }, \
{ KC_##K48, KC_##K49, KC_##K4A, 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_JYEN, KC_RO, KC_PCMM }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_HANJ, KC_##K67 }, \
{ KC_HAEN, 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|
@@ -121,21 +164,21 @@ extern const uint16_t fn_actions[];


/* 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 | . | |
* +---------------------------------------------------------+ +-------+---+---+
*/
* +-------+
* | 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, \
@@ -162,6 +205,48 @@ extern const uint16_t fn_actions[];
{ 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



+ 1
- 1
converter/adb_usb/keymap_iso.c View File

@@ -4,7 +4,7 @@
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,PEQL,PSLS,PAST,
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,

+ 42
- 0
converter/adb_usb/keymap_plain.c View File

@@ -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, VOLD,VOLU,MUTE,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, APP, 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, VOLD,VOLU,MUTE,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,LALT,LGUI, SPC, APP, RALT,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),
};

+ 1
- 1
converter/adb_usb/led.c View File

@@ -23,5 +23,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

void led_set(uint8_t usb_led)
{
adb_host_kbd_led(~usb_led);
adb_host_kbd_led(ADB_ADDR_KEYBOARD, ~usb_led);
}

+ 147
- 13
converter/adb_usb/matrix.c View File

@@ -39,6 +39,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#endif


static bool has_media_keys = false;
static bool is_iso_layout = false;
static bool is_modified = false;
static report_mouse_t mouse_report = {};

@@ -69,14 +71,58 @@ uint8_t matrix_cols(void)

void matrix_init(void)
{
// LED on
DDRD |= (1<<6); PORTD |= (1<<6);

adb_host_init();
// wait for keyboard to boot up and receive command
_delay_ms(1000);
_delay_ms(2000);

// device scan
xprintf("Before init:\n");
for (uint8_t addr = 1; addr < 16; addr++) {
uint16_t reg3 = adb_host_talk(addr, ADB_REG_3);
if (reg3) {
xprintf("Scan: addr:%d, reg3:%04X\n", addr, reg3);
}
_delay_ms(20);
}

// Determine ISO keyboard by handler id
// http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c?v=4.4#L815
uint16_t handler_id = adb_host_talk(ADB_ADDR_KEYBOARD, ADB_REG_3);
switch (handler_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;
}

// Adjustable keyboard media keys: address=0x07 and handlerID=0x02
has_media_keys = (0x02 == (adb_host_talk(ADB_ADDR_APPLIANCE, ADB_REG_3) & 0xff));
if (has_media_keys) {
xprintf("Found: media keys\n");
}

// 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);
// Listen Register3
// upper byte: reserved bits 0000, keyboard address 0010
// lower byte: device handler 00000011
adb_host_listen(ADB_ADDR_KEYBOARD, ADB_REG_3, ADB_ADDR_KEYBOARD, ADB_HANDLER_EXTENDED_PROTOCOL);

// device scan
xprintf("After init:\n");
for (uint8_t addr = 1; addr < 16; addr++) {
uint16_t reg3 = adb_host_talk(addr, ADB_REG_3);
if (reg3) {
xprintf("Scan: addr:%d, reg3:%04X\n", addr, reg3);
}
_delay_ms(20);
}

// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
@@ -86,6 +132,9 @@ void matrix_init(void)
//debug_keyboard = true;
//debug_mouse = true;
print("debug enabled.\n");

// LED off
DDRD |= (1<<6); PORTD &= ~(1<<6);
return;
}

@@ -100,10 +149,10 @@ void adb_mouse_task(void)
{
uint16_t codes;
int16_t x, y;
static int8_t mouseacc;
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 nothing received reset mouse acceleration, and quit.
if (!codes) {
mouseacc = 1;
return;
@@ -113,12 +162,12 @@ void adb_mouse_task(void)
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.
// 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.
// 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))
@@ -126,7 +175,7 @@ void adb_mouse_task(void)
// 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.
// 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);
@@ -139,7 +188,7 @@ void adb_mouse_task(void)
print_decs(mouse_report.x); print(" ");
print_decs(mouse_report.y); print("]\n");
}
// Send result by usb.
// Send result by usb.
host_mouse_send(&mouse_report);
// increase acceleration of mouse
mouseacc += ( mouseacc < ADB_MOUSE_MAXACC ? 1 : 0 );
@@ -167,7 +216,50 @@ uint8_t matrix_scan(void)
if ( codes == 0xFFFF )
{
_delay_ms(12); // delay for preventing overload of poor ADB keyboard controller
codes = adb_host_kbd_recv();
codes = adb_host_kbd_recv(ADB_ADDR_KEYBOARD);

// Adjustable keybaord media keys
if (codes == 0 && has_media_keys &&
(codes = adb_host_kbd_recv(ADB_ADDR_APPLIANCE))) {
// key1
switch (codes & 0x7f ) {
case 0x00: // Mic
codes = (codes & ~0x007f) | 0x42;
break;
case 0x01: // Mute
codes = (codes & ~0x007f) | 0x4a;
break;
case 0x02: // Volume down
codes = (codes & ~0x007f) | 0x49;
break;
case 0x03: // Volume Up
codes = (codes & ~0x007f) | 0x48;
break;
case 0x7F: // no code
break;
default:
xprintf("ERROR: media key1\n");
return 0x11;
}
// key0
switch ((codes >> 8) & 0x7f ) {
case 0x00: // Mic
codes = (codes & ~0x7f00) | (0x42 << 8);
break;
case 0x01: // Mute
codes = (codes & ~0x7f00) | (0x4a << 8);
break;
case 0x02: // Volume down
codes = (codes & ~0x7f00) | (0x49 << 8);
break;
case 0x03: // Volume Up
codes = (codes & ~0x7f00) | (0x48 << 8);
break;
default:
xprintf("ERROR: media key0\n");
return 0x10;
}
}
}
key0 = codes>>8;
key1 = codes&0xFF;
@@ -184,8 +276,50 @@ uint8_t matrix_scan(void)
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
* https://github.com/tmk/tmk_keyboard/issues/35
*
* 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 & 0x7F) == 0x32) {
key0 = (key0 & 0x80) | 0x0A;
} else if ((key0 & 0x7F) == 0x0A) {
key0 = (key0 & 0x80) | 0x32;
}
}
register_key(key0);
if (key1 != 0xFF) // key1 is 0xFF when no second key.
extra_key = key1<<8 | 0xFF; // process in a separate call

+ 2
- 2
converter/ibm4704_usb/Makefile View File

@@ -23,8 +23,8 @@ CONFIG_H = config.h


# MCU name
#MCU = at90usb1287
MCU = atmega32u4
# TMK Converter rev.2
MCU ?= atmega32u2

# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the

+ 5
- 0
converter/ibm4704_usb/Makefile.tmk_rev1 View File

@@ -0,0 +1,5 @@
# TMK Converter rev.1
# which looks like this:
# https://github.com/tmk/keyboard_converter#pcb-rev1
MCU = atmega32u4
include Makefile

+ 6
- 0
converter/ibm4704_usb/Makefile.tmk_rev2 View File

@@ -0,0 +1,6 @@
# TMK Converter rev.2
# which looks like this:
# https://github.com/tmk/keyboard_converter#pcb-rev2
MCU = atmega32u2
include Makefile


+ 21
- 5
converter/ibm4704_usb/README.md View File

@@ -7,8 +7,9 @@ Keyboard initialization process takes a few seconds at start up. During that you

Update
------
2015/05/05 Added keymaps for 107-key, 77-key and 50-key. Thanks, orihalcon @ geekhack!
2015/05/19 Fixed a protocol handling bug.
- 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.



@@ -46,24 +47,39 @@ Keyboard Plug from front:

Connection
----------
In case of using ATMega32U4(Teensy2.0):
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
$ make -f <makefile>

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 KEYMAP=[plain|...]
$ make -f <makefile> 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_<name>.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.

+ 7
- 3
converter/ibm4704_usb/ibm4704.txt View File

@@ -152,12 +152,16 @@ Keyobard sends these bytes to host.
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:

@@ -166,8 +170,8 @@ Data sent from host:
| `-----`--- scan code
`------------- enable bit(0: enable repeat, 1: enable break)

00-79 Enable repeat
80-F9 Enable break(FA-FF are used as other commands, see above.)
00-7B? Enable repeat
80-FB? Enable break
FE Resend(011ah) no need to use
FF End(0114h) exits FC command mode.

@@ -178,5 +182,5 @@ Response from keyboard:
Examples:
To enable break code of all keys.

FC 80 81 ... F7 FF
FC 80 81 ... FB FF


+ 50
- 0
converter/ibm4704_usb/keymap_alps102key.c View File

@@ -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),
};

+ 27
- 0
converter/ibm4704_usb/keymap_common.h View File

@@ -116,4 +116,31 @@ extern const uint16_t fn_actions[];
{ 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

+ 4
- 3
converter/ibm4704_usb/matrix.c View File

@@ -68,8 +68,9 @@ uint8_t matrix_cols(void)
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 < 0x7A; code++) {
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
@@ -105,8 +106,8 @@ uint8_t matrix_scan(void)
if (code==0xFF) {
// Not receivd
return 0;
} else if ((code&0x7F) >= 0x7A) {
// 0xFF-FA and 0x7F-7A is not scancode
} else if ((code&0x7F) >= 0x7C) {
// 0xFF-FC and 0x7F-7C is not scancode
xprintf("Error: %02X\n", code);
matrix_clear();
return 0;

converter/m0110_usb/Makefile.pjrc → converter/m0110_usb/Makefile.tmk_rev1 View File

@@ -1,5 +1,5 @@
# Target file name (without extension).
TARGET = m0110_pjrc
TARGET = m0110_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core
@@ -10,13 +10,14 @@ TARGET_DIR = .
# keyboard dependent files
SRC = matrix.c \
led.c \
keymap_common.c \
m0110.c

# To use own keymap file run make like: make keymap=hasu
ifdef keymap
SRC += keymap_$(keymap).c
ifdef KEYMAP
SRC += keymap_$(KEYMAP).c
else
SRC += keymap.c
SRC += keymap_default.c
endif

CONFIG_H = config.h
@@ -24,10 +25,8 @@ 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 # TMK converter rev2
MCU = atmega32u4 # TMK converter rev1


# Processor frequency.
@@ -38,6 +37,29 @@ MCU = atmega32u4 # Teensy 2.0
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


# Boot Section Size in bytes
# Teensy halfKay 512
# Atmel DFU loader 4096
@@ -55,6 +77,7 @@ 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
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor



@@ -67,7 +90,7 @@ VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)


include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/protocol.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

+ 96
- 0
converter/m0110_usb/Makefile.tmk_rev2 View File

@@ -0,0 +1,96 @@
# Target file name (without extension).
TARGET = m0110_lufa

# Directory common source filess exist
TMK_DIR = ../../tmk_core

# Directory keyboard dependent files exist
TARGET_DIR = .

# keyboard dependent files
SRC = matrix.c \
led.c \
keymap_common.c \
m0110.c

# To use own keymap file run make like: make keymap=hasu
ifdef KEYMAP
SRC += keymap_$(KEYMAP).c
else
SRC += keymap_default.c
endif

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 = atmega32u2 # TMK converter rev2
#MCU = atmega32u4 # TMK converter rev1


# 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


# Boot Section Size in bytes
# Teensy halfKay 512
# Atmel DFU loader 4096
# LUFA bootloader 4096
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
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor



#---------------- Programming Options --------------------------
PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex


# 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

+ 4
- 7
converter/m0110_usb/README.md View File

@@ -59,19 +59,16 @@ To compile firmware you need AVR GCC. You can edit *Makefile* and *config.h* to

$ git clone git://github.com/tmk/tmk_keyboard.git (or download source)
$ cd m0110_usb
$ make -f Makefile clean
$ make -f Makefile [KEYMAP={default|plain|intl|spacefn|hasu}]
$ make -f Makefile.rev2 clean
$ make -f Makefile.rev2 [KEYMAP={default|intl|spacefn|hasu}]

Use `Makefile.teensy` instead for Teensy.
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. You can build it like this.

$ make -f Makefile clean
$ make -f Makefile KEYMAP=name
To create your own keymap copy existent keymap file to `keymap_name.c` and edit it.




+ 48
- 58
converter/m0110_usb/keymap_common.h View File

@@ -1,5 +1,5 @@
/*
Copyright 2011,2012,2014 Jun Wako <[email protected]>
Copyright 2011,2012,2014,2015 Jun Wako <[email protected]>

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
@@ -24,64 +24,49 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


/*
* The keymap works with both M0110 and M0110A keyboards. As you can see, the M0110A is a superset
* of the M0110 keyboard, with only one exception: 'Enter' in M0110 does not exist
* on the M0110A, but since it generates a unique scan code which is not used for some other key in
* the M0110A, they are totally interchangeable. In fact, the M0110A is functionally (almost)
* identical to the combination of the M0110 along with the M0120 keypad. The only difference
* (which is causing some problems as you will read below) is that the M0110+M0120 don't have
* dedicated arrow keys, while the M0110A does. However, the M0120 did have arrow keys, which
* doubled as the [comma], [/], [*] and [+] keys, when used with the [Shift] key. The M0110A has
* substituted the [comma] key with the [=] key, however its scancode is the same.
/* 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.
*
* Physical layout:
* M0110A
* ,---------------------------------------------------------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Bcksp| |Clr| =| /| *|
* | `| 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 | \|Lft|Rgt|Dn | | 0| .| |
* |---------------------------------------------------------| |-----------|Ent|
* |Opt |Mac | Space |Ent| \|Lft|Rgt|Dn | | 0| .| |
* `---------------------------------------------------------' `---------------'
*
* M0110 M0120
* M0110A scan codes
* ,---------------------------------------------------------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| -| +| *|
* | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62|
* |---------------------------------------------------------| |---------------|
* |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| ,|
* | 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|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| |
* `---------------------------------------------------------' |-----------|Ent|
* |Opt|Mac | Space |Ent |Opt| | 0| .| |
* `-----------------------------------------------' `---------------'
* With Shift keys on M0120 work as curosor.(-:Left *:Right /:Up ,:Down)
* | 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| |
* `---------------------------------------------------------' `---------------'
*
* NOTE: \ is located differently.
* NOTE: Enter on M0110 is different from Enter on keypad(M0120 and M0110A).
* NOTE: Left Shift and right Shift are logically same key.
* NOTE: Left Option and right Option are logically same key.
*/

/* Keymap definition Macro
* M0110 + M0120 scan codes
* ,---------------------------------------------------------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backs| |Clr| =| /| *|
* | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33| | 47| 68| 6D| 62|
* |---------------------------------------------------------| |---------------|
* |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| +|
* | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A| | 59| 5B| 5C| 4E|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Opt |Mac | Space |Ent| \|Lft|Rgt|Dn | | 0| .| |
* `---------------------------------------------------------' `---------------'
* NOTE: Ent between Space and \ means Enter on M0110.
* | 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, \
@@ -106,25 +91,30 @@ extern const uint16_t fn_actions[];
{ KC_##K68, KC_NO, KC_NO, KC_NO, KC_NO, KC_##K6D, KC_NO, KC_NO }, \
}

/* International keyboard
* ,---------------------------------------------------------.
* | 32| 12| 13| 14| 15| 17| 16| 1A| 1C| 19| 1D| 1B| 18| 33|
* |---------------------------------------------------------|
* | 30| 0C| 0D| 0E| 0F| 10| 11| 20| 22| 1F| 23| 21| 1E| 2A|
* |------------------------------------------------------, |
* | 39| 00| 01| 02| 03| 05| 04| 26| 28| 25| 29| 27| 24| |
* |---------------------------------------------------------|
* | 38| 06| 07| 08| 09| 0B| 2D| 2E| 2B| 2F| 2C| 0A| 38|
* `---------------------------------------------------------'
* | 3A| 37| 34 | 31| 3A|
* `------------------------------------------------'
/* 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, K4D, K53,K54,K55,K4C, \
K3A,K37, K34, K31, K46,K42,K48, K52, K41 \
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 }, \
@@ -134,8 +124,8 @@ extern const uint16_t fn_actions[];
{ 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_##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 }, \

+ 62
- 10
converter/m0110_usb/keymap_default.c View File

@@ -20,15 +20,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.



#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| -| +| *|
* | `| 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| /|
* |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| ,|
* |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|
@@ -52,27 +56,40 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
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, BSLS,LEFT,RGHT,DOWN, P0, PDOT
LALT,LGUI, SPC, FN0, FN13,LEFT,RGHT,DOWN, P0, PDOT
),
/* Cursor Layer
/* Cursor Layer:
* M0110 M0120
* ,---------------------------------------------------------. ,---------------.
* |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delet| |Nlk| -| +| *|
* |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| /|
* |Caps |Hom| Up|PgU| | | | |Psc|Slk|Pau|Up |INS| | | 7| 8| 9| -|
* |---------------------------------------------------------| |---------------|
* |Ctrl |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Return| | 4| 5| 6| ,|
* |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, NO, P7, P8, P9, PMNS,
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, INS, HOME,END, PGDN, P0, PDOT
LALT,LGUI, SPC, FN0, FN13,HOME,END, PGDN, P0, PDOT
),
};

@@ -80,6 +97,41 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
/*
* 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),
};

+ 0
- 118
converter/m0110_usb/keymap_for_editor.c View File

@@ -1,118 +0,0 @@
/*
Copyright 2014 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#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:
* ,---------------------------------------------------------. ,---------------.
* | `| 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| ;| '|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Ctl |Gui | Space |Alt| \|Lft|Rgt|Dn | | 0| .| |
* `---------------------------------------------------------' `---------------'
*/
[0] = KEYMAP(
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, CLR, EQL, PSLS,PAST,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, P7, P8, P9, PMNS,
LCAP,A, S, D, F, G, H, J, K, L, SCLN,QUOT, FN15, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, UP, P1, P2, P3, PENT,
LCTL,LGUI, FN16, LALT,FN31,LEFT,RGHT,DOWN, P0, PDOT
),
/* Cursor Layer(WASD, IJKL)
* ,---------------------------------------------------------. ,---------------.
* |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| -|
* |-----------------------------------------------------' | |---------------|
* |Caps |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Enter | | 4| 5| 6| +|
* |---------------------------------------------------------| |---------------|
* |Shift |End| |PgD| | | | |End|PgD|Dow|Shif|PgU| | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Ctl |Gui | Space |Alt | \|Hom|End|PgD| | 0| .| |
* `---------------------------------------------------------' `---------------'
*/
[3] = 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,
LCAP,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, FN15, P4, P5, P6, PPLS,
LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT,
LCTL,LGUI, FN16, LALT,FN31,HOME,END, PGDN, P0, PDOT
),
[4] = 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,
LCAP,LEFT,DOWN,RGHT,NO, NO, NO, NO, HOME,PGUP,LEFT,RGHT, FN15, P4, P5, P6, PPLS,
LSFT,END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, PGUP, P1, P2, P3, PENT,
LCTL,LGUI, FN16, LALT,FN31,HOME,END, PGDN, P0, PDOT
),
[7] = {},
};


/*
* 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_F),
[14] = ACTION_LAYER_TAP_KEY(2, KC_J),
[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_RALT, KC_BSLASH),
};

+ 8
- 20
converter/m0110_usb/keymap_intl.c View File

@@ -30,29 +30,17 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
* |------------------------------------------------------, | |---------------|
* |Ctrl | A| S| D| F| G| H| J| K| L| ;| '| \| | | 4| 5| 6| ,|
* |---------------------------------------------------------| |---------------|
* |Shif| <| Z| X| C| V| B| N| M| ,| ,| /|Shift | | 1| 2| 3| |
* |Shif| <| Z| X| C| V| B| N| M| ,| ,| /| | | 1| 2| 3| |
* `---------------------------------------------------------' |-----------|Ent|
* |Opt|Mac | Space |Fn |Opt| | 0| .| |
* |Opt|Mac | Space |Fn | | | 0| .| |
* `-----------------------------------------------' `---------------'
* M0110A(not existent?)
* ,---------------------------------------------------------. ,---------------.
* | `| 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| ,| ,| /|Shft|Up | | 1| 2| 3| |
* |---------------------------------------------------------| |-----------|Ent|
* |Opt |Mac | Space | \|Lft|Rgt|Dn | | 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, UP, P1, P2, P3, PENT,
LALT,LGUI, SPC, FN0, LEFT,RGHT,DOWN, P0, PDOT
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, P1, P2, P3, PENT,
LALT,LGUI, SPC, FN0, P0, PDOT
),
/* Cursor Layer
* ,---------------------------------------------------------. ,---------------.
@@ -62,17 +50,17 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
* |------------------------------------------------------, | |---------------|
* |Ctrl |Lef|Dow|Rig| | | | |Hom|PgU|Lef|Rig|Ins| | | 4| 5| 6| ,|
* |---------------------------------------------------------| |---------------|
* |Shif| <|End| |PgD| | | | |End|PgD|Dow|Shift | | 1| 2| 3| |
* |Shif| <|End| |PgD| | | | |End|PgD|Dow| | | 1| 2| 3| |
* `---------------------------------------------------------' |-----------|Ent|
* |Opt|Mac | Space |Fn |Opt| | 0| .| |
* |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, PGUP, P1, P2, P3, PENT,
LALT,LGUI, SPC, FN0, HOME,END, PGDN, P0, PDOT
LSFT,NO, END, NO, PGDN,NO, NO, NO, NO, END, PGDN,DOWN, P1, P2, P3, PENT,
LALT,LGUI, SPC, FN0, P0, PDOT
),
};


+ 0
- 64
converter/m0110_usb/keymap_plain.c View File

@@ -1,64 +0,0 @@
/*
Copyright 2014 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#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| /|
* |---------------------------------------------------------| |---------------|
* |Caps | 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,
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, UP, P1, P2, P3, PENT,
LALT,LGUI, SPC, RGUI,BSLS,LEFT,RGHT,DOWN, P0, PDOT
),
};

/*
* Fn action definition
*/
const uint16_t fn_actions[] PROGMEM = {
};



+ 6
- 0
converter/m0110_usb/matrix.c View File

@@ -64,6 +64,12 @@ void matrix_init(void)
// 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;
}


+ 93
- 0
converter/news_usb/Makefile View File

@@ -0,0 +1,93 @@
# Target file name (without extension).
TARGET = news_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 \
news.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 # TMK Converter Rev.2


# 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(+5000)
EXTRAKEY_ENABLE = yes # Audio control and System control(+600)
CONSOLE_ENABLE = yes # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration
#NKRO_ENABLE = yes # USB Nkey Rollover(+500)


# 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

+ 2
- 1
converter/news_usb/Makefile.pjrc View File

@@ -24,9 +24,10 @@ CONFIG_H = config_pjrc.h
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
#MCU = at90usb162 # Teensy 1.0
MCU = atmega32u4 # Teensy 2.0
#MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
#MCU = at90usb1286 # Teensy++ 2.0
MCU = atmega32u2 # TMK Converter Rev.2


# Processor frequency.

+ 63
- 0
converter/news_usb/config.h View File

@@ -0,0 +1,63 @@
/*
Copyright 2016 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CONFIG_H
#define CONFIG_H


#define 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<<RXCIE1) | (1<<RXEN1); \
} while(0)
#else
# error "USART configuration is needed."
#endif

#endif

+ 1
- 1
converter/news_usb/config_pjrc.h View File

@@ -45,7 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Asynchronous USART
* 8-data bit, non parity, 1-stop bit, no flow control
*/
#ifdef __AVR_ATmega32U4__
#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

+ 2
- 2
converter/next_usb/Makefile View File

@@ -17,10 +17,10 @@ CONFIG_H = config.h
# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
#MCU = at90usb162 # Teensy 1.0
MCU = atmega32u4 # Teensy 2.0
#MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
#MCU = at90usb1286 # Teensy++ 2.0
#MCU = atmega32u2 # TMK converter
MCU = atmega32u2 # TMK converter


# Processor frequency.

+ 10
- 8
converter/next_usb/config.h View File

@@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.

*/

#define VENDOR_ID 0xBCBC
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0xBCBC
#define DEVICE_VER 0x0500
#define MANUFACTURER t.m.k.
@@ -56,14 +56,15 @@ POSSIBILITY OF SUCH DAMAGE.
#define MATRIX_ROWS 12 // keycode bit: 3-0
#define MATRIX_COLS 8 // keycode bit: 6-4

//#define DEBUG_ON_INIT 1
#define DEBUG_ON_INIT 1

//#define TEENSY_CONFIG 1
#define PRO_MICRO_CONFIG 1
//#define TMK_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
#define NEXT_KBD_INIT_FLASH_LEDS
// 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
@@ -183,6 +184,7 @@ POSSIBILITY OF SUCH DAMAGE.

/* 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))) \
(keyboard_report->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))) \
)

+ 1
- 1
converter/next_usb/keymap.c View File

@@ -159,7 +159,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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,RALT, TRNS, RGUI,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS
TRNS,TRNS, TRNS, TRNS,TRNS, TRNS,TRNS,TRNS, TRNS, TRNS,TRNS
)
};

+ 6
- 1
converter/next_usb/led.c View File

@@ -47,9 +47,14 @@ 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<<USB_LED_CAPS_LOCK)) {
next_kbd_set_leds(true, true);
} else {
next_kbd_set_leds(false, false);
}
}

+ 4
- 2
converter/next_usb/matrix.c View File

@@ -160,7 +160,7 @@ void matrix_init(void)
/* scan all key states on matrix */
uint8_t matrix_scan(void)
{
_delay_ms(20);
_delay_ms(5);
//next_kbd_set_leds(false, false);
NEXT_KBD_LED1_OFF;
@@ -187,17 +187,19 @@ uint8_t matrix_scan(void)
uint32_t resp = (next_kbd_recv());
if (resp == NEXT_KBD_KMBUS_IDLE)
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, \

+ 3
- 6
converter/ps2_usb/Makefile.mbed View File

@@ -1,12 +1,9 @@
PROJECT = ps2_usb

TMK_DIR = ../../tmk_core
MBED_DIR = $(TMK_DIR)/mbed-sdk
MBED_DIR = $(TMK_DIR)/tool/mbed/mbed-sdk

#VPATH += $(MBED_DIR):$(TMK_DIR)
vpath %.s .:$(MBED_DIR):$(TMK_DIR)
vpath %.c .:$(MBED_DIR):$(TMK_DIR)
vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
VPATH += $(TMK_DIR):$(MBED_DIR)

OBJDIR = ./build

@@ -39,8 +36,8 @@ LIBRARIES =
MOUSEKEY_ENABLE = yes


include $(TMK_DIR)/tool/mbed/common.mk
#include $(TMK_DIR)/tool/mbed/mk20d50m.mk
include $(TMK_DIR)/tool/mbed/lpc11u35_501.mk
include $(TMK_DIR)/tool/mbed/mbed.mk
include $(TMK_DIR)/tool/mbed/common.mk
include $(TMK_DIR)/tool/mbed/gcc.mk

+ 7
- 6
converter/ps2_usb/Makefile.vusb View File

@@ -18,13 +18,13 @@ else
SRC := keymap_plain.c $(SRC)
endif

# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful.
SRC += protocol/ps2_usart.c
OPT_DEFS += -DPS2_USE_USART

CONFIG_H = config.h


# Use USART for PS/2. With V-USB INT and BUSYWAIT code is not useful.
PS2_USE_USART = yes


# 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
@@ -36,7 +36,8 @@ OPT_DEFS += -DDEBUG_LEVEL=0
#MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
#MCU = at90usb1286 # Teensy++ 2.0
MCU = atmega168
#MCU = atmega168
MCU = atmega328p


# Processor frequency.
@@ -44,7 +45,7 @@ MCU = atmega168
# 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 = 20000000
F_CPU = 12000000


# Build Options

+ 23
- 0
converter/ps2_usb/config.h View File

@@ -61,6 +61,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* 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
@@ -81,6 +82,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
EIMSK &= ~(1<<INT1); \
} while (0)
#define PS2_INT_VECT INT1_vect

#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
/* uses PCINT17(PD1) for clock line. this doesn't work with VUSB */
#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 { \
PCICR |= (1<<PCIE2); \
} while (0)
#define PS2_INT_ON() do { \
PCMSK2 |= (1<<PCINT17); \
} while (0)
#define PS2_INT_OFF() do { \
PCMSK2 &= ~(1<<PCINT17); \
} while (0)
#define PS2_INT_VECT PCINT2_vect
#endif
#endif

/*

+ 9
- 2
converter/sun_usb/Makefile View File

@@ -11,8 +11,8 @@ TARGET_DIR = .
SRC = keymap.c \
matrix.c \
led.c \
command_extra.c \
protocol/serial_soft.c
command_extra.c

CONFIG_H = config.h

@@ -64,8 +64,15 @@ 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

+ 3
- 1
converter/sun_usb/README View File

@@ -48,7 +48,9 @@ Frame format: 1-Start bit, 8-Data bits, No-Parity, 1-Stop bit
To use AVR UART engine you need external inverter in front of RX and TX pin.
Otherwise you can software serial routine to communicate the keyboard.

This converter uses software method, you doesn't need any inverter part.
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

+ 30
- 23
converter/sun_usb/command_extra.c View File

@@ -5,41 +5,47 @@
#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("Up: Bell On\n");
print("Down: Bell Off\n");
print("Left: Click On\n");
print("Right: Click Off\n");
print("PgUp: LED all On\n");
print("PgDown: LED all On\n");
print("Insert: Layout\n");
print("Delete: Reset\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_UP:
print("Bell On\n");
serial_send(0x02);
break;
case KC_DOWN:
print("Bell Off\n");
serial_send(0x03);
break;
case KC_LEFT:
print("Click On\n");
serial_send(0x0A);
break;
case KC_RIGHT:
print("Click Off\n");
serial_send(0x0B);
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);
@@ -55,6 +61,7 @@ bool command_extra(uint8_t code)
serial_send(0x0F);
break;
default:
xprintf("Unknown extra command: %02X\n", code);
return false;
}
return true;

+ 83
- 46
converter/sun_usb/config.h View File

@@ -39,51 +39,88 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* legacy keymap support */
#define USE_LEGACY_KEYMAP


/* Serial(USART) configuration
* asynchronous, negative logic, 1200baud, no flow control
* 1-start bit, 8-data bit, non parity, 1-stop bit
/* 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.
*/
#define SERIAL_SOFT_BAUD 1200
#define SERIAL_SOFT_PARITY_NONE
#define SERIAL_SOFT_BIT_ORDER_LSB
#define SERIAL_SOFT_LOGIC_NEGATIVE
/* RXD Port */
#define SERIAL_SOFT_RXD_ENABLE
#define SERIAL_SOFT_RXD_DDR DDRD
#define SERIAL_SOFT_RXD_PORT PORTD
#define SERIAL_SOFT_RXD_PIN PIND
#define SERIAL_SOFT_RXD_BIT 2
#define SERIAL_SOFT_RXD_VECT INT2_vect
/* RXD Interupt */
#define SERIAL_SOFT_RXD_INIT() do { \
/* pin configuration: input with pull-up */ \
SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
/* enable interrupt: INT2(rising edge) */ \
EICRA |= ((1<<ISC21)|(1<<ISC20)); \
EIMSK |= (1<<INT2); \
sei(); \
} while (0)
#define SERIAL_SOFT_RXD_INT_ENTER()
#define SERIAL_SOFT_RXD_INT_EXIT() do { \
/* clear interrupt flag */ \
EIFR = (1<<INTF2); \
} while (0)
#define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
/* TXD Port */
#define SERIAL_SOFT_TXD_ENABLE
#define SERIAL_SOFT_TXD_DDR DDRD
#define SERIAL_SOFT_TXD_PORT PORTD
#define SERIAL_SOFT_TXD_PIN PIND
#define SERIAL_SOFT_TXD_BIT 3
#define SERIAL_SOFT_TXD_HI() do { SERIAL_SOFT_TXD_PORT |= (1<<SERIAL_SOFT_TXD_BIT); } while (0)
#define SERIAL_SOFT_TXD_LO() do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
#define SERIAL_SOFT_TXD_INIT() do { \
/* pin configuration: output */ \
SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
/* idle */ \
SERIAL_SOFT_TXD_ON(); \
} while (0)
#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<<UDRE1))
#define SERIAL_UART_INIT() do { \
UBRR1L = (uint8_t) SERIAL_UART_UBRR; /* baud rate */ \
UBRR1H = (uint8_t) (SERIAL_UART_UBRR>>8); /* baud rate */ \
UCSR1B = (1<<RXCIE1) | (1<<RXEN1) | /* RX: interrupt, RX: enable */ \
(1<<TXEN1); /* TX: enable */ \
UCSR1C = (0<<UPM11) | (0<<UPM10) | /* parity: none(00), even(01), odd(11) */ \
(0<<UCSZ12) | (1<<UCSZ11) | (1<<UCSZ10); /* data-8bit(011) */ \
sei(); \
} while(0)
#else
# error "USART configuration is needed."
#endif

#else
/* Software Serial configuration
* asynchronous, negative logic, 1200baud, no flow control
* 1-start bit, 8-data bit, non parity, 1-stop bit
*/
#define SERIAL_SOFT_BAUD 1200
#define SERIAL_SOFT_PARITY_NONE
#define SERIAL_SOFT_BIT_ORDER_LSB
#define SERIAL_SOFT_LOGIC_NEGATIVE
/* RXD Port */
#define SERIAL_SOFT_RXD_ENABLE
#define SERIAL_SOFT_RXD_DDR DDRD
#define SERIAL_SOFT_RXD_PORT PORTD
#define SERIAL_SOFT_RXD_PIN PIND
#define SERIAL_SOFT_RXD_BIT 2
#define SERIAL_SOFT_RXD_VECT INT2_vect
/* RXD Interupt */
#ifdef SERIAL_SOFT_LOGIC_NEGATIVE
/* enable interrupt: INT2(rising edge) */
#define INTR_TRIG_EDGE ((1<<ISC21)|(1<<ISC20))
#else
/* enable interrupt: INT2(falling edge) */
#define INTR_TRIG_EDGE ((1<<ISC21)|(0<<ISC20))
#endif
#define SERIAL_SOFT_RXD_INIT() do { \
/* pin configuration: input with pull-up */ \
SERIAL_SOFT_RXD_DDR &= ~(1<<SERIAL_SOFT_RXD_BIT); \
SERIAL_SOFT_RXD_PORT |= (1<<SERIAL_SOFT_RXD_BIT); \
EICRA |= INTR_TRIG_EDGE; \
EIMSK |= (1<<INT2); \
sei(); \
} while (0)
#define SERIAL_SOFT_RXD_INT_ENTER()
#define SERIAL_SOFT_RXD_INT_EXIT() do { \
/* clear interrupt flag */ \
EIFR = (1<<INTF2); \
} while (0)
#define SERIAL_SOFT_RXD_READ() (SERIAL_SOFT_RXD_PIN&(1<<SERIAL_SOFT_RXD_BIT))
/* TXD Port */
#define SERIAL_SOFT_TXD_ENABLE
#define SERIAL_SOFT_TXD_DDR DDRD
#define SERIAL_SOFT_TXD_PORT PORTD
#define SERIAL_SOFT_TXD_PIN PIND
#define SERIAL_SOFT_TXD_BIT 3
#define SERIAL_SOFT_TXD_HI() do { SERIAL_SOFT_TXD_PORT |= (1<<SERIAL_SOFT_TXD_BIT); } while (0)
#define SERIAL_SOFT_TXD_LO() do { SERIAL_SOFT_TXD_PORT &= ~(1<<SERIAL_SOFT_TXD_BIT); } while (0)
#define SERIAL_SOFT_TXD_INIT() do { \
/* pin configuration: output */ \
SERIAL_SOFT_TXD_DDR |= (1<<SERIAL_SOFT_TXD_BIT); \
/* idle */ \
SERIAL_SOFT_TXD_ON(); \
} while (0)

#endif
#endif //hardware serial
#endif //config.h

+ 2
- 0
converter/sun_usb/led.c View File

@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdint.h"
#include "serial.h"
#include "led.h"
#include "debug.h"


void led_set(uint8_t usb_led)
@@ -27,6 +28,7 @@ void led_set(uint8_t usb_led)
if (usb_led & (1<<USB_LED_COMPOSE)) sun_led |= (1<<1);
if (usb_led & (1<<USB_LED_SCROLL_LOCK)) sun_led |= (1<<2);
if (usb_led & (1<<USB_LED_CAPS_LOCK)) sun_led |= (1<<3);
xprintf("LED: %02X\n", usb_led);

serial_send(0x0E);
serial_send(sun_led);

+ 34
- 10
converter/sun_usb/matrix.c View File

@@ -72,6 +72,21 @@ void matrix_init(void)
// 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;
}

@@ -86,17 +101,26 @@ uint8_t matrix_scan(void)
debug_hex(code); debug(" ");

switch (code) {
case 0xFF: // reset success
case 0xFE: // layout
case 0x7E: // reset fail
if (code == 0xFF) print("reset: 0xFF ");
if (code == 0x7E) print("reset fail: 0x7E ");
if (code == 0xFE) print("layout: 0xFE ");
// response byte
case 0xFF: // reset success: FF 04
print("reset: ");
_delay_ms(500);
code = serial_recv();
xprintf("%02X\n", code);
if (code == 0x04) {
// LED status
led_set(host_keyboard_leds());
}
return 0;
case 0xFE: // layout: FE <layout>
print("layout: ");
_delay_ms(500);
xprintf("%02X\n", serial_recv());
return 0;
case 0x7E: // reset fail: 7E 01
print("reset fail: ");
_delay_ms(500);
if (code = serial_recv()) print_hex8(code);
print("\n");
// FALL THROUGH
xprintf("%02X\n", serial_recv());
return 0;
case 0x7F:
// all keys up
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;

+ 0
- 1
converter/usb_usb/Makefile View File

@@ -111,7 +111,6 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
SRC = \
keymap_common.c \
matrix.c \
led.c \
main.cpp

ifdef KEYMAP

+ 5
- 0
converter/usb_usb/Makefile.keymap_editor View File

@@ -0,0 +1,5 @@
# build firmware for keymap editor
#
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
KEYMAP = editor
include Makefile

+ 2
- 2
converter/usb_usb/config.h View File

@@ -30,8 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.


/* matrix size */
#define MATRIX_ROWS 32
#define MATRIX_COLS 8
#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)))

+ 55
- 48
converter/usb_usb/keymap.c View File

@@ -18,33 +18,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keymap_common.h"


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
/* 0: plain Qwerty without layer switching
* ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------.
* |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| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
* ,---------------. ,---------------. ,---------------.
* |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(
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,
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
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
),

/* 1: Colemak http://colemak.com
#if 0
/* Colemak http://colemak.com
* ,-----------------------------------------------------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa|
* |-----------------------------------------------------------|
@@ -57,16 +61,17 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
* `----------------------------------------------------------'
*/
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, F, P, G, J, L, U, Y, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
BSPC,A, R, S, T, D, H, N, E, I, O, QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, C, V, B, K, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
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
),

/* 2: Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
/* Dvorak http://en.wikipedia.org/wiki/Dvorak_Simplified_Keyboard
* ,-----------------------------------------------------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| [| ]|Backspa|
* |-----------------------------------------------------------|
@@ -79,16 +84,17 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
* `-----------------------------------------------------------'
*/
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, LBRC,RBRC,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
TAB, QUOT,COMM,DOT, P, Y, F, G, C, R, L, SLSH,EQL, BSLS, DEL, END, PGDN, P7, P8, P9,
CAPS,A, O, E, U, I, D, H, T, N, S, MINS, ENT, P4, P5, P6, PPLS,
LSFT,SCLN,Q, J, K, X, B, M, W, V, Z, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
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
),

/* 3: Workman http://viralintrospection.wordpress.com/2010/09/06/a-different-philosophy-in-designing-keyboard-layouts/
/* 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|
* |-----------------------------------------------------------|
@@ -101,15 +107,16 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl|
* `-----------------------------------------------------------'
*/
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, D, R, W, B, J, F, U, P, SCLN,LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9,
BSPC,A, S, H, T, G, Y, N, E, O, I, QUOT, ENT, P4, P5, P6, PPLS,
LSFT,Z, X, M, C, V, K, L, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3,
LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
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 PROGMEM fn_actions[] = {
};
const uint16_t fn_actions[] PROGMEM = {};

+ 175
- 39
converter/usb_usb/keymap_common.h View File

@@ -32,46 +32,182 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
extern const uint16_t fn_actions[];


#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 \
/* ,---------------. ,---------------. ,---------------.
* |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_NO, 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_NO, KC_##K65, KC_NO, KC_NO }, /* 60-67 */ \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 68-6F */ \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 70-77 */ \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 78-7F */ \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 80-87 */ \
{ KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* 88-8F */ \
{ KC_NO, KC_NO, 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 */ \
{ 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

+ 88
- 0
converter/usb_usb/keymap_editor.c View File

@@ -0,0 +1,88 @@
/*
Copyright 2016 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "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),
};

+ 36
- 0
converter/usb_usb/keymap_iso.c View File

@@ -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 = {
};

+ 36
- 0
converter/usb_usb/keymap_jis.c View File

@@ -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 = {
};

+ 34
- 30
converter/usb_usb/keymap_spacefn.c View File

@@ -6,36 +6,39 @@


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| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
/* 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(
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
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 |
* |-----------------------------------------------------------|
* | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins |
* |Caps | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins |
* |-----------------------------------------------------------|
* | | | | | | |PgU|Lef|Dow|Rig| | | |
* |-----------------------------------------------------------|
@@ -44,13 +47,14 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* | | | | | | | | |
* `-----------------------------------------------------------'
*/
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
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
),
};


+ 22
- 22
converter/usb_usb/main.cpp View File

@@ -5,10 +5,10 @@

// USB HID host
#include "Usb.h"
#include "usbhub.h"
#include "hid.h"
#include "hidboot.h"
#include "parser.h"
#include "usbhub.h"

// LUFA
#include "lufa.h"
@@ -17,6 +17,7 @@
#include "sendchar.h"
#include "debug.h"
#include "keyboard.h"
#include "led.h"


/* LED ping configuration */
@@ -42,19 +43,6 @@
#endif


static USB usb_host;
static HIDBoot<HID_PROTOCOL_KEYBOARD> kbd(&usb_host);
static KBDReportParser kbd_parser;
static USBHub hub1(&usb_host); // one hub is enough for HHKB pro2
/* may be needed for other device with more hub
static USBHub hub2(&usb_host);
static USBHub hub3(&usb_host);
static USBHub hub4(&usb_host);
static USBHub hub5(&usb_host);
static USBHub hub6(&usb_host);
static USBHub hub7(&usb_host);
*/

static void LUFA_setup(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
@@ -74,17 +62,24 @@ static void LUFA_setup(void)
print_set_sendchar(sendchar);
}

static void HID_setup()
{
if (usb_host.Init() == -1) {
LED_TX_OFF;
}

_delay_ms(200);

kbd.SetReportParser(0, (HIDReportParser*)&kbd_parser);
/*
* USB Host Shield HID keyboard
*/
USB usb_host;
USBHub hub1(&usb_host);
HIDBoot<HID_PROTOCOL_KEYBOARD> 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
@@ -92,12 +87,17 @@ int main(void)
LED_TX_ON;

debug_enable = true;
debug_keyboard = true;

host_set_driver(&lufa_driver);
keyboard_init();

LUFA_setup();
HID_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).
*/

+ 13
- 13
converter/usb_usb/matrix.c View File

@@ -31,20 +31,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 7 6 5 4 3 2 1 0
* +---------------+
* | ROW | COL |
* | ROW | COL |
* +---------------+
*
* Matrix space(32 * 8):
* 01234567
* 0 +--------+
* : | |
* : | |
* 31 +--------+
* Matrix space(16 * 16):
* r\c0123456789ABCDEF
* 0 +----------------+
* : | |
* : | |
* 16 +----------------+
*/
#define ROW_MASK 0xF8
#define COL_MASK 0x07
#define CODE(row, col) (((row) << 3) | (col))
#define ROW(code) (((code) & ROW_MASK) >> 3)
#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))

@@ -89,8 +89,8 @@ bool matrix_is_on(uint8_t row, uint8_t col) {
return false;
}

uint8_t matrix_get_row(uint8_t row) {
uint8_t row_bits = 0;
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;

+ 29
- 7
converter/x68k_usb/Makefile View File

@@ -4,7 +4,7 @@


# Target file name (without extension).
TARGET = x68k_usb_pjrc
TARGET = x68k_usb

# Directory common source filess exist
TMK_DIR = ../../tmk_core
@@ -18,15 +18,16 @@ SRC = keymap.c \
led.c \
protocol/serial_uart.c

CONFIG_H = config_pjrc.h
CONFIG_H = config.h


# MCU name, you MUST set this to match the board you are using
# type "make clean" after changing this, so all files will be rebuilt
#MCU = at90usb162 # Teensy 1.0
MCU = atmega32u4 # Teensy 2.0
#MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb646 # Teensy++ 1.0
#MCU = at90usb1286 # Teensy++ 2.0
MCU = atmega32u2 # Teensy 2.0


# Processor frequency.
@@ -37,6 +38,29 @@ MCU = atmega32u4 # Teensy 2.0
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
# Atmel DFU loader 4096
@@ -85,9 +109,7 @@ 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)
#PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
PROGRAM_CMD = dfu-programmer atmega32u4 flash $(TARGET).hex
PROGRAM_CMD = $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)


# Search Path
@@ -95,7 +117,7 @@ VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)


include $(TMK_DIR)/protocol/pjrc.mk
include $(TMK_DIR)/protocol.mk
include $(TMK_DIR)/protocol/lufa.mk
include $(TMK_DIR)/common.mk
include $(TMK_DIR)/rules.mk

converter/x68k_usb/config_pjrc.h → converter/x68k_usb/config.h View File

@@ -21,6 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#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
@@ -38,14 +39,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) \
)

/* legacy keymap support */
#define USE_LEGACY_KEYMAP


/* USART configuration
* asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control
*/
#ifdef __AVR_ATmega32U4__
#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)

+ 25
- 32
converter/x68k_usb/keymap.c View File

@@ -19,7 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "util.h"
#include "serial.h"
#include "keymap.h"


@@ -70,30 +72,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}


// 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
static const uint16_t fn_actions[] PROGMEM = {
[0] = ACTION_FUNCTION(0), // toggle all LEDs
};

// 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
};
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] = {
@@ -115,7 +111,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
/* ANSI */
KEYMAP(
F16, F17, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, PSCR,SLCK,PAUS, CAPS,F11, F12, F13,
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,
@@ -134,17 +130,14 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};


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)
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
return pgm_read_byte(&fn_layer[index]);
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}

uint8_t keymap_fn_keycode(uint8_t index)
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return pgm_read_byte(&fn_keycode[index]);
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}

+ 103
- 0
converter/xt_usb/Makefile View File

@@ -0,0 +1,103 @@
#
# Makefile for Teensy
#
# Target file name (without extension).
TARGET = xt_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

ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_plain.c $(SRC)
endif

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


# XT/2 Options
#
XT_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin


# 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

+ 36
- 0
converter/xt_usb/README.md View File

@@ -0,0 +1,36 @@
XT to USB keyboard converter
==============================
This firmware converts XT keyboard protocol to USB.(It supports Scan Code Set 1.)


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)
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 `xt_usb_lufa.hex` in current directory.


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_<name>.c` and see keymap document(you can find in README.md of top directory) and existent keymap files.


+ 71
- 0
converter/xt_usb/config.h View File

@@ -0,0 +1,71 @@
/*
Copyright 2012 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CONFIG_H
#define CONFIG_H

#include <avr/interrupt.h>

#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6512
#define DEVICE_VER 0x0001
#define MANUFACTURER t.m.k.
#define PRODUCT XT keyboard converter
#define DESCRIPTION convert XT keyboard to USB


/* matrix size */
#define MATRIX_ROWS 16 // 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

/*
* XT Pin interrupt
*/
#ifdef XT_USE_INT
/* uses INT1 for clock line(ATMega32U4) */
#define XT_CLOCK_PORT PORTD
#define XT_CLOCK_PIN PIND
#define XT_CLOCK_DDR DDRD
#define XT_CLOCK_BIT 1
#define XT_DATA_PORT PORTD
#define XT_DATA_PIN PIND
#define XT_DATA_DDR DDRD
#define XT_DATA_BIT 0
#define XT_INT_INIT() do { \
EICRA |= ((1<<ISC11) | \
(1<<ISC10)); \
} while (0)
#define XT_INT_ON() do { \
EIMSK |= (1<<INT1); \
} while (0)
#define XT_INT_OFF() do { \
EIMSK &= ~(1<<INT1); \
} while (0)
#define XT_INT_VECT INT1_vect
#endif

#endif

+ 31
- 0
converter/xt_usb/keymap_common.c View File

@@ -0,0 +1,31 @@
/*
Copyright 2011,2012,2013 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "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)]) };
}

+ 144
- 0
converter/xt_usb/keymap_common.h View File

@@ -0,0 +1,144 @@
/*
Copyright 2011,2012,2013 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_COMMON_H
#define KEYMAP_COMMON_H

#include <stdint.h>
#include <stdbool.h>
#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( \
K00, K02,K03,K04,K05,K06,K07,K08,K09,K0A,K0B,K0C,K0D, K0E,K0F,K0G, \
K10,K11,K12,K13,K14,K15,K16,K17,K18,K19,K1A,K1B,K1C,K1D, K1E,K1F,K1G, K1H,K1I,K1J,K1K, \
K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D, K2E,K2F,K2G, K2H,K2I,K2J, \
K30,K31,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B, K3D, K3H,K3I,K3J,K3K, \
K40,K41,K42,K43,K44,K45,K46,K47,K48,K49,K4A, K4D, K4F, K4H,K4I,K4J, \
K50,K51,K52, K55, K5A,K5B,K5C,K5D, K5E,K5F,K5G, K5H, K5J,K5K, \
\
K60, K61, K62, /* System Power, Sleep, Wake */ \
K70, K71, K72, /* Mute, Volume Up, Volume Down */ \
K80, K81, K82, K83, K84, /* Next, Previous, Stop, Pause, Media Select */ \
K90, K91, K92, /* Mail, Calculator, My Computer */ \
KA0, KA1, KA2, KA3, /* WWW Search, Home, Back, Forward */ \
KB0, KB1, KB2 /* WWW Stop, Refresh, Favorites */ \
) { \
{ KC_NO, KC_##K00, 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_##K3D, KC_##K50, KC_##K31, KC_##K32 }, \
{ KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A }, \
{ KC_##K3B, KC_##K10, KC_##K40, KC_##K2D, KC_##K41, KC_##K42, KC_##K43, KC_##K44 }, \
{ KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4D, KC_##K1J }, \
{ KC_##K52, KC_##K55, KC_##K30, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \
{ KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K1H, KC_##K0F, KC_##K2H }, \
{ KC_##K2I, KC_##K2J, KC_##K1K, KC_##K3H, KC_##K3I, KC_##K3J, KC_##K3K, KC_##K4H }, \
{ KC_##K4I, KC_##K4J, KC_##K5H, KC_##K5J, KC_##K5K, KC_##K5D, KC_##K1I, KC_##K0C }, \
{ KC_##K0D, KC_##K5A, KC_##K80, KC_##K51, KC_##K5B, KC_##K5C, KC_##K60, KC_##K61 }, \
{ KC_##K70, KC_##K91, KC_##K83, KC_##K62, KC_##K82, KC_##KA0, KC_##KB2, KC_##KB1 }, \
{ KC_##KB0, KC_##KA3, KC_##KA2, KC_##K92, KC_##K90, KC_##K84, KC_##K81, KC_##K1F }, \
{ KC_##K4F, KC_##K1G, KC_##K72, KC_##K5E, KC_##K71, KC_##K5G, KC_##KA1, KC_##K2F }, \
{ KC_##K5F, KC_##K2G, KC_##K1E, KC_##K2E, KC_##K0E, KC_##K0G, KC_NO , 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, \
\
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, \
\
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, \
\
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

+ 34
- 0
converter/xt_usb/keymap_jis.c View File

@@ -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[] = {
};

+ 32
- 0
converter/xt_usb/keymap_plain.c View File

@@ -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[] = {
};

+ 61
- 0
converter/xt_usb/keymap_spacefn.c View File

@@ -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
};


+ 20
- 0
converter/xt_usb/led.c View File

@@ -0,0 +1,20 @@
/*
Copyright 2016 Ethan Apodaca <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

void led_set(uint8_t usb_led) {
//XT Keyboards do not have LEDs, nothing to do.
}

+ 333
- 0
converter/xt_usb/matrix.c View File

@@ -0,0 +1,333 @@
/*
Copyright 2011 Jun Wako <[email protected]>
Copyright 2016 Ethan Apodaca <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>
#include <stdbool.h>
#include "action.h"
#include "print.h"
#include "util.h"
#include "debug.h"
#include "xt.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

static uint8_t matrix[MATRIX_ROWS];
#define ROW(code) (code>>3)
#define COL(code) (code&0x07)

// matrix positions for exceptional keys
#define PRINT_SCREEN (0x7C)
#define PAUSE (0x7D)

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;
xt_host_init();

// initialize matrix state: all keys off
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;

return;
}

static uint8_t move_codes(uint8_t code) {
switch(code) {
case 0x10:
code += 0x5E;
break;
case 0x19:
code += 0x41;
break;
case 0x1C:
case 0x1D:
code += 0x38;
break;
case 0x20:
case 0x21:
case 0x22:
case 0x24:
code += 0x40;
break;
case 0x2E:
case 0x30:
case 0x32:
code += 0x44;
break;
case 0x35:
case 0x38:
code += 0x21;
break;
case 0x47:
case 0x48:
case 0x49:
case 0x4B:
case 0x4D:
case 0x4F:
case 0x50:
case 0x51:
case 0x52:
case 0x53:
code += 0x28;
break;
}
return code;
}

uint8_t matrix_scan(void)
{

// scan code reading states
static enum {
INIT,
E0,
E0_2A,
E0_2A_E0,
E0_B7,
E0_B7_E0,

// print screen
E1,
E1_1D,
E1_1D_45,
E1_1D_45_E1,
E1_1D_45_E1_9D,
// pause
} state = INIT;


is_modified = false;

// 'pseudo break code' hack
if (matrix_is_on(ROW(PAUSE), COL(PAUSE))) {
matrix_break(PAUSE);
}

uint8_t code = xt_host_recv();
switch (state) {
case INIT:
switch (code) {
case 0xE0:
state = E0;
break;
case 0xE1:
state = E1;
break;
default: // normal key make
if (code < 0x80 && code != 0x00) {
xprintf("make: %X\r\n", code);
matrix_make(code);
} else if (code > 0x80 && code < 0xFF && code != 0x00) {
xprintf("break %X\r\n", code);
matrix_break(code - 0x80);
}
state = INIT;
}
break;
case E0: // E0-Prefixed
switch (code) { //move these codes to unused places on the matrix
case 0x2A:
state = E0_2A;
break;
case 0xB7:
state = E0_B7;
break;
default:
if (code < 0x80 && code != 0x00) {
matrix_make(move_codes(code));
} else if (code > 0x80 && code < 0xFF && code != 0x00) {
matrix_break(move_codes(code - 0x80));
}
state = INIT;
}
break;
case E0_2A:
if(code == 0xE0)
state = E0_2A_E0;
else
state = INIT;
break;
case E0_2A_E0:
if(code == 0x37)
matrix_make(PRINT_SCREEN);
else
state = INIT;
break;
case E0_B7:
if(code == 0xE0)
state = E0_B7;
else
state = INIT;
break;
case E0_B7_E0:
if(code == 0xAA)
matrix_break(PRINT_SCREEN);
else
state = INIT;
break;
case E1:
if (code == 0x1D)
state = E1_1D;
else
state = INIT;
break;
case E1_1D:
if(code == 0x45)
state = E1_1D_45;
else
state = INIT;
break;
case E1_1D_45:
if(code == 0xE1)
state = E1_1D_45_E1;
else
state = INIT;
break;
case E1_1D_45_E1:
if(code == 0x9D)
state = E1_1D_45_E1_9D;
else
state = INIT;
break;
case E1_1D_45_E1_9D:
if(code == 0xC5)
matrix_make(PAUSE);
else
state = INIT;
break;
default:
state = INIT;
}
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<<col));
}

inline
uint8_t matrix_get_row(uint8_t row)
{
return matrix[row];
}

void matrix_print(void)
{
print("\nr/c 01234567\n");
for (uint8_t row = 0; row < matrix_rows(); row++) {
phex(row); print(": ");
pbin_reverse(matrix_get_row(row));
#ifdef MATRIX_HAS_GHOST
if (matrix_has_ghost_in_row(row)) {
print(" <ghost");
}
#endif
print("\n");
}
}

uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop(matrix[i]);
}
return count;
}

#ifdef MATRIX_HAS_GHOST
inline
static bool matrix_has_ghost_in_row(uint8_t row)
{
// no ghost exists in case less than 2 keys on
if (((matrix[row] - 1) & matrix[row]) == 0)
return false;

// ghost exists in case same state as other row
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
if (i != row && (matrix[i] & matrix[row]) == matrix[row])
return true;
}
return false;
}
#endif


inline
static void matrix_make(uint8_t code)
{
if (!matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] |= 1<<COL(code);
is_modified = true;
}
}

inline
static void matrix_break(uint8_t code)
{
if (matrix_is_on(ROW(code), COL(code))) {
matrix[ROW(code)] &= ~(1<<COL(code));
is_modified = true;
}
}

inline
static void matrix_clear(void)
{
for (uint8_t i=0; i < MATRIX_ROWS; i++) matrix[i] = 0x00;
}

+ 0
- 339
doc/COPYING.GPLv2 View File

@@ -1,339 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

+ 0
- 674
doc/COPYING.GPLv3 View File

@@ -1,674 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The GNU General Public License is a free, copyleft license for
software and other kinds of works.

The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.

Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

The precise terms and conditions for copying, distribution and
modification follow.

TERMS AND CONDITIONS

0. Definitions.

"This License" refers to version 3 of the GNU General Public License.

"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.

To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

A "covered work" means either the unmodified Program or a work based
on the Program.

To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

1. Source Code.

The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.

A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

The Corresponding Source for a work in source code form is that
same work.

2. Basic Permissions.

All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.

3. Protecting Users' Legal Rights From Anti-Circumvention Law.

No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

4. Conveying Verbatim Copies.

You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

5. Conveying Modified Source Versions.

You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.

b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".

c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.

d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.

A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

6. Conveying Non-Source Forms.

You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.

b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.

c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.

d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.

e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.

A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

7. Additional Terms.

"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or

b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or

c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or

d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or

e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or

f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.

All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

8. Termination.

You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

9. Acceptance Not Required for Having Copies.

You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

10. Automatic Licensing of Downstream Recipients.

Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.

An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

11. Patents.

A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".

A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

12. No Surrender of Others' Freedom.

If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

13. Use with the GNU Affero General Public License.

Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

14. Revised Versions of this License.

The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

15. Disclaimer of Warranty.

THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

16. Limitation of Liability.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

17. Interpretation of Sections 15 and 16.

If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

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 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

+ 0
- 40
doc/FUSE.txt View File

@@ -1,40 +0,0 @@
ATMega168P Fuse/Lock Bits
=========================
This configuration is from usbasploader's Makefile.

HFUSE 0xD6
LFUSE 0xDF
EFUSE 0x00
LOCK 0x3F(intact)

#---------------------------------------------------------------------
# ATMega168P
#---------------------------------------------------------------------
# Fuse extended byte:
# 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
# \+/
# +------- BOOTSZ (00 = 2k bytes)
# Fuse high byte:
# 0xd6 = 1 1 0 1 0 1 1 0
# ^ ^ ^ ^ ^ \-+-/
# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
# | | | +-------------- WDTON (if 0: watchdog always on)
# | | +---------------- SPIEN (allow serial programming)
# | +------------------ DWEN (debug wire enable)
# +-------------------- RSTDISBL (reset pin is enabled)
# Fuse low byte:
# 0xdf = 1 1 0 1 1 1 1 1
# ^ ^ \ / \--+--/
# | | | +------- CKSEL 3..0 (external >8M crystal)
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
# | +------------------ CKOUT (if 0: Clock output enabled)
# +-------------------- CKDIV8 (if 0: divide by 8)


# Lock Bits
# 0x3f = - - 1 1 1 1 1 1
# \ / \-/ \-/
# | | +----- LB 2..1 (No memory lock features enabled)
# | +--------- BLB0 2..1 (No restrictions for SPM or LPM accessing the Application section)
# +--------------- BLB1 2..1 (No restrictions for SPM or LPM accessing the Boot Loader section)

+ 0
- 62
doc/POWER.txt View File

@@ -1,62 +0,0 @@
Time to Sleep
=============
USB suspend no activity on USB line for 3ms
No Interaction no user interaction
matrix has no change
matrix has no switch on


AVR Power Management
====================

V-USB suspend
USB suspend
http://vusb.wikidot.com/examples

MCUSR MCU Status Register
WDRF Watchdog Reset Flag
BORF
EXTRF
PORF Power-on Reset Flag

SMCR Sleep Mode Control Register
SE Sleep Enable
SM2:0
#define set_sleep_mode(mode) \
#define SLEEP_MODE_IDLE (0)
#define SLEEP_MODE_ADC _BV(SM0)
#define SLEEP_MODE_PWR_DOWN _BV(SM1)
#define SLEEP_MODE_PWR_SAVE (_BV(SM0) | _BV(SM1))
#define SLEEP_MODE_STANDBY (_BV(SM1) | _BV(SM2))
#define SLEEP_MODE_EXT_STANDBY (_BV(SM0) | _BV(SM1) | _BV(SM2))


ACSR Analog Comparator Control and Status Register
To disable Analog Comparator
ACSR = 0x80;
or
ACSR &= ~_BV(ACIE);
ACSR |= _BV(ACD);

ACD: Analog Comparator Disable
When this bit is written logic one, the power to the Analog Comparator is
switched off. This bit can be set at any time to turn off the Analog
Comparator. This will reduce power consumption in Active and Idle mode.
When changing the ACD bit, the Analog Comparator Interrupt must be disabled
by clearing the ACIE bit in ACSR. Otherwise an interrupt can occur when
the bit is changed.

DIDR1 Digital Input Disable Register 1
AIN1D
AIN0D
When this bit is written logic one, the digital input buffer on the AIN1/0 pin is disabled. The corresponding PIN Register bit will always read as zero when this bit is set. When an analog signal is applied to the AIN1/0 pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the digital input buffer.


PRR Power Reduction Register
PRTWI
PRTIM2
PRTIM0
PRTIM1
PRSPI
PRUSART0
PRADC

+ 0
- 160
doc/USB_NKRO.txt View File

@@ -1,160 +0,0 @@
USB NKRO MEMO
=============
2010/12/09


References
----------
USB - boot mode, NKRO, compatibility, etc...
http://geekhack.org/showthread.php?t=13162
NKey Rollover - Overview, Testing Methodology, and Results
http://geekhack.org/showwiki.php?title=NKey+Rollover+-+Overview+Testing+Methodology+and+Results
dfj's NKRO(2010/06)
http://geekhack.org/showpost.php?p=191195&postcount=251
http://geekhack.org/showthread.php?p=204389#post204389


Terminology
---------
NKRO
ghost
matrix
mechanical with diodes
membrane


OS Support Status
-----------------
USB NKRO is possible *without* a custom driver.
At least following OS's supports.
Windows7 64bit
WindowsXP
Windows2000 SP4
Ubuntu10.4(Linux 2.6)
MacOSX(To be tested)


Custom Driver for USB NKRO
--------------------------
NOT NEEDED
at least when using following report formats on Windows, Linux or MacOSX.


USB NKRO methods
----------------
1. Virtual keyboards
Keyboard can increase its KRO by using virtual keyboards with Standard or Extended report.
If the keyboard has 2 virtual keyboard with Standard report(6KRO), it gets 12KRO.
Using this method means the keyboard is a composite device.

2. Extended report
It needs large report size for this method to achieve NKRO.
If a keyboard has 101keys, it needs 103byte report. It seems to be inefficient.

3. Bitmap report
If the keyboard has less than 128keys, 16byte report will be enough for NKRO.
The 16byte report seems to be reasonable cost to get NKRO.


Report Format
-------------
Other report formats than followings are possible, though these format are typical one.

1. Standard 8bytes
modifiers(bitmap) 1byte
reserved 1byte(not used)
keys(array) 1byte*6
Standard report can send 6keys plus 8modifiers simultaneously.
Standard report is used by most keyboards in the marketplace.
Standard report is identical to boot protocol report.
Standard report is hard to suffer from compatibility problems.

2. Extended standard 16,32,64bytes
modifiers(bitmap) 1byte
reserved 1byte(not used)
keys(array) 1byte*(14,32,62)
Extended report can send N-keys by using N+2bytes.
Extended report is expected to be compatible with boot protocol.

3. Bitmap 16,32,64bytes
keys(bitmap) (16,32)bytes
Bitmap report can send at most 128keys by 16bytes and 256keys by 32bytes.
Bitmap report can achieve USB NKRO efficiently in terms of report size.
Bitmap report needs a deliberation for boot protocol implementation.
Bitmap report descriptor sample:
0x05, 0x01, // Usage Page (Generic Desktop),
0x09, 0x06, // Usage (Keyboard),
0xA1, 0x01, // Collection (Application),
// bitmap of modifiers
0x75, 0x01, // Report Size (1),
0x95, 0x08, // Report Count (8),
0x05, 0x07, // Usage Page (Key Codes),
0x19, 0xE0, // Usage Minimum (224),
0x29, 0xE7, // Usage Maximum (231),
0x15, 0x00, // Logical Minimum (0),
0x25, 0x01, // Logical Maximum (1),
0x81, 0x02, // Input (Data, Variable, Absolute), ;Modifier byte
// LED output report
0x95, 0x05, // Report Count (5),
0x75, 0x01, // Report Size (1),
0x05, 0x08, // Usage Page (LEDs),
0x19, 0x01, // Usage Minimum (1),
0x29, 0x05, // Usage Maximum (5),
0x91, 0x02, // Output (Data, Variable, Absolute),
0x95, 0x01, // Report Count (1),
0x75, 0x03, // Report Size (3),
0x91, 0x03, // Output (Constant),
// bitmap of keys
0x95, (REPORT_BYTES-1)*8, // Report Count (),
0x75, 0x01, // Report Size (1),
0x15, 0x00, // Logical Minimum (0),
0x25, 0x01, // Logical Maximum(1),
0x05, 0x07, // Usage Page (Key Codes),
0x19, 0x00, // Usage Minimum (0),
0x29, (REPORT_BYTES-1)*8-1, // Usage Maximum (),
0x81, 0x02, // Input (Data, Variable, Absolute),
0xc0 // End Collection
where REPORT_BYTES is a report size in bytes.


Considerations
--------------
Compatibility
boot protocol
minor/old system
Some BIOS doesn't send SET_PROTOCOL request, a keyboard can't switch to boot protocol mode.
This may cause a problem on a keyboard which uses other report than Standard.
Reactivity
USB polling time
OS/Driver processing time


Windows Problem
---------------
1. Windows accepts only 6keys in case of Standard report.
It should be able to send 6keys plus 8modifiers.
2. Windows accepts only 10keys in case of 16bytes Extended report.
It should be able to send 14keys plus 8modifiers.
3. Windows accepts only 18keys in case of 32bytes Extended report.
It should be able to send 30keys plus 8modifiers.
If keys are pressed in excess of the number, wrong keys are registered on Windows.

This problem will be reportedly fixed soon.(2010/12/05)
http://forums.anandtech.com/showpost.php?p=30873364&postcount=17


Tools for testing NKRO
----------------------
Browser App:
http://www.microsoft.com/appliedsciences/content/projects/KeyboardGhostingDemo.aspx
http://random.xem.us/rollover.html

Windows:
AquaKeyTest.exe http://geekhack.org/showthread.php?t=6643

Linux:
xkeycaps
xev
showkeys

EOF

+ 0
- 187
doc/build.md View File

@@ -1,187 +0,0 @@
Build Firmware and Program Controller
=====================================


Download and Install
--------------------
### 1. Install Tools

1. **Toolchain** On Windows install [MHV AVR Tools][mhv] for AVR GCC compiler and [Cygwin][cygwin](or [MinGW][mingw]) for shell terminal. On Mac you can use [CrossPack][crosspack]. On Linux you can install AVR GCC with your favorite package manager.

2. **Programmer** On Windows install [Atmel FLIP][flip]. On Mac and Linux install [dfu-programmer][dfu-prog].

3. **Driver** On Windows you start DFU bootloader on the chip first time you will see 'Found New Hardware Wizard' to install driver. If you install device driver properly you can find chip name like 'ATmega32U4' under 'LibUSB-Win32 Devices' tree on 'Device Manager'. If not you shall need to update its driver on 'Device Manager'. You will find the driver in `FLIP` install directory like: C:\Program Files (x86)\Atmel\Flip 3.4.5\usb\. In case of `dfu-programmer` use its driver.

If you use PJRC Teensy you don't need step 2 and 3 above, just get [Teensy loader][teensy-loader].


### 2. Download source
You can find firmware source at github:

- <https://github.com/tmk/tmk_keyboard>

If you are familiar with `Git` tools you are recommended to use it but you can also download zip archive from:

- <https://github.com/tmk/tmk_keyboard/archive/master.zip>


Build firmware
--------------
### 1. Open terminal
Open terminal window to get access to commands. Use Cygwin(or MingGW) `shell terminal` in Windows or `Terminal.app` on Mac OSX. In Windows press `Windows` key and `R` then enter `cmd` in 'Run command' dialog showing up.

### 2. Change directory
Move to project directory in the firmware source.

cd tmk_keyboard/{'keyboard' or 'converter'}/<project>

### 3. Make
Build firmware using GNU `make` command. You'll see `<project>_<variant>.hex` file in that directory unless something unexpected occurs in build process.


make -f Makefile.<variant> clean
make -f Makefile.<variant>




Program Controller
------------------
Now you have **hex** file to program on current directory. This **hex** is only needed to program your controller, other files are used for development and you may leave and forget them.

### 1. Start bootloader
How to program controller depends on controller chip and its board design. To program AVR USB chips you'll need to start it up in bootloader mode. Most of boards with the chip have a push button to let bootloader come up. Consult with your controller board manual.

### 2. Program with DFU bootloader
Stock AVR USB chip including ATmega32U4 has DFU bootloader by factory default. `FLIP` is a DFU programmer on Windows offered by Atmel. Open source command line tool `dfu-programmer` also supports AVR chips, it runs on Linux, Mac OSX and even Windows.

To program AVR chip with DFU bootloader use `FLIP` or `dfu-programmer`.
If you have a proper program command in `Makefile` just type this.

`FLIP` has two version of tool, GUI app and command line program. If you want GUI see tutorial below.
To use command line tool run this command. Note that you need to set PATH variable properly.

$ make -f Makefile.<variant> flip

Or to program with `dfu-programmer` run:

$ make -f Makefile.<variant> dfu

#### FLIP GUI tutorial
1. On menu bar click Device -> Select, then. `ATmega32u4`.
2. On menu bar click Settings -> Communication -> USB, then click 'Open' button on 'USB Port Connection' dialog.
At this point you'll see grey-outed widgets on the app get colored and ready.

3. On menu bar click File -> Load HEX File, then select your firmware hex file on File Selector dialog.
4. On 'Operations Flow' panel click 'Run' button to load the firmware binary to the chip. Note that you should keep 'Erase', 'Blank Check', 'Program' and 'Verify' check boxes selected.
5. Re-plug USB cord or click 'Start Application' button to restart your controller.
Done.

See also these instructions if you need.

- <http://code.google.com/p/micropendous/wiki/LoadingFirmwareWithFLIP>
- <http://www.atmel.com/Images/doc7769.pdf>


### 3. Program with Teensy Loader
If you have PJRC Teensy see instruction of `Teensy Loader`.

- <http://www.pjrc.com/teensy/loader.html>

Or use this command if you have command line version of Teensy Loader installed.

$ make -f Makefile.<variant> teensy


### 4. Program with Other programmer
You may want to use other programmer like `avrdude` with AVRISPmkII, Arduino or USBasp. In that case you can still use make target `program` for build with configuring `PROGRAM_CMD` in Makefile.

$ make -f Makefile.<variant> program


[cygwin]: https://www.cygwin.com/
[mingw]: http://www.mingw.org/
[mhv]: https://infernoembedded.com/products/avr-tools
[winavr]: http://winavr.sourceforge.net/
[crosspack]: http://www.obdev.at/products/crosspack/index.html
[flip]: http://www.atmel.com/tools/FLIP.aspx
[dfu-prog]: http://dfu-programmer.sourceforge.net/
[teensy-loader]:http://www.pjrc.com/teensy/loader.html



Makefile Options
----------------
### 1. MCU and Frequency.

MCU = atmega32u4 # Teensy 2.0
#MCU = at90usb1286 # Teensy++ 2.0
F_CPU = 16000000

Set your MCU and its clock in Hz.

# Boot Section Size in *bytes*
# Teensy halfKay 512
# Atmel DFU loader 4096
# LUFA bootloader 4096
OPT_DEFS += -DBOOTLOADER_SIZE=4096

If you are using PJRC Teensy use `512` for `BOOTLOADER_SIZE`, otherwise use `4096` unless you are sure.

### 2. Features
Optional. Note that ***comment out*** with `#` to disable them.

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
#BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
#KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom

### 3. Programmer
Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`.

# avrdude with AVRISPmkII
PROGRAM_CMD = avrdude -p $(MCU) -c avrispmkII -P USB -U flash:w:$(TARGET).hex

# avrdude with USBaspLoader
PROGRAM_CMD = avrdude -p $(MCU) -c usbasp -U flash:w:$(TARGET).hex

# avrdude with arduino
PROGRAM_CMD = avrdude -p $(MCU) -c arduino -P COM1 -b 57600 -U flash:w:$(TARGET).hex



Config.h Options
----------------
### 1. Magic command key combination

#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KB_LSHIFT) | MOD_BIT(KB_RSHIFT)))

### 2. Mechanical Locking Support for CapsLock

/* Mechanical locking CapsLock support. Use KC_LCAP instead of KC_CAPS in keymap */
#define CAPSLOCK_LOCKING_ENABLE
/* Locking CapsLock re-synchronize hack */
#define CAPSLOCK_LOCKING_RESYNC_ENABLE

### 3. Disable Debug and Print

/* disable debug print */
#define NO_DEBUG

/* disable print */
#define NO_PRINT

### 4. Disable Action Features

#define NO_ACTION_LAYER
#define NO_ACTION_TAPPING
#define NO_ACTION_ONESHOT
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION

***TBD***

+ 0
- 261
doc/keycode.txt View File

@@ -1,261 +0,0 @@
Keycode Symbol Table
====================
Keycodes are defined in `common/keycode.h`.
Range of 00-A4 and E0-E7 are identical with HID Usage:
<http://www.usb.org/developers/devclass_docs/Hut1_11.pdf>
Virtual keycodes are defined out of above range to support special actions.


Keycode Symbol Short name Description
--------------------------------------------------------------------------------
KC_NO 00 Reserved (no event indicated)
KC_ROLL_OVER 01 Keyboard ErrorRollOver
KC_POST_FAIL 02 Keyboard POSTFail
KC_UNDEFINED 03 Keyboard ErrorUndefined
KC_A 04 Keyboard a and A
KC_B 05 Keyboard b and B
KC_C 06 Keyboard c and C
KC_D 07 Keyboard d and D
KC_E 08 Keyboard e and E
KC_F 09 Keyboard f and F
KC_G 0A Keyboard g and G
KC_H 0B Keyboard h and H
KC_I 0C Keyboard i and I
KC_J 0D Keyboard j and J
KC_K 0E Keyboard k and K
KC_L 0F Keyboard l and L
KC_M 10 Keyboard m and M
KC_N 11 Keyboard n and N
KC_O 12 Keyboard o and O
KC_P 13 Keyboard p and P
KC_Q 14 Keyboard q and Q
KC_R 15 Keyboard r and R
KC_S 16 Keyboard s and S
KC_T 17 Keyboard t and T
KC_U 18 Keyboard u and U
KC_V 19 Keyboard v and V
KC_W 1A Keyboard w and W
KC_X 1B Keyboard x and X
KC_Y 1C Keyboard y and Y
KC_Z 1D Keyboard z and Z
KC_1 1E Keyboard 1 and !
KC_2 1F Keyboard 2 and @
KC_3 20 Keyboard 3 and #
KC_4 21 Keyboard 4 and $
KC_5 22 Keyboard 5 and %
KC_6 23 Keyboard 6 and ^
KC_7 24 Keyboard 7 and &
KC_8 25 Keyboard 8 and *
KC_9 26 Keyboard 9 and (
KC_0 27 Keyboard 0 and )
KC_ENTER KC_ENT 28 Keyboard Return (ENTER)
KC_ESCAPE KC_ESC 29 Keyboard ESCAPE
KC_BSPACE KC_BSPC 2A Keyboard DELETE (Backspace)
KC_TAB 2B Keyboard Tab
KC_SPACE KC_SPC 2C Keyboard Spacebar
KC_MINUS KC_MINS 2D Keyboard - and (underscore)
KC_EQUAL KC_EQL 2E Keyboard = and +
KC_LBRACKET KC_LBRC 2F Keyboard [ and {
KC_RBRACKET KC_RBRC 30 Keyboard ] and }
KC_BSLASH KC_BSLS 31 Keyboard \ and |
KC_NONUS_HASH KC_NUHS 32 Keyboard Non-US # and ~
KC_SCOLON KC_SCLN 33 Keyboard ; and :
KC_QUOTE KC_QUOT 34 Keyboard ‘ and “
KC_GRAVE KC_GRV 35 Keyboard Grave Accent and Tilde
KC_COMMA KC_COMM 36 Keyboard, and <
KC_DOT 37 Keyboard . and >
KC_SLASH KC_SLSH 38 Keyboard / and ?
KC_CAPSLOCK KC_CAPS 39 Keyboard Caps Lock
KC_F1 3A Keyboard F1
KC_F2 3B Keyboard F2
KC_F3 3C Keyboard F3
KC_F4 3D Keyboard F4
KC_F5 3E Keyboard F5
KC_F6 3F Keyboard F6
KC_F7 40 Keyboard F7
KC_F8 41 Keyboard F8
KC_F9 42 Keyboard F9
KC_F10 43 Keyboard F10
KC_F11 44 Keyboard F11
KC_F12 45 Keyboard F12
KC_PSCREEN KC_PSCR 46 Keyboard PrintScreen1
KC_SCKLOCK KC_SLCK 47 Keyboard Scroll Lock11
KC_PAUSE KC_PAUS 48 Keyboard Pause1
KC_INSERT KC_INS 49 Keyboard Insert1
KC_HOME 4A Keyboard Home1
KC_PGUP 4B Keyboard PageUp1
KC_DELETE KC_DELETE 4C Keyboard Delete Forward
KC_END 4D Keyboard End1
KC_PGDOWN KC_PGDN 4E Keyboard PageDown1
KC_RIGHT KC_RGHT 4F Keyboard RightArrow1
KC_LEFT 50 Keyboard LeftArrow1
KC_DOWN 51 Keyboard DownArrow1
KC_UP 52 Keyboard UpArrow1
KC_NUMLOCK KC_NLCK 53 Keypad Num Lock and Clear11
KC_KP_SLASH KC_PSLS 54 Keypad /1
KC_KP_ASTERISK KC_PAST 55 Keypad *
KC_KP_MINUS KC_PMNS 56 Keypad -
KC_KP_PLUS KC_PPLS 57 Keypad +
KC_KP_ENTER KC_PENT 58 Keypad ENTER5
KC_KP_1 KC_P1 59 Keypad 1 and End
KC_KP_2 KC_P2 5A Keypad 2 and Down Arrow
KC_KP_3 KC_P3 5B Keypad 3 and PageDn
KC_KP_4 KC_P4 5C Keypad 4 and Left Arrow
KC_KP_5 KC_P5 5D Keypad 5
KC_KP_6 KC_P6 5E Keypad 6 and Right Arrow
KC_KP_7 KC_P7 5F Keypad 7 and Home
KC_KP_8 KC_P8 60 Keypad 8 and Up Arrow
KC_KP_9 KC_P9 61 Keypad 9 and PageUp
KC_KP_0 KC_P0 62 Keypad 0 and Insert
KC_KP_DOT KC_PDOT 63 Keypad . and Delete
KC_NONUS_BSLASH KC_NUBS 64 Keyboard Non-US \ and |
KC_APPLICATION KC_APP 65 Keyboard Application10
KC_POWER 66 Keyboard Power9
KC_KP_EQUAL KC_PEQL 67 Keypad =
KC_F13 68 Keyboard F13
KC_F14 69 Keyboard F14
KC_F15 6A Keyboard F15
KC_F16 6B Keyboard F16
KC_F17 6C Keyboard F17
KC_F18 6D Keyboard F18
KC_F19 6E Keyboard F19
KC_F20 6F Keyboard F20
KC_F21 70 Keyboard F21
KC_F22 71 Keyboard F22
KC_F23 72 Keyboard F23
KC_F24 73 Keyboard F24
KC_EXECUTE 74 Keyboard Execute
KC_HELP 75 Keyboard Help
KC_MENU 76 Keyboard Menu
KC_SELECT 77 Keyboard Select
KC_STOP 78 Keyboard Stop
KC_AGAIN 79 Keyboard Again
KC_UNDO 7A Keyboard Undo
KC_CUT 7B Keyboard Cut
KC_COPY 7C Keyboard Copy
KC_PASTE 7D Keyboard Paste
KC_FIND 7E Keyboard Find
KC__MUTE 7F Keyboard Mute
KC__VOLUP 80 Keyboard Volume Up
KC__VOLDOWN 81 Keyboard Volume Down
KC_LOCKING_CAPS 82 Keyboard Locking Caps Lock12
KC_LOCKING_NUM 83 Keyboard Locking Num Lock12
KC_LOCKING_SCROLL 84 Keyboard Locking Scroll Lock12
KC_KP_COMMA KC_PCMM 85 Keypad Comma27
KC_KP_EQUAL_AS400 86 Keypad Equal Sign29
KC_INT1 KC_RO 87 Keyboard International115,28
KC_INT2 KC_KANA 88 Keyboard International216
KC_INT3 KC_JYEN 89 Keyboard International317
KC_INT4 KC_HENK 8A Keyboard International418
KC_INT5 KC_MHEN 8B Keyboard International519
KC_INT6 8C Keyboard International620
KC_INT7 8D Keyboard International721
KC_INT8 8E Keyboard International822
KC_INT9 8F Keyboard International922
KC_LANG1 90 Keyboard LANG125
KC_LANG2 91 Keyboard LANG226
KC_LANG3 92 Keyboard LANG330
KC_LANG4 93 Keyboard LANG431
KC_LANG5 94 Keyboard LANG532
KC_LANG6 95 Keyboard LANG68
KC_LANG7 96 Keyboard LANG78
KC_LANG8 97 Keyboard LANG88
KC_LANG9 98 Keyboard LANG98
KC_ALT_ERASE 99 Keyboard Alternate Erase7
KC_SYSREQ 9A Keyboard SysReq/Attention1
KC_CANCEL 9B Keyboard Cancel
KC_CLEAR 9C Keyboard Clear
KC_PRIOR 9D Keyboard Prior
KC_RETURN 9E Keyboard Return
KC_SEPARATOR 9F Keyboard Separator
KC_OUT A0 Keyboard Out
KC_OPER A1 Keyboard Oper
KC_CLEAR_AGAIN A2 Keyboard Clear/Again
KC_CRSEL A3 Keyboard CrSel/Props
KC_EXSEL A4 Keyboard ExSel
/* Modifiers */
KC_LCTRL KC_LCTL E0 Keyboard LeftControl
KC_LSHIFT KC_LSFT E1 Keyboard LeftShift
KC_LALT E2 Keyboard LeftAlt
KC_LGUI E3 Keyboard Left GUI(Windows/Apple/Meta key)
KC_RCTRL KC_RCTL E4 Keyboard RightControl
KC_RSHIFT KC_RSFT E5 Keyboard RightShift
KC_RALT E6 Keyboard RightAlt
KC_RGUI E7 Keyboard Right GUI(Windows/Apple/Meta key)

/*
* Virtual keycodes
*/
/* System Control */
KC_SYSTEM_POWER KC_PWR System Power Down
KC_SYSTEM_SLEEP KC_SLEP System Sleep
KC_SYSTEM_WAKE KC_WAKE System Wake
/* Consumer Page */
KC_AUDIO_MUTE KC_MUTE
KC_AUDIO_VOL_UP KC_VOLU
KC_AUDIO_VOL_DOWN KC_VOLD
KC_MEDIA_NEXT_TRACK KC_MNXT
KC_MEDIA_PREV_TRACK KC_MPRV
KC_MEDIA_STOP KC_MSTP
KC_MEDIA_PLAY_PAUSE KC_MPLY
KC_MEDIA_SELECT KC_MSEL
KC_MAIL KC_MAIL
KC_CALCULATOR KC_CALC
KC_MY_COMPUTER KC_MYCM
KC_WWW_SEARCH KC_WSCH
KC_WWW_HOME KC_WHOM
KC_WWW_BACK KC_WBAK
KC_WWW_FORWARD KC_WFWD
KC_WWW_STOP KC_WSTP
KC_WWW_REFRESH KC_WREF
KC_WWW_FAVORITES KC_WFAV
/* Mousekey */
KC_MS_UP KC_MS_U Mouse Cursor Up
KC_MS_DOWN KC_MS_D Mouse Cursor Down
KC_MS_LEFT KC_MS_L Mouse Cursor Left
KC_MS_RIGHT KC_MS_R Mouse Cursor Right
KC_MS_BTN1 KC_BTN1 Mouse Button 1
KC_MS_BTN2 KC_BTN2 Mouse Button 2
KC_MS_BTN3 KC_BTN3 Mouse Button 3
KC_MS_BTN4 KC_BTN4 Mouse Button 4
KC_MS_BTN5 KC_BTN5 Mouse Button 5
KC_MS_WH_UP KC_WH_U Mouse Wheel Up
KC_MS_WH_DOWN KC_WH_D Mouse Wheel Down
KC_MS_WH_LEFT KC_WH_L Mouse Wheel Left
KC_MS_WH_RIGHT KC_WH_R Mouse Wheel Right
KC_MS_ACCEL0 KC_ACL0 Mouse Acceleration 0
KC_MS_ACCEL1 KC_ACL1 Mouse Acceleration 1
KC_MS_ACCEL2 KC_ACL2 Mouse Acceleration 2
/* Fn key */
KC_FN0
KC_FN1
KC_FN2
KC_FN3
KC_FN4
KC_FN5
KC_FN6
KC_FN7
KC_FN8
KC_FN9
KC_FN10
KC_FN11
KC_FN12
KC_FN13
KC_FN14
KC_FN15
KC_FN16
KC_FN17
KC_FN18
KC_FN19
KC_FN20
KC_FN21
KC_FN22
KC_FN23
KC_FN24
KC_FN25
KC_FN26
KC_FN27
KC_FN28
KC_FN29
KC_FN30
KC_FN31

+ 0
- 593
doc/keymap.md View File

@@ -1,593 +0,0 @@
Keymap framework - how to define your keymap
============================================
***NOTE: This is not final version, may be inconsistent with source code and changed occasionally for a while.***

## 0. Keymap and layers
**Keymap** is comprised of multiple layers of key layout, you can define **32 layers** at most.
**Layer** is an array of **keycodes** to define **actions** for each physical keys.
respective layers can be validated simultaneously. Layers are indexed with 0 to 31 and higher layer has precedence.

Keymap: 32 Layers Layer: Keycode matrix
----------------- ---------------------
stack of layers array_of_keycode[row][column]
____________ precedence _______________________
/ / | high / ESC / F1 / F2 / F3 ....
31 /___________// | /-----/-----/-----/-----
30 /___________// | / TAB / Q / W / E ....
29 /___________/ | /-----/-----/-----/-----
: _:_:_:_:_:__ | : /LCtrl/ A / S / D ....
: / : : : : : / | : / : : : :
2 /___________// | 2 `--------------------------
1 /___________// | 1 `--------------------------
0 /___________/ V low 0 `--------------------------



### 0.1 Keymap status
Keymap has its state in two parameters:
**`default_layer`** indicates a base keymap layer(0-31) which is always valid and to be referred, **`keymap_stat`** is 16bit variable which has current on/off status of layers on its each bit.

Keymap layer '0' is usually `default_layer` and which is the only valid layer and other layers is initially off after boot up firmware, though, you can configured them in `config.h`.
To change `default_layer` will be useful when you switch key layout completely, say you want Colmak instead of Qwerty.

Initial state of Keymap Change base layout
----------------------- ------------------

31 31
30 30
29 29
: :
: : ____________
2 ____________ 2 / /
1 / / ,->1 /___________/
,->0 /___________/ | 0
| |
`--- default_layer = 0 `--- default_layer = 1
layer_state = 0x00000001 layer_state = 0x00000002

On the other hand, you shall change `layer_state` to overlay base layer with some layers for feature such as navigation keys, function key(F1-F12), media keys or special actions.

Overlay feature layer
--------------------- bit|status
____________ ---+------
31 / / 31 | 0
30 /___________// -----> 30 | 1
29 /___________/ -----> 29 | 1
: : | :
: ____________ : | :
2 / / 2 | 0
,->1 /___________/ -----> 1 | 1
| 0 0 | 0
| +
`--- default_layer = 1 |
layer_state = 0x60000002 <-'



### 0.2 Layer Precedence and Transparency
Note that ***higher layer has higher priority on stack of layers***, namely firmware falls down from top layer to bottom to look up keycode. Once it spots keycode other than **`KC_TRNS`**(transparent) on a layer it stops searching and lower layers aren't referred.

You can place `KC_TRNS` on overlay layer changes just part of layout to fall back on lower or base layer.
Key with `KC_TRANS` doesn't has its own keycode and refers to lower valid layers for keycode, instead.
See example below.


### 0.3 Keymap Example
Keymap is **`keymaps[]`** C array in fact and you can define layers in it with **`KEYMAP()`** C macro and keycodes. To use complex actions you need to define `Fn` keycode in **`fn_actions[]`** array.

This is a keymap example for [HHKB](http://en.wikipedia.org/wiki/Happy_Hacking_Keyboard) keyboard.
This example has three layers, 'Qwerty' as base layer, 'Cursor' and 'Mousekey'.
In this example,

`Fn0` is a **momentary layer switching** key, you can use keys on Cursor layer while holding the key.

`Fn1` is a momentary layer switching key with tapping feature, you can get semicolon **';'** with taping the key and switch layers while holding the key. The word **'tap'** or **'tapping'** mean to press and release a key quickly.

`Fn2` is a **toggle layer switch** key, you can stay switched layer after releasing the key unlike momentary switching.

You can find other keymap definitions in file `keymap.c` located on project directories.

static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: Qwerty
* ,-----------------------------------------------------------.
* |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|Fn1| '|Enter |
* |-----------------------------------------------------------|
* |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0|
* `-----------------------------------------------------------'
* |Gui|Alt |Space |Alt |Fn2|
* `-------------------------------------------'
*/
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, FN1, QUOT,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \
LGUI,LALT, SPC, RALT,FN2),
/* 1: Cursor(HHKB mode)
* ,-----------------------------------------------------------.
* |Pwr| 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|
* `--------------------------------------------'
*/
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, \
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,TRNS, \
LGUI,LALT, SPC, RALT,RGUI),
/* 2: Mousekey
* ,-----------------------------------------------------------.
* |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| | |Return |
* |-----------------------------------------------------------|
* |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | |
* `-----------------------------------------------------------'
* |Gui |Alt |Mb1 |Alt | |
* `--------------------------------------------'
* Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
*/
KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,BSPC, \
LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,TRNS, \
LGUI,LALT, BTN1, RALT,TRNS),
};

static const uint16_t PROGMEM fn_actions[] = {
ACTION_LAYER_MOMENTARY(1), // FN0
ACTION_LAYER_TAP_KEY(2, KC_SCLN), // FN1
ACTION_LAYER_TOGGLE(2), // FN2
};




## 1. Keycode
See [`common/keycode.h`](../common/keycode.h) or keycode table below for the detail. Keycode is internal **8bit code** to indicate action performed on key in keymap. Keycode has `KC_` prefixed symbol respectively. Most of keycodes like `KC_A` have simple action registers key to host on press and unregister on release, while some of other keycodes has some special actions like `Fn` keys, Media control keys, System control keys and Mousekeys.

***In `KEYMAP()` macro you should omit prefix part `KC_` of keycode to keep keymap compact.*** For example, just use `A` instead you place `KC_A` in `KEYMAP()`. Some keycodes has 4-letter **short name** in addition to descriptive name, you'll prefer short one in `KEYMAP()`.

### 1.0 Other key
- `KC_NO` for no action
- `KC_TRNS` for layer transparency (See above)

### 1.1 Normal key
- `KC_A` to `KC_Z`, `KC_1` to `KC_0` for alpha numeric key
- `KC_MINS`, `KC_EQL`, `KC_GRV`, `KC_RBRC`, `KC_LBRC`, `KC_COMM`, `KC_DOT`, `KC_BSLS`, `KC_SLSH`, `KC_SCLN`, `KC_QUOT`
- `KC_ESC`, `KC_TAB`, `KC_SPC`, `KC_BSPC`, `KC_ENT`, `KC_DEL`, `KC_INS`
- `KC_UP`, `KC_DOWN`, `KC_RGHT`, `KC_LEFT`, `KC_PGUP`, `KC_PGDN`, `KC_HOME`, `KC_END`
- `KC_CAPS`, `KC_NLCK`, `KC_SLCK`, `KC_PSCR`, `KC_PAUS`, `KC_APP`, `KC_F1` to `KC_F24`
- `KC_P1` to `KC_P0`, `KC_PDOT`, `KC_PCMM`, `KC_PSLS`, `KC_PAST`, `KC_PMNS`, `KC_PPLS`, `KC_PEQL`, `KC_PENT` for keypad.

### 1.2 Modifier
There are 8 modifiers which has discrimination between left and right.

- `KC_LCTL` and `KC_RCTL` for Control
- `KC_LSFT` and `KC_RSFT` for Shift
- `KC_LALT` and `KC_RALT` for Alt
- `KC_LGUI` and `KC_RGUI` for Windows key or Command key in Mac

### 1.3 Mousekey
- `KC_MS_U`, `KC_MS_D`, `KC_MS_L`, `KC_MS_R` for mouse cursor
- `KC_WH_U`, `KC_WH_D`, `KC_WH_L`, `KC_WH_R` for mouse wheel
- `KC_BTN1`, `KC_BTN2`, `KC_BTN3`, `KC_BTN4`, `KC_BTN5` for mouse buttons

### 1.4 System & Media key
- `KC_PWR`, `KC_SLEP`, `KC_WAKE` for Power, Sleep, Wake
- `KC_MUTE`, `KC_VOLU`, `KC_VOLD` for audio volume control
- `KC_MNXT`, `KC_MPRV`, `KC_MSTP`, `KC_MPLY`, `KC_MSEL` for media control
- `KC_MAIL`, `KC_CALC`, `KC_MYCM` for application launch
- `KC_WSCH`, `KC_WHOM`, `KC_WBAK`, `KC_WFWD`, `KC_WSTP`, `KC_WREF`, `KC_WFAV` for web browser operation

### 1.5 Fn key
`KC_FNnn` are keycodes for `Fn` key which not given any actions at the beginning unlike most of keycodes has its own inborn action. To use these keycodes in `KEYMAP()` you need to assign action you want at first. Action of `Fn` key is defined in `fn_actions[]` and its index of the array is identical with number part of `KC_FNnn`. Thus `KC_FN0` keycode indicates the action defined in first element of the array. ***32 `Fn` keys can be defined at most.***

### 1.6 Keycode Table
See keycode table in [`doc/keycode.txt`](./keycode.txt) for description of keycodes.

In regard to implementation side most of keycodes are identical with [HID usage][HID_usage](pdf) sent to host for real and some virtual keycodes are defined to support special actions.
[HID_usage]: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf



## 2. Action
See [`common/action_code.h`](../common/action_code.h). Action is a **16bit code** and defines function to perform on events of a key like press, release, holding and tapping.

Most of keys just register 8bit scancode to host, but to support other complex features needs 16bit extended action codes internally. However, using 16bit action codes in keymap results in double size in memory compared to using just keycodes. To avoid this waste 8bit keycodes are used in `KEYMAP()` instead of action codes.

***You can just use keycodes of `Normal key`, `Modifier`, `Mousekey` and `System & Media key` in keymap*** to indicate corresponding actions instead of using action codes. While ***to use other special actions you should use keycode of `Fn` key defined in `fn_actions[]`.***


### 2.1 Key Action
This is a simple action that registers scancodes(HID usage in fact) to host on press event of key and unregister on release.

#### Parameters
+ **mods**: { ` MOD_LCTL`, ` MOD_LSFT`, ` MOD_LALT`, ` MOD_LGUI`,
` MOD_RCTL`, ` MOD_RSFT`, ` MOD_RALT`, ` MOD_RGUI` }
+ **key**: keycode


#### 2.1.1 Normal key and Modifier
***This action usually won't be used expressly in keymap*** because you can just use keycodes in `KEYMAP()` instead.

You can define these actions on *'A'* key and *'left shift'* modifier with:

ACTION_KEY(KC_A)
ACTION_KEY(KC_LSFT)

#### 2.1.2 Modified key
This action is comprised of strokes of modifiers and a key. `Macro` action is needed if you want more complex key strokes.

Say you want to assign a key to `Shift + 1` to get character *'!'* or `Alt + Tab` to switch application windows.

ACTION_MODS_KEY(MOD_LSFT, KC_1)
ACTION_MODS_KEY(MOD_LALT, KC_TAB)

Or `Alt,Shift + Tab` can be defined. `ACTION_MODS_KEY(mods, key)` requires **4-bit modifier state** and a **keycode** as arguments. See `keycode.h` for `MOD_BIT()` macro.

ACTION_MODS_KEY(MOD_LALT | MOD_LSFT, KC_TAB)

#### 2.1.3 Multiple Modifiers
Registers multiple modifiers with pressing a key. To specify multiple modifiers use `|`.

ACTION_MODS(MOD_ALT | MOD_LSFT)

#### 2.1.3 Modifier with Tap key([Dual role][dual_role])
Works as a modifier key while holding, but registers a key on tap(press and release quickly).


ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT)



### 2.2 Layer Action
These actions operate layers of keymap.

#### Parameters
You can specify a **target layer** of action and **when the action is executed**. Some actions take a **bit value** for bitwise operation.


+ **layer**: `0`-`31`
+ **on**: { `ON_PRESS` | `ON_RELEASE` | `ON_BOTH` }
+ **bits**: 4-bit value and 1-bit mask bit


#### 2.2.1 Default Layer
Default Layer is a layer which always is valid and referred to when actions is not defined on other overlay layers.

This sets Default Layer to given parameter `layer` and activate it.

ACTION_DEFAULT_LAYER_SET(layer)


#### 2.2.2 Momentary
Turns on `layer` momentarily while holding, in other words it activates when key is pressed and deactivate when released.

ACTION_LAYER_MOMENTARY(layer)


#### 2.2.3 Toggle Switch
Turns on `layer` with first type(press and release) and turns off with next.

ACTION_LAYER_TOGGLE(layer)


#### 2.2.4 Momentary Switch with tap key
Turns on `layer` momentary while holding, but registers key on tap(press and release quickly).

ACTION_LAYER_TAP_KEY(layer, key)


#### 2.2.5 Momentary Switch with tap toggle
Turns on `layer` momentary while holding and toggles it with serial taps.

ACTION_LAYER_TAP_TOGGLE(layer)


#### 2.2.6 Invert state of layer
Inverts current state of `layer`. If the layer is on it becomes off with this action.

ACTION_LAYER_INVERT(layer, on)


#### 2.2.7 Turn On layer
Turns on layer state.

ACTION_LAYER_ON(layer, on)

Turns on layer state on press and turns off on release.

ACTION_LAYER_ON_OFF(layer)


#### 2.2.8 Turn Off layer
Turns off layer state.

ACTION_LAYER_OFF(layer, on)

Turns off layer state on press and activates on release.

ACTION_LAYER_OFF_ON(layer)


#### 2.2.9 Set layer
Turn on layer only.
`layer_state = (1<<layer) [layer: 0-31]`

ACTION_LAYER_SET(layer, on)

Turns on layer only and clear all layer on release..

ACTION_LAYER_SET_CLEAR(layer)


#### 2.2.10 Bitwise operation

**part** indicates which part of 32bit layer state(0-7). **bits** is 5-bit value. **on** indicates when the action is executed.

ACTION_LAYER_BIT_AND(part, bits, on)
ACTION_LAYER_BIT_OR(part, bits, on)
ACTION_LAYER_BIT_XOR(part, bits, on)
ACTION_LAYER_BIT_SET(part, bits, on)

These actions works with parameters as following code.

uint8_t shift = part*4;
uint32_t mask = (bits&0x10) ? ~(0xf<<shift) : 0;
uint32_t layer_state = layer_state <bitop> ((bits<<shift)|mask);


Default Layer also has bitwise operations, they are executed when key is released.

ACTION_DEFAULT_LAYER_BIT_AND(part, bits)
ACTION_DEFAULT_LAYER_BIT_OR(part, bits)
ACTION_DEFAULT_LAYER_BIT_XOR(part, bits)
ACTION_DEFAULT_LAYER_BIT_SET(part, bits)



### 2.3 Macro action
***TBD***

`Macro` action indicates complex key strokes.
MACRO( D(LSHIFT), D(D), END )
MACRO( U(D), U(LSHIFT), END )
MACRO( I(255), T(H), T(E), T(L), T(L), W(255), T(O), END )

#### 2.3.1 Macro Commands
- **I()** change interval of stroke.
- **D()** press key
- **U()** release key
- **T()** type key(press and release)
- **W()** wait
- **END** end mark

#### 2.3.2 Examples

***TODO: sample implementation***
See `keyboard/hhkb/keymap.c` for sample.



### 2.4 Function action
***TBD***

There are two type of action, normal `Function` and tappable `Function`.
These actions call user defined function with `id`, `opt`, and key event information as arguments.

#### 2.4.1 Function
To define normal `Function` action in keymap use this.

ACTION_FUNCTION(id, opt)

#### 2.4.2 Function with tap
To define tappable `Function` action in keymap use this.

ACTION_FUNCTION_TAP(id, opt)

#### 2.4.3 Implement user function
`Function` actions can be defined freely with C by user in callback function:

void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt)

This C function is called every time key is operated, argument `id` selects action to be performed and `opt` can be used for option. Function `id` can be 0-255 and `opt` can be 0-15.

`keyrecord_t` is comprised of key event and tap count. `keyevent_t` indicates which and when key is pressed or released. From `tap_count` you can know tap state, 0 means no tap. These information will be used in user function to decide how action of key is performed.

typedef struct {
keyevent_t event;
uint8_t tap_count;
} keyrecord_t;

typedef struct {
key_t key;
bool pressed;
uint16_t time;
} keyevent_t;

typedef struct {
uint8_t col;
uint8_t row;
} key_t;

***TODO: sample implementation***
See `keyboard/hhkb/keymap.c` for sample.



### 2.5 Backlight Action
These actions control the backlight.

#### 2.5.1 Change backlight level
Increase backlight level.

ACTION_BACKLIGHT_INCREASE()

Decrease backlight level.

ACTION_BACKLIGHT_DECREASE()

Step through backlight levels.

ACTION_BACKLIGHT_STEP()

Turn a specific backlight level on or off.

ACTION_BACKLIGHT_LEVEL(1)

#### 2.5.2 Turn on / off backlight
Turn the backlight on and off without changing level.

ACTION_BACKLIGHT_TOGGLE()



## 3. Layer switching Example
There are some ways to switch layer with 'Layer' actions.

### 3.1 Momentary switching
Momentary switching changes layer only while holding Fn key.

This action makes 'Layer 1' active(valid) on key press event and inactive on release event. Namely you can overlay a layer on lower layers or default layer temporarily with this action.

ACTION_LAYER_MOMENTARY(1)


Note that after switching on press the actions on destination layer(Layer 1) are performed.
***Thus you shall need to place an action to go back on destination layer***, or you will be stuck in destination layer without way to get back. Usually you need to place same action or 'KC_TRNS` on destination layer to get back.


### 3.2 Toggle switching
Toggle switching performed after releasing a key. With this action you can keep staying on the destination layer until you type the key again to return.

This performs toggle switching action of 'Layer 2'.

ACTION_LAYER_TOGGLE(2)



### 3.3 Momentary switching with Tap key
These actions switch a layer only while holding a key but register the key on tap. **Tap** means to press and release a key quickly.

ACTION_LAYER_TAP_KEY(2, KC_SCLN)

With this you can place a layer switching action on normal key like ';' without losing its original key register function. This action allows you to have layer switching action without necessity of a dedicated key. It means you can have it even on home row of keyboard.



### 3.4 Momentary switching with Tap Toggle
This switches layer only while holding a key but toggle layer with several taps. **Tap** means to press and release key quickly.

ACTION_LAYER_TAP_TOGGLE(1)

Number of taps can be configured with `TAPPING_TOGGLE` in `config.h`, `5` by default.



### 3.5 Momentary switching with Modifiers
This registers modifier key(s) simultaneously with layer switching.

ACTION_LAYER_MODS(2, MOD_LSFT | MOD_LALT)



## 4. Tapping
Tapping is to press and release a key quickly. Tapping speed is determined with setting of `TAPPING_TERM`, which can be defined in `config.h`, 200ms by default.

### 4.1 Tap Key
This is a feature to assign normal key action and modifier including layer switching to just same one physical key. This is a kind of [Dual role key][dual_role]. It works as modifier when holding the key but registers normal key when tapping.

Modifier with tap key:

ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV)

Layer switching with tap key:

ACTION_LAYER_TAP_KEY(2, KC_SCLN)

[dual_role]: http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys


### 4.2 Tap Toggle
This is a feature to assign both toggle layer and momentary switch layer action to just same one physical key. It works as momentary layer switch when holding a key but toggle switch with several taps.

ACTION_LAYER_TAP_TOGGLE(1)


### 4.3 Oneshot Modifier
This runs onetime effects which modify only on just one following key. It works as normal modifier key when holding down while oneshot modifier when tapping.

ACTION_MODS_ONESHOT(MOD_LSFT)

Say you want to type 'The', you have to push and hold Shift key before type 't' then release it before type 'h' and 'e', otherwise you'll get 'THe' or 'the' unintentionally. With Oneshot Modifier you can tap Shift then type 't', 'h' and 'e' normally, you don't need to holding Shift key properly here. This mean you can release Shift before 't' is pressed down.

Oneshot effect is cancel unless following key is pressed down within `ONESHOT_TIMEOUT` of `config.h`. No timeout when it is `0` or not defined.


### 4.4 Tap Toggle Mods
Similar to layer tap toggle, this works as a momentary modifier when holding, but toggles on with several taps. A single tap will 'unstick' the modifier again.

ACTION_MODS_TAP_TOGGLE(MOD_LSFT)




## 5. Legacy Keymap
This was used in prior version and still works due to legacy support code in `common/keymap.c`. Legacy keymap doesn't support many of features that new keymap offers. ***It is not recommended to use Legacy Keymap for new project.***

To enable Legacy Keymap support define this macro in `config.h`.

#define USE_LEGACY_KEYMAP

Legacy Keymap uses two arrays `fn_layer[]` and `fn_keycode[]` to define Fn key. The index of arrays corresponds with postfix number of `Fn` key. Array `fn_layer[]` indicates destination layer to switch and `fn_keycode[]` has keycodes to send when tapping `Fn` key.

In following setting example, `Fn0`, `Fn1` and `Fn2` switch layer to 1, 2 and 2 respectively. `Fn2` registers `Space` key when tapping while `Fn0` and `Fn1` doesn't send any key.

static const uint8_t PROGMEM fn_layer[] = {
1, // Fn0
2, // Fn1
2, // Fn2
};

static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_SPC, // Fn2
};


## 6. Terminology
***TBD***
### keymap
is comprised of multiple layers.
### layer
is matrix of keycodes.
### key
is physical button on keyboard or logical switch on software.
### keycode
is codes used on firmware.
### action
is a function assigned on a key.
### layer transparency
Using transparent keycode one layer can refer key definition on other lower layer.
### layer precedence
Top layer has higher precedence than lower layers.
### tapping
is to press and release a key quickly.
### Fn key
is key which executes a special action like layer switching, mouse key, macro or etc.
### dual role key
<http://en.wikipedia.org/wiki/Modifier_key#Dual-role_keys>

+ 0
- 62
doc/other_projects.md View File

@@ -1,62 +0,0 @@
Other Keyboard Firmware Projects
================================
## PJRC USB Keyboard/Mouse Example[USB][PJRC][Teensy][AVR]
- <http://www.pjrc.com/teensy/usb_keyboard.html>
- <http://www.pjrc.com/teensy/usb_mouse.html>

## kbupgrade[USB][V-USB][AVR]
- <http://github.com/rhomann/kbupgrade>
- <http://geekhack.org/showwiki.php?title=Island:8406>

## c64key[USB][V-USB][AVR]
- <http://symlink.dk/projects/c64key/>

## rump[USB][V-USB][AVR]
- <http://mg8.org/rump/>
- <http://github.com/clee/rump>

## dulcimer[USB][V-USB][AVR]
- <http://www.schatenseite.de/dulcimer.html>

## humblehacker-keyboard[USB][LUFA][AVR][Ergo]
- <http://github.com/humblehacker>
- <http://www.humblehacker.com/keyboard/>
- <http://geekhack.org/showwiki.php?title=Island:6292>

## ps2avr[PS/2][AVR]
- <http://sourceforge.net/projects/ps2avr/>

## ErgoDox[Ergo][Split][USB][AVR]
- <http://geekhack.org/index.php?topic=22780.0>
- <https://github.com/benblazak/ergodox-firmware>
- <https://github.com/cub-uanic/tmk_keyboard>

## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR]
- <http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534.html>
- <https://github.com/frobiac/adnw>

## bpiphany's AVR-Keyboard[PJRC][AVR][USB]
- <https://github.com/BathroomEpiphanies/AVR-Keyboard>
- <http://deskthority.net/wiki/HID_Liberation_Device_-_DIY_Instructions>
- <http://deskthority.net/wiki/Phantom>

## USB-USB keyboard remapper[converter][USB-USB][AVR][Arduino]
- <http://forum.colemak.com/viewtopic.php?pid=10837>
- <https://github.com/darkytoothpaste/keymapper>

## USB-USB converter threads[converter][USB-USB]
- <http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841-30.html>
- <http://geekhack.org/index.php?topic=19458.0>

## kbdbabel.org[converter][vintage][protocol][8051]
Great resource of vintage keyboard protocol information and code

- <http://www.kbdbabel.org/>

## Haata's kiibohd Controller[converter][vintage][protocol][AVR][PJRC][Cortex]
A lots of vintage keyboard protocol supports

- <http://gitorious.org/kiibohd-controller>

## Kinesis ergonomic keyboard firmware replacement[V-USB][LUFA][Ergo]
- <https://github.com/chrisandreae/kinesis-firmware>

+ 15
- 8
keyboard/alps64/Makefile View File

@@ -48,16 +48,9 @@ TMK_DIR = ../../tmk_core
TARGET_DIR = .

# project specific files
SRC = keymap_common.c \
matrix.c \
SRC = matrix.c \
led.c

ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_plain.c $(SRC)
endif

CONFIG_H = config.h


@@ -120,6 +113,20 @@ 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"

+ 5
- 0
keyboard/alps64/Makefile.keymap_editor View File

@@ -0,0 +1,5 @@
# build firmware for keymap editor
#
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
KEYMAP = editor
include Makefile

+ 54
- 0
keyboard/alps64/actionmap_common.h View File

@@ -0,0 +1,54 @@
/*
Copyright 2015 Jun Wako <[email protected]>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef 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

+ 149
- 0
keyboard/alps64/actionmap_hasu.c View File

@@ -0,0 +1,149 @@
#include <avr/pgmspace.h>
#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),
};

+ 52
- 0
keyboard/alps64/actionmap_plain.c View File

@@ -0,0 +1,52 @@
#include <avr/pgmspace.h>
#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),
};

+ 2
- 2
keyboard/alps64/config.h View File

@@ -23,9 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define VENDOR_ID 0xFEED
#define PRODUCT_ID 0x6464
#define DEVICE_VER 0x0001
#define MANUFACTURER geekhack
#define MANUFACTURER TMK
#define PRODUCT Alps64
#define DESCRIPTION t.m.k. keyboard firmware for Alps64
#define DESCRIPTION TMK keyboard firmware for Alps64

/* key matrix size */
#define MATRIX_ROWS 8

+ 3
- 3
keyboard/alps64/keymap_common.h View File

@@ -60,11 +60,11 @@ extern const uint16_t fn_actions[];
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, NO, K27, \
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, NO, K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, NO, \
K30, K40, K50, K60, NO, K00, K10, K20 \
K31, NUBS,K42, K51, K61, K62, K71, K72, K01, K02, K11, K12, K21, ESC, \
K30, K40, K50, K60, APP, K00, K10, K20 \
)

#endif

+ 66
- 0
keyboard/alps64/keymap_editor.c View File

@@ -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),
};

+ 29
- 8
keyboard/alps64/keymap_plain.c View File

@@ -1,12 +1,33 @@
#include "keymap_common.h"

const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* 0: qwerty */
KEYMAP_AEK( \
GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, \
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, \
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, RALT,RGUI,RCTL),
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),
};
const uint16_t PROGMEM fn_actions[] = {};

+ 11
- 1
keyboard/alps64/matrix.c View File

@@ -55,6 +55,10 @@ 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
@@ -66,6 +70,12 @@ void matrix_init(void)
matrix[i] = 0;
matrix_debouncing[i] = 0;
}

//debug
debug_matrix = true;
LED_ON();
_delay_ms(500);
LED_OFF();
}

uint8_t matrix_scan(void)
@@ -147,7 +157,7 @@ static void unselect_rows(void)
DDRD &= ~0b01111111;
PORTD &= ~0b01111111;
DDRC &= ~0b00000100;
PORTD &= ~0b00000100;
PORTC &= ~0b00000100;
}

static void select_row(uint8_t row)

+ 5
- 0
keyboard/hhkb/Makefile.keymap_editor View File

@@ -0,0 +1,5 @@
# build firmware for keymap editor
#
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
include Makefile


+ 2
- 2
keyboard/hhkb/Makefile.rn42 View File

@@ -108,12 +108,12 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
#BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
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
NKRO_ENABLE = yes # USB Nkey Rollover
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
#HHKB_JP = yes # HHKB JP support


+ 3
- 0
keyboard/hhkb/Makefile.rn42.jp View File

@@ -0,0 +1,3 @@
HHKB_JP = yes
include Makefile.rn42


+ 5
- 0
keyboard/hhkb/Makefile.rn42.keymap_editor View File

@@ -0,0 +1,5 @@
# build firmware for keymap editor
#
KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
include Makefile.rn42


+ 2
- 2
keyboard/hhkb/README.md View File

@@ -46,7 +46,7 @@ See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HH


##Build Firmware & Program
See [this document](../../doc/build.md) first.
See [this document](../../tmk_core/doc/build.md) first.

### Configuration
If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`.
@@ -76,7 +76,7 @@ Use [Teensy Loader] if your controller is Teensy/Teensy++.


##Keymap
To define your own keymap create file named `keymap_<name>.c` and see [keymap document](../../doc/keymap.md) and existent keymap files.
To define your own keymap create file named `keymap_<name>.c` and see [keymap document](../../tmk_core/doc/keymap.md) and existent keymap files.


##Hardware

+ 1
- 1
keyboard/hhkb/config_rn42.h View File

@@ -48,7 +48,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define ONESHOT_TIMEOUT 300

/* Boot Magic salt key: Space */
#define BOOTMAGIC_KEY_SALT KC_FN6
#define BOOTMAGIC_KEY_SALT KC_SPACE

/* power control of key switch board */
#define HHKB_POWER_SAVING

+ 69
- 0
keyboard/hhkb/doc/HHKB_keycodes.txt View File

@@ -0,0 +1,69 @@
HHKB keycodes
=============
2015/10/03
Looked into unclear keycodes(usages) of Fn-chording-key on HHKB.
Followings are usages of Keyboard/Keypad Page(0x07) that HHKB spits out when Fn key is down.

## HHK mode(Off-Off)
Key Usage
------------------------
⌘ / ◇ 0x78 Stop

## Lite Ext. mode(On-Off)


## Mac mode(Off-On)
Key Usage
------------------------
Esc 0x66 Power
A 0x81 Volume Down
S 0x80 Volume Up
D 0x7F Mute
F 0x6F F20
Delete 0x53 Num Lock and Clear


## Secret mode(On-On)
Key Usage
------------------------
Esc 0x66 Power
Q 0x78 Stop
W 0x7E Find
E 0x74 Execute
R 0x77 Select
T 0x76 Menu
Y 0x75 Help
Z 0x7A Undo
X 0x7B Cut
C 0x7C Copy
V 0x7D Paste
B 0x79 Again


## Matrix Key-Mode


Mode
-------------------------------
Key HHK Lite Mac Secret Desc
---------------------------------------------------------------------------------------
⌘ / ◇ 0x78 - - - Stop
Esc - - 0x66 0x66 Power
A - - 0x81 - Volume Down
S - - 0x80 - Volume Up
D - - 0x7F - Mute
F - - 0x6F - F20
Delete 0x2A 0x2A 0x53 0x2A Num Lock and Clear(0x53)/Backspace(0x2A)
Q - - - 0x78 Stop
W - - - 0x7E Find
E - - - 0x74 Execute
R - - - 0x77 Select
T - - - 0x76 Menu
Y - - - 0x75 Help
Z - - - 0x7A Undo
X - - - 0x7B Cut
C - - - 0x7C Copy
V - - - 0x7D Paste
B - - - 0x79 Again

EOF

+ 0
- 0
keyboard/hhkb/keymap_hhkb.c View File


Some files were not shown because too many files changed in this diff