mirror of
https://github.com/OpenActionAPI/rust-elgato-streamdeck.git
synced 2026-10-28 09:44:56 +00:00
Clean up Mirabox device implementations
This commit is contained in:
1 parent
401b25daaf
commit
1bb900b7bf
3 files changed
+51
-47
No files matched your search
+34
-30
@@ -22,34 +22,34 @@ pub const PID_STREAMDECK_PEDAL: u16 = 0x0086;
|
||||
/// Product ID of Stream Deck Plus
|
||||
pub const PID_STREAMDECK_PLUS: u16 = 0x0084;
|
||||
|
||||
/// Vendor ID of Ajazz Desk Controller
|
||||
pub const AJAZZ_VENDOR_ID_1: u16 = 0x5548;
|
||||
/// A Mirabox vendor ID
|
||||
pub const MIRABOX_VENDOR_ID_1: u16 = 0x5548;
|
||||
|
||||
/// Product ID of Ajazz AKP153 Desk Controller
|
||||
/// Product ID of Ajazz AKP153
|
||||
pub const PID_AJAZZ_AKP153: u16 = 0x6674;
|
||||
|
||||
/// Product ID of Ajazz AKP815
|
||||
pub const PID_AJAZZ_AKP815: u16 = 0x6672;
|
||||
|
||||
/// Product ID of the "FHOOU" (front label) and "MiraBox HSV293S" (rear label). Seems just like an AKP153.
|
||||
pub const PID_MIRABOX_HSV293S: u16 = 0x6670;
|
||||
|
||||
/// Product ID of Ajazz AKP815 Desk Controller
|
||||
pub const PID_AJAZZ_AKP815: u16 = 0x6672;
|
||||
/// A Mirabox vendor ID
|
||||
pub const MIRABOX_VENDOR_ID_2: u16 = 0x0300;
|
||||
|
||||
/// Vendor ID of Ajazz AKP153E Desk Controller
|
||||
pub const AJAZZ_VENDOR_ID_2: u16 = 0x0300;
|
||||
|
||||
/// Product ID of Ajazz AKP153E Desk Controller
|
||||
/// Product ID of Ajazz AKP153E
|
||||
pub const PID_AJAZZ_AKP153E: u16 = 0x1010;
|
||||
|
||||
/// Product ID of Ajazz AKP153R Desk Controller
|
||||
/// Product ID of Ajazz AKP153R
|
||||
pub const PID_AJAZZ_AKP153R: u16 = 0x1020;
|
||||
|
||||
/// Product ID of Ajazz AKP03E Desk Controller
|
||||
/// Product ID of Ajazz AKP03E
|
||||
pub const PID_AJAZZ_AKP03E: u16 = 0x3002;
|
||||
|
||||
/// Product ID of Ajazz AKP03R Desk Controller
|
||||
/// Product ID of Ajazz AKP03R
|
||||
pub const PID_AJAZZ_AKP03R: u16 = 0x1003;
|
||||
|
||||
const RECOGNIZED_VENDORS: [u16; 3] = [ELGATO_VENDOR_ID, AJAZZ_VENDOR_ID_1, AJAZZ_VENDOR_ID_2];
|
||||
const RECOGNIZED_VENDORS: [u16; 3] = [ELGATO_VENDOR_ID, MIRABOX_VENDOR_ID_1, MIRABOX_VENDOR_ID_2];
|
||||
|
||||
/// Returns true for vendors IDs that are recognized by the library
|
||||
pub fn is_vendor_familiar(vendor: &u16) -> bool {
|
||||
@@ -79,17 +79,17 @@ pub enum Kind {
|
||||
Pedal,
|
||||
/// Stream Deck Plus
|
||||
Plus,
|
||||
/// Ajazz AKP153 Desk Controller
|
||||
/// Ajazz AKP153
|
||||
Akp153,
|
||||
/// Ajazz AKP153E Desk Controller
|
||||
/// Ajazz AKP153E
|
||||
Akp153E,
|
||||
/// Ajazz AKP153R Desk Controller
|
||||
/// Ajazz AKP153R
|
||||
Akp153R,
|
||||
/// Ajazz AKP815 Desk Controller
|
||||
/// Ajazz AKP815
|
||||
Akp815,
|
||||
/// Ajazz AKP03E Desk Controller
|
||||
/// Ajazz AKP03E
|
||||
Akp03E,
|
||||
/// Ajazz AKP03R Desk Controller
|
||||
/// Ajazz AKP03R
|
||||
Akp03R,
|
||||
/// MiraBox HSV293S
|
||||
MiraBoxHSV293S,
|
||||
@@ -113,14 +113,18 @@ impl Kind {
|
||||
_ => None,
|
||||
},
|
||||
|
||||
AJAZZ_VENDOR_ID_1 | AJAZZ_VENDOR_ID_2 => match pid {
|
||||
MIRABOX_VENDOR_ID_1 => match pid {
|
||||
PID_AJAZZ_AKP153 => Some(Kind::Akp153),
|
||||
PID_AJAZZ_AKP815 => Some(Kind::Akp815),
|
||||
PID_MIRABOX_HSV293S => Some(Kind::MiraBoxHSV293S),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
MIRABOX_VENDOR_ID_2 => match pid {
|
||||
PID_AJAZZ_AKP153E => Some(Kind::Akp153E),
|
||||
PID_AJAZZ_AKP153R => Some(Kind::Akp153R),
|
||||
PID_AJAZZ_AKP815 => Some(Kind::Akp815),
|
||||
PID_AJAZZ_AKP03E => Some(Kind::Akp03E),
|
||||
PID_AJAZZ_AKP03R => Some(Kind::Akp03R),
|
||||
PID_MIRABOX_HSV293S => Some(Kind::MiraBoxHSV293S),
|
||||
_ => None,
|
||||
},
|
||||
|
||||
@@ -142,9 +146,9 @@ impl Kind {
|
||||
Kind::Pedal => PID_STREAMDECK_PEDAL,
|
||||
Kind::Plus => PID_STREAMDECK_PLUS,
|
||||
Kind::Akp153 => PID_AJAZZ_AKP153,
|
||||
Kind::Akp815 => PID_AJAZZ_AKP815,
|
||||
Kind::Akp153E => PID_AJAZZ_AKP153E,
|
||||
Kind::Akp153R => PID_AJAZZ_AKP153R,
|
||||
Kind::Akp815 => PID_AJAZZ_AKP815,
|
||||
Kind::Akp03E => PID_AJAZZ_AKP03E,
|
||||
Kind::Akp03R => PID_AJAZZ_AKP03R,
|
||||
Kind::MiraBoxHSV293S => PID_MIRABOX_HSV293S,
|
||||
@@ -164,13 +168,13 @@ impl Kind {
|
||||
Kind::Neo => ELGATO_VENDOR_ID,
|
||||
Kind::Pedal => ELGATO_VENDOR_ID,
|
||||
Kind::Plus => ELGATO_VENDOR_ID,
|
||||
Kind::Akp153 => AJAZZ_VENDOR_ID_1,
|
||||
Kind::Akp815 => AJAZZ_VENDOR_ID_1,
|
||||
Kind::Akp153E => AJAZZ_VENDOR_ID_2,
|
||||
Kind::Akp153R => AJAZZ_VENDOR_ID_2,
|
||||
Kind::Akp03E => AJAZZ_VENDOR_ID_2,
|
||||
Kind::Akp03R => AJAZZ_VENDOR_ID_2,
|
||||
Kind::MiraBoxHSV293S => AJAZZ_VENDOR_ID_1,
|
||||
Kind::Akp153 => MIRABOX_VENDOR_ID_1,
|
||||
Kind::Akp153E => MIRABOX_VENDOR_ID_2,
|
||||
Kind::Akp153R => MIRABOX_VENDOR_ID_2,
|
||||
Kind::Akp815 => MIRABOX_VENDOR_ID_1,
|
||||
Kind::Akp03E => MIRABOX_VENDOR_ID_2,
|
||||
Kind::Akp03R => MIRABOX_VENDOR_ID_2,
|
||||
Kind::MiraBoxHSV293S => MIRABOX_VENDOR_ID_1,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -23,7 +23,7 @@ use image::{DynamicImage, ImageError};
|
||||
|
||||
use crate::info::{is_vendor_familiar, Kind};
|
||||
use crate::util::{
|
||||
ajazz03_read_input, ajazz_extend_packet, ajazz153_to_elgato_input, elgato_to_ajazz153, extract_str, flip_key_index, get_feature_report, inverse_key_index, read_button_states, read_data,
|
||||
ajazz03_read_input, mirabox_extend_packet, ajazz153_to_elgato_input, elgato_to_ajazz153, extract_str, flip_key_index, get_feature_report, inverse_key_index, read_button_states, read_data,
|
||||
read_encoder_input, read_lcd_input, send_feature_report, write_data,
|
||||
};
|
||||
|
||||
@@ -222,11 +222,11 @@ impl StreamDeck {
|
||||
|
||||
if self.kind.is_mirabox() {
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x44, 0x49, 0x53];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x4c, 0x49, 0x47, 0x00, 0x00, 0x00, 0x00];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ impl StreamDeck {
|
||||
kind if kind.is_mirabox() => {
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x4c, 0x49, 0x47, 0x00, 0x00, percent];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
@@ -402,7 +402,7 @@ impl StreamDeck {
|
||||
key + 1,
|
||||
];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ impl StreamDeck {
|
||||
/// Writes image data to Stream Deck device, changes must be flushed with `.flush()` before
|
||||
/// they will appear on the device!
|
||||
pub fn write_image(&self, key: u8, image_data: &[u8]) -> Result<(), StreamDeckError> {
|
||||
// Key count is 9 for Akp03*, but only the first 6 (0-5) have screens, so don't output anything for keys 6, 7, 8
|
||||
// Key count is 9 for AKP03x, but only the first 6 (0-5) have screens, so don't output anything for keys 6, 7, 8
|
||||
if (self.kind == Kind::Akp03E || self.kind == Kind::Akp03R) && key >= 6 {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -569,7 +569,7 @@ impl StreamDeck {
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x43, 0x4c, 0x45, 0x00, 0x00, 0x00, if key == 0xff { 0xff } else { key + 1 }];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
@@ -590,7 +590,7 @@ impl StreamDeck {
|
||||
|
||||
// Mirabox "v2" requires STP to commit clearing the screen
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x53, 0x54, 0x50];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
Ok(())
|
||||
@@ -627,7 +627,7 @@ impl StreamDeck {
|
||||
// 854 * 480 * 3
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x4c, 0x4f, 0x47, 0x00, 0x12, 0xc3, 0xc0, 0x01];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
@@ -759,7 +759,7 @@ impl StreamDeck {
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x48, 0x41, 0x4e];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
@@ -775,7 +775,7 @@ impl StreamDeck {
|
||||
}
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x43, 0x4F, 0x4E, 0x4E, 0x45, 0x43, 0x54];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -789,11 +789,11 @@ impl StreamDeck {
|
||||
}
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x43, 0x4c, 0x45, 0x00, 0x00, 0x44, 0x43];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x48, 0x41, 0x4E];
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
|
||||
Ok(())
|
||||
@@ -814,7 +814,7 @@ impl StreamDeck {
|
||||
if self.kind.is_mirabox() {
|
||||
let mut buf = vec![0x00, 0x43, 0x52, 0x54, 0x00, 0x00, 0x53, 0x54, 0x50];
|
||||
|
||||
ajazz_extend_packet(&self.kind, &mut buf);
|
||||
mirabox_extend_packet(&self.kind, &mut buf);
|
||||
|
||||
write_data(&self.device, buf.as_slice())?;
|
||||
}
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ pub fn extract_str(bytes: &[u8]) -> Result<String, Utf8Error> {
|
||||
| 13 | 14 | 15 | 16 | 17 | 18 |
|
||||
-----------------------------
|
||||
|
||||
Ajazz's AKP153(E) key index
|
||||
Ajazz AKP153x's key index
|
||||
-----------------------------
|
||||
| 0d | 0a | 07 | 04 | 01 | 10 |
|
||||
|----|----|----|----|----|----|
|
||||
@@ -64,7 +64,7 @@ pub fn extract_str(bytes: &[u8]) -> Result<String, Utf8Error> {
|
||||
| 0f | 0c | 09 | 06 | 03 | 12 |
|
||||
-----------------------------
|
||||
|
||||
Ajazz's AKP815 key index
|
||||
Ajazz AKP815's key index
|
||||
--------------
|
||||
| 0f | 0e | 0d |
|
||||
|----|----|----|
|
||||
@@ -113,7 +113,7 @@ pub fn flip_key_index(kind: &Kind, key: u8) -> u8 {
|
||||
}
|
||||
|
||||
/// Extends buffer up to required packet length
|
||||
pub fn ajazz_extend_packet(kind: &Kind, buf: &mut Vec<u8>) {
|
||||
pub fn mirabox_extend_packet(kind: &Kind, buf: &mut Vec<u8>) {
|
||||
let length = if kind.is_mirabox_v2() { 1025 } else { 513 };
|
||||
|
||||
buf.extend(vec![0u8; length - buf.len()]);
|
||||
|
||||
Reference in new issue
Block a user