]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Completed the FACOM 6684 converter...
authorJacob Alexander <triplehaata@gmail.com>
Mon, 21 Jan 2013 01:27:14 +0000 (20:27 -0500)
committerJacob Alexander <triplehaata@gmail.com>
Mon, 21 Jan 2013 01:27:14 +0000 (20:27 -0500)
Unfortunately, the protocol annoying, with only 3 keys having Press/Release signals.
Some of the keys were only meant to be pressed once, and do not have repeat functionality.

The current implementation is a bit slow, so some keys may get lost during USB sending.
This is probably fixable, not sure if I want to spend the time on it though.

There is a keyboard input protocol, but I'm not sure of what information can be transmitted to the keyboard.
The terminal does send some information back and forth between the keyboard, but I'm unclear of the purpose, as I can never get any response out of the keyboard.

Keymap/facom6684.h
Scan/FACOM6684/scan_loop.c

index 5812dc822e1d1661a18cca0bf32b7bd24f0321a3..07e40cd54451bbbe65a7cd032d172ff16456ac97 100644 (file)
 
 
 // ----- Variables -----
-static uint8_t facom6684_ModifierMask[] = { 0x20, 0x2D, 0x2E, 0x30, 0x3E, 0x60 };
+static uint8_t facom6684_ModifierMask[] = { 0x22, 0x12, 0x05, 0x04, 0x03 };
 
 static uint8_t facom6684_DefaultMap[] = { 
                                0, // 0x00
                                0, // 0x01
-                               0, // 0x02
-                               0, // 0x03
-                               0, // 0x04
-                               0, // 0x05
+                               KEY_SPACE, // 0x02
+                               KEY_LEFT_ALT, // 0x03
+                               KEY_RIGHT_ALT, // 0x04
+                               KEY_LEFT_GUI, // 0x05
                                0, // 0x06
                                0, // 0x07
-                               0, // 0x08
-                               0, // 0x09
+                               KEY_BACKSPACE, // 0x08
+                               KEY_ENTER, // 0x09
                                0, // 0x0A
                                0, // 0x0B
-                               0, // 0x0C
-                               0, // 0x0D
-                               0, // 0x0E
-                               0, // 0x0F
+                               KEYPAD_0, // 0x0C
+                               KEYPAD_00, // 0x0D
+                               KEYPAD_000, // 0x0E
+                               KEYPAD_DECIMAL, // 0x0F
                                0, // 0x10
                                0, // 0x11
-                               0, // 0x12
+                               KEY_LEFT_SHIFT, // 0x12
                                0, // 0x13
-                               0, // 0x14
-                               0, // 0x15
-                               0, // 0x16
-                               0, // 0x17
-                               0, // 0x18
-                               0, // 0x19
-                               0, // 0x1A
-                               0, // 0x1B
-                               0, // 0x1C
-                               0, // 0x1D
-                               0, // 0x1E
-                               0, // 0x1F
-                               KEY_LEFT_SHIFT, // 0x20
+                               KEY_Z, // 0x14
+                               KEY_X, // 0x15
+                               KEY_C, // 0x16
+                               KEY_V, // 0x17
+                               KEY_B, // 0x18
+                               KEY_N, // 0x19
+                               KEY_M, // 0x1A
+                               KEY_COMMA, // 0x1B
+                               KEYPAD_1, // 0x1C
+                               KEYPAD_2, // 0x1D
+                               KEYPAD_3, // 0x1E
+                               KEYPAD_ENTER, // 0x1F
+                               0, // 0x20
                                0, // 0x21
-                               KEY_Z, // 0x22
-                               KEY_X, // 0x23
-                               KEY_C, // 0x24
-                               KEY_V, // 0x25
-                               KEY_B, // 0x26
-                               KEY_N, // 0x27
-                               KEY_M, // 0x28
-                               KEY_COMMA, // 0x29
-                               KEY_PERIOD, // 0x2A
-                               KEY_SLASH, // 0x2B
-                               0, // 0x2C
-                               KEY_RIGHT_SHIFT, // 0x2D
-                               KEY_LEFT_ALT, // 0x2E
-                               KEY_SPACE, // 0x2F
-                               KEY_LEFT_CTRL, // 0x30
-                               KEY_A, // 0x31
-                               KEY_S, // 0x32
-                               KEY_D, // 0x33
-                               KEY_F, // 0x34
-                               KEY_G, // 0x35
-                               KEY_H, // 0x36
-                               KEY_J, // 0x37
-                               KEY_K, // 0x38
-                               KEY_L, // 0x39
-                               KEY_SEMICOLON, // 0x3A
-                               KEY_QUOTE, // 0x3B
-                               0, // 0x3C
-                               KEY_ENTER, // 0x3D
-                               KEY_RIGHT_GUI, // 0x3E
-                               KEY_LEFT, // 0x3F (KEYPAD_1)
-                               KEY_TAB, // 0x40
-                               KEY_Q, // 0x41
-                               KEY_W, // 0x42
-                               KEY_E, // 0x43
-                               KEY_R, // 0x44
-                               KEY_T, // 0x45
-                               KEY_Y, // 0x46
-                               KEY_U, // 0x47
-                               KEY_I, // 0x48
-                               KEY_O, // 0x49
-                               KEY_P, // 0x4A
-                               KEY_LEFT_BRACE, // 0x4B
-                               KEY_RIGHT_BRACE, // 0x4C
-                               KEY_BACKSLASH, // 0x4D
-                               KEY_DELETE, // 0x4E
-                               KEYPAD_4, // 0x4F
-                               KEY_ESC, // 0x50
-                               KEY_1, // 0x51
-                               KEY_2, // 0x52
-                               KEY_3, // 0x53
-                               KEY_4, // 0x54
-                               KEY_5, // 0x55
-                               KEY_6, // 0x56
-                               KEY_7, // 0x57
-                               KEY_8, // 0x58
-                               KEY_9, // 0x59
-                               KEY_0, // 0x5A
-                               KEY_MINUS, // 0x5B
-                               KEY_EQUAL, // 0x5C
-                               KEY_TILDE, // 0x5D
-                               KEY_BACKSPACE, // 0x5E
-                               KEY_NUM_LOCK, // 0x5F
-                               KEY_LEFT_GUI, // 0x60
-                               KEY_HOME, // 0x61
-                               KEY_END, // 0x62
-                               KEY_INSERT, // 0x63
-                               KEY_DELETE, // 0x64
-                               KEY_F1, // 0x65
-                               KEY_F2, // 0x66
-                               KEY_F3, // 0x67
-                               KEY_F4, // 0x68
-                               KEY_F5, // 0x69
-                               KEY_F6, // 0x6A
-                               KEY_F7, // 0x6B
-                               KEY_F8, // 0x6C
-                               KEY_F9, // 0x6D
-                               KEY_F10, // 0x6E
-                               KEY_PRINTSCREEN, // 0x6F
-                               KEY_PAGE_UP, // 0x70
-                               KEY_PAGE_DOWN, // 0x71
-                               KEY_F11, // 0x72
-                               KEYPAD_7, // 0x73
-                               KEYPAD_8, // 0x74
-                               KEYPAD_9, // 0x75
-                               KEY_UP, // 0x76 (KEYPAD_5)
-                               KEYPAD_6, // 0x77
-                               KEY_DOWN, // 0x78 (KEYPAD_2)
-                               KEY_RIGHT, // 0x79 (KEYPAD_3)
-                               KEYPAD_0, // 0x7A
-                               KEYPAD_00, // 0x7B
-                               KEYPAD_ENTER, // 0x7C
-                               0, // 0x7D
+                               KEY_LEFT_CTRL, // 0x22
+                               KEY_A, // 0x23
+                               KEY_S, // 0x24
+                               KEY_D, // 0x25
+                               KEY_F, // 0x26
+                               KEY_G, // 0x27
+                               KEY_H, // 0x28
+                               KEY_J, // 0x29
+                               KEY_K, // 0x2A
+                               KEY_L, // 0x2B
+                               KEYPAD_4, // 0x2C
+                               KEYPAD_5, // 0x2D
+                               KEYPAD_6, // 0x2E
+                               KEYPAD_MINUS, // 0x2F
+                               0, // 0x30
+                               0, // 0x31
+                               KEY_TAB, // 0x32
+                               KEY_Q, // 0x33
+                               KEY_W, // 0x34
+                               KEY_E, // 0x35
+                               KEY_R, // 0x36
+                               KEY_T, // 0x37
+                               KEY_Y, // 0x38
+                               KEY_U, // 0x39
+                               KEY_I, // 0x3A
+                               KEY_O, // 0x3B
+                               KEYPAD_7, // 0x3C
+                               KEYPAD_8, // 0x3D
+                               KEYPAD_9, // 0x3E
+                               KEYPAD_TAB, // 0x3F
+                               0, // 0x40
+                               0, // 0x41
+                               KEY_TILDE, // 0x42
+                               KEY_1, // 0x43
+                               KEY_2, // 0x44
+                               KEY_3, // 0x45
+                               KEY_4, // 0x46
+                               KEY_5, // 0x47
+                               KEY_6, // 0x48
+                               KEY_7, // 0x49
+                               KEY_8, // 0x4A
+                               KEY_9, // 0x4B
+                               0, // 0x4C
+                               0, // 0x4D
+                               KEYPAD_COMMA, // 0x4E
+                               KEYPAD_SPACE, // 0x4F
+                               KEY_F1, // 0x50
+                               KEY_F2, // 0x51
+                               KEY_F3, // 0x52
+                               KEY_F4, // 0x53
+                               KEY_F5, // 0x54
+                               KEY_F6, // 0x55
+                               KEY_F7, // 0x56
+                               KEY_F8, // 0x57
+                               KEY_0, // 0x58
+                               KEY_P, // 0x59
+                               KEY_SEMICOLON, // 0x5A
+                               KEY_PERIOD, // 0x5B
+                               0, // 0x5C
+                               KEY_LEFT, // 0x5D
+                               0, // 0x5E
+                               0, // 0x5F
+                               KEY_F13, // 0x60
+                               KEY_F14, // 0x61
+                               KEY_F15, // 0x62
+                               KEY_F16, // 0x63
+                               KEY_F17, // 0x64
+                               KEY_F18, // 0x65
+                               KEY_F9, // 0x66
+                               KEY_F10, // 0x67
+                               KEY_MINUS, // 0x68
+                               KEY_LEFT_BRACE, // 0x69
+                               KEY_QUOTE, // 0x6A
+                               KEY_SLASH, // 0x6B
+                               0, // 0x6C
+                               KEY_DOWN, // 0x6D
+                               0, // 0x6E
+                               0, // 0x6F
+                               KEY_F19, // 0x70
+                               KEY_F20, // 0x71
+                               KEY_F21, // 0x72
+                               KEY_F22, // 0x73
+                               KEY_F23, // 0x74
+                               KEY_F24, // 0x75
+                               KEY_F11, // 0x76
+                               KEY_F12, // 0x77
+                               KEY_EQUAL, // 0x78
+                               KEY_RIGHT_BRACE, // 0x79
+                               KEY_BACKSLASH, // 0x7A
+                               KEY_UP, // 0x7B
+                               0, // 0x7C
+                               KEY_RIGHT, // 0x7D
                                0, // 0x7E
                                0, // 0x7F
 };
