Class: Input
- Inherits:
-
AkaneSound
- Object
- AkaneSound
- Input
- Defined in:
- lib/akane_sound/class.input.rb
Instance Attribute Summary collapse
-
#accept ⇒ Object
Returns the value of attribute accept.
-
#any_key ⇒ Object
Returns the value of attribute any_key.
-
#append ⇒ Object
Returns the value of attribute append.
-
#append_r ⇒ Object
Returns the value of attribute append_r.
-
#clear ⇒ Object
Returns the value of attribute clear.
-
#cmd ⇒ Object
Returns the value of attribute cmd.
-
#down ⇒ Object
Returns the value of attribute down.
-
#first ⇒ Object
Returns the value of attribute first.
-
#last ⇒ Object
Returns the value of attribute last.
-
#next ⇒ Object
Returns the value of attribute next.
-
#pagedown ⇒ Object
Returns the value of attribute pagedown.
-
#pageup ⇒ Object
Returns the value of attribute pageup.
-
#pause ⇒ Object
Returns the value of attribute pause.
-
#prev ⇒ Object
Returns the value of attribute prev.
-
#quit ⇒ Object
Returns the value of attribute quit.
-
#refresh ⇒ Object
Returns the value of attribute refresh.
-
#stop ⇒ Object
Returns the value of attribute stop.
-
#switch ⇒ Object
Returns the value of attribute switch.
-
#toggle_mute ⇒ Object
Returns the value of attribute toggle_mute.
-
#toggle_next ⇒ Object
Returns the value of attribute toggle_next.
-
#toggle_repeat ⇒ Object
Returns the value of attribute toggle_repeat.
-
#toggle_shuffle ⇒ Object
Returns the value of attribute toggle_shuffle.
-
#up ⇒ Object
Returns the value of attribute up.
-
#vol_down ⇒ Object
Returns the value of attribute vol_down.
-
#vol_up ⇒ Object
Returns the value of attribute vol_up.
-
#write ⇒ Object
Returns the value of attribute write.
Instance Method Summary collapse
- #handle_event(event) ⇒ Object
-
#initialize ⇒ Input
constructor
A new instance of Input.
- #set_state ⇒ Object
Methods inherited from AkaneSound
Constructor Details
#initialize ⇒ Input
Returns a new instance of Input.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/akane_sound/class.input.rb', line 6 def initialize @tmp_up, @up = 0 @tmp_down, @down = 0 @tmp_last, @last = 0 @tmp_first, @first = 0 @tmp_pageup, @pageup = 0 @tmp_pagedown, @pagedown = 0 @tmp_quit, @quit = 0 @tmp_accept, @accept = 0 @tmp_clear, @clear = 0 @tmp_toggle_shuffle, @toggle_shuffle = 0 @tmp_toggle_repeat, @toggle_repeat = 0 @tmp_toggle_next, @toggle_next = 0 @tmp_toggle_mute, @toggle_mute = 0 @tmp_vol_up, @vol_up = 0 @tmp_vol_down, @vol_down = 0 @tmp_stop, @stop = 0 @tmp_pause, @pause = 0 @tmp_next, @next = 0 @tmp_prev, @prev = 0 @tmp_append, @append = 0 @tmp_append_r, @append_r = 0 @tmp_refresh, @refresh = 0 @tmp_cmd, @cmd = 0 @tmp_switch, @switch = 0 @tmp_write, @write = 0 @tmp_any_key, @any_key = 0 end |
Instance Attribute Details
#accept ⇒ Object
Returns the value of attribute accept.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def accept @accept end |
#any_key ⇒ Object
Returns the value of attribute any_key.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def any_key @any_key end |
#append ⇒ Object
Returns the value of attribute append.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def append @append end |
#append_r ⇒ Object
Returns the value of attribute append_r.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def append_r @append_r end |
#clear ⇒ Object
Returns the value of attribute clear.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def clear @clear end |
#cmd ⇒ Object
Returns the value of attribute cmd.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def cmd @cmd end |
#down ⇒ Object
Returns the value of attribute down.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def down @down end |
#first ⇒ Object
Returns the value of attribute first.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def first @first end |
#last ⇒ Object
Returns the value of attribute last.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def last @last end |
#next ⇒ Object
Returns the value of attribute next.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def next @next end |
#pagedown ⇒ Object
Returns the value of attribute pagedown.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def pagedown @pagedown end |
#pageup ⇒ Object
Returns the value of attribute pageup.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def pageup @pageup end |
#pause ⇒ Object
Returns the value of attribute pause.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def pause @pause end |
#prev ⇒ Object
Returns the value of attribute prev.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def prev @prev end |
#quit ⇒ Object
Returns the value of attribute quit.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def quit @quit end |
#refresh ⇒ Object
Returns the value of attribute refresh.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def refresh @refresh end |
#stop ⇒ Object
Returns the value of attribute stop.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def stop @stop end |
#switch ⇒ Object
Returns the value of attribute switch.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def switch @switch end |
#toggle_mute ⇒ Object
Returns the value of attribute toggle_mute.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def toggle_mute @toggle_mute end |
#toggle_next ⇒ Object
Returns the value of attribute toggle_next.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def toggle_next @toggle_next end |
#toggle_repeat ⇒ Object
Returns the value of attribute toggle_repeat.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def toggle_repeat @toggle_repeat end |
#toggle_shuffle ⇒ Object
Returns the value of attribute toggle_shuffle.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def toggle_shuffle @toggle_shuffle end |
#up ⇒ Object
Returns the value of attribute up.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def up @up end |
#vol_down ⇒ Object
Returns the value of attribute vol_down.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def vol_down @vol_down end |
#vol_up ⇒ Object
Returns the value of attribute vol_up.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def vol_up @vol_up end |
#write ⇒ Object
Returns the value of attribute write.
2 3 4 |
# File 'lib/akane_sound/class.input.rb', line 2 def write @write end |
Instance Method Details
#handle_event(event) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/akane_sound/class.input.rb', line 35 def handle_event(event) case event when SDL2::Event::Quit @quit = 1 when SDL2::Event::KeyDown @tmp_any_key = 1 if event.sym == SDL2::Key::TAB @tmp_switch = 1 end if event.sym == SDL2::Key::ESCAPE @tmp_quit = 1 end if event.sym == SDL2::Key::RETURN @tmp_accept = 1 end if event.sym == SDL2::Key::SPACE @tmp_pause = 1 end if event.sym == SDL2::Key::J @tmp_down = 1 end if event.sym == SDL2::Key::K @tmp_up = 1 end if event.sym == SDL2::Key::W @tmp_write = 1 end if event.sym == SDL2::Key::PAGEDOWN @tmp_pagedown = 1 end if event.sym == SDL2::Key::PAGEUP @tmp_pageup = 1 end if event.sym == SDL2::Key::P @tmp_prev = 1 end if event.sym == SDL2::Key::G if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_last = 1 else @tmp_first = 1 end end if event.sym == SDL2::Key::S if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_toggle_shuffle = 1 else @tmp_stop = 1 end end if event.sym == SDL2::Key::N if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_toggle_next = 1 else @tmp_next = 1 end end if event.sym == SDL2::Key::R if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_toggle_repeat = 1 else @tmp_refresh = 1 end end if event.sym == SDL2::Key::A if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_append_r = 1 else @tmp_append = 1 end end if event.sym == SDL2::Key::C if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_clear = 1 end end if event.sym == SDL2::Key::PERIOD if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_vol_up = 1 end end if event.sym == SDL2::Key::VOLUMEUP if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_vol_up = 1 end end if event.sym == SDL2::Key::COMMA if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_vol_down = 1 end end if event.sym == SDL2::Key::SEMICOLON if event.mod.bit?(SDL2::Key::Mod::SHIFT) @tmp_cmd = 1 end end when SDL2::Event::KeyUp @tmp_any_key = 0 if event.sym == SDL2::Key::TAB @tmp_switch = 0 end if event.sym == SDL2::Key::ESCAPE @tmp_quit = 0 end if event.sym == SDL2::Key::RETURN @tmp_accept = 0 end if event.sym == SDL2::Key::SPACE @tmp_pause = 0 end if event.sym == SDL2::Key::J @tmp_down = 0 end if event.sym == SDL2::Key::K @tmp_up = 0 end if event.sym == SDL2::Key::W @tmp_write = 0 end if event.sym == SDL2::Key::PAGEDOWN @tmp_pagedown = 0 end if event.sym == SDL2::Key::P @tmp_prev = 0 end if event.sym == SDL2::Key::PAGEUP @tmp_pageup = 0 end if event.sym == SDL2::Key::G @tmp_last = 0 @tmp_first = 0 end if event.sym == SDL2::Key::S @tmp_toggle_shuffle = 0 @tmp_stop = 0 end if event.sym == SDL2::Key::N @tmp_toggle_next = 0 @tmp_next = 0 end if event.sym == SDL2::Key::R @tmp_toggle_repeat = 0 @tmp_refresh = 0 end if event.sym == SDL2::Key::A @tmp_append = 0 @tmp_append_r = 0 end if event.sym == SDL2::Key::C @tmp_clear = 0 end if event.sym == SDL2::Key::PERIOD @tmp_vol_up = 0 end if event.sym == SDL2::Key::VOLUMEUP @tmp_vol_up = 0 end if event.sym == SDL2::Key::COMMA @tmp_vol_down = 0 end if event.sym == SDL2::Key::SEMICOLON @tmp_cmd = 0 end end end |
#set_state ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/akane_sound/class.input.rb', line 223 def set_state if @tmp_any_key == 1 @any_key += 1 else @any_key = 0 end if @tmp_switch == 1 @switch += 1 else @switch = 0 end if @tmp_quit == 1 @quit += 1 else @quit = 0 end if @tmp_write == 1 @write += 1 else @write = 0 end if @tmp_up == 1 @up += 1 else @up = 0 end if @tmp_down == 1 @down += 1 else @down = 0 end if @tmp_last == 1 @last += 1 else @last = 0 end if @tmp_first == 1 @first += 1 else @first = 0 end if @tmp_pageup == 1 @pageup += 1 else @pageup = 0 end if @tmp_pagedown == 1 @pagedown += 1 else @pagedown = 0 end if @tmp_accept == 1 @accept += 1 else @accept = 0 end if @tmp_pause == 1 @pause += 1 else @pause = 0 end if @tmp_stop == 1 @stop += 1 else @stop = 0 end if @tmp_toggle_shuffle == 1 @toggle_shuffle += 1 else @toggle_shuffle = 0 end if @tmp_toggle_repeat == 1 @toggle_repeat += 1 else @toggle_repeat = 0 end if @tmp_toggle_next == 1 @toggle_next += 1 else @toggle_next = 0 end if @tmp_toggle_mute == 1 @toggle_mute += 1 else @toggle_mute = 0 end if @tmp_vol_up == 1 @vol_up += 1 else @vol_up = 0 end if @tmp_vol_down == 1 @vol_down += 1 else @vol_down = 0 end if @tmp_next == 1 @next += 1 else @next = 0 end if @tmp_prev == 1 @prev += 1 else @prev = 0 end if @tmp_append == 1 @append += 1 else @append = 0 end if @tmp_clear == 1 @clear += 1 else @clear = 0 end if @tmp_append_r == 1 @append_r += 1 else @append_r = 0 end if @tmp_refresh == 1 @refresh += 1 else @refresh = 0 end if @tmp_cmd == 1 @cmd += 1 else @cmd = 0 end end |