This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'd like to build an hardware interface device that sits between
two game controllers and maps controller buttons based on which
game is to be played. So the device will run some java app where
I've statically coded all the mappings. There's one mapping for
each controller (EnumTGC and EnumPGC) and multiple
controller:controller mappings. Also, multiple games can use the
same controller:controller mapping but one game can only use one
controller:controller mapping. So....
so far so good. but here I run into trouble
when combined with the executable
Does that make sense? Overall idea here is the user will select which game is to be played
(hardcoded here to shrink the problem) and the associated controller:controller mapping gets used.
As always, all help/suggestions/advice/constructive criticism are all welcome,
Maybe the following example is useful for you. I have replaced EnumTGC and EnumPGC with interfaces with the more descriptive names Command and Button.
The point is that eventually all your games should care about is some mapping from Buttons to Commands. We can use the following type for this:
If your game detects that a certain button is pushed, it can easily look up the associated command like so:
Here's how it would look:
The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Joined: Oct 02, 2008
Genius! I thought the EnumMap might be of help but have not worked with it before. I'll give it a try.