Ejemplo n.º 1
0
        static private InputStruct CheckKeyDown(SDL_Event userEvent)
        {
            InputStruct input = new InputStruct {
                inputEvent = UNDEFINED_INPUT, x = 0, y = 0
            };

            SDL_GetMouseState(out input.x, out input.y);
            switch (userEvent.key.keysym.sym)
            {
            case SDLK_ESCAPE:
                input.inputEvent = PRESS_ESCAPE;
                break;

            case SDLK_DOWN:
                input.inputEvent = PRESS_DOWN;
                break;

            case SDLK_UP:
                input.inputEvent = PRESS_UP;
                break;

            case SDLK_w:
                input.inputEvent = PRESS_W;
                break;

            case SDLK_s:
                input.inputEvent = PRESS_S;
                break;

            case SDLK_a:
                input.inputEvent = PRESS_A;
                break;

            case SDLK_d:
                input.inputEvent = PRESS_D;
                break;

            case SDLK_p:
                input.inputEvent = PRESS_P;
                break;

            case SDLK_o:
                input.inputEvent = PRESS_O;
                break;

            case SDLK_RETURN:
                input.inputEvent = PRESS_ENTER;
                break;

            case SDLK_SPACE:
                input.inputEvent = PRESS_SPACE;
                break;
            }
            return(input);
        }
Ejemplo n.º 2
0
        static private InputStruct CheckMouseDown(SDL_Event userEvent)
        {
            InputStruct input = new InputStruct {
                inputEvent = UNDEFINED_INPUT, x = 0, y = 0
            };

            switch ((uint)userEvent.button.button)
            {
            case SDL_BUTTON_LEFT:
                input.inputEvent = PRESS_LEFT_BUTTON;
                input.x          = userEvent.button.x;
                input.y          = userEvent.button.y;
                break;

            case SDL_BUTTON_RIGHT:
                input.inputEvent = PRESS_RIGHT_BUTTON;
                input.x          = userEvent.button.x;
                input.y          = userEvent.button.y;
                break;
            }
            return(input);
        }