question about PSP Controller
question about PSP Controller
hello there, it's a couple of days I'm learning about PSP programming.
I want to know if there is another method for reading the Controller state different from sceCtrlReadBufferPositive. I' m looking a method that can call a particular function when a key is pressed. Is there any possible implementation of this using something like an interrupt???
I want to know if there is another method for reading the Controller state different from sceCtrlReadBufferPositive. I' m looking a method that can call a particular function when a key is pressed. Is there any possible implementation of this using something like an interrupt???
No,no it's a good question...it's PSP related andHere, before you get attacked...
Code: Select all
#define sceCtrlRegisterButtonCallback sceCtrl_driver_5C56C779
Personally i've never used it, but i guess its use is something like (cut-n-paste from a googled page):
Code: Select all
void buttonCallback(int curr, int last, void *arg)
{
...
}
...
sceCtrlRegisterButtonCallback(3, key1 | key2, buttonCallback, NULL);
Code: Select all
oldData = data;
data = pollForData();
justPressed = data & !oldData;
justReleased = oldData & !data;
Code: Select all
if (justPressed & key1) ...
Happy coding.
Last edited by jean on Fri Jun 27, 2008 2:10 am, edited 1 time in total.
thank you for your help, it seems to be what I mean.
However I can't use the API
because the program doesn't start with my PSP.
Is this function working only with 1.50 kernel? And if not how must I implement it?
However I can't use the API
Code: Select all
int sceCtrl_driver_5C56C779 ( int no,
unsigned int mask,
void(*)(int, int, void *) cb,
void * arg
)
Is this function working only with 1.50 kernel? And if not how must I implement it?
Well, if you're asking how to implement a *real* interrupt-driven function, then i'm not able to drive you step by step...it's a quite tough task and requires some additional thinking! If you want to fake the behaviour of the original function at no-(thinking)cost you should create a standalone thread (search around for a thread example...there are plenty) that continuously polls (twice the vsync frequency should be enough) controller status and then calls a function (supplied with function pointer technique) when
But i again reccomend not to make your life difficult with asynchronous functions. If you REALLY need to process pad data asynchronously, then do all you can to make supplied function work instead of doing another that mimic it. If your async needs do born because you're in the middle of development of some vsh plugin messing with inputs, then consider learn about realtime patching.
What does compiler say when you build anyhow??
Code: Select all
// according to my previous snippet:
if ((data^oldData)!=0) callbackFunction(data);
What does compiler say when you build anyhow??
no, the function you told me is what I need (sceCtrlRegisterButtonCallback). The problem is that I don't know how put it in my program to make it runnable on a psp slim with CF 3.90M33 (the only I have). If I use the function my psp doesn't run the program. If I comment out the call to that function the program works.
And for that, start here: http://forums.ps2dev.org/viewtopic.php?p=58653#58653hibbyware wrote:As sceCtrlRegisterButtonCallback is in pspctrl_kernel.h I think you need to put it into a kernel mode prx and do the k1 thing,
thank you very much. I' ve finally managed to make the program work. I put
the function that register the callback in the prx and the function called in the main executable. In this way it works perfectly. But I haven't understood yet what's the meaning of the first int in the sceCtrlRegisterButtonCallback that the pspsdk reference says refers to the number of the callback, but I don't know what it needs.
the function that register the callback in the prx and the function called in the main executable. In this way it works perfectly. But I haven't understood yet what's the meaning of the first int in the sceCtrlRegisterButtonCallback that the pspsdk reference says refers to the number of the callback, but I don't know what it needs.
-
- Posts: 110
- Joined: Tue Feb 27, 2007 9:43 pm
- Contact:
From the thread hlide posted: http://forums.ps2dev.org/viewtopic.php? ... t=callback
0x5E77BC8A sceCtrlGetButtonIntercept
0x7CA723DC sceCtrlSetButtonIntercept
You can rename with the real name now in sdk.
0x5E77BC8A sceCtrlGetButtonIntercept
0x7CA723DC sceCtrlSetButtonIntercept
You can rename with the real name now in sdk.