[SDL] Problems using a joystick as a cursor

Lilith Calbridge lilith at dcccd.edu
Mon Feb 12 07:54:28 PST 2007


Could it be because the joystick is still reporting that it's not
centered after it's been moved off center once?  Have you looked at the
values that it's reporting to determine if it still gives you a small
value?
 
Lilith

>>> On 2/12/2007 at 3:02 AM, "Glenn McCord" <glenn.mccord at gmail.com>
wrote:
What I want is when the joystick is moved hard left, the cursor moves
fast to the left. If it is moved partly to the left, the cursor moves
slowly to the left. When the joystick is released, the curosr stops.

The problem is that the cursor will sometimes continue to move very
slowly in the same direction after the joystick is released.

I use:
if ( (event.jaxis.value < -2000) || (event.jaxis.value > 2000) )
{
//get roll and pitch values
}
else
{
//set roll and pitch to zero
}

and increasing the buffer to 5000 does work, but it isn't ideal
because the joystick becomes less sensitive.

So when there is an event, I 'am' getting the stick's position and
using it to move the cursor, the problem is that sometime an event is
not triggered when the joystick hits zeroish. The last recorded event
is just outside the buffer.

It would be good if I could find out the position of the joystick
without requiring an event but my understanding is that it isn't
possible.

If I give the joystick the tinyist of nudges, it stops. I may just be
asking too much and will have to use the larger buffer. But, I'm just
trying my luck at getting some alternative ideas.

In regards to programming with the PSP, the appeal for me was that I
can use SDL and OpenGL (using PSPGL), my preferred libraries. No other
handheld has 3D acceleration?

Glenn

On 2/12/07, Bill Kendrick <nbs at sonic.net> wrote:
> On Mon, Feb 12, 2007 at 12:11:44AM +1300, Glenn McCord wrote:
> > I have a question about using the joystick as a cursor because I
> > intend to use it on the PSP.
> <snip>
> > What makes this interesting is that when the joystick is still,
but
> > not in a neutral position, the cursor should still be moving.
>
> So why not just keep moving it, until it DOES return to neutral?
>
> e.g., when you receive an event, set some variables that record
> the stick's position.  Then use THOSE variables, rather than the
> events (which only come in during changes, it sounds like).
>
>
> Admittedly, haven't touched a PSP in quite a few months (sadly,
> didn't sund like a very interesting gaming platform...) so I can't
> remember what the joystick does, or what it feels like.
> (Compared to, say, a Nintendo NES pad or Atari 2600 stick :) )
>
> -bill1
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org 
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org 
>
_______________________________________________
SDL mailing list
SDL at lists.libsdl.org 
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20070212/b4565225/attachment.html 


More information about the SDL mailing list