all repos — mgba @ afae3c8b807577123c93f32f1145422fc55500af

mGBA Game Boy Advance Emulator

src/platform/sdl/sdl-events.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef SDL_EVENTS_H
 7#define SDL_EVENTS_H
 8
 9#include "util/common.h"
10
11#include "gba/supervisor/thread.h"
12
13#include <SDL.h>
14
15#define SDL_BINDING_KEY 0x53444C4BU
16#define SDL_BINDING_BUTTON 0x53444C42U
17
18#define MAX_PLAYERS 4
19
20struct GBAVideoSoftwareRenderer;
21struct Configuration;
22
23struct GBASDLEvents {
24	SDL_Joystick** joysticks;
25	size_t nJoysticks;
26	const char* preferredJoysticks[MAX_PLAYERS];
27	int playersAttached;
28	size_t joysticksClaimed[MAX_PLAYERS];
29};
30
31struct GBASDLPlayer {
32	size_t playerId;
33	struct GBAInputMap* bindings;
34	SDL_Joystick* joystick;
35	size_t joystickIndex;
36#if SDL_VERSION_ATLEAST(2, 0, 0)
37	SDL_Window* window;
38	int fullscreen;
39	int windowUpdated;
40#endif
41};
42
43bool GBASDLInitEvents(struct GBASDLEvents*);
44void GBASDLDeinitEvents(struct GBASDLEvents*);
45
46bool GBASDLAttachPlayer(struct GBASDLEvents*, struct GBASDLPlayer*);
47void GBASDLEventsLoadConfig(struct GBASDLEvents*, const struct Configuration*);
48void GBASDLPlayerChangeJoystick(struct GBASDLEvents*, struct GBASDLPlayer*, size_t index);
49
50void GBASDLInitBindings(struct GBAInputMap* inputMap);
51void GBASDLPlayerLoadConfig(struct GBASDLPlayer*, const struct Configuration*);
52
53void GBASDLHandleEvent(struct GBAThread* context, struct GBASDLPlayer* sdlContext, const union SDL_Event* event);
54
55#endif