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

add diva slider only layout without buttons

This commit is contained in:
4yn 2022-04-03 11:30:34 +08:00
parent f0ed581b3d
commit 1d9e52b92f
5 changed files with 44 additions and 6 deletions

View File

@ -27,6 +27,12 @@ pub enum GamepadLayout {
Neardayo,
}
#[derive(Debug, Clone, Copy)]
pub enum HoriLayout {
Full,
SliderOnly,
}
#[derive(Debug, Clone)]
pub enum OutputMode {
None,
@ -41,6 +47,7 @@ pub enum OutputMode {
sensitivity: u8,
},
Hori {
layout: HoriLayout,
polling: PollingRate,
sensitivity: u8,
},
@ -128,6 +135,12 @@ impl OutputMode {
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
},
"gamepad-hori" => OutputMode::Hori {
layout: HoriLayout::Full,
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
},
"gamepad-hori-wide" => OutputMode::Hori {
layout: HoriLayout::SliderOnly,
polling: PollingRate::from_str(v["outputPolling"].as_str()?)?,
sensitivity: u8::try_from(v["keyboardSensitivity"].as_i64()?).ok()?,
},

View File

@ -4,20 +4,27 @@ use vigem_client::{Client, DS4Report, DualShock4Wired, TargetId};
use crate::shared::hori::HoriState;
use super::output::OutputHandler;
use super::{config::HoriLayout, output::OutputHandler};
pub struct HoriOutput {
target: DualShock4Wired<Client>,
slider_only: bool,
gamepad: DS4Report,
}
impl HoriOutput {
pub fn new() -> Option<Self> {
pub fn new(layout: HoriLayout) -> Option<Self> {
let target = Self::get_target();
let slider_only = match layout {
HoriLayout::Full => false,
HoriLayout::SliderOnly => true,
};
match target {
Ok(target) => Some(Self {
target,
slider_only,
gamepad: DS4Report::default(),
}),
Err(e) => {
@ -50,7 +57,10 @@ impl HoriOutput {
impl OutputHandler for HoriOutput {
fn tick(&mut self, flat_input: &Vec<bool>) -> bool {
let hori_state = HoriState::from_flat(flat_input);
let hori_state = match self.slider_only {
false => HoriState::from_flat(flat_input),
true => HoriState::from_flat_to_wide(flat_input)
};
let buttons: u16 = hori_state
.bt

View File

@ -67,11 +67,12 @@ impl AsyncJob for OutputJob {
}
}
OutputMode::Hori {
layout,
polling,
sensitivity,
} => {
self.sensitivity = sensitivity;
let handler = HoriOutput::new();
let handler = HoriOutput::new(layout.clone());
self.timer = interval(Duration::from_micros(polling.to_t_u64()));
match handler {

View File

@ -24,4 +24,17 @@ impl HoriState {
hori_state
}
pub fn from_flat_to_wide(flat_input: &Vec<bool>) -> Self {
let mut hori_state = Self {
slider: [false; 16],
bt: [false; 4],
};
for (idx, i) in flat_input[0..32].iter().enumerate() {
hori_state.slider[idx / 2] |= *i;
}
hori_state
}
}

View File

@ -304,8 +304,9 @@
<option value="gamepad-neardayo"
>XBOX 360 Gamepad, Neardayo Layout</option
>
<option value="gamepad-hori"
>DS4, HORI DIVA Future Tone ASC Layout</option
<option value="gamepad-hori">DS4, HORI DIVA FT ASC Layout</option>
<option value="gamepad-hori-wide"
>DS4, HORI DIVA FT ASC Slider Only Layout</option
>
<!-- <option value="websocket">Websocket</option> -->
</select>