Controller Input Not Working

O

Otyugra

Guest
So I have an old controller made specifically for playing games on computers (I suppose Windows computers in particular, considering my computer runs windows) and I've used it before to play Super Crate Box (a game made with GameMaker) and the controller worked fine. When I tried to program the controller input to function identical to a left or right key press, the character does not move when I press left or right on my Dpad. The controller has the same number of buttons for all types as an Xbox 360 control, except a few of the buttons are arranged slightly different.

Here is code that I used in obj_GamePad for Event: System:
Code:
show_debug_message("Event = " + async_load[? "event_type"]);       
// Debug code so you can see which event has been...
show_debug_message("Pad = " + string(async_load[? "pad_index"]));   
// ...triggered and the pad associated with it.

switch(async_load[? "event_type"])             
// Parse the async_load map to see which event has been triggered
{
case "gamepad discovered":                     
// A game pad has been discovered
    AJoystick = true
    var pad = async_load[? "pad_index"];
    ThePad = pad
    // Get the pad index value from the async_load map
    gamepad_set_axis_deadzone(pad, 0.5);       
    // Set the "deadzone" for the axis
    gamepad_set_button_threshold(pad, 0.1);   
    // Set the "threshold" for the triggers
    break;
case "gamepad lost":                           
// Gamepad has been removed or otherwise disabled
    AJoystick = false
    var pad = async_load[? "pad_index"];
    ThePad = pad
    // Get the pad index
    break;
}
ThePad is a global variable, you'll see it again later.

Here is code for the player (obj_Sikk) in event: Step:
Code:
//moving left and right
if gamepad_button_check_pressed(ThePad, gp_padl)
   {
   sprite_index = spr_SikkD2;
   left = 1;
   PressLe = 1;
   hspeed = 1;
   }
if gamepad_button_check_pressed(ThePad, gp_padr)
   {
   sprite_index = spr_SikkD;
   PressRi = 1;
   left = 0;
   hspeed = 1;
   }
//Releasing left or right
if gamepad_button_check_released(ThePad, gp_padl)
   {
   PressLe = 0;
   if PressRi == 0
      {
      hspeed = 0
      sprite_index = spr_SikkA2
      }
   position_empty(self.x, self.y+1)
      {
      if vspeed == 0
         {
         vspeed = 0.5
         gravity_direction = 270
         gravity = 0.7
         }
      }
   }
if gamepad_button_check_released(ThePad, gp_padr)
   {
   PressRi = 0;
   if PressLe == 0
      {
      hspeed = 0
      sprite_index = spr_SikkA
      }
   position_empty(x, y+1)
      {
      if vspeed == 0
         {
         vspeed = 0.5
         gravity_direction = 270
         gravity = 0.7
         }
      }
   }
Pay little attention to variables like "PressRi" as they are triggers for certain events. The content within a button press or release is the same as for a key press or release.

Thank you for helping.
 

obscene

Member
First are you sure your controller is being detected? Do you get a debug message telling you it connected? If not, it's possible your old controller is a joystick and not a gamepad.

Sidenote: Both your left and right commands set hspeed to 1.

Your code is a bit convoluted but appears it should at least do something. To might toss in some keyboad commands to make sure it works correctly.
 
O

Otyugra

Guest
First are you sure your controller is being detected? Do you get a debug message telling you it connected? If not, it's possible your old controller is a joystick and not a gamepad.

Sidenote: Both your left and right commands set hspeed to 1.

Your code is a bit convoluted but appears it should at least do something. To might toss in some keyboard commands to make sure it works correctly.
Your right, I think the controller is actually a joystick rather than a gamepad since I've never gotten a debug message. I know there is joystick code, but is that supported anymore?
 

Gamebot

Member
It does according to the manual last time I checked. But only two if I remember correctly. Though they change things often....If you go to the manual your self go to the search bar type in joystick, as I just checked. This should give you what you need.
 
Top