![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on key handling within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; so because, from what i've seen from the tutorials on this site, all psp programs have to be looped, this ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
|
so because, from what i've seen from the tutorials on this site, all psp programs have to be looped, this causes some problems with key handling.
for example, lets say i have some code, where hitting x increments the value of something variable by 1. Code:
char str[10];
int variable=0;
while(1)
{
sprintf(str, "%d", variable);
printTextScreen(3, 3, str, RGB(255, 255, 255));
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS) {
variable++;
}
flipScreen()
}
because the program is constantly looped, hitting cross once will increment the value of variable by say...4, depending on how long it takes you to press down cross and release. how can i prevent this from happening? |
|
|
|
|
|
|
#2 | |
![]() ![]() |
Quote:
__________________
Current Project: Citrus |
|
|
|
|
|
|
#4 |
![]() ![]() total-Z
|
You save the pad varaible to another variable (such as oldpad), then you say if pad and NOT oldpad (forgot the C syntax
)
__________________
牧来栠摩琠敨映汩獥PSN: youresam From Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth |
|
|
|
|
|
#6 |
![]() ![]() |
Sure.
Code:
char str[10];
int variable=0;
while(1)
{
unsigned int paddata_old = 0;
SceCtrlData paddata;
sprintf(str, "%d", variable);
printTextScreen(3, 3, str, RGB(255, 255, 255));
sceCtrlReadBufferPositive(&pad, 1);
if(paddata.Buttons != paddata_old){
if(paddata.Buttons & PSP_CTRL_CROSS) variable++;
}
flipScreen()
}
__________________
Current Project: Citrus |
|
|
|
|
|
#9 |
![]() ![]() Cool Developer
|
The best way is to make it set a value to one everytime a key is pressed, and dont allow checking for key until the key has been released, which will declare the same variable as 0 again, which will allow the key to be input again.
But listen to these guys, my idea's prolly oldschool.
__________________
Hmm... |
|
|
|
![]() |
| Tags |
| handling , key |
| Thread Tools | |
|
|