Original Post
I am currently building a wrapper for DirectInput. I would like to use my own keycodes instead of the DirectInput keycodes. I am having trouble thinking up a good way to convert the DirectInput keycodes into my keycodes. Is there any universal keycode to correspond to keys? I know I could convert to ascii but sometimes information can be lost, and I would also need a function to convert from Ascii to DirectInput codes (this would be most helpful right now). Here is roughly how I want it to work. Anyone got any ideas? Thanks -Sevans
// input wrapper interface
class IInputDriver {
enum MyKeyCodeType {
KEY_RIGHT
//...
};
virtual bool isKeyDown( MyKeyCodeType key )=0;
};
// directinput wrapper implementation
class InputDriverDX9 : public IInputDriver {
// this class has all of the logic to
// deal with direct input
bool isKeyDown( MyKeyCodeType key ){
// at this point I have an array of bytes.
// bit 0x80 is set iff the key was down at last device poll
// the array is indexed by DirectInput Key Codes.
// so I need to convert my MyKeyCodeType key passed in
// to a DirectInput key code.
// so I wonder, what would be the best value for my key codes
// and how would i convert them?
};
};
// how to use the input driver
int main(){
// this will be done by a factory in real implementation
IInputDriver *driver = new InputDriverDX9();
}