Exemplo n.º 1
0
void CButtonTranslator::MapAction(WORD wButtonCode, const char *szAction, buttonMap &map)
{
  WORD wAction = ACTION_NONE;
  if (!TranslateActionString(szAction, wAction) || !wButtonCode)
    return;   // no valid action, or an invalid buttoncode
  // have a valid action, and a valid button - map it.
  // check to see if we've already got this (button,action) pair defined
  buttonMap::iterator it = map.find(wButtonCode);
  if (it == map.end() || (*it).second.wID != wAction)
  {
    //char szTmp[128];
    //sprintf(szTmp,"  action:%i button:%i\n", wAction,wButtonCode);
    //OutputDebugString(szTmp);
    CButtonAction button;
    button.wID = wAction;
    button.strID = szAction;
    map.insert(pair<WORD, CButtonAction>(wButtonCode, button));
  }
}
Exemplo n.º 2
0
void CButtonTranslator::MapAction(uint32_t buttonCode, const char *szAction, buttonMap &map)
{
  int action = ACTION_NONE;
  if (!TranslateActionString(szAction, action) || !buttonCode)
    return;   // no valid action, or an invalid buttoncode
  // have a valid action, and a valid button - map it.
  // check to see if we've already got this (button,action) pair defined
  buttonMap::iterator it = map.find(buttonCode);
  if (it == map.end() || (*it).second.id != action || (*it).second.strID != szAction)
  {
    // NOTE: This multimap is only being used as a normal map at this point (no support
    //       for multiple actions per key)
    if (it != map.end())
      map.erase(it);
    CButtonAction button;
    button.id = action;
    button.strID = szAction;
    map.insert(pair<uint32_t, CButtonAction>(buttonCode, button));
  }
}
/*
* Builds the list of possible key presses
* Those acceptable in the profile settings must be listed here first
*
* Look here to see the list of possible ones. I haven't added everything yet.
*
* http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
*/
void keyMouse::buildLookupTable(){
	bmap.insert(std::make_pair("KEY_0",VkKeyScan('0')));
	bmap.insert(std::make_pair("KEY_1",VkKeyScan('1')));
	bmap.insert(std::make_pair("KEY_2",VkKeyScan('2')));
	bmap.insert(std::make_pair("KEY_3",VkKeyScan('3')));
	bmap.insert(std::make_pair("KEY_4",VkKeyScan('4')));
	bmap.insert(std::make_pair("KEY_5",VkKeyScan('5')));
	bmap.insert(std::make_pair("KEY_6",VkKeyScan('6')));
	bmap.insert(std::make_pair("KEY_7",VkKeyScan('7')));
	bmap.insert(std::make_pair("KEY_8",VkKeyScan('8')));
	bmap.insert(std::make_pair("KEY_9",VkKeyScan('9')));

	bmap.insert(std::make_pair("KEY_A",VkKeyScan('a')));
	bmap.insert(std::make_pair("KEY_B",VkKeyScan('b')));
	bmap.insert(std::make_pair("KEY_C",VkKeyScan('c')));
	bmap.insert(std::make_pair("KEY_D",VkKeyScan('d')));
	bmap.insert(std::make_pair("KEY_E",VkKeyScan('e')));
	bmap.insert(std::make_pair("KEY_F",VkKeyScan('f')));
	bmap.insert(std::make_pair("KEY_G",VkKeyScan('g')));
	bmap.insert(std::make_pair("KEY_H",VkKeyScan('h')));
	bmap.insert(std::make_pair("KEY_I",VkKeyScan('i')));
	bmap.insert(std::make_pair("KEY_J",VkKeyScan('j')));
	bmap.insert(std::make_pair("KEY_K",VkKeyScan('k')));
	bmap.insert(std::make_pair("KEY_L",VkKeyScan('l')));
	bmap.insert(std::make_pair("KEY_M",VkKeyScan('m')));
	bmap.insert(std::make_pair("KEY_N",VkKeyScan('n')));
	bmap.insert(std::make_pair("KEY_O",VkKeyScan('o')));
	bmap.insert(std::make_pair("KEY_P",VkKeyScan('p')));
	bmap.insert(std::make_pair("KEY_Q",VkKeyScan('q')));
	bmap.insert(std::make_pair("KEY_R",VkKeyScan('r')));
	bmap.insert(std::make_pair("KEY_S",VkKeyScan('s')));
	bmap.insert(std::make_pair("KEY_T",VkKeyScan('t')));
	bmap.insert(std::make_pair("KEY_U",VkKeyScan('u')));
	bmap.insert(std::make_pair("KEY_V",VkKeyScan('v')));
	bmap.insert(std::make_pair("KEY_W",VkKeyScan('w')));
	bmap.insert(std::make_pair("KEY_X",VkKeyScan('x')));
	bmap.insert(std::make_pair("KEY_Y",VkKeyScan('y')));
	bmap.insert(std::make_pair("KEY_Z",VkKeyScan('z')));

	bmap.insert(std::make_pair("KEY_SHIFT",VK_SHIFT));
	bmap.insert(std::make_pair("KEY_BACKSPACE",VK_BACK));
	bmap.insert(std::make_pair("KEY_TAB",VK_TAB));
	bmap.insert(std::make_pair("KEY_ENTER",VK_RETURN));
	bmap.insert(std::make_pair("KEY_CTRL",VK_CONTROL));
	bmap.insert(std::make_pair("KEY_ALT",VK_MENU));
	bmap.insert(std::make_pair("KEY_CAPS",VK_CAPITAL));
	bmap.insert(std::make_pair("KEY_ESC",VK_ESCAPE));
	bmap.insert(std::make_pair("KEY_SPACE",VK_SPACE));

	bmap.insert(std::make_pair("KEY_PAGEUP",VK_PRIOR));
	bmap.insert(std::make_pair("KEY_PAGEDOWN",VK_NEXT));
	bmap.insert(std::make_pair("KEY_HOME",VK_HOME));
	bmap.insert(std::make_pair("KEY_END",VK_END));
	bmap.insert(std::make_pair("KEY_INSERT",VK_INSERT));
	bmap.insert(std::make_pair("KEY_DELETE",VK_DELETE));

	bmap.insert(std::make_pair("KEY_LEFT",VK_LEFT));
	bmap.insert(std::make_pair("KEY_RIGHT",VK_RIGHT));
	bmap.insert(std::make_pair("KEY_DOWN",VK_DOWN));
	bmap.insert(std::make_pair("KEY_UP",VK_UP));

	bmap.insert(std::make_pair("KEY_F1",VK_F1));
	bmap.insert(std::make_pair("KEY_F2",VK_F2));
	bmap.insert(std::make_pair("KEY_F3",VK_F3));
	bmap.insert(std::make_pair("KEY_F4",VK_F4));
	bmap.insert(std::make_pair("KEY_F5",VK_F5));
	bmap.insert(std::make_pair("KEY_F6",VK_F6));
	bmap.insert(std::make_pair("KEY_F7",VK_F7));
	bmap.insert(std::make_pair("KEY_F8",VK_F8));
	bmap.insert(std::make_pair("KEY_F9",VK_F9));
	bmap.insert(std::make_pair("KEY_F10",VK_F10));
	bmap.insert(std::make_pair("KEY_F11",VK_F11));
	bmap.insert(std::make_pair("KEY_F12",VK_F12));

	bmap.insert(std::make_pair("MOUSE_BUTTON_1",VK_LBUTTON));
	bmap.insert(std::make_pair("MOUSE_BUTTON_2",VK_RBUTTON));
	bmap.insert(std::make_pair("MOUSE_BUTTON_3",VK_MBUTTON));

	bmap.insert(std::make_pair("MOUSE_SCROLL_UP",VK_CUSTOM_SCROLLUP));
	bmap.insert(std::make_pair("MOUSE_SCROLL_DOWN",VK_CUSTOM_SCROLLDOWN));
}