Jump to content


Photo

Gamepad Extended - Version 1.1


  • Please log in to reply
51 replies to this topic

#1 Tahnok

Tahnok

    Friendly Madman

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

Posted 01 June 2008 - 12:18 PM

I finally got tired enough of some of the limitations of GM's built-in gamepad support, so I created this extension. It has the following features:
  • Able to check if a button was pressed or released
  • Analog inputs and POV controls act as buttons, with adjustable dead zone, so all inputs can be handled with the same code
  • Checks whether a joystick exists before attempting to check it's state, since checking non-existent gamepads will slow games down
  • Supports two joysticks
  • Can automatically disable buttons that are being pressed on setup, so they don't interfere with other checks
  • Can suspend the game until a gamepad input is pressed, or until all are released
  • Can automatically find a pressed button on the gamepad
  • Replaces a few other basic functions, but checks whether the gamepad exists first
Download Gamepad Extended

Read the extension's help file for details on how to use it. Also be sure to check out the example, as it demonstrates many of the functions.

Enjoy,
Tahnok

Edited by Tahnok, 02 June 2008 - 04:17 AM.

  • 3

gmc_signature.png


#2 Reshure

Reshure

    Reshure

  • New Member
  • 320 posts

Posted 01 June 2008 - 04:51 PM

Awesome! This is exactly what I need.

Thank you very much!
  • 0

#3 Tahnok

Tahnok

    Friendly Madman

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

Posted 02 June 2008 - 04:16 AM

OK, I played around with this extension a little more today and found a couple bugs. Apparently, it's possible for the gamepad to change it's state mid-step, which was sometimes causing issues with the press and release functions. I've updated it to now poll all the inputs at the start of the step, so things are a little more predictable.

I also fixed a dead zone issue with the second controller and changed some things around so that updates are now done automatically (though, now you have to manually call the initialization script). See the help file for a full list of fixes/updates. The main link has been updated.
  • 0

gmc_signature.png


#4 IsmAvatar

IsmAvatar

    Good Samaritan

  • GMC Member
  • 2411 posts
  • Version:GM8

Posted 02 June 2008 - 05:08 AM

For a second, I almost thought someone had finally extended upon my GameMaker Notepad (GamePad), but no. lol.

Looks promising, although I wouldn't have much of a use for it.
  • 1
Posted Image LateralGM is an IDE for editing GM files on Linux, Mac, and Windows.
We also house the GM File Format Documentation and other projects of that nature.
IsmAvatar.com | Examples | Scripts | Particles | DLLs | Credit Me
Email | Registered

#5 Reshure

Reshure

    Reshure

  • New Member
  • 320 posts

Posted 02 June 2008 - 01:54 PM

I wanted to say thanks again!

It works perfectly :blink:
  • 0

#6 agustusx

agustusx

    GMC Member

  • New Member
  • 27 posts
  • Version:Unknown

Posted 04 June 2008 - 12:41 AM

Thanks a lot this helped me out a great deal :P I can finally used my crusty old sidewiders POV as directional control, same for my 360 controller.

Again thanks for sharing.
  • 0

#7 8-BitTonberry

8-BitTonberry

    GMC Member

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

Posted 13 June 2008 - 02:48 PM

Hey, I'm wondering if there is anyway to return the analogs direction in degrees.

Is this possible to do with this extension or at all?

Ex: Aiming a turret in the direction you're holding.
  • 0
8-BitTonberry.png

#8 Chaos In a Can

Chaos In a Can

    GMC Member

  • New Member
  • 70 posts

Posted 13 June 2008 - 03:40 PM

Hey, I'm wondering if there is anyway to return the analogs direction in degrees.

Is this possible to do with this extension or at all?

Ex: Aiming a turret in the direction you're holding.



Use point_direction() on the x,y position of the joystick.
//Try this:
direction = point_direction(0, 0, joystick_xpos(1), joystick_ypos(1));

//...or if that doesn't work, try this:
direction = point_direction(0, 0, joystick_xpos(1), -joystick_ypos(1));

  • 0

