timothycrosley / streamdeck-ui

A Linux compatible UI for the Elgato Stream Deck.
https://timothycrosley.github.io/streamdeck-ui/
MIT License
1.16k stars 241 forks source link

Update Streamdeck to support pedal #227

Open moenzuel opened 2 years ago

moenzuel commented 2 years ago

The stream deck lib released 0.9.1 and added support for the stream deck pedal.

Not a python dev and the environment setup failed so I don't know if additional changes are needed past updating the dependency.

dodgyrabbit commented 2 years ago

FYI version 2.0.4 does use streamdeck 0.9.1. You can certainly add the required udev rule for the device and see what happens. I don't have one of these and I doubt it "would just work". If there is a lot of interest, I can review. Cast your support with a 👍. I would imagine not many people have this device and there are other more important things to work on but I could be wrong.

SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0086", TAG+="uaccess"
AndyG commented 2 years ago

yup, adding the above rule does get us further, but you run into:

➜  ~ streamdeck
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/andy/.local/lib/python3.8/site-packages/streamdeck_ui/stream_deck_monitor.py", line 89, in _run
    self.attached(streamdeck_id, streamdeck)
  File "/home/andy/.local/lib/python3.8/site-packages/streamdeck_ui/api.py", line 188, in attached
    self.update_streamdeck_filters(serial_number)
  File "/home/andy/.local/lib/python3.8/site-packages/streamdeck_ui/api.py", line 474, in update_streamdeck_filters
    display_handler = self.display_handlers.get(serial_number, DisplayGrid(self.lock, deck, pages, self.cpu_usage_callback))
  File "/home/andy/.local/lib/python3.8/site-packages/streamdeck_ui/display/display_grid.py", line 44, in __init__
    self.size = streamdeck.key_image_format()["size"]
  File "/home/andy/.local/lib/python3.8/site-packages/StreamDeck/Devices/StreamDeck.py", line 247, in key_image_format
    'format': self.KEY_IMAGE_FORMAT,
AttributeError: 'StreamDeckPedal' object has no attribute 'KEY_IMAGE_FORMAT'

i could probably try and take a look at this this weekend, but it's pretty far out of my wheelhouse haha

ctgPi commented 2 years ago

I have a very crude fix that's been working for me (in Zoom meetings etc.) that also adds support for running commands on release:

https://gist.github.com/ctgPi/6e39650d7f64dce5f8822fb34de9ca67

raleighlittles commented 2 years ago

I just bought a Streamdeck Pedal to use on Linux and happened to stumble on this thread.

@ctgPi, I skimmed through your diff, and to my untrained eyes (I'm obviously not familiar with the codebase at all) it seems fine. What about it is very crude, and how could it be improved? I'd like to add support for the pedal in the project so I don't have to maintain a fork.

dodgyrabbit commented 2 years ago

I don't know too much about this product, but I guess in principle it's just a 1x3 set of "buttons" with no screen. Hopefully we can figure something out, but there are other priorities to wrap up first.

raleighlittles commented 2 years ago

I don't know too much about this product, but I guess in principle it's just a 1x3 set of "buttons" with no screen.

Yes, that's exactly right.

Here's what the UI for it looks like on the actual Windows application. image

@dodgyrabbit

RoarkGit commented 1 year ago

I'd like to bump this again to say this would be a nice feature to have. There is a similar application called Boatswain that supports the Pedal, but the developer has a narrow-minded vision for use cases. streamdeck-ui supporting the Pedal and having better overall functionality (e.g. arbitrary hotkeys for things like push-to-talk) would make it hugely useful for me.

dodgyrabbit commented 1 year ago

@ctgPi Is running a command on the release of the pedal essential?

ctgPi commented 1 year ago

My rationale was to have the pedal work as hold-to-talk; since I've been using a Scythe pedal that only toggles on-off; I think that for an initial version of the feature it's fine to not implement the release logic for simplicity.

RoarkGit commented 1 year ago

Being able to hold would be ideal for me personally, but at least being able to toggle with a single keypress would be sufficient in the meantime.

dodgyrabbit commented 1 year ago

I've published a build that should work now. Please give it a test drive. I don't have a pedal, so besides emulation, I could not test it myself.

python -m pip install streamdeck-ui --user --upgrade
dodgyrabbit commented 1 year ago

One question I have is for someone who has this device. If you open settings (which may try set the display brightness), do you get an error - or does the pedal have an LED or some kind of light? You can still set text or an image, but obviously it doesn't do anything to the pedal.

RoarkGit commented 1 year ago

Hmm, when I installed I have my regular Stream Deck show up, but not the Stream Deck Pedal (dropdown only has one entry).. I'm unsure if something else needs to be configured, though.

For info: Fedora 37, GNOME, Wayland

image

dodgyrabbit commented 1 year ago

I'm unsure if something else needs to be configured, though. There should not be configuration required inside streamdeck_ui, but you do need to provide access to the device via udev.

Can you confirm the contents of /etc/udev/rules.d/70-streamdeck.rules contains this one line? SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", TAG+="uaccess"

We need to rule out that udev being the root cause, not providing access to the device.

Can you also confirm the version of streamdeck_ui, Help -> About

You could also try removing the regular streamdeck and only plug in the pedal, to see if there is any specific output in the terminal.

RoarkGit commented 1 year ago

Yeah, unfortunately I do have that udevrule set up properly. The version looks to be 2.0.15, and when I unplug the rulgar Stream Deck I still don't see anything helpful in the terminal regarding the pedal. image image

dodgyrabbit commented 1 year ago

Could you download the following Python file from the author of the streamdeck library, run it and let's see what the output is.

https://github.com/abcminiuser/python-elgato-streamdeck/blob/master/src/example_pedal.py

image

You should be able to run it like this, assuming it's in your current directory:

python example_pedal.py

You may need to use python3 or whatever your OS equivalent is. If you're using a virtual environment, make sure its activated.

This simple example will enumerate what the library "sees" as attached and provide some output whenever you press a pedal.

You should exit streamdeck_ui while running this sample.

RoarkGit commented 1 year ago
> python3 example_pedal.py
Found 2 Stream Deck(s).

Opened 'Stream Deck Original' device (serial number: 'DL42K1A06374', fw: '1.00.003')

Seems like it finds two devices but just hangs without printing the pedal.

FriedrichFroebel commented 1 year ago

Using the latest streamdeck_ui==2.0.15 and streamdeck==0.9.3 gives the following exception inside the terminal when connecting the pedal:

Exception in thread Thread-3 (_run):
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.10/threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.10/dist-packages/streamdeck_ui/display/display_grid.py", line 165, in _run
    image = PILHelper.to_native_format(self.streamdeck, image)
  File "/usr/local/lib/python3.10/dist-packages/StreamDeck/ImageHelpers/PILHelper.py", line 103, in to_native_format
    image.thumbnail(image_format['size'])
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 2602, in thumbnail
    size = preserve_aspect_ratio()
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 2592, in preserve_aspect_ratio
    if x / y >= aspect:
ZeroDivisionError: division by zero

It seems like the UI does not yet like that the pedal does not have an image grid and therefore the image size is reported as 0 pixels.

coolapso commented 1 year ago

hi, this project seems to be stale and a new fork as been made with the intention of replacing this one.

if this still an issue please reopen it at: https://github.com/streamdeck-linux-gui/streamdeck-linux-gui