SDXFrameWork 0.07 SDXFrameWork

- メインページ
- 関連ページ
- クラス

全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
Input.h
1 #pragma once//☀SDL
2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Keyboard.h>
4 #include <Multimedia/Mouse.h>
5 #include <Multimedia/Joypad.h>
6 #include <Multimedia/Touch.h>
7 #include <Multimedia/Window.h>
8
9 namespace SDX
10 {
13 class Input
14 {
15 private:
16 Input(){}
17 ~Input();
18 static int handle;
19
20 public:
21
22 static Joypad pad;
23 static Mouse mouse;
24 static Keyboard key;
25 static Touch touch[10];
26 static Gesture gesture;
27
29 static void Reset()
30 {
31 pad.Reset();
32 mouse.Reset();
33 key.Reset();
34 for (auto && it : touch) it.Reset();
35 gesture.Reset();
36 }
37
39 static void Update()
40 {
41 SDL_JoystickUpdate();
42 pad.Update();
43 mouse.Update();
44 key.Update();
45 for (auto && it : touch) it.Update();
46 gesture.Update();
47 }
48
50 static void GetState(SDL_Event &event)
51 {
52 bool isPush = true;
53
54 switch (event.type)
55 {
56 case SDL_KEYUP:
57 isPush = false;
58 case SDL_KEYDOWN:
59 switch (event.key.keysym.sym)
60 {
61 case SDLK_BACKSPACE: key.press[(int)KeyCode::Back] = isPush; break;
62 case SDLK_TAB: key.press[(int)KeyCode::Tab] = isPush; break;
63 case SDLK_RETURN: key.press[(int)KeyCode::Return] = isPush; break;
64 case SDLK_LSHIFT: key.press[(int)KeyCode::LShift] = isPush; break;
65 case SDLK_RSHIFT: key.press[(int)KeyCode::RShift] = isPush; break;
66 case SDLK_LCTRL: key.press[(int)KeyCode::LControl] = isPush; break;
67 case SDLK_RCTRL: key.press[(int)KeyCode::RControl] = isPush; break;
68 case SDLK_ESCAPE: key.press[(int)KeyCode::Escape] = isPush; break;
69 case SDLK_SPACE: key.press[(int)KeyCode::Space] = isPush; break;
70 case SDLK_PAGEUP: key.press[(int)KeyCode::PageUp] = isPush; break;
71 case SDLK_PAGEDOWN: key.press[(int)KeyCode::PageDown] = isPush; break;
72 case SDLK_END: key.press[(int)KeyCode::End] = isPush; break;
73 case SDLK_HOME: key.press[(int)KeyCode::Home] = isPush; break;
74 case SDLK_LEFT:
75 key.press[(int)KeyCode::Left] = isPush;
76 pad.press[(int)PadCode::Left] = isPush;
77 break;
78 case SDLK_UP:
79 key.press[(int)KeyCode::Up] = isPush;
80 pad.press[(int)PadCode::Up] = isPush;
81 break;
82 case SDLK_RIGHT:
83 key.press[(int)KeyCode::Right] = isPush;
84 pad.press[(int)PadCode::Right] = isPush;
85 break;
86 case SDLK_DOWN:
87 key.press[(int)KeyCode::Down] = isPush;
88 pad.press[(int)PadCode::Down] = isPush;
89 break;
90 case SDLK_INSERT: key.press[(int)KeyCode::Insert] = isPush; break;
91 case SDLK_DELETE: key.press[(int)KeyCode::Delete] = isPush; break;
92
93 case SDLK_MINUS: key.press[(int)KeyCode::Minus] = isPush; break;
94 //case Yen = SDLK_YEN,
95 //case PrevTrack = SDLK_PREVTRACK,
96 case SDLK_PERIOD: key.press[(int)KeyCode::Period] = isPush; break;
97 case SDLK_SLASH: key.press[(int)KeyCode::Slash] = isPush; break;
98 case SDLK_LALT: key.press[(int)KeyCode::LAlt] = isPush; break;
99 case SDLK_RALT: key.press[(int)KeyCode::RAlt] = isPush; break;
100 case SDLK_SCROLLLOCK: key.press[(int)KeyCode::Scroll] = isPush; break;
101 case SDLK_SEMICOLON: key.press[(int)KeyCode::Semicolon] = isPush; break;
102 case SDLK_COLON: key.press[(int)KeyCode::Colon] = isPush; break;
103 case SDLK_LEFTBRACKET: key.press[(int)KeyCode::LBracket] = isPush; break;
104 case SDLK_RIGHTBRACKET: key.press[(int)KeyCode::RBracket] = isPush; break;
105 case SDLK_AT: key.press[(int)KeyCode::At] = isPush; break;
106 case SDLK_BACKSLASH: key.press[(int)KeyCode::Backslash] = isPush; break;
107 case SDLK_COMMA: key.press[(int)KeyCode::Comma] = isPush; break;
108 case SDLK_CAPSLOCK: key.press[(int)KeyCode::Capslock] = isPush; break;
109 case SDLK_PAUSE: key.press[(int)KeyCode::Pause] = isPush; break;
110
111 case SDLK_KP_0: key.press[(int)KeyCode::Numpad0] = isPush; break;
112 case SDLK_KP_1: key.press[(int)KeyCode::Numpad1] = isPush; break;
113 case SDLK_KP_2: key.press[(int)KeyCode::Numpad2] = isPush; break;
114 case SDLK_KP_3: key.press[(int)KeyCode::Numpad3] = isPush; break;
115 case SDLK_KP_4: key.press[(int)KeyCode::Numpad4] = isPush; break;
116 case SDLK_KP_5: key.press[(int)KeyCode::Numpad5] = isPush; break;
117 case SDLK_KP_6: key.press[(int)KeyCode::Numpad6] = isPush; break;
118 case SDLK_KP_7: key.press[(int)KeyCode::Numpad7] = isPush; break;
119 case SDLK_KP_8: key.press[(int)KeyCode::Numpad8] = isPush; break;
120 case SDLK_KP_9: key.press[(int)KeyCode::Numpad9] = isPush; break;
121 case SDLK_ASTERISK: key.press[(int)KeyCode::Multiply] = isPush; break;
122 case SDLK_KP_PLUS: key.press[(int)KeyCode::Add] = isPush; break;
123 case SDLK_KP_MINUS: key.press[(int)KeyCode::Subtract] = isPush; break;
124 case SDLK_KP_PERIOD: key.press[(int)KeyCode::Decimal] = isPush; break;
125 case SDLK_KP_DIVIDE: key.press[(int)KeyCode::Divide] = isPush; break;
126 case SDLK_KP_ENTER: key.press[(int)KeyCode::NUMPADEnter] = isPush; break;
127
128 case SDLK_F1: key.press[(int)KeyCode::F1] = isPush; break;
129 case SDLK_F2: key.press[(int)KeyCode::F2] = isPush; break;
130 case SDLK_F3: key.press[(int)KeyCode::F3] = isPush; break;
131 case SDLK_F4: key.press[(int)KeyCode::F4] = isPush; break;
132 case SDLK_F5: key.press[(int)KeyCode::F5] = isPush; break;
133 case SDLK_F6: key.press[(int)KeyCode::F6] = isPush; break;
134 case SDLK_F7: key.press[(int)KeyCode::F7] = isPush; break;
135 case SDLK_F8: key.press[(int)KeyCode::F8] = isPush; break;
136 case SDLK_F9: key.press[(int)KeyCode::F9] = isPush; break;
137 case SDLK_F10: key.press[(int)KeyCode::F10] = isPush; break;
138 case SDLK_F11: key.press[(int)KeyCode::F11] = isPush; break;
139 case SDLK_F12: key.press[(int)KeyCode::F12] = isPush; break;
140
141 case SDLK_a:
142 key.press[(int)KeyCode::A] = isPush;
143 pad.press[(int)PadCode::Button5] = isPush;
144 break;
145 case SDLK_b: key.press[(int)KeyCode::B] = isPush; break;
146 case SDLK_c:
147 key.press[(int)KeyCode::C] = isPush;
148 pad.press[(int)PadCode::Button3] = isPush;
149 break;
150 case SDLK_d:
151 key.press[(int)KeyCode::D] = isPush;
152 pad.press[(int)PadCode::Button7] = isPush;
153 break;
154 case SDLK_e: key.press[(int)KeyCode::E] = isPush; break;
155 case SDLK_f:
156 key.press[(int)KeyCode::F] = isPush;
157 pad.press[(int)PadCode::Button8] = isPush;
158 break;
159 case SDLK_g: key.press[(int)KeyCode::G] = isPush; break;
160 case SDLK_h: key.press[(int)KeyCode::H] = isPush; break;
161 case SDLK_i: key.press[(int)KeyCode::I] = isPush; break;
162 case SDLK_j: key.press[(int)KeyCode::J] = isPush; break;
163 case SDLK_k: key.press[(int)KeyCode::K] = isPush; break;
164 case SDLK_l: key.press[(int)KeyCode::L] = isPush; break;
165 case SDLK_m: key.press[(int)KeyCode::M] = isPush; break;
166 case SDLK_n: key.press[(int)KeyCode::N] = isPush; break;
167 case SDLK_o: key.press[(int)KeyCode::O] = isPush; break;
168 case SDLK_p: key.press[(int)KeyCode::P] = isPush; break;
169 case SDLK_q: key.press[(int)KeyCode::Q] = isPush; break;
170 case SDLK_r: key.press[(int)KeyCode::R] = isPush; break;
171 case SDLK_s:
172 key.press[(int)KeyCode::S] = isPush;
173 pad.press[(int)PadCode::Button6] = isPush;
174 break;
175 case SDLK_t: key.press[(int)KeyCode::T] = isPush; break;
176 case SDLK_u: key.press[(int)KeyCode::U] = isPush; break;
177 case SDLK_v:
178 key.press[(int)KeyCode::V] = isPush;
179 pad.press[(int)PadCode::Button4] = isPush;
180 break;
181 case SDLK_w: key.press[(int)KeyCode::W] = isPush; break;
182 case SDLK_x:
183 key.press[(int)KeyCode::X] = isPush;
184 pad.press[(int)PadCode::Button2] = isPush;
185 break;
186 case SDLK_y: key.press[(int)KeyCode::Y] = isPush; break;
187 case SDLK_z:
188 key.press[(int)KeyCode::Z] = isPush;
189 pad.press[(int)PadCode::Button1] = isPush;
190 break;
191 case SDLK_0: key.press[(int)KeyCode::_0] = isPush; break;
192 case SDLK_1: key.press[(int)KeyCode::_1] = isPush; break;
193 case SDLK_2: key.press[(int)KeyCode::_2] = isPush; break;
194 case SDLK_3: key.press[(int)KeyCode::_3] = isPush; break;
195 case SDLK_4: key.press[(int)KeyCode::_4] = isPush; break;
196 case SDLK_5: key.press[(int)KeyCode::_5] = isPush; break;
197 case SDLK_6: key.press[(int)KeyCode::_6] = isPush; break;
198 case SDLK_7: key.press[(int)KeyCode::_7] = isPush; break;
199 case SDLK_8: key.press[(int)KeyCode::_8] = isPush; break;
200 case SDLK_9: key.press[(int)KeyCode::_9] = isPush; break;
201 }
202 break;
203 case SDL_JOYAXISMOTION:
204 break;
205 //左右の動き
206 if (event.jaxis.axis == 0)
207 {
208 pad.StickX = event.jaxis.value;
209 pad.press[(int)PadCode::Left] = (event.jaxis.value < -0x7000) ;
210 pad.press[(int)PadCode::Right] = (event.jaxis.value > 0x7000);
211 }
212 //上下の動き
213 if (event.jaxis.axis == 1)
214 {
215 pad.StickY = event.jaxis.value;
216 if (event.jaxis.value < -0x7000) pad.press[(int)PadCode::Up] = true;
217 if (event.jaxis.value > 0x7000) pad.press[(int)PadCode::Down] = true;
218 }
219 break;
220 case SDL_JOYHATMOTION:
221 pad.press[(int)PadCode::Up] = false;
222 pad.press[(int)PadCode::Left] = false;
223 pad.press[(int)PadCode::Down] = false;
224 pad.press[(int)PadCode::Right] = false;
225
226 switch (event.jhat.value)
227 {
228 case SDL_HAT_UP :pad.press[(int)PadCode::Up] = true;break;
229 case SDL_HAT_LEFT :pad.press[(int)PadCode::Left] = true; break;
230 case SDL_HAT_DOWN :pad.press[(int)PadCode::Down] = true; break;
231 case SDL_HAT_RIGHT :pad.press[(int)PadCode::Right] = true;break;
232 case SDL_HAT_LEFTUP :pad.press[(int)PadCode::Up] = true;pad.press[(int)PadCode::Left] = true; break;
233 case SDL_HAT_RIGHTUP :pad.press[(int)PadCode::Up] = true;pad.press[(int)PadCode::Right] = true;break;
234 case SDL_HAT_RIGHTDOWN:pad.press[(int)PadCode::Down] = true;pad.press[(int)PadCode::Right] = true;break;
235 case SDL_HAT_LEFTDOWN :pad.press[(int)PadCode::Down] = true;pad.press[(int)PadCode::Left] = true; break;
236 }
237 break;
238 case SDL_JOYBUTTONUP:
239 isPush = false;
240 case SDL_JOYBUTTONDOWN:
241 pad.press[event.jbutton.button] = isPush;
242 break;
243 case SDL_MOUSEMOTION:
244 mouse.xBuffer = event.motion.x;
245 mouse.yBuffer = event.motion.y;
246 break;
247 case SDL_MOUSEBUTTONUP:
248 isPush = false;
249 case SDL_MOUSEBUTTONDOWN:
250 switch (event.button.button)
251 {
252 case SDL_BUTTON_LEFT:mouse.press[(int)MouseCode::Left] = isPush; break;
253 case SDL_BUTTON_RIGHT:mouse.press[(int)MouseCode::Right] = isPush; break;
254 case SDL_BUTTON_MIDDLE:mouse.press[(int)MouseCode::Middle] = isPush; break;
255 case SDL_BUTTON_X1:mouse.press[(int)MouseCode::_4] = isPush; break;
256 case SDL_BUTTON_X2:mouse.press[(int)MouseCode::_5] = isPush; break;
257 }
258 break;
259 case SDL_FINGERUP:
260 isPush = false;
261 case SDL_FINGERDOWN:
262 if (event.tfinger.fingerId >= 10) break;
263 touch[(int)event.tfinger.fingerId].press = isPush;
264 if(event.tfinger.fingerId == 0) mouse.press[(int)MouseCode::Left] = isPush;
265 if(event.tfinger.fingerId == 1) mouse.press[(int)MouseCode::Right] = isPush;
266 case SDL_FINGERMOTION:
267 if (event.tfinger.fingerId >= 10) break;
268 touch[(int)event.tfinger.fingerId].Position( event.tfinger.x,event.tfinger.y);
269 mouse.xBuffer = (int)touch[(int)event.tfinger.fingerId].xBuffer;
270 mouse.yBuffer = (int)touch[(int)event.tfinger.fingerId].yBuffer;
271 break;
272 case SDL_MULTIGESTURE:
273 gesture.press = true;
274 gesture.fingerCount = event.mgesture.numFingers;
275 gesture.pinche = event.mgesture.dDist;
276 gesture.rotate = event.mgesture.dTheta;
277 gesture.Position( event.mgesture.x , event.mgesture.y);
278 break;
279 }
280 }
281
283 static bool Text(int X座標,int Y座標,int 最大文字数, char *初期文字列 ,bool Escキャンセルフラグ ,bool １バイト文字限定フラグ = false)
284 {
285 return false;
286 }
287
292 static int Number(int X座標, int Y座標, int 最小値, int 最大値, int Escキャンセルフラグ)
293 {
294 return false;
295 }
296
299 static bool StartTextMode( int 最大文字数 , bool ESCキャンセル可能フラグ , bool 半角文字限定フラグ , bool 数値入力限定フラグ )
300 {
301 return false;
302 }
303
305 static int CheckText()
306 {
307 return false;
308 }
309
311 static bool DrawText(int X座標 , int Y座標 )
312 {
313 return false;
314 }
315
317 static bool SetText( const char* 文字列 )
318 {
319 return false;
320 }
322 static bool SetText( int 数値 )
323 {
324 return false;
325 }
326
328 static bool GetText( char* 出力バッファ )
329 {
330 return false;
331 }
332
334 static int SetKeyColor(
335 int 入力文字色 ,
336 int IME非使用時カーソル色 ,
337 int IME使用時文字色 ,
338 int IME使用時カーソル色 ,
339 int 変換時下線色 ,
340 int IME使用時変換候補色 ,
341 int 入力モード名色 ,
342 int 入力文字縁色 ,
343 int 変換候補縁色 ,
344 int 入力モード名縁色 ,
345 int 変換候補ウィンドウ縁色 ,
346 int 変換候補ウィンドウ色 )
347 {
348 return false;
349 }
350
351 };
352
353 }
SDX::Keyboard::Reset
void Reset()
状態のリセット.
Definition: Keyboard.h:125
SDX::Input::SetText
static bool SetText(int 数値)
テキストの設定[DXLIB].
Definition: Input.h:322
SDX::Mouse
マウスの状態を表すクラス.
Definition: Mouse.h:12
SDX::Input::Update
static void Update()
状態を更新.
Definition: Input.h:39
SDX::Keyboard
キーボードの状態を表すクラス.
Definition: Keyboard.h:10
SDX::Input::DrawText
static bool DrawText(int X座標, int Y座標)
テキストの描画[DXLIB].
Definition: Input.h:311
SDX::Keyboard::Update
void Update()
状態の更新.
Definition: Keyboard.h:234
SDX::Input::SetKeyColor
static int SetKeyColor(int 入力文字色, int IME非使用時カーソル色, int IME使用時文字色, int IME使用時カーソル色, int 変換時下線色, int IME使用時変換候補色, int 入力モード名色, int 入力文字縁色, int 変換候補縁色, int 入力モード名縁色, int 変換候補ウィンドウ縁色, int 変換候補ウィンドウ色)
キーボード入力時の表示色設定[DXLIB].
Definition: Input.h:334
SDX::Joypad
ジョイパッドの状態を表すクラス.
Definition: Joypad.h:10
SDX::Gesture
Definition: Touch.h:7
SDX::Input::CheckText
static int CheckText()
テキスト入力モードの確認[DXLIB].
Definition: Input.h:305
SDX::Mouse::Reset
void Reset()
状態のリセット.
Definition: Mouse.h:49
SDX::Input::GetText
static bool GetText(char *出力バッファ)
テキストの取得[DXLIB].
Definition: Input.h:328
SDX::Joypad::Reset
void Reset()
状態のリセット.
Definition: Joypad.h:70
SDX::Input
キーやマウスによる入力をまとめて管理するクラス.
Definition: Input.h:13
SDX::Input::SetText
static bool SetText(const char *文字列)
テキストの設定[DXLIB].
Definition: Input.h:317
SDX::Mouse::Update
void Update()
状態の更新.
Definition: Mouse.h:67
SDX::Input::StartTextMode
static bool StartTextMode(int 最大文字数, bool ESCキャンセル可能フラグ, bool 半角文字限定フラグ, bool 数値入力限定フラグ)
テキスト入力モードの開始[DXLIB].
Definition: Input.h:299
SDX::Input::Text
static bool Text(int X座標, int Y座標, int 最大文字数, char *初期文字列, bool Escキャンセルフラグ, bool １バイト文字限定フラグ=false)
処理を停止してキーボードから文字を入力[DXLIB].
Definition: Input.h:283
SDX::Input::Number
static int Number(int X座標, int Y座標, int 最小値, int 最大値, int Escキャンセルフラグ)
キーボードから数字を入力[DXLIB].
Definition: Input.h:292
SDX::Touch
Definition: Touch.h:69
SDX::Input::Reset
static void Reset()
状態をリセット.
Definition: Input.h:29
SDX::Joypad::Update
void Update()
状態の更新.
Definition: Joypad.h:110
SDX::Input::GetState
static void GetState(SDL_Event &event)
入力の状態を更新[SDL].
Definition: Input.h:50