Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOError: [Errno 25] Inappropriate ioctl for device (Linux, buildroot) #126

Open
Sjoerd82 opened this issue Feb 15, 2018 · 4 comments
Open

Comments

@Sjoerd82
Copy link

Running the Example from the Readme.md, I am greeted with:

Traceback (most recent call last):
  File "example.py", line 3, in <module>
    keyboard.press_and_release('shift+s, space')
  File "/root/defender-headunit/keyboard/__init__.py", line 639, in press_and_release
    send(combination, True, True)
  File "/root/defender-headunit/keyboard/__init__.py", line 623, in send
    _os_keyboard.press(to_scan_code(key))
  File "/root/defender-headunit/keyboard/_nixkeyboard.py", line 157, in press
    write_event(scan_code, True)
  File "/root/defender-headunit/keyboard/_nixkeyboard.py", line 142, in write_event
    build_device()
  File "/root/defender-headunit/keyboard/_nixkeyboard.py", line 107, in build_device
    device = aggregate_devices('kbd')
  File "/root/defender-headunit/keyboard/_nixcommon.py", line 141, in aggregate_devices
    uinput = make_uinput()
  File "/root/defender-headunit/keyboard/_nixcommon.py", line 29, in make_uinput
    fcntl.ioctl(uinput, UI_SET_EVBIT, EV_KEY)
IOError: [Errno 25] Inappropriate ioctl for device

My /dev/uinput:

-rw-r--r--    1 root     root           0 Jan  1 00:37 /dev/uinput

My /dev/input

drwxr-xr-x    4 root     root         140 Jan  1 00:00 .
drwxr-xr-x   11 root     root        3.0K Jan  1 00:31 ..
drwxr-xr-x    2 root     root          80 Jan  1 00:00 by-id
drwxr-xr-x    2 root     root          80 Jan  1 00:00 by-path
crw-rw----    1 root     input      13,  64 Jan  1 00:00 event0
crw-rw----    1 root     input      13,  65 Jan  1 00:00 event1
crw-rw----    1 root     input      13,  63 Jan  1 00:00 mice

by-id:

drwxr-xr-x    2 root     root          80 Jan  1 00:00 .
drwxr-xr-x    4 root     root         140 Jan  1 00:00 ..
lrwxrwxrwx    1 root     root           9 Jan  1 00:00 usb-GASIA_GASIA_USB_KB_Pro-event-if01 -> ../event1
lrwxrwxrwx    1 root     root           9 Jan  1 00:00 usb-GASIA_GASIA_USB_KB_Pro-event-kbd -> ../event0

by-path:

drwxr-xr-x    2 root     root          80 Jan  1 00:00 .
drwxr-xr-x    4 root     root         140 Jan  1 00:00 ..
lrwxrwxrwx    1 root     root           9 Jan  1 00:00 platform-20980000.usb-usb-0:1.2:1.0-event-kbd -> ../event0
lrwxrwxrwx    1 root     root           9 Jan  1 00:00 platform-20980000.usb-usb-0:1.2:1.1-event -> ../event1

I'm running as root. Distribution is Buildroot.
Perhaps I'm missing libs? But I have the kbd libs.

@boppreh
Copy link
Owner

boppreh commented Feb 25, 2018

Sorry for the delay looking into this issue, I was without a Linux machine for a while.

I think the problem is that your system doesn't have the uinput module. keyboard tries to open the file /dev/uinput expecting to create a new device, but ends up just creating a regular file at that location. This can be seen by the mode of the file, -rw-r--r-- , instead of crw-------, where c means "character special file".

uinput is used to ensure we can always send any keys without depending on physical keyboard limitations, or even the presence of a physical keyboard. If your system has a plugged in keyboard we can try removing the dependency on uinput; if it doesn't have either uinput or a plugged in keyboard, I'm out of ideas.

Additionally, I'll add a check to ensure uinput exists before trying to create the file.

@boppreh
Copy link
Owner

boppreh commented Feb 25, 2018

Missing uinput shouldn't error out anymore. Please give the master branch a try and tell me if that fixes your problem.

@Sjoerd82
Copy link
Author

I'll retest soon, I'll let you know.

@hmusgrave
Copy link

hmusgrave commented Oct 24, 2020

I have the same error on the master branch.

Edit: Enabling uinput in the kernel fixes everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants