this post was submitted on 17 Mar 2024
18 points (100.0% liked)

GameDev

2776 readers
1 users here now

A community about game development.

Rules:

More rules might follow if they become necessary; general rule is don't be a pain in the butt. Have fun! ♥

GameDev Telegram chat.

founded 1 year ago
MODERATORS
 

Many games support both keyboard/mouse and controller input. Many users (myself included) may wish to switch their input method mid-game, but what is the best way of handling this?

There are two potential solutions:

  1. Have the two input methods combine and reach a consensus (e.g. pressing W on the keyboard while moving the left thumb stick to the left will cause the player to move forward and left)
  2. Have only one input method work at any given time, but switch automatically depending on what the player most recently used.

Technically there is a third option, which is to have the user manually switch between the two input methods in a menu somewhere. I don't consider this a real option because the user experience would be terrible.

So, which solution do you think is better and why?

top 8 comments
sorted by: hot top controversial new old
[–] catloaf@lemm.ee 17 points 8 months ago (2 children)

Accept all inputs. Update on-screen prompts depending on which one was used last.

But be careful with processing those inputs. Team Fortress 2 used to have an exploit where you could move the mouse and tilt a stick and turn twice as fast as you were supposed to be able to.

[–] Pyroglyph@lemmy.world 5 points 8 months ago

The way I do it would work well. Treat such vectors as two separate components. Not as X and Y, but Direction and Magnitude. No matter how many ways you can find to break the input, as long as you clamp the magnitude you'll never go faster than intended! This also conveniently solves the √2 problem when moving diagonally.

[–] bufalo1973@lemmy.ml 2 points 8 months ago

It's easy. Just check if mouse moves left OR left key is pressed OR joystick is pushed left THEN move left.

[–] Confetti_Camouflage@pawb.social 8 points 8 months ago

The consensus solution. The Steam Deck and Steam Controller's touchpads can result in both mouse and joystick input being used simultaneously. Locking down which input is used prevents this from working as intended.

[–] GroteStreet@aussie.zone 3 points 8 months ago (1 children)

Ideal for me is auto-switching with a debounce time.

There's been a few incidents where I'm using my gamepad and accidentally bumped my desk/mouse and completely lose my orientation in game. With a debounce, one form of input needs to have completely stopped for a certain period (say 500ms) before starting to register movements on the other input device.

[–] Pyroglyph@lemmy.world 5 points 8 months ago (1 children)

I think I'd find that annoying. If a player wanted to quickly switch to the other input method in an intense moment then they'd just be waiting for half a second for their inputs to register. They'd probably think the game is bugged!

[–] GroteStreet@aussie.zone 1 points 8 months ago

I just pulled 500 randomly. I don't know how long it would take me to throw the gamepad and reach for the mouse. 50 might be more realistic. The point is just to prevent accidental bumps.

I also came in with that comment fully expecting younger and much faster players with their 240Hz monitors to disagree profusely.

[–] Kyyrypyy@lemmy.world 2 points 8 months ago

While I'm all for dynamic swapping during gameplay, in the menus I suggest an option to disable controller, in case there is a malfunction. Also, to the same problem I'd suggest havinge the mouse cursor to have a) priority, that affects the menu element under the cursor (not the element selected) and b) a fade out time, so it can be active at the same time as controller is active, to prevent the case, where the game detects controller to be drifting. This will be a godsent feature, when, for some reason, even removing the controller does not fix the game detecting the drifting input.

Also, it would be cool to have a manual option to force displayed prompts, not only between keyboard and controller, but also between x-input, Direct-input and PlayStation controllers.