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-winit = "0.23.0"
egui_glow = { version = "0.23.0", features = ["winit"] }
gilrs = "0.10.7"
gilrs = { version = "0.10.7", features = ["serde-serialize"] }
glow = "0.12.3"
glutin = "0.30.10"
glutin-winit = "0.3.0"

View File

@ -1,9 +1,8 @@
/// Configs Module
use ron;
use gilrs::ev::Button;
///
///
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct Configs {}
@ -14,10 +13,63 @@ pub struct DisplayConfigs {
// i think thats it tbqh
}
#[derive(Deserialize, Serialize)]
pub struct InputConfigs {}
#[derive(Deserialize, Serialize, Debug, Default)]
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 {
// directionals
Up: ScanCodes,
@ -36,8 +88,8 @@ pub struct KeyboardConfig {
HeavyKick: ScanCodes,
// Macros
PunchMacro: ScanCodes,
KickMacro: ScanCodes,
PunchMacro: Option<ScanCodes>,
KickMacro: Option<ScanCodes>,
}
impl Default for KeyboardConfig {
@ -53,8 +105,8 @@ impl Default for KeyboardConfig {
LightKick: ScanCodes::H,
MediumKick: ScanCodes::J,
HeavyKick: ScanCodes::K,
PunchMacro: ScanCodes::P,
KickMacro: ScanCodes::L,
PunchMacro: Some(ScanCodes::P),
KickMacro: Some(ScanCodes::L),
}
}
}
@ -64,7 +116,7 @@ impl Default for KeyboardConfig {
/// TODO finish this
/// UNTESTED AND UNFINISHED
#[repr(u32)]
#[derive(Serialize, Deserialize)]
#[derive(Serialize, Deserialize, Debug)]
pub enum ScanCodes {
Escape = 0x01,
Key1 = 0x02,