Jump to content


Photo

Sinazxinput - Xbox360 Gamepad Support


  • Please log in to reply
134 replies to this topic

#1 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 11 January 2008 - 12:16 AM

Author's note: After a few reports of this extension working just fine, I decided to re-continue it. I appreciate the responses and support. I had initially been worried that this extension would have issues on certain machines and wanted to debug it with the rest of my directX10 based extensions. But, this one doesn't have any bugs, apparently. YAY! So continue to download and use.

This is an XInput wrapper for Game Maker. Now you can use the full functionality of those xBox 360 controllers and other XInput devices. (except for headset and jewel support... I'll get to that.)

What's it got?
At the moment, it supports xBox 360 game pads and other XInput standard controllers.
*Triggers are mapped to separate axes!
*Rumble support!
*Buttons!
*Up to the XInput standard of 4 controllers supported.
*Sample .gmk included for your learning enjoyment.

Posted Image

DOWNLOAD
SinazXInput v1.1
*DInput support added (wrapping GM's joystick functions to work within the same XInput API.) This will NOT magically make your DInput controllers rumble.
*IMPORTANT! This release is not tested. I don't have a DInput only controller to test it with. I would be greatly appreciative if some people would try this out with their legacy devices and tell me if it works, while reporting bugs. If you test it, respond with a message here telling me what make and model controller you used, and whether it worked out alright or if you had any problems. READ THE HELP FILE CAREFULLY! Use the return from xConnected[n] to determine if the controller you are testing with is DInput, XInput, or both-- I really only care about the DInput only controllers.
*Face button constants have changed to xFaceX, xFaceY, xFaceA, and xFaceB.
*Also, DInput only constants have been added. They were coordinated to the xBox360's button layout via the DInput joystick status thinger in Windows control panel. That shouldn't make a difference - button 1 should always end up button 1, etc.
*Added xPOV() which returns similar to joystick_pov() only reoriented to GM's screen angles.
*MORE IMPORTANT STUFF! If you want a stable production ready XInput library wrapper, use v1.0 below. Beta v1.1 is not meant for use with released software yet!

STABLE DOWNLOAD
*Discontinued*

PS: Using the sample .gmk
Push buttons... der ;)

The analog sticks show pressed and release events.
The triggers control the rumble motors.
The shoulder buttons lock/unlock rumble motors at their current value.
The 'start' and 'back' buttons switch between active controllers.
IF you get confused, the ring of lights will remind you which controller is currently active.
  • 0

#2 mindbreaker

mindbreaker

    GMC Member

  • New Member
  • 457 posts

Posted 11 January 2008 - 01:39 AM

not that hard to make but somebody has to do it ;)
good job!
  • 0

#3 mrsmes

mrsmes

    GMC Member

  • GMC Member
  • 991 posts
  • Version:GM:Studio

Posted 11 January 2008 - 02:10 AM

true and it is very good and some body else made a library for checking buttons and axis angles of analog sticks and allowed performing actions afterwards how ever use both the library and the extension together in one extension you can also check if the gamer moved the left thumb stick to the left or right or forwards or backwards or any possible angle as well as wether it was pushed so giving it a full xbox controller functionality except for all the other stuff you are working on i found this library in the library aection apparently it's file name is xbox_controller.lib so when you look around for it just check for the tags: xbox, controller
and the category: Libraries
not sure about the topic or it's number though...
  • 0

#4 Yourself

Yourself

    The Ultimate Pronoun

  • Retired Staff
  • 7343 posts
  • Version:Unknown

Posted 11 January 2008 - 02:55 AM

not that hard to make but somebody has to do it ;)
good job!

<{POST_SNAPBACK}>


Why do you think it isn't hard? It can't be done in GML only (the XBox controller has special triggers).
  • 0

#5 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 11 January 2008 - 07:22 AM

true and it is very good and some body else made a library for checking buttons and axis angles of analog sticks and allowed performing actions afterwards how ever use both the library and the extension together in one extension you can also check if the gamer moved the left thumb stick to the left or right or forwards or backwards or any possible angle as well as wether it was pushed so giving it a full xbox controller functionality except for all the other stuff you are working on i found this library in the library aection apparently it's file name is xbox_controller.lib so when you look around for it just check for the tags: xbox, controller
and the category: Libraries
not sure about the topic or it's number though...

