-
Notifications
You must be signed in to change notification settings - Fork 0
/
pspctrl.h
206 lines (182 loc) · 5.21 KB
/
pspctrl.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
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* pspctrl.h - Prototypes for the sceCtrl library.
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: pspctrl.h 2433 2008-10-15 10:00:27Z iwn $
*/
/* Note: Some of the structures, types, and definitions in this file were
extrapolated from symbolic debugging information found in the Japanese
version of Puzzle Bobble. */
#ifndef __CTRL_H__
#define __CTRL_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup Ctrl Controller Kernel Library */
/*@{*/
/**
* Enumeration for the digital controller buttons.
*
* @note PSP_CTRL_HOME, PSP_CTRL_NOTE, PSP_CTRL_SCREEN, PSP_CTRL_VOLUP, PSP_CTRL_VOLDOWN, PSP_CTRL_DISC, PSP_CTRL_WLAN_UP, PSP_CTRL_REMOTE, PSP_CTRL_MS can only be read in kernel mode
*/
enum PspCtrlButtons
{
/** Select button. */
PSP_CTRL_SELECT = 0x000001,
/** Start button. */
PSP_CTRL_START = 0x000008,
/** Up D-Pad button. */
PSP_CTRL_UP = 0x000010,
/** Right D-Pad button. */
PSP_CTRL_RIGHT = 0x000020,
/** Down D-Pad button. */
PSP_CTRL_DOWN = 0x000040,
/** Left D-Pad button. */
PSP_CTRL_LEFT = 0x000080,
/** Left trigger. */
PSP_CTRL_LTRIGGER = 0x000100,
/** Right trigger. */
PSP_CTRL_RTRIGGER = 0x000200,
/** Triangle button. */
PSP_CTRL_TRIANGLE = 0x001000,
/** Circle button. */
PSP_CTRL_CIRCLE = 0x002000,
/** Cross button. */
PSP_CTRL_CROSS = 0x004000,
/** Square button. */
PSP_CTRL_SQUARE = 0x008000,
/** Home button. In user mode this bit is set if the exit dialog is visible. */
PSP_CTRL_HOME = 0x010000,
/** Hold button. */
PSP_CTRL_HOLD = 0x020000,
/** Music Note button. */
PSP_CTRL_NOTE = 0x800000,
/** Screen button. */
PSP_CTRL_SCREEN = 0x400000,
/** Volume up button. */
PSP_CTRL_VOLUP = 0x100000,
/** Volume down button. */
PSP_CTRL_VOLDOWN = 0x200000,
/** Wlan switch up. */
PSP_CTRL_WLAN_UP = 0x040000,
/** Remote hold position. */
PSP_CTRL_REMOTE = 0x080000,
/** Disc present. */
PSP_CTRL_DISC = 0x1000000,
/** Memory stick present. */
PSP_CTRL_MS = 0x2000000,
};
/** Controller mode. */
enum PspCtrlMode
{
/* Digitial. */
PSP_CTRL_MODE_DIGITAL = 0,
/* Analog. */
PSP_CTRL_MODE_ANALOG
};
/** Returned controller data */
typedef struct SceCtrlData {
/** The current read frame. */
unsigned int TimeStamp;
/** Bit mask containing zero or more of ::PspCtrlButtons. */
unsigned int Buttons;
/** Analogue stick, X axis. */
unsigned char Lx;
/** Analogue stick, Y axis. */
unsigned char Ly;
/** Reserved. */
unsigned char Rsrv[6];
} SceCtrlData;
typedef struct SceCtrlLatch {
unsigned int uiMake;
unsigned int uiBreak;
unsigned int uiPress;
unsigned int uiRelease;
} SceCtrlLatch;
/**
* Set the controller cycle setting.
*
* @param cycle - Cycle. Normally set to 0.
*
* @return The previous cycle setting.
*/
int sceCtrlSetSamplingCycle(int cycle);
/**
* Get the controller current cycle setting.
*
* @param pcycle - Return value.
*
* @return 0.
*/
int sceCtrlGetSamplingCycle(int *pcycle);
/**
* Set the controller mode.
*
* @param mode - One of ::PspCtrlMode.
*
* @return The previous mode.
*/
int sceCtrlSetSamplingMode(int mode);
/**
* Get the current controller mode.
*
* @param pmode - Return value.
*
* @return 0.
*/
int sceCtrlGetSamplingMode(int *pmode);
int sceCtrlPeekBufferPositive(SceCtrlData *pad_data, int count);
int sceCtrlPeekBufferNegative(SceCtrlData *pad_data, int count);
/**
* Read buffer positive
*
* @par Example:
* @code
* SceCtrlData pad;
* sceCtrlSetSamplingCycle(0);
* sceCtrlSetSamplingMode(1);
* sceCtrlReadBufferPositive(&pad, 1);
* // Do something with the read controller data
* @endcode
*
* @param pad_data - Pointer to a ::SceCtrlData structure used hold the returned pad data.
* @param count - Number of ::SceCtrlData buffers to read.
*/
int sceCtrlReadBufferPositive(SceCtrlData *pad_data, int count);
int sceCtrlReadBufferNegative(SceCtrlData *pad_data, int count);
int sceCtrlPeekLatch(SceCtrlLatch *latch_data);
int sceCtrlReadLatch(SceCtrlLatch *latch_data);
/**
* Set analog threshold relating to the idle timer.
*
* @param idlereset - Movement needed by the analog to reset the idle timer.
* @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
*
* Set to -1 for analog to not cancel idle timer.
* Set to 0 for idle timer to be cancelled even if the analog is not moved.
* Set between 1 - 128 to specify the movement on either axis needed by the analog to fire the event.
*
* @return < 0 on error.
*/
int sceCtrlSetIdleCancelThreshold(int idlereset, int idleback);
/**
* Get the idle threshold values.
*
* @param idlerest - Movement needed by the analog to reset the idle timer.
* @param idleback - Movement needed by the analog to bring the PSP back from an idle state.
*
* @return < 0 on error.
*/
int sceCtrlGetIdleCancelThreshold(int *idlerest, int *idleback);
/*@}*/
#ifdef __cplusplus
}
#endif
#endif