Advertisement

anybody got a better way to do this?

Started by April 14, 2001 10:09 PM
2 comments, last by Succinct 23 years, 10 months ago
  
inline Event VirtualKeyToEvent( const unsigned VK,const bool IsExtendedKey )
{
    switch( VK )
    {
    case VK_MENU:           return IsExtendedKey ? EventKeyRightAlt : EventKeyLeftAlt;
    case VK_SHIFT:          return IsExtendedKey ? EventKeyRightShift : EventKeyLeftShift;
    case VK_CONTROL:        return IsExtendedKey ? EventKeyRightControl : EventKeyLeftControl;
    case VK_RETURN:         return IsExtendedKey ? EventKeyRightReturn : EventKeyLeftReturn;
    case VK_CANCEL:         return EventKeyControlBreak;
    case VK_BACK:           return EventKeyBackSpace;
    case VK_TAB:            return EventKeyTab;
    case VK_PAUSE:          return EventKeyPause;
    case VK_CAPITAL:        return EventKeyCapsLock;
    case VK_ESCAPE:         return EventKeyEscape;
    case VK_SPACE:          return EventKeySpace;
    case VK_CLEAR:          return EventKeyNum5;
    case VK_PRIOR:          return EventKeyPageUp;
    case VK_NEXT:           return EventKeyPageDown;
    case VK_END:            return EventKeyEnd;
    case VK_HOME:           return EventKeyHome;
    case VK_LEFT:           return EventKeyLeft;
    case VK_UP:             return EventKeyUp;
    case VK_RIGHT:          return EventKeyRight;
    case VK_DOWN:           return EventKeyDown;
    case VK_SNAPSHOT:       return EventKeyPrintScreen;
    case VK_INSERT:         return EventKeyInsert;
    case VK_DELETE:         return EventKeyDelete;
    case VK_0:              return EventKey0;
    case VK_1:              return EventKey1;
    case VK_2:              return EventKey2;
    case VK_3:              return EventKey3;
    case VK_4:              return EventKey4;
    case VK_5:              return EventKey5;
    case VK_6:              return EventKey6;
    case VK_7:              return EventKey7;
    case VK_8:              return EventKey8;
    case VK_9:              return EventKey9;
    case VK_A:              return EventKeyA;
    case VK_B:              return EventKeyB;
    case VK_C:              return EventKeyC;
    case VK_D:              return EventKeyD;
    case VK_E:              return EventKeyE;
    case VK_F:              return EventKeyF;
    case VK_G:              return EventKeyG;
    case VK_H:              return EventKeyH;
    case VK_I:              return EventKeyI;
    case VK_J:              return EventKeyJ;
    case VK_K:              return EventKeyK;
    case VK_L:              return EventKeyL;
    case VK_M:              return EventKeyM;
    case VK_N:              return EventKeyN;
    case VK_O:              return EventKeyO;
    case VK_P:              return EventKeyP;
    case VK_Q:              return EventKeyQ;
    case VK_R:              return EventKeyR;
    case VK_S:              return EventKeyS;
    case VK_T:              return EventKeyT;
    case VK_U:              return EventKeyU;
    case VK_V:              return EventKeyV;
    case VK_W:              return EventKeyW;
    case VK_X:              return EventKeyX;
    case VK_Y:              return EventKeyY;
    case VK_Z:              return EventKeyZ;
    case VK_SEMICOLON:      return EventKeySemiColon;
    case VK_EQUALS:         return EventKeyEqual;
    case VK_COMMA:          return EventKeyComma;
    case VK_PERIOD:         return EventKeyPeriod;
    case VK_MINUS:          return EventKeyMinus;
    case VK_SLASH:          return EventKeySlash;
    case VK_BACK_QUOTE:     return EventKeyBackQuote;
    case VK_OPEN_BRACKET:   return EventKeyOpenBracket;
    case VK_BACKSLASH:      return EventKeyBackSlash;
    case VK_CLOSE_BRACKET:  return EventKeyCloseBracket;
    case VK_QUOTE:          return EventKeyQuote;
    case VK_LWIN:           return EventKeyLeftWindow;
    case VK_RWIN:           return EventKeyRightWindow;
    case VK_APPS:           return EventKeyContext;
    case VK_NUMPAD0:        return EventKeyNum0;
    case VK_NUMPAD1:        return EventKeyNum1;
    case VK_NUMPAD2:        return EventKeyNum2;
    case VK_NUMPAD3:        return EventKeyNum3;
    case VK_NUMPAD4:        return EventKeyNum4;
    case VK_NUMPAD5:        return EventKeyNum5;
    case VK_NUMPAD6:        return EventKeyNum6;
    case VK_NUMPAD7:        return EventKeyNum7;
    case VK_NUMPAD8:        return EventKeyNum8;
    case VK_NUMPAD9:        return EventKeyNum9;
    case VK_MULTIPLY:       return EventKeyNumMultiply;
    case VK_ADD:            return EventKeyNumPlus;
    case VK_SEPARATOR:      return EventNone;
    case VK_SUBTRACT:       return EventKeyNumMinus;
    case VK_DECIMAL:        return EventKeyNumDelete;
    case VK_DIVIDE:         return EventKeyNumSlash;
    case VK_F1:             return EventKeyF1;
    case VK_F2:             return EventKeyF2;
    case VK_F3:             return EventKeyF3;
    case VK_F4:             return EventKeyF4;
    case VK_F5:             return EventKeyF5;
    case VK_F6:             return EventKeyF6;
    case VK_F7:             return EventKeyF7;
    case VK_F8:             return EventKeyF8;
    case VK_F9:             return EventKeyF9;
    case VK_F10:            return EventKeyF10;
    case VK_F11:            return EventKeyF11;
    case VK_F12:            return EventKeyF12;
    case VK_F13:            return EventKeyF13;
    case VK_F14:            return EventKeyF14;
    case VK_F15:            return EventKeyF15;
    case VK_F16:            return EventKeyF16;
    case VK_F17:            return EventKeyF17;
    case VK_F18:            return EventKeyF18;
    case VK_F19:            return EventKeyF19;
    case VK_F20:            return EventKeyF20;
    case VK_F21:            return EventKeyF21;
    case VK_F22:            return EventKeyF22;
    case VK_F23:            return EventKeyF23;
    case VK_F24:            return EventKeyF24;
    case VK_NUMLOCK:        return EventKeyNumLock;
    case VK_SCROLL:         return EventKeyScrollLock;
    }

    return EventNone;
}                                                          
  
Edited by - Succinct on April 14, 2001 11:23:25 PM
-- Succinct(Don't listen to me)
heh, lol, like inline''ll do anything here! sheesh!

Thank you for your bandwidth.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~Succinct Demos Online~

"&ltDiLLiGaS> I''m suprised nobody takes M$ to court for rape... The OS keeps going down on you w/o your permission."
-- Succinct(Don't listen to me)
Advertisement
There are four special cases and the rest is a one to one map from virtual keys to your keys. Handle the special cases with a switch, and the rest can be handled with a lookup table (just a simple array).
i thought of that, the way they used to do it back in the Wolfenstein3d day...

dunno, just didn''t seem appealing, because of all the empty entries, but yeah, that sounds more reasonable now, after looking at the disassembly of that monster!

thanks for the reality check, sir!
*off to code the lut*

-succinct

Thank you for your bandwidth.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~Succinct Demos Online~

"&ltDiLLiGaS> I''m suprised nobody takes M$ to court for rape... The OS keeps going down on you w/o your permission."
-- Succinct(Don't listen to me)

This topic is closed to new replies.

Advertisement