mirror of
https://github.com/SleepingInsomniac/pixelfaucet
synced 2024-11-16 07:47:36 +01:00
Update constants
This commit is contained in:
parent
bc416fa310
commit
5694e1380e
1 changed files with 5 additions and 4 deletions
|
@ -2,6 +2,7 @@ require "./lib_sdl"
|
|||
|
||||
module PF
|
||||
alias Keys = LibSDL::Scancode
|
||||
alias KeyCodes = LibSDL::Keycode
|
||||
|
||||
# Handle button to action mapping in a dynamic way
|
||||
class Controller(T)
|
||||
|
@ -17,9 +18,9 @@ module PF
|
|||
def self.detect_layout
|
||||
keys = String.build do |io|
|
||||
{
|
||||
LibSDL::Keycode::Q,
|
||||
LibSDL::Keycode::W,
|
||||
LibSDL::Keycode::Y,
|
||||
KeyCodes::Q,
|
||||
KeyCodes::W,
|
||||
KeyCodes::Y,
|
||||
}.each do |key_code|
|
||||
scan_code = LibSDL.get_scancode_from_key(key_code)
|
||||
key_name = LibSDL.get_scancode_name(scan_code)
|
||||
|
@ -48,7 +49,7 @@ module PF
|
|||
# Map
|
||||
def map_event(event : SDL::Event?)
|
||||
case event
|
||||
when SDL::Event::Keyboard
|
||||
when Event::Keyboard
|
||||
{% if T == LibSDL::Scancode %}
|
||||
press(event.scancode) if event.keydown?
|
||||
release(event.scancode) if event.keyup?
|
||||
|
|
Loading…
Reference in a new issue