The above video goes away if you are a member and logged in, so log in now!

 Would you like to get all the newest Gaming News fromQJ.NET in your email each day? Want to learn more about the team who brings you the QJ news?

## Analog nub controls

This is a discussion on Analog nub controls within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; How do I add diagonal checking on the analog stick using the following code? (I'm using oslib incase anyone wants ...

 Tweet
1. ## Analog nub controls

How do I add diagonal checking on the analog stick using the following code? (I'm using oslib incase anyone wants to know, but the analog stick controls are done the same for oslib and the sdk)

Code:
```int a;
//joystick
for (a=60;a<=120;a+=60)
{
if (osl_keys->analogX > a) {
//Do something
} else if (osl_keys->analogY > a) {
//Do something
} else if (osl_keys->analogX < -a) {
//Do something
} else if (osl_keys->analogY < -a) {
//Do something
} else {
//Do something when the stick isn't moved
}
}```

2. Anyone?

3. so, no one can help?

4. It's simple, check for both analog x and y at the same time. For example:
Code:
```int a;
//joystick
for (a=60;a<=120;a+=60)
{
if (osl_keys->analogX > a && osl_keys->analogY > a) {
//Do something
} else {
//Do something when the stick isn't moved
}
}```
Little question... What is the use of the for statement here?

5. Originally Posted by Percival
It's simple, check for both analog x and y at the same time. For example:
Code:
```int a;
//joystick
for (a=60;a<=120;a+=60)
{
if (osl_keys->analogX > a && osl_keys->analogY > a) {
//Do something
} else {
//Do something when the stick isn't moved
}
}```
Little question... What is the use of the for statement here?
That doesn't work. I'm going to try this one way that uses switches though.
also, the for helps calculate the where the nub is at and where it can go.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

All times are GMT -8. The time now is 10:54 PM.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY