I had an idea for my game engine to simultaneously take in Keyboard and xbox controller input. But there would be a conflict for people who want jumping to be the same key for the xbox controller, without checking for both. I was also thinking of people implementing a GUI in game for changing the keys/input to do another thing. Would people need to make their own input controller, or something? It has to be API-level, so its easy to use.
Quite hard to understand, (it would be nice if you could be more explicitly) but I think you mean that people can set spacebar and R1 as jumping (for example).
Well that shouldn’t be a problem since if you get input, you check if it is spacebar/R1 and if so, toggle the jumping boolean.
boolean jumping = false;
public void keyPressed(int keyCode){
if(keyCode == spacebar)
jumping = true;
}
public void controllerButtonPressed(int keyCode){
if(keyCode == R1)
jumping = true;
}
Just very simple but what I try to say is that if you use the same variables (like I did with jumping) you shouldn’t have a problem.
I meant, for example; Pressing start takes you to the pause menu. Opening the pause menu takes a bit of code to create, so I was thinking of ‘linking’ certain keys to some kind of ‘action’. And in game, you can see a list of actions, and their linked keys. And you can link new keys to it.
Yeah, that’s what is called key mapping. You map buttons to intentions.
Pretty basic stuff, you should make a key-value collection for them where the key is the button and the value is the intention. When the user presses a button check if it’s in the collection, if it is run the respective intention. If you want to make the player able to use both a keyboard and a controller without the need of remapping the intentions from one to the other all the time make 2 collections, one for the keyboard and one for the controller and in the input check stage check for both collections. Again, pretty straight forward stuff.