SteelGolem icon

keeping a keyboard double buffer in SDL

SteelGolem | PRO | 01/18/18 04:08:14 PM UTC | 0 ⭐ | 423 👁️ | Never ⏰ | []
C |

340 B

|

None

|

0 👍

/

0 👎

// start of Update ()
        keyboard = SDL_GetKeyboardState (&numKeys);
        if (numKeys > lastNumKeys)
        {
            if (lastKeyboard) free ((void *) lastKeyboard);
            lastKeyboard = (Uint8 *) malloc (numKeys * sizeof (Uint8));
        }
 
// end of Update ()
        memcpy ((void *) lastKeyboard, (void *) keyboard, numKeys * sizeof (Uint8));
        lastNumKeys = numKeys;

Comments