YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
Input.h
浏览该文件的文档.
1 /*
2  Copyright (C) by Franksoft 2012.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #ifndef YCL_INC_INPUT_H_
29 #define YCL_INC_INPUT_H_ 1
30 
31 #include "Keys.h"
32 #include "NativeAPI.h"
33 
34 namespace platform
35 {
36 
38 struct YF_API CursorInfo final
39 #if YCL_DS
40  : public ::touchPosition
41 # define YCL_CURSOR_X px
42 # define YCL_CURSOR_Y py
43 #elif YCL_MINGW32
44  : public ::POINT
45 # define YCL_CURSOR_X x
46 # define YCL_CURSOR_Y y
47 #else
48 # error Unsupport platform found!
49 #endif
50 {
55  template<class _tBinary>
56  operator _tBinary() const
57  {
58  return _tBinary(YCL_CURSOR_X, YCL_CURSOR_Y);
59  }
60 
65  yconstfn std::uint16_t
66  GetX() const
67  {
68  return YCL_CURSOR_X;
69  }
74  yconstfn std::uint16_t
75  GetY() const
76  {
77  return YCL_CURSOR_Y;
78  }
79 #undef YCL_CURSOR_Y
80 #undef YCL_CURSOR_X
81 };
82 
83 
90 #ifndef YCL_DS
91 # define YCL_KEY(X) (#X [0])
92 # define YCL_KEY_Start 'P'
93 #else
94 # define YCL_KEY(X) KeyCodes::X
95 # define YCL_KEY_Start KeyCodes::Start
96 #endif
97 
98 
102 YF_API void
103 WaitForInput();
104 
105 } // namespace platform;
106 
107 namespace platform_ex
108 {
109 
115 #if YCL_MULTITHREAD // || ...
116 # define YCL_KEYSTATE_DIRECT 0
117 #elif defined(YCL_DS)
118 # define YCL_KEYSTATE_DIRECT 1
119 #endif
120 
121 
127 FetchKeyState();
128 
135 
142 
149 
154 YF_API void
156 
161 YF_API void
163 
164 #if YCL_KEYSTATE_DIRECT
165 
170 
171 inline const platform::KeyInput&
173 {
174  return KeyState;
175 }
176 
177 inline const platform::KeyInput&
179 {
180  return OldKeyState;
181 }
182 
183 inline void
185 {
186  yunseq(KeyState.reset(), OldKeyState.reset());
187 }
188 
189 inline platform::KeyInput
191 {
192  return FetchKeyState() &~ FetchOldKeyState();
193 }
194 
195 inline platform::KeyInput
197 {
198  return (FetchKeyState() ^ FetchOldKeyState()) & ~FetchKeyState();
199 }
200 
201 #endif
202 
203 
208 YF_API void
210 
211 
212 #if YCL_DS
213 
217 YF_API void
219 
223 inline void
225 {
226  WaitForKey(KEY_A | KEY_B | KEY_X | KEY_Y | KEY_L | KEY_R
227  | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN
228  | KEY_START | KEY_SELECT);
229 }
230 
234 inline void
236 {
237  WaitForKey(KEY_TOUCH | KEY_A | KEY_B | KEY_X | KEY_Y
238  | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN
239  | KEY_START | KEY_SELECT);
240 }
241 
245 inline void
247 {
248  WaitForKey(KEY_A | KEY_B | KEY_X | KEY_Y
249  | KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN
250  |KEY_START | KEY_SELECT);
251 }
252 
256 inline void
258 {
259  WaitForKey(KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN);
260 }
261 
265 inline void
267 {
268  WaitForKey(KEY_A | KEY_B | KEY_X | KEY_Y);
269 }
270 #endif
271 
272 } // namespace platform_ex;
273 
274 #endif
275