shift as modifier
This commit is contained in:
parent
1f87adf03f
commit
f7903197b8
1 changed files with 199 additions and 182 deletions
|
@ -1,6 +1,6 @@
|
|||
/* Arduino Keyboard HID driver and USB host shield pass through */
|
||||
|
||||
/*-
|
||||
/*
|
||||
* Copyright (c) 2011 Darran Hunt (darran [at] hunt dot net dot nz)
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -56,8 +56,8 @@ bool numLock = false;
|
|||
bool capsLock = false;
|
||||
bool scrollLock = false;
|
||||
|
||||
uint8_t dvorak_changer (uint8_t ch, uint8_t mod);
|
||||
void setup();
|
||||
uint8_t dvorak_changer (uint8_t ch, uint8_t mod);
|
||||
void loop();
|
||||
bool key_is_new(byte key, byte *report);
|
||||
|
||||
|
@ -128,17 +128,18 @@ void kbd_poll(void)
|
|||
return;
|
||||
}
|
||||
|
||||
for (i = 2; i < 8; ++i) {
|
||||
buf[i] = dvorak_changer (buf[i], buf[0]);
|
||||
}
|
||||
|
||||
// Serial.print ("Modifier = ");
|
||||
// Serial.println (buf[0]);
|
||||
// Serial.print ("Modifier = ");
|
||||
// Serial.println (buf[0]);
|
||||
|
||||
/* Check for change */
|
||||
for (i=0; i<8; i++) {
|
||||
if (buf[i] != old_buf[i]) {
|
||||
|
||||
for (i = 2; i < 8; ++i) {
|
||||
buf[i] = dvorak_changer (buf[i], buf[0]);
|
||||
}
|
||||
|
||||
/* Send the new key presses to the host */
|
||||
Serial.write(buf, 8);
|
||||
|
||||
|
@ -148,7 +149,7 @@ void kbd_poll(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Check for status keys and adjust led status */
|
||||
/* Check for status keys and adjust led status */
|
||||
for (i=2; i<8; i++) {
|
||||
if (buf[i] == 0) {
|
||||
/* 0 marks end of keys in the report */
|
||||
|
@ -189,10 +190,10 @@ void kbd_poll(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* Function: key_is_new(key, report)
|
||||
* Description: see if key is new or is already in report
|
||||
* Returns: false if found, true if not
|
||||
*/
|
||||
* Function: key_is_new(key, report)
|
||||
* Description: see if key is new or is already in report
|
||||
* Returns: false if found, true if not
|
||||
*/
|
||||
bool key_is_new(uint8_t key, uint8_t *report)
|
||||
{
|
||||
uint8_t ind;
|
||||
|
@ -226,7 +227,7 @@ bool key_is_new(uint8_t key, uint8_t *report)
|
|||
uint8_t dvorak_changer (uint8_t ch, uint8_t mod)
|
||||
{
|
||||
|
||||
if (mod != 8) { // WINKEY as layer key
|
||||
if (mod != 32) { // RIGHTSHIFT as layer key
|
||||
switch (ch){
|
||||
/* begin mid row*/
|
||||
|
||||
|
@ -330,25 +331,41 @@ uint8_t dvorak_changer (uint8_t ch, uint8_t mod)
|
|||
return 0x35;
|
||||
case 0x4C: // DEL --> /
|
||||
return 0x31;
|
||||
case 0x49: // INS --> BEGIN END
|
||||
case 0x49: // INS --> HOME END
|
||||
buf[0] = 0;
|
||||
if (mod == 2) {
|
||||
return 0x5D ;
|
||||
return 0x4D ;
|
||||
} else {
|
||||
return 0x4D;
|
||||
return 0x4A;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buf[0] = 0;
|
||||
switch (ch){
|
||||
case 0x0C: // WINKEY + I --> UpArrow
|
||||
case 0x1A: // SHIFTRIGHT + , --> UpArrow
|
||||
return 0x52;
|
||||
case 0x0E: // WINKEY + K --> DownArrow
|
||||
case 0x16: // SHIFTRIGHT + o --> DownArrow
|
||||
return 0x51;
|
||||
case 0x0D: // WINKEY + J --> LeftArrow
|
||||
case 0x04: // SHIFTRIGHT + a --> LeftArrow
|
||||
return 0x50;
|
||||
case 0x0F: // WINKEY + L --> RightArrow
|
||||
case 0x07: // SHIFTRIGHT + e --> RightArrow
|
||||
return 0x4F;
|
||||
case 0x2E: // += --> ]}
|
||||
buf[0] = 2;
|
||||
return 0x32;
|
||||
case 0x2D: // -_ --> [{
|
||||
buf[0] = 2;
|
||||
return 0x2F;
|
||||
case 0x36: // <, --> W
|
||||
buf[0] = 2;
|
||||
return 0x1A;
|
||||
case 0x37: // >. --> V
|
||||
buf[0] = 2;
|
||||
return 0x19;
|
||||
case 0x38: // ?/ --> Z
|
||||
buf[0] = 2;
|
||||
return 0x1D;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue