mirror of
https://github.com/mattrberry/crab.git
synced 2025-01-13 20:01:38 +01:00
rename event handlers
This commit is contained in:
parent
e02b31bcc7
commit
e4e5ebda3b
6 changed files with 13 additions and 15 deletions
|
@ -4,6 +4,6 @@ abstract class Emu
|
|||
|
||||
abstract def scheduler : Scheduler
|
||||
abstract def run_until_frame : Nil
|
||||
abstract def handle_event(event : SDL::Event) : Nil
|
||||
abstract def handle_controller_event(event : SDL::Event::JoyHat | SDL::Event::JoyButton) : Nil
|
||||
abstract def toggle_sync : Nil
|
||||
end
|
||||
|
|
|
@ -32,8 +32,8 @@ abstract class Controller
|
|||
emu.run_until_frame
|
||||
end
|
||||
|
||||
def handle_event(event : SDL::Event) : Nil
|
||||
emu.handle_event(event)
|
||||
def handle_controller_event(event : SDL::Event::JoyHat | SDL::Event::JoyButton) : Nil
|
||||
emu.handle_controller_event(event)
|
||||
end
|
||||
|
||||
def handle_input(input : Input, pressed : Bool) : Nil
|
||||
|
|
|
@ -19,7 +19,7 @@ class StubbedController < Controller
|
|||
def run_until_frame : Nil
|
||||
end
|
||||
|
||||
def handle_event(event : SDL::Event) : Nil
|
||||
def handle_controller_event(event : SDL::Event::JoyHat | SDL::Event::JoyButton) : Nil
|
||||
end
|
||||
|
||||
def handle_input(input : Input, pressed : Bool) : Nil
|
||||
|
|
|
@ -121,18 +121,16 @@ class SDLOpenGLImGuiFrontend < Frontend
|
|||
case event
|
||||
when SDL::Event::Quit then exit
|
||||
when SDL::Event::JoyHat,
|
||||
SDL::Event::JoyButton then @controller.handle_event(event)
|
||||
SDL::Event::JoyButton then @controller.handle_controller_event(event)
|
||||
when SDL::Event::Keyboard
|
||||
if @keybindings.wants_input?
|
||||
@keybindings.key_released(event.sym) unless event.pressed? # pass on key release
|
||||
else
|
||||
if event.sym == LibSDL::Keycode::TAB
|
||||
@controller.toggle_sync if event.pressed?
|
||||
elsif event.sym == LibSDL::Keycode::Q && event.mod.includes?(LibSDL::Keymod::LCTRL)
|
||||
exit
|
||||
elsif input = @keybindings[event.sym]?
|
||||
@controller.handle_input(input, event.pressed?)
|
||||
end
|
||||
elsif input = @keybindings[event.sym]?
|
||||
@controller.handle_input(input, event.pressed?)
|
||||
elsif event.sym == LibSDL::Keycode::TAB
|
||||
@controller.toggle_sync if event.pressed?
|
||||
elsif event.sym == LibSDL::Keycode::Q && event.mod.includes?(LibSDL::Keymod::LCTRL)
|
||||
exit
|
||||
end
|
||||
else nil
|
||||
end
|
||||
|
|
|
@ -58,7 +58,7 @@ module GB
|
|||
ppu.frame = false
|
||||
end
|
||||
|
||||
def handle_event(event : SDL::Event) : Nil
|
||||
def handle_controller_event(event : SDL::Event::JoyHat | SDL::Event::JoyButton) : Nil
|
||||
joypad.handle_joypad_event event
|
||||
end
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ module GBA
|
|||
ppu.frame = false
|
||||
end
|
||||
|
||||
def handle_event(event : SDL::Event) : Nil
|
||||
def handle_controller_event(event : SDL::Event::JoyHat | SDL::Event::JoyButton) : Nil
|
||||
keypad.handle_keypad_event event
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue