[PLUGIN] Joystick / Game controller support! v1.2.0

Started by Wyz, Fri 20/08/2010 19:43:43

Previous topic - Next topic

Dualnames

Honestly, I'd rather use a plugin for that. And the absence of any games using JoyToKey pretty much states the statement itself. I think Wyz made possible what was only a dream. ;)
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Snarky

There's no "absence of games using JoyToKey", because JoyToKey is completely separate from the games; you can use it with any game, indeed any application, to allow joystick/gamepad input.

I recently used it with Psychonauts to map auto-fire (or more precisely, auto-douse) onto an unused button, and with the Prince of Persia games for all actions. I don't remember if Dreamfall and Fahrenheit had built-in controller support; otherwise I used it for those as well.

JoyToKey is pretty much everything you could ever want for game-controller input. The only drawback is that a lot of people aren't aware of it. I say just distribute it with your game.

abstauber

Wow! Thanks for creating this awesome plugin!

I somehow missed this thread during my vacation. Let's see how it works for that platform engine.

Time to search for my Gravis Gamepad  Pro :)


Icey


Dualnames

Quote from: Snarky on Sat 04/09/2010 23:29:05
There's no "absence of games using JoyToKey", because JoyToKey is completely separate from the games; you can use it with any game, indeed any application, to allow joystick/gamepad input.

I recently used it with Psychonauts to map auto-fire (or more precisely, auto-douse) onto an unused button, and with the Prince of Persia games for all actions. I don't remember if Dreamfall and Fahrenheit had built-in controller support; otherwise I used it for those as well.

JoyToKey is pretty much everything you could ever want for game-controller input. The only drawback is that a lot of people aren't aware of it. I say just distribute it with your game.


I stand corrected. Still, this plugin just pretty much adds to what is considered "basic" for games out there. And that's of course a personal opinion. I just never used JoyToKey cause I never found a use for it, all of the games I've played had in-game controller support, and that's a very useful thing for an AGS game in my personal opinion. I will be certainly using it on TROICA. :D
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

monkey0506

#26
I didn't mean to hijack this thread..::)..as was said, JoyToKey is completely independent of games..you can even use it to control the cursor/keyboard in the OS if you really want to (how you set that up is entirely up to you). For streamlined, built-in controller support, that you can edit at run-time from within your AGS game, there's this plugin. For everything else, there's JoyToKey. ;)

[/JoyToKey posts in this thread already!!] :P

Dualnames

I'm not ditching JoyToKey, heaven forbid, lots of people are using it in their games. I'm just fairly happy with the existence of a plugin. There I said it in one sentence. That said, let's leave this to a more gen-gen approach.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Snake

#28
I say NAY to resorting to JoyToKey with AGS.
It is indeed a great program, which I've used numerous times, but with a non-adventure AGS game, in-game joystick/gamepad support is a must (depending on the game, of course).
I would not want to make a game intended to be played with a gamepad or joystick and tell the player, search for a program called JoyToKey and follow the instructions, etc, to play with a gamepad/joystick.
It's absurd to suggest this when there is an in-game default available.

\\--EDIT--//
If this reply seems a little awkward, it's because I didn't realize there was a second page...
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

Wyz

I'm glad that is settled ;D
I still working on the example + documentation, but in the mean time please feel free to PM me if you have questions. I'm looking forward to the first implementations!
Life is like an adventure without the pixel hunts.

mode7

Quote from: Wyz on Wed 08/09/2010 18:43:18
I'm glad that is settled ;D
I still working on the example + documentation, but in the mean time please feel free to PM me if you have questions. I'm looking forward to the first implementations!

An example would be great. I'm still quite unexperienced with coding and can't quite figure out how it works.


         

abstauber

Just take a look at the readme file. It's contains almost everything you need to know.
Also the autocompletion hints added by wyz are really helpful.

As for an example, I've almost done including the plugin to my platform engine. I'll upload it this evening, so you can take a look.

Wyz



Update!



V1.1.0
- Unplugged() member function added
- Joysticks IDs now number from 0 on (this is a bit more consistent with the other functions)
- EnableEvents() scope parameter added (now possible to add event function in roomscript)
- buttons property made accesible
- minor fixes
Life is like an adventure without the pixel hunts.

mode7

Thanks a lot Wyz, for this great plugin.
Finally I managed to get it working and it works great.

There's only one thing I can't figure out now. Can I somehow assign a deadzone for the joysticks? Because e.g. joy.x always seems to return 1 or -1 which means that when I touch the stick a only a little the character will start moving.

I tried with

if (joy.x > 128)

but that doesn't seem to work.

Wyz

#34
You're welcome!

I guess the thing is that joy.x also is negative at some point. The value is between -JOY_RANGE and JOY_RANGE. JOY_RANGE is a constant you can use, it is a very big number, but you can do a conversion like this:
Code: ags

int x = joy.x / (JOY_RANGE / 256);


x will then be between -256 and 256.

I hope that helps you :)

- Cheers
Life is like an adventure without the pixel hunts.

Wyz

#35
I've made I tutorial with plenty examples:
- Finding joysticks
- Using the inputs
- Mapping inputs
- Analog to digital stick conversion
- Game lobby
- Point & Click games
and more :D

check it out:
AGSJoy Tutorial v1
Life is like an adventure without the pixel hunts.

Snake

YAY!!

I will check it out soon :D Thank you VERY much!
Grim: "You're making me want to quit smoking... stop it!;)"
miguel: "I second Grim, stop this nonsense! I love my cigarettes!"

tzachs

This looks pretty cool, I will probably add this to AGS Footballer.
Too bad I have neither joystick nor a gamepad, so no way to test this...

<Noobish question>
I'm guessing there's no way to plug in your PS2/Wii controllers to the computer and use them as gamepads, right?
</Noobish question>

Wyz

That's a good question actually. ;D
For PS2 controllers you need to buy an USB adapter. For Wii controllers however, if you have a bluetooth device installed you can download a piece of software to use it as gamepad.
Life is like an adventure without the pixel hunts.

tzachs

Thanks for the reply, I'll have to look into it when I've got the time...

SMF spam blocked by CleanTalk