-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
180 lines (169 loc) · 4.81 KB
/
main.c
File metadata and controls
180 lines (169 loc) · 4.81 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
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
/*******************************************************************************************
*
* raylib [shapes] example - Draw raylib logo using basic shapes
*
* This example has been created using raylib 1.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Copyright (c) 2014 Ramon Santamaria (@raysan5)
* Copyright (c) 2020 Antonio Jose Ramos Marquez (@psxdev) adapt sample to orbisdev
********************************************************************************************/
#include <stdio.h>
#include <user_mem.h>
#include <stdlib.h>
#include <string.h>
#include <orbisdev.h>
#include <orbislink.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <signal.h>
#include <debugnet.h>
#include <fcntl.h>
#include <orbisNfs.h>
#include <sqlite3.h>
#include <raylib.h>
#define ATTR_ORBIS_WIDTH 1920
#define ATTR_ORBIS_HEIGHT 1080
bool flag=true;
OrbisPadConfig *confPad;
bool l1flag=false;
bool r1flag=false;
void updateController()
{
int ret;
unsigned int buttons=0;
ret=orbisPadUpdate();
if(ret==0)
{
if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2))
{
debugNetPrintf(DEBUGNET_DEBUG,"Combo L2R2 pressed\n");
buttons=orbisPadGetCurrentButtonsPressed();
buttons&= ~(ORBISPAD_L2|ORBISPAD_R2);
orbisPadSetCurrentButtonsPressed(buttons);
}
if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) )
{
debugNetPrintf(DEBUGNET_DEBUG,"Combo L1R1 pressed\n");
buttons=orbisPadGetCurrentButtonsPressed();
buttons&= ~(ORBISPAD_L1|ORBISPAD_R1);
orbisPadSetCurrentButtonsPressed(buttons);
}
if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2))
{
debugNetPrintf(DEBUGNET_DEBUG,"Combo L1R2 pressed\n");
buttons=orbisPadGetCurrentButtonsPressed();
buttons&= ~(ORBISPAD_L1|ORBISPAD_R2);
orbisPadSetCurrentButtonsPressed(buttons);
}
if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) )
{
debugNetPrintf(DEBUGNET_DEBUG,"Combo L2R1 pressed\n");
buttons=orbisPadGetCurrentButtonsPressed();
buttons&= ~(ORBISPAD_L2|ORBISPAD_R1);
orbisPadSetCurrentButtonsPressed(buttons);
}
if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP))
{
debugNetPrintf(DEBUGNET_DEBUG,"Up pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN))
{
debugNetPrintf(DEBUGNET_DEBUG,"Down pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT))
{
debugNetPrintf(DEBUGNET_DEBUG,"Right pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT))
{
debugNetPrintf(DEBUGNET_DEBUG,"Left pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE))
{
debugNetPrintf(DEBUGNET_DEBUG,"Triangle pressed exit\n");
flag=0;
}
if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE))
{
debugNetPrintf(DEBUGNET_DEBUG,"Circle pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_CROSS))
{
debugNetPrintf(DEBUGNET_DEBUG,"Cross pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_SQUARE))
{
debugNetPrintf(DEBUGNET_DEBUG,"Square pressed\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_L1))
{
debugNetPrintf(DEBUGNET_DEBUG,"L1 pressed %d\n");
l1flag=1;
}
if(orbisPadGetButtonPressed(ORBISPAD_L2))
{
debugNetPrintf(DEBUGNET_DEBUG,"L2 pressed %d\n");
}
if(orbisPadGetButtonPressed(ORBISPAD_R1))
{
debugNetPrintf(DEBUGNET_DEBUG,"R1 pressed\n");
r1flag=1;
}
if(orbisPadGetButtonPressed(ORBISPAD_R2))
{
debugNetPrintf(DEBUGNET_DEBUG,"R2 pressed\n");
}
}
}
bool initApp()
{
int ret;
ret=initOrbisLinkAppVanillaGl();
if(ret==ORBISLINK_OK)
{
ret=orbisLinkLoadModule(SCE_SYSMODULE_INTERNAL_PAD);
if(ret==ORBISLINK_OK)
{
ret=orbisPadInit();
if(ret==1)
{
confPad=orbisPadGetConf();
sceSystemServiceHideSplashScreen();
return true;
}
}
}
return false;
}
void finishApp()
{
orbisPadFinish();
finishOrbisLinkApp();
kill(getpid(), SIGTERM);
}
int main(int argc, char *argv[])
{
flag=initApp();
if(!flag)
{
finishApp();
}
InitWindow(ATTR_ORBIS_WIDTH,ATTR_ORBIS_HEIGHT,"raylib [shapes] example - raylib logo using shapes");
SetTargetFPS(60);
while(flag)
{
updateController();
BeginDrawing();
ClearBackground(RAYWHITE);
DrawRectangle(ATTR_ORBIS_WIDTH/2 - 128, ATTR_ORBIS_HEIGHT/2 - 128, 256, 256, BLACK);
DrawRectangle(ATTR_ORBIS_WIDTH/2 - 112, ATTR_ORBIS_HEIGHT/2 - 112, 224, 224, RAYWHITE);
DrawText("raylib", ATTR_ORBIS_WIDTH/2 - 44, ATTR_ORBIS_HEIGHT/2 + 48, 50, BLACK);
DrawText("this is NOT a texture!", 905, 679, 10, GRAY);
EndDrawing();
}
CloseWindow();
finishApp();
return 0;
}