@@ -162,130 +162,130 @@ static uint8_t facom6684_DefaultMap[] = {
 static uint8_t facom6684_ColemakMap[] = {
                                0, // 0x00
                                0, // 0x01
-                               0, // 0x02
-                               0, // 0x03
-                               0, // 0x04
-                               0, // 0x05
+                               KEY_SPACE, // 0x02
+                               KEY_LEFT_ALT, // 0x03
+                               KEY_RIGHT_ALT, // 0x04
+                               KEY_LEFT_GUI, // 0x05
                                0, // 0x06
                                0, // 0x07
-                               0, // 0x08
-                               0, // 0x09
+                               KEY_BACKSPACE, // 0x08
+                               KEY_ENTER, // 0x09
                                0, // 0x0A
                                0, // 0x0B
-                               0, // 0x0C
-                               0, // 0x0D
-                               0, // 0x0E
-                               0, // 0x0F
+                               KEYPAD_0, // 0x0C
+                               KEYPAD_00, // 0x0D
+                               KEYPAD_000, // 0x0E
+                               KEYPAD_DECIMAL, // 0x0F
                                0, // 0x10
                                0, // 0x11
-                               0, // 0x12
+                               KEY_LEFT_SHIFT, // 0x12
                                0, // 0x13
-                               0, // 0x14
-                               0, // 0x15
-                               0, // 0x16
-                               0, // 0x17
-                               0, // 0x18
-                               0, // 0x19
-                               0, // 0x1A
-                               0, // 0x1B
-                               0, // 0x1C
-                               0, // 0x1D
-                               0, // 0x1E
-                               0, // 0x1F
-                               KEY_LEFT_SHIFT, // 0x20
+                               KEY_Z, // 0x14
+                               KEY_X, // 0x15
+                               KEY_C, // 0x16
+                               KEY_V, // 0x17
+                               KEY_B, // 0x18
+                               KEY_K, // 0x19
+                               KEY_M, // 0x1A
+                               KEY_COMMA, // 0x1B
+                               KEYPAD_1, // 0x1C
+                               KEYPAD_2, // 0x1D
+                               KEYPAD_3, // 0x1E
+                               KEYPAD_ENTER, // 0x1F
+                               0, // 0x20
                                0, // 0x21
-                               KEY_Z, // 0x22
-                               KEY_X, // 0x23
-                               KEY_C, // 0x24
-                               KEY_V, // 0x25
-                               KEY_B, // 0x26
-                               KEY_K, // 0x27
-                               KEY_M, // 0x28
-                               KEY_COMMA, // 0x29
-                               KEY_PERIOD, // 0x2A
-                               KEY_SLASH, // 0x2B
-                               0, // 0x2C
-                               KEY_RIGHT_SHIFT, // 0x2D
-                               KEY_LEFT_ALT, // 0x2E
-                               KEY_SPACE, // 0x2F
-                               KEY_LEFT_CTRL, // 0x30
-                               KEY_A, // 0x31
-                               KEY_R, // 0x32
-                               KEY_S, // 0x33
-                               KEY_T, // 0x34
-                               KEY_D, // 0x35
-                               KEY_H, // 0x36
-                               KEY_N, // 0x37
-                               KEY_E, // 0x38
-                               KEY_I, // 0x39
-                               KEY_O, // 0x3A
-                               KEY_QUOTE, // 0x3B
-                               0, // 0x3C
-                               KEY_ENTER, // 0x3D
-                               KEY_RIGHT_GUI, // 0x3E
-                               KEY_LEFT, // 0x3F (KEYPAD_1)
-                               KEY_TAB, // 0x40
-                               KEY_Q, // 0x41
-                               KEY_W, // 0x42
-                               KEY_F, // 0x43
-                               KEY_P, // 0x44
-                               KEY_G, // 0x45
-                               KEY_J, // 0x46
-                               KEY_L, // 0x47
-                               KEY_U, // 0x48
-                               KEY_Y, // 0x49
-                               KEY_SEMICOLON, // 0x4A
-                               KEY_LEFT_BRACE, // 0x4B
-                               KEY_RIGHT_BRACE, // 0x4C
-                               KEY_BACKSLASH, // 0x4D
-                               KEY_DELETE, // 0x4E
-                               KEYPAD_4, // 0x4F
-                               KEY_ESC, // 0x50
-                               KEY_1, // 0x51
-                               KEY_2, // 0x52
-                               KEY_3, // 0x53
-                               KEY_4, // 0x54
-                               KEY_5, // 0x55
-                               KEY_6, // 0x56
-                               KEY_7, // 0x57
-                               KEY_8, // 0x58
-                               KEY_9, // 0x59
-                               KEY_0, // 0x5A
-                               KEY_MINUS, // 0x5B
-                               KEY_EQUAL, // 0x5C
-                               KEY_TILDE, // 0x5D
-                               KEY_BACKSPACE, // 0x5E
-                               KEY_NUM_LOCK, // 0x5F
-                               KEY_LEFT_GUI, // 0x60
-                               KEY_HOME, // 0x61
-                               KEY_END, // 0x62
-                               KEY_INSERT, // 0x63
-                               KEY_DELETE, // 0x64
-                               KEY_F1, // 0x65
-                               KEY_F2, // 0x66
-                               KEY_F3, // 0x67
-                               KEY_F4, // 0x68
-                               KEY_F5, // 0x69
-                               KEY_F6, // 0x6A
-                               KEY_F7, // 0x6B
-                               KEY_F8, // 0x6C
-                               KEY_F9, // 0x6D
-                               KEY_F10, // 0x6E
-                               KEY_PRINTSCREEN, // 0x6F
-                               KEY_PAGE_UP, // 0x70
-                               KEY_PAGE_DOWN, // 0x71
-                               KEY_F11, // 0x72
-                               KEYPAD_7, // 0x73
-                               KEYPAD_8, // 0x74
-                               KEYPAD_9, // 0x75
-                               KEY_UP, // 0x76 (KEYPAD_5)
-                               KEYPAD_6, // 0x77
-                               KEY_DOWN, // 0x78 (KEYPAD_2)
-                               KEY_RIGHT, // 0x79 (KEYPAD_3)
-                               KEYPAD_0, // 0x7A
-                               KEYPAD_00, // 0x7B
-                               KEYPAD_ENTER, // 0x7C
-                               0, // 0x7D
+                               KEY_LEFT_CTRL, // 0x22
+                               KEY_A, // 0x23
+                               KEY_R, // 0x24
+                               KEY_S, // 0x25
+                               KEY_T, // 0x26
+                               KEY_D, // 0x27
+                               KEY_H, // 0x28
+                               KEY_N, // 0x29
+                               KEY_E, // 0x2A
+                               KEY_I, // 0x2B
+                               KEYPAD_4, // 0x2C
+                               KEYPAD_5, // 0x2D
+                               KEYPAD_6, // 0x2E
+                               KEYPAD_MINUS, // 0x2F
+                               0, // 0x30
+                               0, // 0x31
+                               KEY_TAB, // 0x32
+                               KEY_Q, // 0x33
+                               KEY_W, // 0x34
+                               KEY_F, // 0x35
+                               KEY_P, // 0x36
+                               KEY_G, // 0x37
+                               KEY_J, // 0x38
+                               KEY_L, // 0x39
+                               KEY_U, // 0x3A
+                               KEY_Y, // 0x3B
+                               KEYPAD_7, // 0x3C
+                               KEYPAD_8, // 0x3D
+                               KEYPAD_9, // 0x3E
+                               KEYPAD_TAB, // 0x3F
+                               0, // 0x40
+                               0, // 0x41
+                               KEY_TILDE, // 0x42
+                               KEY_1, // 0x43
+                               KEY_2, // 0x44
+                               KEY_3, // 0x45
+                               KEY_4, // 0x46
+                               KEY_5, // 0x47
+                               KEY_6, // 0x48
+                               KEY_7, // 0x49
+                               KEY_8, // 0x4A
+                               KEY_9, // 0x4B
+                               0, // 0x4C
+                               0, // 0x4D
+                               KEYPAD_COMMA, // 0x4E
+                               KEYPAD_SPACE, // 0x4F
+                               KEY_F1, // 0x50
+                               KEY_F2, // 0x51
+                               KEY_F3, // 0x52
+                               KEY_F4, // 0x53
+                               KEY_F5, // 0x54
+                               KEY_F6, // 0x55
+                               KEY_F7, // 0x56
+                               KEY_F8, // 0x57
+                               KEY_0, // 0x58
+                               KEY_SEMICOLON, // 0x59
+                               KEY_O, // 0x5A
+                               KEY_PERIOD, // 0x5B
+                               0, // 0x5C
+                               KEY_LEFT, // 0x5D
+                               0, // 0x5E
+                               0, // 0x5F
+                               KEY_F13, // 0x60
+                               KEY_F14, // 0x61
+                               KEY_F15, // 0x62
+                               KEY_F16, // 0x63
+                               KEY_F17, // 0x64
+                               KEY_F18, // 0x65
+                               KEY_F9, // 0x66
+                               KEY_F10, // 0x67
+                               KEY_MINUS, // 0x68
+                               KEY_LEFT_BRACE, // 0x69
+                               KEY_QUOTE, // 0x6A
+                               KEY_SLASH, // 0x6B
+                               0, // 0x6C
+                               KEY_DOWN, // 0x6D
+                               0, // 0x6E
+                               0, // 0x6F
+                               KEY_F19, // 0x70
+                               KEY_F20, // 0x71
+                               KEY_F21, // 0x72
+                               KEY_F22, // 0x73
+                               KEY_F23, // 0x74
+                               KEY_F24, // 0x75
+                               KEY_F11, // 0x76
+                               KEY_F12, // 0x77
+                               KEY_EQUAL, // 0x78
+                               KEY_RIGHT_BRACE, // 0x79
+                               KEY_BACKSLASH, // 0x7A
+                               KEY_UP, // 0x7B
+                               0, // 0x7C
+                               KEY_RIGHT, // 0x7D
                                0, // 0x7E
                                0, // 0x7F
 };
index 9d48d4def30f968df0298c26506acb87a34f1d40..6fb8f7658e3aadef1ebee31ac8d0fa70830e5774 100644 (file)
 
 // ----- Defines -----
 
-// Pinout Defines
-#define HOLD_PORT PORTD
-#define HOLD_DDR   DDRD
-#define HOLD_PIN      3
-
 
 // ----- Macros -----
 
 // 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;
-volatile uint8_t KeyIndex_Add_InputSignal; // Used to pass the (click/input value) to the keyboard for the clicker
-
 
-// Buffer Signals
-volatile uint8_t BufferReadyToClear;
+static uint8_t KeyBuffer[3];
+static uint8_t KeyBufferCount = 0;
 
 
 
 // ----- Function Declarations -----
 
-void processKeyValue( uint8_t keyValue );
+void processKeyValue( uint8_t valueType, uint8_t keyValue );
 void  removeKeyValue( uint8_t keyValue );
 
 
@@ -79,38 +72,29 @@ ISR(USART1_RX_vect)
 {
        cli(); // Disable Interrupts
 
-       uint8_t keyValue = 0x00;
-       uint8_t keyState = 0x00;
-
-       // Read the scancode packet from the USART (1st to 8th bits)
-       keyValue = UDR1;
 
-       // Read the release/press bit (9th bit) XXX Unnecessary, and wrong it seems, parity bit? or something else?
-       keyState = UCSR1B & 0x02;
+       // Read part of the scan code (3 8bit chunks) from USART
+       KeyBuffer[KeyBufferCount] = UDR1;
 
-       // High bit of keyValue, also represents press/release
-       keyState = keyValue & 0x80 ? 0x00 : 0x02;
-
-       // Debug
-       char tmpStr[6];
-       hexToStr( keyValue & 0x7F, tmpStr );
-
-       // Process the scancode
-       switch ( keyState )
+       if ( KeyBufferCount >= 2 )
        {
-       case 0x00: // Released
-               dPrintStrs( tmpStr, "R  " ); // Debug
-
-               // Remove key from press buffer
-               removeKeyValue( keyValue & 0x7F );
-               break;
+               KeyBufferCount = 0;
 
-       case 0x02: // Pressed
-               dPrintStrs( tmpStr, "P " ); // Debug
+               // Debug
+               for ( uint8_t c = 0; c <= 2; c++ )
+               {
+                       // Debug
+                       char tmpStr[6];
+                       hexToStr( KeyBuffer[c], tmpStr );
+                       dPrintStrs( tmpStr, " " ); // Debug
+               }
+               print("\n");
 
-               // New key to process
-               processKeyValue( keyValue & 0x7F );
-               break;
+               processKeyValue( KeyBuffer[1], KeyBuffer[2] );
+       }
+       else
+       {
+               KeyBufferCount++;
        }
 
        sei(); // Re-enable Interrupts
@@ -128,29 +112,18 @@ inline void scan_setup()
        
        // Setup baud rate
        // 16 MHz / ( 16 * Baud ) = UBRR
-       // Baud <- 0.823284 ms per bit, thus 1000 / 0.823284 = 1214.65004 -> 823.2824
-       // Thus baud setting = 823
-       uint16_t baud = 823; // Max setting of 4095
+       // Baud: 4817 -> 16 MHz / ( 16 * 4817 ) = 207.5981
+       // Thus baud setting = 208
+       uint16_t baud = 208; // Max setting of 4095
        UBRR1H = (uint8_t)(baud >> 8);
        UBRR1L = (uint8_t)baud;
 
-       // Enable the receiver, and RX Complete Interrupt as well as 9 bit data
-       UCSR1B = 0x94;
+       // Enable the receiver, transmitter, and RX Complete Interrupt
+       UCSR1B = 0x98;
 
-       // The transmitter is only to be enabled when needed
-       // Set the pin to be pull-up otherwise (use the lowered voltage inverter in order to sink)
-       HOLD_DDR  &= ~(1 << HOLD_PIN);
-       HOLD_PORT |=  (1 << HOLD_PIN);
-
-       // Set frame format: 9 data, 1 stop bit, no parity
+       // Set frame format: 8 data, 1 stop bit, odd parity
        // Asynchrounous USART mode
-       UCSR1C = 0x06;
-
-       // Initially buffer doesn't need to be cleared (it's empty...)
-       BufferReadyToClear = 0;
-
-       // InputSignal is off by default
-       KeyIndex_Add_InputSignal = 0x00;
+       UCSR1C = 0x36;
 
        // Reset the keyboard before scanning, we might be in a wierd state
        scan_resetKeyboard();
@@ -158,39 +131,40 @@ inline void scan_setup()
 
 
 // Main Detection Loop
-// Not needed for the BETKB, this is just a busy loop
 inline uint8_t scan_loop()
 {
        return 0;
 }
 
-void processKeyValue( uint8_t keyValue )
+void processKeyValue( uint8_t valueType, uint8_t keyValue )
 {
-       // Interpret scan code
-       switch ( keyValue )
+       switch ( valueType )
        {
-       case 0x00: // Break code from input?
+       // Single Key Press
+       case 0x00:
                break;
-       default:
-               // Make sure the key isn't already in the buffer
-               for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ )
+       // Repeated Key Press
+       case 0x01:
+               break;
+       // Modifier Key Release
+       case 0x02:
+               removeKeyValue( keyValue );
+               return;
+       }
+
+       // 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 )
                {
-                       // Key isn't in the buffer yet
-                       if ( c == KeyIndex_BufferUsed )
-                       {
-                               bufferAdd( keyValue );
-
-                               // Only send data if enabled
-                               if ( KeyIndex_Add_InputSignal )
-                                       scan_sendData( KeyIndex_Add_InputSignal );
-                               break;
-                       }
-
-                       // Key already in the buffer
-                       if ( KeyIndex_Buffer[c] == keyValue )
-                               break;
+                       bufferAdd( keyValue );
+                       break;
                }
-               break;
+
+               // Key already in the buffer
+               if ( KeyIndex_Buffer[c] == keyValue )
+                       break;
        }
 }
 
