From 3a94bdf5b709a166c3526f276efa037ed85dae0e Mon Sep 17 00:00:00 2001 From: "Vincent@524" Date: Tue, 26 Nov 2013 12:11:22 +0800 Subject: [PATCH 1/4] added dvorak layout support for Arduino leonardo only since I have no teensy --- keymapper.ino | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/keymapper.ino b/keymapper.ino index 098fc4a..91c5169 100644 --- a/keymapper.ino +++ b/keymapper.ino @@ -1,26 +1,12 @@ #include - -#include -#include -#include -#include #include -#include -#include #include -#include -#include -#include -#include - #include "keymapper_game.h" //#define DEBUG #define modeLED 13 -#define TEENSY - - +//#define TEENSY // function definitions bool HandleReservedKeystrokes(HID *hid, uint8_t *buf); @@ -48,6 +34,8 @@ PROGMEM prog_uint8_t tarmak2Keymap[] = {4, 5, 6, 7, 9, 23, 13, 11, 12, 17, 8, 15 PROGMEM prog_uint8_t tarmak3Keymap[] = {4, 5, 6, 7, 9, 23, 51, 11, 12, 17, 8, 15, 16, 14, 28, 19, 20, 21, 22, 10, 24, 25, 26, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 18, 52, 53, 54, 55, 56, 42}; PROGMEM prog_uint8_t tarmak4Keymap[] = {4, 5, 6, 7, 9, 23, 51, 11, 24, 17, 8, 12, 16, 14, 28, 19, 20, 21, 22, 10, 15, 25, 26, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 18, 52, 53, 54, 55, 56, 42}; PROGMEM prog_uint8_t colemakKeymap[] = {4, 5, 6, 22, 9, 23, 7, 11, 24, 17, 8, 12, 16, 14, 28, 51, 20, 19, 21, 10, 15, 25, 26, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 18, 52, 53, 54, 55, 56, 42}; +PROGMEM prog_uint8_t dvorakKeymap[] = {4, 27, 13, 8, 55, 24, 12, 7, 6, 11, 23, 17, 16, 5, 21, 15, 52, 19, 18, 28, 10, 14, 54, 20, 9, 51, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 47, 48, 56, 46, 49, 50, 22, 45, 53, 26, 25, 29, 57}; + const uint8_t *Keymap[] = { @@ -56,7 +44,8 @@ const uint8_t *Keymap[] = tarmak2Keymap, tarmak3Keymap, tarmak4Keymap, - colemakKeymap + colemakKeymap, + dvorakKeymap }; // global variables @@ -215,6 +204,12 @@ bool HandleReservedKeystrokes(HID *hid, uint8_t *buf) // return true if it is a digitalWrite(modeLED, HIGH); LatchKey(buf[keyPosition]); return true; + + case 0x23: // 6 + CurrentLayout = dvorak; + digitalWrite(modeLED, HIGH); + LatchKey(buf[keyPosition]); + return true; case 0x2c: // space bar play_word_game(); From d84d358c00c0571fe9fc8a687ef8e7f949ddb8a8 Mon Sep 17 00:00:00 2001 From: "Vincent@524" Date: Tue, 26 Nov 2013 16:38:54 +0800 Subject: [PATCH 2/4] added Workman layout and removed unnecessary comments --- keymapper.ino | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/keymapper.ino b/keymapper.ino index 91c5169..ce62b95 100644 --- a/keymapper.ino +++ b/keymapper.ino @@ -1,3 +1,17 @@ +/* +Usage: Convert standard QWERTY keyboard to any keyboard layout you want +Default layout: QWERTY +Reserved key combination to switch layout: +Ctrl-Shift 0 => QWERTY (DEFAULT) +Ctrl-Shift 1 => tarmak1 +Ctrl-Shift 2 => tarmak2 +Ctrl-Shift 3 => tarmak3 +Ctrl-Shift 4 => tarmak4 +Ctrl-Shift 5 => Colemak +Ctrl-Shift 6 => Dvorak +Ctrl-Shift 7 => Workman +*/ + #include #include #include @@ -8,6 +22,7 @@ #define modeLED 13 //#define TEENSY + // function definitions bool HandleReservedKeystrokes(HID *hid, uint8_t *buf); inline void SendKeysToHost (uint8_t *buf); @@ -24,7 +39,8 @@ typedef enum tarmak3, tarmak4, colemak, - dvorak + dvorak, + workman } KeyboardLayout; // Keymap based on the scancodes from 4 to 57, refer to the HID usage table on the meaning of each element @@ -35,6 +51,7 @@ PROGMEM prog_uint8_t tarmak3Keymap[] = {4, 5, 6, 7, 9, 23, 51, 11, 12, 17, 8, 15 PROGMEM prog_uint8_t tarmak4Keymap[] = {4, 5, 6, 7, 9, 23, 51, 11, 24, 17, 8, 12, 16, 14, 28, 19, 20, 21, 22, 10, 15, 25, 26, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 18, 52, 53, 54, 55, 56, 42}; PROGMEM prog_uint8_t colemakKeymap[] = {4, 5, 6, 22, 9, 23, 7, 11, 24, 17, 8, 12, 16, 14, 28, 51, 20, 19, 21, 10, 15, 25, 26, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 18, 52, 53, 54, 55, 56, 42}; PROGMEM prog_uint8_t dvorakKeymap[] = {4, 27, 13, 8, 55, 24, 12, 7, 6, 11, 23, 17, 16, 5, 21, 15, 52, 19, 18, 28, 10, 14, 54, 20, 9, 51, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 47, 48, 56, 46, 49, 50, 22, 45, 53, 26, 25, 29, 57}; +PROGMEM prog_uint8_t workmanKeymap[] = {4, 25, 16, 11, 21, 23, 10, 28, 24, 17, 8, 18, 15, 14, 19, 51, 20, 26, 22, 5, 9, 6, 7, 27, 13, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 52, 53, 54, 55, 56, 42}; const uint8_t *Keymap[] = @@ -45,7 +62,8 @@ const uint8_t *Keymap[] = tarmak3Keymap, tarmak4Keymap, colemakKeymap, - dvorakKeymap + dvorakKeymap, + workmanKeymap }; // global variables @@ -210,6 +228,12 @@ bool HandleReservedKeystrokes(HID *hid, uint8_t *buf) // return true if it is a digitalWrite(modeLED, HIGH); LatchKey(buf[keyPosition]); return true; + + case 0x24: // 7 + CurrentLayout = workman; + digitalWrite(modeLED, HIGH); + LatchKey(buf[keyPosition]); + return true; case 0x2c: // space bar play_word_game(); @@ -321,9 +345,6 @@ uint32_t next_time; KbdRptParser Prs; - - - void setup() @@ -360,4 +381,3 @@ void loop() Usb.Task(); } - From a9a5c69cbcf17a799538ae6d5809adaa001aa080 Mon Sep 17 00:00:00 2001 From: proxhotdog Date: Tue, 26 Nov 2013 17:07:39 +0800 Subject: [PATCH 3/4] Added README.md --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b330479 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +Description +===== +* Keymapper - An Arduino-based hardware QWERTY keyboard layout remapper. +* Last updated: 26 November 2013 + +What you can do with it? +==== +1. You can design your own keyboard layout with real hardware support +2. You can cheat your friend with it or do some other evil things :P +3. Just think about it! + + +How to use this +==== +##Hardware support +* Arduino Leonardo with [Circuits@Home USB Host Shield 2.0](http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled) +* Teensy 2.0 with [Circuits@Home USB Host Shield for Arduino Pro Mini](http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini) + +##Hardware assemble +1. Stack the USB Host Shield on top of Arduino Leonardo, for Teensy, soldering work is required, you may refer to [this page](http://forum.colemak.com/viewtopic.php?id=1561) + +2. Import [USB Host Shield 2.0 library](https://github.com/felis/USB_Host_Shield_2.0) to Arduino IDE + +3. Connect the stack to your computer and upload the sketch + +4. Plug your USB keyboard to the USB Host shield + +5. Done! Happy keyboard hacking :) + +##Keyboard layout switching +* QWERTY is the default layout +* To change layout, press: + - CTRL+SHIFT+0: QWERTY (Default) + - CTRL+SHIFT+1: Tarmak1 + - CTRL+SHIFT+2: Tarmak2 + - CTRL+SHIFT+3: Tarmak3 + - CTRL+SHIFT+4: Tarmak4 + - CTRL+SHIFT+5: Colemak + - CTRL+SHIFT+6: Dvorak + - CTRL+SHIFT+7: Workman + + +Acknowledgement +=== +Thanks to original author: [darkytoothpaste](https://github.com/darkytoothpaste/keymapper) + From 4ed4d19dbc37563b70e809d380964ee137cbefb5 Mon Sep 17 00:00:00 2001 From: proxhotdog Date: Wed, 27 Nov 2013 01:08:14 +0800 Subject: [PATCH 4/4] Updated README.md and added a comment in keymapper.ino --- README.md | 2 +- keymapper.ino | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b330479..e0c9284 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ What you can do with it? 3. Just think about it! -How to use this +How to use this? ==== ##Hardware support * Arduino Leonardo with [Circuits@Home USB Host Shield 2.0](http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled) diff --git a/keymapper.ino b/keymapper.ino index ce62b95..4d10637 100644 --- a/keymapper.ino +++ b/keymapper.ino @@ -20,7 +20,7 @@ Ctrl-Shift 7 => Workman //#define DEBUG #define modeLED 13 -//#define TEENSY +//#define TEENSY //uncomment this line if you are usin Teensy // function definitions