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 

Oddities using sceCtrlReadBufferPositive

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



Joined: 22 Nov 2005
Posts: 11

PostPosted: Tue Nov 22, 2005 7:04 pm    Post subject: Oddities using sceCtrlReadBufferPositive Reply with quote

Hello all, i'm relatively new to programing with the psp, although I am experienced in c and c++. Anyways, I'm just curious if anyone has encountered any stranges results when using sceCtrlReadBufferPositive() ?? Mainly the reason I've asked if i'm using this snippet of code...

Code:

SceCtrlData pad;
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);


sceCtrlReadBufferPositive(&pad, 1);
                 

                  if (pad.Buttons & PSP_CTRL_DOWN)
                     {
                     ymod = 1;
                      }                         

                  if (pad.Buttons & PSP_CTRL_RIGHT)
                     {
                      xmod = 1;
                     }

                               
                  if (pad.Buttons & PSP_CTRL_UP)
                    {   
                    ymod = -1;
                    }   
                     
                  if (pad.Buttons & PSP_CTRL_LEFT)
                     {
                      xmod = -1;
                     }

                                 

                     else
                    {
                      ymod = 0;
                      xmod = 0;                   
                     }



(I was only using brackets around all the if statements for debugging)

My problem is it will only respond to PSP_CTRL_LEFT and will respond to PSP_CTRL_UP/DOWN but only when i'm holding LEFT (ie diagonal up and diagonal down, to the left)

So whatever if statment I want to run I just change to LEFT and it will do it, and will do UP and DOWN only when im pressing it with LEFT (i'm assuming it'd do right if it COULD be pressed at the same time as left :P )

It's funky....and this is really frustrating me as it's a pretty simple procedure and according to the 15 different source files i've referenced that also use this statement, well it SHOULD all work fine :(

Any suggestions ?

Thanks in advance...

edit: Seems whichever statement I put at the bottom of the list, before else, works....but only for directions, as I can assign sceKernelExitGame(); to SQUARE with an if statement at the begining or middle or even last and it works every time...same with any other button...strange...
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Tue Nov 22, 2005 7:58 pm    Post subject: Reply with quote

This is really basic stuff
Code:

                      ymod = 0;
                      xmod = 0;                   

                     if (pad.Buttons & PSP_CTRL_DOWN)
                     {
                     ymod = 1;
                      }                         

                  if (pad.Buttons & PSP_CTRL_RIGHT)
                     {
                      xmod = 1;
                     }

                               
                  if (pad.Buttons & PSP_CTRL_UP)
                    {   
                    ymod = -1;
                    }   
                     
                  if (pad.Buttons & PSP_CTRL_LEFT)
                     {
                      xmod = -1;
                     }

         

In your example, the else only belongs to the last if, so unless the last if test is true, xmod and ymod are both set to 0.
Are you sure you copied the examples right? They didn't have 'else if' and not just 'if'?

Jim
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Shatterdome



Joined: 22 Nov 2005
Posts: 11

PostPosted: Wed Nov 23, 2005 9:02 am    Post subject: Reply with quote

durrrll....Thanks, that did it...can't beleive I didn't realise that...I think I must have moved and checked everything except those two variables...makes sence though, why change them to 0 if yadda yadda aren't true, just have them start at 0 and have things change them as they happen....the if structure was my own creating, hence the error :P hehe, anyways thank you again very muchly...
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 -> PSP 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