I've tried a lot of different ways to get it to work but now I've just given up. Does anyone know a way to get 8-directional movement to work with an Xbox controller? Thanks!
Printable View
I've tried a lot of different ways to get it to work but now I've just given up. Does anyone know a way to get 8-directional movement to work with an Xbox controller? Thanks!
Are you talking about the default eight direction movement?
The first thing I would recommend is checking out this example. It covers the basics of the XBOX Gamepad object.
If you don't want to make a custom movement, I suggest using the bouncing ball movement. That way, you're not fighting with the built-in control mapping that the 8-dir movement has.
Make a value someplace to track the angle of the left stick. Ex: ATan2(( StickLeftV( "XBOX Gamepad", 1 ) * -1.0 ), StickLeftH( "XBOX Gamepad", 1 ))
Also make a value that changes when you've moved the stick outside of the dead zone. (0 for inside dead zone, 1 for outside dead zone).
So, when your inside/outside dead zone value is 1 and that angle value is within whatever range, move in a direction.
It's still coffee time here, but I hope this helps. :pacman:
I strongly recommend VACCiNE, it makes everything to do with gamepads easier: https://clickstore.clickteam.com/vaccine_2
I have to disagree a bit with that recommendation, and that's based on what I've seen without using it. Not only is the video a bit misleading on what the XBOX Gamepad and Joystick 2 objects can do, but it also seems to rely on Control X (Key Object always gets me a better result). Can't speak for how easy it is.
If it's a quick solution that works okay for people, that's great. However, XBOX Gamepad, Joystick 2, and Key are not that complicated once you figure them out.
I've used VACCiNE extensively and Xbox control works out the box, it's very exhaustive and you can modify any aspect you want to suit your needs. @Volnaiskra knows what he's doing
Thanks for the reply! I've been studying the example for quite a bit and have gotten pretty comfortable with it. Thanks again!
The Xbox Gamepad object is pretty good if you definitely only want Xbox controls. It's relatively easy to use, and should be adequate for many needs. Though IIRC it won't give you 8-directional, 360-degree or analog strength information - just X and Y information, which you'd need to convert using trigonometric equations if you want that information. If you want support for Playstation or other gamepads, then you need Joystick 2, which is a whole other story.
Sorry, but that's just not true. Joystick 2 is way more complicated than it should be. It contains various errors and inconsistencies that are certain to break your game in certain situations and/or on certain gamepads, provides much of its information in convoluted and inconsistent ways, has inconsistent and/or missing deadzones, and fails to measure basic things like how hard certain joysticks are being pressed, or what direction they're pointed. I could give you a huge list of its problems and inconsistencies, but I've already done that elsewhere, so I'll copy and paste that. Behold, a little taste of the uncomplicated and user-friendly world of the Joystick 2 object: ;)
The PS4 joystick gives you both 8-directional and 360-degree values. But you have to press the stick significantly harder to register the 8dir one. 8dir starts at 0 but 360deg starts at -1, and while one goes clockwise, the other goes anticlockwise. But at least they both start at east. Unless you're talking about the right joystick, in which case they both start at south. Just for fun, the dpad starts from north (oh, and the value you'll get when pressing north on the dpad just happens to identical to the one you'll get if no gamepad is detected, so have fun with that). If you want to know how hard you're pressing either of the sticks, you'll need to calculate it yourself from the X and Y values. The X and Y values from the left stick are given as RawX and RawY, and both go from -1000 to 1000. On the other hand, the X and Y values of the right stick are given as RawZ and RawZrotation. Like RawX and RawY, RawZ goes from -1000 to 1000, but RawZrotation (which actually has nothing to do with rotation) likes to really express itself, so goes from 0 to 65535. But at least the use of RawZRotation doesn't conflict with the Xbox gamepads, which the use of RawZ does, since RawZ is what Xbox uses for the triggers (well, unless a player is on Windows 10 with native drivers, in which case their right trigger is measured in RawZrotation). Anyway, the Xbox left stick works much like the PS4 one, complete with inconsistent measurement methods and mismatched deadzones. But the Xbox right stick missed the memo and doesn't bother giving you 8dir, 360deg or analog strength data at all. Well, not real data anyway - it does give you a permanent false positive for 'moving left', so there's that. But it provides X and Y info (from 0 to 65535) so stop interrupting its nap and work it all out for yourself (hope your trigonometry is up to scratch!). Oh, and it has absolutely no deadzone, so you'll need to program one in yourself unless you want erratic micro-movements pretty much nonstop.............Simple, right?
It's true that it's a disaster if you try bringing analog to the table. If analog controls aren't needed, it's really not that terrible.
Some things have to be left up to the user to change (mainly right stick axes). In the case of the Xbox Gamepad object, it might be a good idea to leave an option for the user to adjust the dead zone.
Do you think Joystick 2 is inherently flawed, or is it DirectInput that is the problem?
That is true, Dark Devotion and Aggelos both had controller issues on Steam-launch, due to the joystick2 extension. If a user on Steam has controller configuration enabled joystick 2 will either stop working in total or randomly mix up button and axis input. Many Steam users have these configurations enabled, and while this also produces issues in AAA titles like Seikiro, it remains a very bad thing, as we Fusion devs cannot fix joystick2 and it remains the only option to support generic controllers next to JoyToKey setups.
TBH, with the options on Steam it is very easy to setup a JoyToKey solution for any game, but many players seem to get angry if gamepads do not work out of the box and refuse to fiddle around a bit.
Xbox extension is a very good readout and works perfectly with Steam, but to have just Xbox support is not enough... My advice is at least to implement both readout in any commercial product to at least offer the player some options.
I very much hope CT can fix these joy2 issues, I think the need is very much there, I don't know if this is technically possible tho.
We've fixed a part of those issues (for Dark Devotion), there was an incompatibility between Steam custom joystick configurations and the "Sync with MMF" option of Joystick 2, as Steam for some reason changes the joystick IDs in some APIs and not all.
The updated version of Joystick 2 can be downloaded from the Extension Manager, I've just uploaded it.
Though it seems there are still issues with some custom configs. I don't know which ones, we didn't get precise reports yet.
I just see your post Julian82, the updated version of Joystick2 shouldn't fix anything in Aggelos as AFAIK it doesn't use "Sync with MMF".
@Yves : I do not sync Outbuddies as well and get issues on Steam. I'll install the latest version of joy2 and report my findings. Thanks for your hard work, guys:)
If you can give us instructions to reproduce the problems and a simple MFA that would help A LOT.
Doesn't Steam have an input wrapper now? DirectInput devices should work on XInput-only games.
Can't confirm this right now, but that would render Joystick2 obsolete as far as Steam releases go.
@raxabit : Yes, if your gamepad is emulated as Xbox on Steam, Xbox extension will work. That's why I think one should at least implement an Xbox readout next to joy2 atm.
@Yves : Here are some findings for the current version of joy2, I'll see if I find a time slot to create a separate .mfa for testing, but I cannot promise atm cuz I've some daunting deadlines to fulfill.
Xbox gamepad object: Will always work correctly, key rebinding on Steam included, for both real Xbox controllers and devices emulated as Xbox input, also a combination of both is good
Joy2: For only ONE gamepad connected + Steam configuration, it now seems to read out correctly for any device I checked (checked Xbox, PS4 and a generic gamepad)
Joy2: If 2 gamepads are connected and at least one of them is no real Xbox controller (but some other device emulated as Xbox), one of the controllers will randomly stop working or provide false inputs, while the other one still works.
Very important: This issue will appear outside the Steam environmet too, for example if you connect Xbox controller plus PS4 controller with DS4 emulation.
I also tested the following cases for Joy2 with Steam configuration enabled.
Xbox + Xbox: OK
Xbox + PS4: Fail
PS4 + Generic: Fail
Xbox + Generic: Fail
Conclusions:
With the present controller emulation options provided on Steam, @raxabit ist right. If a readout pattern using Xbox gamepad object is implemented, players will get their devices to work within Steam. Joy2 seem obsolete and may produce severe issues if more than one gamepad is connected and Steam configuration is enabled. It seems to work fine for only one connected device tho.
Outside the Steam environment and its emulation options, Joy2 is still needed to support generic controllers. In case more than one gamepad is connected, and at least one of them is emulated as Xinput, the same issues as on Steam may occur.
Joy2 extension seems to have a specific problem with multiple gamepads that use Xinput emulation.
OK, thanks!
This MFA is what I used to get 8-directional kind of the same way the keyboard does it. My problem is that when I use the keyboard controls, obstacles work fine; but when I use XBOX, collisions don't always work.
Controls for keyboard have been changed to:
E - Up
D - Down
A - Left
F - Right
Top Down.mfa
Does anybody have a solution for the joy2 object for Steam, I am experiencing the same issues, joystick2 doesn't respond when I launch it in steam have the 1.4 version.
Pretty frustrating :/
AFAIK there’s no fix for Joy 2 on Steam besides making sure there’s no XInput emulation running in the background (deactivate Steam controller configuration). If you wanna do yourself a favor and avoid being flamed by your players, rework your code for the Xbox gamepad. Players expect the gamepad configuration options to work and if someone has a desktop based emulation running you’re doomed anyway.
There are two APIs in Windows to read out gamepads. One is DirectInput, the rather outdated API Joy 2 uses, the other one is XInput. Steam offers XInput emulation for almost any gamepad, it’s called Steam controller configuration, you can activate it for any device in the Steam properties. It basically makes devices read out as an Xbox gamepad and adjusts the button mappings accordingly, so you can make sure every player has the same layout. There’s also an option to either remap your inputs in total or make a tab for each game. This way you need not care about gamepad rebinding options as a dev. Outside of Steam, only the Xbox gamepad will natively work with your game tho. Anyway even non-Steam players tend to emulate their devices as XInput (PS4 gamepad plus DS4 emulation, for example).