Not logged inOpenClonk Forum
Up Topic Gamepad support

This board is threaded (i.e. has a tree structure). Please use the Reply button of the specific post you are referring to, not just any random button. If you want to reply to the topic in general, use the Post button near the top and bottom of the page.

Post Reply
In Response to Luchs
I'm currently working on improving OC's gamepad support. The source code is available on github. (diff)

What's working already?



- I changed the gamepad input on all platforms to use the SDL gamecontroller API. This API abstracts the usual numbered buttons to provide a single controller layout which looks like an Xbox controller. This allows us to create more advanced mappings which can use all of the available buttons, sticks and triggers on the controller. This also makes XInput controllers such as the Xbox and Steam controllers available on Windows. (I didn't try building the code on Windows yet.)

- I made analog input from the gamepad sticks and triggers available to the script. There already was a strength parameter, but it was only updated once when moving the stick. With my changes, the PlayerControl() function continuously receives stick movement events. Additionally, the sticks and triggers still send regular "key down" and "key up" events for cases where analog input isn't needed (for example menus).

- Make GetPlayerControlState() query the current position of analog sticks and not the emulated button state. (optional via third parameter)

- Improve main menu controls with the gamepad. Previously, these controls used a simple mapping heuristic with odd/even buttons etc. This isn't necessary anymore because we know exactly what the controller looks like. The main menu can now be controlled with the left stick or the dpad and the A/B buttons.

- Implement controller rumbling / force feedback (the simple rumbling provided by SDL is probably enough for now): StartRumble(int plr, int strength, int length) and StopRumble(int plr)

- Documentation. The strength parameter to PlayerControl() now receives the full range 0-32767/32768 exposed by SDL. The release flag has been replaced with a status parameter with the possible values CONS_Down, CONS_Up, CONS_Moved. Third parameter of GetPlayerControlState() makes the function query the current strength of an analog stick or trigger. StartRumble/StopRumble.

- Automatic controller selection and hot plugging. The available controllers are automatically distributed among all players with gamepad controls. It is possible to start a game without a gamepad, controls work as soon as a controller is plugged in. When removing a controller while playing, the game is paused and controls continue to work after plugging the controller back in.

- Controlling multiple players with gamepads. There are a few issues with split screen play (broken HUD, music), but the gamepad controls work fine.

Todo list



- Implement analog movement and aiming in script. Create a good controller mapping which is competitive with keyboard/mouse controls. (Would be cool if someone who's familiar with the existing gamepad controls could help here.)

- Improve control device selection. The current method where the device number of the gamepad is baked into the control scheme doesn't make a lot of sense. There probably should be a separate player selection screen when starting a game both locally and over the network. On this screen, each player would select their player file with the controller or keyboard/mouse they want to play with. (I will probably need some help here as well.)

- Re-enable split-screen playing. Currently, it isn't possible to select more than one player at once.

- Code review: I'm new to engine modifications so I don't really know whether my changes actually make sense :)

- Improve main menu UX with keyboard and controller. For example, when leaving a scenario folder, the selection bar should already be on the folder we just left. There are also some things which are possible with the keyboard, but lack proper gamepad bindings (e.g. crew selection).

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill