Path: chuka.playstation.co.uk!news From: "Martin Keates" Newsgroups: scee.yaroze.freetalk.english Subject: Re: Controller Questions Date: Tue, 25 Jun 2002 12:41:46 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 42 Message-ID: References: NNTP-Posting-Host: modem-1409.monkey.dialup.pol.co.uk X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 > I know the Tutorial shows how to do things, but seeing as it uses the > different pad.h file it confussed me, i was wondering if there was anyway to > detect the controllers using the method below ? well im still playing so i > may infact understand more before you get a chance to reply. > > u_long PadRead(void) > { > return(~(*(bb0+3) | *(bb0+2) << 8 | *(bb1+3) << 16 | *(bb1+2) << 24)); > } Yes, you can detect the controllers by looking at the 2nd byte of each buffer (i.e. bb0+1 and bb1+1). You would need to #define the controllers (as in cntrl.h) and then you could do: switch (*(bb0+1)>>4) { case MOUSE: . case ANALOG: . } Should work, but I've not tried doing it that way. You can look at *(bb0) and *(bb1) to see if any controller is connected (0xff: not connected, 0x00: something connected). Basically the two methods (pad.h and cntrl.h) are working on the same buffers (buffer1 and bb0 are the same pointer, as are buffer2 and bb1). All cntrl.h is doing is defining structures that make using the buffers a bit easier (so instead of accessing e.g. *(bb0+1) you look at buffer1->type). Oh, and: > Oops - that should be: > switch (controller1->type << 4) maybe my brain will engage soon, but the shift should be >>, not << Martin.