comparison ext/guichan-0.8.1/include/guichan/hge/hgeinput.hpp @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /* _______ __ __ __ ______ __ __ _______ __ __
2 * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3 * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4 * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5 * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6 * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7 * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8 *
9 * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
10 *
11 *
12 * Per Larsson a.k.a finalman
13 * Olof Naessén a.k.a jansem/yakslem
14 *
15 * Visit: http://guichan.sourceforge.net
16 *
17 * License: (BSD)
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in
25 * the documentation and/or other materials provided with the
26 * distribution.
27 * 3. Neither the name of Guichan nor the names of its contributors may
28 * be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
37 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 #ifndef GCN_HGEINPUT_HPP
45 #define GCN_HGEINPUT_HPP
46
47 #include <queue>
48 #include <hge.h>
49
50 #if defined(DELETE)
51 #undef DELETE
52 #endif
53
54 #include "guichan/input.hpp"
55 #include "guichan/keyinput.hpp"
56 #include "guichan/mouseinput.hpp"
57 #include "guichan/platform.hpp"
58
59 namespace gcn
60 {
61 /**
62 * HGE implementation of Input.
63 *
64 * @author Kevin Lynx
65 * @since 0.6.1
66 */
67 class GCN_EXTENSION_DECLSPEC HGEInput : public Input
68 {
69 public:
70
71 /**
72 * Constructor.
73 */
74 HGEInput();
75
76 /**
77 * Destructor.
78 */
79 virtual ~HGEInput();
80
81
82 //Inherited from Input
83
84 virtual bool isKeyQueueEmpty();
85
86 virtual bool isMouseQueueEmpty();
87
88 virtual KeyInput dequeueKeyInput();
89
90 virtual MouseInput dequeueMouseInput();
91
92 virtual void _pollInput();
93
94 protected:
95 /**
96 * Handles key input. The function is called by _pollInput.
97 *
98 * @param ki the hge input event to handle.
99 */
100 void pollKeyInput(hgeInputEvent &ki);
101
102 /**
103 * Handles mouse input. The function is called by _pollInput.
104 *
105 * This function directly deal with the mouse input , and it avoid
106 * the odd things in HGE.
107 */
108 void pollMouseInput();
109
110 /**
111 * Converts the keycode and characters to a Key object.
112 *
113 * @param key The key to convert.
114 * @param chr The character to convert.
115 */
116 Key convertToKey(int key, int chr);
117
118 /**
119 * Checks if a keyCode is numeric.
120 *
121 * @param keyCode The key code to check.
122 */
123 bool isNumericPad(int keyCode);
124
125 protected:
126 static HGE *mHGE;
127
128 std::queue<KeyInput> mKeyInputQueue;
129 std::queue<MouseInput> mMouseInputQueue;
130
131 float mMouseX;
132 float mMouseY;
133
134 bool mLeftMouseButtonDown;
135 bool mRightMouseButtonDown;
136 bool mMiddleMouseButtonDown;
137 };
138 }
139
140 #endif // end GCN_HGEINPUT_HPP