I am in the process of making a simple 2D game, with SDL. I am trying to hide the SDL subsystems from the program, and only #include them in the .c files. I was able to hide the graphics part of SDL, but now I am not sure how to hide the SDL event system. The SDL event system has hundreds of constants named SDLK_<key>, but I'd like to assign those constants to KEY_<key> instead. Right now i have something like this:
#ifndef EVENT_HHH #define EVENT_HHH extern int const KEY_A; extern int const KEY_B; /*....*/ extern int const KEY_SPACE; #endif
and in event.c:
#include "event.h" #include <SDL/SDL.h> int const KEY_A = SDLK_a; int const KEY_B = SDLK_b; /*.../* int const KEY_SPACE = SDLK_SPACE;
Since there are hundreds of these constants, it feels like it's very easy to make errors if i just assign them one by one.
My question is, is there a shorter and better way to do this?