From ec40f6e3acc7874b82709ab81b254c741529fdff Mon Sep 17 00:00:00 2001 From: Mica White Date: Mon, 26 Oct 2026 10:52:04 -0400 Subject: Finish engine --- platforms/tortuise-script-compiled/src/input.rs | 260 ++++++++++++++++++++++++ 1 file changed, 260 insertions(+) create mode 100644 platforms/tortuise-script-compiled/src/input.rs (limited to 'platforms/tortuise-script-compiled/src/input.rs') diff --git a/platforms/tortuise-script-compiled/src/input.rs b/platforms/tortuise-script-compiled/src/input.rs new file mode 100644 index 0000000..a7d7340 --- /dev/null +++ b/platforms/tortuise-script-compiled/src/input.rs @@ -0,0 +1,260 @@ +use serde::{Deserialize, Serialize}; + +use crate::ScriptContext; + +/// Represents a key. +#[derive(Debug, PartialOrd, PartialEq, Eq, Clone, Copy, Hash, Serialize, Deserialize)] +pub enum KeyCode { + /// Backspace key (Delete on macOS, Backspace on other platforms). + Backspace, + /// Enter key. + Enter, + /// Left arrow key. + Left, + /// Right arrow key. + Right, + /// Up arrow key. + Up, + /// Down arrow key. + Down, + /// Home key. + Home, + /// End key. + End, + /// Page up key. + PageUp, + /// Page down key. + PageDown, + /// Tab key. + Tab, + /// Shift + Tab key. + BackTab, + /// Delete key. (Fn+Delete on macOS, Delete on other platforms) + Delete, + /// Insert key. + Insert, + /// F key. + /// + /// `KeyCode::F(1)` represents F1 key, etc. + F(u8), + /// A character. + /// + /// `KeyCode::Char('c')` represents `c` character, etc. + Char(char), + /// Null. + Null, + /// Escape key. + Esc, +} + +pub type Position = tortuise::input::Position; +pub type Direction = tortuise::input::Direction; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Button { + // Action Pad + South = 1, + East = 2, + North = 4, + West = 5, + C = 3, + Z = 6, + // Triggers + LeftTrigger = 7, + LeftTrigger2 = 9, + RightTrigger = 8, + RightTrigger2 = 10, + // Menu Pad + Select = 11, + Start = 12, + Mode = 13, + // Sticks + LeftThumb = 14, + RightThumb = 15, + // D-Pad + DPadUp = 16, + DPadDown = 17, + DPadLeft = 18, + DPadRight = 19, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum Axis { + LeftStickX = 1, + LeftStickY = 2, + LeftZ = 3, + RightStickX = 4, + RightStickY = 5, + RightZ = 6, + DPadX = 7, + DPadY = 8, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub enum PowerInfo { + Wired, + Discharging(u8), + Charging(u8), + Charged, + Unknown, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct Gamepad(usize); + +impl From