Fix return keymap to 0

No longer attempts to change keymap when there is only one
Fixed typo in keymap
This commit is contained in:
lordwelch 2018-01-24 14:43:33 -08:00
parent f882f599ff
commit 2697df4352
2 changed files with 18 additions and 15 deletions

View File

@ -81,11 +81,11 @@
}, },
"": { "": {
"modifier": ["LSHIFT"], "modifier": ["LSHIFT"],
"decimal": 46 "decimal": 45
}, },
"": { "": {
"modifier": ["LSHIFT"], "modifier": ["LSHIFT"],
"decimal": 45 "decimal": 46
}, },
"": { "": {
"modifier": ["NONE"], "modifier": ["NONE"],

29
main.go
View File

@ -47,23 +47,26 @@ func Hold(press [8]byte, file io.Writer) {
} }
func keymapto0(args Args, hidg0 *os.File, currentKeyMap *int) { func keymapto0(args Args, hidg0 *os.File, currentKeyMap *int) {
if len(args.ORDER) > 1 {
for i := 0; i <= len(args.ORDER)-(*currentKeyMap+1); i++ { for i := 0; i < len(args.ORDER)-(*currentKeyMap); i++ {
Press([8]byte{LALT, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00}, hidg0) Press([8]byte{LALT, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00}, hidg0)
}
} }
} }
func changeKeymap(r rune, keys map[string]Keys, args Args, hidg0 *os.File, currentKeyMap *int) { func changeKeymap(r rune, keys map[string]Keys, args Args, hidg0 *os.File, currentKeyMap *int) {
for i := 0; i < len(args.ORDER); i++ { if len(args.ORDER) > 1 {
if keys[args.ORDER[(*currentKeyMap)]][string(r)].Decimal == 0 { for i := 0; i < len(args.ORDER); i++ {
Press([8]byte{LALT, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00}, hidg0) if keys[args.ORDER[(*currentKeyMap)]][string(r)].Decimal == 0 {
if *currentKeyMap == len(args.ORDER)-1 { Press([8]byte{LALT, 0x00, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00}, hidg0)
*currentKeyMap = 0 if *currentKeyMap == len(args.ORDER)-1 {
} else { *currentKeyMap = 0
*currentKeyMap++ } else {
} *currentKeyMap++
if i == len(args.ORDER)-1 { }
fmt.Println("key not in keymap: " + string(r)) if i == len(args.ORDER)-1 {
fmt.Println("key not in keymap: " + string(r))
}
} }
} }
} }