<{POST_SNAPBACK}>

er... well... it's not really necessary since this does it all.

The big thing is the separate trigger returns and the rumble support.

GM uses DirectInput natively which doesn't give us access to the rumble motors, and treats the two triggers as a single axis.

This extension is a wrapper of a .dll that handles the main functions of the XInput libraries.

Edited by Sinaz, 11 January 2008 - 07:24 AM.

  • 0

#6 Tarik

Tarik

    GMC Member

  • GMC Member
  • 2483 posts
  • Version:GM:Studio

Posted 11 January 2008 - 07:22 AM

Great work, Sinaz. This'll be a great addition to Game Maker in the coming years.

Keep it up.
  • 0

#7 TheOmega

TheOmega

    GMC Member

  • New Member
  • 88 posts

Posted 11 January 2008 - 07:51 AM

not that hard to make but somebody has to do it <_<
good job!

<{POST_SNAPBACK}>


Why do you think it isn't hard? It can't be done in GML only (the XBox controller has special triggers).

<{POST_SNAPBACK}>


not hard because there are some Xinput or XNA DLLs you can easly calling in a DLL for GM.

Nice thinking and now it has been done for GM!
  • 0

#8 mindbreaker

mindbreaker

    GMC Member

  • New Member
  • 457 posts

Posted 11 January 2008 - 03:27 PM

Why do you think it isn't hard?

everybody with some C++ skills can make it ..., just include the write files and trigger the correct events...
I have also made it for my (C++ writen) engine and it isn't that hard...

it can't be done in GML only (the XBox controller has special triggers).

true, but there are a lot of things that gm can't handle (no offence :GM122: it is a great program <_< ) but it doesn't mean that there are extremly hard to make in other programming languages....
  • 0

#9 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 11 January 2008 - 04:33 PM

Why do you think it isn't hard?

everybody with some C++ skills can make it ..., just include the write files and trigger the correct events...
I have also made it for my (C++ writen) engine and it isn't that hard...

it can't be done in GML only (the XBox controller has special triggers).

true, but there are a lot of things that gm can't handle (no offence :GM122: it is a great program <_< ) but it doesn't mean that there are extremly hard to make in other programming languages....

<{POST_SNAPBACK}>


True, the dll and extension were pretty easy to make. The thing is, nobody had made a decent one for GM yet, and I, especially, needed XInput controls for my current project.

The dll itself is written in C, and there is a lot of cleverness in the way I designed the API for GM-- it's not just straight function calls to the dll, I tried to make it easy and intuitive for GM users, sharing the conventions that GM's native Direct Input API has (like the direction of the Y axes are reversed for your convience, and everything is normalized to values in the -1 to 1, or 0 to 1 range, built in arrays, etc.) I also took the time to write quick and efficient pressed/released functions since GM native DirectInput lacks them. And there's a comprehensive help file. Again, not difficult, but I could have just made the GEX for myself and be done with it. Instead I took an entire day out of my schedule to create something the GMC could make use of.

The main issue, though, is that now there is an XInput GEX for Game Maker, free to use, and with regular support. Use it or don't. But a lot of GMCers have been demanding XInput support indirectly by demanding proper trigger support, and especially rumble capabilities. And, finally, here it is.

Edited by Sinaz, 11 January 2008 - 06:23 PM.

  • 0

#10 mindbreaker

mindbreaker

    GMC Member

  • New Member
  • 457 posts

Posted 12 January 2008 - 12:28 AM

The thing is, nobody had made a decent one for GM yet

I know :P see my first post :P

Edited by mindbreaker, 12 January 2008 - 12:28 AM.

  • 0

#11 Nailog

Nailog

    GMC Member

  • Retired Staff
  • 603 posts
  • Version:Unknown

Posted 12 January 2008 - 12:57 AM

Absolutely wonderful, Sinaz. This will be very handy. Many thanks. :P
  • 0

#12 thegreatgaveno@mac.com

thegreatgaveno@mac.com

    GMC Member

  • New Member
  • 178 posts

Posted 13 January 2008 - 04:51 AM

Could you maybe add functionality to check the hardware directly? To work similar to the keyboard_check_direct function built into gamemaker. It would help me out quite a bit, but I'd be able to do without it.

I might include this in my game if I find a way to switch around my code effectively. If I do, I'll add you to the credits.
-Gavin
  • 0

