/// Input System Protocol - Platform-agnostic input handling /// This module contains ONLY protocol definitions with no platform-specific imports import Foundation // MARK: - Input Types /// Keyboard key codes public enum KeyCode: Int, Sendable { case unknown = 0 case space = 32 case apostrophe = 39 case comma = 44 case minus = 45 case period = 46 case slash = 47 case key0 = 48, key1, key2, key3, key4, key5, key6, key7, key8, key9 case semicolon = 59 case equal = 61 case a = 65, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z case leftBracket = 91 case backslash = 92 case rightBracket = 93 case graveAccent = 96 case escape = 256 case enter = 257 case tab = 258 case backspace = 259 case insert = 260 case delete = 261 case right = 262 case left = 263 case down = 264 case up = 265 case pageUp = 266 case pageDown = 267 case home = 268 case end = 269 case capsLock = 280 case scrollLock = 281 case numLock = 282 case printScreen = 283 case pause = 284 case f1 = 290, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12 case leftShift = 340 case leftControl = 341 case leftAlt = 342 case leftSuper = 343 case rightShift = 344 case rightControl = 345 case rightAlt = 346 case rightSuper = 347 } /// Mouse button codes public enum MouseButton: Int, Sendable { case left = 0 case right = 1 case middle = 2 case button4 = 3 case button5 = 4 } /// Input action state public enum InputAction: Sendable { case press case release case repeat_ } /// Input event types public enum InputEvent: Sendable { case keyEvent(key: KeyCode, action: InputAction) case mouseButton(button: MouseButton, action: InputAction) case mouseMove(x: Double, y: Double) case mouseScroll(xOffset: Double, yOffset: Double) case gamepadButton(gamepadId: Int, button: Int, action: InputAction) case gamepadAxis(gamepadId: Int, axis: Int, value: Float) } // MARK: - Input Handler Protocol /// Input system abstraction - all platform-specific input implementations must conform public protocol InputHandler: Sendable { /// Initialize the input system func initialize() async throws /// Poll for input events (called each frame) func pollEvents() -> [InputEvent] /// Check if a key is currently pressed func isKeyPressed(_ key: KeyCode) -> Bool /// Check if a mouse button is currently pressed func isMouseButtonPressed(_ button: MouseButton) -> Bool /// Get current mouse position func getMousePosition() -> (x: Double, y: Double) /// Set mouse cursor visibility func setCursorVisible(_ visible: Bool) /// Set mouse cursor mode (normal, hidden, locked) func setCursorMode(_ mode: CursorMode) /// Get connected gamepad count func getGamepadCount() -> Int /// Check if a gamepad is connected func isGamepadConnected(_ gamepadId: Int) -> Bool /// Get gamepad name func getGamepadName(_ gamepadId: Int) -> String? /// Shutdown the input system func shutdown() async } /// Cursor display mode public enum CursorMode: Sendable { case normal case hidden case locked }