LRESULT CALLBACK KeyHandler(int nCode, WPARAM wParam, LPARAM lParam) {

    if (GetAsyncKeyState(VK_LWIN) != 0)
    if (nCode >= 0 && (wParam == WM_KEYDOWN || wParam == WM_KEYUP))
    {
        KBDLLHOOKSTRUCT kbdStruct = *((KBDLLHOOKSTRUCT*)lParam);
        HWND hTaskView = FindWindow("MultitaskingViewFrame", NULL);

        switch (wParam)
        {
        case WM_KEYDOWN:
            if (kbdStruct.vkCode == VK_TAB)
            {
                //TODO: Find another way to open Task View 

                if (GetAsyncKeyState(VK_SHIFT) != 0 && reverse == false)
                {
                    /*
                    Achtung! Костыль!
                    Task View doesn't open when you press [Win + Shift + Tab]
                    Release [Shift] to fix this, but remeber reverse direction
                    */

                    reverse = true;
                    if (hTaskView == NULL)
                        SimulateInput(VK_SHIFT, KEYEVENTF_KEYUP);
                }

                SwitchVirtualDesktop(pDesktopManager, reverse);

                //Interrupt [Tab] to prevent Task View closing
                if (hTaskView != NULL)
                    return 1;
            }
            break;

        case WM_KEYUP:
            if (hTaskView != NULL)
            {
                if (kbdStruct.vkCode == VK_LWIN)
                {
                    //TODO: Find another way to close Task View 
                    SimulateInput(VK_ESCAPE);
                    reverse = false;
                }
                else if (kbdStruct.vkCode == VK_LSHIFT)
                {
                    reverse = false;
                }
            }
            break;

        default:
            break;
        }
    }

    return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
}
コード例 #2
0
ファイル: GBEmulator.cpp プロジェクト: GinNoOokami/GBEmu
//----------------------------------------------------------------------------------------------------
void GBEmulator::Run()
{
    m_bRunning = true;

#ifdef _DEBUG
    string oPath;
    ifstream oFile( "debug_load.ini" );
    if( oFile )
    {
        while( getline( oFile, oPath ) )
        {
            if( oPath.front() != ';' )
            {
                LoadCartridge( oPath.c_str() );
                break;
            }
        }
        oFile.close();
    }
#endif

    while( m_bRunning )
    {
        SDL_Event oEvent;
        while( SDL_PollEvent( &oEvent ) )
        {
            switch( oEvent.type )
            {
                case SDL_KEYDOWN:
                    HandleShortcuts( &oEvent );
                    // Intentional fall-through
                case SDL_KEYUP:
                    SimulateInput( &oEvent );
                    break;

                case SDL_DROPFILE:
                    LoadCartridge( oEvent.drop.file );
                    SDL_free( oEvent.drop.file );
                    break;

                case SDL_QUIT:
                    m_bRunning = false;
                    break;
            }
        }

        Update();
    }

    Profiler()->DisplayProfiles();
}