// 下位4ビットは移動キーに割り当てる。
const Button BUTTON_UP = 0x00001;
const Button BUTTON_LEFT = 0x00002;
const Button BUTTON_DOWN = 0x00004;
const Button BUTTON_RIGHT = 0x00008;
const Button BUTTON_SHOT = 0x00010;
const Button BUTTON_BOMB = 0x00020;
const Button BUTTON_SLOW = 0x00040;
typedef unsigned int Button;
Button GetTurnedKeyState()
{
auto dirKey = m_InputState & 0x0f;
auto tmp = ( dirKey & 0x03 ) << 2;
auto turnedDirKey = ( dirKey >> 2 ) | tmp;
return turnedDirKey;
}
void sampleFunc( bool turn )
{
if( turn ) {
auto anotherKey = m_InputState - ( m_InputState & 0x0f );
m_InputState = GetTurnedKeyState() | anotherKey;
}
}
sampleFunc()の anotherKey は方向キー以外のキー入力。