 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Tue Nov 25, 2008 11:58 pm Post subject: Questions regarding sceCtrlPeekBufferPositive |
|
|
I have two questions regarding the following function call
| Code: | | sceCtrlPeekBufferPositive(&pad, 1) |
1) What is the second parameter ? I've never seen anything else than 1 used here...
2) What does the function return ? Number of values read ?
Thanks in advance for your answers |
|
| Back to top |
|
 |
hibbyware
Joined: 28 Mar 2007 Posts: 78
|
Posted: Wed Nov 26, 2008 12:40 am Post subject: |
|
|
This is taken from the pspsdk docs,
Controller Kernel Library
| Code: |
int sceCtrlPeekBufferPositive(SceCtrlData * pad_data, int count);
Parameters:
pad_data - Pointer to a SceCtrlData structure used hold the returned pad data.
count - Number of SceCtrlData buffers to read.
|
Returned data SceCtrlData
| Code: |
unsigned int TimeStamp; // The current read frame.
unsigned int Buttons; // Bit mask containing zero or more of PspCtrlButtons.
unsigned char Lx; // Analogue stick, X axis.
unsigned char Ly; // Analogue stick, Y axis.
unsigned char Rsrv[6]; // Reserved.
|
|
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Nov 26, 2008 4:18 am Post subject: |
|
|
| It probably lets you read values between the last sceCtrlReadBuffer and the present value if sceCtrlReadBuffer is being called less than 60 times a second. From what ive seen syscon always sends button state packets 60 times a second. |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Wed Nov 26, 2008 11:28 am Post subject: |
|
|
@hibbyware:
Thanks. Actually I did read the docs, and search the net, but didn't get a real answer.
Count is number of buffers to read, sure, but my question is, why is there several of them ? If I pass 2, and I get 2, what is the meaning of the second one ?
Does it depend on sceCtrlSetSamplingMode ? I mean, the analog stick probably won't give off events, it has to be polled, that makes sense. However, polling the digital controller makes little sense - it can be done, and it works, but makes for a cranky input.
Here is what I can suppose :
- Is there *exactly* a buffer to read for each sample cycle (according to the setting given by sceCtrlSetSamplingCycle(int cycle)) ?
- Is there a buffer to read each time there is something happening on the controller ?
- Is there a buffer for each cycle PLUS one buffer each time something happens on the controller ?
- Does the behaviour alternates between first and second possibility depending on sceCtrlSetSamplingMode ?
This is what I wanted to know, and haven't been able to find either in the docs or on the net. Sorry for the not very explicit question.
| Quote: | | Returned data SceCtrlData |
Thanks, but this is not the return value, this is what it puts into the memory you give it. I want to know what the *return value* of the function means, the int that the function returns.
My guess would be, number of buffers actually read, but it's only a wild guess, so I wonder if anyone knows.
@Torch: thanks, but doesn't the function SetCycle change this behavior ? |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Nov 26, 2008 11:39 am Post subject: |
|
|
I've used the Syscon hook sample where you receive every packet sent from the Syscon. You have to check some bits to identify which kind of packet it is, such as ctrl pad data using a simple switch-case.
In my app, the ctrl pad case gets executed 60 times a second always, even if you change the sampling cycle. In fact I'm using the incoming ctrl pad packets as a timer accurate to 1/60 of a second for other things in my app!!
The sampling mode invokes a hardware change. You get a different value in the Syscon packet identifier if analog is enabled. But the remaining format is exactly the same. In digital mode, the analog x & y is zero.
I have not experimented with different values of count, but I know this, suppose sceCtrlReadBuffer is not executed for some time, then sceCtrlPeekBuffer stops working after you have called it some amount of times, until you call sceCtrlReadBuffer again.
Try this experiment. Create an EBOOT and set a slow sampling rate like 1 second or something with a long delay thread. Then press some buttons and use PeekBuffer with different count values. See what pad_data you get for each count value. Don't use read buffer. |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Wed Nov 26, 2008 12:43 pm Post subject: |
|
|
| Thanks, I'll give it a try |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|