kde-lockscreen-suspend-display/xdg/keypressdetector/evdev.go

29 lines
517 B
Go

package keypressdetector
// #cgo CFLAGS: -g -Wall
// #include "evdev.h"
// #include <stdlib.h>
import "C"
import (
"unsafe"
"syscall"
)
// Evdev can detect keypresses on /dev/input devices
type Evdev struct {}
// BlockUntilKeypress waits until a key is pressed on the specified device
func (Evdev) BlockUntilKeypress(devicePath string) error {
path := C.CString(devicePath)
defer C.free(unsafe.Pointer(path))
ret := C.block_until_keypress(path)
if ret != 0 {
return syscall.Errno(ret)
}
return nil
}