made inputConfigs

pull/4/head
Milk.H 2024-05-07 15:24:55 +02:00
parent 71add6cfc6
commit c78e556210
Signed by: milk
GPG Key ID: 1C656AF758F96101
2 changed files with 63 additions and 11 deletions

View File

@ -11,7 +11,7 @@ cgmath = "0.18.0"
egui = "0.23.0" egui = "0.23.0"
egui-winit = "0.23.0" egui-winit = "0.23.0"
egui_glow = { version = "0.23.0", features = ["winit"] } egui_glow = { version = "0.23.0", features = ["winit"] }
gilrs = "0.10.7" gilrs = { version = "0.10.7", features = ["serde-serialize"] }
glow = "0.12.3" glow = "0.12.3"
glutin = "0.30.10" glutin = "0.30.10"
glutin-winit = "0.3.0" glutin-winit = "0.3.0"

View File

@ -1,9 +1,8 @@
/// Configs Module /// Configs Module
use ron; use gilrs::ev::Button;
/// ///
/// ///
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Configs {} pub struct Configs {}
@ -14,10 +13,63 @@ pub struct DisplayConfigs {
// i think thats it tbqh // i think thats it tbqh
} }
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize, Debug, Default)]
pub struct InputConfigs {} pub struct InputConfigs {
keyboard_single: KeyboardConfig,
//Keyboard_duo_1: KeyboardConfig,
// keyboard_duo_2: KeyboardConfig
Controller1: Option<ControllerConfig>,
Controller2: Option<ControllerConfig>,
Controller3: Option<ControllerConfig>,
Controller4: Option<ControllerConfig>,
Controller5: Option<ControllerConfig>,
}
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize, Debug)]
pub struct ControllerConfig {
// directionals
Up: Button,
Down: Button,
Right: Button,
Left: Button,
// the punches
LightPunch: Button,
MediumPunch: Button,
HeavyPunch: Button,
// the kicks
LightKick: Button,
MediumKick: Button,
HeavyKick: Button,
// Macros
PunchMacro: Option<Button>,
KickMacro: Option<Button>,
}
impl Default for ControllerConfig {
fn default() -> Self {
Self {
Up: Button::DPadUp,
Down: Button::DPadDown,
Right: Button::DPadRight,
Left: Button::DPadLeft,
LightPunch: Button::West,
MediumPunch: Button::North,
HeavyPunch: Button::RightTrigger,
LightKick: Button::South,
MediumKick: Button::East,
HeavyKick: Button::LeftTrigger,
PunchMacro: Some(Button::RightTrigger2),
KickMacro: Some(Button::LeftTrigger2),
}
}
}
#[derive(Deserialize, Serialize, Debug)]
pub struct KeyboardConfig { pub struct KeyboardConfig {
// directionals // directionals
Up: ScanCodes, Up: ScanCodes,
@ -36,8 +88,8 @@ pub struct KeyboardConfig {
HeavyKick: ScanCodes, HeavyKick: ScanCodes,
// Macros // Macros
PunchMacro: ScanCodes, PunchMacro: Option<ScanCodes>,
KickMacro: ScanCodes, KickMacro: Option<ScanCodes>,
} }
impl Default for KeyboardConfig { impl Default for KeyboardConfig {
@ -53,8 +105,8 @@ impl Default for KeyboardConfig {
LightKick: ScanCodes::H, LightKick: ScanCodes::H,
MediumKick: ScanCodes::J, MediumKick: ScanCodes::J,
HeavyKick: ScanCodes::K, HeavyKick: ScanCodes::K,
PunchMacro: ScanCodes::P, PunchMacro: Some(ScanCodes::P),
KickMacro: ScanCodes::L, KickMacro: Some(ScanCodes::L),
} }
} }
} }
@ -64,7 +116,7 @@ impl Default for KeyboardConfig {
/// TODO finish this /// TODO finish this
/// UNTESTED AND UNFINISHED /// UNTESTED AND UNFINISHED
#[repr(u32)] #[repr(u32)]
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize, Debug)]
pub enum ScanCodes { pub enum ScanCodes {
Escape = 0x01, Escape = 0x01,
Key1 = 0x02, Key1 = 0x02,