#9 8-BitTonberry

8-BitTonberry

    GMC Member

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

Posted 13 June 2008 - 04:10 PM

Sweet! That worked perfectly!

Is there any way to check how far the joystick is actually being pressed?
I know it probably says that in the help, but I can't find it.

And one final thing...

Since each joystick is considered 4 buttons(13, 14, 15, 16 in this case), is there any way to check if it is being pressed at all without checking all of those?

Thanks again!
  • 0
8-BitTonberry.png

#10 Tahnok

Tahnok

    Friendly Madman

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

Posted 13 June 2008 - 09:53 PM

Sweet! That worked perfectly!

Is there any way to check how far the joystick is actually being pressed?
I know it probably says that in the help, but I can't find it.

And one final thing...

Since each joystick is considered 4 buttons(13, 14, 15, 16 in this case), is there any way to check if it is being pressed at all without checking all of those?

Thanks again!

GM can natively check how far you're pressing a specific direction. Look in the help manual under GML > User Interaction > The Joystick. You will find functions such as joystick_xpos(id) and joystick_ypos(id), which return between -1 and 1 (0 being centered, most of the time).

No, you have to check each input individually. I suppose I could add a function eventually to check whether all analog stick are released or if any are pressed, but that would kind of defeat the purpose of this extension (making all gamepad code universal, no matter what types of controls a gamepad may have).
  • 0

gmc_signature.png


#11 Warmachine

Warmachine

    GMC Member

  • GMC Member
  • 97 posts

Posted 15 June 2008 - 10:09 PM

Would this actually work with the Xbox360 Pad? I know that some other example shows rumble support etc.
  • 0

#12 Tahnok

Tahnok

    Friendly Madman

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

Posted 16 June 2008 - 06:34 AM

Would this actually work with the Xbox360 Pad? I know that some other example shows rumble support etc.

If you install drivers for the Xbox 360 gamepad to turn it into a normal windows direct input pad then it should. As far as I know though, it wont work out of the box without the drivers (which is why Sinaz created his extension, which I believe supports it regardless of drivers).

This doesn't have any sort of rumble support, especially for the 360 gamepad. That would require a dll, and this extension is just a wrapper for GM's internal functions to make them easier to use. Sindarin has made the only working force feedback dll for direct input pads and I believe Sinaz's dll supports rumble for the 360 gamepad.

BTW, I don't own a 360 controller to test with.
  • 0

gmc_signature.png


#13 mory

mory

    GMC Member

  • New Member
  • 26 posts

Posted 19 June 2008 - 03:05 PM

well done. tnx

I need somthing Important. Vibration

could you ?
  • 0

#14 Tahnok

Tahnok

    Friendly Madman

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

Posted 20 June 2008 - 05:22 AM

well done. tnx

I need somthing Important. Vibration

could you ?

No, I can't, but that doesn't matter, someone already has:

http://gmc.yoyogames...howtopic=379111

I was going to put his dll into an extension, but ran into some issues and haven't had a chance to look at it again. It's a fairly easy dll to use though.
  • 0

gmc_signature.png


#15 mory

mory

    GMC Member

  • New Member
  • 26 posts

Posted 29 June 2008 - 02:03 PM

well done. tnx

I need somthing Important. Vibration

could you ?

No, I can't, but that doesn't matter, someone already has:

http://gmc.yoyogames...howtopic=379111

I was going to put his dll into an extension, but ran into some issues and haven't had a chance to look at it again. It's a fairly easy dll to use though.


  • 0

#16 bradshaw

bradshaw

    GMC Member

  • GMC Member
  • 44 posts

Posted 07 July 2008 - 12:43 AM

well done. tnx

I need somthing Important. Vibration

could you ?

No, I can't, but that doesn't matter, someone already has:

http://gmc.yoyogames...howtopic=379111

I was going to put his dll into an extension, but ran into some issues and haven't had a chance to look at it again. It's a fairly easy dll to use though.



