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

}
