| View previous topic :: View next topic |
| Author |
Message |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Wed May 18, 2005 9:32 pm Post subject: libpad with 2 controllers |
|
|
Ok. I making an arcade-y type thing, with 1up, 2up or 2 player, depending on who's pressed start. And i'm up to the bit where i set up the pads (ie at the beginning!). So.
Based on the libpad sample, i noticed that when calling initializePad when none inserted hangs. Then i found code in the turnips source that must have been pulled out that chekcs for pad's existence: (cheers to pukko!) | Code: | while((ret=padGetState(port, slot)) != PAD_STATE_STABLE) {
if(ret==0) {
// No pad connected!
printf("Pad(%d, %d) is disconnected\n", port, slot);
return 0;
}
printf("looping\n");
} | So i stuck that at the start and now initializePad returns quietly when none is pulgged in. So far so good.
The problem is that this only seems to work with dualshock (1 and 2) If i have a old digi pad or (more importantly) my remote IR-dongle the above loop goes for ever.(both have 0 modes and identify as a vanilla digital pad) However to find the type i have to do other stuff, which dies when no pad is inserted.
So now i just have to know at compile time what type of pad, rather than if there is one or not.
There has to be a way to achieve this, but i'm yet to find any source to assist.
All ideas are welcome!
thanks - cheriff _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Thu May 19, 2005 2:51 am Post subject: |
|
|
Keep in mind the pad example contains a lot of crap it doesn't need to have...
You should be able to detect what type of pad is connected easily, I thought the pad example showed how.
If you don't have it figured out by the time I can play around with my PS2 again, I'll dig through my code and see if I can get an example for you. _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Thu May 19, 2005 3:34 am Post subject: |
|
|
I can detect between dualshock / digital (as thats all I have) but this method fails when nothing is in.,
I can detect between dualshock / nothing using another method, but that fails when a digi pad is in.
All i really need is "Is there a pad (of any type) in slot x? (Y/N)"
I'm sleeping now (soon) so I'l play some more tomorrow and maybe post some code.
Cheers, - cheriff _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
Drakonite Site Admin

Joined: 17 Jan 2004 Posts: 989
|
Posted: Thu May 19, 2005 3:49 am Post subject: |
|
|
padGetState will return a different value if there is no pad connected, not sure what the defines for it are (or if anyone bothered to put a define in libpad for it for that matter) _________________ Shoot Pixels Not People!
Makeshift Development |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Fri May 20, 2005 11:46 am Post subject: |
|
|
Yep, you're right.
The pad sample had something like waitPadready() that looped untill padGetState eventually returned 6 or 2 (seems to be 6=dualshock2, 2=not?).
So I just changed it to stop when state is 0 (no pad) and return the fact, so as not to go thru the rest of the init routine on a non-pad.
So thanks for the pointer.. why do i always find the 'easy' answer after ages of testing every combination of padman/xpadman digi/analog pad and port/slot numbers... beh. _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
|