Thanks. Perfect.
  • 0

#17 justin123

justin123

    GMC Member

  • New Member
  • 124 posts

Posted 24 July 2008 - 04:29 PM

gamepad_check_button_pressed() doesn't seem to work.
  • 0

SADE Website DOWN - Link To WIP
C++ Sonic Engine 20% Complete

#18 Tahnok

Tahnok

    Friendly Madman

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

Posted 24 July 2008 - 09:26 PM

gamepad_check_button_pressed() doesn't seem to work.

Read the help file. There are two reasons listed in there that could be causing the problem. gamepad_init() has to be called before any other function. Also, make sure any objects calling the press and release checks have a depth between -10,000,000 and 10,000,000.
  • 0

gmc_signature.png


#19 justin123

justin123

    GMC Member

  • New Member
  • 124 posts

Posted 24 July 2008 - 10:45 PM

gamepad_check_button_pressed() doesn't seem to work.

Read the help file. There are two reasons listed in there that could be causing the problem. gamepad_init() has to be called before any other function. Also, make sure any objects calling the press and release checks have a depth between -10,000,000 and 10,000,000.


I still can't get it to work, but i'll give you that part of the code I used:

The create event in objSetup - depth=0
//Declare Variablesgamepad_init()global.button_a_pressed=0;global.button_b_pressed=0;global.button_x_pressed=0;global.button_y_pressed=0;global.button_action_pressed=0;

Now the step event for the same object
global.button_a_pressed=gamepad_check_button_pressed(1,2);global.button_b_pressed=gamepad_check_button_pressed(1,3);global.button_x_pressed=gamepad_check_button_pressed(1,4);global.button_y_pressed=gamepad_check_button_pressed(1,1);global.button_action_pressed=gamepad_check_button_pressed(1,9);

This is what's in the object using those variables. Its depth is also equal to zero.
key_action_pressed  =   global.button_b_pressed;//I used the same variables for gamepad and keyboard.

Note that the keyboard and gamepads are not used at the same time. global.input_config="gamepad" or ="keyboard".
All of the button_pressed functions are always equal to zero for some reason.

Edited by justin123, 24 July 2008 - 10:49 PM.

  • 0

SADE Website DOWN - Link To WIP
C++ Sonic Engine 20% Complete

#20 Tahnok

Tahnok

    Friendly Madman

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

Posted 24 July 2008 - 11:17 PM

I just tried it and it seems to be working just fine. Are you sure you're not just missing the incredibly short press of the button? Try putting this line after that last line of code you gave me:

if(key_action_pressed = true) { show_message("button pressed"); }

If that shows a message then the code is working just fine.

Are you sure you're not mistaking gamepad_check_button_pressed() for gamepad_check_button()? Just like GM's mouse functions, the former will only return true only when the button is pressed down the first time (for a single frame). The latter will return true the whole time the button is held.
  • 0

gmc_signature.png


#21 justin123

justin123

    GMC Member

  • New Member
  • 124 posts

Posted 25 July 2008 - 12:12 AM

I just tried it and it seems to be working just fine. Are you sure you're not just missing the incredibly short press of the button? Try putting this line after that last line of code you gave me:

if(key_action_pressed = true) { show_message("button pressed"); }

If that shows a message then the code is working just fine.

Are you sure you're not mistaking gamepad_check_button_pressed() for gamepad_check_button()? Just like GM's mouse functions, the former will only return true only when the button is pressed down the first time (for a single frame). The latter will return true the whole time the button is held.


I tried this :
if(gamepad_check_button_pressed(1,3)== true) { show_message("button pressed"); }

It didn't working my game, but it worked when i tested it in a new game file.
  • 0

SADE Website DOWN - Link To WIP
C++ Sonic Engine 20% Complete

#22 justin123

justin123

    GMC Member

  • New Member
  • 124 posts

Posted 25 July 2008 - 12:22 AM

Problem Solved!!!!!!!!!!

gamepad_check_button_pressed() don't work in begin step. B)
  • 0

