/*
* call-seq:
* enable_key_repeat( delay=:default, interval=:default )
*
* Enable key repeat, so that additional keyboard release and press
* events are automatically generated for as long as the key is held
* down. See also #disable_key_repeat.
*
* delay:: how many seconds to wait before starting to repeat.
* Default is 0.5 seconds. (Numeric or :default, optional)
*
* interval:: how many seconds to wait in between repetitions after
* the first one. Default is 0.03 seconds.
* (Numeric or :default, optional)
*
*/
VALUE rg_enable_key_repeat(int argc, VALUE *argv, VALUE module)
{
VALUE vdelay, vinterval;
rb_scan_args(argc, argv, "02", &vdelay, &vinterval);
int delay = rg_get_keyrepeat_value( vdelay,
SDL_DEFAULT_REPEAT_DELAY,
"delay" );
int interval = rg_get_keyrepeat_value( vinterval,
SDL_DEFAULT_REPEAT_INTERVAL,
"interval" );
int result = SDL_EnableKeyRepeat( delay, interval );
if (result != 0) {
rb_raise(eSDLError, "Could not enable key repeat: %s",
SDL_GetError());
}
return Qnil;
}