Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by freeman91

I am using this plugin to implement gamepad support to my game: https://github.com/ansimuz/BitWars/blob/master/lib/plugins/gamepad.js

It works great but the problem is that only player 1 works and I want the game to be controlled by any connected gamepad, is there anything I can edit so that the plugin ignores the controller (i.e. player1 or player2...). So that a button on each connected controller will trigger the 'jump' for example.

8 years ago by lunarcloud

Give me a week and I'll fix up and release my ImpactJS plugin for my gamepad library.
https://github.com/lunarcloud/gameinputjs

8 years ago by lunarcloud

Actually, it shouldn't be too hard to modify that existing gamepad plugin and instead of using "get the first gamepad" function, to make it get all gamepads and check them all...

8 years ago by freeman91

If it is not that hard, Could you tell me what exactly should I modify in the gamepad.js?

8 years ago by lunarcloud

Okay, so I looked at it much closer. There's a bit of work to be done for multiplayer/multiple gamepad support.
I'm going to have to think about it and come up with the right way to implement it with my library.
However, I'm in no rush right now.

Here's my thoughts:
1) For your purposes, just change pollGamepad to accept the gamepad as a parameter and where it's being called (Game inject run function) run a loop through all the gamepads and call pollGamepad on each one
2) to do it "right" aka for multiplayer purposes and not just "all gamepads are player 1", it takes a bit more of a dynamic solution

8 years ago by freeman91

Could you make those edits you mentioned in 1) to the gamepad.js and share them please I tried but JavaScript is not my forte and no gamepads work now.

I can even help you with your need for a multiplayer gamepad.js plugin I found this: https://gist.github.com/zachstronaut/d2bf6db425bfc169e4e1

8 years ago by lunarcloud

Okay, so that code you just linked DOES what I was suggesting.
You just need to change their example to fire all the same event.

Like this:
ig.input.bind( ig.GAMEPAD1.FACE_1, 'shoot');
ig.input.bind( ig.GAMEPAD2.FACE_1, 'shoot');
ig.input.bind( ig.GAMEPAD3.FACE_1, 'shoot');
ig.input.bind( ig.GAMEPAD4.FACE_1, 'shoot');

8 years ago by lunarcloud

I want to thank you for sharing that code with me. It led to some needed improvements to my own gamepad library/plugin.
Page 1 of 1
« first « previous next › last »