예제 #1
0
// Returns: TRUE - close menu, FALSE - do not close menu
int Main_ExecuteMenuCommand(int command, int rightleft)
{
    switch (command)
    {
    case ID_VIDEO_MODE:
        Main_ExecuteCommand(rightleft ? ID_VIDEO_MODE_NEXT : ID_VIDEO_MODE_PREV);
        return FALSE;
    default:
        Main_ExecuteCommand(command);
        return TRUE;
    }
}
예제 #2
0
void Main_OnKeyJoyEvent(SDL_Event evt)
{
    int pressed = (evt.type == SDL_KEYDOWN || evt.type == SDL_JOYBUTTONDOWN);
    //int sourcetype = (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP) ? EVKEY : EVJOY;

    //DEBUG
    if (pressed) printf("KeyDown %d\n", evt.key.keysym.sym);

    BYTE ukncscan = FindKeyMapping(evt.key.keysym.sym);
    if (ukncscan != 0)  // UKNC event mapping found
    {
        Emulator_KeyboardEvent(ukncscan, pressed);
    }
    else if (pressed)  // Commands works only on key/button press, not release
    {
        int command = FindCommandMapping(evt.key.keysym.sym);
        if (command != 0)  // Command mapping found
        {
            Main_ExecuteCommand(command);
        }
    }
}
예제 #3
0
// Handles SDL keyboard press/release and joystick button press/release events.
void Main_OnKeyJoyEvent(SDL_Event evt)
{
    KeyMappingStruct* mapping;
    int pressed = (evt.type == SDL_KEYDOWN || evt.type == SDL_JOYBUTTONDOWN);
    int sourcetype = (evt.type == SDL_KEYDOWN || evt.type == SDL_KEYUP) ? EVKEY : EVJOY;

    if (g_okKeyboard)  // Onscreen keyboard mode
    {
        mapping = FindKeyMapping(sourcetype, evt.key.keysym.sym, TRUE);
        if (mapping == NULL)
            return;
        int command = mapping->resultcd;
        if (pressed)
        {
            switch (command)
            {
            case ID_MENU_ESCAPE:
            case ID_MENU:
            case ID_KEYBOARD:
                Main_ExecuteCommand(ID_KEYBOARD);
                return;
            case ID_MENU_UP:
            case ID_MENU_DOWN:
            case ID_MENU_LEFT:
            case ID_MENU_RIGHT:
                g_KeyboardCurrent = Main_KeyboardFindNearestKey(command);
                return;
            case ID_MENU_SELECT:
                Emulator_KeyboardEvent(m_arrKeyboardKeys[g_KeyboardCurrent].code, TRUE);
                break;
            default:
                break;
            }
        }
        else
        {
            if (command == ID_MENU_SELECT)
            {
                Emulator_KeyboardEvent(m_arrKeyboardKeys[g_KeyboardCurrent].code, FALSE);
            }
        }
        return;
    }

    mapping = FindKeyMapping(sourcetype, evt.key.keysym.sym, FALSE);
    if (mapping != NULL)  // BK event mapping found
    {
        BYTE result = mapping->resultcd;
        if (mapping->resulttype == EVJOY)
            Emulator_JoystickEvent(result, pressed);
        else
            Emulator_KeyboardEvent(result, pressed);
    }
    else if (pressed)  // Commands works only on key/button press, not release
    {
        mapping = FindKeyMapping(sourcetype, evt.key.keysym.sym, TRUE);
        if (mapping != NULL)  // Command mapping found
        {
            Main_ExecuteCommand(mapping->resultcd);
        }
    }
}