comparison src/events/SDL_keyboard.c @ 122:8f33e95b43b6

Don't worry about a minimum repeat rate - let the user hang themselves...
author Sam Lantinga <slouken@libsdl.org>
date Mon, 23 Jul 2001 04:34:52 +0000
parents c3e9d4a623c1
children 3142d2ac11db
comparison
equal deleted inserted replaced
121:43febd46d49d 122:8f33e95b43b6
47 static char *keynames[SDLK_LAST]; /* Array of keycode names */ 47 static char *keynames[SDLK_LAST]; /* Array of keycode names */
48 48
49 /* 49 /*
50 * jk 991215 - added 50 * jk 991215 - added
51 */ 51 */
52 #define MINIMUM_REPEAT_INTERVAL 30 /* Minimum repeat interval (30 ms) */
53 struct { 52 struct {
54 int firsttime; /* if we check against the delay or repeat value */ 53 int firsttime; /* if we check against the delay or repeat value */
55 int delay; /* the delay before we start repeating */ 54 int delay; /* the delay before we start repeating */
56 int interval; /* the delay between key repeat events */ 55 int interval; /* the delay between key repeat events */
57 Uint32 timestamp; /* the time the first keydown event occurred */ 56 Uint32 timestamp; /* the time the first keydown event occurred */
554 } 553 }
555 } 554 }
556 555
557 int SDL_EnableKeyRepeat(int delay, int interval) 556 int SDL_EnableKeyRepeat(int delay, int interval)
558 { 557 {
559 if ( delay < 0 ) { 558 if ( (delay < 0) || (interval < 0) ) {
560 SDL_SetError("keyboard repeat delay less than zero"); 559 SDL_SetError("keyboard repeat value less than zero");
561 return(-1); 560 return(-1);
562 } 561 }
563 SDL_KeyRepeat.firsttime = 0; 562 SDL_KeyRepeat.firsttime = 0;
564 SDL_KeyRepeat.delay = delay; 563 SDL_KeyRepeat.delay = delay;
565 if ( interval < MINIMUM_REPEAT_INTERVAL ) { 564 SDL_KeyRepeat.interval = interval;
566 SDL_KeyRepeat.interval = MINIMUM_REPEAT_INTERVAL;
567 } else {
568 SDL_KeyRepeat.interval = interval;
569 }
570 SDL_KeyRepeat.timestamp = 0; 565 SDL_KeyRepeat.timestamp = 0;
571 return(0); 566 return(0);
572 } 567 }
573 568