Ok, my doubt is about joysticks and axis

Well, first i want say im not a high advanced skilled programmer,
so…probaly my doubt is very simple, i guess

The problem is that i cant get a diagonal whit the axis, i didnt figure out
how do that, cause SDL just get axi x or axi y, so how i do to get the both?

=) too stupid?

2008/5/20 Mason Wheeler :> Subscribe to the list to get messages. To post to the list, just send an

email to the list’s mailing address, like you just did. It’s that simple.

----- Original Message ----
From: Giuliano Pieta <@Giuliano_Pieta>
To: A list for developers using the SDL library. (includes SDL-announce) <
sdl at lists.libsdl.org>
Sent: Tuesday, May 20, 2008 4:53:26 PM
Subject: Re: [SDL] i want post on the list

lol
geeses, that mainlist is very confuse, how i do to post a doubt and see the
feedback i get?

.>"

2008/5/20 Leo Cabrera :

Uhh… you just posted. =)

Giuliano Pieta wrote:

my email is @Giuliano_Pieta mailto:Giuliano_Pieta


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


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Are you talking about the hat switch on the joystick or gamepad?

This should work

case SDL_JOYHATMOTION:

               if(sdlEvent->jhat.which == 0)

               {

                    if(sdlEvent->jhat.value == SDL_HAT_UP)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_DOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFT)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHT)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_CENTERED)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHTUP)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHTDOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFTDOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFTUP)

                    {

                    }

               }

               break;_____  

From: sdl-bounces@lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org] On
Behalf Of Giuliano Pieta
Sent: Tuesday, May 20, 2008 8:14 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: [SDL] Ok, my doubt is about joysticks and axis…

Well, first i want say im not a high advanced skilled programmer,
so…probaly my doubt is very simple, i guess

The problem is that i cant get a diagonal whit the axis, i didnt figure out
how do that, cause SDL just get axi x or axi y, so how i do to get the both?

=) too stupid?

2008/5/20 Mason Wheeler :

Subscribe to the list to get messages. To post to the list, just send an
email to the list’s mailing address, like you just did. It’s that simple.

----- Original Message -----
From: yksnimus@gmail.com (Giuliano Pieta)
To: A list for developers using the SDL library. (includes SDL-announce)

Sent: Tuesday, May 20, 2008 4:53:26 PM
Subject: Re: [SDL] i want post on the list

lol
geeses, that mainlist is very confuse, how i do to post a doubt and see the
feedback i get?

.>"

2008/5/20 Leo Cabrera :

Uhh… you just posted. =)

Giuliano Pieta wrote:

my email is yksnimus at gmail.com <mailto:yksnimus at gmail.com>


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


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

That is like i did, but i did whit the axis…but the axis just have axi x
or axi y, and the values…
im talking about the analog axis of gamepad ( my english its not so good, im
not sure what is a hat, but i want get the diagonals of the analog axis, not
of the hat…)

here my code:

*case SDL_JOYAXISMOTION:

            if( event_test.jaxis.axis==1){  //axi Y
                if(event_test.jaxis.value<-1){// pressing up
                    backg_img->clip_rect.y = backg_img->clip_rect.y-5;
                }
                else if(event_test.jaxis.value>-1){//pressing down
                    backg_img->clip_rect.y =

backg_img->clip_rect.y+5;//(desce +5)

                }
            }
            if( event_test.jaxis.axis==0){// axis X
                if(event_test.jaxis.value<-1){//pressing left
                    backg_img->clip_rect.x = backg_img->clip_rect.x-5;
                }
                else if(event_test.jaxis.value>-1){//pressing right
                    backg_img->clip_rect.x = backg_img->clip_rect.x+5;
                }
            }

            break;

*I just cant figure out how get axi x AND axi y since it just return one per
time…

2008/5/20 mars999 :> Are you talking about the hat switch on the joystick or gamepad?

This should work

case SDL_JOYHATMOTION:

               if(sdlEvent->jhat.which == 0)

               {

                    if(sdlEvent->jhat.value == SDL_HAT_UP)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_DOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFT)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHT)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_CENTERED)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHTUP)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_RIGHTDOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFTDOWN)

                    {

                    }

                    if(sdlEvent->jhat.value == SDL_HAT_LEFTUP)

                    {

                    }

               }

               break;

From: sdl-bounces at lists.libsdl.org [mailto:sdl-bounces at lists.libsdl.org]
*On Behalf Of *Giuliano Pieta
Sent: Tuesday, May 20, 2008 8:14 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: [SDL] Ok, my doubt is about joysticks and axis…

Well, first i want say im not a high advanced skilled programmer,
so…probaly my doubt is very simple, i guess

The problem is that i cant get a diagonal whit the axis, i didnt figure out
how do that, cause SDL just get axi x or axi y, so how i do to get the both?

=) too stupid?

2008/5/20 Mason Wheeler :

Subscribe to the list to get messages. To post to the list, just send an
email to the list’s mailing address, like you just did. It’s that simple.

----- Original Message ----
From: Giuliano Pieta <@Giuliano_Pieta>
To: A list for developers using the SDL library. (includes SDL-announce) <
sdl at lists.libsdl.org>
Sent: Tuesday, May 20, 2008 4:53:26 PM
Subject: Re: [SDL] i want post on the list

lol
geeses, that mainlist is very confuse, how i do to post a doubt and see the
feedback i get?

.>"

2008/5/20 Leo Cabrera :

Uhh… you just posted. =)

Giuliano Pieta wrote:

my email is @Giuliano_Pieta mailto:Giuliano_Pieta


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


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

I just cant figure out how get axi x AND axi y since it just return one per
time…

It seems that you get the events separately, but you have to combine
them yourself. For example, you could accumulate them in some X-Y
state variable, and process them once per frame, say.On Thu, May 22, 2008 at 1:18 AM, Giuliano Pieta wrote:


http://pphaneuf.livejournal.com/

Ah…so simple,…it worked!! tanx for the help

how i didnt figure that…

heres the code:
*…
* *case SDL_JOYAXISMOTION:

            if( event_test.jaxis.axis==1 ){ //up down
                axi_Y=event_test.jaxis.value;
            }
            else if(event_test.jaxis.axis==0 ){ //left right
                axi_X=event_test.jaxis.value;
            }

            break;

   }


    if(axi_Y < -1){
        backg_img->clip_rect.y=backg_img->clip_rect.y-5;
    }
    else if(axi_Y > -1){
        backg_img->clip_rect.y=backg_img->clip_rect.y+5;
    }

    if(axi_X < -1){
        backg_img->clip_rect.x=backg_img->clip_rect.x-5;
    }
    else if( axi_X > -1){
        backg_img->clip_rect.x=backg_img->clip_rect.x+5;
    }*

tanx =)

2008/5/22 Pierre Phaneuf :

On Thu, May 22, 2008 at 1:18 AM, Giuliano Pieta <@Giuliano_Pieta> wrote:

I just cant figure out how get axi x AND axi y since it just return one
per
time…

It seems that you get the events separately, but you have to combine
them yourself. For example, you could accumulate them in some X-Y
state variable, and process them once per frame, say.


http://pphaneuf.livejournal.com/


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org