Issue handling many near-simultaneous inputs

I’ve set up a game to play up to 4 players on one keyboard. Each player has a set of functions initialized and mapped to given keys.

public void initializeInputs(InputMapper im, int drive, int reverse, int flip, int right, int left) {
	gas = new FunctionId(id+"-input", "gas");
	this.flip = new FunctionId(id+"-input", "flip");
	steer = new FunctionId(id+"-input", "steer");
	im.map(gas, InputState.Positive, drive);
	im.map(gas, InputState.Negative, reverse);
	im.map(this.flip, flip);
	im.map(steer, InputState.Positive, right);
	im.map(steer, InputState.Negative, left);
	listenToInputs(im);
}
public void listenToInputs(InputMapper im) {		
	im.addStateListener(this, gas, this.flip, steer);
	im.activateGroup(id+"-input");
}

The problem is – while up to 3 players works smoothly – with 4 players many key presses are not picked up on. How should I fix this?

1 Like

Some keyboards and/or operating systems have limits to the number of simultaneous key presses that they’ll correctly report. My guess is you’re hitting this limit - I’ve hit issues with simultaneous key presses not being detected when it was far fewer than 4 people on a multiplayer game on the same keyboard. I don’t know the extent to which the limitation is keyboard specific or operating system specific, or if there’s anything you can reconfigure to change the limit.

4 Likes

If it is the system limiting simultaneous key presses, will it also limit simultaneous joystick/gamepad inputs?

The problem is usually within the physical circuitry of the keyboard itself.

See this Q&A for a good answer on the causes (tl;dr it makes the keyboards cheaper to manufacture). How do I remove the limit on PC keyboard button presses? - Arqade

This diagram is useful to help think about how the circuity in a keyboard actually works (even if it may be an oversimplification)

image

So its a keyboard specific phenomenon (although i see in that Q&A that 6 key rollover might be the max that USB can support so even a very expensive keyboard may be limited to 6 - that said the answer is a decade old so things may have improved)

2 Likes

No clue - I’d expect different devices to be totally independent of each other (especially given @richtea’s response about this being a keyboard-specific limitation), but I have never looked into this question specifically.

I am learning to design a custom control system for my game, the Keyboards/Keypads building units are mainly Multiplexers, a multiplexer is a data selector that can route multiple input channels to a single output channel, it’s commonly used to shrink the data bus to a single data line, there are many forms of MUX, 8-channels, 10-channels and etc, and you can even build a combinatorial nest of MUX to increase your input and further additions on the circuit like Parallel-In-Serial-Out (PISO) shift registers, all can contribute to differences among controllers.

EDIT:
And, there are many factors that can determine how fast the system can perceive data from a data bus, including the max clock speed of the microcontroller used and the number and layout of the MUX and Shift registers, literally, a lot of factors can contribute, so I confirm it’s a design dependent.

1 Like

No.

For the keyboard, it’s the hardware+driver itself.

You can have many joysticks/gamepads plugged in all at once and they should all work. I think I’ve done more than four before (don’t remember how many because we were testing something else). And that was like almost 20 years ago.

1 Like

There are devices that will make each key a independent input but they are not a keyboard. This is highly used in the “Arcade Retro” division. Where you have an emulator but have “Arcade” joysticks and etc… To get around this issue there are USB cards out there that will make a 48 key input that are each independent so you can play games like “Street Fighter” 2 player with 8 way joystick, and 7 buttons. Then the computer will see they correctly, but again not a keyboard.
There is a device called “ultimarc I-PAC” that simulates keyboard.

Classic problem from my childhood <3 We gamed with PCs (Intel 386, 486…) via split-screen. There were no networks back then. Just huddled around the same screen and keyboard. If things weren’t going exactly your way, you could deliberately spam some keys to prevent others having their input registered. Good times! :slight_smile:

Nothing to contribute :slight_smile: Others already opened this up.

2 Likes

I’m glad to hear that! :sweat_smile:

Thanks for your help everyone! :+1: