abcminiuser / python-elgato-streamdeck

Python library to control the Elgato Stream Deck.
Other
919 stars 137 forks source link

Stream Deck + returns 10 key states instead of 8 #136

Closed Giraut closed 8 months ago

Giraut commented 8 months ago

The Stream Deck + has 8 keys (KEY_COUNT == 8 ) but it returns 10 ControlType.KEY states when reading the control states.

E.g. this test code:

from StreamDeck.DeviceManager import DeviceManager
from StreamDeck.Devices.StreamDeck import ControlType

for streamdeck in DeviceManager().enumerate():
  if streamdeck.deck_type == "Stream Deck +":
    break

streamdeck.device.open()
streamdeck._reset_key_stream()

while True:
  ctrl_states = streamdeck._read_control_states()
  if ctrl_states is not None:
    key_states = ctrl_states.get(ControlType.KEY, None)
    if key_states is not None:
      print("KEY_COUNT:", streamdeck.KEY_COUNT, "Nb of key states:", len(key_states), "-", key_states, end = "\r")

...outputs this:

KEY_COUNT: 8 Nb of key states: 10 - [False, False, False, False, False, False, False, False, False, False]

Test setup:

Linux Mint 21.3 Virginia (Linux kernel 6.5.0) Python 3.10.12 streamdeck 0.9.5

abcminiuser commented 8 months ago

Should be fixed by https://github.com/abcminiuser/python-elgato-streamdeck/commit/f8f0335148685d7e434b6c833e6ce90f234f3937 - I don't have hardware to experimentally determine what the suffix bytes are for, so I've just ignored them in that patch to ensure only the first 8 payload entries are converted to key press states.

Giraut commented 8 months ago

It's not fixed. I just created a PR to fix the issue - and a typo that slipped in too in the same file.