zeth / inputs

Cross-platform Python support for keyboards, mice and gamepads
BSD 3-Clause "New" or "Revised" License
273 stars 88 forks source link

Laptop Keyboard not detected by get_key() #4

Closed amos1969 closed 6 years ago

amos1969 commented 8 years ago

Hi

I'm just having a play with inputs on my Linux Laptop, when I run the example to look at the devices it gives me:

Logitech USB Optical Mouse USB2.0 UVC HD Webcam Atmel Atmel maXTouch Digitizer

But doesn't show the keyboard. When I run the simple keyboard example it crashes with:

Traceback (most recent call last): File "/usr/local/lib/python3.5/site-packages/inputs.py", line 2692, in get_key keyboard = devices.keyboards[0] IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/amos/Projects/mech/myinputs.py", line 3, in events = get_key() File "/usr/local/lib/python3.5/site-packages/inputs.py", line 2694, in get_key raise UnpluggedError("No keyboard found.") inputs.UnpluggedError: No keyboard found.

Essentially I guess, because no keyboard is being recognised.

Plugging an external keyboard in removes this error but creates a new permissions related error.

zeth commented 8 years ago

Sorry for the delay in replying. Thanks so much for logging the error.

What model is the laptop?

With the external keyboard it sounds like your user is not in the inputs group. What distro is it? If you run your program as root does it find the keyboard?

amos1969 commented 8 years ago

Hi Zeth

It's an Asus Vivobook S200E. I'm running Linux Mint 17.2 which doesn't have a group called inputs.

I'll try creating one and let you know if it works.

Dave

OzymandiasTheGreat commented 7 years ago

Hello, same error on Linux Mint 18. My touchpad is also not detected. I tried putting myself in input group, same thing. Also tried running as root. Laptop is Asus X51L.

bryhoyt commented 7 years ago

Same error on a Lenovo Thinkpad T520, both Python2 and 3, Elementary OS Freya (Ubuntu-based):

$ sudo python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import inputs
>>> inputs.get_key()
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/inputs.py", line 2692, in get_key
    keyboard = devices.keyboards[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/inputs.py", line 2694, in get_key
    raise UnpluggedError("No keyboard found.")
inputs.UnpluggedError: No keyboard found.
>>> exit()
$ cat /etc/lsb-release 
DISTRIB_ID="elementary OS"
DISTRIB_RELEASE=0.3.1
DISTRIB_CODENAME=freya
DISTRIB_DESCRIPTION="elementary OS Freya"
bryhoyt commented 7 years ago

This problem appears to be because some devices (laptop keyboards!) don't appear in /dev/input/by-id/. The above PR should fix it.

zeth commented 6 years ago

This is fixed in 0.2. Thanks to @bryhoyt