From a40686a87caafde7b40fcd0f7e59c4b641b975fb Mon Sep 17 00:00:00 2001 From: a dinosaur Date: Mon, 27 Jan 2025 01:21:30 +1100 Subject: [PATCH] Fix build errors against release SDL 3.2.0 ABI --- Sources/Voxelotl/Application.swift | 6 +++--- Sources/Voxelotl/Input/GameController.swift | 6 +++--- Sources/Voxelotl/Input/Keyboard.swift | 2 +- Sources/Voxelotl/Input/Mouse.swift | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Sources/Voxelotl/Application.swift b/Sources/Voxelotl/Application.swift index 3c57e72..1e1401f 100644 --- a/Sources/Voxelotl/Application.swift +++ b/Sources/Voxelotl/Application.swift @@ -132,7 +132,7 @@ public class Application { case SDLK_ESCAPE: return .exitSuccess default: - Keyboard.instance.keyDownEvent(scan: event.key.scancode, repeat: event.key.repeat != 0) + Keyboard.instance.keyDownEvent(scan: event.key.scancode, repeat: event.key.repeat) } return .running @@ -154,13 +154,13 @@ public class Application { return .running case SDL_EVENT_GAMEPAD_BUTTON_DOWN, SDL_EVENT_GAMEPAD_BUTTON_UP: GameController.instance.buttonEvent(id: event.gbutton.which, - btn: SDL_GamepadButton(Int32(event.gbutton.button)), state: event.gbutton.state) + btn: SDL_GamepadButton(Int32(event.gbutton.button)), state: event.gbutton.down) return .running case SDL_EVENT_MOUSE_BUTTON_DOWN, SDL_EVENT_MOUSE_BUTTON_UP: Mouse.instance.buttonEvent( btn: UInt32(event.button.button), - state: event.button.state) + state: event.button.down) return .running case SDL_EVENT_MOUSE_MOTION: Mouse.instance.motionEvent( diff --git a/Sources/Voxelotl/Input/GameController.swift b/Sources/Voxelotl/Input/GameController.swift index 65fddfd..94b6da5 100644 --- a/Sources/Voxelotl/Input/GameController.swift +++ b/Sources/Voxelotl/Input/GameController.swift @@ -92,7 +92,7 @@ public class GameController { //MARK: - Private private var _joyInstance: SDL_JoystickID, _sdlPad: OpaquePointer - private var _axes = [Int16](repeating: 0, count: Int(SDL_GAMEPAD_AXIS_MAX.rawValue)) + private var _axes = [Int16](repeating: 0, count: Int(SDL_GAMEPAD_AXIS_COUNT.rawValue)) private var _btnCur: Buttons = [], _btnPrv: Buttons = [] internal var instanceID: SDL_JoystickID { _joyInstance } @@ -167,8 +167,8 @@ public class GameController { } } - internal func buttonEvent(id: SDL_JoystickID, btn: SDL_GamepadButton, state: UInt8) { - _pads[id]?.buttonEvent(btn, state == SDL_PRESSED) + internal func buttonEvent(id: SDL_JoystickID, btn: SDL_GamepadButton, state: Bool) { + _pads[id]?.buttonEvent(btn, state) } internal func axisEvent(id: SDL_JoystickID, axis: SDL_GamepadAxis, value: Int16) { diff --git a/Sources/Voxelotl/Input/Keyboard.swift b/Sources/Voxelotl/Input/Keyboard.swift index 0d39882..0f188b6 100644 --- a/Sources/Voxelotl/Input/Keyboard.swift +++ b/Sources/Voxelotl/Input/Keyboard.swift @@ -38,7 +38,7 @@ public class Keyboard { private static let _PRESS: UInt8 = _DOWN | _IMPULSE private static let _RELEASE: UInt8 = _UP | _IMPULSE - private var _state = [UInt8](repeating: _UP, count: Int(SDL_NUM_SCANCODES.rawValue)) + private var _state = [UInt8](repeating: _UP, count: Int(SDL_SCANCODE_COUNT.rawValue)) internal func keyDownEvent(scan: SDL_Scancode, repeat rep: Bool) { var newState = Self._PRESS diff --git a/Sources/Voxelotl/Input/Mouse.swift b/Sources/Voxelotl/Input/Mouse.swift index b74b1a8..ccf391d 100644 --- a/Sources/Voxelotl/Input/Mouse.swift +++ b/Sources/Voxelotl/Input/Mouse.swift @@ -53,8 +53,8 @@ public class Mouse { private func getAbsolute() -> SIMD2 { self._abs * self._dpiScale } private func getDelta() -> SIMD2 { self._delta } - internal func buttonEvent(btn: UInt32, state: UInt8) { - if state == SDL_PRESSED { + internal func buttonEvent(btn: UInt32, state: Bool) { + if state { self._btns.formUnion(.init(rawValue: btn.buttonMask)) } else { self._btns.subtract(.init(rawValue: btn.buttonMask))