forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

libpad with 2 controllers

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Wed May 18, 2005 9:32 pm    Post subject: libpad with 2 controllers Reply with quote

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
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu May 19, 2005 2:51 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Thu May 19, 2005 3:34 am    Post subject: Reply with quote

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
View user's profile Send private message
Drakonite
Site Admin


Joined: 17 Jan 2004
Posts: 989

PostPosted: Thu May 19, 2005 3:49 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Fri May 20, 2005 11:46 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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