Hmm. First, I'd like to say I appreciate your effort and your quickness for this. Unfortunately, it only solves half my issue. I wish I could have gotten back with my code I dreamed up, but today was my daughter's birthday.
I'd have worked this all out myself, but I just started using SVN (or any version control) yesterday, so I'm not entirely sure how to get checkouts and submissions and such to work with Eclipse, nor do I know if I even have permission, it never asked for a password so far.
Anyway, basically I had two issues before, given any DeviceComponent (let's just stick with Digital ones for now), I need to determine it's instanceof (Keyboard, Mouse, etc), and then based on which one, call a lookup method from that device. The changes you made solved the second one for my by making Keyboard/Mouse/etc each have a common lookup function, and on the mouse it actually helped allot because of all the different Components, but I still have to determine which device to call using if...instanceofs very similar to the ones you used to make sure it was a DC that Device knew how to handle. I guess I could just call all three and ignore the exceptions, knowing it would work on one of them, but that seems very hacked to me.
I also understand what you're saying about the Singletons, but I don't think it affects my solution. We get a Key or a MouseSomething and know it came from one of those devices, but not which, and it is really unlikely that someone has multiple keyboards/mice plugged in, they've only got so many hands. And you don't want to store a boolean when you have a class doing that already, we want to have a chain or responsibility.
What I had in mind was this, and let me know if I don't know what I'm talking about, because it's a strong possibility. I want to go from a list of DigitalDeviceComponents and get their value and not worry if it's a key or button or what, because as long as it's boolean it really doesn't affect the game. But I don't really have DDC's, they're all extensions there of, they're Keys or MouseButtons or what have you. And they each, by virtue of knowing what they are, all know which device they should call and which method they should use, and which index they should pass. So if we make them all implement the same method, then I can call it and it will delegate the correct method for me. Best of all, there is no need to for the device to check anything. Polymorphism in action.
I know I'm not describing this very well, but the code is in my head, and I think it will make it clear.
//org.jagatoo.input.devices.components.DigitalDeviceComponent
public abstract boolean getBooleanValue();
public abstract InputState getState();
//org.jagatoo.input.devices.components.Key
public boolean getBooleanValue() {
return Keyboard.isKeyPressed(this);
}
public InputState getState() {
return Keyboard.getState(this);
}
//org.jagatoo.input.devices.components.MouseButton
public boolean getBooleanValue() {
return Mouse.isButtonPressed(this);
}
public InputState getState() {
return Mouse.getState(this);
}
//org.jagatoo.input.devices.components.ControllerButton
//already implements getBooleanValue as getBooleanState, just a rename to fit the get{Boolean|Float|Int}Value naming scheme
//already implements getState