gvalkov / golang-evdev Goto Github PK
View Code? Open in Web Editor NEWGo bindings for the linux input subsystem
License: Other
Go bindings for the linux input subsystem
License: Other
Hi,
I am catching keyboard strokes (device.Grab + device.ReadOne) but how can I translate key events to a final char with right casing ?
Thanks.
PiZero and Pi 4B with Raspbian Buster (debian 10 buster).
newest version can't read keyboard events with ReadOne() or Read()
change to b6f418b work fine.
mouse event works fine with all version.
$GOPATH/src/github.com/gvalkov/golang-evdev
. It should install it in $GOPATH/src/github.com/gvalkov/evdev
if package name in it is evdev
.evdev
in bin/evtest.go is evdev
. It should be github.com/gvalkov/evdev
.When I run the command :
go get -v "github.com/gvalkov/golang-evdev"
github.com/gvalkov/golang-evdev (download)
github.com/gvalkov/golang-evdev
../../../../../gvalkov/golang-evdev/cdefs.go:4:26: fatal error: linux/input.h: No such file or directory
#include <linux/input.h>
^
compilation terminated.
I run the command from a docker container :
FROM golang:1.11.0-alpine3.8 as builder
RUN apk add -U alpine-sdk git python
ENV GOARCH=arm64
I tried cross compiling:
GOARCH=arm64 go build -v
github.com/Max2Inc/IES-Services/golang-evdev-master
./device.go:132:9: undefined: ioctl
./device.go:132:38: undefined: EVIOCGBIT
./device.go:142:4: undefined: ioctl
./device.go:142:33: undefined: EVIOCGBIT
./device.go:164:15: undefined: MAX_NAME_SIZE
./device.go:165:15: undefined: MAX_NAME_SIZE
./device.go:167:9: undefined: ioctl
./device.go:167:38: undefined: EVIOCGID
./device.go:172:2: undefined: ioctl
./device.go:323:26: undefined: MAX_NAME_SIZE
./device.go:172:2: too many errors
with the following config
go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jerome/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jerome/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jerome/Documents/Go Examples/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build261697354=/tmp/go-build -gno-record-gcc-switches"
Would be awesome if this library supported writing to the devices :-)
After b6f418b there was some change that broke the usage of golang-evdev
on my Raspberry Pi 3B+ running balenaOS. (With resin/scratch containers built with balenalib/raspberrypi3-alpine-golang)
In the latest version of this package the input device list is empty
([]*evdev.InputDevice{}
) and /dev/input/event0
doesn’t exist.
For now my workaround is to lock the version of this package to b6f418b but just wanted to give you a heads up.
(I’m using this package in combination with https://github.com/nathany/bobblehat on a RPi connected to a SenseHAT)
sudo go get github.com/gvalkov/golang-evdev
# github.com/gvalkov/golang-evdev
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:122: undefined: EV_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:122: invalid array bound (EV_MAX + 1) / 8
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:123: undefined: KEY_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:123: invalid array bound (KEY_MAX + 1) / 8
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:126: undefined: EV_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:130: undefined: EV_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:134: undefined: KEY_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:135: undefined: KEY_MAX
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:137: undefined: ByEventType
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:143: undefined: EV
/usr/lib/go/src/pkg/github.com/gvalkov/golang-evdev/device.go:143: too many errors
Hi, As github does not allow to send any message to gvalkov, I try a issue to state my question to him
Its a question, if golang-evdev can be used in my use-case...
Currently I am using a USB-Device https://www.usbbutton.com/ to toggle the state of a software.
As the device can only output a pre-defined textsequence, like "send-signal.sh(enter)"
I have to use the cli as a separate step to start a shellscript, that is
sending a signal to my app (sudo pkill -USR1 MyApp). Then the app reacts to the signal by toggling its state.
Press USB-Button -> USB Device pastes text sequence to cli "send-signal.sh(enter)" -> cli execute shellscript -> Shellscript sends signal to software -> Software toggles state
As this is a quite complicated way to toggle the software status, and I was wondering if golang-evdev
is able to do the trick also, even without using the cli.
Press USB-Button -> golang-evdev -> Software toggles state
As its a headless device, it would be great if I don't have to use cli in future as I do currently....
Thanks and best regards
Alex
Good day @gvalkov, marvelous work you and the other contributors have done to craft this project.
I have noticed that the README was updated recently in regards to a new project maintainer.
I am in the process of cultivating some newfound works that are going to utilize many elements of this golang-evdev project and I thought I may just look to take over the status of maintainer of the project so I can bring things a bit more up to date and get some of the needed changes into the repository.
Let me know you thoughts and if this may work for yourself and I would be happy to take this one on.
Cheers
In order to cancel an ongoing read, I assumed is was sufficient to close the underlying file-descriptor by calling dev.File.Close()
- but the ReadOne
function (and I suppose the normal Read
also) hangs until a new message arrives on the input device (tested with evemu).
I don't really see any other way to abort a read in progress... I've looked briefly into the code but couldn't immediately see what would be wrong, it just seems to use normal Go i/o internally?
Tested with go version go1.11.2 linux/amd64
with evemu.
$ GOOS=linux GOARCH=arm go get github.com/gvalkov/golang-evdev
# github.com/gvalkov/golang-evdev
../../gvalkov/golang-evdev/device.go:132:9: undefined: ioctl
../../gvalkov/golang-evdev/device.go:132:38: undefined: EVIOCGBIT
../../gvalkov/golang-evdev/device.go:142:4: undefined: ioctl
../../gvalkov/golang-evdev/device.go:142:33: undefined: EVIOCGBIT
../../gvalkov/golang-evdev/device.go:164:15: undefined: MAX_NAME_SIZE
../../gvalkov/golang-evdev/device.go:165:15: undefined: MAX_NAME_SIZE
../../gvalkov/golang-evdev/device.go:167:9: undefined: ioctl
../../gvalkov/golang-evdev/device.go:167:38: undefined: EVIOCGID
../../gvalkov/golang-evdev/device.go:172:2: undefined: ioctl
../../gvalkov/golang-evdev/device.go:304:26: undefined: MAX_NAME_SIZE
../../gvalkov/golang-evdev/device.go:172:2: too many errors
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.