added serde and wrote some of the configuration code

pull/4/head
Milk.H 2024-05-01 13:06:20 +01:00
parent 518ccff2aa
commit e1c61d6799
Signed by: milk
GPG Key ID: 94C7CB70FFF80593
2 changed files with 170 additions and 0 deletions

View File

@ -18,4 +18,5 @@ glutin-winit = "0.3.0"
image = "0.25.1"
raw-window-handle = "0.6.1"
ron = "0.8.1"
serde = { version = "1.0.199", features = ["derive"] }
winit = "0.28.7"

169
src/config.rs Normal file
View File

@ -0,0 +1,169 @@
/// Configs Module
///
///
use serde::{Deserialize, Serialize};
use ron;
#[derive(Deserialize, Serialize)]
pub struct Configs
{
}
#[derive(Deserialize, Serialize)]
pub struct DisplayConfigs
{
// TODO set Resolutions
//Resolution:
// i think thats it tbqh
}
#[derive(Deserialize, Serialize)]
pub struct InputConfigs
{
}
#[derive(Deserialize, Serialize)]
pub struct KeyboardConfig
{
// directionals
Up: u32,
Down: u32,
Right: u32,
Left: u32,
// the punches
LightPunch: u32,
MediumPunch: u32,
HeavyPunch: u32,
// the kicks
LightKick: u32,
MediumKick: u32,
HeavyKick: u32,
// Macros
PunchMacro: u32,
KickMacro: u32
}
impl Default for KeyboardConfig
{
fn default() -> Self
{
KeyboardConfig {
Up: ScanCodes::W,
Down: ScanCodes::S,
Right: ScanCodes::D,
Left: ScanCodes::A,
LightPunch: ScanCodes::U,
MediumPunch: ScanCodes::I,
HeavyPunch: ScanCodes::O,
LightKick: ScanCodes::H,
MediumKick: ScanCodes::J,
HeavyKick: ScanCodes::K,
PunchMacro: ScanCodes::P,
KickMacro: ScanCodes::L
}
}
}
/// these ones are written after this
/// https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html
/// TODO finish this
/// UNTESTED AND UNFINISHED
#[repr(u32)]
pub enum ScanCodes
{
Escape = 0x01,
Key1 = 0x02,
Key2 = 0x03,
Key3 = 0x04,
Key4 = 0x05,
Key5 = 0x06,
Key6 = 0x07,
Key7 = 0x08,
Key8 = 0x09,
Key9 = 0x0a,
Key0 = 0x0b,
Minus = 0x0c,
Equal = 0x0d,
BackSpace = 0x0e,
Tab = 0x0f,
Q = 0x10,
W = 0x11,
E = 0x12,
R = 0x13,
T = 0x14,
Y = 0x15,
U = 0x16,
I = 0x17,
O = 0x18,
P = 0x19,
OpenBracket = 0x1a,
CloseBrack = 0x1b,
Enter = 0x1c,
LCtrl = 0x1d,
A = 0x1e,
S = 0x1f,
D = 0x20,
F = 0x21,
G = 0x22,
H = 0x23,
J = 0x24,
K = 0x25,
L = 0x26,
SemiColon = 0x27,
Quote = 0x28,
Tilde = 0x29,
LShift = 0x2a,
Pipe = 0x2b,
Z = 0x2c,
X = 0x2d,
C = 0x2e,
V = 0x2f,
B = 0x30,
N = 0x31,
M = 0x32,
// TODO figure out what these are called lmao
// "<" and ">"
LeftTri = 0x33,
RightTri = 0x34,
QMark = 0x35,
RShift = 0x36,
KeyPad = 0x37,
LAlt = 0x38,
Space = 0x39,
Caps = 0x3a,
// NOTE Skip the Function Keys,
// Delusional
// will have to do logic later to just ignore the call for that lmao
Numlock = 0x45,
ScrollLock = 0x46,
KeyPad7 = 0x47,
KeyPad8 = 0x48,
KeyPad9 = 0x49,
KeyPadMinus = 0x4a,
KeyPad4 = 0x4b,
KeyPad5 = 0x4c,
KeyPad6 = 0x4d,
KeyPadPlus = 0x4e,
KeyPad1 = 0x4f,
KeyPad2 = 0x50,
KeyPad3 = 0x51,
KeyPad0 = 0x52,
KeyPadDot = 0x53,
// NOTE don't bother with the ones after this, these are super important
// (for some degenerates)
UpArrow = 0x67,
LeftArrow = 0x69,
RightArrow = 0x6a,
DownArrow = 0x6c
}