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 Stick

This is a discussion on Analog Stick within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; How do i take input from the PSPs analog stick? Ive seen it in a couple of sources and the ...

 Tweet
1. ## Analog Stick

How do i take input from the PSPs analog stick? Ive seen it in a couple of sources and the SDK documentation but just cant work it out

2. Code:
```if(paddata.analog[CTRL_ANALOG_Y] == 0x00) //If you push the analog upwards

if(paddata.analog[CTRL_ANALOG_Y] == 0xff) //If you push the analog downwards

if(paddata.analog[CTRL_ANALOG_X] == 0x00) //If you push the analog to the left

if(paddata.analog[CTRL_ANALOG_X] == 0xff) //If you push the analog to the right```

3. Is that it? if i just stuff that into my code will it work?

4. Just do what you normally would do when you read the pad.

5. Cool thanks alot.

6. Originally Posted by homer
Code:
```if(paddata.analog[CTRL_ANALOG_Y] == 0x00) //If you push the analog upwards

if(paddata.analog[CTRL_ANALOG_Y] == 0xff) //If you push the analog downwards

if(paddata.analog[CTRL_ANALOG_X] == 0x00) //If you push the analog to the left

if(paddata.analog[CTRL_ANALOG_X] == 0xff) //If you push the analog to the right```
Does that mean the the analog's center point is at 0x80?

7. Originally Posted by Nutterbutter
Cool thanks alot.

Yes.

The center position of the analog stick is at 0xff/2 which is 255/2. And that is 127.5 which is about 0x80.

8. I get 3 compiler errors when using your code homer,
Code:
```main.c:213: error: 'paddata' undeclared (first use in this function)
main.c:213: error: (Each undeclared identifier is reported only once
main.c:213: error: for each function it appears in.)
main.c:213: error: 'CTRL_ANALOG_Y' undeclared (first use in this function)
main.c:221: error: 'CTRL_ANALOG_X' undeclared (first use in this function)```

9. The first three errors means what it says on the tin, pspddata variable hasn't been decleared in the scope.
Code:
`sceCtrlReadBufferPositive (&pad, 1);`

The last errors may need a header file to be included or for you to #define yourself.

10. Hmm.. Seems like I've been wrong all the time.
You'll have to use:
Code:
```if(pad.Ly== 0x00) //If you push the analog upwards

if(pad.Ly == 0xff) //If you push the analog downwards

if(pad.Lx == 0x00) //If you push the analog to the left

if(pad.Lx == 0xff) //If you push the analog to the right```
Make sure you call
sceCtrlSetSamplingMode(PS P_CTRL_MODE_ANALOG);
before starting the main loop.

11. Yay, thanks!!!

One more thing, how would i handle diagonal movement?

12. just do

Code:
`if(pad.Lx>=0xff && pad.Ly>=0xff) //For right-down`

13. Perfect thanks!

#### 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 02:16 AM.

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