| View previous topic :: View next topic |
| Author |
Message |
zydeoN
Joined: 09 May 2009 Posts: 45
|
Posted: Sun Sep 06, 2009 8:33 pm Post subject: Detecting one button input each time |
|
|
Is there a way of saying:
If(square is pressed and the others buttons are not being pressed) then...
?
Help |
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sun Sep 06, 2009 8:49 pm Post subject: |
|
|
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 |
|
 |
zydeoN
Joined: 09 May 2009 Posts: 45
|
Posted: Sun Sep 06, 2009 9:16 pm Post subject: |
|
|
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 |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Sun Sep 06, 2009 9:31 pm Post subject: |
|
|
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 |
|
 |
zydeoN
Joined: 09 May 2009 Posts: 45
|
Posted: Sun Sep 06, 2009 10:09 pm Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Mon Sep 07, 2009 12:33 pm Post subject: Re: Detecting one button input each time |
|
|
| 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 |
|
 |
zydeoN
Joined: 09 May 2009 Posts: 45
|
Posted: Tue Sep 08, 2009 12:03 am Post subject: |
|
|
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 |
|
 |
jojojoris
Joined: 30 Mar 2008 Posts: 261
|
Posted: Tue Sep 08, 2009 4:02 am Post subject: |
|
|
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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Sep 08, 2009 4:47 am Post subject: |
|
|
| 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 |
|
 |
jsharrad
Joined: 20 Oct 2005 Posts: 102
|
Posted: Tue Sep 08, 2009 10:20 am Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Tue Sep 08, 2009 1:46 pm Post subject: |
|
|
| 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 |
|
 |
SilverSpring
Joined: 27 Feb 2007 Posts: 115
|
Posted: Tue Sep 08, 2009 3:57 pm Post subject: |
|
|
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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Tue Sep 08, 2009 4:28 pm Post subject: |
|
|
| 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 |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 09, 2009 2:53 am Post subject: |
|
|
| 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 |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Wed Sep 09, 2009 3:13 am Post subject: |
|
|
| moonlight should have added it to kubridge in the very beginning, it would have been really useful. |
|
| Back to top |
|
 |
|