SDL: Load SDLK and SDLB input maps

This commit is contained in:
Jeffrey Pfau 2014-11-03 23:28:33 -08:00
parent 3e75a8e3fe
commit 629196e7a1
3 changed files with 10 additions and 0 deletions

View File

@ -119,6 +119,7 @@ int main(int argc, char** argv) {
renderer.events.bindings = &context.inputMap; renderer.events.bindings = &context.inputMap;
GBASDLInitEvents(&renderer.events); GBASDLInitEvents(&renderer.events);
GBASDLEventsLoadConfig(&renderer.events, &config);
GBAThreadStart(&context); GBAThreadStart(&context);

View File

@ -45,9 +45,15 @@ bool GBASDLInitEvents(struct GBASDLEvents* context) {
GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 6, GBA_KEY_DOWN); GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 6, GBA_KEY_DOWN);
GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 7, GBA_KEY_LEFT); GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 7, GBA_KEY_LEFT);
GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 5, GBA_KEY_RIGHT); GBAInputBindKey(context->bindings, SDL_BINDING_BUTTON, 5, GBA_KEY_RIGHT);
return true; return true;
} }
void GBASDLEventsLoadConfig(struct GBASDLEvents* context, const struct Configuration* config) {
GBAInputMapLoad(context->bindings, SDL_BINDING_KEY, config);
GBAInputMapLoad(context->bindings, SDL_BINDING_BUTTON, config);
}
void GBASDLDeinitEvents(struct GBASDLEvents* context) { void GBASDLDeinitEvents(struct GBASDLEvents* context) {
SDL_JoystickClose(context->joystick); SDL_JoystickClose(context->joystick);
SDL_QuitSubSystem(SDL_INIT_JOYSTICK); SDL_QuitSubSystem(SDL_INIT_JOYSTICK);

View File

@ -11,6 +11,7 @@
#define SDL_BINDING_BUTTON 0x53444C42 #define SDL_BINDING_BUTTON 0x53444C42
struct GBAVideoSoftwareRenderer; struct GBAVideoSoftwareRenderer;
struct Configuration;
struct GBASDLEvents { struct GBASDLEvents {
struct GBAInputMap* bindings; struct GBAInputMap* bindings;
@ -25,6 +26,8 @@ struct GBASDLEvents {
bool GBASDLInitEvents(struct GBASDLEvents*); bool GBASDLInitEvents(struct GBASDLEvents*);
void GBASDLDeinitEvents(struct GBASDLEvents*); void GBASDLDeinitEvents(struct GBASDLEvents*);
void GBASDLEventsLoadConfig(struct GBASDLEvents*, const struct Configuration*);
void GBASDLHandleEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const union SDL_Event* event); void GBASDLHandleEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const union SDL_Event* event);
#endif #endif