Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions 40-streamdeck.rules
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00a5", MODE="0660"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00b8", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00b9", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00ba", MODE="0660", TAG+="uaccess"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00c6", MODE="0660", TAG+="uaccess"

KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", MODE="0660", TAG+="uaccess"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0063", MODE="0660", TAG+="uaccess"
Expand All @@ -29,3 +30,4 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00b8", MODE="0660", TAG+="uaccess"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00b9", MODE="0660", TAG+="uaccess"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00ba", MODE="0660", TAG+="uaccess"
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="00c6", MODE="0660", TAG+="uaccess"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ As it stands, this library should support the following devices.
- Stream Deck Mk2
- Stream Deck Pedal
- Stream Deck Plus (thanks to [node-elgato-stream-deck](https://github.com/Julusian/node-elgato-stream-deck))
- Stream Deck Plus XL
- Stream Deck Neo (thanks to [@ejiektpobehuk](https://github.com/ejiektpobehuk), [@AkechiShiro](https://github.com/AkechiShiro) and [node-elgato-stream-deck](https://github.com/Julusian/node-elgato-stream-deck))

Support for non-Elgato (Mirabox/Ajazz) devices has been removed in v0.11. If you wish to use these devices, please use the `mirajazz` crate, or use v0.10.2 of this crate.
10 changes: 8 additions & 2 deletions examples/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ compile_error!("The `async` feature must be enabled to compile this example.");

use std::time::Duration;
use image::open;

use elgato_streamdeck::info::{ImageFormat};
use elgato_streamdeck::{DeviceStateUpdate, list_devices, new_hidapi, AsyncStreamDeck};
use elgato_streamdeck::images::{convert_image_with_format, ImageRect};
use tokio::time::sleep;
Expand Down Expand Up @@ -50,7 +50,13 @@ async fn main() {
Some((w, h)) => {
let min = w.min(h) as u32;
let scaled_image = image.clone().resize_to_fill(min, min, image::imageops::Nearest);
Some(ImageRect::from_image(scaled_image).unwrap())
let converted_image = convert_image_with_format(ImageFormat {
mode: device.kind().lcd_image_format().unwrap().mode,
size: (min.try_into().unwrap(), min.try_into().unwrap()),
rotation: device.kind().lcd_image_format().unwrap().rotation,
mirror: device.kind().lcd_image_format().unwrap().mirror,
}, scaled_image).unwrap();
Some(ImageRect::from_image(image::load_from_memory(&converted_image).unwrap()).unwrap())
}
None => None,
};
Expand Down
28 changes: 25 additions & 3 deletions src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub const PID_STREAMDECK_NEO: u16 = 0x009a;
pub const PID_STREAMDECK_PEDAL: u16 = 0x0086;
/// Product ID of Stream Deck Plus
pub const PID_STREAMDECK_PLUS: u16 = 0x0084;
/// Product ID of Stream Deck + XL
pub const PID_STREAMDECK_PLUS_XL: u16 = 0x00c6;
/// Product ID of Stream Deck Mini Mk2 Module
pub const PID_STREAMDECK_MINI_MK2_MODULE: u16 = 0x00b8;
/// Product ID of Stream Deck Mk2 Module
Expand Down Expand Up @@ -70,6 +72,8 @@ pub enum Kind {
Pedal,
/// Stream Deck Plus
Plus,
/// Stream Deck + XL
PlusXl,
/// Stream Deck Mini Mk2 Module
MiniMk2Module,
/// Stream Deck Mk2 Module
Expand All @@ -95,6 +99,7 @@ impl Kind {
PID_STREAMDECK_NEO => Some(Kind::Neo),
PID_STREAMDECK_PEDAL => Some(Kind::Pedal),
PID_STREAMDECK_PLUS => Some(Kind::Plus),
PID_STREAMDECK_PLUS_XL => Some(Kind::PlusXl),
PID_STREAMDECK_MINI_MK2_MODULE => Some(Kind::MiniMk2Module),
PID_STREAMDECK_MK2_MODULE => Some(Kind::Mk2Module),
PID_STREAMDECK_XL_V2_MODULE => Some(Kind::XlV2Module),
Expand All @@ -119,6 +124,7 @@ impl Kind {
Kind::Neo => PID_STREAMDECK_NEO,
Kind::Pedal => PID_STREAMDECK_PEDAL,
Kind::Plus => PID_STREAMDECK_PLUS,
Kind::PlusXl => PID_STREAMDECK_PLUS_XL,
Kind::MiniMk2Module => PID_STREAMDECK_MINI_MK2_MODULE,
Kind::Mk2Module => PID_STREAMDECK_MK2_MODULE,
Kind::XlV2Module => PID_STREAMDECK_XL_V2_MODULE,
Expand All @@ -140,6 +146,7 @@ impl Kind {
Kind::Neo => ELGATO_VENDOR_ID,
Kind::Pedal => ELGATO_VENDOR_ID,
Kind::Plus => ELGATO_VENDOR_ID,
Kind::PlusXl => ELGATO_VENDOR_ID,
Kind::MiniMk2Module => ELGATO_VENDOR_ID,
Kind::Mk2Module => ELGATO_VENDOR_ID,
Kind::XlV2Module => ELGATO_VENDOR_ID,
Expand All @@ -152,6 +159,7 @@ impl Kind {
Kind::Original | Kind::OriginalV2 | Kind::Mk2 | Kind::Mk2Scissor | Kind::Mk2Module => 15,
Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => 6,
Kind::Xl | Kind::XlV2 | Kind::XlV2Module => 32,
Kind::PlusXl => 36,
Kind::Pedal => 3,
Kind::Neo | Kind::Plus => 8,
}
Expand All @@ -162,7 +170,7 @@ impl Kind {
match self {
Kind::Original | Kind::OriginalV2 | Kind::Mk2 | Kind::Mk2Scissor | Kind::Mk2Module => 3,
Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => 2,
Kind::Xl | Kind::XlV2 | Kind::XlV2Module => 4,
Kind::Xl | Kind::XlV2 | Kind::XlV2Module | Kind::PlusXl => 4,
Kind::Pedal => 1,
Kind::Neo | Kind::Plus => 2,
}
Expand All @@ -174,6 +182,7 @@ impl Kind {
Kind::Original | Kind::OriginalV2 | Kind::Mk2 | Kind::Mk2Scissor | Kind::Mk2Module => 5,
Kind::Mini | Kind::MiniMk2 | Kind::MiniDiscord | Kind::MiniMk2Module => 3,
Kind::Xl | Kind::XlV2 | Kind::XlV2Module => 8,
Kind::PlusXl => 9,
Kind::Pedal => 3,
Kind::Neo | Kind::Plus => 4,
}
Expand All @@ -183,6 +192,7 @@ impl Kind {
pub fn encoder_count(&self) -> u8 {
match self {
Kind::Plus => 4,
Kind::PlusXl => 6,
_ => 0,
}
}
Expand All @@ -199,6 +209,7 @@ impl Kind {
pub fn lcd_strip_size(&self) -> Option<(usize, usize)> {
match self {
Kind::Plus => Some((800, 100)),
Kind::PlusXl => Some((100, 1200)),
Kind::Neo => Some((248, 58)),
_ => None,
}
Expand Down Expand Up @@ -251,7 +262,12 @@ impl Kind {
rotation: ImageRotation::Rot0,
mirror: ImageMirroring::None,
},

Kind::PlusXl => ImageFormat {
mode: ImageMode::JPEG,
size: (120, 120),
rotation: ImageRotation::Rot270,
mirror: ImageMirroring::None,
},
Kind::Pedal => ImageFormat::default(),
}
}
Expand All @@ -271,6 +287,12 @@ impl Kind {
rotation: ImageRotation::Rot0,
mirror: ImageMirroring::None,
}),
Kind::PlusXl => Some(ImageFormat {
mode: ImageMode::JPEG,
size: (100, 1200),
rotation: ImageRotation::Rot270,
mirror: ImageMirroring::None,
}),
_ => None,
}
}
Expand Down Expand Up @@ -348,7 +370,7 @@ impl Kind {
0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x02, 0x8a, 0x28, 0xa0, 0x0f, 0xff, 0xd9,
],

Kind::Plus => vec![
Kind::Plus | Kind::PlusXl => vec![
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x78, 0x00, 0x78, 0x03,
0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05, 0x08,
0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07, 0x07, 0x06, 0x08, 0x0c, 0x0a, 0x0c, 0x0c, 0x0b, 0x0a, 0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d, 0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16,
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ impl StreamDeck {
/// Reads all possible input from Stream Deck device
pub fn read_input(&self, timeout: Option<Duration>) -> Result<StreamDeckInput, StreamDeckError> {
match &self.kind {
Kind::Plus => {
let data = read_data(&self.device, 14.max(5 + self.kind.encoder_count() as usize), timeout)?;

Kind::Plus | Kind::PlusXl => {
let data = read_data(&self.device, 6 + self.kind.key_count().max(5 + self.kind.encoder_count()) as usize, timeout)?;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: you added a small space here ;)

if data[0] == 0 {
return Ok(StreamDeckInput::NoData);
}
Expand Down Expand Up @@ -319,7 +319,7 @@ impl StreamDeck {
/// Only Stream Deck Plus supports writing LCD regions, for Stream Deck Neo use write_lcd_fill
pub fn write_lcd(&self, x: u16, y: u16, rect: &ImageRect) -> Result<(), StreamDeckError> {
match self.kind {
Kind::Plus => (),
Kind::Plus | Kind::PlusXl => (),
_ => return Err(StreamDeckError::UnsupportedOperation),
}

Expand Down Expand Up @@ -382,7 +382,7 @@ impl StreamDeck {
},
),

Kind::Plus => {
Kind::Plus | Kind::PlusXl => {
let (w, h) = self.kind.lcd_strip_size().unwrap();

self.write_image_data_reports(
Expand Down