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
RevLine 
[103]1//
[221]2// Lol Engine
[103]3//
[221]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//
[103]10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <SDL.h>
16
[150]17#include "core.h"
[103]18#include "sdlinput.h"
19
20/*
21 * SDL Input implementation class
22 */
23
24class SdlInputData
25{
26    friend class SdlInput;
27
28private:
[150]29    int mx, my;
[103]30};
31
32/*
33 * Public SdlInput class
34 */
35
[170]36SdlInput::SdlInput()
[103]37{
[117]38    SDL_Init(SDL_INIT_TIMER);
39
[103]40    data = new SdlInputData();
[150]41    SDL_GetMouseState(&data->mx, &data->my);
[103]42
[210]43    gamegroup = GAMEGROUP_BEFORE;
[103]44}
45
[149]46void SdlInput::TickGame(float deltams)
[103]47{
[149]48    Entity::TickGame(deltams);
[103]49
50    /* Handle mouse input */
[150]51    SDL_GetMouseState(&data->mx, &data->my);
[103]52
[150]53    /* Handle keyboard and WM events */
[103]54    SDL_Event event;
55    while (SDL_PollEvent(&event))
56    {
57        if (event.type == SDL_QUIT)
[170]58            Ticker::Shutdown();
[103]59#if 0
[150]60        else if (event.type == SDL_KEYDOWN)
61            Input::KeyPressed(event.key.keysym.sym, deltams);
[103]62#endif
63    }
64
[150]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
[103]72}
73
74SdlInput::~SdlInput()
75{
76    delete data;
77}
78
Note: See TracBrowser for help on using the repository browser.