controller_linux.go 677 B

123456789101112131415161718192021222324252627282930313233
  1. package controller
  2. import "gitlab.com/beoran/galago/os/linux"
  3. import "os"
  4. import "unsafe"
  5. import "syscall"
  6. import "fmt"
  7. func Ioctl(file * os.File, code uint32, pointer unsafe.Pointer) error {
  8. fmt.Printf("ioctl: %d %d %d\n", uintptr(file.Fd()), uintptr(code), uintptr(pointer))
  9. _, _, errno := syscall.Syscall(
  10. syscall.SYS_IOCTL,
  11. uintptr(file.Fd()),
  12. uintptr(code),
  13. uintptr(pointer))
  14. if (errno != 0) {
  15. return errno
  16. }
  17. return nil
  18. }
  19. func GetDriverVersion(file * os.File) (int32, error) {
  20. res := int32(0)
  21. data := unsafe.Pointer(&res)
  22. err := Ioctl(file, linux.EVIOCGVERSION, data)
  23. return res, err
  24. }