forked from KapLex/PGE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgeControls.h
182 lines (157 loc) · 4.01 KB
/
pgeControls.h
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
* pgeControls.h: Header for controls (button input)
*
* This file is part of "Phoenix Game Engine".
*
* Copyright (C) 2008 Phoenix Game Engine
* Copyright (C) 2008 InsertWittyName <[email protected]>
* Copyright (C) 2008 MK2k <[email protected]>
*
* Phoenix Game Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Phoenix Game Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Phoenix Game Engine. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __PGECONTROLS_H__
#define __PGECONTROLS_H__
#include <pspctrl.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @defgroup pgeControls Controller Library
* @{
*/
/**
* Enumerator for buttons
*/
enum pgeCtrlButtons
{
/** Select button. */
PGE_CTRL_SELECT = PSP_CTRL_SELECT,
/** Start button. */
PGE_CTRL_START = PSP_CTRL_START,
/** Up D-Pad button. */
PGE_CTRL_UP = PSP_CTRL_UP,
/** Right D-Pad button. */
PGE_CTRL_RIGHT = PSP_CTRL_RIGHT,
/** Down D-Pad button. */
PGE_CTRL_DOWN = PSP_CTRL_DOWN,
/** Left D-Pad button. */
PGE_CTRL_LEFT = PSP_CTRL_LEFT,
/** Left trigger. */
PGE_CTRL_LTRIGGER = PSP_CTRL_LTRIGGER,
/** Right trigger. */
PGE_CTRL_RTRIGGER = PSP_CTRL_RTRIGGER,
/** Triangle button. */
PGE_CTRL_TRIANGLE = PSP_CTRL_TRIANGLE,
/** Circle button. */
PGE_CTRL_CIRCLE = PSP_CTRL_CIRCLE,
/** Cross button. */
PGE_CTRL_CROSS = PSP_CTRL_CROSS,
/** Square button. */
PGE_CTRL_SQUARE = PSP_CTRL_SQUARE
};
/**
* Init the controls
*
* @returns 1 on success
*/
int pgeControlsInit(void);
/**
* Shutdown the controls
*/
void pgeControlsShutdown(void);
/**
* Update the controls
*
* Should be called once at the start of each iteration of your main loop
*/
void pgeControlsUpdate(void);
/**
* Check for ANY button being pressed
*
* @returns 1 on any button being pressed, 0 if no buttons are pressed
*/
int pgeControlsPressedAny(void);
/**
* Check for a button being pressed
*
* @param buttons - The button types (PGE_CTRL_*) to check for
*
* @returns 1 if buttons pressed, 0 if not pressed
*/
int pgeControlsPressed(const unsigned int buttons);
/**
* Check for ANY button being held
*
* @returns 1 on any button being pressed, 0 if no buttons are pressed
*/
int pgeControlsHeldAny(void);
/**
* Check for a button being held
*
* @param buttons - The button types (PGE_CTRL_*) to check for
*
* @returns 1 if buttons pressed, 0 if not pressed
*/
int pgeControlsHeld(const unsigned int buttons);
/**
* Check for ANY button being released
*
* @returns 1 on any button being released, 0 if no buttons are released
*/
int pgeControlsReleasedAny(void);
/**
* Check for a button being released
*
* @param buttons - The button types (PGE_CTRL_*) to check for
*
* @returns 1 if buttons released, 0 if not pressed
*/
int pgeControlsReleased(const unsigned int buttons);
/**
* Get the analog X position
*
* @returns The current value of the analog X position, -128 to 127, -128 being fully left, 127 being fully right
*/
char pgeControlsAnalogX(void);
/**
* Get the analog Y position
*
* @returns The current value of the analog Y position, -128 to 127, -128 being fully up, 127 being fully down
*/
char pgeControlsAnalogY(void);
/**
* Get the analog angle
*
* @returns The angle in radians
*/
float pgeControlsAnalogAngle(void);
/**
* Get the analog magnitude
*
* @returns The magnitude
*/
float pgeControlsAnalogMag(void);
/**
* Enables the controls
*
* @note The controls are enabled by default
*/
void pgeControlsEnable(void);
/**
* Disables the controls
*/
void pgeControlsDisable(void);
/** @} */
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __PGECONTROLS_H__