Any way to detect Microsoft Sidewinder Dpad?

Get help using Construct 2

Post » Wed Jun 26, 2013 9:42 am

Hi Everyone,

With chrome and Node-Webkit my game sucessfully responds to My XBox Controller, but doesnt respond at all to any direction or button press from my old Sidewinder D-Pad.
This is actually VERY important for my current client, who has commissioned me to make a game which can respond to their custom input device which has the same "button-mapping etc" as the Sidewinder.

Anyone have any clever ideas, or has had luck getting C2 games to detect input from old d-pads?

Thanks,

Mike
B
47
S
9
G
4
Posts: 421
Reputation: 6,969

Post » Wed Jun 26, 2013 9:46 am

I've been using joytokey (not sure if that'll help you). I agree it would be nice if they were automatically usable, but that's up to the browser makers to implement.
Moderator
B
92
S
32
G
33
Posts: 3,005
Reputation: 27,582

Post » Wed Jun 26, 2013 9:59 am

EDIT : I wrote this supposing that the browser detected the gamepad. If that's not the case though, I don't know how to do it.

Hey !

It just seems to be a mapping problem.
Here is some help that can be found in the runtime.js of the gamepad plugin :

     How to write a mapping:
     Construct 2 normalises all controller states to the format used by the XBox 360 controller
     on Chrome/Windows. Everything is mapped to a single 20-element array in the format:
     0: A                                        10: Left analog button
     1: B                                        11: Right analog button
     2: X                                        12: D-pad up
     3: Y                                        13: D-pad down
     4: Left shoulder button              14: D-pad left
     5: Right shoulder button              15: D-pad right
     6: Left shoulder trigger              16: Left analog X axis
     7: Right shoulder trigger          17: Left analog Y axis
     8: Back                                   18: Right analog X axis
     9: Start                                   19: Right analog Y axis
     Since different controllers return buttons and axes in a different order on different
     browsers and OSs, all combinations need to be mapped to the above 20-element array,
     called the 'c2state'.
     The buttons mapping array translates a raw button input to the c2state, and the axis
     mapping array translates a raw axis input to the range 0, 1, 2 or 3 (automatically offset
     by 16 to fit in to the c2state). However, sometimes an axis is mapped to a pair of buttons,
     e.g. for the D-pad coming up as an axis. In this case the mapping is another array
     of the buttons to map the axis to; the first element for the button when axis negative,
     and the second element for the button when the axis positive. e.g. XBox 360 on Firefox/Windows
     has axis 5 mapped to D-pad left and right; the entry is [14, 15] to map negative (left) to
     c2state 14 (D-pad left), and positive (right) to c2state 15 (D-pad right).
     If no mapping exists for an OS/browser/controller configuration, it defaults to assuming it's
     the same as Windows/Chrome/XBox 360, done by the defaultMap function.

And here is the mappings already set in this plugin :

     var win_ff_xbox360_buttons = [0, 1, 2, 3, 4, 5, 8, 9, 10, 11];
     var win_ff_xbox360_axes    = [0, 1, [7, 6], 2, 3, [14, 15], [12, 13]];
     ctrlmap["windows"]["firefox"]["xbox360"] = function (index, isAxis)
     {          
          return doControllerMapping(index, isAxis, win_ff_xbox360_buttons, win_ff_xbox360_axes);
     };
     
     var win_ff_lda_buttons = [2, 0, 1, 3, 4, 6, 5, 7, 8, 9];
     var win_ff_lda_axes    = [0, 1, 2, 3, [14, 15], [12, 13]];
     ctrlmap["windows"]["firefox"]["logitechdualaction"] = function (index, isAxis)
     {          
          return doControllerMapping(index, isAxis, win_ff_lda_buttons, win_ff_lda_axes);
     };

For a debug purpose, I would edit the runtime of controler, and add a console.log in getMapper (function(_id)) (line 132), just to see what input you get from your D-pad, and then prepare a mapping just like the two I just paste above. If your specific gamepad isn't supported, I don't see any other way.Guizmus2013-06-26 10:00:58
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Post » Wed Jun 26, 2013 10:05 am

Wow Guizmus,
you really seem to know your stuff! Unfortunately the solution you suggest is completely out of my realm of understanding. (artist, and C2 user, not by any stretch a real programmer)

B
47
S
9
G
4
Posts: 421
Reputation: 6,969

Post » Wed Jun 26, 2013 10:32 am

I'm more of a web developer than an artist, so it helps ^^
I don't have any D-Pad to test and help you though, so I would have hard time here ...
Here is a capx to test if any input is detected. Just try to use it and see if a debug appears. If so, you should try to associate an ID (displayed in the capx) to every button, and then we could try to map it with a custom plugin.
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Post » Wed Jun 26, 2013 10:54 am

Thanks Guizmus,

Unfortunately when I run it and press any directions or buttons on my control-pad, nothing shows up... would text be appearing on the screen?

-Mike
B
47
S
9
G
4
Posts: 421
Reputation: 6,969

Post » Wed Jun 26, 2013 10:57 am

@ Arima,

Thanks very much for the tip about joytokey. That does work here on my system, and will likely be a great fall-back option...but I'd rather not have to tell my client he needs to install and run additional software for it to work...so hopefully we can find an integrated solution.

cheers,
Mike
B
47
S
9
G
4
Posts: 421
Reputation: 6,969

Post » Wed Jun 26, 2013 11:06 am

@Brashmonkey
Well yes, it's only a debug panel, outputing ID for keys pressed on the gamepad. I changed the capx a little to add detection of adding/removing a gamepad. It should also give you the detected name, witch is needed for the configuration.
I hope somethings outputs this time ^^ Can't help more if it doesn't

Cya !
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Post » Wed Jun 26, 2013 11:16 am

Sadly completly no response from the Sidewinder.. But it detects everything fine from the XBox controller.

There's nothing more than can be done?

It works fine with joytokey, and the Sidewinder works fine with other games (non-C2 made) and emulators.

thanks,
-Mike
B
47
S
9
G
4
Posts: 421
Reputation: 6,969

Post » Wed Jun 26, 2013 12:27 pm

Just to be sure that your gamepad can be detected by your browser (if it's not the case, tier party software like Joy2Key are the only solution), open the console (F12) on any chrome or Firefox page, enter this code, and then connect your gamepad. If the browser detects it, it will alert "Detected", and won't do anything otherwise.
It should also, on detection, log the gamepad object, more infos on it can be usefull.
function onDetected(g) {
     window.alert("Detected");
     console.log(g);
}
     window.addEventListener("webkitgamepadconnected", onDetected, false);
     window.addEventListener("MozGamepadConnected", onDetected, false);
     window.addEventListener("gamepadconnected", onDetected, false);


(Thanks Ashley for the code, it's a copy past from the gamepad plugin)
B
17
S
8
G
4
Posts: 461
Reputation: 6,097

Next

Return to How do I....?

Who is online

Users browsing this forum: ColombageEnPLS, FabianB and 11 guests