SADE Website DOWN - Link To WIP
C++ Sonic Engine 20% Complete

#23 Tahnok

Tahnok

    Friendly Madman

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

Posted 25 July 2008 - 12:46 AM

Problem Solved!!!!!!!!!!

gamepad_check_button_pressed() don't work in begin step. B)

That's odd. I thought I tried that kind of stuff. I'll test it a bit later and see if I can figure it out.
  • 0

gmc_signature.png


#24 songs

songs

    GMC Member

  • New Member
  • 54 posts

Posted 12 August 2008 - 02:33 PM

i cant download the extension its not there ?
  • 0

#25 Tahnok

Tahnok

    Friendly Madman

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

Posted 12 August 2008 - 07:50 PM

i cant download the extension its not there ?

Try the download again a little later. It's actually one of the few that's being hosted by 64D, not my website that has gone down recently due to money issues. So if it's down just wait for 64D to come back online (it appears to be fine right now).
  • 0

gmc_signature.png


#26 duven60

duven60

    GMC Member

  • New Member
  • 316 posts

Posted 10 September 2008 - 10:09 PM

I just wanted o know if this exstention would help with the Xbox 360 trigger problem with GM or not..
I red the help file and couldn't figure it out..
  • 0

#27 slayer 64

slayer 64

    Slayer of gingers

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

Posted 12 September 2008 - 12:14 AM

nice extension.

i would use it if it could vibrate the game controller.
  • 0

5y5rs3d.pngfg0UQNL.png


#28 mrsmes

mrsmes

    GMC Member

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

Posted 12 September 2008 - 08:17 AM

that would be rather handy, so long as that function is implemented we will be seeing many new emulators, and even with a rumble pack, to vibrate the controller, and use it as if you r playing the game on the console just with a computer access skin on startup, and accessing it, and a computer cover up over the circuit boards and slightly 1% slower on bootup but even the consoles themselves get like that at times. So it would really give it a lagging console feel.
so long as you edit the way the machine starts up, and it, has those emulators all in their to play practically any kind of game, and yeah what ever now enjoy, it's as close to having as many consoles in one as you can possibly ever get.
few questions though how, does the xbox controller, or xbox 360, controller get attached to the computer, and what about the GII-MOTE with the WII like look, and all, connect with a blue-tooth phone like device and well I heard you can use that kind of controller on your computer to browse through your files and all that, and your desktop, I heard about it on YouTube, although if you wanted to it would require some hacking, into your own computer.

Edited by mrsmes, 12 September 2008 - 08:23 AM.

  • 0

Assuming I helped you out in a questions and answers topic won't you return the favour by helping me with one my coding problems, or recommend some one who can chat to me over pms about helping and how to overcome my obstacles, after all lets just say I did help you or them or many people with similar problems, in that topic.

Here i have a topic for those of you struggling with type writer text and mugshots in your games especially if it is a rpg see the link below for more info

http://gmc.yoyogames...howtopic=619103

almost no code needed, only uses two events.

click here for the l8est version of feed the alien pizza, it has some major polished up features.


#29 Jakyl11

Jakyl11

    GMC Member

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

Posted 24 September 2008 - 04:35 AM

ok I got it to download fine and the gmk opens fine but the extension will not install says an error has occured...
  • 0

#30 Harvest Moon

Harvest Moon

    GMC Member

  • New Member
  • 158 posts

Posted 14 October 2008 - 07:54 PM

Something is wrong with the gamepad_get_dead_zone(id) code. When I try to write: dead_zone = gamepad_get_dead_zone(1), then I get this error message:

___________________________________________
FATAL ERROR in
action number 1
of  Step Event
for object mouse_c:

COMPILATION ERROR in code action
Error in code at line 8:
	   dead_zone = gamepad_get_dead_zone(1);

at position 38: Wrong number of arguments to function or script.

I think it's because in Game Maker it says (in the help box on the bottom of the code window) just: gamepad_get_dead_zone(). It doesn't say that it needs an argument. If I try to just type (), Game Maker says:

