KisaragiLibrary
 
読み取り中…
検索中…
一致する文字列を見つけられません
Kisaragi_Lib::KeyInput クラス

#include <KeyInput.hpp>

公開メンバ関数

 KeyInput ()
 
void KeyCheck ()
 Key入力を取得する
 
bool KeyDown (const KeyCode &_key)
 
bool KeyHold (const KeyCode &_key)
 
bool KeyUp (const KeyCode &_key)
 

非公開変数類

unsigned int saveInputKeyHistorySize = 0
 
deque< unordered_set< KeyCode > > keyBuffer
 

構築子と解体子

◆ KeyInput()

Kisaragi_Lib::KeyInput::KeyInput ( )
inline
201 {
202 //余剰バッファ + 現在バッファ を確保
204 }
deque< unordered_set< KeyCode > > keyBuffer
Definition KeyInput.hpp:197
unsigned int saveInputKeyHistorySize
Definition KeyInput.hpp:195

関数詳解

◆ KeyCheck()

void Kisaragi_Lib::KeyInput::KeyCheck ( )
inline

Key入力を取得する

210 {
211 //現在のフレームのコンテナを追加.
212 keyBuffer.push_front(unordered_set<KeyCode>());
213
214 //コンテナ数が超えたら
215 if (keyBuffer.size() + 1 > saveInputKeyHistorySize)
216 {
217 //コンテナ削除.
218 keyBuffer.pop_back();
219 }
220
221 //入力取得用配列作成.
222 char buf[256];
223
224 //Key入力取得.
225 GetHitKeyStateAll(buf);
226
227 for (int i = 0; i < 256; i++)
228 {
229 //入力されているものを登録する.
230 if (buf[i] == 1)
231 {
232 //現在フレームのコンテナにkeyを登録する.
233 keyBuffer.front().insert((KeyCode)i);
234 }
235 }
236
237 }
KeyCode
KeyCode列挙型 DirectInputのkeycodeです。
Definition KeyInput.hpp:27

参照元 KisaragiFacade::MainRoop().

◆ KeyDown()

bool Kisaragi_Lib::KeyInput::KeyDown ( const KeyCode & _key)
inline
240 {
241 bool result = true;
242
243 //直前のフレームで押されているなら
244 if (keyBuffer[1].find(_key) != keyBuffer[1].end())
245 {
246 result = false;
247 }
248
249 //見つからない場合.
250 if (keyBuffer.front().find(_key) == keyBuffer.front().end())
251 {
252 result = false;
253 }
254
255 return result;
256 }

◆ KeyHold()

bool Kisaragi_Lib::KeyInput::KeyHold ( const KeyCode & _key)
inline
259 {
260 bool result = true;
261
262 //見つからない場合.
263 if (keyBuffer.front().find(_key) == keyBuffer.front().end())
264 {
265 result = false;
266 }
267
268 return result;
269 }

◆ KeyUp()

bool Kisaragi_Lib::KeyInput::KeyUp ( const KeyCode & _key)
inline
272 {
273 bool result = false;
274
275 //直前のフレームで押されているなら
276 if (keyBuffer[1].find(_key) != keyBuffer[1].end())
277 {
278 //見つからない場合(押されていないなら).
279 if (keyBuffer.front().find(_key) == keyBuffer.front().end())
280 {
281 result = true;
282 }
283 }
284
285 return result;
286 }

メンバ詳解

◆ saveInputKeyHistorySize

unsigned int Kisaragi_Lib::KeyInput::saveInputKeyHistorySize = 0
private

参照元 KeyCheck(), KeyInput().

◆ keyBuffer

deque<unordered_set<KeyCode> > Kisaragi_Lib::KeyInput::keyBuffer
private

このクラス詳解は次のファイルから抽出されました: