当前位置: 首页>>代码示例>>C++>>正文


C++ MapVirtualKey函数代码示例

本文整理汇总了C++中MapVirtualKey函数的典型用法代码示例。如果您正苦于以下问题:C++ MapVirtualKey函数的具体用法?C++ MapVirtualKey怎么用?C++ MapVirtualKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MapVirtualKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

    /**
     * Handles all keyboard input.
     * @param vkCode the key pressed
     * @param bKeyDown <code>true</code> if the key is pressed, else it is released
     * @param sender the window that send the keyboard messages
     */
    bool ApplicationBase::HandleKeyboard(unsigned int vkCode, bool bKeyDown, BaseGLWindow* sender)
    {
        auto handled = 0;
        static unsigned __int64 s_PrevKeyDown = 0;
        static __int64 s_PrevKeyDownMod = 0;
        static auto s_PrevKeyDownHandled = 0;

        auto kmod = 0;
        auto testkp = 0;
        auto k = 0;
        auto twVKCode = vkCode == VK_NUMRETURN ? VK_RETURN : vkCode;
        if (sender->GetKeyboardModState(VK_MOD_SHIFT)) kmod |= TW_KMOD_SHIFT;
        if (sender->GetKeyboardModState(VK_MOD_CTRL)) {
            kmod |= TW_KMOD_CTRL; testkp = 1;
        }
        if (sender->GetKeyboardModState(VK_MOD_MENU)) {
            kmod |= TW_KMOD_ALT;  testkp = 1;
        }

        if (twVKCode >= VK_F1 && twVKCode <= VK_F15)
            k = TW_KEY_F1 + (twVKCode - VK_F1);
        else if (testkp && twVKCode >= VK_NUMPAD0 && twVKCode <= VK_NUMPAD9)
            k = '0' + (twVKCode - VK_NUMPAD0);
        else switch (twVKCode)
        {
        case VK_UP:
            k = TW_KEY_UP;
            break;
        case VK_DOWN:
            k = TW_KEY_DOWN;
            break;
        case VK_LEFT:
            k = TW_KEY_LEFT;
            break;
        case VK_RIGHT:
            k = TW_KEY_RIGHT;
            break;
        case VK_INSERT:
            k = TW_KEY_INSERT;
            break;
        case VK_DELETE:
            k = TW_KEY_DELETE;
            break;
        case VK_PRIOR:
            k = TW_KEY_PAGE_UP;
            break;
        case VK_NEXT:
            k = TW_KEY_PAGE_DOWN;
            break;
        case VK_HOME:
            k = TW_KEY_HOME;
            break;
        case VK_END:
            k = TW_KEY_END;
            break;
        case VK_DIVIDE:
            if (testkp)
                k = '/';
            break;
        case VK_MULTIPLY:
            if (testkp)
                k = '*';
            break;
        case VK_SUBTRACT:
            if (testkp)
                k = '-';
            break;
        case VK_ADD:
            if (testkp)
                k = '+';
            break;
        case VK_DECIMAL:
            if (testkp)
                k = '.';
            break;
        default:
            if ((kmod&TW_KMOD_CTRL) && (kmod&TW_KMOD_ALT))
                k = MapVirtualKey(twVKCode, 2) & 0x0000FFFF;
        }

        if (bKeyDown) {
            if (k != 0)
                handled = TwKeyPressed(k, kmod);
            else
            {
                // if the key will be handled at next WM_CHAR report this event as handled
                auto key = static_cast<int>(MapVirtualKey(twVKCode, 2) & 0xff);
                if (kmod&TW_KMOD_CTRL && key > 0 && key < 27)
                    key += 'a' - 1;
                if (key > 0 && key < 256)
                    handled = TwKeyPressed(key, kmod);
            }
            s_PrevKeyDown = twVKCode;
            s_PrevKeyDownMod = kmod;
//.........这里部分代码省略.........
开发者ID:dasmysh,项目名称:OGLFramework_uulm,代码行数:101,代码来源:ApplicationBase.cpp

示例2: key_event

/* return code -1 means that event_queue_ptr won't be incremented.
   In other word, this event makes two key codes.   (by himi)       */
static int
key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
{
  static int mod_key_state = 0;
  int wParam;

  *isdead = 0;

  /* Skip key-up events.  */
  if (!event->bKeyDown)
    {
      switch (event->wVirtualKeyCode)
	{
	case VK_LWIN:
	  mod_key_state &= ~LEFT_WIN_PRESSED;
	  break;
	case VK_RWIN:
	  mod_key_state &= ~RIGHT_WIN_PRESSED;
	  break;
	case VK_APPS:
	  mod_key_state &= ~APPS_PRESSED;
	  break;
	}
      return 0;
    }

  /* Ignore keystrokes we fake ourself; see below.  */
  if (faked_key == event->wVirtualKeyCode)
    {
      faked_key = 0;
      return 0;
    }

  /* To make it easier to debug this code, ignore modifier keys!  */
  switch (event->wVirtualKeyCode)
    {
    case VK_LWIN:
      if (NILP (Vw32_pass_lwindow_to_system))
	{
	  /* Prevent system from acting on keyup (which opens the Start
	     menu if no other key was pressed) by simulating a press of
	     Space which we will ignore.  */
	  if ((mod_key_state & LEFT_WIN_PRESSED) == 0)
	    {
	      if (NUMBERP (Vw32_phantom_key_code))
		faked_key = XUINT (Vw32_phantom_key_code) & 255;
	      else
		faked_key = VK_SPACE;
	      keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0);
	    }
	}
      mod_key_state |= LEFT_WIN_PRESSED;
      if (!NILP (Vw32_lwindow_modifier))
	return 0;
      break;
    case VK_RWIN:
      if (NILP (Vw32_pass_rwindow_to_system))
	{
	  if ((mod_key_state & RIGHT_WIN_PRESSED) == 0)
	    {
	      if (NUMBERP (Vw32_phantom_key_code))
		faked_key = XUINT (Vw32_phantom_key_code) & 255;
	      else
		faked_key = VK_SPACE;
	      keybd_event (faked_key, (BYTE) MapVirtualKey (faked_key, 0), 0, 0);
	    }
	}
      mod_key_state |= RIGHT_WIN_PRESSED;
      if (!NILP (Vw32_rwindow_modifier))
	return 0;
      break;
    case VK_APPS:
      mod_key_state |= APPS_PRESSED;
      if (!NILP (Vw32_apps_modifier))
	return 0;
      break;
    case VK_CAPITAL:
      /* Decide whether to treat as modifier or function key.  */
      if (NILP (Vw32_enable_caps_lock))
	goto disable_lock_key;
      return 0;
    case VK_NUMLOCK:
      /* Decide whether to treat as modifier or function key.  */
      if (NILP (Vw32_enable_num_lock))
	goto disable_lock_key;
      return 0;
    case VK_SCROLL:
      /* Decide whether to treat as modifier or function key.  */
      if (NILP (Vw32_scroll_lock_modifier))
	goto disable_lock_key;
      return 0;
    disable_lock_key:
      /* Ensure the appropriate lock key state is off (and the
	 indicator light as well).  */
      wParam = event->wVirtualKeyCode;
      if (GetAsyncKeyState (wParam) & 0x8000)
	{
	  /* Fake another press of the relevant key.  Apparently, this
//.........这里部分代码省略.........
开发者ID:exedre,项目名称:emacs,代码行数:101,代码来源:w32inevt.c

示例3: switch

//*-----------------------------------------------------------------------------------------//
/// @brief 채팅을 한번 할때마다 Enter 를 입력 해야 하는 방식
//*-----------------------------------------------------------------------------------------//
bool CITStateNormal::ProcessHotKeyNormalInput( unsigned uiMsg, WPARAM wParam, LPARAM lParam )
{
	if( CTEditBox::s_pFocusEdit == NULL )///입력 포커스가 없는경우
	{
		switch(uiMsg)
		{
		case WM_KEYDOWN:
			{
				unsigned int oemScan = int( lParam & (0xff << 16) ) >> 16; 
				UINT vk = MapVirtualKey( oemScan, 1 );

				switch( vk )
				{
				case 0x41:
					g_itMGR.OpenDialog( DLG_TYPE_CHAR);
					return true;
				case 0x43:
					g_itMGR.OpenDialog( DLG_TYPE_COMMUNITY );
					return true;
				case 0x48:
					return true;

				case 0x49:
				case 0x56:
					g_itMGR.OpenDialog( DLG_TYPE_ITEM );
					return true;
				case 0x53:
					g_itMGR.OpenDialog( DLG_TYPE_SKILL );
					return true;
				case 0x51:
					g_itMGR.OpenDialog( DLG_TYPE_QUEST );
					return true;
				case 0x4d:
					{
						CMinimapDLG* pDlg = ( CMinimapDLG*)g_itMGR.FindDlg( DLG_TYPE_MINIMAP );
						pDlg->ToggleShowMinimap();
						return true;
					}
				case 0x4c:
					{
						CMinimapDLG* pDlg = ( CMinimapDLG*)g_itMGR.FindDlg( DLG_TYPE_MINIMAP );
						pDlg->ToggleZoomMinimap();
						return true;
					}
				case 0x4e:
					{
						g_itMGR.OpenDialog( DLG_TYPE_CLAN );
						return true;
					}
			/*	case 0x58:
					g_itMGR.OpenDialog( DLG_TYPE_SYSTEM );
					return true;*/
				case 0x4f:
					g_itMGR.OpenDialog( DLG_TYPE_OPTION );
					return true;
				default:
					break;
				}
			}
			return false;
		default:
			break;
			
		}
	}
	return ProcessHotKeyAutoEnter( uiMsg, wParam, lParam );
}
开发者ID:PurpleYouko,项目名称:Wibble_Wibble,代码行数:70,代码来源:CITStateNormal.cpp

