diff --git a/.gitmodules b/.gitmodules index 17a20decb7..e21f449613 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "protocol/usb_hid/USB_Host_Shield_2.0"] - path = protocol/usb_hid/USB_Host_Shield_2.0 - url = git@github.com:tmk/USB_Host_Shield_2.0.git [submodule "protocol/lufa/LUFA-git"] path = protocol/lufa/LUFA-git url = https://github.com/abcminiuser/lufa.git +[submodule "protocol/usb_hid/USB_Host_Shield_2.0"] + path = protocol/usb_hid/USB_Host_Shield_2.0 + url = https://github.com/felis/USB_Host_Shield_2.0.git diff --git a/README.md b/README.md index a01de8c6f8..dd03e1403d 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,16 @@ You can find some keyboard specific projects under `converter` and `keyboard` di * [macway](keyboard/macway/) - [Compact keyboard mod][GH_macway] [retired] * [KMAC](keyboard/kmac/) - Korean custom keyboard * [Lightsaber](keyboard/lightsaber/) - Korean custom keyboard +* [Infinity](keyboard/infinity/) - Massdrop [Infinity keyboard][Infinity] +* [NerD](keyboard/nerd/) - Korean custom keyboard +* [KittenPaw](keyboard/kitten_paw) - Custom Majestouch controller +* [Lightpad](keyboard/lightpad) - Korean custom keypad +* [ghost_squid](keyboard/ghost_squid/) - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt] + +### Extenal projects using tmk_keyboard +* [ErgoDox_cub-uanic][cub-uanic] - Split Ergonomic Keyboard [ErgoDox][ergodox_org] +* [mcdox][mcdox_tmk] - [mcdox][mcdox] + [GH_macway]: http://geekhack.org/showwiki.php?title=Island:11930 [GH_hhkb]: http://geekhack.org/showwiki.php?title=Island:12047 @@ -72,6 +82,13 @@ You can find some keyboard specific projects under `converter` and `keyboard` di [PC98]: http://en.wikipedia.org/wiki/NEC_PC-9801 [Sun]: http://en.wikipedia.org/wiki/Sun-3 [IIGS]: http://en.wikipedia.org/wiki/Apple_IIGS +[Infinity]: https://www.massdrop.com/buy/infinity-keyboard-kit +[ghost_squid]: http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid +[cmxt]: http://gaming.coolermaster.com/en/products/keyboards/quickfirext/ +[ergodox_org]: http://ergodox.org/ +[cub-uanic]: https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox +[mcdox]: https://github.com/DavidMcEwan/mcdox +[mcdox_tmk]: https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox @@ -276,4 +293,4 @@ Coding Style Other Keyboard Firmware Projects ------------------ -See [doc/other_projects.md](doc/other_projects.md). +You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md). diff --git a/common/avr/suspend.c b/common/avr/suspend.c index 66a579fd78..80243f02bc 100644 --- a/common/avr/suspend.c +++ b/common/avr/suspend.c @@ -7,6 +7,7 @@ #include "backlight.h" #include "suspend_avr.h" #include "suspend.h" +#include "timer.h" #ifdef PROTOCOL_LUFA #include "lufa.h" #endif @@ -52,11 +53,13 @@ void suspend_idle(uint8_t time) * WDTO_4S * WDTO_8S */ -void suspend_power_down(uint8_t wdto) +static uint8_t wdt_timeout = 0; +static void power_down(uint8_t wdto) { #ifdef PROTOCOL_LUFA if (USB_DeviceState == DEVICE_STATE_Configured) return; #endif + wdt_timeout = wdto; // Watchdog Interrupt Mode wdt_intr_enable(wdto); @@ -67,7 +70,6 @@ void suspend_power_down(uint8_t wdto) // - prescale clock // - BOD disable // - Power Reduction Register PRR - set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); sei(); @@ -78,6 +80,11 @@ void suspend_power_down(uint8_t wdto) wdt_disable(); } +void suspend_power_down(void) +{ + power_down(WDTO_15MS); +} + bool suspend_wakeup_condition(void) { matrix_power_up(); @@ -103,15 +110,13 @@ void suspend_wakeup_init(void) /* watchdog timeout */ ISR(WDT_vect) { - /* wakeup from MCU sleep mode */ -/* - // blink LED - static uint8_t led_state = 0; - static uint8_t led_count = 0; - led_count++; - if ((led_count & 0x07) == 0) { - led_set((led_state ^= (1<. */ -/* +/* * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf */ @@ -140,6 +140,8 @@ along with this program. If not, see . #define KC_VOLD KC_AUDIO_VOL_DOWN #define KC_MNXT KC_MEDIA_NEXT_TRACK #define KC_MPRV KC_MEDIA_PREV_TRACK +#define KC_MFFD KC_MEDIA_FAST_FORWARD +#define KC_MRWD KC_MEDIA_REWIND #define KC_MSTP KC_MEDIA_STOP #define KC_MPLY KC_MEDIA_PLAY_PAUSE #define KC_MSEL KC_MEDIA_SELECT @@ -390,7 +392,7 @@ enum hid_keyboard_keypad_usage { KC_RALT, KC_RGUI, - /* NOTE: 0xE8-FF are used for internal special purpose */ + /* NOTE: 0xE8-FF are used for internal special purpose */ }; /* Special keycodes */ @@ -420,7 +422,9 @@ enum internal_special_keycodes { KC_WWW_FORWARD, KC_WWW_STOP, KC_WWW_REFRESH, - KC_WWW_FAVORITES, /* 0xBA */ + KC_WWW_FAVORITES, + KC_MEDIA_FAST_FORWARD, + KC_MEDIA_REWIND, /* 0xBC */ /* Fn key */ KC_FN0 = 0xC0, diff --git a/common/matrix.h b/common/matrix.h index 23fef78f74..107ee72653 100644 --- a/common/matrix.h +++ b/common/matrix.h @@ -35,6 +35,10 @@ typedef uint32_t matrix_row_t; #define MATRIX_IS_ON(row, col) (matrix_get_row(row) && (1< -#include +#include #include "print.h" #ifndef NO_PRINT +#if defined(__AVR__) + #define sendchar(c) xputc(c) @@ -37,4 +38,11 @@ void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) xdev_out(sendchar_func); } +#elif defined(__arm__) + +// TODO +//void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { } + +#endif + #endif diff --git a/common/report.h b/common/report.h index 62190469a4..f6c0a315de 100644 --- a/common/report.h +++ b/common/report.h @@ -61,6 +61,7 @@ along with this program. If not, see . /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */ #define AL_LOCK 0x019E #define TRANSPORT_RECORD 0x00B2 +#define TRANSPORT_FAST_FORWARD 0x00B3 #define TRANSPORT_REWIND 0x00B4 #define TRANSPORT_EJECT 0x00B8 #define AC_MINIMIZE 0x0206 @@ -158,6 +159,8 @@ typedef struct { (key == KC_AUDIO_VOL_DOWN ? AUDIO_VOL_DOWN : \ (key == KC_MEDIA_NEXT_TRACK ? TRANSPORT_NEXT_TRACK : \ (key == KC_MEDIA_PREV_TRACK ? TRANSPORT_PREV_TRACK : \ + (key == KC_MEDIA_FAST_FORWARD ? TRANSPORT_FAST_FORWARD : \ + (key == KC_MEDIA_REWIND ? TRANSPORT_REWIND : \ (key == KC_MEDIA_STOP ? TRANSPORT_STOP : \ (key == KC_MEDIA_EJECT ? TRANSPORT_STOP_EJECT : \ (key == KC_MEDIA_PLAY_PAUSE ? TRANSPORT_PLAY_PAUSE : \ @@ -171,7 +174,7 @@ typedef struct { (key == KC_WWW_FORWARD ? AC_FORWARD : \ (key == KC_WWW_STOP ? AC_STOP : \ (key == KC_WWW_REFRESH ? AC_REFRESH : \ - (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))) + (key == KC_WWW_FAVORITES ? AC_BOOKMARKS : 0))))))))))))))))))))) #ifdef __cplusplus } diff --git a/common/suspend.h b/common/suspend.h index f339c670ac..80617a8244 100644 --- a/common/suspend.h +++ b/common/suspend.h @@ -6,7 +6,7 @@ void suspend_idle(uint8_t timeout); -void suspend_power_down(uint8_t timeout); +void suspend_power_down(void); bool suspend_wakeup_condition(void); void suspend_wakeup_init(void); diff --git a/converter/adb_usb/README.md b/converter/adb_usb/README.md index defc477e2c..21ad318c1d 100644 --- a/converter/adb_usb/README.md +++ b/converter/adb_usb/README.md @@ -88,7 +88,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 keyobard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI +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. https://github.com/tmk/tmk_keyboard/issues/35 diff --git a/converter/ps2_usb/Makefile.mbed b/converter/ps2_usb/Makefile.mbed index 631f270f75..ff8a0de7a4 100644 --- a/converter/ps2_usb/Makefile.mbed +++ b/converter/ps2_usb/Makefile.mbed @@ -39,6 +39,8 @@ LIBRARIES = MOUSEKEY_ENABLE = yes +#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 diff --git a/converter/terminal_bluefruit/Makefile b/converter/terminal_bluefruit/Makefile index 83d68fc252..28b7397bae 100644 --- a/converter/terminal_bluefruit/Makefile +++ b/converter/terminal_bluefruit/Makefile @@ -83,21 +83,6 @@ COMMAND_ENABLE = yes # Commands for debug and configuration PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin #PS2_USE_BUSYWAIT = yes # uses primitive reference code -ifdef PS2_USE_USART - SRC += protocol/ps2_usart.c - OPT_DEFS += -DPS2_USE_USART -endif - -ifdef PS2_USE_INT - SRC += protocol/ps2.c - OPT_DEFS += -DPS2_USE_INT -endif - -ifdef PS2_USE_BUSYWAIT - SRC += protocol/ps2.c - OPT_DEFS += -DPS2_USE_BUSYWAIT -endif - #---------------- Programming Options -------------------------- PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex @@ -107,6 +92,7 @@ VPATH += $(TARGET_DIR) VPATH += $(TOP_DIR) +include $(TOP_DIR)/protocol.mk include $(TOP_DIR)/protocol/bluefruit.mk include $(TOP_DIR)/protocol.mk include $(TOP_DIR)/common.mk diff --git a/converter/terminal_usb/Makefile b/converter/terminal_usb/Makefile index 6154d86826..16df638b94 100644 --- a/converter/terminal_usb/Makefile +++ b/converter/terminal_usb/Makefile @@ -82,21 +82,6 @@ PS2_USE_USART = yes # uses hardware USART engine for PS/2 signal receive(recomen #PS2_USE_INT = yes # uses external interrupt for falling edge of PS/2 clock pin #PS2_USE_BUSYWAIT = yes # uses primitive reference code -ifdef PS2_USE_USART - SRC += protocol/ps2_usart.c - OPT_DEFS += -DPS2_USE_USART -endif - -ifdef PS2_USE_INT - SRC += protocol/ps2.c - OPT_DEFS += -DPS2_USE_INT -endif - -ifdef PS2_USE_BUSYWAIT - SRC += protocol/ps2.c - OPT_DEFS += -DPS2_USE_BUSYWAIT -endif - #---------------- Programming Options -------------------------- PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex diff --git a/converter/usb_usb/Makefile b/converter/usb_usb/Makefile index 13f77ca9b7..d6867bb002 100644 --- a/converter/usb_usb/Makefile +++ b/converter/usb_usb/Makefile @@ -99,16 +99,22 @@ CONSOLE_ENABLE = yes # Console for debug # Teensy halfKay 512 # Atmel DFU loader 4096 # LUFA bootloader 4096 -#OPT_DEFS += -DBOOTLOADER_SIZE=4096 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 SRC = \ - keymap.c \ + keymap_common.c \ matrix.c \ led.c \ main.cpp +ifdef KEYMAP + SRC := keymap_$(KEYMAP).c $(SRC) +else + SRC := keymap.c $(SRC) +endif + CONFIG_H = config.h @@ -120,7 +126,7 @@ VPATH += $(TOP_DIR) # program Leonardo -PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -P$(DEV) -b57600 -Uflash:w:$(TARGET).hex +PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -b57600 -Uflash:w:$(TARGET).hex -P$(DEV) diff --git a/converter/usb_usb/README b/converter/usb_usb/README index a489371107..30d5deb1e5 100644 --- a/converter/usb_usb/README +++ b/converter/usb_usb/README @@ -7,7 +7,19 @@ Arduino Leonardo http://arduino.cc/en/Main/ArduinoBoardLeonardo Circuit@Home USB Host Shield 2.0 - http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino + https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/ + +Buying Arduino Leonardo and USB Host Shield 2.0(from Circuit@home) will be the easiest way, you won't need even soldering iron. +Arduino's Shield will also work well but I think Sparkfun's needs to be modified. + + http://arduino.cc/en/Main/ArduinoUSBHostShield + https://www.sparkfun.com/products/9947 + +Also Pro Micro 3.3V(not Mini) or Teensy with mini host shield will work with some fixes on signal/power routing. + https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini + https://www.sparkfun.com/products/12587 + https://www.pjrc.com/teensy/td_libs_USBHostShield.html + Build firmware @@ -19,13 +31,44 @@ Build firmware $ cd converter/usb_usb $ make -You will get usb_usb.hex if you are lucky. -Program your Leonardo with avrdude(or easy-going Arduino IDE): +Program converter. Push reset button on Leonardo before run this command. Serial port name(COM17) depends your system. On Linux I got /dev/ttyACM0. + + $ DEV=COM17 make program + or + $ avrdude -patmega32u4 -cavr109 -b57600 -Uflash:w:usb_usb.hex -PCOM17 - $ avrdude -patmega32u4 -cavr109 -PCOM17 -b57600 -Uflash:w:usb_usb.hex Limitation ---------- Only supports 'HID Boot protocol'. Not support keyboard LED yet. + +Note that the converter can host only USB "boot protocol" keyboard(6KRO) and not NKRO, it is possible to support NKRO keyboard but you will need to write HID report parser for that. Every NKRO keyboard can have different HID report and it is difficult to support all kind of NKRO keyboards in the market. + + + +Update +------ +2014/12/11 Added Hub support(confirmed with HHKB pro2) + + + +Resource +-------- +USB Host Sheild 2.0 + https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino + https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini +USB Host Sheild 2.0 source + https://github.com/felis/USB_Host_Shield_2.0 +Arduino USB Host Shield(with bootst converter) + http://arduino.cc/en/Main/ArduinoUSBHostShield +Arduino source + https://github.com/arduino/Arduino/hardware/arduino/{cores,variants} +Initial release of TMK USB-USB converter + https://geekhack.org/index.php?topic=33057.msg653549#msg653549 + http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841-30.html#p74854 +Arduino-based hardware keyboard remapper - Colemak forum + http://forum.colemak.com/viewtopic.php?id=1561 +Teensy + Host Shield + http://www.pjrc.com/teensy/td_libs_USBHostShield.html diff --git a/converter/usb_usb/config.h b/converter/usb_usb/config.h index d614973f7e..c992456763 100644 --- a/converter/usb_usb/config.h +++ b/converter/usb_usb/config.h @@ -20,7 +20,7 @@ along with this program. If not, see . #define VENDOR_ID 0xFEED -#define PRODUCT_ID 0xCAFE +#define PRODUCT_ID 0x005B #define DEVICE_VER 0x0814 #define MANUFACTURER t.m.k. #define PRODUCT USB to USB keyboard converter @@ -33,8 +33,6 @@ along with this program. If not, see . #define MATRIX_ROWS 32 #define MATRIX_COLS 8 -#define USE_LEGACY_KEYMAP - /* key combination for command */ #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) diff --git a/converter/usb_usb/keymap.c b/converter/usb_usb/keymap.c index ff166fcf1f..c14a8aa553 100644 --- a/converter/usb_usb/keymap.c +++ b/converter/usb_usb/keymap.c @@ -15,62 +15,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include -#include "keycode.h" -#include "util.h" -#include "keymap.h" +#include "keymap_common.h" -#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 \ -) { \ - { 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 */ \ -} - - -// Layers to switch by holding Fn key(0-7) -static const uint8_t PROGMEM fn_layer[] = { 5, 6, 5, 0, 0, 0, 0, 0 }; - -// Codes to register by clicking Fn key(0-7) -static const uint8_t PROGMEM fn_keycode[] = { KC_SCLN, KC_SLSH, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }; - -static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +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| @@ -86,16 +34,14 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * |-----------------------------------------------------------| ,-----------. |-----------|Ent| * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | * `-----------------------------------------------------------' `-----------' `---------------' - * ; = Fn0(to Layer 5) - * / = Fn1(to Layer 6) */ KEYMAP( ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, 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, - FN2, A, S, D, F, G, H, J, K, L, FN0, QUOT, ENT, P4, P5, P6, PPLS, - LSFT,Z, X, C, V, B, N, M, COMM,DOT, FN1, RSFT, UP, P1, P2, P3, - LCTL,LGUI,LALT, SPC, RALT,FN2, FN2, GRV, LEFT,DOWN,RGHT, P0, PDOT,PENT + 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, GRV, LEFT,DOWN,RGHT, P0, PDOT,PENT ), /* 1: plain Qwerty without layer switching @@ -185,67 +131,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 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 ), - - /* 5: Mouse keys - * ,-----------------------------------------------------------. - * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa| - * |-----------------------------------------------------------| - * |Tab |MwL|MwU|McU|WwU|WwR|MwL|MwD|MwU|MwR| | | | \| - * |-----------------------------------------------------------| - * |CapsLo| |McL|McD|McR| |McL|McD|McU|McR|Fn0| |Return | - * |-----------------------------------------------------------| - * |Shift |VoD|VoU|Mut|Mb2|Mb3|Mb2|Mb1|VoD|VoU|Mut|Shift | - * |-----------------------------------------------------------| - * |Ctrl |Gui |Alt | Mb1 |Alt |Gui |Menu|Ctrl| - * `-----------------------------------------------------------' - * Mc = mouse cursor, Mw = mouse wheel, Mb = mouse button - * Vo = Volume, Mut = Mute - */ - KEYMAP( - ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, - GRV, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, - CAPS,NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,PSCR,SLCK,PAUS,INS, DEL, END, PGDN, P7, P8, P9, - FN2, VOLD,VOLU,MUTE,NO, NO, MS_L,MS_D,MS_U,MS_R,FN0, NO, ENT, P4, P5, P6, PPLS, - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,NO, NO, NO, RSFT, UP, P1, P2, P3, - LCTL,LGUI,LALT, BTN1, RALT,FN2, FN2, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT - ), - - /* 6: Cursor keys - * ,-----------------------------------------------------------. - * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa| - * |-----------------------------------------------------------| - * |Tab |Hom|PgU| Up|PgU|End|Hom|PgD|PgU|End| | | | \| - * |-----------------------------------------------------------| - * |CapsLo| |Lef|Dow|Rig| |Lef|Dow| Up|Rig| | |Return | - * |-----------------------------------------------------------| - * |Shift | | | | | |Hom|PgD|PgU|End|Fn1|Shift | - * |-----------------------------------------------------------| - * |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, F1, F2, F3, F4, F5, F6, F7, F8, F8, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, - CAPS,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, NO, NO, NO, INS, DEL, END, PGDN, P7, P8, P9, - LCTL,NO, NO, NO, NO, NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, - LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN1, RSFT, UP, P1, P2, P3, - LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT - ), }; - - -uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) -{ - return pgm_read_byte(&keymaps[(layer)][(row)][(col)]); -} - -uint8_t keymap_fn_layer(uint8_t index) -{ - return pgm_read_byte(&fn_layer[index]); -} - -uint8_t keymap_fn_keycode(uint8_t index) -{ - return pgm_read_byte(&fn_keycode[index]); -} +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/converter/usb_usb/keymap_common.c b/converter/usb_usb/keymap_common.c new file mode 100644 index 0000000000..8ab5ba923e --- /dev/null +++ b/converter/usb_usb/keymap_common.c @@ -0,0 +1,31 @@ +/* +Copyright 2014 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "keymap_common.h" +#include "progmem.h" + + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; +} diff --git a/converter/usb_usb/keymap_common.h b/converter/usb_usb/keymap_common.h new file mode 100644 index 0000000000..435d83fdc7 --- /dev/null +++ b/converter/usb_usb/keymap_common.h @@ -0,0 +1,77 @@ +/* +Copyright 2014 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + + +#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 \ +) { \ + { 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 */ \ +} + +#endif diff --git a/converter/usb_usb/keymap_hasu.c b/converter/usb_usb/keymap_hasu.c new file mode 100644 index 0000000000..de19e23076 --- /dev/null +++ b/converter/usb_usb/keymap_hasu.c @@ -0,0 +1,158 @@ +#include "keymap_common.h" + +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + /* Layer 0: Default Layer + * ,-----------------------------------------------------------. + * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + * |-----------------------------------------------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| + * |-----------------------------------------------------------| + * |Contro| A| S| D| F| G| H| J| K| L|Fn3| '|Fn6 | + * |-----------------------------------------------------------| + * |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| + * `-----------------------------------------------------------' + * |Gui|Alt | Fn4 |Fn5 |Gui| + * `-------------------------------------------' + */ + [0] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT, FN6, P4, P5, P6, PPLS, + FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, FN4, RALT,FN5, FN5, FN1, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 1: HHKB mode[HHKB Fn] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| + * |-----------------------------------------------------------| + * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | + * |-----------------------------------------------------------| + * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [1] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, TRNS, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 2: Vi mode[Slash] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| + * |-----------------------------------------------------------| + * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | | + * `-----------------------------------------------------------' + * |Gui|Alt | Space |Alt |Gui| + * `-------------------------------------------' + */ + [2] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSLS, DEL, END, PGDN, P7, P8, P9, + LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, SPC, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 3: Mouse mode(IJKL)[Semicolon] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + */ + [3] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, FN8, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, DEL, END, PGDN, P7, P8, P9, + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, BTN1, RALT,TRNS,TRNS,RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* Layer 5: Mouse mode(IJKL)[Space] + * ,-----------------------------------------------------------. + * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + * |-----------------------------------------------------------| + * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| + * |-----------------------------------------------------------| + * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | + * |-----------------------------------------------------------| + * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | + * `-----------------------------------------------------------' + * |Gui |Alt | Mb1 |Fn |Fn | + * `--------------------------------------------' + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + */ + [4] = \ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, FN8, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, DEL, END, PGDN, P7, P8, P9, + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, P4, P5, P6, PPLS, + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, TRNS, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + + +/* + * Macro definition + */ +enum macro_id { + ALT_TAB, +}; +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + switch (id) { + case ALT_TAB: + return (record->event.pressed ? + MACRO( D(LALT), D(TAB), END ) : + MACRO( U(TAB), END )); + } + return MACRO_NONE; +} + + +/* + * Fn action definition + */ +#ifdef KEYMAP_SECTION_ENABLE +const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +#else +const uint16_t fn_actions[] PROGMEM = { +#endif + [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) + [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) + [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* + [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* + [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space + [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer + [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter + [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift + [8] = ACTION_MACRO(ALT_TAB), // Application switching +}; diff --git a/converter/usb_usb/keymap_spacefn.c b/converter/usb_usb/keymap_spacefn.c new file mode 100644 index 0000000000..bffd2bc606 --- /dev/null +++ b/converter/usb_usb/keymap_spacefn.c @@ -0,0 +1,61 @@ +/* + * SpaceFN layout + * http://geekhack.org/index.php?topic=51069.0 + */ +#include "keymap_common.h" + + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: default + * ,---. ,---------------. ,---------------. ,---------------. ,-----------. ,-----------. + * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |Pwr|Slp|Wak| + * `---' `---------------' `---------------' `---------------' `-----------' `-----------' + * ,-----------------------------------------------------------. ,-----------. ,---------------. + * | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| /| *| -| + * |-----------------------------------------------------------| |-----------| |---------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| | + * |-----------------------------------------------------------| `-----------' |-----------| +| + * |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| | + * |-----------------------------------------------------------| ,---. |---------------| + * |Shift | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| | + * |-----------------------------------------------------------| ,-----------. |-----------|Ent| + * |Ctrl |Gui |Alt | Space |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| | 0| .| | + * `-----------------------------------------------------------' `-----------' `---------------' + */ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, PPLS, + LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, + LCTL,LGUI,LALT, FN0, RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), + + /* 1: SpaceFN + * ,-----------------------------------------------------------. + * |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + * |-----------------------------------------------------------| + * | | | |Esc| | | |Hom|Up |End|Psc|Slk|Pau|Ins | + * |-----------------------------------------------------------| + * | | | | | | |PgU|Lef|Dow|Rig| | | | + * |-----------------------------------------------------------| + * | | | | | |Spc|PgD|` |~ | |Men| | + * |-----------------------------------------------------------| + * | | | | | | | | | + * `-----------------------------------------------------------' + */ + KEYMAP( + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,BRK, + GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, + TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP, END, PSCR,SLCK,PAUS,INS, DEL, END, PGDN, P7, P8, P9, + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS, TRNS, P4, P5, P6, PPLS, + TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP, TRNS, UP, P1, P2, P3, + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, LEFT,DOWN,RGHT, P0, PDOT,PENT + ), +}; + +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE), + [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // tilde +}; + diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp index 20b7af66a2..30fd3348a3 100644 --- a/converter/usb_usb/main.cpp +++ b/converter/usb_usb/main.cpp @@ -8,11 +8,13 @@ #include "hid.h" #include "hidboot.h" #include "parser.h" +#include "usbhub.h" // LUFA #include "lufa.h" #include "timer.h" +#include "sendchar.h" #include "debug.h" #include "keyboard.h" @@ -22,6 +24,15 @@ static USB usb_host; static HIDBoot 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) { @@ -39,6 +50,7 @@ static void LUFA_setup(void) // for Console_Task USB_Device_EnableSOFEvents(); + print_set_sendchar(sendchar); } static void HID_setup() @@ -60,9 +72,11 @@ int main(void) LED_TX_ON; debug_enable = true; +/* debug_matrix = true; debug_keyboard = true; debug_mouse = true; +*/ host_set_driver(&lufa_driver); keyboard_init(); diff --git a/doc/other_projects.md b/doc/other_projects.md index ce24e0ab5c..bf980b0a9e 100644 --- a/doc/other_projects.md +++ b/doc/other_projects.md @@ -29,6 +29,7 @@ Other Keyboard Firmware Projects ## ErgoDox[Ergo][Split][USB][AVR] - - +- ## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR] - diff --git a/keyboard/hhkb/Makefile.nodebug b/keyboard/atomic/Makefile similarity index 81% rename from keyboard/hhkb/Makefile.nodebug rename to keyboard/atomic/Makefile index 578ba70c45..c4e0cb45d7 100644 --- a/keyboard/hhkb/Makefile.nodebug +++ b/keyboard/atomic/Makefile @@ -39,7 +39,7 @@ #---------------------------------------------------------------------------- # Target file name (without extension). -TARGET = hhkb_lufa +TARGET = atomic_lufa # Directory common source filess exist TOP_DIR = ../.. @@ -47,25 +47,22 @@ TOP_DIR = ../.. # Directory keyboard dependent files exist TARGET_DIR = . - -# List C source files here. (C dependencies are automatically generated.) -SRC += keymap_common.c \ +# project specific files +SRC = keymap_common.c \ matrix.c \ led.c ifdef KEYMAP SRC := keymap_$(KEYMAP).c $(SRC) else - SRC := keymap_hasu.c $(SRC) + SRC := keymap_vlad.c $(SRC) endif CONFIG_H = config.h # MCU name -# PJRC Teensy++ 2.0 -#MCU = at90usb1286 -# TMK Alt Controller or PJRC Teensy 2.0 +#MCU = at90usb1287 MCU = atmega32u4 # Processor frequency. @@ -101,14 +98,14 @@ ARCH = AVR8 # 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 +# 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 (TMK Alt Controller) +# Atmel DFU loader 4096 # LUFA bootloader 4096 # USBaspLoader 2048 OPT_DEFS += -DBOOTLOADER_SIZE=4096 @@ -117,14 +114,17 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 # Build Options # comment out to disable the options. # -BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration -MOUSEKEY_ENABLE = yes # Mouse keys -EXTRAKEY_ENABLE = yes # Audio control and System control -#CONSOLE_ENABLE = yes # Console for debug -COMMAND_ENABLE = yes # Commands for debug and configuration -NKRO_ENABLE = yes # USB Nkey Rollover -KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor +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 + +# Optimize size but this may cause error "relocation truncated to fit" +#EXTRALDFLAGS = -Wl,--relax # Search Path VPATH += $(TARGET_DIR) @@ -133,9 +133,3 @@ VPATH += $(TOP_DIR) include $(TOP_DIR)/protocol/lufa.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk - -debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION -debug-on: all - -debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT -debug-off: all diff --git a/keyboard/atomic/Makefile.pjrc b/keyboard/atomic/Makefile.pjrc new file mode 100644 index 0000000000..9655ff65a9 --- /dev/null +++ b/keyboard/atomic/Makefile.pjrc @@ -0,0 +1,116 @@ +#---------------------------------------------------------------------------- +# 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 = gh60_pjrc + +# Directory common source filess exist +TOP_DIR = ../.. + +# 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_poker.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 = atmega32u4 +#MCU = at90usb1286 + + +# 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 +# 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(+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) +#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support + + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/pjrc.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk + +plain: OPT_DEFS += -DKEYMAP_PLAIN +plain: all + +poker: OPT_DEFS += -DKEYMAP_POKER +poker: all + +poker_set: OPT_DEFS += -DKEYMAP_POKER_SET +poker_set: all + +poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT +poker_bit: all diff --git a/keyboard/atomic/README 2.md b/keyboard/atomic/README 2.md new file mode 100644 index 0000000000..510cb5c8b6 --- /dev/null +++ b/keyboard/atomic/README 2.md @@ -0,0 +1,141 @@ +GH60 keyboard firmware +====================== +DIY compact keyboard designed and run by komar007 and Geekhack community. + +- Both Rev.A and Rev.B PCB are supported by one firmware binary(issue #64) + +## GH60 Resources +- [KOMAR's project page](http://blog.komar.be/projects/gh60-programmable-keyboard/) +- [Prototyping](http://geekhack.org/index.php?topic=34959.0) +- [Rev.A PCB test](http://geekhack.org/index.php?topic=37570.0) +- [Rev.B PCB test](http://geekhack.org/index.php?topic=50685.0) +- [Group buy](http://geekhack.org/index.php?topic=41464.0) + + +## Build +Move to this directory then just run `make` like: + + $ make + +Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now. + + +## Keymap +Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_.c` and see keymap document(you can find in top README.md) and existent keymap files. + +To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like: + + $ make KEYMAP=[poker|poker_set|poker_bit|plain|hasu|spacefn|hhkb|] + + +### 1 Poker +[keymap_poker.c](keymap_poker.c) emulates original Poker layers +while both [keymap_poker_bit.c](keymap_poker_bit.c) and [keymap_poker_set.c](keymap_poker_set.c) implements same layout in different way and they fix a minor issue of original Poker and enhance arrow keys. + + Fn + Esc = ` + Fn + {left, down, up, right} = {home, pgdown, pgup, end} + +#### 1.0 Default layer + ,-----------------------------------------------------------. + | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space |Fn |Gui |App |Ctrl| + `-----------------------------------------------------------' +#### 1.1 Poker Fn layer + ,-----------------------------------------------------------. + |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12| | + |-----------------------------------------------------------| + | |FnQ| Up| | | | | | |Cal| |Hom|Ins| | + |-----------------------------------------------------------| + | |Lef|Dow|Rig| | |Psc|Slk|Pau| |Tsk|End| | + |-----------------------------------------------------------| + | |Del| |Web|Mut|VoU|VoD| |PgU|PgD|Del| Up | + |-----------------------------------------------------------| + | | | | FnS |Fn |Left|Down|Righ| + `-----------------------------------------------------------' + + +### 2. Plain +Without any Fn layer this will be useful if you want to use key remapping tool like AHK on host. +See [keymap_plain.c](keymap_plain.c) for detail. + +#### 1.0 Plain Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space |Alt |Gui |App |Ctrl| + `-----------------------------------------------------------' + + +### 3. Hasu +This is my favorite keymap with HHKB Fn, Vi cursor and Mousekey layer. See [keymap_hasu.c](keymap_hasu.c) for detail. + + +### 4. SpaceFN +This layout proposed by spiceBar uses space bar to change layer with using Dual role key technique. See [keymap_spacefn.c](keymap_spacefn.c) and [SpaceFN discussion](http://geekhack.org/index.php?topic=51069.0). + +#### 4.0 Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| + |-----------------------------------------------------------| + |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | + |-----------------------------------------------------------| + |Ctrl|Gui |Alt | Space/Fn |Alt |Gui |App |Ctrl| + `-----------------------------------------------------------' +#### 4.1 SpaceFN layer + ,-----------------------------------------------------------. + |` | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete | + |-----------------------------------------------------------| + | | | | | | | |Hom|Up |End|Psc|Slk|Pau|Ins | + |-----------------------------------------------------------| + | | | | | | |PgU|Lef|Dow|Rig| | | | + |-----------------------------------------------------------| + | | | | | |Spc|PgD|` |~ | | | | + |-----------------------------------------------------------| + | | | | Fn | | | | | + `-----------------------------------------------------------' + + +### 5. HHKB +[keymap_hhkb.c](keymap_hhkb.c) emulates original HHKB layers. +#### 5.0: Default layer + ,-----------------------------------------------------------. + |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| + |-----------------------------------------------------------| + |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Bspc | + |-----------------------------------------------------------| + |Ctrl | A| S| D| F| G| H| J| K| L|Fn3| '|Return | + |-----------------------------------------------------------| + |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn | + |-----------------------------------------------------------| + | |Gui |Alt | Space | |Alt |Gui | | + `-----------------------------------------------------------' +#### 5.1: HHKB Fn layer + ,-----------------------------------------------------------. + |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| + |-----------------------------------------------------------| + |Caps | | | | | | | |Psc|Slk|Pus|Up | | | + |-----------------------------------------------------------| + | |VoD|VoU|Mut|Ejc| | *| /|Hom|PgU|Lef|Rig|Enter | + |-----------------------------------------------------------| + | | | | | | | +| -|End|PgD|Dow| | | + |-----------------------------------------------------------| + | | | | | | | | | + `-----------------------------------------------------------' + diff --git a/keyboard/atomic/config.h b/keyboard/atomic/config.h new file mode 100644 index 0000000000..5ea953805f --- /dev/null +++ b/keyboard/atomic/config.h @@ -0,0 +1,70 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Ortholinear Keyboards +#define PRODUCT Atomic Keyboard +#define DESCRIPTION t.m.k. keyboard firmware for Atomic + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 5 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +#define LOCKING_RESYNC_ENABLE + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboard/hhkb_rn42/keymap_common.c b/keyboard/atomic/keymap_common.c similarity index 93% rename from keyboard/hhkb_rn42/keymap_common.c rename to keyboard/atomic/keymap_common.c index e938fb6270..fdb1769e1c 100644 --- a/keyboard/hhkb_rn42/keymap_common.c +++ b/keyboard/atomic/keymap_common.c @@ -14,9 +14,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include -#include "action.h" -#include #include "keymap_common.h" diff --git a/keyboard/atomic/keymap_common.h b/keyboard/atomic/keymap_common.h new file mode 100644 index 0000000000..c582c0135f --- /dev/null +++ b/keyboard/atomic/keymap_common.h @@ -0,0 +1,87 @@ +/* +Copyright 2012,2013 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef KEYMAP_COMMON_H +#define KEYMAP_COMMON_H + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[]; + +// JCK: Semi-Standard layout +#define KEYMAP_JCK( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0E, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, K2E, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3C, K3D, K3E, \ + K40, K41, K43, K46, K4A, K4B, K4C, K4D, 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_NO, KC_##K0E }, \ + { 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_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, KC_##K2D, KC_##K2E }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO, KC_##K3C, KC_##K3D, KC_##K3E }, \ + { KC_##K40, KC_##K41, KC_NO, KC_##K43, KC_NO, KC_NO, KC_##K46, KC_NO, KC_NO, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E } \ +} + +// ASK: Short Space layout +#define KEYMAP_ASK_MESSY( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0E, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2D, K2E, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3C, K3D, K3E, \ + K40, K41, K43, K44, K46, K48, K49, K4A, K4B, K4C, K4D, 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_NO, KC_##K0E }, \ + { 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_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO, KC_##K2D, KC_##K2E }, \ + { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO, KC_##K3C, KC_##K3D, KC_##K3E }, \ + { KC_##K40, KC_##K41, KC_NO, KC_##K43, KC_##K44, KC_NO, KC_##K46, KC_NO, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E } \ +} + +#define KEYMAP_ASK( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0E, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2E, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3D, K3E, \ + K40, K41, K43, K44, K46, K47, K48, K4A, K4B, K4C, K4D, 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_NO, KC_##K0E }, \ + { 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_##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_NO, KC_##K2E }, \ + { 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_NO, KC_##K3D, KC_##K3E }, \ + { KC_##K40, KC_##K41, KC_NO, KC_##K43, KC_##K44, KC_NO, KC_##K46, KC_##K47, KC_##K48, KC_NO, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E } \ +} + + +// MLO: Semi-Grid layout + +// KLN: Grid layout + +// PKR: Standard layout + +#endif diff --git a/keyboard/atomic/keymap_plain.c b/keyboard/atomic/keymap_plain.c new file mode 100644 index 0000000000..e7f53649f0 --- /dev/null +++ b/keyboard/atomic/keymap_plain.c @@ -0,0 +1,46 @@ +#include "keymap_common.h" + +// JCK: Semi-Standard layout + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + [0] = KEYMAP_JCK(GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, \ + ESC, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, MPLY, \ + LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, VOLD, VOLU, \ + LCTL, LALT, LGUI, SPC, FN1, LEFT, DOWN, UP, RGHT), + [1] = KEYMAP_JCK(GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, \ + TAB, Q, W, F, P, G, J, L, U, Y, SCLN, LBRC, RBRC, BSLS, DEL, \ + ESC, A, R, S, T, D, H, N, E, I, O, QUOT, ENT, MPLY, \ + LSFT, Z, X, C, V, B, K, M, COMM, DOT, SLSH, RSFT, VOLD, VOLU, \ + LCTL, LALT, LGUI, SPC, FN1, LEFT, DOWN, UP, RGHT), + [2] = KEYMAP_JCK(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, BSPC, \ + TAB, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, LBRC, RBRC, BSLS, DEL, \ + ESC, FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL, LBRC, RBRC, BSLS, ENT, MPLY, \ + LSFT, FN9, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, VOLD, VOLU, \ + LCTL, LALT, LGUI, SPC, TRNS, MNXT, VOLD, VOLU, MPLY), +}; +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_MOMENTARY(2), // to Fn overlay + [3] = ACTION_DEFAULT_LAYER_SET(0), + [4] = ACTION_DEFAULT_LAYER_SET(1), + + [9] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE), + + [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1), + [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2), + [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3), + [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4), + [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5), + [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6), + [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7), + [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8), + [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9), + [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0), + [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), + [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), + [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), + [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), + [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), + [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), +}; diff --git a/keyboard/atomic/keymap_vlad.c b/keyboard/atomic/keymap_vlad.c new file mode 100644 index 0000000000..e56bcf1618 --- /dev/null +++ b/keyboard/atomic/keymap_vlad.c @@ -0,0 +1,14 @@ +#include "keymap_common.h" + +// JCK: Semi-Standard layout + +const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* 0: qwerty */ + [0] = KEYMAP_ASK(GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, \ + CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, VOLU, \ + LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, VOLD, \ + LCTL, LGUI, LALT, LGUI, SPC, RGUI, RALT, RGUI, RCTL, LEFT, DOWN, RGHT) +}; +const uint16_t PROGMEM fn_actions[] = { +}; \ No newline at end of file diff --git a/keyboard/atomic/led.c b/keyboard/atomic/led.c new file mode 100644 index 0000000000..2d52fbf1c3 --- /dev/null +++ b/keyboard/atomic/led.c @@ -0,0 +1,25 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "stdint.h" +#include "led.h" + + +void led_set(uint8_t usb_led) +{ +} diff --git a/keyboard/atomic/matrix.c b/keyboard/atomic/matrix.c new file mode 100644 index 0000000000..98102cb694 --- /dev/null +++ b/keyboard/atomic/matrix.c @@ -0,0 +1,211 @@ +/* +Copyright 2012 Jun Wako + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + + +#ifndef DEBOUNCE +# define DEBOUNCE 10 +#endif +static uint8_t debouncing = DEBOUNCE; + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static matrix_row_t read_cols(void); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + + +void matrix_init(void) +{ + // initialize row and col + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + _delay_us(30); // without this wait read unstable value. + matrix_row_t cols = read_cols(); + if (matrix_debouncing[i] != cols) { + matrix_debouncing[i] = cols; + if (debouncing) { + debug("bounce!: "); debug_hex(debouncing); debug("\n"); + } + debouncing = DEBOUNCE; + } + unselect_rows(); + } + + if (debouncing) { + if (--debouncing) { + _delay_ms(1); + } else { + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + matrix[i] = matrix_debouncing[i]; + } + } + } + + + return 1; +} + +bool matrix_is_modified(void) +{ + if (debouncing) return false; + return true; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<. #ifndef DEBOUNCE -# define DEBOUNCE 10 +# define DEBOUNCE 10 #endif static uint8_t debouncing = DEBOUNCE; @@ -56,21 +56,12 @@ uint8_t matrix_cols(void) return MATRIX_COLS; } -static -void setup_leds(void) { - DDRF |= 0x00; - PORTF |= 0x00; -} - - void matrix_init(void) { // initialize row and col unselect_rows(); init_cols(); - setup_leds(); - // initialize matrix state: all keys off for (uint8_t i=0; i < MATRIX_ROWS; i++) { matrix[i] = 0; @@ -104,15 +95,16 @@ uint8_t matrix_scan(void) } } - // uint8_t layer = biton32(default_layer_state); - switch (default_layer_state) { + uint8_t layer = biton32(layer_state); + switch (layer) { case 1: - DDRF &= ~(1<<0); - PORTF &= ~(1<<0); - break; case 2: - DDRF |= (1<<0); - PORTF |= (1<<0); + DDRC |= (1<<7); + PORTC |= (1<<7); + break; + case 0: + DDRC &= ~(1<<7); + PORTC &= ~(1<<7); break; } @@ -163,28 +155,28 @@ uint8_t matrix_key_count(void) static void init_cols(void) { - DDRC &= ~(1<<6 | 1<<7); - PORTC |= (1<<6 | 1<<7); - DDRD &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5); - PORTD |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5); + DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7); + PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7); + DDRD &= ~(1<<0); + PORTD |= (1<<0); DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7); PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7); } static matrix_row_t read_cols(void) { - return (PIND&(1<<5) ? 0 : (1<< 0)) | - (PINC&(1<<7) ? 0 : (1<< 1)) | - (PINC&(1<<6) ? 0 : (1<< 2)) | - (PIND&(1<<3) ? 0 : (1<< 3)) | - (PIND&(1<<2) ? 0 : (1<< 4)) | - (PIND&(1<<1) ? 0 : (1<< 5)) | - (PIND&(1<<0) ? 0 : (1<< 6)) | - (PINB&(1<<7) ? 0 : (1<< 7)) | - (PINB&(1<<3) ? 0 : (1<< 8)) | - (PINB&(1<<2) ? 0 : (1<< 9)) | - (PINB&(1<<1) ? 0 : (1<<10)) | - (PINB&(1<<0) ? 0 : (1<<11)); + return (PINB&(1<<0) ? 0 : (1<< 0)) | + (PINB&(1<<1) ? 0 : (1<< 1)) | + (PINB&(1<<2) ? 0 : (1<< 2)) | + (PINB&(1<<3) ? 0 : (1<< 3)) | + (PINB&(1<<7) ? 0 : (1<< 4)) | + (PIND&(1<<0) ? 0 : (1<< 5)) | + (PINF&(1<<7) ? 0 : (1<< 6)) | + (PINF&(1<<6) ? 0 : (1<< 7)) | + (PINF&(1<<5) ? 0 : (1<< 8)) | + (PINF&(1<<4) ? 0 : (1<< 9)) | + (PINF&(1<<1) ? 0 : (1<<10)) | + (PINF&(1<<0) ? 0 : (1<<11)); } /* Row pin configuration @@ -194,30 +186,30 @@ static matrix_row_t read_cols(void) static void unselect_rows(void) { // Hi-Z(DDR:0, PORT:0) to unselect - DDRD &= ~(1<<4 | 1<<6 | 1<<7); - PORTD |= (1<<4 | 1<<6 | 1<<7); - DDRB &= ~(1<<4); - PORTB |= (1<<4); + DDRB &= ~0b01110000; + PORTB &= ~0b01110000; + DDRD &= ~0b10000000; + PORTD &= ~0b10000000; } static void select_row(uint8_t row) { switch (row) { case 0: - DDRD |= (1<<4); - PORTD &= ~(1<<4); + DDRB |= (1<<6); + PORTB &= ~(1<<6); break; case 1: - DDRD |= (1<<6); - PORTD &= ~(1<<6); + DDRB |= (1<<5); + PORTB &= ~(1<<5); break; case 2: - DDRD |= (1<<7); - PORTD &= ~(1<<7); - break; - case 3: DDRB |= (1<<4); PORTB &= ~(1<<4); break; + case 3: + DDRD |= (1<<7); + PORTD &= ~(1<<7); + break; } } diff --git a/keyboard/ghost_squid/Makefile.lufa b/keyboard/ghost_squid/Makefile.lufa new file mode 100644 index 0000000000..61893893a4 --- /dev/null +++ b/keyboard/ghost_squid/Makefile.lufa @@ -0,0 +1,117 @@ +#---------------------------------------------------------------------------- +# 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 = ghostsquid_lufa + +# Directory common source filess exist +TOP_DIR = ../.. + +# Directory keyboard dependent files exist +TARGET_DIR = . + +# List C source files here. (C dependencies are automatically generated.) +SRC = keymap.c \ + matrix.c \ + led.c + +CONFIG_H = config.h + +# MCU name +MCU = atmega32u2 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + + +# 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 + + +# Boot Section Size in bytes +# Teensy halfKay 512 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + +# Search Path +VPATH += $(TARGET_DIR) +VPATH += $(TOP_DIR) + +include $(TOP_DIR)/protocol/lufa.mk +include $(TOP_DIR)/common.mk +include $(TOP_DIR)/rules.mk diff --git a/keyboard/ghost_squid/README.md b/keyboard/ghost_squid/README.md new file mode 100644 index 0000000000..dda67e6ba1 --- /dev/null +++ b/keyboard/ghost_squid/README.md @@ -0,0 +1,20 @@ +The Ghost Squid controller +========================== +Custom controller for the Cooler Master QuickFire XT keyboard designed by bpiphany. + +*Note that this is not the official firmware* + +Build +----- +Move to this directory then just run `make` like: + + $ make -f Makefile.lufa + +At the moment only the LUFA stack is supported. + + +Bootloader +--------- +To enter bootloader by hardware use a magnet above the controller before connecting the usb cable. + +It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though. diff --git a/keyboard/ghost_squid/config.h b/keyboard/ghost_squid/config.h new file mode 100644 index 0000000000..54f03143c1 --- /dev/null +++ b/keyboard/ghost_squid/config.h @@ -0,0 +1,43 @@ +/* +Copyright 2014 Ralf Schmitt + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED // 0x2516 (original CM XT value) +#define PRODUCT_ID 0x001A +#define DEVICE_VER 0x0000 +#define MANUFACTURER Cooler Master +#define PRODUCT Cooler Master QuickFire XT + +/* message strings */ +#define DESCRIPTION t.m.k. keyboard firmware for Cooler Master QuickFire XT + +/* matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 18 + +/* Set 0 if need no debouncing */ +#define DEBOUNCE 5 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +#endif diff --git a/keyboard/ghost_squid/keymap.c b/keyboard/ghost_squid/keymap.c new file mode 100644 index 0000000000..e9ad9efe1a --- /dev/null +++ b/keyboard/ghost_squid/keymap.c @@ -0,0 +1,102 @@ +/* +Copyright 2014 Ralf Schmitt + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "debug.h" +#include "keymap.h" + +/* + Matrix col/row mapping + + ,----. ,-------------------. ,-------------------. ,-------------------. ,--------------. + |06/6| |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7| + `----' `-------------------' `-------------------' `-------------------' `--------------' + ,-------------------------------------------------------------------------. ,--------------. ,-------------------. + |06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4| 14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0| + |-------------------------------------------------------------------------| |--------------| |-------------------| + |06/2 |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2| 14/3| |16/4|02/5|04/5| |16/7|17/7|04/7| | + |-------------------------------------------------------------------------| '--------------' |-------------- 02/7| + |02/7 |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6| 14/1| |16/2|17/2|04/2| | + |-------------------------------------------------------------------------| ,----. |-------------------| + |01/2 |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0| 01/3| |02/6| |16/3|17/3|04/3| | + |-------------------------------------------------------------------------| ,--------------. |-------------- 02/3| + |15/4|03/2|13/6| 16/6 |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6 |04/6| | + `-------------------------------------------------------------------------' `--------------' `-------------------' +*/ + +#define KEYMAP( \ + KG6, KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0, KN5, KN7, KP7, \ + KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2, KR4, KC4, KE4, KQ1, KR1, KE1, KE0, \ + KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3, KQ4, KC5, KE5, KQ7, KR7, KE7, KC7, \ + KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6, KO1, KQ2, KR2, KE2, \ + KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0, KB3, KC6, KQ3, KR3, KE3, KC3, \ + KP4, KD2, KN6, KQ6, KN0, KA3, KM0, KP1, KC0, KQ0, KR0, KR6, KE6 \ +) { \ +/* 0 1 2 3 4 5 6 7 */ \ +/* A 0 */ {KC_NO, KC_NO, KC_NO, KC_##KA3, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* B 1 */ {KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* C 2 */ {KC_##KC0, KC_NO, KC_NO, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\ +/* D 3 */ {KC_NO, KC_NO, KC_##KD2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO },\ +/* E 4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\ +/* F 5 */ {KC_##KF0, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\ +/* G 6 */ {KC_NO, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\ +/* H 7 */ {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\ +/* I 8 */ {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\ +/* J 9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\ +/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\ +/* L 11 */ {KC_NO, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\ +/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO, KC_##KM7},\ +/* N 13 */ {KC_##KN0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KN5, KC_##KN6, KC_##KN7},\ +/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO },\ +/* P 15 */ {KC_NO, KC_##KP1, KC_NO, KC_NO, KC_##KP4, KC_##KP5, KC_NO, KC_##KP7},\ +/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO, KC_##KQ6, KC_##KQ7},\ +/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO, KC_##KR6, KC_##KR7} \ +} + +#include "keymap_ansi.h" + +#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) +{ + if (layer < KEYMAPS_SIZE) { + return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]); + } else { + return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]); + } +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} diff --git a/keyboard/ghost_squid/keymap_ansi.h b/keyboard/ghost_squid/keymap_ansi.h new file mode 100644 index 0000000000..ed1088baa9 --- /dev/null +++ b/keyboard/ghost_squid/keymap_ansi.h @@ -0,0 +1,23 @@ + +static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = { + /* Layer 0: Standard ANSI layer */ + KEYMAP(\ + ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, \ + GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS, \ + TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSLS, DEL, END, PGDN, P7, P8, P9, PPLS, \ + CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, ENT, P4, P5, P6, \ + LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RSFT, UP, P1, P2, P3, PENT, \ + LCTL,LGUI,LALT, SPC, RALT,RGUI, FN0,RCTL, LEFT,DOWN,RGHT, P0, PDOT), \ + /* Layer 1: Function layer */ + KEYMAP(\ + CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS, WAKE, PWR,SLEP, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, \ + TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS) +}; + +static const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_LAYER_MOMENTARY(1) +}; diff --git a/keyboard/ghost_squid/led.c b/keyboard/ghost_squid/led.c new file mode 100644 index 0000000000..da5dbd7ae2 --- /dev/null +++ b/keyboard/ghost_squid/led.c @@ -0,0 +1,60 @@ +/* +Copyright 2014 Ralf Schmitt + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include "stdint.h" +#include "led.h" + +/* LED pin configuration + * + * Scroll Lock PB7 + * CAPS PC6 + * NUMLOCK PC5 + * + */ +void led_set(uint8_t usb_led) +{ + DDRB |= (1<<7); + DDRC |= (1<<5) | (1<<6); + + if (usb_led & (1< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +#ifndef DEBOUNCE +# define DEBOUNCE 0 +#endif +static uint8_t debouncing = DEBOUNCE; + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(void); +static void init_rows(void); +static void unselect_cols(void); +static void select_col(uint8_t col); + +inline uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + unselect_cols(); + init_rows(); + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } +} + +uint8_t matrix_scan(void) +{ + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + uint8_t rows = read_rows(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<] + $ make -f Makefile. KEYMAP=(hasu|hhkb|spacefn|) + +You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**. ### Program @@ -56,11 +66,11 @@ First, push reset button on board to start bootloader. This command programs the controller with [dfu-programmer] if the tool is installed and configured properly. - $ make dfu + $ make -f Makefile. KEYMAP= dfu Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available. - $ make flip + $ make -f Makefile. KEYMAP= flip Use [Teensy Loader] if your controller is Teensy/Teensy++. diff --git a/keyboard/hhkb_rn42/config.h b/keyboard/hhkb/config_rn42.h similarity index 100% rename from keyboard/hhkb_rn42/config.h rename to keyboard/hhkb/config_rn42.h diff --git a/keyboard/hhkb/hhkb_avr.h b/keyboard/hhkb/hhkb_avr.h index b7bd507b5d..7ea6322c73 100644 --- a/keyboard/hhkb/hhkb_avr.h +++ b/keyboard/hhkb/hhkb_avr.h @@ -41,17 +41,32 @@ static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); } static inline bool KEY_STATE(void) { return (PIND & (1<<7)); } static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); } static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); } +#ifdef HHKB_POWER_SAVING +static inline void KEY_POWER_ON(void) { + DDRB = 0xFF; PORTB = 0x40; // change pins output + DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on + /* Without this wait you will miss or get false key events. */ + _delay_ms(5); // wait for powering up +} +static inline void KEY_POWER_OFF(void) { + /* input with pull-up consumes less than without it when pin is open. */ + DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up + DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off +} +static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); } +#else static inline void KEY_POWER_ON(void) {} static inline void KEY_POWER_OFF(void) {} +static inline bool KEY_POWER_STATE(void) { return true; } +#endif static inline void KEY_INIT(void) { + /* row,col,prev: output */ DDRB = 0xFF; - PORTB = 0x00; + PORTB = 0x40; // unable + /* key: input with pull-up */ DDRD &= ~0x80; - PORTD |= 0x80; - /* keyswitch board power on */ - DDRD |= (1<<4); - PORTD |= (1<<4); + PORTD |= 0x80; #ifdef HHKB_JP /* row extention for HHKB JP */ DDRC |= (1<<6|1<<7); @@ -59,6 +74,8 @@ static inline void KEY_INIT(void) #endif KEY_UNABLE(); KEY_PREV_OFF(); + + KEY_POWER_OFF(); } static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) { @@ -98,6 +115,7 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) #define KEY_PREV_OFF() (PORTE &= ~(1<<7)) #define KEY_POWER_ON() #define KEY_POWER_OFF() +#define KEY_POWER_STATE() true #else diff --git a/keyboard/hhkb/keymap_hasu.c b/keyboard/hhkb/keymap_hasu.c index 8379c84f52..433f9cb270 100644 --- a/keyboard/hhkb/keymap_hasu.c +++ b/keyboard/hhkb/keymap_hasu.c @@ -27,7 +27,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \ FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ - LGUI,LALT, FN4, FN5, FN5), + LGUI,LALT, FN4, FN5, RGUI), /* Layer 1: HHKB mode[HHKB Fn] * ,-----------------------------------------------------------. @@ -47,7 +47,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ - LGUI,LALT, SPC, RALT,RGUI), + LGUI,LALT, TRNS, RALT,RGUI), /* Layer 2: Vi mode[Slash] * ,-----------------------------------------------------------. @@ -66,7 +66,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ - LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, TRNS,RSFT,NO, \ + LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \ LGUI,LALT, SPC, RALT,RGUI), /* Layer 3: Mouse mode(IJKL)[Semicolon] @@ -81,16 +81,16 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * `-----------------------------------------------------------' * |Gui |Alt | Mb1 |Fn |Fn | * `--------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [3] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \ - LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,TRNS,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ + LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, BTN1, TRNS,TRNS), - /* Layer 5: Mouse mode(IJKL)[Space] + /* Layer 4: Mouse mode(IJKL)[Space] * ,-----------------------------------------------------------. * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| * |-----------------------------------------------------------| @@ -102,13 +102,13 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * `-----------------------------------------------------------' * |Gui |Alt | Mb1 |Fn |Fn | * `--------------------------------------------' - * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8 + * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ [4] = \ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ LGUI,LALT, TRNS, TRNS,TRNS), #if 0 @@ -127,9 +127,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - TAB, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, NO, NO, BSPC, \ + TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \ LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \ LGUI,LALT, BTN1, RALT,TRNS), /* Layer4: Mouse mode(HJKL)[Space] @@ -147,9 +147,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel */ KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ - FN8, NO, NO, NO, NO, NO, WH_L,WH_D,WH_U,WH_R,NO, WBAK,WFWD,FN8, \ + FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \ LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \ - LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,BTN4,BTN5,NO, RSFT,NO, \ + LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \ LGUI,LALT, TRNS, RALT,RGUI), #endif #if 0 @@ -201,10 +201,12 @@ const uint16_t fn_actions[] PROGMEM = { [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space - [5] = ACTION_LAYER_MOMENTARY(3), // Mousekey layer + [5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL) [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift [8] = ACTION_MACRO(ALT_TAB), // Application switching + [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), + [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index b0af4baa52..fb96997944 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c @@ -27,8 +27,15 @@ along with this program. If not, see . #include "timer.h" #include "matrix.h" #include "hhkb_avr.h" +#include +#include "suspend.h" +#include "lufa.h" +// matrix power saving +#define MATRIX_POWER_SAVE 10000 +static uint32_t matrix_last_modified = 0; + // matrix state buffer(1:on, 0:off) static matrix_row_t *matrix; static matrix_row_t *matrix_prev; @@ -72,7 +79,8 @@ uint8_t matrix_scan(void) matrix_prev = matrix; matrix = tmp; - KEY_POWER_ON(); + // power on + if (!KEY_POWER_STATE()) KEY_POWER_ON(); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { for (uint8_t col = 0; col < MATRIX_COLS; col++) { KEY_SELECT(row, col); @@ -126,8 +134,16 @@ uint8_t matrix_scan(void) // This takes 25us or more to make sure KEY_STATE returns to idle state. _delay_us(75); } + if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); + } + // power off + if (KEY_POWER_STATE() && + (USB_DeviceState == DEVICE_STATE_Suspended || + USB_DeviceState == DEVICE_STATE_Unattached ) && + timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) { + KEY_POWER_OFF(); + suspend_power_down(); } - KEY_POWER_OFF(); return 1; } @@ -165,3 +181,10 @@ void matrix_print(void) xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row))); } } + +void matrix_power_up(void) { + KEY_POWER_ON(); +} +void matrix_power_down(void) { + KEY_POWER_OFF(); +} diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/not_supported/Makefile.iwrap similarity index 100% rename from keyboard/hhkb/Makefile.iwrap rename to keyboard/hhkb/not_supported/Makefile.iwrap diff --git a/keyboard/hhkb/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb similarity index 100% rename from keyboard/hhkb/Makefile.vusb rename to keyboard/hhkb/not_supported/Makefile.vusb diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/not_supported/config_iwrap.h similarity index 100% rename from keyboard/hhkb/config_iwrap.h rename to keyboard/hhkb/not_supported/config_iwrap.h diff --git a/keyboard/hhkb/config_vusb.h b/keyboard/hhkb/not_supported/config_vusb.h similarity index 100% rename from keyboard/hhkb/config_vusb.h rename to keyboard/hhkb/not_supported/config_vusb.h diff --git a/keyboard/hhkb/iwrap.txt b/keyboard/hhkb/not_supported/iwrap.txt similarity index 100% rename from keyboard/hhkb/iwrap.txt rename to keyboard/hhkb/not_supported/iwrap.txt diff --git a/keyboard/hhkb/usbconfig.h b/keyboard/hhkb/not_supported/usbconfig.h similarity index 100% rename from keyboard/hhkb/usbconfig.h rename to keyboard/hhkb/not_supported/usbconfig.h diff --git a/keyboard/hhkb_rn42/rn42.mk b/keyboard/hhkb/rn42.mk similarity index 100% rename from keyboard/hhkb_rn42/rn42.mk rename to keyboard/hhkb/rn42.mk diff --git a/keyboard/hhkb/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt new file mode 100644 index 0000000000..0363c2f433 --- /dev/null +++ b/keyboard/hhkb/rn42/MEMO.txt @@ -0,0 +1,255 @@ +Memo of deveopment +================== +just memo, NOT WORTH READING + +Bug: +- Factory Reset PIO4 doesn't work + - the reason is unclear - 12/08 NOT LOOK INTO ANY MORE + - WORKAROUND: use serial pins(3.3V, GND, RX and TX) + - SF,1 and R,1 to set factory defalult + + +Todo: +- LED cover and switch knob and new Slide Switch +- RN42 auto configuration + - configure the module as HID device every time powering up + - this'll reduce work load of assembly + +- move rn42 to protocol directory when it becomes reusable stack + +- sendchar() in lufa.c no buffer + - no buffering. character lost can be caused. +- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256). + +- BT operations + - disconnect + - new connection + - remove connection + +- sendchar() in lufa.c block loop - DONE 11/29 + - block loop when powered with AC adapter + - FrameNumber is not updated when adapter powered + +Improving: +- ADC resolution + AVR120 + AVR32138 + - Enhancing ADC resolution by oversampling + AVR121 http://www.atmel.com/images/doc8003.pdf + - disable digital input buffer DIDR(7.8.6) + +Design: +- suspend.h - DONE 11/26 + - remove argument from suspend_power_down() for backward compatitibility +- remove MCU dependent power saving code from core/keyboard - DONE 11/23 + - it should be located in project matrix.c +- HHKB matrix.c needs matrix_prev? + - is_modified() is obsolete now. really needs? +- ADC: removing AREF capacitor C10 + - seems to be better while usb powered + - still bad while battery powered + http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc +- ADC: smaller resistors for voltage dividor + - 1K + 1K: not improved. - 11/27 + + +LUFA: +USB connection check: state of USB deivce +- USB_DeviceState: + USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* } + Unattached: unpluged + Powered: pluged with power adapter + Default: enumerate process bigin + Addressed: addressed + Configured: enumerated + Suspended: suspended + +- USB_IsInitialized: state of LUFA core setup + becomes true in USB_Init() USBController_AVR8.c + becomes false in USB_Disable() USBController_AVR8.c +- USB_VBUS_GetStatus(): state of VBUS(power/connection) +- USB_Disable() detaches, disables all interrupts, controller, PLL, regulater. + +- When connect to power adapter + - event happened: CW or CSW or C or DDC + - USB state: not configured + +- USB evnets + - USB connect: CSWRWRW + - USB connect but fail to enumeration: CWRWRWRWS + - USB disconnect: D + - Power adapter connect: CW, CSW, C + - Power adapter disconnect: D + + +Power saving: +- Pro2 current consumption + - active: 138.2mA(no device on Hub) + - suspended: 30.9mA(WakeUp enabled DIPSW6) + - suspended: 0mA->46.0mA(WakeUp disabled DIPSW6) +- Pro current consumption + - active: 54.0mA + - suspended: 40.5mA(WakeUp enabled DIPSW6) + - suspended: 0.3mA(WakeUp disabled DIPSW6) + +- RN42 3.3V + - disconnected(Idle): 5mA (config mode) + - connected(Active): + SW,0000: 23-26mA + SW,0010: 27-29mA worse than 0000 for unknown reason + SW,0020: 17-19mA mouse NG + SW,0030: 13-16mA laggy mouse NG + SW,0050: 10-13mA laggy mouse NG + +- matrix power saving + - power saving while externally powered and not while unpluged +- confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition +- 8MHz clock +- When not connected in a few minutes get into deep sleep to save battery life +- CTS is needed for waking up from deep sleep? How deep sleep is activated? +- firmware controlled 3.3V DC converter to switch on/off BT module +- sleep MCU and BT module(keyboard is not used) +- deep sleep MCU and BT module(keyboard is not used for long time) +- deep sleep MCU and turn off BT module(keyboard is not used and not connected) +- Battery ADC; switching, high resistance + - switching gnd end of divider with PF4 + - high resistor 100K/1M? + capacitor 10nF + http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/ +- During USB suspend change clock source to internal RC from external Xtal(6.8) +- FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3) +- Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13) +- Voltage reference(8.1.1) + - to reduce power consumption while power down mode +- unset ADEN before sleep(24.7) + + + + + + + +Lipo +---- +850mA lasts around 9 hours(07/28) + +Sparkfun Polymer Lithium Ion Battery 850mAh: +https://www.sparkfun.com/products/341 +Lipo Cell spec: +https://www.sparkfun.com/datasheets/Batteries/063048%20Li-polymer.pdf +Protection spec: +http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf + min typical max + over-charge 4.255 4.280 4.305 + over-charge discover? 4.030 4.080 4.130 + over-discharge 2.827 2.900 2.973 + over-discharge discover 3.022 3.100 3.178 + +ADC voltage monitor: voltage divider 10K+10K(0.5) + ADC=V*0.5/2.56*1024 + + V ADC + ------------------ + 4.20 0x347(839) + 3.10 0x26b(619) + + + + +TROUBLE SHOOT +------------- +07/16 After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive. + Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before. + +07/18 On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it. + +12/07 rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered. + It resolved with resoldering PF1 and new resistor on R12. + + + + +Done: +- low battery alert(solid light) 09/04 +- *** Rev.E BT test *** - DONE + - with MCP73832, new Schottky, tantalum caps - DONE 12/07 + * MCP73832 doesn't leak from Vcc pin when unpluged and battery powered + 34mV vs 2.07V(MCP73831) at Vcc pin + MCP73832 doesn't need revese protection diode D5 + * PMEG2010ER is very low VF while reverse current/voltage is high + VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175 + Anode of D11 is 680mV vs 20mV(RB160M-30TR) + 780mV is still low < 1.4V VBUS plugin detection(21.11) + this doesn't cause false VBUS detect + and 780mV on MCP73832 Vcc pin is also no problem. + D5 can be removed. + - ADC divider switching - DONE 12/07 + * Drain and Source of Q4 Pch was reversed wrongly on Rev.E. + + - reverse current from Lipo charger - DONE 12/07 + * MCP73832 has no recverse current from Vcc pin unlike MCP73831 + + +- Rev.F design - DONE + - current measure point - DONE 12/08 + - change value of cap 68->47 - DONE 12/08 + - PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08 + - Q4 Pch FET: wrong Drain and Source - DONE 12/08 + - D5 can be removed. - DONE 12/08 + + + +- BT_INDICATOR LED turns on wrongly when touching line or pin. -- pull-up enabled on PF6/GPIO2 08/30 +- Lipo charger configuration: fast charge time: USB charger spec? -- used 2kohm +- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB +- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done +- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done +- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24 +- LINKED: add trace on PIO2 to PF6 07.24 +- Lipo voltage ADC sensing +- Lipo charger MCP73831: needs capacitor 4.7uF *2 +- USB connection check - 07.01 +- BT on/off check: whether RX line is pulled up? - checking RTS 07.01 +- USB/BT switching BT is on -> BT, BT is off -> USB - 07.01 +- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V 07.01 +- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough 07.01 +- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04 + +- wrongly suspended when powered from adapter without USB connection - DONE + - suspend event may occur when plug into adapter + - and never wake until conected to real USB line + - without debug print via USB no problem; CSW(wake just after suspend as real USB line) + - seems like USB print causes this problem after suspended + +- lose USB connection during power-down mode - DONE + - USB initialize code in main() causes this - WRONG + - Do not power-down during USB connection is active - DONE 11/11 + (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection + matrix_power_down() matrix.c - 11/23 + +- with Nexus5 keyboard and mouse are very laggy. + Not confirmed. 01/15 + +- switch BT host connections - CANCEL 01/15 + - switch next connection + cannot switch connection with version 6.15 at least + +- When given power only from wall wart adapter - DONE? not confirmed 01/15 + - it sleeps. it should not sleep + - Configured state without USB connection? + +- timer is slow while power down - DONE 11/26 + - time out interrupt is lost while power down? + - interrupt of watchdog timer compensates timer counter(avr/suspend.c) + +- repeated CHARGING/FULL_CHARGED - No longer problem 01/15 + - In LTC sharp pulses are observed. + - MCP has no pulse but still has a problem. + - needs more wait before read pin state? - NO + +- USB plug-in fails while BT - No longer problem 01/15 + - it ends in suspend state + - maybe, not responsive to host enumeration process due to power-down. + - matrix_power_down() only when state is unattached - 11/26 + - need to observe a while + diff --git a/keyboard/hhkb_rn42/PowerSave.txt b/keyboard/hhkb/rn42/PowerSave.txt similarity index 72% rename from keyboard/hhkb_rn42/PowerSave.txt rename to keyboard/hhkb/rn42/PowerSave.txt index 943923c336..4b9c8f415d 100644 --- a/keyboard/hhkb_rn42/PowerSave.txt +++ b/keyboard/hhkb/rn42/PowerSave.txt @@ -1,5 +1,28 @@ -RN-42 -===== +Power Saving +============ + + +MCU+HHKB Power Comsumption +-------------------------- +Battery drive: + idle 18.9mA + active 35.8mA + +USB powered: + 40.0mA + 52mA 01/17 + +Other keyboards: +HHKB Pro 55mA +HHKB Pro2 140mA +HHKB Pro 42mA(Alt) +HHKB Pro2 52mA(Alt BT controller USB mode) +HHKB Pro2 88mA(Alt BT controller BT mode connected) +HHKB Pro2 68mA(Alt BT controller BT mode config mode) +Poker X 6mA +Infinity 24mA(TMK) + 65mA(kiibohd) + HHKB key switch power control ----------------------------- @@ -63,40 +86,3 @@ S%,1000 status led and connection control don't work GPIO5: status LED GPIO6: Connection control GPIO2: linked status - - - - - -Ver 6.15 04/26/2013 -(c) Roving Networks -***Settings*** -BTA=00066667BBE9 -BTName=tmkBT-BBE9 -Baudrt(SW4)=115K -Mode =DTR -Authen=1 -Bonded=0 -Rem=001BDC06415B -***ADVANCED Settings*** -SrvName= keyboard/mouse -SrvClass=0000 -DevClass=1F00 -InqWindw=0012 -PagWindw=0012 -CfgTimer=255 -StatuStr=NULL -HidFlags=3c -DTRtimer=8 -KeySwapr=0 -***OTHER Settings*** -Profile= HID -CfgChar= $ -SniffEna=8010 -LowPower=0 S|, -TX Power=fff4 SY, -IOPorts= 0 -IOValues=0 -Sleeptmr=0 -DebugMod=0 -RoleSwch=0 diff --git a/keyboard/hhkb/rn42/RN42.txt b/keyboard/hhkb/rn42/RN42.txt new file mode 100644 index 0000000000..64c3fdd4ec --- /dev/null +++ b/keyboard/hhkb/rn42/RN42.txt @@ -0,0 +1,408 @@ +RN-42 Bluetooth Module Support +============================== +Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board. + + +RN-42: +http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42 + + +Capabitlities: +- USB keyboard functions + completely equivarent to USB controller including mouse keys and NKRO. +- Switching between USB and Bluetooth + You can switch the two connections with BT switch or key combination. +- RN-42 config mode + You can change power/connection configuration of the module if needed. +- Low battery alert + Red LED turns on when low voltage. +- RN-42 status indicator + LED indicates status of Bluetooth connection. +- Pairing + The module stores up to 8 connections. +- Auto connect + The module connects the last connected device automatically. +- iOS support + works as keyboard with iPhone5. No tested completely. +- Android support + works as keyboard and mouse with Nexus5. No tested completely. +- Mouse keys over BT + Note that iOS doesn't accept mouse device. + + +Limitations: +- Short battery life + Around 12hr with 1000mAh +- No connection switching + RN-42 auto-connects to the last connected device. + Some of consumer products can switch between devices, for example Logitech K480. + http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26 +- HHKB JP requires case modification for BT switch and LEDs. + without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled. + +NOTE: +- LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY. +- RN-42 version 6.15 is supported. +- No NKRO over Bluetooth +- Check you country's wiress regulation and certification of RN-42. + +Bugs: + +Todos: + + +Lipo Battery +------------ +You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit. +Battery space inside HHKB is around 54mm x 50mm and its height is 7mm. + +Sparkfun 850mAh +https://www.sparkfun.com/products/341 +Sparkfun 1000mAh +https://www.sparkfun.com/products/339 + +Sparkfun 2000mAh battery won't fit due to its size. + +Learn about Lipo battery: +https://learn.adafruit.com/li-ion-and-lipoly-batteries + + + + + +LED Status +---------- +Configuring 10 times per sec +Startup/configuration timer 2 times per sec +Discoverable/Inquiring/Idle once per sec +Connected solid on + + +RN-42 Magic Command +-------------------- +Magic key combination is 'LShift+RShift' by default in case of HHKB. + +Here is help. + + ----- Bluetooth RN-42 Help ----- + i: RN-42 info + b: battery voltage + Del: enter/exit RN-42 config mode + Slck: RN-42 initialize + p: pairing + u: toggle Force USB mode + + RN-42 info: displays information of the module on console. + battery voltage: displays current voltage of battery and uptime. + RN-42 initialize: does factory reset and configures RN-42 + pairing: enters Pairing mode. + toggle Force USB mode: switch between USB and Bluetooth + + +RN-42 Config mode +----------------- +You can tune/operate RN-42 yourself with config(command) mode. + +1. hook up USB cable +2. run `hid_listen` command in console +3. turn on Bluetooth switch +4. press LShift+RShift+Delete(Fn+~) you will see output like followings: + + Entering config mode ... + CMD + v + Ver 6.15 04/26/2013 + (c) Roving Networks + +5. do config with RN-42 commands. See documentations of RN-42. +6. to exit also press LShift+RShift+Delete(Fn+~) + + Exiting config mode ... + --- + END + + +RN-42 Initial Configuration +--------------------------- +RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time. + +1. hook up USB cable +2. run `hid_listen` command in console +3. turn on Bluetooth switch +4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings: + + Entering config mode ... + CMD + Ver 6.15 04/26/2013 + (c) Roving Networks + ECHO ON + SF,1 + AOK + S-,TmkBT + AOK + SS,Keyboard/Mouse + AOK + SM,4 + AOK + SW,8000 + AOK + S~,6 + AOK + SH,003C + AOK + SY,FFF4 + AOK + R,1 + Reboot! + Exiting config mode ... + +5. output of command 'X' after cofiguration + + Ver 6.15 04/26/2013 + (c) Roving Networks + ***Settings*** + BTA=00066667BBE9 + BTName=TmkBT-BBE9 + Baudrt(SW4)=115K + Mode =DTR + Authen=1 + PinCod=1234 + Bonded=0 + Rem=NONE SET + ***ADVANCED Settings*** + SrvName= Keyboard/Mouse + SrvClass=0000 + DevClass=1F00 + InqWindw=0100 + PagWindw=0100 + CfgTimer=255 + StatuStr=NULL + HidFlags=3c + DTRtimer=8 + KeySwapr=0 + ***OTHER Settings*** + Profile= HID + CfgChar= $ + SniffEna=8000 + LowPower=0 + TX Power=fff4 + IOPorts= 0 + IOValues=0 + Sleeptmr=0 + DebugMod=0 + RoleSwch=0 + + +Switch to USB mode +------------------ +You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'. + + +Pairing mode +------------ +This disconnects current connect and enter pairing mode. + + + + +For deveropment +=============== + +RN-42 Serial Connection +----------------------- +UART: 115200bps, 8bit, 1-stopbit, non-parity, no flow control +SSP: 115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth) + +To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END'). + + +RN-42 Commands +-------------- +S-,tmkBT // Device name +SS,keyboard/mouse // service name +SM,4 // Auto Connect DTR mode +SW,8010 // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save +S~,6 // HID profile +S~,0 // SPP profile +SH,003C // HID register +SY,0004 // Transmit power +SC,0000 // COD: 000005C0 (see HID spec/Bluegiga doc) +SD,05C0 // bit 12-8 7 6 5-0 + // 00101 1 1 0 + // peripheral pointing keybaord joystick, gamepad, ... +SM,6 // Pairing mode: auto connect +SM,4 // Master mode: Connection can be controled with GPIO6 +SF,1 // Factroy reset +R,1 // reboot +SR,Z // removes all remote addresses for reconnecting. + // can be used to connect another host +SR,I // registers last inquiry address + + +Operation Modes +--------------- +SM,3 Auto Connect Master mode +SM,4 Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR) + confirm: auto connect works and control connection with GPIO6 +SM,5 Auto Connect ANY Mode (Mode =ANY) + each time GPIO is set, make inquiry and connect to the first found device +SM,6 automatically reconnect(Mode =Pair) + confirm: auto connect works well but difficult to enter command mode. + + +HID flag register +----------------- +SH,0200 +GH + +10 0000 0000(0200) default +00 0011 1000(0038) Combo +|| | | |\_\____ number of paired devices to which the module can reconnect +|| | | \_______ send out reports over UART (0xFF ) +|| \__\_________ descriptor type +|\______________ toggle virtual keyboard on iOS when first connected +\_______________ Force HID mode if GPIO11 is high on power-up + + Descriptor type: + 0000: keybaord + 0001: Game Pad + 0010: Mouse + 0011: Combo + 0100: Joystick + 1xxx: reserved + + +Out report - Indicator +---------------------- +0xFE 0x02 0x01 + + +Apple iOS +--------- +Keyboard can be used with iPhone, but mouse cannot. + + +Android +------- +3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds. + + +Power Management +---------------- +Inquiry and Page window Idle or Active (3.1.1) + Downside: delay in discovery or connection time + SI, // set inquiry scan window(discovery) on/off duty? + SJ, // set page scan window(connection) + This reduces averaege power >20mA to 5mA(3mA in Sniff mode) + +Sniff mode Transmit + Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA) + In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA) + SW, // set interval timer(*0.625ms) 0000-7FFF + +Deep sleep Idle (3.1.2) + In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer. + SW,8320 // deep sleep enable(interval=0x320*0.625=500ms) + In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second. + To wake from deep sleep there are three ways: (in worst case wake up takes 5ms) + *send a charactor to the UART(first charactor will be lost) + *toggle CTS low to high and wait 5ms + *wake automatically every slot time(*0.625ms) + Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again. + Downside: latency and data loss + +Disable Output driver Idle or Active (3.1.3) + S%,1000 // set all GPIO pins(0-11) to inputs. + +Lower Transmit Power Idle or Active (3.1.4) + SY, // transmit power setting(takes effect after a power cycle and reboot) + Downside: reducing effective range + + +Optimizig for Latency +--------------------- +By default the firmware is optimized for throughput. +SQ,16 // set latency bit +SQ,0 // unset latency bit + + +Configuration timer settings +---------------------------- +Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?). + +The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.) + ST,0 // no remote, no local when connected + ST,<1-252> // local and remote with timeout in seconds from power up + ST,253 // local only without timeout + ST,254 // remote only without timeout + ST,255 // local and remote without timeout + + +Commands +-------- +S7, 7bit mode +SA, Authenticaiton +SB, Send break +SC, Service class +SD, Device class +SM, Operation mode +SP, Pin code(alpahnumeric) +SQ, Special configuration(GPIO, discovery mode, low latency, reboot, UART) +SR, Store remote address +SR,Z Erase all address +SS, Set service name(1-20)** +ST, Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer) +SU, UART baud rate +SW, low-power sniff mode** deep sleep and wake up every 625us * +SX,<0|1> bonding enable only acceps device that matches the stored address +SY, power setting** +SZ, non-standard raw baud rate =baud*0.004096 +S~, Profile 0:SPP, 5:APL, 6:HID +S-, Device name -15 alphanumeric charactors +S?,<0|1> role switch enable +S$, command mode char +$|, low-power connect mode deep sleep/active(discoverable and connectable) cycle +D display basic setting +E display extended setting +GB display the device's Bluetooth address +GF display Bluetooth address of connected device +GK show connection status +GR show remote address for reconnecting +G& show GPIO pin +G show stored setting ++ toggle local echo on/off +& show GPIO 3,4,6,7(DIP switch) +C connect to stored remote address +C,
connect last address +CFI connect and go into fast data mode +CFR connect and go into fast data mode +CT,
, connect to the address and disconnect after val? +F,1 fast data mod: +H display help +I,