Module: SDL::Key

Defined in:
ext/sdl/sdl.c

Class Method Summary collapse

Class Method Details

.press?(keycode_) ⇒ Boolean

// SDL::Key methods:

Returns:

  • (Boolean)


314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# File 'ext/sdl/sdl.c', line 314

static VALUE Key_s_press_p(VALUE mod, VALUE keycode_) {
  UNUSED(mod);

  if (!key_state)
    rb_raise(eSDLError,
             "You should call SDL::Key#scan before calling SDL::Key#press?");

  SDL_Keycode keycode   = NUM2INT(keycode_);
  SDL_Scancode scancode = SDL_GetScancodeFromKey(keycode);

  if (0 >= scancode || scancode >= key_state_len)
    rb_raise(eSDLError, "%d (%d) is out of bounds: %d",
             keycode, scancode, key_state_len);

  return INT2BOOL(key_state[scancode]);
}

.scanObject



331
332
333
334
335
336
337
338
# File 'ext/sdl/sdl.c', line 331

static VALUE Key_s_scan(VALUE mod) {
  UNUSED(mod);

  key_state = (Uint8 *) SDL_GetKeyboardState(&key_state_len);
  mod_state = SDL_GetModState();

  return Qnil;
}