21 #include "../../SDL_internal.h" 27 #include <pspkernel.h> 32 #include "../SDL_sysjoystick.h" 33 #include "../SDL_joystick_c.h" 39 #include "../../thread/SDL_systhread.h" 42 static SceCtrlData pad = { .Lx = 0, .Ly = 0, .Buttons = 0 };
43 static SDL_sem *pad_sem =
NULL;
45 static int running = 0;
46 static const enum PspCtrlButtons button_map[] = {
47 PSP_CTRL_TRIANGLE, PSP_CTRL_CIRCLE, PSP_CTRL_CROSS, PSP_CTRL_SQUARE,
48 PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER,
49 PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_UP, PSP_CTRL_RIGHT,
50 PSP_CTRL_SELECT, PSP_CTRL_START, PSP_CTRL_HOME, PSP_CTRL_HOLD };
51 static int analog_map[256];
60 static point
a = { 0, 0 };
61 static point
b = { 50, 0 };
62 static point
c = { 78, 32767 };
63 static point
d = { 128, 32767 };
66 static SDL_INLINE void lerp (point *dest, point *
a, point *
b,
float t)
68 dest->x = a->x + (b->x - a->x)*t;
69 dest->y = a->y + (b->y - a->y)*t;
73 static int calc_bezier_y(
float t)
75 point ab, bc, cd, abbc, bccd, dest;
76 lerp (&ab, &
a, &
b, t);
77 lerp (&bc, &
b, &
c, t);
78 lerp (&cd, &
c, &
d, t);
79 lerp (&abbc, &ab, &bc, t);
80 lerp (&bccd, &bc, &cd, t);
81 lerp (&dest, &abbc, &bccd, t);
88 int JoystickUpdate(
void *
data)
92 sceCtrlPeekBufferPositive(&pad, 1);
95 sceKernelDelayThread(1000000 / 60);
111 sceCtrlSetSamplingCycle(0);
112 sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
125 for (i = 0; i < 128; i++)
127 float t = (float)i/127.0
f;
128 analog_map[i+128] = calc_bezier_y(t);
129 analog_map[127-
i] = -1 * analog_map[i+128];
147 return "PSP builtin joypad";
157 const char *SDL_SYS_JoystickName(
int index)
160 return "PSP controller";
173 joystick->nbuttons = 14;
194 enum PspCtrlButtons buttons;
195 enum PspCtrlButtons changed;
197 static enum PspCtrlButtons old_buttons = 0;
198 static unsigned char old_x = 0, old_y = 0;
201 buttons = pad.Buttons;
217 changed = old_buttons ^ buttons;
218 old_buttons = buttons;
220 for(i=0; i<
sizeof(button_map)/
sizeof(button_map[0]); i++) {
221 if(changed & button_map[i]) {
224 (buttons & button_map[i]) ?
230 sceKernelDelayThread(0);
261 const char *name = joystick->name;
GLint GLint GLint GLint GLint x
#define SDL_CreateSemaphore
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
void SDL_SYS_JoystickQuit(void)
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
GLuint const GLchar * name
SDL_Thread * SDL_CreateThreadInternal(int(*fn)(void *), const char *name, const size_t stacksize, void *data)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
GLint GLint GLint GLint GLint GLint y
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int SDL_SYS_JoystickInit(void)
int SDL_SYS_NumJoysticks(void)
#define SDL_DestroySemaphore
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
GLboolean GLboolean GLboolean GLboolean a
GLboolean GLboolean GLboolean b
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index)
void SDL_SYS_JoystickDetect(void)