I tested your script with an official X360 controller on an empty project and it doesn't seem to work too well, the player keeps walking even when I'm not touching the control stick at all, and some of the mappings seem to be wrong (ie C is set to the X button, and A is set to the A button) and I couldn't find a way to change them, even changing the gamepad button IDs didn't do much.
If you start the game itself (F12 or the playtest option, or I guess the .exe file) and then press F1, it'll take you to a config menu. You can adjust the individual button settings there (just swap A and C around). As far as I can tell, that pretty much fixes some of the queries above (which was the same problem I was having). I think the game 'saves' the preferences too--no need to edit any of the scripts any further!
For script idiot like me, this module has the beautiful effect of activating the D-pad on my controller, which was the only bit of the controller that wasn't working for me before. Thanks Lone Wolf for this! Funnily enough, I actually didn't know the controller worked at all until I started mucking around tonight!
EDIT: I was wrong; it doesn't remember the playtest settings when you load the game from the .exe. However, players can still press F1 to configure their own buttons, which is good enough, I think.
EDIT EDIT: Or, wait, it might remember. I'm confused, and past caring. Either way is a win!
First off, thank you for this script. I am just making a game for the fun of it and wanted to be able to utilize my Xbox 360 wireless controller. But... for whatever reason the left stick's Y-axis doesn't respond properly. As soon as the game starts my "hero" moves down. If I put the stick all the way up it will go up, sometimes. If it is in the neutral position it will usually have the "hero" go down or the slightest touch of the stick in that direction will do so.
I have tested this with a different game and the controller works just fine so I am curious as to where I can adjust this in the script or in the game.
Thanks,
-Grev
because angle 0 is the result when you press up on the stick, if you leave it as 0, will make the direction=0 instead direction=8 that makes your character go up.
you can change -1 to any number except one from 0 to 360, its just a check for nothing being pressed
i did this, because in my game, the stick is not working fine when i press up, with this change, works perfect.
Use this code change if you need it only.
PS: i made another change, a detection to change the character speed movement based on the stick movement, like in mario 64, when i finish i will post it.
Oooh. I hadn't even thought about that! Makes sense.
IMO character movement speed and such should be in a separate controls module specific for your game... Such things would most probably instantly break any additional add-on scripts if you aren't extremely careful with them.
I have an issue that I can't solve. My UP joystick command isn't being accepted by the game and I'm not sure why. All other directions work with "MOVE_WITH_STICK" set to true. I can move up if I press a little to the right or left with the stick, just not directly up. All tests lead me to believe that my joy is working fine. If I disable the script, I can move in-game properly, all directions work. If I set move to stick to false, the up direction pad works properly. Down works fine, so I have to have the axis set correctly in x360ce.exe, correct? Any ideas would be appreciated!
Thanks!
**EDIT**
Looks like raulf17 in post #28 fixed the problem. Thanks!
**EDIT again**
How do i define the second controller?
"When using multiple pads, send calls to WolfPad with pad number (0...3)
# as the final parameter."
Can you give me an example as to what it would look like if I sent a call to wolfpad with a number as the final parameter?
Thanks again!!
I've been using an old XInput script all this time (one year or so) in my game, and I just realized it was pretty laggy. Glitchfinder's Gamepad Input, so to speak. Thing is, I'm looking for a replacement, but since I use analog values to determine running/walking and 8 direction, there is quite some things I have to redo in order to work with this (fortunately all my input calls already do a call to my own custom functions, so I don't need to go and check every Input.press? on every class).
My little, minor question is, have you tested it about how much lag it produces? Because, seriously, just some days ago I removed the gamepad module I had and I regained like 10fps lol (if you try and tell me "maybe you have something else that's causing so much lag" I'll bite you to death because I'm touchy on that aspect =D and depressed, mostly depressed "OTL).
Anyway, I'll try it out. I want to compare both. See if this one gives me better performance.
Also, does this module need any DirectX version in particular? Like, 10 and up or something? Would be nice to know, to better inform users.
(Props to you for not using extra custom DLLs because of swag).
Lag? Why would it lag? I'm using Microsoft's own libraries and the most bare-bones state checking possible with Ruby. Also not polling the controller more than once per frame, because the VXAce engine is locked to 60FPS. There's really not much going on here besides the minimum required functionality.
I'm just going to assume that you're talking about the lag the other script gave you, and say, yeah, you should get that replaced. This one is about as lightweight as the VXAce input module itself, because they work the same way. It will probably work better for you, but test it for yourself.
Darn I hope Lone Wolf checks by to fix that. Going to see if I can replicate it also today. It would suck if it crashed if you don't ever have a gamepad or software installed.
We confirmed that it's only a problem if you don't have DirectX installed. Which a majority of people (especially gamers) do. Easy fix!