___________________________________________
ERROR in
action number 1
of  Step Event
for object mouse_c:

In extension function gamepad_get_dead_zone:
In extension function gamepad_exists:
Error in code at line 2:
   return gamepadExists[argument0 - 1];

at position 23: Negative array index

because I haven't written the gamepad id. Can you solve this, please?
  • 0

#31 DarkFlame

DarkFlame

    GMB Member...wtf?

  • GMC Member
  • 2167 posts

Posted 03 December 2008 - 08:11 AM

I like it,...i might open up an old version of Alexander the Grape and attempt to implement this GEX
  • 0

#32 Ryan-Phoenixan

Ryan-Phoenixan

    GMC Member

  • New Member
  • 211 posts

Posted 10 December 2008 - 11:55 PM

I just wanted o know if this exstention would help with the Xbox 360 trigger problem with GM or not..
I red the help file and couldn't figure it out..

It does, since the axis are counted as buttons.

Though in GM, if you want to use the triggers using the default functions, it's actually under the Z Axis.
  • 0

#33 willfox

willfox

    GMC Member

  • GMC Member
  • 21 posts

Posted 18 December 2008 - 10:54 PM

weird, this extention used to work like a charm. Now it doesn't work at all. What's wrong?
  • 0

#34 willfox

willfox

    GMC Member

  • GMC Member
  • 21 posts

Posted 19 December 2008 - 03:33 PM

I got it to work again, this code is good but I think it would be more effective to use this as a re-map to the keyboard.

keyboard_set_map(key1,key2)

maybe you could set a key from the gamepad to the keyboard
keyboard_set_map(key1,gamepadbutton) ?
or something like that.
If you could add that it would help me a lot.
  • 0

#35 X_marks_the_ed

X_marks_the_ed

    GMC Member

  • New Member
  • 14 posts

Posted 19 December 2008 - 10:15 PM

QUESTION NOW VOID - PROBLEM SOLVED
-------

Okay, I'm doing something wrong.
The only use of the extension is in the step event of object: Pl2select.

if gamepad_check_button_pressed(1,11) == true
//Left
	{
	event_user(0)
	}
if gamepad_check_button_pressed(2,12) == true
//Up
	{
	event_user(1)
	}
if gamepad_check_button_pressed(2,13) == true
//Right
	{
	event_user(2)
	}
if gamepad_check_button_pressed(2,14) == true
//Down
	{
	event_user(3)
	}

When I hit any of those buttons, nothing happens.

Edited by X_marks_the_ed, 19 December 2008 - 10:27 PM.

  • 0

#36 DarkFlame

DarkFlame

    GMB Member...wtf?

  • GMC Member
  • 2167 posts

Posted 20 December 2008 - 01:38 AM

You did initiate the extension in the create event?
  • 0

#37 someguy999

someguy999

    GMC Member

  • New Member
  • 12 posts

Posted 23 January 2009 - 11:39 PM

The download link doesn't work.

However this does sound very useful, anyone got a working link by chance?

Edit: Nevermind, the link works now.

Edited by someguy999, 25 January 2009 - 02:15 AM.

  • 0

#38 RavenCrow

RavenCrow

    Corvus

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

Posted 19 July 2009 - 05:03 AM

the link dosnt work.... i would like to have a look at this. Dose anyone have a working dl link, or different example ;)
  • 0

#39 Ryan-Phoenixan

Ryan-Phoenixan

    GMC Member

  • New Member
  • 211 posts

Posted 26 July 2009 - 12:51 AM

I hope bumping is permitted here, but I also found another bug in this extension, that is, if you are going to release another version of this. The released and pressed functions don't seem to work proper, since I tested this out with a screenshot key/button. Of course, keyboard_check_pressed() works just fine, and only works again once the key's been released and pressed again. The pressed function doesn't seem to behave this way, and always returns true for as long as the button is held down.

Next, the released function, I tested with a variable that is set back to false when the button is released. After releasing the button, the variable never returned back to false.

