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 

issue with input from the second controller

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



Joined: 25 Sep 2007
Posts: 48
Location: London

PostPosted: Fri Jun 20, 2008 12:26 pm    Post subject: issue with input from the second controller Reply with quote

I'd like to add a 2 players feature in my project, but can't succesfully receive data from the second controler.

I init my pads with this:
Code:

    int port = 0; // 0 -> Connector 1, 1 -> Connector 2
    int slot = 0; // Always zero if not using multitap
    if((ret = padPortOpen(port, slot, padBuf)) == 0) {
        scr_printf("padOpenPort failed: %d\n", ret);
        SleepThread();
    }
    else{scr_printf("ok-");}

    if(!initializePad(port, slot)) {
        scr_printf("pad initalization failed!\n");
        SleepThread();
    }
    else{scr_printf("ok-");}

    port = 1; // 0 -> Connector 1, 1 -> Connector 2
    slot = 0; // Always zero if not using multitap
    if((ret = padPortOpen(port, slot, padBuf)) == 0) {
        scr_printf("padOpenPort failed: %d\n", ret);
        SleepThread();
    }
    else{scr_printf("ok-");}

    if(!initializePad(port, slot)) {
        scr_printf("pad initalization failed!\n");
        SleepThread();
    }
    else{scr_printf("ok-");}


and 4 "ok" are printed, fine!

but how can I receive data from the second one?

i tried

Code:

struct padButtonStatus buttons[2];
int port =1;
int slot=0;
int ret
ret = padRead(port, slot, &buttons[port]); // port, slot, buttons

    if (ret != 0) {
        paddata[port] = 0xffff ^ buttons[port].btns;

        new_pad[port] = paddata[port] & ~old_pad[port];
        old_pad[port] = paddata[port];

        i=new_pad[port];
    }

    paddata[port] = 0xffff ^ buttons[port].btns;
    i=paddata[port];

but then
Code:

    if (i&PAD_TRIANGLE) { ... }

just never works...
_________________
softwares for artists on video game systems - http://www.pikilipita.com
Back to top
View user's profile Send private message Visit poster's website
Lukasz



Joined: 19 Jan 2004
Posts: 248
Location: Denmark

PostPosted: Fri Jun 20, 2008 3:59 pm    Post subject: Reply with quote

From a quick glance at your description and code I can't spot the problem. I suggest you try the 3 different pad samples in ps2sdk (rpc/pad, rpc/padx, rpc/mtap) and go from there.
_________________
Lukasz.dk
Back to top
View user's profile Send private message Visit poster's website
kouky



Joined: 25 Sep 2007
Posts: 48
Location: London

PostPosted: Sat Jun 21, 2008 12:45 am    Post subject: Reply with quote

Thanks, Lukasz,
I've found my error in those examples:
You need to have 2 padBuf, so the code has to be:
Code:

static char *padBuf[2];
    padBuf[0] = memalign(64, 256);
    padBuf[1] = memalign(64, 256);


...



    int port = 0; // 0 -> Connector 1, 1 -> Connector 2
    int slot = 0; // Always zero if not using multitap
    if((ret = padPortOpen(port, slot, padBuf[0])) == 0) {
        scr_printf("padOpenPort failed: %d\n", ret);
        SleepThread();
    }

    if(!initializePad(port, slot)) {
        scr_printf("pad initalization failed!\n");
        SleepThread();
    }

    port = 1; // 0 -> Connector 1, 1 -> Connector 2
    slot = 0; // Always zero if not using multitap
    if((ret = padPortOpen(port, slot, padBuf[1])) == 0) {
        scr_printf("padOpenPort failed: %d\n", ret);
        SleepThread();
    }

    if(!initializePad(port, slot)) {
        scr_printf("pad initalization failed!\n");
        SleepThread();
    }


now it works :)
_________________
softwares for artists on video game systems - http://www.pikilipita.com
Back to top
View user's profile Send private message Visit poster's website
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Jun 21, 2008 1:48 am    Post subject: Reply with quote

Thanks for letting us know what it was that worked. Too often you see people post that they worked out the problem, but not what the solution was, and that doesn't help anyone.
Back to top
View user's profile Send private message AIM Address
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