1
0
mirror of https://github.com/gdsports/keymapper synced 2024-11-21 08:45:05 -05:00

Merge pull request #1 from proxhotdog/master

Removed unnecessary defines and added colemak and workman layout
This commit is contained in:
darkytoothpaste 2013-11-26 09:49:20 -08:00
commit 32119ce9d0
2 changed files with 81 additions and 20 deletions

46
README.md Normal file
View File

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

View File

@ -1,25 +1,26 @@
/*
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 <avr/pgmspace.h>
#include <avrpins.h>
#include <max3421e.h>
#include <usbhost.h>
#include <usb_ch9.h>
#include <Usb.h>
#include <usbhub.h>
#include <address.h>
#include <hidboot.h>
#include <printhex.h>
#include <message.h>
#include <hexdump.h>
#include <parsetools.h>
#include "keymapper_game.h"
//#define DEBUG
#define modeLED 13
#define TEENSY
//#define TEENSY //uncomment this line if you are usin Teensy
// function definitions
@ -38,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
@ -48,6 +50,9 @@ 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};
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[] =
{
@ -56,7 +61,9 @@ const uint8_t *Keymap[] =
tarmak2Keymap,
tarmak3Keymap,
tarmak4Keymap,
colemakKeymap
colemakKeymap,
dvorakKeymap,
workmanKeymap
};
// global variables
@ -215,6 +222,18 @@ 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 0x24: // 7
CurrentLayout = workman;
digitalWrite(modeLED, HIGH);
LatchKey(buf[keyPosition]);
return true;
case 0x2c: // space bar
play_word_game();
@ -326,9 +345,6 @@ uint32_t next_time;
KbdRptParser Prs;
void setup()
@ -365,4 +381,3 @@ void loop()
Usb.Task();
}