0 Favourites

Any way to detect Microsoft Sidewinder Dpad?

  • 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

  • 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.

  • 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.

  • 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)

  • 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.

  • 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

  • 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

  • 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 !

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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)

  • Enter the code where? I'm not web developer... I dont understand how to do this, or in what part of the browser's interface.

    thanks,

    Mike

  • Sorry, you have to enter this in the Javascript console. On chrome, F12 will make the debugger show up, and there is a tab "Console" in it. There, just enter the code I gave you, and submit it (enter). Then, plug in your controler. If it's detected (i.e. if the browser gets a hand on it and gives it to your page), there will be an alert and some debug in the console.

    If not, you will have to use third party software as javascript would then be unable to access the controller at all.

  • Hi again, Still no luck...I bring up the console, but can't sucessfully paste your code anywhere...at least not without an error message. I have no idea what I'm doing....and if construct 2 is already using this same code to check for the control pad and it doesnt detect any presses, or when its removed or plugged in, then I guess my only bet is to tell the client to use joytokey for now and try and convinced the web developers to make sure more controllers are supported.

    thanks again.

    Mike

  • Well, last try ? I put up an HTML page executing exactly the code I linked you before, the test is still the same : once the page is open, plug in the controller.

    It's not exactly the same code as in the plugin. The plugin checks lots of thinks, like what browser it is, what gamepad, if it knows how to map it, ... (witch could explain that the sample capx didn't trigger anything, if C2 ignores unknown gamepads). The function I used is only here to tell if your controller is usable by the browser, if it's detected when plugged in.

  • I did so with both chrome and firefox AND with the Sidewinder and the Xbox controller and nothing ever happens...is a message supposed o appear somewhere? if so, where? It should definately work at least with the XBox controller but I see nothing. :(

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
132 17,744
LordCrafterMC's avatar
LordCrafterMC
Unread hot topic
67 46,051
Pedro Tavares's avatar
Pedro Tavares
Unread hot topic
41 1,466
KTML5's avatar
KTML5