mirror of
https://github.com/GayPizzaSpecifications/voxelotl-engine.git
synced 2025-08-03 05:10:57 +00:00
add mouse support
This commit is contained in:
@ -71,6 +71,7 @@ public class Application {
|
||||
private func beginHandleEvents() {
|
||||
Keyboard.instance.newFrame()
|
||||
GameController.instance.newFrame()
|
||||
Mouse.instance.newFrame(window!)
|
||||
}
|
||||
|
||||
private func handleEvent(_ event: SDL_Event) -> ApplicationExecutionState {
|
||||
@ -108,6 +109,17 @@ public class Application {
|
||||
btn: SDL_GamepadButton(Int32(event.gbutton.button)), state: event.gbutton.state)
|
||||
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)
|
||||
return .running
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
Mouse.instance.motionEvent(
|
||||
absolute: SIMD2(event.motion.x, event.motion.y),
|
||||
relative: SIMD2(event.motion.xrel, event.motion.yrel))
|
||||
return .running
|
||||
|
||||
case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED:
|
||||
let backBufferSize = Size(Int(event.window.data1), Int(event.window.data2))
|
||||
self.renderer!.resize(size: backBufferSize)
|
||||
|
Reference in New Issue
Block a user