Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-1-2-2013-Decompilation
Path: blob/main/RSDKv4/Input.hpp
817 views
1
#ifndef INPUT_H
2
#define INPUT_H
3
4
enum InputButtons {
5
INPUT_UP,
6
INPUT_DOWN,
7
INPUT_LEFT,
8
INPUT_RIGHT,
9
INPUT_BUTTONA,
10
INPUT_BUTTONB,
11
INPUT_BUTTONC,
12
INPUT_BUTTONX,
13
INPUT_BUTTONY,
14
INPUT_BUTTONZ,
15
INPUT_BUTTONL,
16
INPUT_BUTTONR,
17
INPUT_START,
18
INPUT_SELECT,
19
INPUT_ANY,
20
INPUT_BUTTONCOUNT,
21
};
22
23
struct InputData {
24
bool up;
25
bool down;
26
bool left;
27
bool right;
28
bool A;
29
bool B;
30
bool C;
31
bool X;
32
bool Y;
33
bool Z;
34
bool L;
35
bool R;
36
bool start;
37
bool select;
38
};
39
40
struct InputButton {
41
bool press, hold;
42
int keyMappings, contMappings;
43
44
inline void setHeld()
45
{
46
press = !hold;
47
hold = true;
48
}
49
inline void setReleased()
50
{
51
press = false;
52
hold = false;
53
}
54
55
inline bool down() { return (press || hold); }
56
};
57
58
enum DefaultHapticIDs {
59
HAPTIC_NONE = -2,
60
HAPTIC_STOP = -1,
61
};
62
63
extern InputData keyPress;
64
extern InputData keyDown;
65
66
extern int touchDown[8];
67
extern int touchX[8];
68
extern int touchY[8];
69
extern int touchID[8];
70
extern float touchXF[8];
71
extern float touchYF[8];
72
extern int touches;
73
74
extern int hapticEffectNum;
75
76
#if !RETRO_USE_ORIGINAL_CODE
77
extern InputButton inputDevice[INPUT_BUTTONCOUNT];
78
extern int inputType;
79
80
extern float LSTICK_DEADZONE;
81
extern float RSTICK_DEADZONE;
82
extern float LTRIGGER_DEADZONE;
83
extern float RTRIGGER_DEADZONE;
84
85
extern int mouseHideTimer;
86
extern int lastMouseX;
87
extern int lastMouseY;
88
#endif
89
90
#if !RETRO_USE_ORIGINAL_CODE
91
#if RETRO_USING_SDL2
92
// Easier this way
93
enum ExtraSDLButtons {
94
SDL_CONTROLLER_BUTTON_ZL = SDL_CONTROLLER_BUTTON_MAX + 1,
95
SDL_CONTROLLER_BUTTON_ZR,
96
SDL_CONTROLLER_BUTTON_LSTICK_UP,
97
SDL_CONTROLLER_BUTTON_LSTICK_DOWN,
98
SDL_CONTROLLER_BUTTON_LSTICK_LEFT,
99
SDL_CONTROLLER_BUTTON_LSTICK_RIGHT,
100
SDL_CONTROLLER_BUTTON_RSTICK_UP,
101
SDL_CONTROLLER_BUTTON_RSTICK_DOWN,
102
SDL_CONTROLLER_BUTTON_RSTICK_LEFT,
103
SDL_CONTROLLER_BUTTON_RSTICK_RIGHT,
104
SDL_CONTROLLER_BUTTON_MAX_EXTRA,
105
};
106
107
void controllerInit(int controllerID);
108
void controllerClose(int controllerID);
109
#endif
110
111
#if RETRO_USING_SDL1
112
extern byte keyState[SDLK_LAST];
113
114
extern SDL_Joystick *controller;
115
#endif
116
117
void InitInputDevices();
118
void ReleaseInputDevices();
119
120
void ProcessInput();
121
#endif
122
123
void CheckKeyPress(InputData *input);
124
void CheckKeyDown(InputData *input);
125
126
int CheckTouchRect(float x1, float y1, float x2, float y2);
127
int CheckTouchRectMatrix(void *m, float x1, float y1, float x2, float y2);
128
129
#if RETRO_USE_HAPTICS
130
inline int GetHapticEffectNum()
131
{
132
int num = hapticEffectNum;
133
hapticEffectNum = HAPTIC_NONE;
134
return num;
135
}
136
void HapticEffect(int *id, int *a2, int *a3, int *a4);
137
#endif
138
139
#endif // !INPUT_H
140