I hope this isn't completely dead, since it was such a good extension.
  • 0

#40 jobro

jobro

    GMC Member

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

Posted 26 July 2009 - 12:14 PM

The download link is dead.
  • 0

Marketplace.png


#41 Mayhem Games

Mayhem Games

    Proud Kiwi

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

Posted 03 August 2009 - 05:52 AM

Soooo cool! Im using it with my ps3 controller!
  • 0

For a long time it puzzled me how something so expensive, so leading edge, could be so useless, and then it occurred to me that a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are, in short, a dangerously perfect match. ~ Bill Bryson


#42 songs

songs

    GMC Member

  • New Member
  • 54 posts

Posted 07 August 2009 - 03:47 PM

i got this error

plz help it will do me good..

COMPILATION ERROR in extension package Gamepad Extended
Error in code at line 5:
   globalvar test;

at position 16: Variable name expected.

NM i had other stuff named test is all...

Edited by songs, 07 August 2009 - 04:34 PM.

  • 0

#43 Kold Monster

Kold Monster

    GMC Member

  • GMC Member
  • 20 posts

Posted 02 May 2010 - 08:50 PM

This is awesome! I've just needed the extension to make my future projects. You know this extension is not just useful for GML, but also for D&D using the "Test expression" branch. It's recommended to use in the Step event. This is so wonderful!! It supports all gamepads! I like that :D !!

Edited by Kold Monster, 02 May 2010 - 08:52 PM.

  • 0
Gamers! GJ6 is here! Are you ready for the new experience of gaming?
Posted Image

#44 theg721

theg721

    G Dawg

  • GMC Member
  • 1959 posts
  • Version:GM8

Posted 02 May 2010 - 08:58 PM

Soooo cool! Im using it with my ps3 controller!

So what! I've been playing RuneScape with my PS3 controller for ages without this. That's better than playing a half-finished GM game with one (no offense). Anywho, @OP - I'll download soon, I can't download for some reason.

Edited by theg721, 02 May 2010 - 08:59 PM.

  • 0

#45 F4LL0UT

F4LL0UT

    GMC Member

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

Posted 27 June 2011 - 09:11 PM

****, it's exactly what I need but the help file doesn't work (maybe it's not compatible with GM 8.1?). Could someone somehow separately post the helpfile or something?
  • 0

#46 Someone447

Someone447

    GMC Member

  • GMC Member
  • 14 posts
  • Version:GM8

Posted 12 February 2012 - 09:42 PM

I know this thread is old but I really need help with it.
I want to add a second player to my game. How do I do that?
  • 0

#47 J-Mac

J-Mac

    GMC Member

  • New Member
  • 4 posts
  • Version:GM8

Posted 26 August 2012 - 06:14 AM

I'm probably going to sound like a noob, but am I correct in thinking I can only use this with a Pro Edition?
  • 0

#48 Lightang3l

Lightang3l

    GMC Member

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

Posted 30 August 2012 - 10:26 AM

I sent you a PM. Please try to help me with my problem.

I'll post here too if anyone else is having this issue:

gamepad_check_button_pressed() works in old objects but not in new ones... I think it has something to do with object_index or something...
All the old objects in the gmk work like a charm but all the recently created one do not...

Very good extension... but please help me i can't progress since I can't create new objects that can use the gamepad_check_button_pressed() function :(
  • 0

New_Sig_small.jpg

Newsig.jpg


#49 janlucvd

janlucvd

    GMC Member

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

Posted 10 September 2012 - 01:05 PM

Cool!

How can this gamepad work with GM: Studio?
  • 0

#50 TPFunGame

TPFunGame

    GMC Member

  • New Member
  • 2 posts
  • Version:GM8.1

Posted 08 April 2013 - 05:03 PM

Every time, when my "Explorer" created (every Level!), I must calibrate the controller! How I make it other? Every Level are the Setup-Screen and in an other object, it doesn´t work! Help!


Edited by TPFunGame, 02 May 2013 - 03:52 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users