forked from libcg/XtreamLua-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctrl.h
294 lines (173 loc) · 6.53 KB
/
ctrl.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
* XtreamLua Player - Final Version
* ctrl.h
*
* Copyright:
*
* This work is licensed under the Creative Commons BY-SA 3.0 License.
* See http://creativecommons.org/licenses/by-sa/3.0/ or the LICENSE file
* for more details.
*/
#ifndef __XLP_CTRL__
#define __XLP_CTRL__
#include "common.h"
#include <string.h>
#include <pspctrl.h>
/*
Ctrl.read() - Read all buttons state.
%arg nothing
%ret ctrlData A variable with the buttons state.
*/
int Ctrl_read(lua_State *L);
/*
Ctrl.buttons(pad) - Get bit mask containing the control buttons, can be used like this: pad:buttons().
%arg ctrlData pad A variable created with Ctrl.read().
%ret number The bit mask containing the control buttons.
*/
int Ctrl_buttons(lua_State *L);
/*
Ctrl.cross(pad) - Get the state of the cross button, can be used like this: pad:cross()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the cross button is pressed, false if it isn't pressed.
*/
int Ctrl_cross(lua_State *L);
/*
Ctrl.circle(pad) - Get the state of the circle button, can be used like this: pad:circle()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the circle button is pressed, false if it isn't pressed.
*/
int Ctrl_circle(lua_State *L);
/*
Ctrl.triangle(pad) - Get the state of the triangle button, can be used like this: pad:triangle()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the triangle button is pressed, false if it isn't pressed.
*/
int Ctrl_triangle(lua_State *L);
/*
Ctrl.square(pad) - Get the state of the square button, can be used like this: pad:square()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the square button is pressed, false if it isn't pressed.
*/
int Ctrl_square(lua_State *L);
/*
Ctrl.down(pad) - Get the state of the down button, can be used like this: pad:down()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the down button is pressed, false if it isn't pressed.
*/
int Ctrl_down(lua_State *L);
/*
Ctrl.right(pad) - Get the state of the right button, can be used like this: pad:right()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the right button is pressed, false if it isn't pressed.
*/
int Ctrl_right(lua_State *L);
/*
Ctrl.up(pad) - Get the state of the up button, can be used like this: pad:up()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the up button is pressed, false if it isn't pressed.
*/
int Ctrl_up(lua_State *L);
/*
Ctrl.left(pad) - Get the state of the left button, can be used like this: pad:left()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the left button is pressed, false if it isn't pressed.
*/
int Ctrl_left(lua_State *L);
/*
Ctrl.l(pad) - Get the state of the left trigger, can be used like this: pad:l()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the left trigger is triggered, false if it isn't pressed.
*/
int Ctrl_l(lua_State *L);
/*
Ctrl.r(pad) - Get the state of the right trigger, can be used like this: pad:r()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the right trigger is triggered, false if it isn't pressed.
*/
int Ctrl_r(lua_State *L);
/*
Ctrl.start(pad) - Get the state of the start button, can be used like this: pad:start()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the start button is pressed, false if it isn't pressed.
*/
int Ctrl_start(lua_State *L);
/*
Ctrl.select(pad) - Get the state of the select button, can be used like this: pad:select()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the select button is pressed, false if it isn't pressed.
*/
int Ctrl_select(lua_State *L);
/*
Ctrl.hold(pad) - Get the state of the hold button, can be used like this: pad:hold()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the hold button is pressed, false if it isn't pressed.
*/
int Ctrl_hold(lua_State *L);
/*
Ctrl.note(pad) - Get the state of the note button, can be used like this: pad:note()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the note button is pressed, false if it isn't pressed.
*/
int Ctrl_note(lua_State *L);
/*
Ctrl.home(pad) - Get the state of the home button, can be used like this: pad:home()
%arg ctrlData pad A variable created with Ctrl.read().
%ret boolean A boolean, true if the home button is pressed, false if it isn't pressed.
*/
int Ctrl_home(lua_State *L);
/*
Ctrl.Lx(pad) - Get the value of the joystick's X-Axis, can be used like this: pad:Lx()
%arg ctrlData pad A variable created with Ctrl.read().
%ret number The value of the joystick's X-Axis, between 0 -> 128.
*/
int Ctrl_analogX(lua_State *L);
/*
Ctrl.Ly(pad) - Get the value of the joystick's Y-Axis, can be used like this: pad:Ly()
%arg ctrlData pad A variable created with Ctrl.read().
%ret number The value of the joystick's Y-Axis, between 0 -> 128.
*/
int Ctrl_analogY(lua_State *L);
/*
tostring(pad) - Put a Ctrl value as string.
%arg ctrlData pad A variable created with Ctrl.read().
%ret string A string like this: "Ctrl: 16384" if cross is pressed.
*/
int Ctrl_tostring(lua_State *L);
/*
pad1 == pad2 - Check if two Ctrl datas are equal or not.
%arg ctrlData pad1 A variable created with Ctrl.read().
%arg ctrlData pad2 A variable created with Ctrl.read().
%ret boolean A boolean, true if the two pad datas are equal, false if they're not.
*/
int Ctrl_equal(lua_State *L);
// XLP internal code //
int Ctrl_init(lua_State *L);
static const luaL_reg Ctrl_methods[] = { //Ctrl methods
{"read", Ctrl_read},
{"buttons", Ctrl_buttons},
{"cross", Ctrl_cross},
{"circle", Ctrl_circle},
{"square", Ctrl_square},
{"triangle", Ctrl_triangle},
{"down", Ctrl_down},
{"right", Ctrl_right},
{"left", Ctrl_left},
{"up", Ctrl_up},
{"l", Ctrl_l},
{"r", Ctrl_r},
{"start", Ctrl_start},
{"select", Ctrl_select},
{"note", Ctrl_note},
{"home", Ctrl_home},
{"hold", Ctrl_hold},
{"Lx", Ctrl_analogX},
{"Ly", Ctrl_analogY},
{0, 0}
};
static const luaL_reg Ctrl_metamethods[] = { //Ctrl metamethods
{"__tostring", Ctrl_tostring},
{"__eq", Ctrl_equal},
{0, 0}
};
#endif
//EOF