Commit 31db3fb3 authored by Sli's avatar Sli

Minimal support for AZERTY, usable for UIDs

parent 45ba7879
Pipeline #1754 canceled with stages
......@@ -3,7 +3,7 @@ package string2keyboard
import "github.com/micmonay/keybd_event"
var (
names = map[string]keySet{
names_en = map[string]keySet{
"a": keySet{keybd_event.VK_A, false},
"b": keySet{keybd_event.VK_B, false},
"c": keySet{keybd_event.VK_C, false},
......@@ -109,4 +109,6 @@ var (
"TAB": keySet{keybd_event.VK_TAB, false},
"BACKSPACE": keySet{keybd_event.VK_DELETE, false},
}
// I'm a MACOS user but still, it's for the foyer, I don't care
names_fr = names_en
)
......@@ -3,7 +3,7 @@ package string2keyboard
import "github.com/micmonay/keybd_event"
var (
names = map[string]keySet{
names_en = map[string]keySet{
"a": keySet{keybd_event.VK_A, false},
"b": keySet{keybd_event.VK_B, false},
"c": keySet{keybd_event.VK_C, false},
......@@ -105,6 +105,113 @@ var (
"?": keySet{keybd_event.VK_SLASH, true},
"~": keySet{keybd_event.VK_GRAVE, true},
"ENTER": keySet{keybd_event.VK_ENTER, false},
"TAB": keySet{keybd_event.VK_TAB, false},
"BACKSPACE": keySet{keybd_event.VK_BACKSPACE, false},
}
// Good enough for UIDS
names_fr = map[string]keySet{
"a": keySet{keybd_event.VK_Q, false},
"b": keySet{keybd_event.VK_B, false},
"c": keySet{keybd_event.VK_C, false},
"d": keySet{keybd_event.VK_D, false},
"e": keySet{keybd_event.VK_E, false},
"f": keySet{keybd_event.VK_F, false},
"g": keySet{keybd_event.VK_G, false},
"h": keySet{keybd_event.VK_H, false},
"i": keySet{keybd_event.VK_I, false},
"j": keySet{keybd_event.VK_J, false},
"k": keySet{keybd_event.VK_K, false},
"l": keySet{keybd_event.VK_L, false},
"m": keySet{keybd_event.VK_SEMICOLON, false},
"n": keySet{keybd_event.VK_N, false},
"o": keySet{keybd_event.VK_O, false},
"p": keySet{keybd_event.VK_P, false},
"q": keySet{keybd_event.VK_A, false},
"r": keySet{keybd_event.VK_R, false},
"s": keySet{keybd_event.VK_S, false},
"t": keySet{keybd_event.VK_T, false},
"u": keySet{keybd_event.VK_U, false},
"v": keySet{keybd_event.VK_V, false},
"w": keySet{keybd_event.VK_Z, false},
"x": keySet{keybd_event.VK_X, false},
"y": keySet{keybd_event.VK_Y, false},
"z": keySet{keybd_event.VK_W, false},
"A": keySet{keybd_event.VK_Q, true},
"B": keySet{keybd_event.VK_B, true},
"C": keySet{keybd_event.VK_C, true},
"D": keySet{keybd_event.VK_D, true},
"E": keySet{keybd_event.VK_E, true},
"F": keySet{keybd_event.VK_F, true},
"G": keySet{keybd_event.VK_G, true},
"H": keySet{keybd_event.VK_H, true},
"I": keySet{keybd_event.VK_I, true},
"J": keySet{keybd_event.VK_J, true},
"K": keySet{keybd_event.VK_K, true},
"L": keySet{keybd_event.VK_L, true},
"M": keySet{keybd_event.VK_SEMICOLON, true},
"N": keySet{keybd_event.VK_N, true},
"O": keySet{keybd_event.VK_O, true},
"P": keySet{keybd_event.VK_P, true},
"Q": keySet{keybd_event.VK_A, true},
"R": keySet{keybd_event.VK_R, true},
"S": keySet{keybd_event.VK_S, true},
"T": keySet{keybd_event.VK_T, true},
"U": keySet{keybd_event.VK_U, true},
"V": keySet{keybd_event.VK_V, true},
"W": keySet{keybd_event.VK_Z, true},
"X": keySet{keybd_event.VK_X, true},
"Y": keySet{keybd_event.VK_Y, true},
"Z": keySet{keybd_event.VK_W, true},
"0": keySet{keybd_event.VK_0, true},
"1": keySet{keybd_event.VK_1, true},
"2": keySet{keybd_event.VK_2, true},
"3": keySet{keybd_event.VK_3, true},
"4": keySet{keybd_event.VK_4, true},
"5": keySet{keybd_event.VK_5, true},
"6": keySet{keybd_event.VK_6, true},
"7": keySet{keybd_event.VK_7, true},
"8": keySet{keybd_event.VK_8, true},
"9": keySet{keybd_event.VK_9, true},
" ": keySet{keybd_event.VK_SPACE, false},
")": keySet{keybd_event.VK_MINUS, false},
"!": keySet{keybd_event.VK_SLASH, false},
"@": keySet{keybd_event.VK_2, false}, // Impossible to do with this setup, sorry mate
"#": keySet{keybd_event.VK_3, false}, // Same here
"$": keySet{keybd_event.VK_RIGHTBRACKET, false},
"%": keySet{keybd_event.VK_QUOTE, true},
"^": keySet{keybd_event.VK_LEFTBRACKET, false},
"&": keySet{keybd_event.VK_1, false},
"*": keySet{keybd_event.VK_BACKSLASH, false},
"(": keySet{keybd_event.VK_5, false},
"-": keySet{keybd_event.VK_6, false},
"=": keySet{keybd_event.VK_EQUAL, false},
"[": keySet{keybd_event.VK_LEFTBRACE, false}, // Alt+GR = Impossible
"]": keySet{keybd_event.VK_RIGHTBRACE, false}, // Sorry
"\\": keySet{keybd_event.VK_BACKSLASH, false}, // Still on Alt+GR
";": keySet{keybd_event.VK_COMMA, false},
"'": keySet{keybd_event.VK_4, false},
",": keySet{keybd_event.VK_M, false},
".": keySet{keybd_event.VK_COMMA, true},
"/": keySet{keybd_event.VK_DOT, true},
"`": keySet{keybd_event.VK_GRAVE, false}, // Alt+gr+7
"_": keySet{keybd_event.VK_8, false},
"+": keySet{keybd_event.VK_EQUAL, true},
"{": keySet{keybd_event.VK_LEFTBRACE, true}, // You died of death
"}": keySet{keybd_event.VK_RIGHTBRACE, true}, // You died of death
"|": keySet{keybd_event.VK_BACKSLASH, true}, // Same
":": keySet{keybd_event.VK_DOT, true},
"\"": keySet{keybd_event.VK_3, false},
"<": keySet{keybd_event.VK_SP12, false},
">": keySet{keybd_event.VK_SP12, true},
"?": keySet{keybd_event.VK_M, true},
"~": keySet{keybd_event.VK_GRAVE, true}, // Oups
"ENTER": keySet{keybd_event.VK_ENTER, false},
"TAB": keySet{keybd_event.VK_TAB, false},
"BACKSPACE": keySet{keybd_event.VK_BACKSPACE, false},
......
......@@ -2,8 +2,12 @@ package string2keyboard
import "github.com/micmonay/keybd_event"
package string2keyboard
import "github.com/micmonay/keybd_event"
var (
names = map[string]keySet{
names_en = map[string]keySet{
"a": keySet{keybd_event.VK_A, false},
"b": keySet{keybd_event.VK_B, false},
"c": keySet{keybd_event.VK_C, false},
......@@ -81,32 +85,139 @@ var (
"*": keySet{keybd_event.VK_8, true},
"(": keySet{keybd_event.VK_9, true},
"-": keySet{keybd_event.VK_OEM_MINUS, false},
"=": keySet{keybd_event.VK_OEM_PLUS, false},
"[": keySet{keybd_event.VK_OEM_4, false},
"]": keySet{keybd_event.VK_OEM_6, false},
"\\": keySet{keybd_event.VK_OEM_5, false},
";": keySet{keybd_event.VK_OEM_1, false},
"'": keySet{keybd_event.VK_OEM_7, false},
",": keySet{keybd_event.VK_OEM_COMMA, false},
".": keySet{keybd_event.VK_OEM_PERIOD, false},
"/": keySet{keybd_event.VK_OEM_2, false},
"`": keySet{keybd_event.VK_OEM_3, false},
"_": keySet{keybd_event.VK_OEM_MINUS, true},
"+": keySet{keybd_event.VK_OEM_PLUS, true},
"{": keySet{keybd_event.VK_OEM_4, true},
"}": keySet{keybd_event.VK_OEM_6, true},
"|": keySet{keybd_event.VK_OEM_5, true},
":": keySet{keybd_event.VK_OEM_1, true},
"\"": keySet{keybd_event.VK_OEM_7, true},
"<": keySet{keybd_event.VK_OEM_COMMA, true},
">": keySet{keybd_event.VK_OEM_PERIOD, true},
"?": keySet{keybd_event.VK_OEM_2, true},
"~": keySet{keybd_event.VK_OEM_3, true},
"-": keySet{keybd_event.VK_MINUS, false},
"=": keySet{keybd_event.VK_EQUAL, false},
"[": keySet{keybd_event.VK_LEFTBRACE, false},
"]": keySet{keybd_event.VK_RIGHTBRACE, false},
"\\": keySet{keybd_event.VK_BACKSLASH, false},
";": keySet{keybd_event.VK_SEMICOLON, false},
"'": keySet{keybd_event.VK_APOSTROPHE, false},
",": keySet{keybd_event.VK_COMMA, false},
".": keySet{keybd_event.VK_DOT, false},
"/": keySet{keybd_event.VK_SLASH, false},
"`": keySet{keybd_event.VK_GRAVE, false},
"_": keySet{keybd_event.VK_MINUS, true},
"+": keySet{keybd_event.VK_EQUAL, true},
"{": keySet{keybd_event.VK_LEFTBRACE, true},
"}": keySet{keybd_event.VK_RIGHTBRACE, true},
"|": keySet{keybd_event.VK_BACKSLASH, true},
":": keySet{keybd_event.VK_SEMICOLON, true},
"\"": keySet{keybd_event.VK_APOSTROPHE, true},
"<": keySet{keybd_event.VK_COMMA, true},
">": keySet{keybd_event.VK_DOT, true},
"?": keySet{keybd_event.VK_SLASH, true},
"~": keySet{keybd_event.VK_GRAVE, true},
"ENTER": keySet{keybd_event.VK_ENTER, false},
"TAB": keySet{keybd_event.VK_TAB, false},
"BACKSPACE": keySet{keybd_event.VK_BACKSPACE, false},
}
// Good enough for UIDS
names_fr = map[string]keySet{
"a": keySet{keybd_event.VK_Q, false},
"b": keySet{keybd_event.VK_B, false},
"c": keySet{keybd_event.VK_C, false},
"d": keySet{keybd_event.VK_D, false},
"e": keySet{keybd_event.VK_E, false},
"f": keySet{keybd_event.VK_F, false},
"g": keySet{keybd_event.VK_G, false},
"h": keySet{keybd_event.VK_H, false},
"i": keySet{keybd_event.VK_I, false},
"j": keySet{keybd_event.VK_J, false},
"k": keySet{keybd_event.VK_K, false},
"l": keySet{keybd_event.VK_L, false},
"m": keySet{keybd_event.VK_SEMICOLON, false},
"n": keySet{keybd_event.VK_N, false},
"o": keySet{keybd_event.VK_O, false},
"p": keySet{keybd_event.VK_P, false},
"q": keySet{keybd_event.VK_A, false},
"r": keySet{keybd_event.VK_R, false},
"s": keySet{keybd_event.VK_S, false},
"t": keySet{keybd_event.VK_T, false},
"u": keySet{keybd_event.VK_U, false},
"v": keySet{keybd_event.VK_V, false},
"w": keySet{keybd_event.VK_Z, false},
"x": keySet{keybd_event.VK_X, false},
"y": keySet{keybd_event.VK_Y, false},
"z": keySet{keybd_event.VK_W, false},
"A": keySet{keybd_event.VK_Q, true},
"B": keySet{keybd_event.VK_B, true},
"C": keySet{keybd_event.VK_C, true},
"D": keySet{keybd_event.VK_D, true},
"E": keySet{keybd_event.VK_E, true},
"F": keySet{keybd_event.VK_F, true},
"G": keySet{keybd_event.VK_G, true},
"H": keySet{keybd_event.VK_H, true},
"I": keySet{keybd_event.VK_I, true},
"J": keySet{keybd_event.VK_J, true},
"K": keySet{keybd_event.VK_K, true},
"L": keySet{keybd_event.VK_L, true},
"M": keySet{keybd_event.VK_SEMICOLON, true},
"N": keySet{keybd_event.VK_N, true},
"O": keySet{keybd_event.VK_O, true},
"P": keySet{keybd_event.VK_P, true},
"Q": keySet{keybd_event.VK_A, true},
"R": keySet{keybd_event.VK_R, true},
"S": keySet{keybd_event.VK_S, true},
"T": keySet{keybd_event.VK_T, true},
"U": keySet{keybd_event.VK_U, true},
"V": keySet{keybd_event.VK_V, true},
"W": keySet{keybd_event.VK_Z, true},
"X": keySet{keybd_event.VK_X, true},
"Y": keySet{keybd_event.VK_Y, true},
"Z": keySet{keybd_event.VK_W, true},
"0": keySet{keybd_event.VK_0, true},
"1": keySet{keybd_event.VK_1, true},
"2": keySet{keybd_event.VK_2, true},
"3": keySet{keybd_event.VK_3, true},
"4": keySet{keybd_event.VK_4, true},
"5": keySet{keybd_event.VK_5, true},
"6": keySet{keybd_event.VK_6, true},
"7": keySet{keybd_event.VK_7, true},
"8": keySet{keybd_event.VK_8, true},
"9": keySet{keybd_event.VK_9, true},
" ": keySet{keybd_event.VK_SPACE, false},
")": keySet{keybd_event.VK_MINUS, false},
"!": keySet{keybd_event.VK_SLASH, false},
"@": keySet{keybd_event.VK_2, false}, // Impossible to do with this setup, sorry mate
"#": keySet{keybd_event.VK_3, false}, // Same here
"$": keySet{keybd_event.VK_RIGHTBRACKET, false},
"%": keySet{keybd_event.VK_QUOTE, true},
"^": keySet{keybd_event.VK_LEFTBRACKET, false},
"&": keySet{keybd_event.VK_1, false},
"*": keySet{keybd_event.VK_BACKSLASH, false},
"(": keySet{keybd_event.VK_5, false},
"-": keySet{keybd_event.VK_6, false},
"=": keySet{keybd_event.VK_EQUAL, false},
"[": keySet{keybd_event.VK_LEFTBRACE, false}, // Alt+GR = Impossible
"]": keySet{keybd_event.VK_RIGHTBRACE, false}, // Sorry
"\\": keySet{keybd_event.VK_BACKSLASH, false}, // Still on Alt+GR
";": keySet{keybd_event.VK_COMMA, false},
"'": keySet{keybd_event.VK_4, false},
",": keySet{keybd_event.VK_M, false},
".": keySet{keybd_event.VK_COMMA, true},
"/": keySet{keybd_event.VK_DOT, true},
"`": keySet{keybd_event.VK_GRAVE, false}, // Alt+gr+7
"_": keySet{keybd_event.VK_8, false},
"+": keySet{keybd_event.VK_EQUAL, true},
"{": keySet{keybd_event.VK_LEFTBRACE, true}, // You died of death
"}": keySet{keybd_event.VK_RIGHTBRACE, true}, // You died of death
"|": keySet{keybd_event.VK_BACKSLASH, true}, // Same
":": keySet{keybd_event.VK_DOT, true},
"\"": keySet{keybd_event.VK_3, false},
"<": keySet{keybd_event.VK_SP12, false},
">": keySet{keybd_event.VK_SP12, true},
"?": keySet{keybd_event.VK_M, true},
"~": keySet{keybd_event.VK_GRAVE, true}, // Oups
"ENTER": keySet{keybd_event.VK_ENTER, false},
"TAB": keySet{keybd_event.VK_TAB, false},
"BACKSPACE": keySet{keybd_event.VK_BACK, false},
"BACKSPACE": keySet{keybd_event.VK_BACKSPACE, false},
}
)
......@@ -27,7 +27,7 @@ import (
```golang
message := "Hello world!"
err := string2keyboard.KeyboardWrite(message)
err := string2keyboard.KeyboardWrite(message, layout)
```
## Special characters
......@@ -51,7 +51,7 @@ Check usage in example folder.
```golang
//Newline example
message := "123\n456"
err := string2keyboard.KeyboardWrite(message)
err := string2keyboard.KeyboardWrite(message, layout)
//Output
123
......@@ -59,14 +59,14 @@ err := string2keyboard.KeyboardWrite(message)
//Tab example
message := "123\t456"
err := string2keyboard.KeyboardWrite(message)
err := string2keyboard.KeyboardWrite(message, layout)
//Output
123 456
//Backslash example
message := "123\\456"
err := string2keyboard.KeyboardWrite(message)
err := string2keyboard.KeyboardWrite(message, layout)
//Output
123\456
......
......@@ -13,7 +13,7 @@ type keySet struct {
}
//KeyboardWrite emulate keyboard input from string
func KeyboardWrite(textInput string) error {
func KeyboardWrite(textInput string, layout string) error {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
return err
......@@ -23,6 +23,12 @@ func KeyboardWrite(textInput string) error {
time.Sleep(2 * time.Second)
}
// Select layout
names := names_en
if layout == "fr" {
names = names_fr
}
//Should we skip next character in string
//Used if we found some escape sequence
skip := false
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment