blockdude11
Member
I am having an issue with getting useable inputs from a Nintendo Switch Pro Controller. Win7, GMS2 2.3.1. It's plugged in via USB.
First off, the working bits. I have this in the Async System event for my control object, which I found from some other threads. It works great - I can see the discovery case firing in the debugger and also I added a debug printout to show the button mapping. That mapping is down below.
That mapping looks really normal and believable (it's the default and I never tried changing it), but unfortunately once the controller is connected all the inputs look wrong. I noticed that it connects as device ID 4 which I think is the first DirectInput device.
I wrote some code to print out all the button/axis/hat data and I get a jittering mess of zeroes and ones flipping constantly.
Many buttons seem to be actually subdivisions of "Axis0". For example if I press the home button I see Axis0 move to 0.25, and if I press the capture button I see it move to 0.13. Pressing the two together is enough to break the movement threshold in my code and my character starts walking! So at least it's kind of working!
Other buttons seem to have no effect at all. And there's still the matter of about half of these so-called buttons flipping state from 0 to 1 and back every frame or few frames.
Has anyone encountered this? How would I even go about remapping this? Is there a way to access the raw data (0s and 1s) coming from the device and try to figure out what it's saying?
Thanks in advance.
First off, the working bits. I have this in the Async System event for my control object, which I found from some other threads. It works great - I can see the discovery case firing in the debugger and also I added a debug printout to show the button mapping. That mapping is down below.
Code:
switch(async_load[? "event_type"])
{
case "gamepad discovered":
var padnew = async_load[? "pad_index"];
if global.playerInput[0] == noone
{
global.playerInput[0] = padnew;
switch ( gamepad_get_description(global.playerInput[0])) {
case "Nintendo Switch Pro Controller":
global.playerDeviceType[0] = inputType.ProController;
show_debug_message(gamepad_get_mapping(global.playerInput[0]));
break;
}
}
break;
case "gamepad lost":
var padlost = async_load[? "pad_index"];
if global.playerInput[0] == padlost
{
global.playerInput[0] = noone;
global.playerDeviceType[0] = inputType.Keyboard;
}
break;
}
Code:
7e050920000000000000504944564944,Nintendo Switch Pro Controller,platform:Windows,a:b0,b:b1,x:b2,y:b3,leftshoulder:b4,rightshoulder:b5,lefttrigger:b6,righttrigger:b7,guide:b12,start:b13,leftstick:b10,rightstick:b11,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,
I wrote some code to print out all the button/axis/hat data and I get a jittering mess of zeroes and ones flipping constantly.
GML:
for ( var i = 0; i < 32; i++ ) {
str += ( i mod 4 ) ? " " : "\n";
str += string(i) + ": " + string( gamepad_button_check( global.playerInput[0], i ) );
}
for ( var i = 0; i < 10; i++ ) {
str += "\n Axis" + string(i) + ": " + string( gamepad_axis_value( global.playerInput[0], i ) );
}
for ( var i = 0; i < 4; i++ ) {
str += "\n Hat" + string(i) + ": " + string( gamepad_hat_value( global.playerInput[0], i ) );
}
Many buttons seem to be actually subdivisions of "Axis0". For example if I press the home button I see Axis0 move to 0.25, and if I press the capture button I see it move to 0.13. Pressing the two together is enough to break the movement threshold in my code and my character starts walking! So at least it's kind of working!
Other buttons seem to have no effect at all. And there's still the matter of about half of these so-called buttons flipping state from 0 to 1 and back every frame or few frames.
Has anyone encountered this? How would I even go about remapping this? Is there a way to access the raw data (0s and 1s) coming from the device and try to figure out what it's saying?
Thanks in advance.