zeth / inputs

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

struct.error: unpack requires a string argument of length 16 #20

Closed huntfx closed 6 years ago

huntfx commented 6 years ago

It doesn't like the chunk size of 24 on Python 2.7, stops the error if set to 16.

Traceback (most recent call last):
  File "C:\Users\Peter\Python\MouseTrack\extensions\test.py", line 17, in <module>
    events = get_key()
  File "C:\Users\Peter\Python\MouseTrack\extensions\inputs.py", line 2698, in get_key
    return keyboard.read()
  File "C:\Users\Peter\Python\MouseTrack\extensions\inputs.py", line 2104, in read
    return next(iter(self))
  File "C:\Users\Peter\Python\MouseTrack\extensions\inputs.py", line 2064, in __iter__
    event = self._do_iter()
  File "C:\Users\Peter\Python\MouseTrack\extensions\inputs.py", line 2087, in _do_iter
    events = [self._make_event(*event) for event in evdev_objects]
  File "C:\Users\Peter\Python\MouseTrack\extensions\inputs.py", line 87, in chunks
    yield struct.unpack(EVENT_FORMAT, raw[i:i+24])
struct.error: unpack requires a string argument of length 16
zeth commented 6 years ago

Thanks very much, I will test that on Windows 2.7 and will patch appropriately.