#13 xot

xot

    media multimixer

  • Global Moderators
  • 4653 posts
  • Version:GM:Studio

Posted 13 January 2008 - 08:18 AM

Hey, you figured out the triggers! Well done!
  • 0

#14 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 13 January 2008 - 08:21 AM

Could you maybe add functionality to check the hardware directly? To work similar to the keyboard_check_direct function built into gamemaker. It would help me out quite a bit, but I'd be able to do without it.

I might include this in my game if I find a way to switch around my code effectively. If I do, I'll add you to the credits.
-Gavin

<{POST_SNAPBACK}>

I don't understand what you need... You can't just use xButtonDown()?

Thing is, the hardware returns a state that is a bit array, and my extension masks the array to give you the button states. It also handles the pressed and released states.

Although, I can hint to you that if you want the raw bit array from the state data, use the xButtonState[0...3] global variable. It's not documented, but it holds the button bit array. You'll have to refer to the DirectX SDK for the proper bits to mask (but you'll just be rewriting code I've already given you.)

Anyway, all the functions should work properly regardless of what window has focus... just like the keyboard_check_direct() function.
  • 0

#15 FredFredrickson

FredFredrickson

    Artist

  • Global Moderators
  • 9196 posts
  • Version:GM8

Posted 13 January 2008 - 08:22 AM

This looks pretty neat Sinaz. I'll have to play around with it a bit. It'd be interesting to see if a game like Hover Tank 3D is possible to play with two thumbsticks... :)

Edited by FredFredrickson, 13 January 2008 - 08:23 AM.

  • 0

#16 Dragonos

Dragonos

    Multimedia Pro

  • New Member
  • 357 posts

Posted 16 January 2008 - 12:44 AM

Looks good but ignores my gamecube controller that works in GM regularly.
  • 0

#17 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 16 January 2008 - 02:42 AM

Looks good but ignores my gamecube controller that works in GM regularly.

<{POST_SNAPBACK}>

Your GameCube controller is likely DirectInput only-- in which case, you have to stick with using the built in DInput features of GM.

It's an inevitable drawback. Only XInput controllers will respond to the XInput libraries.

So now I know that DInput controllers won't enumerate on the extension.

What you have to do is poll the controllers and determine which controllers are DInput and which are XInput, and have a contingency for each. Before I hear any complaining, there is no way around that-- it's how all developers using DirectX have to support new and legacy controllers, no matter the engine or API they are using.

I will look into automating this process for the extension in the near future.

[edit]
On second thought, it would be a whole lot easier for the programmer to determine whether the joystick is D or XInput.

Simply check if the joystick is detected with joystick_exists(); if true, then the joystick is at least DInput. Then check if it is detected with xUpdateState() and looking at the value of xConnected[]. If that is false, then the controller is just a DInput controller (like your GameCube controller) and will only respond to GM's standard DInput functions. If it is true, then the controller is an XInput controller and can use either the XInput library or the Dinput functions in standard GM.

Both the GM DInput functions and the XInput library can be used side by side.
[/edit]

Edited by Sinaz, 16 January 2008 - 04:11 AM.

  • 0

#18 13bgarli

13bgarli

    GMC Member

  • New Member
  • 177 posts

Posted 18 January 2008 - 01:55 AM

I like this
  • 0

#19 Timmeh

Timmeh

    GMC Member

  • New Member
  • 358 posts

Posted 18 January 2008 - 04:11 AM

This is awsome... I have a cord that allows me to plug my laptop into a tv screen, between that and this I might as well be developing for the 360 with Game Maker :lol:

Tim
  • 0

#20 Sinaz

Sinaz

    MCP Killer

  • Retired Staff
  • 2751 posts
  • Version:GM8

Posted 19 January 2008 - 09:19 AM

I just put up a new version. It is BETA! I need people to test it with legacy DInput only controllers. Read the first post for info. Please read it carefully.

I took GM's DInput functions and wrapped them into API as well... so now you can use all the SINAZxInput functions and variables to interface with your DInput only controllers.

[edit]
It just occurred to me that GM only supports two controllers, and I didnt make provisions for that in the extension... so DInput only joysticks will not register as joysticks 2 and 3.
[/edit]

Edited by Sinaz, 19 January 2008 - 09:58 AM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users