Sdl_Enablekey Repeat For Joystick


captainchris

Still Fresh
Joined
Feb 12, 2012
Messages
12
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.
 
captainchris said:
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.
 
Last edited by a moderator:
Yes pickle , i know, my english is very bad ;)
did you have an exmple of timer to control joystick event ??
Thank's.
 
captainchris said:
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):

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.de/board/index.php?/topic/56370-caanoo-controls-info/
 
Last edited by a moderator:
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
 
captainchris said:
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.
 
Last edited by a moderator:
Back