Goombert
|
 |
Posted on: August 07, 2013, 09:12:09 am |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
Well I implemented and finished up XInput and DirectInput extensions for Windows. The constants... http://enigma-dev.org/docs/Wiki/Gamepad_constantsThe functions... http://enigma-dev.org/docs/Wiki/Input_FunctionsGreg has tested them already and we know they work, even from an emulator or virtual machine. Gamepads currently only support Xbox 360 controllers and only on Windows when you enable the XInput extension. You may connect up to 4 devices at any given time, but you should query xinput using the gamepad function provided to see the max number of gamepads you actually can connect. Everything is well documented for you guys, happy programming! Also, here is a map of the control constants (right click->View Image to enlarge)...  Here is a simple little code example that you can move an object around with the left axis and run with the letter 'A' using. // demonstrates using the 'A' button on player 1's Xbox 360 controller to move a player around the screen var spd, lhaxis, lvaxis; lhaxis = gamepad_axis_value(0, gp_axislh); lvaxis = gamepad_axis_value(0, gp_axislv); spd = sqrt(lhaxis * lhaxis + lvaxis * lvaxis) * 5; // calculate the magnitude spd += gamepad_button_check(0, gp_face1) * 15; // when player is pressing 'A' speed will increase 15 direction = point_direction(0, 0, lhaxis, lvaxis); // use the value of the left axis to determine the player direction
x += lengthdir_x(spd, direction); // use the horizontal position of the left axis to throttle horizontal speed y -= lengthdir_y(spd, direction); // use the vertical position of the left axis to throttle vertical speed
|
|
« Last Edit: August 08, 2013, 05:02:05 am by Robert B Colton »
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
Josh @ Dreamland
|
 |
Reply #1 Posted on: August 07, 2013, 10:35:03 am |
|
|
Prince of all Goldfish
 Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
Yoyo's (GM's) joystick functions suck dick. They're underpowered, inconsistent, and fuck-ugly. Use my Linux joystick functions. If any functionality is missing in my joystick functions, by all means, add more. The Linux joystick API is missing a write mechanism for such features as rumble. It's been missing this for years... So yes, feel free to add a joystick_rumble, etc.
|
|
« Last Edit: August 07, 2013, 10:42:22 am by Josh @ Dreamland »
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
|
Josh @ Dreamland
|
 |
Reply #3 Posted on: August 07, 2013, 10:44:44 am |
|
|
Prince of all Goldfish
 Location: Pittsburgh, PA, USA Joined: Feb 2008
Posts: 2950
|
I did my best to emulate their original API using my own. The functions most notable in my set are joystick_map_button and joystick_map_axis, which allow you to make a joystick button behave like an arbitrary keyboard key, or a joystick axis behave like two. No other code needs written to add joystick support for your game.
Another key difference is that my joystick numbering begins at zero, as opposed to one.
Also, please tell me you made that image yourself. If you got that from Yoyo, we're about to have serious legal issues.
And one more thing: I'd rather not use an XBox controller as our only example. Microshit's worthless-fuck toolkits only support XBox controllers. I would rather use a Logitech controller to show prospective developers, "hey, we support shit that Microsoft The Great did not bestow upon us rectally!"
|
|
« Last Edit: August 07, 2013, 11:04:30 am by Josh @ Dreamland »
|
Logged
|
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble "I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
|
|
|
Goombert
|
 |
Reply #4 Posted on: August 07, 2013, 02:19:56 pm |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
There we go, wow I am amazed, I didn't even test this before committing them and me and cheeseboy got them working right away perfectly. Have fun with the new controller support guys!
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
Goombert
|
 |
Reply #5 Posted on: August 08, 2013, 05:01:06 am |
|
|
 Location: Cappuccino, CA Joined: Jan 2013
Posts: 2991
|
*Update* Windows Joystick functions implemented fully in a DirectInput extension... https://github.com/enigma-dev/enigma-dev/pull/303
|
|
|
Logged
|
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect. 
|
|
|
forthevin
|
 |
Reply #6 Posted on: August 08, 2013, 04:06:16 pm |
|
|
 Joined: Jun 2012
Posts: 167
|
In regards to the image, it seems like a modified version from someone describing how to set up an X-box controller on Linux to play Cave Story ( http://linuxtidbits.wordpress.com/2009/11/11/doukutsu-aka-cave-story-with-an-xbox-controller/). If it turns out to be a problem, we can always take it down and replace it with another image. YoYoGames are using a different image in any case. In regards to the controller support, nicely done  .
|
|
|
Logged
|
|
|
|
|