1
0
mirror of https://github.com/4yn/slidershim.git synced 2024-11-24 05:50:12 +01:00

add start/options to fn buttons

This commit is contained in:
4yn 2022-04-03 11:46:22 +08:00
parent 1d9e52b92f
commit 32045ffa61
2 changed files with 13 additions and 2 deletions

View File

@ -59,7 +59,7 @@ impl OutputHandler for HoriOutput {
fn tick(&mut self, flat_input: &Vec<bool>) -> bool { fn tick(&mut self, flat_input: &Vec<bool>) -> bool {
let hori_state = match self.slider_only { let hori_state = match self.slider_only {
false => HoriState::from_flat(flat_input), false => HoriState::from_flat(flat_input),
true => HoriState::from_flat_to_wide(flat_input) true => HoriState::from_flat_to_wide(flat_input),
}; };
let buttons: u16 = hori_state let buttons: u16 = hori_state
@ -78,7 +78,11 @@ impl OutputHandler for HoriOutput {
true => code, true => code,
false => 0, false => 0,
} }
}); })
| match hori_state.extra[0] {
true => 1 << 13, // options
false => 0,
};
let axis: u32 = hori_state let axis: u32 = hori_state
.slider .slider

View File

@ -1,6 +1,7 @@
pub struct HoriState { pub struct HoriState {
pub slider: [bool; 16], pub slider: [bool; 16],
pub bt: [bool; 4], pub bt: [bool; 4],
pub extra: [bool; 1],
} }
impl HoriState { impl HoriState {
@ -8,6 +9,7 @@ impl HoriState {
let mut hori_state = Self { let mut hori_state = Self {
slider: [false; 16], slider: [false; 16],
bt: [false; 4], bt: [false; 4],
extra: [false; 1],
}; };
for (idx, i) in flat_input[0..32].iter().enumerate() { for (idx, i) in flat_input[0..32].iter().enumerate() {
@ -22,6 +24,8 @@ impl HoriState {
} }
} }
hori_state.extra[0] = flat_input[38];
hori_state hori_state
} }
@ -29,12 +33,15 @@ impl HoriState {
let mut hori_state = Self { let mut hori_state = Self {
slider: [false; 16], slider: [false; 16],
bt: [false; 4], bt: [false; 4],
extra: [false; 1],
}; };
for (idx, i) in flat_input[0..32].iter().enumerate() { for (idx, i) in flat_input[0..32].iter().enumerate() {
hori_state.slider[idx / 2] |= *i; hori_state.slider[idx / 2] |= *i;
} }
hori_state.extra[0] = flat_input[38];
hori_state hori_state
} }
} }