first commit

This commit is contained in:
christalib 2019-11-19 23:48:26 +01:00
commit 4dec97b732
5 changed files with 172 additions and 0 deletions

5
go.mod Normal file
View file

@ -0,0 +1,5 @@
module git.postblue.info/keygoller
go 1.12
require github.com/sirupsen/logrus v1.4.2

9
go.sum Normal file
View file

@ -0,0 +1,9 @@
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

BIN
keygoller Executable file

Binary file not shown.

34
main.go Normal file
View file

@ -0,0 +1,34 @@
package main
import (
"fmt"
"io/ioutil"
"strings"
"github.com/sirupsen/logrus"
)
func getKeyboard() string {
path := "/sys/class/input/event%d/device/name"
resolved := "/dev/input/event%d"
for i := 0; i < 255; i++ {
buff, err := ioutil.ReadFile(fmt.Sprintf(path, i))
if err != nil {
logrus.Error(err)
}
if strings.Contains(strings.ToLower(string(buff)), "keyboard") {
return fmt.Sprintf(resolved, i)
}
}
return ""
}
func main() {
fmt.Println("Your keyboard input will be here: ", getKeyboard())
// TODO
// !) get streaming data from keyboard
// 2 unpackage the data to be human readable
// 3 stream the data through an api
}

124
utils/main.go Normal file
View file

@ -0,0 +1,124 @@
package utils
// keyCodeMap connects the code with human readable key
var KeyCodeMap = map[uint16]string{
1: "ESC",
2: "1",
3: "2",
4: "3",
5: "4",
6: "5",
7: "6",
8: "7",
9: "8",
10: "9",
11: "0",
12: "-",
13: "=",
14: "BS",
15: "TAB",
16: "Q",
17: "W",
18: "E",
19: "R",
20: "T",
21: "Y",
22: "U",
23: "I",
24: "O",
25: "P",
26: "[",
27: "]",
28: "ENTER",
29: "L_CTRL",
30: "A",
31: "S",
32: "D",
33: "F",
34: "G",
35: "H",
36: "J",
37: "K",
38: "L",
39: ";",
40: "'",
41: "`",
42: "L_SHIFT",
43: "\\",
44: "Z",
45: "X",
46: "C",
47: "V",
48: "B",
49: "N",
50: "M",
51: ",",
52: ".",
53: "/",
54: "R_SHIFT",
55: "*",
56: "L_ALT",
57: "SPACE",
58: "CAPS_LOCK",
59: "F1",
60: "F2",
61: "F3",
62: "F4",
63: "F5",
64: "F6",
65: "F7",
66: "F8",
67: "F9",
68: "F10",
69: "NUM_LOCK",
70: "SCROLL_LOCK",
71: "HOME",
72: "UP_8",
73: "PGUP_9",
74: "-",
75: "LEFT_4",
76: "5",
77: "RT_ARROW_6",
78: "+",
79: "END_1",
80: "DOWN",
81: "PGDN_3",
82: "INS",
83: "DEL",
84: "",
85: "",
86: "",
87: "F11",
88: "F12",
89: "",
90: "",
91: "",
92: "",
93: "",
94: "",
95: "",
96: "R_ENTER",
97: "R_CTRL",
98: "/",
99: "PRT_SCR",
100: "R_ALT",
101: "",
102: "Home",
103: "Up",
104: "PgUp",
105: "Left",
106: "Right",
107: "End",
108: "Down",
109: "PgDn",
110: "Insert",
111: "Del",
112: "",
113: "",
114: "",
115: "",
116: "",
117: "",
118: "",
119: "Pause",
}