shift as modifier

This commit is contained in:
pesceWanda 2016-07-07 23:24:45 -04:00
parent 1f87adf03f
commit f7903197b8

View file

@ -1,6 +1,6 @@
/* Arduino Keyboard HID driver and USB host shield pass through */ /* Arduino Keyboard HID driver and USB host shield pass through */
/*- /*
* Copyright (c) 2011 Darran Hunt (darran [at] hunt dot net dot nz) * Copyright (c) 2011 Darran Hunt (darran [at] hunt dot net dot nz)
* All rights reserved. * All rights reserved.
* *
@ -56,8 +56,8 @@ bool numLock = false;
bool capsLock = false; bool capsLock = false;
bool scrollLock = false; bool scrollLock = false;
uint8_t dvorak_changer (uint8_t ch, uint8_t mod);
void setup(); void setup();
uint8_t dvorak_changer (uint8_t ch, uint8_t mod);
void loop(); void loop();
bool key_is_new(byte key, byte *report); bool key_is_new(byte key, byte *report);
@ -128,9 +128,6 @@ void kbd_poll(void)
return; return;
} }
for (i = 2; i < 8; ++i) {
buf[i] = dvorak_changer (buf[i], buf[0]);
}
// Serial.print ("Modifier = "); // Serial.print ("Modifier = ");
// Serial.println (buf[0]); // Serial.println (buf[0]);
@ -139,6 +136,10 @@ void kbd_poll(void)
for (i=0; i<8; i++) { for (i=0; i<8; i++) {
if (buf[i] != old_buf[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 */ /* Send the new key presses to the host */
Serial.write(buf, 8); Serial.write(buf, 8);
@ -226,7 +227,7 @@ bool key_is_new(uint8_t key, uint8_t *report)
uint8_t dvorak_changer (uint8_t ch, uint8_t mod) 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){ switch (ch){
/* begin mid row*/ /* begin mid row*/
@ -330,25 +331,41 @@ uint8_t dvorak_changer (uint8_t ch, uint8_t mod)
return 0x35; return 0x35;
case 0x4C: // DEL --> / case 0x4C: // DEL --> /
return 0x31; return 0x31;
case 0x49: // INS --> BEGIN END case 0x49: // INS --> HOME END
buf[0] = 0;
if (mod == 2) { if (mod == 2) {
return 0x5D ;
} else {
return 0x4D ; return 0x4D ;
} else {
return 0x4A;
} }
} }
} else { } else {
buf[0] = 0;
switch (ch){ switch (ch){
case 0x0C: // WINKEY + I --> UpArrow case 0x1A: // SHIFTRIGHT + , --> UpArrow
return 0x52; return 0x52;
case 0x0E: // WINKEY + K --> DownArrow case 0x16: // SHIFTRIGHT + o --> DownArrow
return 0x51; return 0x51;
case 0x0D: // WINKEY + J --> LeftArrow case 0x04: // SHIFTRIGHT + a --> LeftArrow
return 0x50; return 0x50;
case 0x0F: // WINKEY + L --> RightArrow case 0x07: // SHIFTRIGHT + e --> RightArrow
return 0x4F; 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;
} }
} }
} }