changeset 34:5425548818d3

Adding support for the Micro Switch 8304 Hall Effect Keyboard - Full support (NKRO, provided the USB module can handle it) - Full LED support (available to the macro modules per input signals) - Reset/Hold line support - Handles repeat rate issues (keyboard does not send key updates as most keyboards do...)
author Jacob Alexander <triplehaata@gmail.com>
date Sun, 13 Nov 2011 02:04:44 -0800
parents df192346cf95
children 45fcd87055d2
files CMakeLists.txt Keymap/keymap.h Keymap/microswitch8304.h Keymap/usb_keys.h Macro/buffer/macro.c Macro/buffer/macro.h Macro/buffer/setup.cmake Scan/MicroSwitch8304/scan_loop.c Scan/MicroSwitch8304/scan_loop.h Scan/MicroSwitch8304/setup.cmake main.c setup.cmake
diffstat 12 files changed, 1179 insertions(+), 229 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Thu Nov 03 00:09:10 2011 -0700
+++ b/CMakeLists.txt	Sun Nov 13 02:04:44 2011 -0800
@@ -13,6 +13,10 @@
 cmake_force_cxx_compiler( avr-g++ AVRCxxCompiler )
 
 
+#| Add Dependency Macro
+include( AddFileDependencies )
+
+
 ###
 # Project Description
 #
@@ -38,7 +42,13 @@
 
 #| Instead, include the module source selector
 include( setup.cmake )
-set( SRCS main.c ${SCAN_SRCS} ${MACRO_SRCS} ${USB_SRCS} ${DEBUG_SRCS} )
+set( SRCS
+	main.c
+	${SCAN_SRCS}
+	${MACRO_SRCS}
+	${USB_SRCS}
+	${DEBUG_SRCS}
+)
 
 
 
@@ -54,7 +64,7 @@
 #| "atmega32u4"       # Teensy   2.0
 #| "at90usb646"       # Teensy++ 1.0
 #| "at90usb1286"      # Teensy++ 2.0
-set( MCU "at90usb1286" )
+set( MCU "atmega32u4" )
 
 
 #| Compiler flag to set the C Standard level.
--- a/Keymap/keymap.h	Thu Nov 03 00:09:10 2011 -0700
+++ b/Keymap/keymap.h	Sun Nov 13 02:04:44 2011 -0800
@@ -44,6 +44,7 @@
 #include "budkeypad.h"
 #include "heathzenith.h"
 #include "kaypro1.h"
+#include "microswitch8304.h"
 #include "tandy1000.h"
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keymap/microswitch8304.h	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,296 @@
+/* Copyright (C) 2011 by Jacob Alexander
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __TANDY1000_H
+#define __TANDY1000_H
+
+// This file contains various key layouts for the Tandy 1000 keyboard
+
+
+// ----- Variables -----
+static uint8_t microswitch8304_ModifierMask[] = { 0x48, 0x49, 0x4C, 0x4D, 0x45, 0x14 };
+
+static uint8_t microswitch8304_DefaultMap[] = { 
+				KEY_TILDE, // 0x00
+				KEY_UP, // 0x01
+				0, // 0x02
+				0, // 0x03
+				KEY_PRINTSCREEN, // 0x04
+				KEY_PAGE_DOWN, // 0x05
+				KEY_LEFT_BRACE, // 0x06
+				KEY_F11, // 0x07
+				KEY_BACKSPACE, // 0x08
+				KEY_TAB, // 0x09
+				KEY_ENTER, // 0x0A
+				KEY_DOWN, // 0x0B
+				KEY_PAGE_UP, // 0x0C
+				KEYPAD_ENTER, // 0x0D
+				KEY_LEFT, // 0x0E
+				KEY_RIGHT, // 0x0F
+				0, // 0x10
+				KEY_PAGE_UP, // 0x11
+				KEY_F12, // 0x12
+				KEY_PAGE_DOWN, // 0x13
+				KEY_GUI, // 0x14
+				KEY_F1, // 0x15
+				KEY_F2, // 0x16
+				KEY_F3, // 0x17
+				KEY_F4, // 0x18
+				KEY_F5, // 0x19
+				KEY_F6, // 0x1A
+				KEY_ESC, // 0x1B
+				KEY_F7, // 0x1C
+				KEY_F8, // 0x1D
+				KEY_F9, // 0x1E
+				KEY_F10, // 0x1F
+				KEY_SPACE, // 0x20
+				KEYPAD_9, // 0x21
+				0, // 0x22
+				0, // 0x23
+				0, // 0x24
+				0, // 0x25
+				0, // 0x26
+				KEY_QUOTE, // 0x27
+				0, // 0x28
+				0, // 0x29
+				0, // 0x2A
+				KEY_EQUAL, // 0x2B
+				KEY_COMMA, // 0x2C
+				KEY_MINUS, // 0x2D
+				KEY_PERIOD, // 0x2E
+				KEY_SLASH, // 0x2F
+				KEY_0, // 0x30
+				KEY_1, // 0x31
+				KEY_2, // 0x32
+				KEY_3, // 0x33
+				KEY_4, // 0x34
+				KEY_5, // 0x35
+				KEY_6, // 0x36
+				KEY_7, // 0x37
+				KEY_8, // 0x38
+				KEY_9, // 0x39
+				0, // 0x3A
+				KEY_SEMICOLON, // 0x3B
+				0, // 0x3C
+				KEY_EQUAL, // 0x3D
+				0, // 0x3E
+				0, // 0x3F
+				0, // 0x40
+				KEYPAD_6, // 0x41
+				KEYPAD_MINUS, // 0x42
+				KEY_PAUSE, // 0x43
+				KEY_INSERT, // 0x44
+				KEY_CTRL, // 0x45
+				KEYPAD_2, // 0x46
+				KEYPAD_3, // 0x47
+				KEY_LEFT_SHIFT, // 0x48
+				KEY_RIGHT_SHIFT, // 0x49
+				KEYPAD_0, // 0x4A
+				KEYPAD_PERIOD, // 0x4B
+				KEY_LEFT_ALT, // 0x4C
+				KEY_RIGHT_ALT, // 0x4D
+				0, // 0x4E
+				0, // 0x4F
+				0, // 0x50
+				0, // 0x51
+				0, // 0x52
+				0, // 0x53
+				0, // 0x54
+				0, // 0x55
+				0, // 0x56
+				0, // 0x57
+				0, // 0x58
+				0, // 0x59
+				0, // 0x5A
+				KEY_RIGHT_BRACE, // 0x5B
+				KEYPAD_7, // 0x5C
+				KEY_BACKSLASH, // 0x5D
+				KEY_ESC, // 0x5E
+				0, // 0x5F
+				KEYPAD_1, // 0x60
+				KEY_A, // 0x61
+				KEY_B, // 0x62
+				KEY_C, // 0x63
+				KEY_D, // 0x64
+				KEY_E, // 0x65
+				KEY_F, // 0x66
+				KEY_G, // 0x67
+				KEY_H, // 0x68
+				KEY_I, // 0x69
+				KEY_J, // 0x6A
+				KEY_K, // 0x6B
+				KEY_L, // 0x6C
+				KEY_M, // 0x6D
+				KEY_N, // 0x6E
+				KEY_O, // 0x6F
+				KEY_P, // 0x70
+				KEY_Q, // 0x71
+				KEY_R, // 0x72
+				KEY_S, // 0x73
+				KEY_T, // 0x74
+				KEY_U, // 0x75
+				KEY_V, // 0x76
+				KEY_W, // 0x77
+				KEY_X, // 0x78
+				KEY_Y, // 0x79
+				KEY_Z, // 0x7A
+				KEYPAD_4, // 0x7B
+				KEYPAD_8, // 0x7C
+				KEYPAD_5, // 0x7D
+				0, // 0x7E
+				KEY_DELETE, // 0x7F
+};
+
+static uint8_t microswitch8304_ColemakMap[] = {
+				KEY_TILDE, // 0x00
+				KEY_UP, // 0x01
+				0, // 0x02
+				0, // 0x03
+				KEY_PRINTSCREEN, // 0x04
+				KEY_PAGE_DOWN, // 0x05
+				KEY_LEFT_BRACE, // 0x06
+				KEY_F11, // 0x07
+				KEY_BACKSPACE, // 0x08
+				KEY_TAB, // 0x09
+				KEY_ENTER, // 0x0A
+				KEY_DOWN, // 0x0B
+				KEY_PAGE_UP, // 0x0C
+				KEYPAD_ENTER, // 0x0D
+				KEY_LEFT, // 0x0E
+				KEY_RIGHT, // 0x0F
+				0, // 0x10
+				KEY_PAGE_UP, // 0x11
+				KEY_F12, // 0x12
+				KEY_PAGE_DOWN, // 0x13
+				KEY_GUI, // 0x14
+				KEY_F1, // 0x15
+				KEY_F2, // 0x16
+				KEY_F3, // 0x17
+				KEY_F4, // 0x18
+				KEY_F5, // 0x19
+				KEY_F6, // 0x1A
+				KEY_ESC, // 0x1B
+				KEY_F7, // 0x1C
+				KEY_F8, // 0x1D
+				KEY_F9, // 0x1E
+				KEY_F10, // 0x1F
+				KEY_SPACE, // 0x20
+				KEYPAD_9, // 0x21
+				0, // 0x22
+				0, // 0x23
+				0, // 0x24
+				0, // 0x25
+				0, // 0x26
+				KEY_QUOTE, // 0x27
+				0, // 0x28
+				0, // 0x29
+				0, // 0x2A
+				KEY_EQUAL, // 0x2B
+				KEY_COMMA, // 0x2C
+				KEY_MINUS, // 0x2D
+				KEY_PERIOD, // 0x2E
+				KEY_SLASH, // 0x2F
+				KEY_0, // 0x30
+				KEY_1, // 0x31
+				KEY_2, // 0x32
+				KEY_3, // 0x33
+				KEY_4, // 0x34
+				KEY_5, // 0x35
+				KEY_6, // 0x36
+				KEY_7, // 0x37
+				KEY_8, // 0x38
+				KEY_9, // 0x39
+				0, // 0x3A
+				KEY_O, // 0x3B
+				0, // 0x3C
+				KEY_EQUAL, // 0x3D
+				0, // 0x3E
+				0, // 0x3F
+				0, // 0x40
+				KEYPAD_6, // 0x41
+				KEYPAD_MINUS, // 0x42
+				KEY_PAUSE, // 0x43
+				KEY_INSERT, // 0x44
+				KEY_CTRL, // 0x45
+				KEYPAD_2, // 0x46
+				KEYPAD_3, // 0x47
+				KEY_LEFT_SHIFT, // 0x48
+				KEY_RIGHT_SHIFT, // 0x49
+				KEYPAD_0, // 0x4A
+				KEYPAD_PERIOD, // 0x4B
+				KEY_LEFT_ALT, // 0x4C
+				KEY_RIGHT_ALT, // 0x4D
+				0, // 0x4E
+				0, // 0x4F
+				0, // 0x50
+				0, // 0x51
+				0, // 0x52
+				0, // 0x53
+				0, // 0x54
+				0, // 0x55
+				0, // 0x56
+				0, // 0x57
+				0, // 0x58
+				0, // 0x59
+				0, // 0x5A
+				KEY_RIGHT_BRACE, // 0x5B
+				KEYPAD_7, // 0x5C
+				KEY_BACKSLASH, // 0x5D
+				KEY_ESC, // 0x5E
+				0, // 0x5F
+				KEYPAD_1, // 0x60
+				KEY_A, // 0x61
+				KEY_B, // 0x62
+				KEY_C, // 0x63
+				KEY_S, // 0x64
+				KEY_F, // 0x65
+				KEY_T, // 0x66
+				KEY_D, // 0x67
+				KEY_H, // 0x68
+				KEY_U, // 0x69
+				KEY_N, // 0x6A
+				KEY_E, // 0x6B
+				KEY_I, // 0x6C
+				KEY_M, // 0x6D
+				KEY_K, // 0x6E
+				KEY_Y, // 0x6F
+				KEY_SEMICOLON, // 0x70
+				KEY_Q, // 0x71
+				KEY_P, // 0x72
+				KEY_R, // 0x73
+				KEY_G, // 0x74
+				KEY_L, // 0x75
+				KEY_V, // 0x76
+				KEY_W, // 0x77
+				KEY_X, // 0x78
+				KEY_J, // 0x79
+				KEY_Z, // 0x7A
+				KEYPAD_4, // 0x7B
+				KEYPAD_8, // 0x7C
+				KEYPAD_5, // 0x7D
+				0, // 0x7E
+				KEY_DELETE, // 0x7F
+};
+
+
+
+#endif
+
--- a/Keymap/usb_keys.h	Thu Nov 03 00:09:10 2011 -0700
+++ b/Keymap/usb_keys.h	Sun Nov 13 02:04:44 2011 -0800
@@ -25,237 +25,237 @@
 // ----- Defines -----
 
 // List of Modifiers
-#define KEY_CTRL	0x01
-#define KEY_SHIFT	0x02
-#define KEY_ALT		0x04
-#define KEY_GUI		0x08
-#define KEY_LEFT_CTRL	0x01
-#define KEY_LEFT_SHIFT	0x02
-#define KEY_LEFT_ALT	0x04
-#define KEY_LEFT_GUI	0x08
-#define KEY_RIGHT_CTRL	0x10
-#define KEY_RIGHT_SHIFT	0x20
-#define KEY_RIGHT_ALT	0x40
-#define KEY_RIGHT_GUI	0x80
+#define KEY_CTRL          0x01
+#define KEY_SHIFT         0x02
+#define KEY_ALT	          0x04
+#define KEY_GUI	          0x08
+#define KEY_LEFT_CTRL     0x01
+#define KEY_LEFT_SHIFT    0x02
+#define KEY_LEFT_ALT      0x04
+#define KEY_LEFT_GUI      0x08
+#define KEY_RIGHT_CTRL    0x10
+#define KEY_RIGHT_SHIFT   0x20
+#define KEY_RIGHT_ALT     0x40
+#define KEY_RIGHT_GUI     0x80
 
 // List of Keycodes
-#define KEY_A           4
-#define KEY_B           5
-#define KEY_C           6
-#define KEY_D           7
-#define KEY_E           8
-#define KEY_F           9
-#define KEY_G           10
-#define KEY_H           11
-#define KEY_I           12
-#define KEY_J           13
-#define KEY_K           14
-#define KEY_L           15
-#define KEY_M           16
-#define KEY_N           17
-#define KEY_O           18
-#define KEY_P           19
-#define KEY_Q           20
-#define KEY_R           21
-#define KEY_S           22
-#define KEY_T           23
-#define KEY_U           24
-#define KEY_V           25
-#define KEY_W           26
-#define KEY_X           27
-#define KEY_Y           28
-#define KEY_Z           29
-#define KEY_1           30
-#define KEY_2           31
-#define KEY_3           32
-#define KEY_4           33
-#define KEY_5           34
-#define KEY_6           35
-#define KEY_7           36
-#define KEY_8           37
-#define KEY_9           38
-#define KEY_0           39
-#define KEY_ENTER       40
-#define KEY_ESC         41
-#define KEY_BACKSPACE   42
-#define KEY_TAB         43
-#define KEY_SPACE       44
-#define KEY_MINUS       45
-#define KEY_EQUAL       46
-#define KEY_LEFT_BRACE  47
-#define KEY_RIGHT_BRACE 48
-#define KEY_BACKSLASH   49
-#define KEY_NUMBER      50
-#define KEY_SEMICOLON   51
-#define KEY_QUOTE       52
-#define KEY_TILDE       53
-#define KEY_COMMA       54
-#define KEY_PERIOD      55
-#define KEY_SLASH       56
-#define KEY_CAPS_LOCK   57
-#define KEY_F1          58
-#define KEY_F2          59
-#define KEY_F3          60
-#define KEY_F4          61
-#define KEY_F5          62
-#define KEY_F6          63
-#define KEY_F7          64
-#define KEY_F8          65
-#define KEY_F9          66
-#define KEY_F10         67
-#define KEY_F11         68
-#define KEY_F12         69
-#define KEY_PRINTSCREEN 70
-#define KEY_SCROLL_LOCK 71
-#define KEY_PAUSE       72
-#define KEY_INSERT      73
-#define KEY_HOME        74
-#define KEY_PAGE_UP     75
-#define KEY_DELETE      76
-#define KEY_END         77
-#define KEY_PAGE_DOWN   78
-#define KEY_RIGHT       79
-#define KEY_LEFT        80
-#define KEY_DOWN        81
-#define KEY_UP          82
-#define KEY_NUM_LOCK    83
-#define KEYPAD_SLASH    84
-#define KEYPAD_ASTERIX  85
-#define KEYPAD_MINUS    86
-#define KEYPAD_PLUS     87
-#define KEYPAD_ENTER    88
-#define KEYPAD_1        89
-#define KEYPAD_2        90
-#define KEYPAD_3        91
-#define KEYPAD_4        92
-#define KEYPAD_5        93
-#define KEYPAD_6        94
-#define KEYPAD_7        95
-#define KEYPAD_8        96
-#define KEYPAD_9        97
-#define KEYPAD_0        98
-#define KEYPAD_PERIOD   99
-#define KEY_ISO_BACKSLASH 100
-#define KEY_APP         101
-#define KEYBOARD_ERROR  102 // See spec
-#define KEYPAD_EQUAL    103
-#define KEY_F13         104
-#define KEY_F14         105
-#define KEY_F15         106
-#define KEY_F16         107
-#define KEY_F17         108
-#define KEY_F18         109
-#define KEY_F19         110
-#define KEY_F20         111
-#define KEY_F21         112
-#define KEY_F22         113
-#define KEY_F23         114
-#define KEY_F24         115
-#define KEY_EXEC        116
-#define KEY_HELP        117
-#define KEY_MENU        118
-#define KEY_SELECT      119
-#define KEY_STOP        120
-#define KEY_AGAIN       121
-#define KEY_UNDO        122
-#define KEY_CUT         123
-#define KEY_COPY        124
-#define KEY_PASTE       125
-#define KEY_FIND        126
-#define KEY_MUTE        127
-#define KEY_VOL_UP      128
-#define KEY_VOL_DOWN    129
-#define KEY_CAPS_LLOCK  130 // "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
-#define KEY_NUM_LLOCK   131
-#define KEY_SCROLL_LLOCK 132
-#define KEYPAD_COMMA    133 // Brazillian (See spec)
-#define KEYPAD_EQUAL_AS 134 // AS/400 Keyboard (See spec)
-#define KEY_INTER1      135 // Brazillian and Japanese "Ru"
-#define KEY_INTER2      136 // Japanese Katakana/Hiragana
-#define KEY_INTER3      137 // Japanese Yen
-#define KEY_INTER4      138 // Japanese Henkan
-#define KEY_INTER5      139 // Japanese Muhenkan
-#define KEY_INTER6      140 // PC98 Comma (Ka-m-ma)
-#define KEY_INTER7      141 // Double-Byte/Single-Byte Toggle
-#define KEY_INTER8      142 // Undefined
-#define KEY_INTER9      143 // Undefined
-#define KEY_LANG1       144 // Korean Hangul/English Toggle
-#define KEY_LANG2       145 // Korean Hanja Conversion
-#define KEY_LANG3       146 // Japanese Katakana Key (USB)
-#define KEY_LANG4       147 // Japanese Hiragana Key (USB)
-#define KEY_LANG5       148 // Japanese Zenkaku/Hankaku Key (USB)
-#define KEY_LANG6       149 // Reserved (Application Specific)
-#define KEY_LANG7       150 // Reserved (Application Specific)
-#define KEY_LANG8       151 // Reserved (Application Specific)
-#define KEY_LANG9       152 // Reserved (Application Specific)
-#define KEY_ALT_ERASE   153 // Special Erase (See Spec)
-#define KEY_SYSREQ_ATT  154 // Modifier Type
-#define KEY_CANCEL      155
-#define KEY_CLEAR       156
-#define KEY_PRIOR       157
-#define KEY_RETURN      158
-#define KEY_SEPARATOR   159
-#define KEY_OUT         160
-#define KEY_OPER        161
-#define KEY_CLEAR_AGAIN 162
-#define KEY_CRSEL_PROPS 163
-#define KEY_EXSEL       164
+#define KEY_A                4
+#define KEY_B                5
+#define KEY_C                6
+#define KEY_D                7
+#define KEY_E                8
+#define KEY_F                9
+#define KEY_G               10
+#define KEY_H               11
+#define KEY_I               12
+#define KEY_J               13
+#define KEY_K               14
+#define KEY_L               15
+#define KEY_M               16
+#define KEY_N               17
+#define KEY_O               18
+#define KEY_P               19
+#define KEY_Q               20
+#define KEY_R               21
+#define KEY_S               22
+#define KEY_T               23
+#define KEY_U               24
+#define KEY_V               25
+#define KEY_W               26
+#define KEY_X               27
+#define KEY_Y               28
+#define KEY_Z               29
+#define KEY_1               30
+#define KEY_2               31
+#define KEY_3               32
+#define KEY_4               33
+#define KEY_5               34
+#define KEY_6               35
+#define KEY_7               36
+#define KEY_8               37
+#define KEY_9               38
+#define KEY_0               39
+#define KEY_ENTER           40
+#define KEY_ESC             41
+#define KEY_BACKSPACE       42
+#define KEY_TAB             43
+#define KEY_SPACE           44
+#define KEY_MINUS           45
+#define KEY_EQUAL           46
+#define KEY_LEFT_BRACE      47
+#define KEY_RIGHT_BRACE     48
+#define KEY_BACKSLASH       49
+#define KEY_NUMBER          50
+#define KEY_SEMICOLON       51
+#define KEY_QUOTE           52
+#define KEY_TILDE           53
+#define KEY_COMMA           54
+#define KEY_PERIOD          55
+#define KEY_SLASH           56
+#define KEY_CAPS_LOCK       57
+#define KEY_F1              58
+#define KEY_F2              59
+#define KEY_F3              60
+#define KEY_F4              61
+#define KEY_F5              62
+#define KEY_F6              63
+#define KEY_F7              64
+#define KEY_F8              65
+#define KEY_F9              66
+#define KEY_F10             67
+#define KEY_F11             68
+#define KEY_F12             69
+#define KEY_PRINTSCREEN     70
+#define KEY_SCROLL_LOCK     71
+#define KEY_PAUSE           72
+#define KEY_INSERT          73
+#define KEY_HOME            74
+#define KEY_PAGE_UP         75
+#define KEY_DELETE          76
+#define KEY_END             77
+#define KEY_PAGE_DOWN       78
+#define KEY_RIGHT           79
+#define KEY_LEFT            80
+#define KEY_DOWN            81
+#define KEY_UP              82
+#define KEY_NUM_LOCK        83
+#define KEYPAD_SLASH        84
+#define KEYPAD_ASTERIX      85
+#define KEYPAD_MINUS        86
+#define KEYPAD_PLUS         87
+#define KEYPAD_ENTER        88
+#define KEYPAD_1            89
+#define KEYPAD_2            90
+#define KEYPAD_3            91
+#define KEYPAD_4            92
+#define KEYPAD_5            93
+#define KEYPAD_6            94
+#define KEYPAD_7            95
+#define KEYPAD_8            96
+#define KEYPAD_9            97
+#define KEYPAD_0            98
+#define KEYPAD_PERIOD       99
+#define KEY_ISO_BACKSLASH  100
+#define KEY_APP            101
+#define KEYBOARD_ERROR     102 // See spec
+#define KEYPAD_EQUAL       103
+#define KEY_F13            104
+#define KEY_F14            105
+#define KEY_F15            106
+#define KEY_F16            107
+#define KEY_F17            108
+#define KEY_F18            109
+#define KEY_F19            110
+#define KEY_F20            111
+#define KEY_F21            112
+#define KEY_F22            113
+#define KEY_F23            114
+#define KEY_F24            115
+#define KEY_EXEC           116
+#define KEY_HELP           117
+#define KEY_MENU           118
+#define KEY_SELECT         119
+#define KEY_STOP           120
+#define KEY_AGAIN          121
+#define KEY_UNDO           122
+#define KEY_CUT            123
+#define KEY_COPY           124
+#define KEY_PASTE          125
+#define KEY_FIND           126
+#define KEY_MUTE           127
+#define KEY_VOL_UP         128
+#define KEY_VOL_DOWN       129
+#define KEY_CAPS_LLOCK     130 // "Locking" Scroll Lock (Old keyboards with Locking Caps Lock)
+#define KEY_NUM_LLOCK      131
+#define KEY_SCROLL_LLOCK   132
+#define KEYPAD_COMMA       133 // Brazillian (See spec)
+#define KEYPAD_EQUAL_AS    134 // AS/400 Keyboard (See spec)
+#define KEY_INTER1         135 // Brazillian and Japanese "Ru"
+#define KEY_INTER2         136 // Japanese Katakana/Hiragana
+#define KEY_INTER3         137 // Japanese Yen
+#define KEY_INTER4         138 // Japanese Henkan
+#define KEY_INTER5         139 // Japanese Muhenkan
+#define KEY_INTER6         140 // PC98 Comma (Ka-m-ma)
+#define KEY_INTER7         141 // Double-Byte/Single-Byte Toggle
+#define KEY_INTER8         142 // Undefined
+#define KEY_INTER9         143 // Undefined
+#define KEY_LANG1          144 // Korean Hangul/English Toggle
+#define KEY_LANG2          145 // Korean Hanja Conversion
+#define KEY_LANG3          146 // Japanese Katakana Key (USB)
+#define KEY_LANG4          147 // Japanese Hiragana Key (USB)
+#define KEY_LANG5          148 // Japanese Zenkaku/Hankaku Key (USB)
+#define KEY_LANG6          149 // Reserved (Application Specific)
+#define KEY_LANG7          150 // Reserved (Application Specific)
+#define KEY_LANG8          151 // Reserved (Application Specific)
+#define KEY_LANG9          152 // Reserved (Application Specific)
+#define KEY_ALT_ERASE      153 // Special Erase (See Spec)
+#define KEY_SYSREQ_ATT     154 // Modifier Type
+#define KEY_CANCEL         155
+#define KEY_CLEAR          156
+#define KEY_PRIOR          157
+#define KEY_RETURN         158
+#define KEY_SEPARATOR      159
+#define KEY_OUT            160
+#define KEY_OPER           161
+#define KEY_CLEAR_AGAIN    162
+#define KEY_CRSEL_PROPS    163
+#define KEY_EXSEL          164
 // 165 - 175 Reserved
-#define KEYPAD_00       176
-#define KEYPAD_000      177
-#define KEY_1000_SEP    178
-#define KEY_DECIMAL_SEP 179
-#define KEY_CURRENCY_MAIN 180
-#define KEY_CURRENCY_SUB 181
-#define KEYPAD_LPAREN   182
-#define KEYPAD_RPAREN   183
-#define KEYPAD_LBRACE   184
-#define KEYPAD_RBRACE   185
-#define KEYPAD_TAB      186
-#define KEYPAD_BACKSPACE 187
-#define KEYPAD_A        188
-#define KEYPAD_B        189
-#define KEYPAD_C        190
-#define KEYPAD_D        191
-#define KEYPAD_E        192
-#define KEYPAD_F        193
-#define KEYPAD_XOR      194
-#define KEYPAD_CHEVRON  195
-#define KEYPAD_PERCENT  196
-#define KEYPAD_LTHAN    197
-#define KEYPAD_GTHAN    198
-#define KEYPAD_AND      199
-#define KEYPAD_AND_AND  200
-#define KEYPAD_OR       201
-#define KEYPAD_OR_OR    202
-#define KEYPAD_COLON    203
-#define KEYPAD_POUND    204
-#define KEYPAD_SPACE    205
-#define KEYPAD_AT       206
-#define KEYPAD_EXCLAIM  207
-#define KEYPAD_MEM_STORE 208
-#define KEYPAD_MEM_RECALL 209
-#define KEYPAD_MEM_CLEAR 210
-#define KEYPAD_MEM_ADD  211
-#define KEYPAD_MEM_SUB  212
-#define KEYPAD_MEM_MULT 213
-#define KEYPAD_MEM_DIV  214
-#define KEYPAD_PLUS_MINUS 215
-#define KEYPAD_CLEAR    216
+#define KEYPAD_00          176
+#define KEYPAD_000         177
+#define KEY_1000_SEP       178
+#define KEY_DECIMAL_SEP    179
+#define KEY_CURRENCY_MAIN  180
+#define KEY_CURRENCY_SUB   181
+#define KEYPAD_LPAREN      182
+#define KEYPAD_RPAREN      183
+#define KEYPAD_LBRACE      184
+#define KEYPAD_RBRACE      185
+#define KEYPAD_TAB         186
+#define KEYPAD_BACKSPACE   187
+#define KEYPAD_A           188
+#define KEYPAD_B           189
+#define KEYPAD_C           190
+#define KEYPAD_D           191
+#define KEYPAD_E           192
+#define KEYPAD_F           193
+#define KEYPAD_XOR         194
+#define KEYPAD_CHEVRON     195
+#define KEYPAD_PERCENT     196
+#define KEYPAD_LTHAN       197
+#define KEYPAD_GTHAN       198
+#define KEYPAD_AND         199
+#define KEYPAD_AND_AND     200
+#define KEYPAD_OR          201
+#define KEYPAD_OR_OR       202
+#define KEYPAD_COLON       203
+#define KEYPAD_POUND       204
+#define KEYPAD_SPACE       205
+#define KEYPAD_AT          206
+#define KEYPAD_EXCLAIM     207
+#define KEYPAD_MEM_STORE   208
+#define KEYPAD_MEM_RECALL  209
+#define KEYPAD_MEM_CLEAR   210
+#define KEYPAD_MEM_ADD     211
+#define KEYPAD_MEM_SUB     212
+#define KEYPAD_MEM_MULT    213
+#define KEYPAD_MEM_DIV     214
+#define KEYPAD_PLUS_MINUS  215
+#define KEYPAD_CLEAR       216
 #define KEYPAD_CLEAR_ENTRY 217
-#define KEYPAD_BINARY   218
-#define KEYPAD_OCTAL    219
-#define KEYPAD_DECIMAL  220
-#define KEYPAD_HEX      221
+#define KEYPAD_BINARY      218
+#define KEYPAD_OCTAL       219
+#define KEYPAD_DECIMAL     220
+#define KEYPAD_HEX         221
 // 222 - 223 Reserved
-#define KEYS_LCTRL      224
-#define KEYS_LSHIFT     225
-#define KEYS_LALT       226
-#define KEYS_LGUI       227
-#define KEYS_RCTRL      228
-#define KEYS_RSHIFT     229
-#define KEYS_RALT       230
-#define KEYS_RGUI       231
+#define KEYS_LCTRL         224
+#define KEYS_LSHIFT        225
+#define KEYS_LALT          226
+#define KEYS_LGUI          227
+#define KEYS_RCTRL         228
+#define KEYS_RSHIFT        229
+#define KEYS_RALT          230
+#define KEYS_RGUI          231
 // 232 - 65535 Reserved
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Macro/buffer/macro.c	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,244 @@
+/* Copyright (C) 2011 by Jacob Alexander
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// ----- Includes -----
+
+// AVR Includes
+#include <util/delay.h>
+#include <avr/interrupt.h>
+
+// Project Includes
+#include <led.h>
+#include <print.h>
+#include <scan_loop.h>
+#include <usb_com.h>
+
+// Keymaps
+#include <keymap.h>
+#include <usb_keys.h>
+
+// Local Includes
+#include "macro.h"
+
+
+
+// ----- Variables -----
+
+// Keeps track of the sequence used to reflash the teensy in software
+static uint8_t Bootloader_ConditionSequence[] = {1,16,6,11};
+       uint8_t Bootloader_ConditionState      = 0;
+       uint8_t Bootloader_NextPositionReady   = 1;
+
+
+
+// ----- Functions -----
+
+void jumpToBootloader(void)
+{
+	cli();
+	// disable watchdog, if enabled
+	// disable all peripherals
+	UDCON = 1;
+	USBCON = (1<<FRZCLK);  // disable USB
+	UCSR1B = 0;
+	_delay_ms(5);
+
+#if defined(__AVR_AT90USB162__)                // Teensy 1.0
+	EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0;
+	TIMSK0 = 0; TIMSK1 = 0; UCSR1B = 0;
+	DDRB = 0; DDRC = 0; DDRD = 0;
+	PORTB = 0; PORTC = 0; PORTD = 0;
+	asm volatile("jmp 0x3E00");
+#elif defined(__AVR_ATmega32U4__)              // Teensy 2.0
+	EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
+	TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0;
+	DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0;
+	PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
+	asm volatile("jmp 0x7E00");
+#elif defined(__AVR_AT90USB646__)              // Teensy++ 1.0
+	EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
+	TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
+	DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
+	PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
+	asm volatile("jmp 0xFC00");
+#elif defined(__AVR_AT90USB1286__)             // Teensy++ 2.0
+	EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
+	TIMSK0 = 0; TIMSK1 = 0; TIMSK2 = 0; TIMSK3 = 0; UCSR1B = 0; TWCR = 0;
+	DDRA = 0; DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0;
+	PORTA = 0; PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
+	asm volatile("jmp 0x1FC00");
+#endif
+}
+
+// Given a sampling array, and the current number of detected keypress
+// Add as many keypresses from the sampling array to the USB key send array as possible.
+/*
+inline void keyPressDetection( uint8_t *keys, uint8_t numberOfKeys, uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map )
+{
+	uint8_t Bootloader_KeyDetected = 0;
+	uint8_t processed_keys         = 0;
+
+	// Parse the detection array starting from 1 (all keys are purposefully mapped from 1 -> total as per typical PCB labels)
+	for ( uint8_t key = 0; key < numberOfKeys + 1; key++ )
+	{
+		if ( keys[key] & (1 << 7) )
+		{
+			processed_keys++;
+
+			// Display the detected scancode
+			char tmpStr[4];
+			int8ToStr( key, tmpStr );
+			dPrintStrs( tmpStr, " " );
+
+			// Is this a bootloader sequence key?
+			if ( !Bootloader_KeyDetected
+			   && Bootloader_NextPositionReady
+			   && key == Bootloader_ConditionSequence[Bootloader_ConditionState] )
+			{
+				Bootloader_KeyDetected = 1;
+				Bootloader_NextPositionReady = 0;
+				Bootloader_ConditionState++;
+			}
+			else if ( Bootloader_ConditionState > 0 && key == Bootloader_ConditionSequence[Bootloader_ConditionState - 1] )
+			{
+				Bootloader_KeyDetected = 1;
+			}
+
+			// Determine if the key is a modifier
+			uint8_t modFound = 0;
+			for ( uint8_t mod = 0; mod < numberOfModifiers; mod++ ) {
+				// Modifier found
+				if ( modifiers[mod] == key ) {
+					USBKeys_Modifiers |= map[key];
+					modFound = 1;
+					break;
+				}
+			}
+
+			// Modifier, already done this loop
+			if ( modFound )
+				continue;
+
+			// Too many keys
+			if ( USBKeys_Sent >= USBKeys_MaxSize )
+			{
+				info_print("USB Key limit reached");
+				errorLED( 1 );
+				break;
+			}
+
+			// Allow ignoring keys with 0's
+			if ( map[key] != 0 )
+				USBKeys_Array[USBKeys_Sent++] = map[key];
+		}
+	}
+
+	// Boot loader sequence state handler
+	switch ( processed_keys )
+	{
+	// The next bootloader key can now be pressed, if there were no keys processed
+	case 0:
+		Bootloader_NextPositionReady = 1;
+		break;
+	// If keys were detected, and it wasn't in the sequence (or there was multiple keys detected), start bootloader sequence over
+	// This case purposely falls through
+	case 1:
+		if ( Bootloader_KeyDetected )
+			break;
+	default:
+		Bootloader_ConditionState = 0;
+		break;
+	}
+
+	// Add debug separator if keys sent via USB
+	if ( USBKeys_Sent > 0 )
+		print("\033[1;32m|\033[0m\n");
+}
+*/
+
+// Given a list of keypresses, translate into the USB key codes
+// The buffer is cleared after running
+// If the buffer doesn't fit into the USB send array, the extra keys are dropped
+void keyPressBufferRead( uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map )
+{
+	// Loop through input buffer
+	for ( uint8_t index = 0; index < KeyIndex_BufferUsed; index++ )
+	{
+		// Get the keycode from the buffer
+		uint8_t key = KeyIndex_Buffer[index];
+
+		// Determine if the key is a modifier
+		uint8_t modFound = 0;
+		for ( uint8_t mod = 0; mod < numberOfModifiers; mod++ ) {
+			// Modifier found
+			if ( modifiers[mod] == key ) {
+				USBKeys_Modifiers |= map[key];
+				modFound = 1;
+				break;
+			}
+		}
+
+		// Modifier, already done this loop
+		if ( modFound )
+			continue;
+
+		// Too many keys
+		if ( USBKeys_Sent >= USBKeys_MaxSize )
+		{
+			info_print("USB Key limit reached");
+			errorLED( 1 );
+			break;
+		}
+
+		// Allow ignoring keys with 0's
+		if ( map[key] != 0 )
+		{
+			USBKeys_Array[USBKeys_Sent++] = map[key];
+		}
+		else
+		{
+			// Key was not mapped
+			// TODO Add dead key map
+			char tmpStr[6];
+			hexToStr( key, tmpStr );
+			erro_dPrint( "Key not mapped... - ", tmpStr );
+			errorLED( 1 );
+		}
+	}
+
+	// Signal buffer that we've used it
+	scan_finishedWithBuffer();
+}
+
+inline void process_macros(void)
+{
+	// Online process macros once (if some were found), until the next USB send
+	if ( USBKeys_Sent != 0 )
+		return;
+
+	// Query the input buffer for keypresses
+	keyPressBufferRead( MODIFIER_MASK, sizeof(MODIFIER_MASK), KEYINDEX_MASK );
+
+	// Check for bootloader condition
+	//if ( Bootloader_ConditionState == sizeof( Bootloader_ConditionSequence ) )
+	//	jumpToBootloader();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Macro/buffer/macro.h	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,38 @@
+/* Copyright (C) 2011 by Jacob Alexander
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __macro_h
+#define __macro_h
+
+// ----- Includes -----
+
+// Compiler Includes
+#include <stdint.h>
+
+
+
+// ----- Functions -----
+
+void keyPressDetection( uint8_t *keys, uint8_t numberOfKeys, uint8_t *modifiers, uint8_t numberOfModifiers, uint8_t *map );
+void process_macros(void);
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Macro/buffer/setup.cmake	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,22 @@
+###| CMake Kiibohd Controller Macro Module |###
+#
+# Written by Jacob Alexander in 2011 for the Kiibohd Controller
+#
+# Released into the Public Domain
+#
+###
+
+
+###
+# Module C files
+#
+
+set( MACRO_SRCS
+	macro.c
+)
+
+
+###
+# Module Specific Options
+#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Scan/MicroSwitch8304/scan_loop.c	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,225 @@
+/* Copyright (C) 2011 by Jacob Alexander
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+// ----- Includes -----
+
+// AVR Includes
+#include <avr/interrupt.h>
+#include <avr/io.h>
+#include <util/delay.h>
+
+// Project Includes
+#include <led.h>
+#include <print.h>
+
+// Local Includes
+#include "scan_loop.h"
+
+
+
+// ----- Defines -----
+
+// Pinout Defines
+#define RESET_PORT PORTB
+#define RESET_DDR   DDRD
+#define RESET_PIN      0
+
+
+// ----- Macros -----
+
+// Make sure we haven't overflowed the buffer
+#define bufferAdd(byte) \
+		if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
+			KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
+
+#define UNSET_RESET()   RESET_DDR &= ~(1 << RESET_PIN)
+#define   SET_RESET()   RESET_DDR |=  (1 << RESET_PIN)
+
+
+
+// ----- Variables -----
+
+// Buffer used to inform the macro processing module which keys have been detected as pressed
+volatile uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+volatile uint8_t KeyIndex_BufferUsed;
+
+
+// Buffer Signals
+volatile uint8_t BufferReadyToClear;
+
+
+
+// ----- Functions -----
+
+// Setup
+inline void scan_setup()
+{
+	// Setup the the USART interface for keyboard data input
+	// NOTE: The input data signal needs to be inverted for the Teensy USART to properly work
+	
+	// Setup baud rate
+	// 16 MHz / ( 16 * Baud ) = UBRR
+	// Baud <- 0.82020 ms per bit, thus 1000 / 0.82020 = 1219.2
+	// Thus baud = 820
+	uint16_t baud = 820; // Max setting of 4095
+	UBRR1H = (uint8_t)(baud >> 8);
+	UBRR1L = (uint8_t)baud;
+
+	// Enable the receiver, transitter, and RX Complete Interrupt
+	UCSR1B = 0x98;
+
+	// Set frame format: 8 data, no stop bits or parity
+	// Asynchrounous USART mode
+	// 8304 sends encoded scancodes (for example Alphanumeric 0-9 follows their keypad encoding scheme)
+	// Separate line is for reset
+	UCSR1C = 0x06;
+
+	// Initially buffer doesn't need to be cleared (it's empty...)
+	BufferReadyToClear = 0;
+}
+
+
+// Main Detection Loop
+// Not needed for the Micro Switch 8304, this is just a busy loop
+inline uint8_t scan_loop()
+{
+	return 0;
+}
+
+void processKeyValue( uint8_t keyValue )
+{
+	// Finalize output buffer
+	// Mask 8th bit
+	keyValue &= 0x7F;
+
+	// Interpret scan code
+	switch ( keyValue )
+	{
+	case 0x40: // Clear buffer command
+		info_print("CLEAR!");
+
+		BufferReadyToClear = 1;
+		break;
+	case 0x7F:
+		scan_lockKeyboard();
+		_delay_ms(3000);
+		scan_unlockKeyboard();
+
+	default:
+		// Make sure the key isn't already in the buffer
+		for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
+		{
+			// Key isn't in the buffer yet
+			if ( c == KeyIndex_BufferUsed )
+			{
+				bufferAdd( keyValue );
+				break;
+			}
+
+			// Key already in the buffer
+			if ( KeyIndex_Buffer[c] == keyValue )
+				break;
+		}
+		break;
+	}
+}
+
+// USART Receive Buffer Full Interrupt
+ISR(USART1_RX_vect)
+{
+	cli(); // Disable Interrupts
+
+	uint8_t keyValue = 0x00;
+
+	// The interrupt is always for the first item of the packet set, reset the buffer
+	KeyIndex_BufferUsed = 0;
+
+	// Only the first 7 bits have scancode data
+	// The last packet of the packet set has the 8th bit high, all the others are low
+	//
+	// Interrupts are too slow for the rest of the packet set, poll for the rest
+	while ( 1 )
+	{
+		// Read the raw packet from the USART
+		keyValue = UDR1;
+
+		// Debug
+		char tmpStr[6];
+		hexToStr( keyValue, tmpStr );
+		dPrintStrs( tmpStr, " " );
+
+		// Process the scancode
+		processKeyValue( keyValue );
+
+		// Last packet of the set
+		if ( keyValue & 0x80 )
+		{
+			dPrintStrs( "**" );
+			break;
+		}
+
+		// Delay enough so we don't run into the same packet (or the previous buffered packet)
+		_delay_us(10000);
+	}
+
+	sei(); // Re-enable Interrupts
+}
+
+// Send data 
+//
+// Keyboard Input Guide for Micro Switch 8304
+// 0xBX is for LED F1,F2,Over Type,Lock
+// 0xAX is for LED F3,F8,F9,F10
+// 0x92 resets keyboard (LED off, echo scancode mode off)
+// 0x9E sets echo scancode mode from (0x81 to 0xFF; translates to 0x01 to 0x7F)
+// Other echos: 0x15~0x19 send 0x15~0x19, 0x40 sends 0x40 (as well as 0x44,0x45, 0x80)
+// 0x8C Acks the keyboard and gets 0x70 sent back (delayed)
+uint8_t scan_sendData( uint8_t dataPayload )
+{
+	UDR1 = dataPayload;
+	return 0;
+}
+
+// Signal KeyIndex_Buffer that it has been properly read
+// In the case of the Micro Switch 8304, we leave the buffer alone until more scancode data comes in
+void scan_finishedWithBuffer( void )
+{
+	// We received a Clear code from the 8304, clear the buffer now that we've used it
+	if ( BufferReadyToClear )
+	{
+		KeyIndex_BufferUsed = 0;
+		BufferReadyToClear = 0;
+	}
+}
+
+// Reset/Hold keyboard
+// Warning! This will cause the keyboard to not send any data, so you can't disable with a keypress
+// The Micro Switch 8304 has a dedicated reset line
+void scan_lockKeyboard( void )
+{
+	UNSET_RESET();
+}
+
+void scan_unlockKeyboard( void )
+{
+	SET_RESET();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Scan/MicroSwitch8304/scan_loop.h	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,64 @@
+/* Copyright (C) 2011 by Jacob Alexander
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ * 
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#ifndef __SCAN_LOOP_H
+#define __SCAN_LOOP_H
+
+// ----- Includes -----
+
+// Compiler Includes
+#include <stdint.h>
+
+// Local Includes
+
+
+
+// ----- Defines -----
+
+#define KEYBOARD_SIZE 0x62 // 76 - Size of the array space for the keyboard(max index)
+#define KEYBOARD_BUFFER 24 // Max number of key signals to buffer
+
+
+
+// ----- Variables -----
+
+extern volatile     uint8_t KeyIndex_Buffer[KEYBOARD_BUFFER];
+extern volatile     uint8_t KeyIndex_BufferUsed;
+
+
+
+// ----- Functions -----
+
+// Functions used by main.c
+void scan_setup( void );
+uint8_t scan_loop( void );
+
+
+// Functions available to macro.c
+uint8_t scan_sendData( uint8_t dataPayload );
+
+void scan_finishedWithBuffer( void );
+void scan_lockKeyboard( void );
+void scan_unlockKeyboard( void );
+
+
+#endif // __SCAN_LOOP_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Scan/MicroSwitch8304/setup.cmake	Sun Nov 13 02:04:44 2011 -0800
@@ -0,0 +1,48 @@
+###| CMake Kiibohd Controller Scan Module |###
+#
+# Written by Jacob Alexander in 2011 for the Kiibohd Controller
+#
+# Released into the Public Domain
+#
+# For the Micro Switch 8304 Keyboard (No Branding)
+#
+###
+
+
+###
+# Module C files
+#
+
+set( SCAN_SRCS
+	scan_loop.c
+)
+
+
+###
+# Module H files
+#
+set( SCAN_HDRS
+	scan_loop.h
+)
+
+
+###
+# File Dependency Setup
+#
+ADD_FILE_DEPENDENCIES( scan_loop.c ${SCAN_HDRS} )
+#add_file_dependencies( scan_loop.c ${SCAN_HDRS} )
+#add_file_dependencies( macro.c keymap.h microswitch8304.h )
+
+
+###
+# Module Specific Options
+#
+add_definitions( -I${HEAD_DIR}/Keymap )
+
+#| Keymap Settings
+add_definitions(
+	-DMODIFIER_MASK=microswitch8304_ModifierMask
+	-DKEYINDEX_MASK=microswitch8304_ColemakMap
+	#-DKEYINDEX_MASK=microswitch8304_DefaultMap
+)
+
--- a/main.c	Thu Nov 03 00:09:10 2011 -0700
+++ b/main.c	Sun Nov 13 02:04:44 2011 -0800
@@ -146,6 +146,7 @@
 	}
 }
 
+// USB Keyboard Data Send Counter Interrupt
 ISR( TIMER0_OVF_vect )
 {
 	sendKeypressCounter++;
--- a/setup.cmake	Thu Nov 03 00:09:10 2011 -0700
+++ b/setup.cmake	Sun Nov 13 02:04:44 2011 -0800
@@ -20,7 +20,7 @@
 #| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones
 
 ##| Deals with acquiring the keypress information and turning it into a key index
-set(  ScanModule  "Kaypro1" )
+set(  ScanModule  "MicroSwitch8304" )
 
 ##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
 set( MacroModule  "buffer"  )
@@ -78,6 +78,7 @@
 
 	# Loop through items
 	foreach( item ${ARGN} )
+		# Set the path
 		set( tmpSource ${tmpSource} "${SourcesPath}/${item}" )
 	endforeach( item )