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 

Detecting one button input each time

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



Joined: 09 May 2009
Posts: 45

PostPosted: Sun Sep 06, 2009 8:33 pm    Post subject: Detecting one button input each time Reply with quote

Is there a way of saying:
If(square is pressed and the others buttons are not being pressed) then...
?

Help
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Sun Sep 06, 2009 8:49 pm    Post subject: Reply with quote

Yeah, the value of pad.button will be unique if only square is pressed.
Look at the value of pad.buttons.
_________________
If not actually, then potentially.
Back to top
View user's profile Send private message
zydeoN



Joined: 09 May 2009
Posts: 45

PostPosted: Sun Sep 06, 2009 9:16 pm    Post subject: Reply with quote

but the problem is that if i only put:
if(square pressed) {...}

and if im pressing square and say triangle the code inside the brackets of the if statement is processed anyway and im pressing triangle too...
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Sun Sep 06, 2009 9:31 pm    Post subject: Reply with quote

dont use & but do it this way.

Code:
if(pad.buttons == PSP_CTRL_BUTTON_SQUARE){
    //do something
}


I think this should be it or something like this.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
zydeoN



Joined: 09 May 2009
Posts: 45

PostPosted: Sun Sep 06, 2009 10:09 pm    Post subject: Reply with quote

It doesnt work jojoris
EDIT: Solved. I just had to do:
if(pad.Buttons & PSP_CTRL_RTRIGGER && !(pad.Buttons & PSP_CTRL_SQUARE)) {...}

and this would only be processed if the user didnt press square..
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Sep 07, 2009 12:33 pm    Post subject: Re: Detecting one button input each time Reply with quote

zydeoN wrote:
Is there a way of saying:
If(square is pressed and the others buttons are not being pressed) then...
?

Help


This logic is very different from your solution of if Only Square is NOT pressed.
Back to top
View user's profile Send private message
zydeoN



Joined: 09 May 2009
Posts: 45

PostPosted: Tue Sep 08, 2009 12:03 am    Post subject: Reply with quote

I will just had to add this !(pad.Buttons & ...) to all the buttons.
Btw, why isnt this working:

int pad_ = 0x100000;
if(pad.Buttons & pad_) {...}

The inside of the brackets isnt being processed. I know this uses a bit mask, but they say Buttons is unsigned int. So the problem here could be the type of pad_. What could it be ?

EDIT: just had to use u32 instead of int.
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Sep 08, 2009 4:02 am    Post subject: Reply with quote

actuallt u32 is the same as unsigned int

Code:

u32 i = 0;
unsigned int = 0;

both the same.
_________________
Code:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Sep 08, 2009 4:47 am    Post subject: Reply with quote

zydeoN wrote:
I will just had to add this !(pad.Buttons & ...) to all the buttons.
Btw, why isnt this working:

int pad_ = 0x100000;
if(pad.Buttons & pad_) {...}

The inside of the brackets isnt being processed. I know this uses a bit mask, but they say Buttons is unsigned int. So the problem here could be the type of pad_. What could it be ?

EDIT: just had to use u32 instead of int.


Anything above 0x8000 is kernel only. You won't ever see 0x100000 at user level. That's why there's a kernel PRX floating around to let user mode homebrew check the HOME button.
Back to top
View user's profile Send private message AIM Address
jsharrad



Joined: 20 Oct 2005
Posts: 102

PostPosted: Tue Sep 08, 2009 10:20 am    Post subject: Reply with quote

huh? isn't u32 pad_ = 0x100000 just the same as doing u32 pad_ = 1048576 ?

Unless you were thinking of memory addresses ... &0x100000
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Sep 08, 2009 1:46 pm    Post subject: Reply with quote

J.F. wrote:
zydeoN wrote:
I will just had to add this !(pad.Buttons & ...) to all the buttons.
Btw, why isnt this working:

int pad_ = 0x100000;
if(pad.Buttons & pad_) {...}

The inside of the brackets isnt being processed. I know this uses a bit mask, but they say Buttons is unsigned int. So the problem here could be the type of pad_. What could it be ?

EDIT: just had to use u32 instead of int.


Anything above 0x8000 is kernel only. You won't ever see 0x100000 at user level. That's why there's a kernel PRX floating around to let user mode homebrew check the HOME button.


I don't understand what you're trying to say here. I doubt the mask values of the buttons are related to any of the memory addresses (and whether or not those buttons are readable under user or kernel mode; Those buttons must be permanently masked by software in the syscall version of the functions, thats all). Anything above 0x7FFFFFFF is kernel (the upper 2GiB of the 4GiB of memory addresses the CPU can access).

Unless I've completely missed a point somewhere =.=*
Back to top
View user's profile Send private message
SilverSpring



Joined: 27 Feb 2007
Posts: 115

PostPosted: Tue Sep 08, 2009 3:57 pm    Post subject: Reply with quote

He is saying the button masks above 0x8000 (ie. the volume up/down, note, screen, etc. buttons) can only be read in kernel mode. Only the the normal keypad buttons (of which are masked to values under 0x8000) are readable when under user mode. It has nothing to do with memory addresses.
_________________
PSP PRX LibDocs
Back to top
View user's profile Send private message Visit poster's website
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Tue Sep 08, 2009 4:28 pm    Post subject: Reply with quote

SilverSpring wrote:
He is saying the button masks above 0x8000 (ie. the volume up/down, note, screen, etc. buttons) can only be read in kernel mode. Only the the normal keypad buttons (of which are masked to values under 0x8000) are readable when under user mode. It has nothing to do with memory addresses.


Ok that way... They just got lucky they could split it up like that since the PSP has a limited number of buttons :/
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed Sep 09, 2009 2:53 am    Post subject: Reply with quote

SilverSpring wrote:
He is saying the button masks above 0x8000 (ie. the volume up/down, note, screen, etc. buttons) can only be read in kernel mode. Only the the normal keypad buttons (of which are masked to values under 0x8000) are readable when under user mode. It has nothing to do with memory addresses.


What he said. Sorry if that confused people. I meant the values that represent individual buttons in the .Buttons field. Those are defined in the pspctrl.h file. 0x0001 to 0x8000 are "normal" buttons like X, O, LTRIGGER, START, etc. Anything from 0x10000 on up are the "extra" buttons on the PSP like HOME, VOLUME_UP, NOTE, etc.

Every once in a while, you'll see someone complain that their loop waiting on the NOTE button doesn't work, and they're confused since old homebrew had no trouble with that. The old homebrew ran in kernel mode, so NOTE was visible. New homebrew is usually user mode, and so it cannot see that button and the loop waits forever.
Back to top
View user's profile Send private message AIM Address
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Wed Sep 09, 2009 3:13 am    Post subject: Reply with quote

moonlight should have added it to kubridge in the very beginning, it would have been really useful.
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