golang-evdev icon indicating copy to clipboard operation
golang-evdev copied to clipboard

Writing to device?

Open evanpurkhiser opened this issue 7 years ago • 1 comments

Would be awesome if this library supported writing to the devices :-)

evanpurkhiser avatar Mar 27 '17 04:03 evanpurkhiser

Just for future reference: you can easily write to any device using the constants and structs provided in the library

func input_event(typ uint16, code uint16, value int32) ev.InputEvent {
	return ev.InputEvent{
		Time: syscall.Timeval{
			Sec:  time.Now().Unix(),
			Usec: time.Now().UnixNano() / 1000 % 1000,
		},
		Type:  typ,
		Code:  code,
		Value: value,
	}
}

and

binary.Write(f, binary.LittleEndian, input_event(ev.EV_KEY, ev.KEY_LEFTCTRL, 1))

omeryagmurlu avatar Sep 24 '21 15:09 omeryagmurlu