Jump to content
  • Advertisement
Sign in to follow this  
Sevans

Universal KeyCode?

This topic is 4118 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
// 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();
}


Anyone got any ideas? Thanks -Sevans

Share this post


Link to post
Share on other sites
Advertisement
Well I am going to start implementing a translation table, between the DI codes and my codes, boo hoo. ^.^d

BUT if anyone knows of a better way to do this by simply making a few fancy schmancy method calls please let me know.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!