source: trunk/src/input/keyboard.cpp @ 2009

Last change on this file since 2009 was 2009, checked in by sam, 7 years ago

input: add the Keyboard abstraction object type.

  • Property svn:keywords set to Id
File size: 1.0 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 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 <cstdlib>
16
17#include "core.h"
18
19namespace lol
20{
21
22/*
23 * Keyboard implementation class
24 */
25
26static class KeyboardData
27{
28    friend class Keyboard;
29
30public:
31    KeyboardData() { }
32
33private:
34    Array<uint32_t> m_chars;
35}
36keyboarddata;
37
38/*
39 * Public Keyboard class
40 */
41
42Keyboard::Keyboard()
43  : m_data(new KeyboardData())
44{
45}
46
47Keyboard::~Keyboard()
48{
49    delete m_data;
50}
51
52void Keyboard::PushChar(uint32_t ch)
53{
54    m_data->m_chars.Push(ch);
55}
56
57uint32_t Keyboard::PopChar()
58{
59    if (!m_data->m_chars.Count())
60        return 0;
61
62    uint32_t ret = m_data->m_chars[0];
63    m_data->m_chars.Remove(0);
64    return ret;
65}
66
67} /* namespace lol */
68
Note: See TracBrowser for help on using the repository browser.