Digistump Forums

The Digispark => Digispark (Original) Support => Topic started by: duckythescientist on December 24, 2012, 12:36:23 pm

Title: Dvorak keyboard support
Post by: duckythescientist on December 24, 2012, 12:36:23 pm
I have my keyboard layout set to Dvorak. When running the keyboard example for the Digispark, instead of "Hello digispark", "D.nnr ecicolapt" is typed. This is what would be typed if I typed the qwerty letters on a qwerty keyboard with the input language set to English Dvorak.

Any suggestions as to how to fix this nicely? Possibly a #define that I could add? Also, I don't know if this is a Digispark specific problem or a problem with the fact that keyboard scancodes may correlate to a key position not an actual letter.


#edit
I modified the install\libraries\DigisparkKeyboard\digiKeyboard.h to change the layout when #define LAYOUT_US_DVORAK is in the file, so this works for now, but I'd love a feature of being able to select the layout from the sketch or even in the code during runtime.  I also added a few more keycode defines. Here are the interesting bits:


 //begin Dvorak/Qwerty specific
#ifdef LAYOUT_US_DVORAK
 
#define KEY_A       4
#define KEY_B       17
#define KEY_C       12
#define KEY_D       11
#define KEY_E       7
#define KEY_F       28
#define KEY_G       24
#define KEY_H       13
#define KEY_I       10
#define KEY_J       6
#define KEY_K       25
#define KEY_L       19
#define KEY_M       16
#define KEY_N       15
#define KEY_O       22
#define KEY_P       21
#define KEY_Q       27
#define KEY_R       18
#define KEY_S       51
#define KEY_T       14
#define KEY_U       9
#define KEY_V       55
#define KEY_W       54
#define KEY_X       5
#define KEY_Y       23
#define KEY_Z       56
 
#define KEY_MINUS        52
#define KEY_EQUAL        48
#define KEY_LEFT_BRACE   45
#define KEY_RIGHT_BRACE  46
#define KEY_BACKSLASH    49
#define KEY_SEMICOLON    29
#define KEY_QUOTE        20
#define KEY_COMMA        26
#define KEY_PERIOD       8
#define KEY_SLASH        47
 
#else //LAYOUT_US_ENGLISH
#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_MINUS        45
#define KEY_EQUAL        46
#define KEY_LEFT_BRACE   47
#define KEY_RIGHT_BRACE  48
#define KEY_BACKSLASH    49
#define KEY_SEMICOLON    51
#define KEY_QUOTE        52
#define KEY_COMMA        54
#define KEY_PERIOD       55
#define KEY_SLASH        56
#endif //back to nonspecific layouts
 

#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_NON_US_NUM   50
#define KEY_TILDE        53
#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  
Title: Dvorak keyboard support
Post by: digistump on December 26, 2012, 03:50:17 pm
awesome! it seems the scancodes do correlate to the key position rather than the letter/number

feel free to push any changes to the repo here: https://github.com/digistump/DigisparkArduinoIntegration

thanks!