Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gamepad Implementation
- - By BlueScope Date 2015-08-11 18:47
So, I've taken a look at the Gosu source's Input.cpp to maybe fiddle with the gamepad implementation. I should add that this is the first time I see C-something, and after looking at it a little bit, I figured I'd need some more fiddling with the language before I can be of any help here... :) I do have afew ideas that would improve the class, though, in case anyone else would like to mess with it...

First of all, it'd be most awesome if you could directly return the value of SDL_JoystickGetAxis (Documentation), as in a value between -32768 and 32767 (or even 0.0 to 1.0, really). It would/should be perfectly backwards compatible at least with Ruby (again, I don't know about C++), as "if (32767)" would still return true, but to be honest, I don't know about the negative values... maybe an additional parameter such as button_down?(id, :analog => true) would do the trick?

As for the dead zone, I'd personally like to have the option to not include it in the function, but in the method call, such as button_down?(id, :deadzone => 0.05) that defaults to some smart value... this would allow for a better fine-tuning, as well as giving the option to use user-input values, and read the base value if you want to know how big your joystick jitter is in the first place.

It'd also be practical to be able to directly reference the axes instead of just "up" or "down", for example. I've read somewhere before that to get the triggers on the X360 controller correctly without overwriting each other (as one of the triggers uses the x and the other the y output of the same "joystick"), you need to specifically read axis 8 and 9 to get the seperate values. Apparently this is the case for Windows drivers only, but nevertheless.

That being said, I could see a few methods being useful, for example something that translates the movement of x and y of a joystick into the combined value between the center and the outer ring (i'm sure there's a cool term for this in Math), basically to get the strangth it's being pressed with. Another thing would be the angle, while pretty straightforward, it would be a handy function to not having to code yourself.

I don't know if I'm being captain obvious here, and everyone knows the above and didn't just find the time to do it... but it seems like an easy-enough thing to do - I know I wouldn't take too long in Ruby to do it! :D
Parent - By jlnr (dev) Date 2015-08-12 22:34 Edited 2015-08-13 05:36
I love my gamepads, and I agree that everything you mention should be possible -  PLUS force feedback :) However, I'm afraid that redesigning/extending the gamepad interface will take a while. So my current roadmap is:

Gosu 0.9.10 - more cleanup
Gosu 1.0 - once SDL 2.0.4 is released, plus some interface fixes (Gosu::TextInput and <b>pseudo HTML tags</b> are an embarrassingly bad mix right now!)
Gosu 1.1 - input redesign

I'm a big fan of the SDL 2 Game Controller API, so I'll probably model the new input API after it, and I'll try to expose as much of it as possible (+ backward compatibility layer for the current Gosu API).

One more thing that I'd like to keep an eye on is serialisation/deserialisation of button IDs. (They're only semi-portable now.)

That all being said, if you have an idea of what the API could look like, feel free to post it here or open an issue on GitHub for discussion :)
Up Topic Gosu / Gosu Exchange / Gamepad Implementation

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill