Navigating Menu With Joystick (Gamepad)

B

BlakeNBitz

Guest
Ok this is hard for me to explain but please bear with me as I am still a noob.....here's the situation:

I successfully am able to navigate my main menu one key press at a time (using up or down arrows). I try to add gamepad controls for the menu navigation as well, but it just goes crazy. If I hold the JS up or down it blazes through the selections w/o stopping until there is zero JS input. I want to move the joystick up or down for each selection each time. I dont want to be able to just hold the joystick down.

Is there a way to easily enable and then disable the JS input in order to navigate the menu one at a time? Any suggestions are greatly appreciated.

IDK if this is needed info, but heres my code for the arrow navigation
Code:
//event press enter


//Action:
switch (selection)
{
    case 0:
    audio_stop_sound(snd_Lvl2);
    room_goto_next();
    break;
   
    case 1:
    script_execute(scr_loadgame);
     audio_stop_sound(snd_Lvl2);
   
    break;
   
     case 2:
    room_goto(rm_Level10);
    break;
   
     case 3:
    game_end();
    break;
}


//Event: press up

//action:
if (selection > 0 )
{
    selection --;
}
 else {
    selection = array_length_1d(menu) -1
    }


//Event: press down

//action:

if (selection <array_length_1d(menu)-1)
{
    selection ++;
}   else {
    selection = 0;
    }
 
There are a few ways you could do so, but they all involve not checking for the joystick directly in the menu. Let the joystick set a variable that mimics its ability to be true. Set this variable to true immediately, then on the next Step set it to false and have another variable act as a timer that will allow the first variable to be true again. Rinse and repeat, and disable both variables upon a joystick release. Or, using a single variable, set it to the timer still and have a specific value act as the true state.
 
B

BlakeNBitz

Guest
Yeah I was trying to think of a way to do a true/false for the joystick, I'm just new to programming so it's taking a little bit of time to piece together.

So are you saying that I should do something like making a new object and set it as like a joystick controller ?
 
Nah, just create some variables to represent the four directions, as well as a script to actually handle all the timers and such. Set this script in any menu event prior to the actual menu code.
 
B

BlakeNBitz

Guest
Nah, just create some variables to represent the four directions, as well as a script to actually handle all the timers and such. Set this script in any menu event prior to the actual menu code.
OK sounds simple enough I'll give this a try tomorrow when I'm at my computer. Thanks!
 
Top