@@ -227,9 +201,6 @@ void removeKeyValue( uint8_t keyValue )
 // Send data 
 uint8_t scan_sendData( uint8_t dataPayload )
 {
-       // Enable the USART Transmitter
-       UCSR1B |=  (1 << 3);
-
        // Debug
        char tmpStr[6];
        hexToStr( dataPayload, tmpStr );
@@ -237,12 +208,6 @@ uint8_t scan_sendData( uint8_t dataPayload )
 
        UDR1 = dataPayload;
 
-       // Wait for the payload
-       _delay_us( 800 );
-
-       // Disable the USART Transmitter
-       UCSR1B &= ~(1 << 3);
-
        return 0;
 }
 
@@ -254,15 +219,68 @@ void scan_finishedWithBuffer( void )
 // Signal that the keys have been properly sent over USB
 void scan_finishedWithUSBBuffer( void )
 {
+       // Count for number of modifiers to maintain in the buffer
+       uint8_t filled = 0;
+       uint8_t latched = 0;
+       uint8_t latchBuffer[13]; // There are only 13 keys that can possibly be latched at the same time...
+       uint8_t normal = 0;
+
+       // Clean out all keys except "special" keys (designated modifiers)
+       for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
+       {
+               switch ( KeyIndex_Buffer[c] )
+               {
+               // Dedicated Modifier Keys
+               // NOTE: Both shifts are represented as the same scan code
+               case 0x04:
+               case 0x05:
+               case 0x12:
+                       KeyIndex_Buffer[filled++] = KeyIndex_Buffer[c];
+                       break;
+               // Latched Keys, only released if a non-modifier is pressed along with it
+               // NOTE: This keys do not have a built in repeating
+               case 0x00:
+               case 0x01:
+               case 0x03:
+               case 0x0B:
+               case 0x22:
+               case 0x10:
+               case 0x11:
+               case 0x20:
+               case 0x21:
+               case 0x30:
+               case 0x31:
+               case 0x40:
+               case 0x41:
+                       latchBuffer[latched++] = KeyIndex_Buffer[c];
+                       break;
+               // Allow the scancode to be removed, normal keys
+               default:
+                       normal++;
+                       break;
+               }
+       }
+
+       // Reset the buffer counter
+       KeyIndex_BufferUsed = filled;
+
+       // Only "re-add" the latched keys if they weren't used
+       if ( latched > 0 && normal == 0 )
+       {
+               for ( uint8_t c = 0; c < latched; c++ )
+               {
+                       bufferAdd( latchBuffer[c] );
+               }
+       }
 }
 
 // Reset/Hold keyboard
-// NOTE: Does nothing with the BETKB
+// NOTE: Does nothing with the FACOM6684
 void scan_lockKeyboard( void )
 {
 }
 
-// NOTE: Does nothing with the BETKB
+// NOTE: Does nothing with the FACOM6684
 void scan_unlockKeyboard( void )
 {
 }
@@ -272,5 +290,8 @@ void scan_resetKeyboard( void )
 {
        // Not a calculated valued...
        _delay_ms( 50 );
+
+       KeyBufferCount = 0;
+       KeyIndex_BufferUsed = 0;
 }