We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1538 - SDL_EnableKeyRepeat creates keyboard events
Summary: SDL_EnableKeyRepeat creates keyboard events
Status: RESOLVED ENDOFLIFE
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 1.2.14
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-05 12:56 UTC by Issa Gorissen
Modified: 2015-08-25 09:38 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Issa Gorissen 2012-07-05 12:56:20 UTC
Hi,

I'm describing a problem of events occurring in XBMC 11.0 and SDL 1.2.14 on a openSuse 12.1 64 bits. the input device is a MCE usb remote.

The problem I am having is that if I push the same button on the remote quickly, two times, the key event representing the button will occur more than two times in XBMC.

So, to narrow down the problem, I tested the following piece of code coming from SDL web site. The problem was the same as in XBMC.

XBMC calls SDL_EnableKeyRepeat method with a repeat of 10.
During my test, a value of 500 was running without a problem.

Could you look into this please ?

Thx
--
Issa

#include <SDL/SDL.h>

main(int argc, char *argv[])
{
    int quit = 0;
    int count = 0;
    SDL_Event event;

    if (SDL_Init(SDL_INIT_VIDEO) < 0 ) {
        fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
        exit(1);
    }

    if (!SDL_SetVideoMode(320, 200, 0, 0)) {
        fprintf(stderr, "Could not set video mode: %s\n", SDL_GetError());
        SDL_Quit();
        exit(1);
    }

    atexit(SDL_Quit);
    SDL_EnableUNICODE(1);
    SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 500);

    while (!quit) {
/*        if (SDL_WaitEvent(&event) < 1) {
            fprintf(stderr, "WaitEvent error: %s\n", SDL_GetError());
            exit(1);
        }
*/
        if (SDL_PollEvent(&event) < 1) {
            continue;
        }

        switch (event.type) {
        case SDL_KEYDOWN:
            printf("Key pressed:\n");
            printf("    state: %i\n", event.key.state);
            printf("    SDL sim: %i\n", event.key.keysym.sym);
            printf("    modifiers: %i\n", event.key.keysym.mod);
            printf("    unicode: %i (if enabled with SDL_EnableUNICODE)\n", event.key.keysym.unicode);

        break;

        case SDL_KEYUP:
            printf("Key released:\n");
            printf("    state: %i\n", event.key.state);
            printf("    SDL sim: %i\n", event.key.keysym.sym);
            printf("    modifiers: %i\n", event.key.keysym.mod);
            printf("    unicode: %i (if enabled with SDL_EnableUNICODE)\n", event.key.keysym.unicode);
        break;

        case SDL_QUIT:
            printf("Request to quit\n");
            quit = 1;
        break;

        case SDL_USEREVENT:
            printf("User event:\n");
            printf("    code:  %i\n", event.user.code);
            printf("    data1: %p\n", event.user.data1);
            printf("    data2: %p\n", event.user.data2);
        break;
        }

        printf("%i\n", ++count);
    }
}
Comment 1 Ryan C. Gordon 2015-08-25 09:38:23 UTC
Hello, and sorry if you're getting several copies of this message by email, since we are closing many bugs at once here.

We have decided to mark all SDL 1.2-related bugs as RESOLVED ENDOFLIFE, as we don't intend to work on SDL 1.2 any further, but didn't want to mark a large quantity of bugs as RESOLVED WONTFIX, to clearly show what was left unattended to and make it easily searchable.

Our current focus is on SDL 2.0.

If you are still having problems with an ENDOFLIFE bug, your absolute best option is to move your program to SDL2, as it will likely fix the problem by default, and give you access to modern platforms and tons of super-cool new features.

Failing that, we _will_ accept small patches to fix these issues, and put them in revision control, although we do not intend to do any further official 1.2 releases.

Failing that, please feel free to contact me directly by email (icculus@icculus.org) and we'll try to find some way to help you out of your situation.

Thank you,
--ryan.