-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmain.c
More file actions
98 lines (82 loc) · 2.19 KB
/
main.c
File metadata and controls
98 lines (82 loc) · 2.19 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
#include <pspuser.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
PSP_MODULE_INFO("Controller", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
#define printf pspDebugScreenPrintf
int done = 0;
int exit_callback(int arg1, int arg2, void *common)
{
done = 1;
return 0;
}
int callback_thread(SceSize args, void *argp)
{
int cbid = sceKernelCreateCallback("Exit Callback",
exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
return 0;
}
int setup_callbacks(void)
{
int thid = sceKernelCreateThread("update_thread",
callback_thread, 0x11, 0xFA0, 0, 0);
if(thid >= 0)
sceKernelStartThread(thid, 0, 0);
return thid;
}
int main(void)
{
SceCtrlData pad;
pspDebugScreenInit();
setup_callbacks();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
while (!done)
{
pspDebugScreenSetXY(0, 2);
sceCtrlReadBufferPositive(&pad, 1);
printf("Analog X = %3d, ", pad.Lx);
printf("Analog Y = %3d \n", pad.Ly);
if (pad.Buttons != 0)
{
if (pad.Buttons & PSP_CTRL_SQUARE)
{
printf("Square pressed! \n");
}
if (pad.Buttons & PSP_CTRL_TRIANGLE)
{
printf("Triangle pressed! \n");
}
if (pad.Buttons & PSP_CTRL_CIRCLE)
{
printf("Circle pressed! \n");
}
if (pad.Buttons & PSP_CTRL_CROSS)
{
printf("Cross pressed! \n");
}
if (pad.Buttons & PSP_CTRL_UP)
{
printf("Up direction pad pressed! \n");
}
if (pad.Buttons & PSP_CTRL_DOWN)
{
printf("Down direction pad pressed! \n");
}
if (pad.Buttons & PSP_CTRL_LEFT)
{
printf("Left direction pad pressed! \n");
}
if (pad.Buttons & PSP_CTRL_RIGHT)
{
printf("Right direction pad pressed! \n");
}
}
}
sceKernelExitGame();
return 0;
}