The Daily Click ::. Forums ::. Klik Coding Help ::. How to configure a game to use a joypad
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
30th January, 2015 at 30/01/2015 23:14:20 -

so i have a game im working on that uses the arrow keys for movement, z for jump, x for shoot, and a,s, and d for skills, i would like to set it up so if you plug in a controller it lets you use that instead. i dont exactly need a set controls thing, i just want it to detect if theres a controller and auto set the buttons. anyone know how to do this in a simple manor? ive had way to many requests from my testers for joypad control for my latest game i working on.

 
[Game design makes my brain feel like its gonna explode.]

nim



Registered
  17/05/2002
Points
  7234
31st January, 2015 at 31/01/2015 06:40:18 -

There is a Joypad object. There's also an Xbox 360 object if you have Fusion 2.5. Both of these objects have a "Joypad is connected" condition which works well.

 
//

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
31st January, 2015 at 31/01/2015 20:16:55 -

is there an example anywhere? i cant seem to figure it out lol. ive never messed around with joypad controls

 
[Game design makes my brain feel like its gonna explode.]

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
3rd February, 2015 at 03/02/2015 18:15:50 -

It's not very complicated. You'll just need to test for specific axis and button-presses by ID much like testing for specific keypress events on a keyboard. So long as you have a controller plugged in, it should be pretty easy to 'guess and test' until you can figure out axis values and button IDs.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
5th February, 2015 at 05/02/2015 20:10:34 -

appreciate it! thats what i ended up doing, seems to work great, and the game is tons easier for a lot of people with a controller.

 
[Game design makes my brain feel like its gonna explode.]

Dr James 2



Registered
  17/02/2015 13:10:14
Points
  64
17th February, 2015 at 17/02/2015 13:29:40 -

I'm working on this at the moment! I'm trying to build one of those Fusion extensions (not an extension-extension), you know the sort... I wanted to make something I could drop into any project and just point an object to it and have it work. I'm hoping to get it fixed up (just working on double-tap right now) and then I'll tidy it up for public release. It uses the Joystick 2, Ini, and Control X objects.

It supports easy remapping of any axis, repeating (for menus), up to 16 players, returns axis movements as a percentage (no matter the raw values the axis uses), has a little flag for toggling between a keyboard and controller. Not sure when it'll be ready. I'm making a game with it so it'll no doubt be tweaked as it goes along.

Background: controllers are the bane of my existence. I didn't think many people used them so when I released a game with controller support I had to fight for ages to get them working right, for a twin-stick shooter.

 
n/a

nim



Registered
  17/05/2002
Points
  7234
17th February, 2015 at 17/02/2015 14:56:04 -

That would be incredibly useful. MMF/Fusion really needs some definitive "widgets" like this, that solve common problems.

Joypad support is something I've been wrestling with recently, too (hence my recent plea on Twitter!) I think I've got something reasonable now by combining the Joypad object and the Xbox360 object, although I don't have access to a lot of non-360 joypads to test it out. I was hoping to be able to bundle this code up and release it (it's actually based on Fifth's engine) but the code has turned into some kind of awful frankenstein mess that I doubt it'd be useful for anyone.

 
//

Dr James 2



Registered
  17/02/2015 13:10:14
Points
  64
17th February, 2015 at 17/02/2015 15:03:52 -

Nim! Yeah it was actually your tweet that made me think of this place!

And yeah Widget, thats what I was looking for

Wake uses both the Joypad 2 and Xbox object to get controllers working but it's a bit messy too. That's why I finally decided to sit down and work out a system that was perfect for my needs.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click