]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Finishing up the Epson QX-10 module
authorJacob Alexander <triplehaata@gmail.com>
Sun, 11 Dec 2011 08:06:49 +0000 (00:06 -0800)
committerJacob Alexander <triplehaata@gmail.com>
Sun, 11 Dec 2011 08:06:49 +0000 (00:06 -0800)
- Typing and modifiers fully working
- Still some features left to implement
  * Stop input
  * Diagnostic test
  * Setting interval before starting repeat rate
  * More comments
  * Handling LED stats

Keymap/epsonqx10.h
Scan/EpsonQX-10/scan_loop.c
Scan/EpsonQX-10/scan_loop.h
USB/pjrc/usb_com.c
main.c

index aa15a9eba62cc03b0b09c2516c684968ad2bb1b6..1f8aa6355e5b429112a91cdd030eb3a074c5a44c 100644 (file)
@@ -322,7 +322,7 @@ static uint8_t epsonqx10_ColemakMap[] = {
                                0, // 0x8C
                                KEY_GUI, // 0x8D
                                0, // 0x8E
-                               KEY_RIGHT_CTRL, // 0x8F
+                               KEY_ALT, // 0x8F
 };
 
 
index ec74c9cd7e30e0c6dd0639c8ed6cf17d3dbede83..8bbabf88ece87527ed43abfe25e69d4357a44aa0 100644 (file)
@@ -147,6 +147,7 @@ inline void scan_setup()
        // Prescaler is 1
        // Twice every 1200 baud (actually 1200.1, timer isn't accurate enough)
        // This is close to 820 us, but a bit slower
+       cli();
        TCCR1B = 0x09;
        OCR1AH = 0x1A;
        OCR1AL = 0x09;
@@ -171,16 +172,19 @@ inline void scan_setup()
        // Synchrounous USART mode
        // Tx Data on Falling Edge, Rx on Rising
        UCSR1C = 0x47;
+       sei();
 
        // Reset the keyboard before scanning, we might be in a wierd state
-       _delay_ms( 1 );
+       _delay_ms( 50 );
        scan_resetKeyboard();
 
+       _delay_ms( 5000 ); // Wait for the reset command to finish enough for new settings to take hold afterwards
        scan_setRepeatRate( 0x00 ); // Set the fastest repeat rate
 }
 
 
 // Main Detection Loop
+// Nothing is required here with the Epson QX-10 Keyboards as the interrupts take care of the inputs
 inline uint8_t scan_loop()
 {
        return 0;
@@ -251,12 +255,14 @@ void processKeyValue( uint8_t keyValue )
                // Modifier Release Detected
                else
                {
+                       uint8_t actualKeyValue = keyValue | 0x01;
+
                        // Check for the released key, and shift the other keys lower on the buffer
                        uint8_t c;
                        for ( c = 0; c < KeyIndex_BufferUsed; c++ )
                        {
                                // Key to release found
-                               if ( KeyIndex_Buffer[c] == keyValue )
+                               if ( KeyIndex_Buffer[c] == actualKeyValue )
                                {
                                        // Shift keys from c position
                                        for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
@@ -376,13 +382,19 @@ uint8_t scan_sendData( uint8_t dataPayload )
 }
 
 // Signal KeyIndex_Buffer that it has been properly read
+inline void scan_finishedWithBuffer( void )
+{
+       return;
+}
+
+// Signal that the keys have been properly sent over USB
 // For the Epson QX-10 only the modifier keys have release signals
 // Therefore, only 5 keys could possibly be assigned as a modifiers
 // The rest of the keys are single press (like the Kaypro keyboards)
 //
 // However, this differentiation causes complications on how the key signals are discarded and used
 // The single keypresses must be discarded immediately, while the modifiers must be kept
-inline void scan_finishedWithBuffer( void )
+inline void scan_finishedWithUSBBuffer( void )
 {
        uint8_t foundModifiers = 0;
 
@@ -401,7 +413,13 @@ inline void scan_finishedWithBuffer( void )
        // Adjust the size of the new Key Buffer
        KeyIndex_BufferUsed = foundModifiers;
 
-       return;
+       /* Non-working, too slow (too much traffic on the bus)
+       // Poll the modifiers using an input command
+       uint8_t oldBuffer = KeyIndex_BufferUsed;
+       KeyIndex_BufferUsed = 0;
+       if ( oldBuffer )
+               scan_readSwitchStatus();
+       */
 }
 
 // Reset/Hold keyboard
index d4da30679b1927ad2444eb3ea9e6731a25c66667..4ce8c7e4f5ee7612be7af3224ca4ad1f695b8245 100644 (file)
@@ -56,6 +56,7 @@ uint8_t scan_loop( void );
 uint8_t scan_sendData( uint8_t dataPayload );
 
 void scan_finishedWithBuffer( void );
+void scan_finishedWithUSBBuffer( void );
 void scan_lockKeyboard( void );
 void scan_unlockKeyboard( void );
 void scan_resetKeyboard( void );
index af2d9c7bb9284a8138f28cf7054c64d51705c520..730ba2107553e7af35c43426dab75975bd68dd3d 100644 (file)
@@ -27,6 +27,7 @@
 // AVR Includes
 
 // Project Includes
+#include <scan_loop.h>
 #include "usb_keyboard_debug.h"
 
 // Local Includes
@@ -82,5 +83,8 @@ inline void usb_send(void)
                // Clear modifiers and keys
                USBKeys_Modifiers = 0;
                USBKeys_Sent      = 0;
+
+               // Signal Scan Module we are finishedA
+               scan_finishedWithUSBBuffer();
 }
 
diff --git a/main.c b/main.c
index 905f7bd06aebef3a044262f6a429262342cbea98..1533443cc2c4de2525702bd39ffa9987d844d33c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -108,9 +108,7 @@ int main(void)
        while ( 1 )
        {
                // Setup the scanning module
-               cli();
                scan_setup();
-               sei();
 
                while ( 1 )
                {