Module: DXRubySDL::Input
- Defined in:
- lib/dxruby_sdl/input.rb
Class Method Summary collapse
- .key_down?(key_code) ⇒ Boolean (also: keyDown?)
- .key_push?(key_code) ⇒ Boolean (also: keyPush?)
- .keys ⇒ Object
- .mouse_down?(button) ⇒ Boolean (also: mouseDown?)
- .mouse_pos_x ⇒ Object (also: mousePosX)
- .mouse_pos_y ⇒ Object (also: mousePosY)
- .mouse_push?(button) ⇒ Boolean (also: mousePush?)
- .pad_down?(button_code, pad_number = 0) ⇒ Boolean (also: padDown?)
- .pad_push?(button_code, pad_number = 0) ⇒ Boolean (also: padPush?)
- .set_repeat(wait, interval) ⇒ Object (also: setRepeat)
- .x(pad_number = 0) ⇒ Object
- .y(pad_number = 0) ⇒ Object
Class Method Details
.key_down?(key_code) ⇒ Boolean Also known as: keyDown?
71 72 73 |
# File 'lib/dxruby_sdl/input.rb', line 71 def key_down?(key_code) return sdl_key_press?(to_sdl_key(key_code)) end |
.key_push?(key_code) ⇒ Boolean Also known as: keyPush?
75 76 77 |
# File 'lib/dxruby_sdl/input.rb', line 75 def key_push?(key_code) return sdl_key_push?(to_sdl_key(key_code)) end |
.keys ⇒ Object
103 104 105 |
# File 'lib/dxruby_sdl/input.rb', line 103 def keys return @keys end |
.mouse_down?(button) ⇒ Boolean Also known as: mouseDown?
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/dxruby_sdl/input.rb', line 79 def mouse_down?() case when M_LBUTTON index = 2 when M_MBUTTON index = 3 when M_RBUTTON index = 4 end return SDL::Mouse.state[index] end |
.mouse_pos_x ⇒ Object Also known as: mousePosX
63 64 65 |
# File 'lib/dxruby_sdl/input.rb', line 63 def mouse_pos_x return SDL::Mouse.state[0] end |
.mouse_pos_y ⇒ Object Also known as: mousePosY
67 68 69 |
# File 'lib/dxruby_sdl/input.rb', line 67 def mouse_pos_y return SDL::Mouse.state[1] end |
.mouse_push?(button) ⇒ Boolean Also known as: mousePush?
91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/dxruby_sdl/input.rb', line 91 def mouse_push?() case when M_LBUTTON index = 2 when M_MBUTTON index = 3 when M_RBUTTON index = 4 end return SDL::Mouse.state[index] && !@last_mouse_state[index] end |
.pad_down?(button_code, pad_number = 0) ⇒ Boolean Also known as: padDown?
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/dxruby_sdl/input.rb', line 35 def pad_down?(, pad_number = 0) if == P_BUTTON0 && sdl_key_press?(SDL::Key::Z) || == P_BUTTON1 && sdl_key_press?(SDL::Key::X) || == P_BUTTON2 && sdl_key_press?(SDL::Key::C) || == P_LEFT && sdl_key_press?(SDL::Key::LEFT) || == P_RIGHT && sdl_key_press?(SDL::Key::RIGHT) || == P_UP && sdl_key_press?(SDL::Key::UP) || == P_DOWN && sdl_key_press?(SDL::Key::DOWN) || ((j = joystick(pad_number)) && j.()) return true end return false end |
.pad_push?(button_code, pad_number = 0) ⇒ Boolean Also known as: padPush?
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dxruby_sdl/input.rb', line 49 def pad_push?(, pad_number = 0) if == P_BUTTON0 && sdl_key_push?(SDL::Key::Z) || == P_BUTTON1 && sdl_key_push?(SDL::Key::X) || == P_BUTTON2 && sdl_key_push?(SDL::Key::C) || == P_LEFT && sdl_key_push?(SDL::Key::LEFT) || == P_RIGHT && sdl_key_push?(SDL::Key::RIGHT) || == P_UP && sdl_key_push?(SDL::Key::UP) || == P_DOWN && sdl_key_push?(SDL::Key::DOWN) || ((j = joystick(pad_number)) && j.()) return true end return false end |
.set_repeat(wait, interval) ⇒ Object Also known as: setRepeat
9 10 11 |
# File 'lib/dxruby_sdl/input.rb', line 9 def set_repeat(wait, interval) SDL::Key.enable_key_repeat(wait, interval) end |
.x(pad_number = 0) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dxruby_sdl/input.rb', line 13 def x(pad_number = 0) res = 0 if sdl_key_press?(SDL::Key::LEFT) res -= 1 end if sdl_key_press?(SDL::Key::RIGHT) res += 1 end return res end |
.y(pad_number = 0) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dxruby_sdl/input.rb', line 24 def y(pad_number = 0) res = 0 if sdl_key_press?(SDL::Key::UP) res -= 1 end if sdl_key_press?(SDL::Key::DOWN) res += 1 end return res end |