source: trunk/src/sdlinput.cpp @ 221

Last change on this file since 221 was 221, checked in by sam, 12 years ago

Complete Lol Engine / Deus Hax / Monsterz split.

  • Property svn:keywords set to Id
File size: 1.5 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <SDL.h>
16
17#include "core.h"
18#include "sdlinput.h"
19
20/*
21 * SDL Input implementation class
22 */
23
24class SdlInputData
25{
26    friend class SdlInput;
27
28private:
29    int mx, my;
30};
31
32/*
33 * Public SdlInput class
34 */
35
36SdlInput::SdlInput()
37{
38    SDL_Init(SDL_INIT_TIMER);
39
40    data = new SdlInputData();
41    SDL_GetMouseState(&data->mx, &data->my);
42
43    gamegroup = GAMEGROUP_BEFORE;
44}
45
46void SdlInput::TickGame(float deltams)
47{
48    Entity::TickGame(deltams);
49
50    /* Handle mouse input */
51    SDL_GetMouseState(&data->mx, &data->my);
52
53    /* Handle keyboard and WM events */
54    SDL_Event event;
55    while (SDL_PollEvent(&event))
56    {
57        if (event.type == SDL_QUIT)
58            Ticker::Shutdown();
59#if 0
60        else if (event.type == SDL_KEYDOWN)
61            Input::KeyPressed(event.key.keysym.sym, deltams);
62#endif
63    }
64
65    /* Send the whole keyboard state to the input system */
66#if 0
67    Uint8 *keystate = SDL_GetKeyState(NULL);
68    for (int i = 0; i < 256; i++)
69        if (keystate[i])
70            Input::KeyPressed(i, deltams);
71#endif
72}
73
74SdlInput::~SdlInput()
75{
76    delete data;
77}
78
Note: See TracBrowser for help on using the repository browser.