Fix/mira box n3 en buttons (#43)

This commit is contained in:
Jens Heinrich authored and GitHub committed 2025-04-16 18:54:27 +01:00
1 parent bd495125c9
commit 4f83de3ab8
4 files changed
+19 -14

No files matched your search

+2 -2
View File
@@ -221,7 +221,7 @@ impl AsyncDeviceStateReader {
match input {
StreamDeckInput::ButtonStateChange(buttons) => {
for (index, (their, mine)) in zip(buttons.iter(), my_states.buttons.iter()).enumerate() {
if self.device.kind.is_mirabox() {
if self.device.kind.is_mirabox() && self.device.kind != Kind::MiraBoxN3EN {
if *their {
updates.push(DeviceStateUpdate::ButtonDown(index as u8));
updates.push(DeviceStateUpdate::ButtonUp(index as u8));
@@ -246,7 +246,7 @@ impl AsyncDeviceStateReader {
StreamDeckInput::EncoderStateChange(encoders) => {
for (index, (their, mine)) in zip(encoders.iter(), my_states.encoders.iter()).enumerate() {
if self.device.kind.is_mirabox() {
if self.device.kind.is_mirabox() && self.device.kind != Kind::MiraBoxN3EN {
if *their {
updates.push(DeviceStateUpdate::EncoderDown(index as u8));
updates.push(DeviceStateUpdate::EncoderUp(index as u8));
+1 -1
View File
@@ -58,7 +58,7 @@ pub const PID_AJAZZ_AKP03R: u16 = 0x1003;
/// A Mirabox vendor ID
pub const MIRABOX_VENDOR_ID_3: u16 = 0x6603;
/// Product ID of Mirabox N3EN
/// Product ID of the "FHOOU" (front label) and "MiraBox N3" (rear label) and "MiraBox N3EN" as per Mirabox's repository. Seems just like an AKP03.
pub const PID_MIRABOX_N3EN: u16 = 0x1003;
const RECOGNIZED_VENDORS: [u16; 4] = [ELGATO_VENDOR_ID, MIRABOX_VENDOR_ID_1, MIRABOX_VENDOR_ID_2, MIRABOX_VENDOR_ID_3];
+8 -3
View File
@@ -292,7 +292,12 @@ impl StreamDeck {
return Ok(StreamDeckInput::NoData);
}
ajazz03_read_input(&self.kind, data[9])
if self.kind == Kind::MiraBoxN3EN {
ajazz03_read_input(&self.kind, data[9], data[10])
} else {
// Devices not returning a state for the input
ajazz03_read_input(&self.kind, data[9], 0x01)
}
}
_ => {
@@ -1044,7 +1049,7 @@ impl DeviceStateReader {
match input {
StreamDeckInput::ButtonStateChange(buttons) => {
for (index, (their, mine)) in zip(buttons.iter(), my_states.buttons.iter()).enumerate() {
if self.device.kind.is_mirabox() {
if self.device.kind.is_mirabox() && self.device.kind != Kind::MiraBoxN3EN {
if *their {
updates.push(DeviceStateUpdate::ButtonDown(index as u8));
updates.push(DeviceStateUpdate::ButtonUp(index as u8));
@@ -1070,7 +1075,7 @@ impl DeviceStateReader {
StreamDeckInput::EncoderStateChange(encoders) => {
for (index, (their, mine)) in zip(encoders.iter(), my_states.encoders.iter()).enumerate() {
if self.device.kind.is_mirabox() {
if self.device.kind.is_mirabox() && self.device.kind != Kind::MiraBoxN3EN {
if *their {
updates.push(DeviceStateUpdate::EncoderDown(index as u8));
updates.push(DeviceStateUpdate::EncoderUp(index as u8));
+8 -8
View File
@@ -187,17 +187,17 @@ pub fn read_encoder_input(kind: &Kind, data: &[u8]) -> Result<StreamDeckInput, S
}
}
/// Read inputs from Ajazz AKP03x
pub fn ajazz03_read_input(kind: &Kind, input: u8) -> Result<StreamDeckInput, StreamDeckError> {
/// Read inputs from Ajazz AKP03x and MiraBox N3 devices
pub fn ajazz03_read_input(kind: &Kind, input: u8, state: u8) -> Result<StreamDeckInput, StreamDeckError> {
match input {
(0..=6) | 0x25 | 0x30 | 0x31 => ajazz03_read_button_press(kind, input),
(0..=6) | 0x25 | 0x30 | 0x31 => ajazz03_read_button_press(kind, input, state),
0x90 | 0x91 | 0x50 | 0x51 | 0x60 | 0x61 => ajazz03_read_encoder_value(kind, input),
0x33..=0x35 => ajazz03_read_encoder_press(kind, input),
0x33..=0x35 => ajazz03_read_encoder_press(kind, input, state),
_ => Err(StreamDeckError::BadData),
}
}
fn ajazz03_read_button_press(kind: &Kind, input: u8) -> Result<StreamDeckInput, StreamDeckError> {
fn ajazz03_read_button_press(kind: &Kind, input: u8, state: u8) -> Result<StreamDeckInput, StreamDeckError> {
let mut button_states = vec![0x01];
button_states.extend(vec![0u8; (kind.key_count() + 1) as usize]);
@@ -215,7 +215,7 @@ fn ajazz03_read_button_press(kind: &Kind, input: u8) -> Result<StreamDeckInput,
_ => return Err(StreamDeckError::BadData),
};
button_states[pressed_index] = 0x1u8;
button_states[pressed_index] = state;
Ok(StreamDeckInput::ButtonStateChange(read_button_states(kind, &button_states)))
}
@@ -240,7 +240,7 @@ fn ajazz03_read_encoder_value(kind: &Kind, input: u8) -> Result<StreamDeckInput,
Ok(StreamDeckInput::EncoderTwist(encoder_values))
}
fn ajazz03_read_encoder_press(kind: &Kind, input: u8) -> Result<StreamDeckInput, StreamDeckError> {
fn ajazz03_read_encoder_press(kind: &Kind, input: u8, state: u8) -> Result<StreamDeckInput, StreamDeckError> {
let mut encoder_states = vec![false; kind.encoder_count() as usize];
let encoder: usize = match input {
@@ -250,6 +250,6 @@ fn ajazz03_read_encoder_press(kind: &Kind, input: u8) -> Result<StreamDeckInput,
_ => return Err(StreamDeckError::BadData),
};
encoder_states[encoder] = true;
encoder_states[encoder] = state != 0;
Ok(StreamDeckInput::EncoderStateChange(encoder_states))
}