source: trunk/src/sdlinput.cpp @ 210

Last change on this file since 210 was 210, checked in by sam, 11 years ago

Allow for different priorities in game and draw tick levels.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010 Sam Hocevar <sam@hocevar.net>
4//
5
6#if defined HAVE_CONFIG_H
7#   include "config.h"
8#endif
9
10#include <SDL.h>
11
12#include "core.h"
13#include "sdlinput.h"
14
15/*
16 * SDL Input implementation class
17 */
18
19class SdlInputData
20{
21    friend class SdlInput;
22
23private:
24    int mx, my;
25};
26
27/*
28 * Public SdlInput class
29 */
30
31SdlInput::SdlInput()
32{
33    SDL_Init(SDL_INIT_TIMER);
34
35    data = new SdlInputData();
36    SDL_GetMouseState(&data->mx, &data->my);
37
38    gamegroup = GAMEGROUP_BEFORE;
39}
40
41void SdlInput::TickGame(float deltams)
42{
43    Entity::TickGame(deltams);
44
45    /* Handle mouse input */
46    SDL_GetMouseState(&data->mx, &data->my);
47
48    /* Handle keyboard and WM events */
49    SDL_Event event;
50    while (SDL_PollEvent(&event))
51    {
52        if (event.type == SDL_QUIT)
53            Ticker::Shutdown();
54#if 0
55        else if (event.type == SDL_KEYDOWN)
56            Input::KeyPressed(event.key.keysym.sym, deltams);
57#endif
58    }
59
60    /* Send the whole keyboard state to the input system */
61#if 0
62    Uint8 *keystate = SDL_GetKeyState(NULL);
63    for (int i = 0; i < 256; i++)
64        if (keystate[i])
65            Input::KeyPressed(i, deltams);
66#endif
67}
68
69SdlInput::~SdlInput()
70{
71    delete data;
72}
73
Note: See TracBrowser for help on using the repository browser.