Jump to content


Photo

Sdl_Enablekey Repeat For Joystick


  • Please log in to reply
5 replies to this topic

#1 captainchris

captainchris

    Member

  • Members
  • PipPip
  • 12 posts

Posted 28 February 2012 - 09:24 PM

Hi everybody,

I've a problem , with my CAANOO stick.I will a function similar to SDL_EnableKey repeat for joystick, to disable event when stick is pushed.

#2 Pickle

Pickle

    Mega GP Mania

  • X-treme Team
  • 4074 posts
  • Gender:Male
  • Location:Detroit, Michigan

Posted 29 February 2012 - 03:01 PM

I've a problem , with my CAANOO stick.I will a function similar to SDL_EnableKey repeat for joystick, to disable event when stick is pushed.


Sorry but your question is very badly written. I think you want the same function for joystick events as SDL_EnableKey does for keyboard events. A quick look at the SDL api nothing like this exists.
I think the only option is to remember the last sent value and create your own timer to control how you use that value.

#3 captainchris

captainchris

    Member

  • Members
  • PipPip
  • 12 posts

Posted 29 February 2012 - 05:23 PM

Yes pickle , i know, my english is very bad ;)
did you have an exmple of timer to control joystick event ??
Thank's.

#4 Pickle

Pickle

    Mega GP Mania

  • X-treme Team
  • 4074 posts
  • Gender:Male
  • Location:Detroit, Michigan

Posted 29 February 2012 - 05:36 PM

Yes pickle , i know, my english is very bad ;)
did you have an exmple of timer to control joystick event ??
Thank's.


well a simple way would something like this (in rough pseudo code):


IF sdl button pressed event detected THEN /* Should only occur once if the position is stable, if the stick changes then this will be triggered quite often */
   button = pressed
   timer = 0 /* This makes sure you act instantly on the first press */
ELSE IF sdl button released event detected THEN
   button = released
    timer = 0
ENDIF

IF button is pressed and timer is 0 THEN
     do logic
     set timer = 100 /* force 100 ticks until logic occurs again */
ENDIF

timer--

Som other info that may be useful
http://www.gp32x.com...-controls-info/

#5 captainchris

captainchris

    Member

  • Members
  • PipPip
  • 12 posts

Posted 02 March 2012 - 05:47 PM

Hi Pickle,

Thank you for your reply.I see your post to control Info.it's possible to disable event repeating with

if(eventState.jaxis.axis == 0)
{

positionX[eventState.jaxis.which] = eventState.jaxis.value;
}
...

Thx

#6 Pickle

Pickle

    Mega GP Mania

  • X-treme Team
  • 4074 posts
  • Gender:Male
  • Location:Detroit, Michigan

Posted 02 March 2012 - 06:56 PM

Hi Pickle,

Thank you for your reply.I see your post to control Info.it's possible to disable event repeating with

if(eventState.jaxis.axis == 0)
{

positionX[eventState.jaxis.which] = eventState.jaxis.value;
}
...

Thx


Ok im a bit confused, i thought you wanted a way to enable a repeat of the joystick value not disable anything. I also dont see how that snippet of code you posted really has any effect on controlling how events are handled.
All that code says is that if a joystick event says it occured on the X-axis store in a array that is sorted by the joystick index. In no way does it control when or how often you store or act on a event.