bool InputMapper::IsButtonDown( MenuInput MenuI ) { GameInput GameI[4]; MenuToGame( MenuI, GameI ); for( int i=0; i<4; i++ ) if( GameI[i].IsValid() && IsButtonDown(GameI[i]) ) return true; return false; }
//=============================================================================================== // FUNCTION: OnMouseMove // PURPOSE: Processes the mouse move message. // void CRepeatButton::OnMouseMove(UINT nFlags, CPoint point) { ASSERT_VALID(this); // Make sure the user still has the mouse button down if ( !IsButtonDown() ) EndTracking(); // Don't call base class so that repeat continues even if finger is off button. return; }
bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) { if (!m_pNormalWidget || !IsButtonDown()) return false; SetButtonDown(false); CFWL_MessageMouse ms(nullptr, m_pNormalWidget.get()); ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; ms.m_pos = FWLToClient(point); TranslateFWLMessage(&ms); return true; }
BOOL HasBtnDown(int preKeyPress) { if (preKeyPress == -1) return FALSE; //若上一个键没有弹起则重新不做任何事 if(IsButtonDown(preKeyPress)) { return TRUE; } return FALSE; }
bool CXFA_FFCheckButton::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { if (!m_pNormalWidget || !IsButtonDown()) return false; SetButtonDown(false); CFWL_MsgMouse ms; ms.m_dwCmd = FWL_MouseCommand::LeftButtonUp; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; FWLToClient(ms.m_fx, ms.m_fy); ms.m_pDstTarget = m_pNormalWidget->GetWidget(); TranslateFWLMessage(&ms); return true; }
FX_BOOL CXFA_FFField::OnRButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { if (!m_pNormalWidget) { return FALSE; } if (!IsButtonDown()) { return FALSE; } SetButtonDown(FALSE); CFWL_MsgMouse ms; ms.m_dwCmd = FWL_MouseCommand::RightButtonUp; ms.m_dwFlags = dwFlags; ms.m_fx = fx; ms.m_fy = fy; FWLToClient(ms.m_fx, ms.m_fy); ms.m_pDstTarget = m_pNormalWidget->m_pIface; TranslateFWLMessage(&ms); return TRUE; }
//============================================================================================= // Method Name: OnLButtonDown // Purpose: Process the left-button down message. // Params: (Standard event processor arguments.) // Returns: (Standard event processor returns.) // void CRepeatButton::OnLButtonDown( UINT nFlags, CPoint point ) { ASSERT_VALID(this); RepeatButton_BASE::OnLButtonDown(nFlags, point); // Send a command to the parent. SendCommand(); // If the mouse button is not down, do not start the timer etc. if ( !IsButtonDown() ) return; // Set a timer to keep giving us messages even though the mouse doesn't move SetTimer(c_nTimerID, c_uFastMsgPeriod, NULL); m_uStartTickCount = GetTickCount(); m_uNextMsg = c_uFirstRepeat; m_uMsgDelta = c_uFastMsgPeriod; return; }
//=============================================================================================== // FUNCTION: OnTimer // PURPOSE: Called on each timer tick. // void CRepeatButton::OnTimer( UINT nIDEvent ) { ASSERT_VALID(this); if( nIDEvent==c_nTimerID ) { // Make sure the user still has the mouse button down if ( !IsButtonDown() ) { EndTracking(); return; } UINT uTickCount = GetTickCount() - m_uStartTickCount; // If not time for next message return FALSE. if (uTickCount < m_uNextMsg) return; // If we have passed the threshold for accelerating the repetition rate, boost the delta. if (uTickCount > c_uSlowFastThreshold) m_uMsgDelta = c_uFastMsgPeriod; // Step the "next message" count on until it is in the future... while (m_uNextMsg < uTickCount) m_uNextMsg += m_uMsgDelta; // send a command out to the parent. SendCommand(); return; } // Unhandled timer events. CWnd::OnTimer(nIDEvent); }
//************************************************ //*操纵杆输入线程 //************************************************ DWORD WINAPI t1::InputThreadProcedure(LPVOID lpStartupParam) { // get the data we passed to the thread. Note that we don't have to use this // at all if we don't want MYDATA* pMyData = (MYDATA*)lpStartupParam; // access some imaginary members of MYDATA, which you can define on // your own later pMyData->nTime = GetCurrentTime(); // imaginary function I created pMyData->nNumber = 5; // here's the thread's main loop ?kind of like the main loop in WinMain MSG msg; int i; for (;;) { //处理外部消息 if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { GetMessage(&msg, NULL, 0, 0); if (msg.message == WM_THREADSTOP) break; // only way out of the for( ;; ) loop TranslateMessage(&msg); DispatchMessage(&msg); } else { switch (m_TestState) { case STATE_DISPLAYINSTURCTION: case STATE_DISPLAYNEXT: case STATE_DISPLAYOPTION: //呈现开始选项,等待按任意键开始测试 if (JoystickUpdate()) { for (i = 0; i<8; i++) { if (IsButtonDown(KEY_YES)) { m_TrialNo++; TestInit(); m_TestState = STATE_DISPLAYOBJ; break; } } } break; case STATE_DISPLAYOBJ: case STATE_MOVINGOBJ: //测试过程中获得操纵杆输入 if (JoystickUpdate()) { JoyX = GetXAxis();//GetYAxis();// JoyY = GetYAxis();//-GetZAxis();// if (m_Setting.m_MoveMode == MODE_MOVEROATE) { JoyZ = GetZAxis();//GetXAxis();// post_fai = (float)(JoyZ - post_fai0)*(3600.0 / 1024.0) / m_HardSetting.m_KnobSensitive;//GetZAxis()*PI/400.0; while (post_fai<-180) { post_fai = post_fai + 360; } while (post_fai>180) { post_fai = post_fai - 360; } } } break; case STATE_OVER: //测试结束,等待按任意键退出 if (JoystickUpdate()) { for (i = 0; i<12; i++) { if (IsButtonDown(i)) { PostThreadMessage(dwInputThreadID, WM_THREADSTOP, 0, 0); m_TestState = STATE_NEXT;// STATE_EXIT --> STATE_NEXT } } } break; default: break; } // do the task ?add in your own stuff here // yield to other threads, because we almost never get messages // (note that we may be yielding to WinMain too) //以键盘代替操纵杆 if (JOY == 0) { if (IsButtonDown(DIK_ESCAPE)) { PostThreadMessage(dwInputThreadID, WM_THREADSTOP, 0, 0); m_TestState = STATE_EXIT; } } } Sleep(1); } g_nThreadExitCount++; return 0; }
void CInputManager::_Test() { short stickLeft = GetLeftStickX(0); USHORT left = 0; USHORT right = 0; if (stickLeft < 0) left = -stickLeft * 2; else right = stickLeft * 2; SetMotorSpeed(0, left, right); if (IsButtonDown(0, Buttons::A)) DebugManager->Debug(L"A", L"A"); if (IsButtonDown(0, Buttons::B)) DebugManager->Debug(L"B", L"B"); if (IsButtonDown(0, Buttons::Back)) DebugManager->Debug(L"Back", L"Back"); if (IsButtonDown(0, Buttons::Down)) DebugManager->Debug(L"Down", L"Down"); if (IsButtonDown(0, Buttons::LB)) DebugManager->Debug(L"LB", L"LB"); if (IsButtonDown(0, Buttons::Left)) DebugManager->Debug(L"Left", L"Left"); if (IsButtonDown(0, Buttons::LeftStick)) DebugManager->Debug(L"LeftStick", L"LeftStick"); if (IsButtonDown(0, Buttons::RB)) DebugManager->Debug(L"RB", L"RB"); if (IsButtonDown(0, Buttons::Right)) DebugManager->Debug(L"Right", L"Right"); if (IsButtonDown(0, Buttons::RightStick)) DebugManager->Debug(L"RightStick", L"RightStick"); if (IsButtonDown(0, Buttons::Start)) DebugManager->Debug(L"Start", L"Start"); if (IsButtonDown(0, Buttons::Up)) DebugManager->Debug(L"Up", L"Up"); if (IsButtonDown(0, Buttons::X)) DebugManager->Debug(L"X", L"X"); if (IsButtonDown(0, Buttons::Y)) DebugManager->Debug(L"Y", L"Y"); DebugManager->Debug(GetLeftTrigger(0), L"left trigger"); DebugManager->Debug(GetRightTrigger(0), L"right trigger"); DebugManager->Debug(GetLeftStickX(0), L"left stick x"); DebugManager->Debug(GetLeftStickY(0), L"left stick y"); DebugManager->Debug(GetRightStickX(0), L"right stick x"); DebugManager->Debug(GetRightStickY(0), L"right stick y"); DebugManager->Debug(GetLeftTriggerDelta(0), L"left trigger Delta"); DebugManager->Debug(GetRightTriggerDelta(0), L"right trigger Delta"); DebugManager->Debug(GetLeftStickXDelta(0), L"left stick x Delta"); DebugManager->Debug(GetLeftStickYDelta(0), L"left stick y Delta"); DebugManager->Debug(GetRightStickXDelta(0), L"right stick x Delta"); DebugManager->Debug(GetRightStickYDelta(0), L"right stick y Delta"); if (IsButtonPressed(0, Buttons::A)) printf("A pressed\n"); if (IsButtonPressed(0, Buttons::B)) printf("B pressed\n"); if (IsButtonPressed(0, Buttons::Back)) printf("Back pressed\n"); if (IsButtonPressed(0, Buttons::Down)) printf("Down pressed\n"); if (IsButtonPressed(0, Buttons::LB)) printf("LB pressed\n"); if (IsButtonPressed(0, Buttons::Left)) printf("Left pressed\n"); if (IsButtonPressed(0, Buttons::LeftStick)) printf("LeftStick pressed\n"); if (IsButtonPressed(0, Buttons::RB)) printf("RB pressed\n"); if (IsButtonPressed(0, Buttons::Right)) printf("Right pressed\n"); if (IsButtonPressed(0, Buttons::RightStick)) printf("RightStick pressed\n"); if (IsButtonPressed(0, Buttons::Start)) printf("Start pressed\n"); if (IsButtonPressed(0, Buttons::Up)) printf("Up pressed\n"); if (IsButtonPressed(0, Buttons::X)) printf("X pressed\n"); if (IsButtonPressed(0, Buttons::Y)) printf("Y pressed\n"); if (IsButtonReleased(0, Buttons::A)) printf("A released\n"); if (IsButtonReleased(0, Buttons::B)) printf("B released\n"); if (IsButtonReleased(0, Buttons::Back)) printf("Back released\n"); if (IsButtonReleased(0, Buttons::Down)) printf("Down released\n"); if (IsButtonReleased(0, Buttons::LB)) printf("LB released\n"); if (IsButtonReleased(0, Buttons::Left)) printf("Left released\n"); if (IsButtonReleased(0, Buttons::LeftStick)) printf("LeftStick released\n"); if (IsButtonReleased(0, Buttons::RB)) printf("RB released\n"); if (IsButtonReleased(0, Buttons::Right)) printf("Right released\n"); if (IsButtonReleased(0, Buttons::RightStick)) printf("RightStick released\n"); if (IsButtonReleased(0, Buttons::Start)) printf("Start released\n"); if (IsButtonReleased(0, Buttons::Up)) printf("Up released\n"); if (IsButtonReleased(0, Buttons::X)) printf("X released\n"); if (IsButtonReleased(0, Buttons::Y)) printf("Y released\n"); if (GamepadConnected()) printf("gamepad connected\n"); if (GamepadDisconnected()) printf("gamepad disconnected\n"); UINT connectedGamepads = 0; for (UINT i = 0; i < XUSER_MAX_COUNT; i++) if (IsGamepadActive(i)) connectedGamepads++; DebugManager->Debug((int)connectedGamepads, L"Connected gamepads"); }
bool InputMapper::IsButtonDown( StyleInput StyleI ) { GameInput GameI; StyleToGame( StyleI, GameI ); return IsButtonDown( GameI ); }