void MoveButtonState::OnPressToggle(bool bDown, boost::signal<void (VariantList*)> *pCustomSignal) { VariantList v; if (bDown) { if (!m_bIsDown) { m_bIsDown = true; v.Get(0).Set(uint32(m_keyType)); v.Get(1).Set(uint32(VIRTUAL_KEY_PRESS)); if (pCustomSignal) { (*pCustomSignal)(&v); } else { GetBaseApp()->m_sig_arcade_input(&v); } } m_releaseTimer = rt_max(GetTick(TIMER_SYSTEM), m_releaseTimer); m_releaseTimer += 1000*60; } else { ReleaseIfNeeded(pCustomSignal); } }
void ArcadeInputComponent::ActivateBinding(ArcadeKeyBind *pBind, bool bDown) { //special handling for directional keys, so they work in tandem with the trackball or whatever else also does directions bool bWasDirectionalKey = true; switch (pBind->m_outputkeycode) { case VIRTUAL_KEY_DIR_LEFT: m_buttons[MOVE_BUTTON_DIR_LEFT].OnPressToggle(bDown, m_customSignal); break; case VIRTUAL_KEY_DIR_RIGHT: m_buttons[MOVE_BUTTON_DIR_RIGHT].OnPressToggle(bDown, m_customSignal); break; case VIRTUAL_KEY_DIR_UP: m_buttons[MOVE_BUTTON_DIR_UP].OnPressToggle(bDown, m_customSignal); break; case VIRTUAL_KEY_DIR_DOWN: m_buttons[MOVE_BUTTON_DIR_DOWN].OnPressToggle(bDown, m_customSignal); break; default: bWasDirectionalKey = false; break; } if (bWasDirectionalKey) { //avoid sending it twice, we already would above return; } //for other keys, just send it through the arcade signal: VariantList v; v.Get(0).Set(pBind->m_outputkeycode); v.Get(1).Set(uint32(bDown)); if (m_customSignal) { (*m_customSignal)(&v); } else { GetBaseApp()->m_sig_arcade_input(&v); } if (bDown) { //send as normal key, only on the keydown VariantList v2; v2.Get(0).Set((float)MESSAGE_TYPE_GUI_CHAR); v2.Get(1).Set(0,0); v2.Get(2).Set(uint32(pBind->m_outputkeycode)); GetBaseApp()->m_sig_input(&v2); } if (pBind->m_bOutputAsNormalKeyToo) { //also send as regular global key GetBaseApp()->m_sig_raw_keyboard(&v); } }
void MoveButtonState::ReleaseIfNeeded(boost::signal<void (VariantList*)> *pCustomSignal) { if (m_bIsDown) { m_bIsDown = false; VariantList v; v.Get(0).Set(uint32(m_keyType)); v.Get(1).Set(uint32(VIRTUAL_KEY_RELEASE)); if (pCustomSignal) { (*pCustomSignal)(&v); } else { GetBaseApp()->m_sig_arcade_input(&v); } } }
void BaseApp::OnMessage(Message &m) { static VariantList v; v.Reset(); switch (m.GetClass()) { case MESSAGE_CLASS_GUI: switch (m.GetType()) { case MESSAGE_TYPE_GUI_CLICK_START: case MESSAGE_TYPE_GUI_CLICK_END: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(float(m.GetParm1()), float(m.GetParm2()) ); v.Get(2).Set(uint32(m.GetParm3())); v.Get(3).Set(m.GetParm4()); if (m.GetType() == MESSAGE_TYPE_GUI_CLICK_START) { // LogMsg("Clicked finger %d, down is %d", m.GetParm3(), (int)m_touchTracker[m.GetParm3()].IsDown()); m_touchTracker[m.GetParm3()].SetIsDown(true); m_touchTracker[m.GetParm3()].SetPos(v.Get(1).GetVector2()); m_touchTracker[m.GetParm3()].SetWasHandled(false); m_touchTracker[m.GetParm3()].SetWasPreHandled(false); } else { // LogMsg("Released finger %d, down is %d", m.GetParm3(), (int)m_touchTracker[m.GetParm3()].IsDown()); m_touchTracker[m.GetParm3()].SetIsDown(false); } m_sig_input(&v); break; } case MESSAGE_TYPE_GUI_CLICK_MOVE: case MESSAGE_TYPE_GUI_CLICK_MOVE_RAW: { if (!m_touchTracker[m.GetParm3()].IsDown()) { //ignore this, we don't want a move message from something that isn't fricken' down. At least //one known HP device is known to do this... break; } v.Get(0).Set(float(m.GetType())); v.Get(1).Set(float(m.GetParm1()), float(m.GetParm2()) ); v.Get(2).Set(uint32(m.GetParm3())); v.Get(3).Set(m.GetParm4()); if (m.GetType() == MESSAGE_TYPE_GUI_CLICK_MOVE) { m_touchTracker[m.GetParm3()].SetPos(v.Get(1).GetVector2()); } if (m_inputMode == INPUT_MODE_NORMAL) { m_sig_input(&v); } else { m_sig_input_move(&v); } break; } case MESSAGE_TYPE_GUI_ACCELEROMETER: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(m.Get().GetVector3()); m_sig_accel(&v); } break; //like MESSAGE_TYPE_GUI_CHAR, but handles up AND down events, and ignores things like key-repeat, better for //arcade action case MESSAGE_TYPE_GUI_CHAR_RAW: { v.Get(0).Set(uint32(m.GetParm1())); v.Get(1).Set(uint32(m.GetParm2())); v.Get(2).Set(uint32(m.GetParm3())); v.Get(3).Set(m.GetParm4()); m_sig_raw_keyboard(&v); } break; //usually used for text input case MESSAGE_TYPE_GUI_CHAR: { #ifdef _DEBUG //LogMsg("Got char: %c (%d)", (char)m.GetParm1(), int(m.GetParm1())); #endif v.Get(0).Set((float)m.GetType()); v.Get(1).Set(0,0); v.Get(2).Set(uint32(m.GetParm1())); v.Get(3).Set(m.GetParm4()); m_sig_input(&v); } break; case MESSAGE_TYPE_GUI_PASTE: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(0,0); v.Get(2).Set(m.Get()); m_sig_input(&v); break; } case MESSAGE_TYPE_GUI_TRACKBALL: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(m.Get().GetVector3()); m_sig_trackball(&v); break; } case MESSAGE_TYPE_HW_TOUCH_KEYBOARD_WILL_SHOW: case MESSAGE_TYPE_HW_TOUCH_KEYBOARD_WILL_HIDE: { v.Get(0).Set((float)m.GetType()); m_sig_hardware(&v); break; } case MESSAGE_TYPE_OS_CONNECTION_CHECKED: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(float(m.GetParm1()), float(m.GetParm2()) ); m_sig_os(&v); } break; case MESSAGE_TYPE_GUI_TOGGLE_FULLSCREEN: { OnFullscreenToggleRequest(); } break; case MESSAGE_TYPE_APP_VERSION: { m_version = m.GetStringParm(); break; } case MESSAGE_TYPE_GUI_MOUSEWHEEL: { v.Get(0).Set((float)m.GetType()); v.Get(1).Set(float(m.GetParm1()), float(m.GetParm2()) ); v.Get(2).Set(uint32(m.GetParm3())); v.Get(3).Set(m.GetParm4()); m_sig_input(&v); break; } } break; case MESSAGE_CLASS_GAME: switch (m.GetType()) { case MESSAGE_TYPE_PLAY_SOUND: if (GetAudioManager()) { GetAudioManager()->Play(m.GetVarName()); } break; case MESSAGE_TYPE_SET_SOUND_ENABLED: GetAudioManager()->SetSoundEnabled(m.Get().GetUINT32() != 0); break; case MESSAGE_TYPE_PRELOAD_SOUND: if (GetAudioManager()) { GetAudioManager()->Preload(ReplaceMP3(m.GetVarName())); } break; case MESSAGE_TYPE_PLAY_MUSIC: if (GetAudioManager()) { GetAudioManager()->Play(ReplaceMP3(m.GetVarName()), true, true); } break; case MESSAGE_TYPE_VIBRATE: if (GetAudioManager()) { GetAudioManager()->Vibrate(m.Get().GetUINT32()); } break; } break; } }