GMS 2 Testing a script for controllers (request)

PlayerOne

Member
I have been creating a script that detects certain controller brands (Xbox, Playstation, etc) that would change the in-game button prompts when detected. The problem is I have only one controller that works and I was hoping some here would test to see if their controller(s) would check to see if the proper button layouts would be displayed on screen when plugged in.

I'm aware that certain controllers aren't compatible and 3rd party programs such as DS4 Windows can give off the wrong controller types in game maker.


Right now I'm in the early stages in developing this and any feedback is appreciated.


Code:
_gamepad=gamepad_get_description(0); // <<< Gets gamepad information
_flag=-1

// Controller types (1D Array)
gamepad_device[0]="PLAYSTATION"
gamepad_device[1]="Xbox"



if !gamepad_is_connected(0) 
{
_flag=-1 // <<< Reset when no controller is found in port 0
}
else
{
  
   for (var i = 0; i<array_length_1d(gamepad_device); i++) // <<< Loop through 1D array to find controller type
   {
    
      if string_pos(gamepad_device[i], _gamepad) != 0 && _flag=-1 // <<< Conditions
      {
      _flag=gamepad_device[i] // <<< Set _flag to device
      }
  
   }

}


Code:
//DRAW GUI:


//DEBUG

draw_text(25,25, "_gamepad_type  " + string(_gamepad))
draw_text(25,50, "_gamepad_find  " + string(string_pos("Xbox", _gamepad)))
//draw_text(25,75, "_flag  " + string(_flag))



switch(_flag)
{
  
  
  
case -1:
draw_text(25,100,"W")
draw_text(25,125,"A")
draw_text(25,150,"S")
draw_text(25,175,"D")
break;
  
case "Xbox":
draw_text(25,100,"Y")
draw_text(25,125,"X")
draw_text(25,150,"A")
draw_text(25,175,"B")
break;      

case "PLAYSTATION":
draw_text(25,100,"X")
draw_text(25,125,"SQUARE")
draw_text(25,150,"CIRCLE")
draw_text(25,175,"TRIANGLE")
break;  

}
 
Top