REGoth-project / REGoth

OpenSource-Reimplementation of the zEngine, used by the game "Gothic"
GNU General Public License v3.0
630 stars 63 forks source link

XInput / Gamepad Support #316

Open phspo opened 6 years ago

phspo commented 6 years ago

Was curious if that would be acceptable or if you would rather have a "pure" recreation of the original Gothic engine. I was thinking about expanding the Input class so the game could react to a connected gamepad in a fashion many other modern games do (show the respective buttons next to highlighted objects etc., maybe offer alternative menus if suitable) but I could understand if that is not what you are aiming for.

ataulien commented 6 years ago

Gamepad support would be a great addition. As far as I'm concerned, we're not after a "pure" reimplementation, but we are improving the engine where it makes sense. I don't see any reason to stick with all the old annoyances like having to set up weird tools just to crappily emulate a gamepad-keyboard-mouse combination.

Well, we do lose the nostalgic good ol' days of messing around with getting the damn game to work the way you want it! :smile:

toolatetotheparty commented 6 years ago

Gamepad-keyboard control scheme switching at runtime would be amazing.

phspo commented 6 years ago

Alright so I will probably wait for https://github.com/REGoth-project/REGoth/pull/313 to be merged in because that would create more work merging later and then get working on it ;)

ataulien commented 6 years ago

Not sure how the state on #313 is. There were some issues with it as @markusobi mentioned. However, the PR is mostly about UI code, not sure how much it would interfere.

By the way, since we are using GLFW for input, there is no need to use XInput. GLFW supports gamepads (probably through XInput on windows) as well!

More information here: http://www.glfw.org/docs/latest/input_guide.html#joystick

HunterwolfAT commented 6 years ago

Afaik, there are no GLFW joystick/gamepad bindings in the codebase yet. That could be something one could tackle. And yeah, #313 should probably be merged for that. Today I can take a look at the remaining problems again

phspo commented 6 years ago

@ataulien now that is a design decision you would have to make. i was planning on implementing it using GLFW but the XBOX controller is the de-facto standard controller for PC. so would we assume its layout for a default gamepad layout and also adjust menus with the xbox controller in mind (show xbox buttons visually etc.) or choose a more generic approach (allow keybindings for controllers, don't show any specific UI elements)?

my plan would be: there are two states that can be accessed from any class (XBOX / Mouse + Keyboard), when you plug in a controller the state changes to XBOX, when you hit a button on the controller: same, when you remove all joysticks or use any key on the keyboard it switches to keyboard+mouse.

when you are in gamepad mode some menus would be modified (showing XBOX buttons for accept etc.)

this overlaps with what @HunterwolfAT is doing in his refactoring which is why I would wait on his merge first

Linux13524 commented 6 years ago

Some time ago I implemented simple joystick support for the XBOX One Controller based on GLFW. It works for Windows and Linux, but is currently neither up to date with master nor with @HunterwolfAT 's refactoring. You can find it here: https://github.com/Linux13524/REGoth/tree/joystick It's not very much and as it only supports the XBOX Controller I did not open a pull request for it. @spqrPh Have you already worked on it?

phspo commented 6 years ago

hey @Linux13524, yes I have but no worries, nothing too complicated, your code is way ahead ;) if you already did some code taking that is obviously easier :) I will find something else to contribute

Linux13524 commented 6 years ago

Did you commit your work somewhere so I can look into it? ^^

danielxdietrich commented 6 years ago

Not sure if you guys have already have mapped controllers so here's my basic proposition. mockup Targets should change by quick move of right stick, like it's done in games nowadays.

Since controllers get support, then I don't think #302 should be overlooked. Playing without mentioned improvements might get difficult and unintuitive on controller.