Joystick Support

If there is something important you think is missing in the current version of ZGameEditor then you can post a feature request here!

Moderator: Moderators

Post Reply
User avatar
diki
Posts: 140
Joined: Thu Sep 11, 2008 7:53 pm
Location: GMT+1
Contact:

Joystick Support

Post by diki »

Stop me if I'm being redundant, but is Joystick/Gamepad/HID Support already a consideration? It would be rather nice to have, and complete the trio of 'most popular input methods' out there :)
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi diki,

I actually had a go at Joystick support some time ago and managed to get it to work. Though as there was no way to save ( configuration ) files back then, it would have been a crutch to use. But as file saving got implemented last week, I'll have another look at it.

K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell, I wonder if you perhaps set you ambitions too high :)

Does every game with gamepad support really need a calibrate/configuration feature with save-support? Can't we have some sort of "simpler" gamepad support first?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Well, you're right. If you're just using one analog stick ( 2 axes ) and some of the first buttons you're pretty safe across the board. However, the second analog stick as well as shoulder triggers are different joystick to joystick, not to mention d-pads .. which can be POV, a set of buttons or 2 axes. Shoulder triggers can even have different ranges, sometimes -1..1, others 0..1, or even -1..0 for one and 0..1 for the other. This is just one of those things you have to deal with when it comes to PC / Mac / Linux gaming :wink:

Here are the most important input details of a couple of Joystick's I tried out ( 360 controller using USB, others using MagicBox interfaces ). You can see that differ quite a bit .. also, don't forget that axes that aren't used by the hardware return a value of -1.

K
Attachments
Joystick.jpg
Joystick.jpg (75.03 KiB) Viewed 12882 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I see the complexities here... You've done good research Kjell :) . That Sega-controller brings back memories.
If you're just using one analog stick ( 2 axes ) and some of the first buttons you're pretty safe across the board
I think this would cover the needs for many games and would be sufficient as a first attempt at joystick-support in ZGE. What do you other guys think?
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Don't underestimate the importance of button layout. For example, if one would be creating a game with a jump and shoot button for the 360 pad, I can imagine going for jump under 1 and shoot under 3. This combination will be very annoying on the Playstation and Saturn controllers.

Anyway, it's up to the creator to decide whether or not to let players configure their button layout. It was just the reason for not pushing through on the Joystick components, since I certainly will :)

K
User avatar
diki
Posts: 140
Joined: Thu Sep 11, 2008 7:53 pm
Location: GMT+1
Contact:

Post by diki »

VilleK wrote:
If you're just using one analog stick ( 2 axes ) and some of the first buttons you're pretty safe across the board
I think this would cover the needs for many games and would be sufficient as a first attempt at joystick-support in ZGE. What do you other guys think?
hm, i guess that if you split the component into e.g. JoystickAxis and JoystickButton (each with their own field to specify which joystick to use), it would be modular enough to accomodate for almost everything; you could read a simple file & apply the settings fit for the user and his specific hardware.
(that is, of course, from someone who has no idea about implementing such things ;)
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

yeah that sounds good diki,. there are like 6 axii (x,y,z,r,u,v or some such,.) 10 or so buttons and the POV,. then you could set up for just about anything,. It would of course be nice to set it all up from an options menu in game, but if it is keep really simple some games could be done without too much fuss.
I am left handed so even on a keyboard for example I try to support a left and right handed layout WASD and ARROWS and often mirrored action keys,. and if you only have a couple buttons you can just remap them like 1,2 then 4,3, then 5,6, etc. so ppl can hoplfully find buttons that they can adjust to.
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hey jph,

Most modern platforms ( DirectX / Allegro ) support 16 joysticks with up to 8 axis, 32 buttons and 4 pov hats simultaneously. Should be plenty 8)

K
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Kjell, your original design with JoystickButton and JoystickAxis components seems like a good start. I can try to throw something together using that design myself. Or do you have any code that you can send to me that I can work with? If you need time to work on it yourself then it can wait, just offering my help here.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I'm working on joystick-support and I am considering the options of implementing them in ZGE.

Either we use the component alternative with JoystickAxis and JoystickButton components.

Or we introduce new scripting functions such as joyGetAxis(joyId,axisNr) and joyGetButton(joyId,buttonNr).

I'm sort of leaning towards the scripting alternative since we are going towards more advanced scripting and it would be nice to be able to read all joystick input in a single ZExpression. And I'd rather not do both alternatives, at least not right now. But maybe there are benefits of components that I'm forgetting. What do you guys think?
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

that scripting solution sounds great to me,. no pressing reason to have an actual component comes to mind,. and yeah not having to have one seems more efficent in fact.

This feature will be a great addition,. as I have had lots of request for it with lockOn,. (oh, ville there is a video of that up on the ig site now,.)
iterationGAMES.com
Post Reply