-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathsdl-events.h
More file actions
135 lines (110 loc) · 3.14 KB
/
Copy pathsdl-events.h
File metadata and controls
135 lines (110 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* Copyright (c) 2013-2014 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef SDL_EVENTS_H
#define SDL_EVENTS_H
#include <mgba-util/common.h>
CXX_GUARD_START
#include <mgba/core/interface.h>
#include <mgba/core/log.h>
#include <mgba-util/circle-buffer.h>
#include <mgba-util/vector.h>
#include <SDL.h>
// Altivec sometimes defines this
#ifdef vector
#undef vector
#endif
#ifdef bool
#undef bool
#define bool _Bool
#endif
mLOG_DECLARE_CATEGORY(SDL_EVENTS);
// SDL_BINDING_KEYCODE: Bindings for SDL_Keysym.sim (SDL < 2.0).
#define SDL_BINDING_KEYCODE 0x53444C4BU
// SDL_BINDING_SCANCODE: Bindings for SDL_Keysym.scancode (SDL >= 2.0).
#define SDL_BINDING_SCANCODE 0x53444C53U
#define SDL_BINDING_BUTTON 0x53444C42U
#define MAX_PLAYERS 4
struct Configuration;
struct SDL_JoystickCombo {
size_t index;
SDL_Joystick* joystick;
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_GameController* controller;
SDL_Haptic* haptic;
SDL_JoystickID id;
#else
int id;
#endif
};
DECLARE_VECTOR(SDL_JoystickList, struct SDL_JoystickCombo);
struct mSDLPlayer;
struct mSDLEvents {
struct SDL_JoystickList joysticks;
const char* preferredJoysticks[MAX_PLAYERS];
int playersAttached;
struct mSDLPlayer* players[MAX_PLAYERS];
#if SDL_VERSION_ATLEAST(2, 0, 0)
int screensaverSuspendDepth;
bool screensaverSuspendable;
#endif
};
struct mSDLPlayer {
size_t playerId;
struct mInputMap* bindings;
struct SDL_JoystickCombo* joystick;
int fullscreen;
int windowUpdated;
#if SDL_VERSION_ATLEAST(2, 0, 0)
SDL_Window* window;
struct mSDLRumble {
struct mRumble d;
struct mSDLPlayer* p;
int level;
float activeLevel;
struct CircleBuffer history;
} rumble;
#else
int newWidth;
int newHeight;
#endif
struct mSDLRotation {
struct mRotationSource d;
struct mSDLPlayer* p;
// Tilt
int axisX;
int axisY;
float accelX;
float accelY;
// Gyro
int gyroX;
int gyroY;
int gyroZ;
float gyroSensitivity;
struct CircleBuffer zHistory;
int oldX;
int oldY;
float zDelta;
} rotation;
};
bool mSDLInitEvents(struct mSDLEvents*);
void mSDLDeinitEvents(struct mSDLEvents*);
bool mSDLAttachPlayer(struct mSDLEvents*, struct mSDLPlayer*);
void mSDLDetachPlayer(struct mSDLEvents*, struct mSDLPlayer*);
void mSDLEventsLoadConfig(struct mSDLEvents*, const struct Configuration*);
void mSDLPlayerChangeJoystick(struct mSDLEvents*, struct mSDLPlayer*, size_t index);
void mSDLUpdateJoysticks(struct mSDLEvents* events, const struct Configuration*);
void mSDLPlayerLoadConfig(struct mSDLPlayer*, const struct Configuration*);
void mSDLPlayerSaveConfig(const struct mSDLPlayer*, struct Configuration*);
void mSDLInitBindingsGBA(struct mInputMap* inputMap);
struct mCoreThread;
void mSDLHandleEvent(struct mCoreThread* context, struct mSDLPlayer* sdlContext, const union SDL_Event* event);
#if SDL_VERSION_ATLEAST(2, 0, 0)
void mSDLSuspendScreensaver(struct mSDLEvents*);
void mSDLResumeScreensaver(struct mSDLEvents*);
void mSDLSetScreensaverSuspendable(struct mSDLEvents*, bool suspendable);
#endif
CXX_GUARD_END
#endif