示例4: MapVirtualKey

// Parses the keys in m_sKeys string and puts them into m_KeyList
void CKeystrokeEngine::ParseKeys()
{
	KeyStruct	tempKey, keyAltHold, keyCtrlHold, keyShiftHold,
				keyAltRelease, keyCtrlRelease, keyShiftRelease;

	keyAltHold.nAction = Action_KeyDown;
	keyAltHold.nOptional = 0;
	keyAltHold.nSpecial = SK_None;
	keyAltHold.Vk = VK_MENU;
	keyAltHold.nScan = MapVirtualKey (VK_MENU, 0);

	keyCtrlHold.nAction = Action_KeyDown;
	keyCtrlHold.nOptional = 0;
	keyCtrlHold.nSpecial = SK_None;
	keyCtrlHold.Vk = VK_CONTROL;
	keyCtrlHold.nScan = MapVirtualKey (VK_CONTROL, 0);

	keyShiftHold.nAction = Action_KeyDown;
	keyShiftHold.nOptional = 0;
	keyShiftHold.nSpecial = SK_None;
	keyShiftHold.Vk = VK_SHIFT;
	keyShiftHold.nScan = MapVirtualKey (VK_SHIFT, 0);

	keyAltRelease.nAction = Action_KeyUp;
	keyAltRelease.nOptional = 0;
	keyAltRelease.nSpecial = SK_None;
	keyAltRelease.Vk = VK_MENU;
	keyAltRelease.nScan = MapVirtualKey (VK_MENU, 0);

	keyCtrlRelease.nAction = Action_KeyUp;
	keyCtrlRelease.nOptional = 0;
	keyCtrlRelease.nSpecial = SK_None;
	keyCtrlRelease.Vk = VK_CONTROL;
	keyCtrlRelease.nScan = MapVirtualKey (VK_CONTROL, 0);

	keyShiftRelease.nAction = Action_KeyUp;
	keyShiftRelease.nOptional = 0;
	keyShiftRelease.nSpecial = SK_None;
	keyShiftRelease.Vk = VK_SHIFT;
	keyShiftRelease.nScan = MapVirtualKey (VK_SHIFT, 0);

	m_KeyList.clear ();
	int idx = 0;
	int nKeyLength = m_sKeys.size ();
	char c = 0;
	char szTemp [MAX_SK_LEN];
	SHORT nTemp;
	bool bNotASpecialKey = false;
	
	bool bPushAltRelease = false, bPushCtrlRelease = false, bPushShiftRelease = false;

	while (idx < nKeyLength)
	{
		c = m_sKeys[idx];
		// if a normal key
		if (bNotASpecialKey || 
			((c != '<') || ((c == '<') && (idx == nKeyLength - 1)))
			)
		{
			bNotASpecialKey = false;
			tempKey.nAction = Action_KeyPress;
			tempKey.nSpecial = SK_None;
			nTemp = VkKeyScan (c);
			tempKey.Vk = LOBYTE (nTemp);
            int nTempState = HIBYTE(nTemp);

			if (nTempState & 0x0001)
				m_KeyList.push_back (keyShiftHold);
			if (nTempState & 0x0002)
				m_KeyList.push_back (keyCtrlHold);
			if (nTempState & 0x0004)
				m_KeyList.push_back (keyAltHold);
			
			tempKey.nScan = MapVirtualKey (tempKey.Vk, 0);
			m_KeyList.push_back (tempKey);

			if (nTempState & 0x0004)
				m_KeyList.push_back (keyAltRelease);
			if (nTempState & 0x0002)
				m_KeyList.push_back (keyCtrlRelease);
			if (nTempState & 0x0001)
				m_KeyList.push_back (keyShiftRelease);

			if (bPushAltRelease)
				m_KeyList.push_back (keyAltRelease);
			if (bPushCtrlRelease)
				m_KeyList.push_back (keyCtrlRelease);
			if (bPushShiftRelease)
				m_KeyList.push_back (keyShiftRelease);
			bPushAltRelease = false;
			bPushCtrlRelease = false;
			bPushShiftRelease = false;

			++ idx;
		}
		// if a special key
		else
		{
			bNotASpecialKey = false;
//.........这里部分代码省略.........
开发者ID:brkpt,项目名称:luaplus51-all,代码行数:101,代码来源:KeystrokeEngine.cpp

示例5: mapVirtualKey

inline unsigned int mapVirtualKey(unsigned int key) {
	return MapVirtualKey(key, MAPVK_VK_TO_VSC);
}
开发者ID:Ordinaryperson2,项目名称:3DSController,代码行数:3,代码来源:keys.c

示例6: switch

void plInputManager::HandleWin32ControlEvent(UINT message, WPARAM Wparam, LPARAM Lparam, hsWindowHndl hWnd)
{
    if( !fhWnd )
        fhWnd = hWnd;

    bool bExtended;

    switch (message)
    {
    case SYSKEYDOWN:
    case KEYDOWN:
        {
            bExtended = Lparam >> 24 & 1;
            bool bRepeat = ((Lparam >> 29) & 0xf) != 0;
            for (int i=0; i<fInputDevices.Count(); i++)
                fInputDevices[i]->HandleKeyEvent( KEYDOWN, UntranslateKey((plKeyDef)Wparam, bExtended), true, bRepeat ); 
        }
        break;
    case SYSKEYUP:
    case KEYUP:
        {
            bExtended = Lparam >> 24 & 1;
            for (int i=0; i<fInputDevices.Count(); i++)
                fInputDevices[i]->HandleKeyEvent( KEYUP, UntranslateKey((plKeyDef)Wparam, bExtended), false, false ); 
        }
        break;
    case CHAR_MSG:
        {
            wchar_t ch = (wchar_t)Wparam;

            // These are handled by KEYUP/KEYDOWN and should not be sent
            // We don't like garbage getting in string fields
            if (std::iscntrl(ch, localeC))
                break;

            BYTE scan = (BYTE)(Lparam >> 16);
            UINT vkey = MapVirtualKey(scan, 1); //MAPVK_VSC_TO_VK

            bExtended = Lparam >> 24 & 1;
            bool bRepeat = ((Lparam >> 29) & 0xf) != 0;
            bool down = !(Lparam >> 31);
 
            for (int i=0; i<fInputDevices.Count(); i++)
                fInputDevices[i]->HandleKeyEvent( CHAR_MSG, (plKeyDef)vkey, down, bRepeat, ch );
        }
        break;
    case MOUSEWHEEL:
        {
            plMouseEventMsg* pMsg = new plMouseEventMsg;
            int zDelta = GET_WHEEL_DELTA_WPARAM(Wparam);
            pMsg->SetWheelDelta((float)zDelta);
            if (zDelta < 0)
                pMsg->SetButton(kWheelNeg);
            else
                pMsg->SetButton(kWheelPos);

            RECT rect;
            GetClientRect(hWnd, &rect);
            pMsg->SetXPos(LOWORD(Lparam) / (float)rect.right);
            pMsg->SetYPos(HIWORD(Lparam) / (float)rect.bottom);

            pMsg->Send();
        }
        break;
    case MOUSEMOVE:
    case L_BUTTONDN:
    case L_BUTTONUP:
    case R_BUTTONDN:
    case R_BUTTONUP:
    case L_BUTTONDBLCLK:
    case R_BUTTONDBLCLK:
    case M_BUTTONDN:
    case M_BUTTONUP:
        {
            
            RECT rect;
            GetClientRect(hWnd, &rect);
         
            plIMouseXEventMsg* pXMsg = new plIMouseXEventMsg;
            plIMouseYEventMsg* pYMsg = new plIMouseYEventMsg;
            plIMouseBEventMsg* pBMsg = new plIMouseBEventMsg;

            pXMsg->fWx = LOWORD(Lparam);
            pXMsg->fX = (float)LOWORD(Lparam) / (float)rect.right;
            pYMsg->fWy = HIWORD(Lparam);
            pYMsg->fY = (float)HIWORD(Lparam) / (float)rect.bottom;

            // Apply mouse scale
//          pXMsg->fX *= fMouseScale;
//          pYMsg->fY *= fMouseScale;
            
            if (Wparam & MK_LBUTTON && message != L_BUTTONUP)
            {
                pBMsg->fButton |= kLeftButtonDown;
            }
            else
            {
                pBMsg->fButton |= kLeftButtonUp;
            }
                        
//.........这里部分代码省略.........
开发者ID:branan,项目名称:Plasma-nobink,代码行数:101,代码来源:plInputManager.cpp

示例7: _get_key_count

static int _get_key_count(void)
{
    int num_keys = 0, vk;

    PDC_LOG(("_get_key_count() - called\n"));

    vk = KEV.wVirtualKeyCode;

    if (KEV.bKeyDown)
    {
        /* key down */

        save_press = 0;

        if (vk == VK_CAPITAL || vk == VK_NUMLOCK || vk == VK_SCROLL)
        {
            /* throw away these modifiers */
        }
        else if (vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU)
        {
            /* These keys are returned on keyup only. */

            save_press = vk;
            switch (vk)
            {
            case VK_SHIFT:
                left_key = GetKeyState(VK_LSHIFT);
                break;
            case VK_CONTROL:
                left_key = GetKeyState(VK_LCONTROL);
                break;
            case VK_MENU:
                left_key = GetKeyState(VK_LMENU);
            }
        }
        else
        {
            /* Check for diacritics. These are dead keys. Some locales
               have modified characters like umlaut-a, which is an "a"
               with two dots on it. In some locales you have to press a
               special key (the dead key) immediately followed by the
               "a" to get a composed umlaut-a. The special key may have
               a normal meaning with different modifiers. */

            if (KEV.uChar.UnicodeChar || !(MapVirtualKey(vk, 2) & 0x80000000))
                num_keys = KEV.wRepeatCount;
        }
    }
    else
    {
        /* key up */

        /* Only modifier keys or the results of ALT-numpad entry are
           returned on keyup */

        if ((vk == VK_MENU && KEV.uChar.UnicodeChar) ||
           ((vk == VK_SHIFT || vk == VK_CONTROL || vk == VK_MENU) &&
             vk == save_press))
        {
            save_press = 0;
            num_keys = 1;
        }
    }

    PDC_LOG(("_get_key_count() - returning: num_keys %d\n", num_keys));

    return num_keys;
}
开发者ID:Bill-Gray,项目名称:PDCurses,代码行数:68,代码来源:pdckbd.c

示例8: switch

NzKeyboard::Key NzWindowImpl::ConvertVirtualKey(WPARAM key, LPARAM flags)
{
	switch (key)
	{
		case VK_CONTROL:	return (HIWORD(flags) & KF_EXTENDED) ? NzKeyboard::RControl : NzKeyboard::LControl;
		case VK_MENU:		return (HIWORD(flags) & KF_EXTENDED) ? NzKeyboard::RAlt : NzKeyboard::LAlt;
		case VK_SHIFT:
		{
			static UINT scancode = MapVirtualKey(VK_SHIFT, MAPVK_VK_TO_VSC);
			return (((flags >> 16) & 0xFF) == scancode) ? NzKeyboard::LShift : NzKeyboard::RShift;
		}

		case 0x30:                 return NzKeyboard::Num0;
		case 0x31:                 return NzKeyboard::Num1;
		case 0x32:                 return NzKeyboard::Num2;
		case 0x33:                 return NzKeyboard::Num3;
		case 0x34:                 return NzKeyboard::Num4;
		case 0x35:                 return NzKeyboard::Num5;
		case 0x36:                 return NzKeyboard::Num6;
		case 0x37:                 return NzKeyboard::Num7;
		case 0x38:                 return NzKeyboard::Num8;
		case 0x39:                 return NzKeyboard::Num9;
		case 0x41:                 return NzKeyboard::A;
		case 0x42:                 return NzKeyboard::B;
		case 0x43:                 return NzKeyboard::C;
		case 0x44:                 return NzKeyboard::D;
		case 0x45:                 return NzKeyboard::E;
		case 0x46:                 return NzKeyboard::F;
		case 0x47:                 return NzKeyboard::G;
		case 0x48:                 return NzKeyboard::H;
		case 0x49:                 return NzKeyboard::I;
		case 0x4A:                 return NzKeyboard::J;
		case 0x4B:                 return NzKeyboard::K;
		case 0x4C:                 return NzKeyboard::L;
		case 0x4D:                 return NzKeyboard::M;
		case 0x4E:                 return NzKeyboard::N;
		case 0x4F:                 return NzKeyboard::O;
		case 0x50:                 return NzKeyboard::P;
		case 0x51:                 return NzKeyboard::Q;
		case 0x52:                 return NzKeyboard::R;
		case 0x53:                 return NzKeyboard::S;
		case 0x54:                 return NzKeyboard::T;
		case 0x55:                 return NzKeyboard::U;
		case 0x56:                 return NzKeyboard::V;
		case 0x57:                 return NzKeyboard::W;
		case 0x58:                 return NzKeyboard::X;
		case 0x59:                 return NzKeyboard::Y;
		case 0x5A:                 return NzKeyboard::Z;
		case VK_ADD:               return NzKeyboard::Add;
		case VK_BACK:              return NzKeyboard::Backspace;
		case VK_BROWSER_BACK:      return NzKeyboard::Browser_Back;
		case VK_BROWSER_FAVORITES: return NzKeyboard::Browser_Favorites;
		case VK_BROWSER_FORWARD:   return NzKeyboard::Browser_Forward;
		case VK_BROWSER_HOME:      return NzKeyboard::Browser_Home;
		case VK_BROWSER_REFRESH:   return NzKeyboard::Browser_Refresh;
		case VK_BROWSER_SEARCH:    return NzKeyboard::Browser_Search;
		case VK_BROWSER_STOP:      return NzKeyboard::Browser_Stop;
		case VK_CAPITAL:           return NzKeyboard::CapsLock;
		case VK_CLEAR:             return NzKeyboard::Clear;
		case VK_DECIMAL:           return NzKeyboard::Decimal;
		case VK_DELETE:            return NzKeyboard::Delete;
		case VK_DIVIDE:            return NzKeyboard::Divide;
		case VK_DOWN:              return NzKeyboard::Down;
		case VK_END:               return NzKeyboard::End;
		case VK_ESCAPE:            return NzKeyboard::Escape;
		case VK_F1:                return NzKeyboard::F1;
		case VK_F2:                return NzKeyboard::F2;
		case VK_F3:                return NzKeyboard::F3;
		case VK_F4:                return NzKeyboard::F4;
		case VK_F5:                return NzKeyboard::F5;
		case VK_F6:                return NzKeyboard::F6;
		case VK_F7:                return NzKeyboard::F7;
		case VK_F8:                return NzKeyboard::F8;
		case VK_F9:                return NzKeyboard::F9;
		case VK_F10:               return NzKeyboard::F10;
		case VK_F11:               return NzKeyboard::F11;
		case VK_F12:               return NzKeyboard::F12;
		case VK_F13:               return NzKeyboard::F13;
		case VK_F14:               return NzKeyboard::F14;
		case VK_F15:               return NzKeyboard::F15;
		case VK_HOME:              return NzKeyboard::Home;
		case VK_INSERT:            return NzKeyboard::Insert;
		case VK_LEFT:              return NzKeyboard::Left;
		case VK_LWIN:              return NzKeyboard::LSystem;
		case VK_MEDIA_NEXT_TRACK:  return NzKeyboard::Media_Next;
		case VK_MEDIA_PLAY_PAUSE:  return NzKeyboard::Media_Play;
		case VK_MEDIA_PREV_TRACK:  return NzKeyboard::Media_Previous;
		case VK_MEDIA_STOP:        return NzKeyboard::Media_Stop;
		case VK_MULTIPLY:          return NzKeyboard::Multiply;
		case VK_NEXT:              return NzKeyboard::PageDown;
		case VK_NUMPAD0:           return NzKeyboard::Numpad0;
		case VK_NUMPAD1:           return NzKeyboard::Numpad1;
		case VK_NUMPAD2:           return NzKeyboard::Numpad2;
		case VK_NUMPAD3:           return NzKeyboard::Numpad3;
		case VK_NUMPAD4:           return NzKeyboard::Numpad4;
		case VK_NUMPAD5:           return NzKeyboard::Numpad5;
		case VK_NUMPAD6:           return NzKeyboard::Numpad6;
		case VK_NUMPAD7:           return NzKeyboard::Numpad7;
		case VK_NUMPAD8:           return NzKeyboard::Numpad8;
		case VK_NUMPAD9:           return NzKeyboard::Numpad9;
//.........这里部分代码省略.........
开发者ID:GuillaumeBelz,项目名称:NazaraEngine,代码行数:101,代码来源:WindowImpl.cpp

示例9: WndProc


//.........这里部分代码省略.........
				
				//right button
				if (mouseData.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN)
					listener->MousePressed(HQKeyCode::RBUTTON, point);
				else if (mouseData.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP)
					listener->MouseReleased(HQKeyCode::RBUTTON, point);
				
				//middle button
				if (mouseData.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN)
					listener->MousePressed(HQKeyCode::MBUTTON, point);
				else if (mouseData.usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP)
					listener->MouseReleased(HQKeyCode::MBUTTON, point);

				//wheel
				if (mouseData.usButtonFlags & RI_MOUSE_WHEEL)
					listener->MouseWheel((hqfloat32)(SHORT)mouseData.usButtonData, point);

			}//if (rawInput->header.dwType == RIM_TYPEMOUSE)
			else if (rawInput->header.dwType == RIM_TYPEKEYBOARD)//keyboard
			{
				RAWKEYBOARD &keyData = rawInput->data.keyboard;
				USHORT scanCode = keyData.MakeCode;
				HQKeyCodeType keyCode = keyData.VKey;

				switch (keyData.VKey)
				{
				case VK_CONTROL:
					keyCode = (scanCode & 0xe000) != 0 ? HQKeyCode::RCONTROL : HQKeyCode::LCONTROL;
					break;
				case VK_MENU:
					keyCode = (scanCode & 0xe000) != 0 ? HQKeyCode::RALT : HQKeyCode::LALT;
					break;
				case VK_SHIFT:
					keyCode = MapVirtualKey(scanCode, MAPVK_VSC_TO_VK_EX);
					break;
				}//switch (keyData.VKey)

				if (keyData.Flags & RI_KEY_BREAK)//key up
				{
					HQEngineApp::GetInstance()->GetKeyListener()->KeyReleased(keyCode);
					g_keyPressed[keyCode] = false;
				}
				else
				{
					HQEngineApp::GetInstance()->GetKeyListener()->KeyPressed(keyCode, g_keyPressed[keyCode]);
					g_keyPressed[keyCode] = true;
				}

			}//else if (rawInput->header.dwType == RIM_TYPEKEYBOARD)
		}//else
	}//if (GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT)

}
/*--------handle legacy key down message------------------*/
bool KeyDownMessage(WPARAM wParam, LPARAM lParam)
{
	bool repeated_msg = (lParam & 0x40000000) != 0;
	switch (wParam)
	{
	case VK_CONTROL:
		if ((lParam & (0x1 << 24)) == 0)//left
			HQEngineApp::GetInstance()->GetKeyListener()->KeyPressed(HQKeyCode::LCONTROL, repeated_msg);
		else//right
			HQEngineApp::GetInstance()->GetKeyListener()->KeyPressed(HQKeyCode::RCONTROL, repeated_msg);
		break;
	case VK_MENU:
开发者ID:kakashidinho,项目名称:HQEngine,代码行数:67,代码来源:HQEngineWindowWin32.cpp

示例10: vlc_savecancel


//.........这里部分代码省略.........
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_LEFT );
            break;
        case WM_LBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_LEFT );
            break;
        case WM_LBUTTONDBLCLK:
            vout_display_SendEventMouseDoubleClick(vd);
            break;

        case WM_MBUTTONDOWN:
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_CENTER );
            break;
        case WM_MBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_CENTER );
            break;

        case WM_RBUTTONDOWN:
            MousePressed( p_event, msg.hwnd, MOUSE_BUTTON_RIGHT );
            break;
        case WM_RBUTTONUP:
            MouseReleased( p_event, MOUSE_BUTTON_RIGHT );
            break;

        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        {
            /* The key events are first processed here and not translated
             * into WM_CHAR events because we need to know the status of the
             * modifier keys. */
            int i_key = Win32VoutConvertKey( msg.wParam );
            if( !i_key )
            {
                /* This appears to be a "normal" (ascii) key */
                i_key = tolower( (unsigned char)MapVirtualKey( msg.wParam, 2 ) );
            }

            if( i_key )
            {
                if( GetKeyState(VK_CONTROL) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_CTRL;
                }
                if( GetKeyState(VK_SHIFT) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_SHIFT;
                }
                if( GetKeyState(VK_MENU) & 0x8000 )
                {
                    i_key |= KEY_MODIFIER_ALT;
                }

                vout_display_SendEventKey(vd, i_key);
            }
            break;
        }

        case WM_MOUSEWHEEL:
        {
            int i_key;
            if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
            {
                i_key = KEY_MOUSEWHEELUP;
            }
            else
            {
                i_key = KEY_MOUSEWHEELDOWN;
开发者ID:chouquette,项目名称:vlc,代码行数:67,代码来源:events.c

示例11: WindowProcedure


//.........这里部分代码省略.........

                case WM_LBUTTONUP:
                if (!mousecapture && (curtube == 3 || mouse_amx))
                {
                        GetClipCursor(&oldclip);
                        GetWindowRect(hwnd, &newclip);
                        newclip.left   += GetSystemMetrics(SM_CXFIXEDFRAME) + 10;
                        newclip.right  -= GetSystemMetrics(SM_CXFIXEDFRAME) + 10;
                        newclip.top    += GetSystemMetrics(SM_CXFIXEDFRAME) + GetSystemMetrics(SM_CYMENUSIZE) + GetSystemMetrics(SM_CYCAPTION) + 10;
                        newclip.bottom -= GetSystemMetrics(SM_CXFIXEDFRAME) + 10;
                        ClipCursor(&newclip);
                        mousecapture = 1;
                        updatewindowtitle();
                }
                break;

                case WM_ENTERMENULOOP:
//              log_debug("EnterMenuLoop\n");
                bempause = 1;
                //EnterCriticalSection(&cs);
                break;
                case WM_EXITMENULOOP:
//              log_debug("ExitMenuLoop\n");
                bempause = 0;
                key_clear();
                for (c = 0; c < 128; c++) key[c] = 0;
                //LeaveCriticalSection(&cs);
                break;

                case WM_SETFOCUS:
//              log_debug("SetFocus\n");
                key_clear();
                for (c = 0; c < 128; c++) key[c] = 0;
		bempause = 0;
		break;

                case WM_SIZE:
                winsizex = lParam & 0xFFFF;
                winsizey = lParam >> 16;
                break;

        	case WM_SYSKEYDOWN:
        	case WM_KEYDOWN:
                if (LOWORD(wParam) != 255)
                {
                        //log_debug("Key %04X %04X\n",LOWORD(wParam),VK_LEFT);
                        c = MapVirtualKey(LOWORD(wParam),0);
                        c = hw_to_mycode[c];
//                        log_debug("MVK %i %i %i\n",c,hw_to_mycode[c],KEY_PGUP);
                        if (LOWORD(wParam) == VK_LEFT)   c = KEY_LEFT;
                        if (LOWORD(wParam) == VK_RIGHT)  c = KEY_RIGHT;
                        if (LOWORD(wParam) == VK_UP)     c = KEY_UP;
                        if (LOWORD(wParam) == VK_DOWN)   c = KEY_DOWN;
                        if (LOWORD(wParam) == VK_HOME)   c = KEY_HOME;
                        if (LOWORD(wParam) == VK_END)    c = KEY_END;
                        if (LOWORD(wParam) == VK_INSERT) c = KEY_INSERT;
                        if (LOWORD(wParam) == VK_DELETE) c = KEY_DEL;
                        if (LOWORD(wParam) == VK_PRIOR)  c = KEY_PGUP;
                        if (LOWORD(wParam) == VK_NEXT)   c = KEY_PGDN;
                        //log_debug("MVK2 %i %i %i\n",c,hw_to_mycode[c],KEY_PGUP);
                        key[c]=1;
                }
                break;
        	case WM_SYSKEYUP:
        	case WM_KEYUP:
                if (LOWORD(wParam) != 255)
                {
//                        log_debug("Key %04X %04X\n",LOWORD(wParam),VK_LEFT);
                        c = MapVirtualKey(LOWORD(wParam), 0);
                        c = hw_to_mycode[c];
                        if (LOWORD(wParam) == VK_LEFT)   c = KEY_LEFT;
                        if (LOWORD(wParam) == VK_RIGHT)  c = KEY_RIGHT;
                        if (LOWORD(wParam) == VK_UP)     c = KEY_UP;
                        if (LOWORD(wParam) == VK_DOWN)   c = KEY_DOWN;
                        if (LOWORD(wParam) == VK_HOME)   c = KEY_HOME;
                        if (LOWORD(wParam) == VK_END)    c = KEY_END;
                        if (LOWORD(wParam) == VK_INSERT) c = KEY_INSERT;
                        if (LOWORD(wParam) == VK_DELETE) c = KEY_DEL;
                        if (LOWORD(wParam) == VK_PRIOR)  c = KEY_PGUP;
                        if (LOWORD(wParam) == VK_NEXT)   c = KEY_PGDN;
//                        log_debug("MVK %i\n",c);
                        key[c] = 0;
                }
                break;

                case WM_CREATE:

//        initbbc(argc,argv);

//        free(argv);

//                mainthread=(HANDLE)_beginthread(_mainthread,0,NULL);
                break;

                default:
                r = DefWindowProc (hwnd, message, wParam, lParam);
		return r;
        }
        return 0;
}
开发者ID:hoglet67,项目名称:b-em,代码行数:101,代码来源:win.c

示例12: _ASSERTE

// pvkKeys - 0-terminated VKKeys array
bool CConEmuInside::SendVkKeySequence(HWND hWnd, WORD* pvkKeys)
{
	bool bSent = false;
	//DWORD_PTR nRc1, nRc2;
	LRESULT lSendRc = 0;
	DWORD nErrCode = 0;

	if (!pvkKeys || !*pvkKeys)
	{
		_ASSERTE(pvkKeys && *pvkKeys);
		return false;
	}

	// Только для XP
	_ASSERTE(gnOsVer < 0x600);
	HWND hWorker1 = GetDlgItem(hWnd, 0xA005);
	if (!CheckClassName(hWorker1, L"WorkerW"))
		return false;
	HWND hReBar1 = GetDlgItem(hWorker1, 0xA005);
	if (!CheckClassName(hReBar1, L"ReBarWindow32"))
		return false;
	HWND hMenuBar = FindTopWindow(hReBar1, L"ToolbarWindow32");
	if (!hMenuBar)
		return false;

	size_t k = 0;

	HWND hSend = hMenuBar;

	while (pvkKeys[k])
	{
		// Prep send msg values
		UINT nMsg1 = (pvkKeys[k] == VK_F10) ? WM_SYSKEYDOWN : WM_KEYDOWN;
		DEBUGTEST(UINT nMsg2 = (pvkKeys[k] == VK_F10) ? WM_SYSKEYUP : WM_KEYUP);
		UINT vkScan = MapVirtualKey(pvkKeys[k], 0/*MAPVK_VK_TO_VSC*/);
		LPARAM lParam1 = 0x00000001 | (vkScan << 16);
		DEBUGTEST(LPARAM lParam2 = 0xC0000001 | (vkScan << 16));

		// Post KeyDown&KeyUp
		if (pvkKeys[k] == VK_F10)
		{
			PostMessage(hMenuBar, WM_LBUTTONDOWN, 0, MAKELONG(5,5));
			PostMessage(hMenuBar, WM_LBUTTONUP, 0, MAKELONG(5,5));
			//lSendRc = PostMessage(hWnd, nMsg1, pvkKeys[k], lParam1)
			//	&& PostMessage(hWnd, nMsg2, pvkKeys[k], lParam2);
			Sleep(100);
			hSend = hMenuBar;
		}
		else
		{
			// Sequental keys send to "menu" control
			lSendRc = PostMessage(hSend, nMsg1, pvkKeys[k], lParam1);
			if (lSendRc)
			{
				Sleep(100);
				//lSendRc = PostMessage(hSend, nMsg2, pvkKeys[k], lParam2);
				//Sleep(100);
			}
		}

		if (lSendRc)
		{
			bSent = true;
		}
		else
		{
			// failed, may be ERROR_TIMEOUT?
			nErrCode = GetLastError();
			bSent = false;
			break;
		}

		k++;
	}

	// SendMessageTimeout failed?
	_ASSERTE(bSent);

	UNREFERENCED_PARAMETER(nErrCode);

	return bSent;
}
开发者ID:Alexander-Shukaev,项目名称:ConEmu,代码行数:83,代码来源:Inside.cpp

示例13: Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey

JNIEXPORT jint JNICALL Java_org_lwjgl_opengl_WindowsKeyboard_MapVirtualKey(JNIEnv *env, jclass unused, jint uCode, jint uMapType) {
	return MapVirtualKey(uCode, uMapType);
}
开发者ID:AlvinNorin,项目名称:Lumen,代码行数:3,代码来源:org_lwjgl_opengl_WindowsKeyboard.c

示例14: _glfwTranslateKey

static int _glfwTranslateKey( DWORD wParam, DWORD lParam )
{
    MSG next_msg;
    DWORD msg_time;
    DWORD scan_code;

    // Check which key was pressed or released
    switch( wParam )
    {
        // The SHIFT keys require special handling
        case VK_SHIFT:
            // Compare scan code for this key with that of VK_RSHIFT in
            // order to determine which shift key was pressed (left or
            // right)
            scan_code = MapVirtualKey( VK_RSHIFT, 0 );
            if( ((lParam & 0x01ff0000) >> 16) == scan_code )
            {
                return GLFW_KEY_RSHIFT;
            }
            return GLFW_KEY_LSHIFT;

        // The CTRL keys require special handling
        case VK_CONTROL:
            // Is this an extended key (i.e. right key)?
            if( lParam & 0x01000000 )
            {
                return GLFW_KEY_RCTRL;
            }
            // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
            // want the RALT message, so we try to see if the next message
            // is a RALT message. In that case, this is a false LCTRL!
            msg_time = GetMessageTime();
            if( PeekMessage( &next_msg, NULL, 0, 0, PM_NOREMOVE ) )
            {
                if( next_msg.message == WM_KEYDOWN ||
                    next_msg.message == WM_SYSKEYDOWN )
                {
                    if( next_msg.wParam == VK_MENU &&
                        (next_msg.lParam & 0x01000000) &&
                        next_msg.time == msg_time )
                    {
                        // Next message is a RALT down message, which
                        // means that this is NOT a proper LCTRL message!
                        return GLFW_KEY_UNKNOWN;
                    }
                }
            }
            return GLFW_KEY_LCTRL;

        // The ALT keys require special handling
        case VK_MENU:
            // Is this an extended key (i.e. right key)?
            if( lParam & 0x01000000 )
            {
                return GLFW_KEY_RALT;
            }
            return GLFW_KEY_LALT;

        // The ENTER keys require special handling
        case VK_RETURN:
            // Is this an extended key (i.e. right key)?
            if( lParam & 0x01000000 )
            {
                return GLFW_KEY_KP_ENTER;
            }
            return GLFW_KEY_ENTER;

        // Special keys (non character keys)
        case VK_ESCAPE:        return GLFW_KEY_ESC;
        case VK_TAB:           return GLFW_KEY_TAB;
        case VK_BACK:          return GLFW_KEY_BACKSPACE;
        case VK_HOME:          return GLFW_KEY_HOME;
        case VK_END:           return GLFW_KEY_END;
        case VK_PRIOR:         return GLFW_KEY_PAGEUP;
        case VK_NEXT:          return GLFW_KEY_PAGEDOWN;
        case VK_INSERT:        return GLFW_KEY_INSERT;
        case VK_DELETE:        return GLFW_KEY_DEL;
        case VK_LEFT:          return GLFW_KEY_LEFT;
        case VK_UP:            return GLFW_KEY_UP;
        case VK_RIGHT:         return GLFW_KEY_RIGHT;
        case VK_DOWN:          return GLFW_KEY_DOWN;
        case VK_F1:            return GLFW_KEY_F1;
        case VK_F2:            return GLFW_KEY_F2;
        case VK_F3:            return GLFW_KEY_F3;
        case VK_F4:            return GLFW_KEY_F4;
        case VK_F5:            return GLFW_KEY_F5;
        case VK_F6:            return GLFW_KEY_F6;
        case VK_F7:            return GLFW_KEY_F7;
        case VK_F8:            return GLFW_KEY_F8;
        case VK_F9:            return GLFW_KEY_F9;
        case VK_F10:           return GLFW_KEY_F10;
        case VK_F11:           return GLFW_KEY_F11;
        case VK_F12:           return GLFW_KEY_F12;
        case VK_F13:           return GLFW_KEY_F13;
        case VK_F14:           return GLFW_KEY_F14;
        case VK_F15:           return GLFW_KEY_F15;
        case VK_F16:           return GLFW_KEY_F16;
        case VK_F17:           return GLFW_KEY_F17;
        case VK_F18:           return GLFW_KEY_F18;
        case VK_F19:           return GLFW_KEY_F19;
//.........这里部分代码省略.........
开发者ID:VajraFramework,项目名称:Tools,代码行数:101,代码来源:win32_window.c

示例15: PushFnKey

//-----------------------------------------------------------
//function keys
void PushFnKey(CString KeyCode)
{

	// Outputs function key. KeyCode may have a number of times to be output
	LONG NumPushes;
	INT index;
	CString FnKey;
	CString OrigCode;
	bool isfnkey=false;

	// Work out which function key to push and how many times

	//get key press count & strip out count characters
	NumPushes=GetFunctionKeyCount(KeyCode);

	//keep a copy
	OrigCode=KeyCode;

	FnKey=KeyCode.UpperCase();

	//direct code entry
	if (FnKey.Pos("\\")==1)
	{
		ProcessFuncKey(FnKey);
		return;
	}

	//braces
	if (FnKey=="LEFTBRACE" || FnKey=="RIGHTBRACE")
	{
		char pc=FnKey.Pos("LEFT")<1 ? '}' : '{';
		for (index=1;index<=NumPushes;index++)
		{
			PushAKey(pc);
		}
		return;
	}

	//search for F key
	byte fnkey=GetFunctionKey(FnKey);

	if (fnkey==(byte)-1)
		fnkey=GetControlKey(FnKey);

	if (fnkey!=(byte)-1)
	{
		isfnkey=true;
	}

	//press f key
	if (isfnkey)
	{
		bool dodos=false;

		//do DOS conversion?
		if (DOSKey)
		{
			byte vk[]={VK_BELL,VK_BREAK,VK_RETURN,VK_ESCAPE,VK_CLEAR,VK_LINEFEED,VK_TAB};
			char dk[]={'G','C','M','[','L','J','I'};

			//search for key equivalent
			for (int i=0;i<sizeof(vk)/sizeof(vk[0]);i++)
			{
				if (fnkey==vk[i])
				{
					//match found
					dodos=true;

					for (index=1;index<=NumPushes;index++)
					{
						//do key press
						PushCTRLKey(dk[i]);
					}
					break;
				}
			}
		}
		if (!dodos)//normal fkey
		{
			for (index=1;index<=NumPushes;index++)
			{
				//reserved characters
				if (GetControlKey(fnkey)!=(byte)-1)
				{
					PushAKey(fnkey);
				}
				else
				{
					//full printscreen
					if (fnkey==VK_SNAPSHOT && !AltOn)
					{
						PressKey(fnkey,1);
					}
					else
					{
						PressKey(fnkey,MapVirtualKey(fnkey,0));
					}
				}
//.........这里部分代码省略.........
开发者ID:henryfung01,项目名称:GameCode4,代码行数:101,代码来源:windows.cpp


注:本文中的MapVirtualKey函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。