void Gui::MouseClicks(SRPWindows *pSRPWindow, Control &cControl) { if (cControl.GetName() == "MouseLeft") { // mouse clicked on a window so we need to focus it /*have this happen on mouse down*/ FocusWindow(pSRPWindow); if ((Timing::GetInstance()->GetPastTime() - m_nLastMouseLeftReleaseTime) > 0 && (Timing::GetInstance()->GetPastTime() - m_nLastMouseLeftReleaseTime) < 250) { // we should send a double click if (!reinterpret_cast<Button&>(cControl).IsPressed()) { pSRPWindow->GetAwesomiumWindow()->InjectMouseDown(Awesomium::kMouseButton_Left); pSRPWindow->GetAwesomiumWindow()->InjectMouseUp(Awesomium::kMouseButton_Left); pSRPWindow->GetAwesomiumWindow()->InjectMouseDown(Awesomium::kMouseButton_Left); pSRPWindow->GetAwesomiumWindow()->InjectMouseUp(Awesomium::kMouseButton_Left); m_nLastMouseLeftReleaseTime = 0; } } else { // send a single click if (!reinterpret_cast<Button&>(cControl).IsPressed()) { // mouse button has been released pSRPWindow->GetAwesomiumWindow()->InjectMouseUp(Awesomium::kMouseButton_Left); m_bMouseLeftDown = false; m_nLastMouseLeftReleaseTime = Timing::GetInstance()->GetPastTime(); } else { // mouse button has been pressed pSRPWindow->GetAwesomiumWindow()->InjectMouseDown(Awesomium::kMouseButton_Left); m_bMouseLeftDown = true; m_nLastMouseLeftReleaseTime = 0; } } } if (cControl.GetName() == "MouseRight") { // mouse clicked on a window so we need to focus it /*have this happen on mouse down*/ FocusWindow(pSRPWindow); // send a right mouse click if (!reinterpret_cast<Button&>(cControl).IsPressed()) { // mouse button has been released pSRPWindow->GetAwesomiumWindow()->InjectMouseUp(Awesomium::kMouseButton_Right); } else { // mouse button has been pressed pSRPWindow->GetAwesomiumWindow()->InjectMouseDown(Awesomium::kMouseButton_Right); } } }
/** * @brief * Test: Controller */ void Application30::TestController() { // Start System::GetInstance()->GetConsole().Print("Controller 'GameBoy'\n"); System::GetInstance()->GetConsole().Print('\n'); // Create test controller GameBoyController cController; // List all controls System::GetInstance()->GetConsole().Print("Controls:\n"); const List<Control*> &lstControls = cController.GetControls(); for (uint32 i=0; i<lstControls.GetNumOfElements(); i++) { // Get control Control *pControl = lstControls[i]; if (pControl->GetType() == ControlButton) System::GetInstance()->GetConsole().Print("- Button '" + pControl->GetName() + "' [" + pControl->GetDescription() + "]\n"); else if (pControl->GetType() == ControlAxis) System::GetInstance()->GetConsole().Print("- Axis '" + pControl->GetName() + "' [" + pControl->GetDescription() + "]\n"); } System::GetInstance()->GetConsole().Print('\n'); // List buttons System::GetInstance()->GetConsole().Print("Buttons:\n"); const List<Button*> &lstButtons = cController.GetButtons(); for (uint32 i=0; i<lstButtons.GetNumOfElements(); i++) { Button *pButton = lstButtons[i]; System::GetInstance()->GetConsole().Print("- Button '" + pButton->GetName() + "' [" + pButton->GetDescription() + "]\n"); } System::GetInstance()->GetConsole().Print('\n'); // List axes System::GetInstance()->GetConsole().Print("Axes:\n"); const List<Axis*> &lstAxes = cController.GetAxes(); for (uint32 i=0; i<lstAxes.GetNumOfElements(); i++) { Axis *pAxis = lstAxes[i]; System::GetInstance()->GetConsole().Print("- Axis '" + pAxis->GetName() + "' [" + pAxis->GetDescription() + "]\n"); } System::GetInstance()->GetConsole().Print('\n'); // Done System::GetInstance()->GetConsole().Print('\n'); }
/** * @brief * Called when a control event has occurred */ void Application61::OnControl(Control &cControl) { // Is it a button? if (cControl.GetType() == ControlButton && static_cast<Button&>(cControl).IsPressed()) { // Check whether the escape key was pressed if (cControl.GetName() == "KeyboardEscape") { // Shut down the application Exit(0); } else { // Get current time difference Timing *pTimer = Timing::GetInstance(); const float fTimeScaleFactor = pTimer->GetTimeScaleFactor(); // Check button if (cControl.GetName() == "Keyboard1") { // Decrease timescale pTimer->SetTimeScaleFactor(fTimeScaleFactor - 0.1f); if (pTimer->GetTimeScaleFactor() < 0.1f) pTimer->SetTimeScaleFactor(0.1f); } else if (cControl.GetName() == "Keyboard2") { // Increase timescale pTimer->SetTimeScaleFactor(fTimeScaleFactor + 0.1f); if (pTimer->GetTimeScaleFactor() > 4.0f) pTimer->SetTimeScaleFactor(4.0f); } else if (cControl.GetName() == "Keyboard3") { // Reset timescale pTimer->SetTimeScaleFactor(); } // Time scale factor changed? if (fTimeScaleFactor != pTimer->GetTimeScaleFactor()) { // Update the time scale text node UpdateTimeScaleTextNode(); // Update the pitch variable of the sound container using the time scale factor SceneContainer *pSceneContainer = GetScene(); if (pSceneContainer) pSceneContainer->SetAttribute("Pitch", pTimer->GetTimeScaleFactor()); } } } }
void FCarAddEdit::OnTouchReleased(const Control &source, const Point ¤tPosition, const TouchEventInfo &touchInfo) { if (!this->detailmode) { if (source.GetName() == L"CB_4_fueltypestring") { pPopup_->SetShowState(true); pPopup_->Show(); } } else { OnFocusGained(source); //this->SetFocus(); } }
/** * @brief * Called when a control event has occurred */ void Application::OnControl(Control &cControl) { // Is it a button and was it just hit? if (cControl.GetType() == ControlButton) { // Shut down the application? if (cControl.GetName() == "KeyboardEscape") { if (reinterpret_cast<Button&>(cControl).IsHit()) Exit(0); // Make a screenshot from the current render target? } else if (cControl.GetName() == "KeyboardF12") { if (reinterpret_cast<Button&>(cControl).IsHit()) GetScreenshotTool().SaveScreenshot(); // Toggle mouse cursor visibility? } else if (cControl.GetName() == "KeyboardM") { // Toggle mouse cursor visibility if (reinterpret_cast<Button&>(cControl).IsHit()) GetFrontend().SetMouseVisible(!GetFrontend().IsMouseVisible()); } } }
/** * @brief * Called when a control event has occurred */ void Application67::OnControl(Control &cControl) { // Is it a button and was it just hit? if (cControl.GetType() == ControlButton && reinterpret_cast<Button&>(cControl).IsHit()) { // Check whether the escape key was pressed if (cControl.GetName() == "KeyboardEscape") { // Shut down the application Exit(0); // Restart the game } else if (cControl.GetName() == "KeyboardR") { Restart(); // Toggle post processing } else if (cControl.GetName() == "KeyboardP") { // Get the camera const SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Loop through all available post process scene node modifiers bool bRenderToTexture = false; uint32 nIndex = 0; SceneNodeModifier *pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", nIndex); while (pModifier) { // Toggle the active state of the post process scene node modifier pModifier->SetActive(!pModifier->IsActive()); if (pModifier->IsActive()) bRenderToTexture = true; // Next modifier, please pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", ++nIndex); } // Enable/disable render to texture for the post processing feature GetSceneRendererTool().SetPassAttribute("Begin", "Flags", bRenderToTexture ? "" : "Inactive"); } } } }
/** * @brief * Called when a control of the input controller has been activated */ void Application30::OnControl(Control &cControl) { // Get name of control String sControl = cControl.GetName(); // Display control value String sValue; if (cControl.GetType() == ControlButton) sValue = static_cast<Button&>(cControl).IsPressed() ? "<pressed>" : "<released>"; else if (cControl.GetType() == ControlAxis) sValue = String::Format("%5.2f", static_cast<Axis&>(cControl).GetValue()); System::GetInstance()->GetConsole().Print("- '" + sControl + "': " + sValue + '\n'); // LED test if ((cControl.GetName() == "Plus" || cControl.GetName() == "Minus") && static_cast<Button&>(cControl).IsPressed()) { // Get LED control LED *pLED = static_cast<LED*>(cControl.GetController()->GetControl("LED")); if (pLED) { // Change LED value uint32 nLED = pLED->GetLEDs(); if (cControl.GetName() == "Plus") nLED++; else nLED--; if (nLED > 15) nLED = 0; pLED->SetLEDs(nLED); } } // Rumble test if (cControl.GetName() == "Button1" || cControl.GetName() == "Button2") { // Get rumble control (try "Rumble3" first for joystick, then "Rumble1" for WiiMote) Effect *pRumble = static_cast<Effect*>(cControl.GetController()->GetControl("Rumble3")); if (!pRumble) pRumble = static_cast<Effect*>(cControl.GetController()->GetControl("Rumble1")); if (pRumble) { // Enable or disable rumble? if (cControl.GetName() == "Button1") pRumble->SetValue(1.0f); if (cControl.GetName() == "Button2") pRumble->SetValue(0.0f); } } }
void Gui::MouseScrolls(SRPWindows *pSRPWindow, Control &cControl) { if (pSRPWindow) { if (pSRPWindow->GetData()->bIsVisable && pSRPWindow->GetData()->bMouseEnabled) { if (cControl.GetType() == ControlAxis) { if (cControl.GetName() == "MouseWheel") { // if all of the above is true, send mouse scroll pSRPWindow->GetAwesomiumWindow()->InjectMouseWheel(int(static_cast<Axis&>(cControl).GetValue()), 0); } } } } }
void Gui::KeyboardEvents(Control &cControl) { /*i am not yet satisfied with this method*/ if (m_pFocusedWindow) { // check if the focused window allows for key events if (m_pFocusedWindow->GetData()->bKeyboardEnabled) { // check if the event is for the keyboard if (cControl.GetName().GetSubstring(0, 8) == "Keyboard") { // get the button class Button &cButton = reinterpret_cast<Button&>(cControl); if (cButton.IsPressed()) { sButton *psButton = new sButton; if (String(cButton.GetCharacter()).IsAlphaNumeric()) { AddTextKey(cButton.GetName(), cButton.GetCharacter(), psButton); } else if (cButton.GetName() == "KeyboardSpace") { AddTextKey(cButton.GetName(), cButton.GetCharacter(), psButton); } else if (cButton.GetName() == "KeyboardBackspace") { AddKey(cButton.GetName(), cButton.GetCharacter(), psButton); } else if (cButton.GetName() == "KeyboardTab") { AddKey(cButton.GetName(), cButton.GetCharacter(), psButton); } else { psButton->bValid = false; } } else { if (m_pTextButtonHandler->GetNumOfElements() == 1) { m_nTextKeyHitCount = 0; } m_pTextButtonHandler->Remove(cButton.GetName()); if (m_pKeyButtonHandler->GetNumOfElements() == 1) { m_nKeyHitCount = 0; } m_pKeyButtonHandler->Remove(cButton.GetName()); } //DebugToConsole("Window: '" + m_pFocusedWindow->GetName() + "', GetName(): '" + String(cButton.GetName()) + "'\n"); //DebugToConsole("Window: '" + m_pFocusedWindow->GetName() + "', GetCharacter(): '" + String(cButton.GetCharacter()) + "'\n"); //DebugToConsole("Window: '" + m_pFocusedWindow->GetName() + "', IsPressed(): '" + String(cButton.IsPressed()) + "'\n"); DebugToConsole("Amount of text: " + String(m_pTextButtonHandler->GetNumOfElements()) + "\n"); DebugToConsole("Hit count: " + String(m_nTextKeyHitCount) + "\n\n"); DebugToConsole("Amount of keys: " + String(m_pKeyButtonHandler->GetNumOfElements()) + "\n"); DebugToConsole("Hit count: " + String(m_nKeyHitCount) + "\n\n\n"); } } } }
void Gui::MouseEvents(Control &cControl) { // get the frontend Frontend &cFrontend = static_cast<FrontendApplication*>(CoreApplication::GetApplication())->GetFrontend(); if (cFrontend.IsRunning() && cFrontend.IsMouseOver()) { // get the mouse position Vector2i vMousePos(cFrontend.GetMousePositionX(), cFrontend.GetMousePositionY()); // set the last known mouse position m_vLastKnownMousePos = vMousePos; // check if mouse pointer is visible if (GetMousePointer()->IsVisible()) { // hide the native mouse pointer // this should be a setting so that the user can decide if they want to hide the native mouse pointer cFrontend.SetMouseVisible(false); // set the position of the mouse pointer GetMousePointer()->SetPosition(vMousePos.x, vMousePos.y); // move the mouse pointer to front so that its always visible GetMousePointer()->MoveToFront(); } else { // show the native mouse pointer // this should be a setting so that the user can decide if they want to show the native mouse pointer cFrontend.SetMouseVisible(true); } // get the window that the mouse is over // if there are more window under the mouse then it will return the top most SRPWindows *pSRPWindow = GetTopMostWindow(GetMouseOverWindows(GetMouseEnabledWindows(), vMousePos)); if (pSRPWindow) { // move the mouse on the window MouseMove(pSRPWindow, vMousePos); // process mouse clicks on the window MouseClicks(pSRPWindow, cControl); // process mouse scrolls on the window MouseScrolls(pSRPWindow, cControl); // set the window that the mouse last had contact with m_pLastMouseWindow = pSRPWindow; } else { if (m_pLastMouseWindow) { // the mouse has left the window so the tooltip should be empty //m_pLastMouseWindow->SetToolTip(""); } if (m_pFocusedWindow) { // process mouse scrolls for the focused window MouseScrolls(m_pFocusedWindow, cControl); if (cControl.GetName() == "MouseLeft") { // we clicked outside a window so we need to unfocus it UnFocusAllWindows(); } } if (cControl.GetName() == "MouseLeft") { // set the state for the left mouse button m_bMouseLeftDown = reinterpret_cast<Button&>(cControl).IsPressed(); } } // the mouse supposedly has moved so we wanna know about it m_bMouseMoved = true; } }
void VimridViewer::OnControlSelectRelease(Control &control) { // HACK: Comparing text when pointer should be compared. if ((control.GetName() == "loadDicomSet1Button") || (control.GetName() == "loadDicomSet2Button") || (control.GetName() == "loadDicomSet3Button") || (control.GetName() == "loadDicomSet4Button")) { const Button *buttonPtr = dynamic_cast<const Button*>(&control); mDicomClient.DownloadAsync(buttonPtr->GetText()); } // HACK: Comparing text when pointer should be compared. if (control.GetName() == "toggleStatusButton") { EnableRenderStatusText = !EnableRenderStatusText; } // Cancel loading of DICOM data. if (&control == mFilterLoadingScreenCancelButton) { mDicomLoadCancel = true; } // Turns transparency on and off. if (&control == mToggleAlphaButton) { mAlphaEnabled = !mAlphaEnabled; } if (&control == mFilterRestoreButton) { pthread_create(&mFilterRestoreThread, NULL, _filterRestore, NULL); } /* HACK: If any other button pressed, filter mode is reset. This * conveniently does the same thing as what the cancel button does * so it works fine for the time being, but this should only really * be reset on specific scenarios (such as cancel button press). */ mFilterMode = VV_FM_None; if (&control == mSobelXNormalButton) { mFilterMode = VV_FM_SobelXNormal; } else if (&control == mSobelYNormalButton) { mFilterMode = VV_FM_SobelYNormal; } else if (&control == mSobelXYNormalButton) { mFilterMode = VV_FM_SobelXYNormal; } else if (&control == mSobelXYScopedButton) { mFilterMode = VV_FM_SobelXYScoped; } // Once filter mode potentially set, check and if it is, process! if (mFilterMode != VV_FM_None) { pthread_create(&mProcessorThread, NULL, _processImages, NULL); } if (&control == mToggleStereoButton) { if (IsStereoEnabled()) { DisableStereo(); } else { EnableStereo(); } } if (&control == mToggleTrackdButton) { VimridMenu &mainMenu = *mMainMenu; if (GetUtility().IsTrackdEnabled()) { GetUtility().DisableTrackd(); GetUiContainer().ResetCursor(); if (mainMenu.HasToggleMode(UI_MTM_CENTRE_CURSOR)) { mainMenu.RemoveToggleMode(UI_MTM_CENTRE_CURSOR); } } else { GetUtility().EnableTrackd(); GetUiContainer().CentreCursor(*mMainMenu); if (!mainMenu.HasToggleMode(UI_MTM_CENTRE_CURSOR)) { mainMenu.AddToggleMode(UI_MTM_CENTRE_CURSOR); } } } if (&control == mExitVimridButton) { Exit(); } }
/** * @brief * Called when a control of the input controller has been activated */ void Application30::OnControlExit(Control &cControl) { // Exit? if (cControl.GetName() == "Escape" || cControl.GetName() == "Q") m_bExit = true; }
/** * @brief * Called when a control event has occurred */ void Application70::OnControl(Control &cControl) { // Check whether the escape key was pressed if (cControl.GetType() == ControlButton && cControl.GetName() == "KeyboardEscape") Exit(0); // Shut down the application }
/** * @brief * Called when a control event has occurred */ void Application65::OnControl(Control &cControl) { // Is it a button and was it just hit? if (cControl.GetType() == ControlButton && reinterpret_cast<Button&>(cControl).IsHit()) { // Check whether the escape key was pressed if (cControl.GetName() == "KeyboardEscape") { // Shut down the application Exit(0); // Show/hide the help text } else if (cControl.GetName() == "KeyboardF1") { // Get the info text scene node SceneNode *pSceneNode = GetRootScene() ? GetRootScene()->GetByName("InfoText") : nullptr; if (pSceneNode) { // Toggle the active state of the scene node pSceneNode->SetActive(!pSceneNode->IsActive()); } // Toggle post processing } else if (cControl.GetName() == "KeyboardSpace") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Loop through all available post process scene node modifiers uint32 nIndex = 0; SceneNodeModifier *pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", nIndex); while (pModifier) { // Toggle the active state of the post process scene node modifier pModifier->SetActive(!pModifier->IsActive()); // Next modifier, please pModifier = pCamera->GetModifier("PLCompositing::SNMPostProcess", ++nIndex); } } // Next post process effect } else if (cControl.GetName() == "KeyboardPageUp") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Increase the current selected modifier index m_nCurrentSelectedModifier++; if (m_nCurrentSelectedModifier >= m_lstModifierClasses.GetNumOfElements()) m_nCurrentSelectedModifier = 0; // Remove all old modifiers add the new one pCamera->ClearModifiers(); pCamera->AddModifier(m_lstModifierClasses[m_nCurrentSelectedModifier]->GetClassName()); } // Previous post process effect } else if (cControl.GetName() == "KeyboardPageDown") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Decrease the current selected modifier index if (m_nCurrentSelectedModifier) m_nCurrentSelectedModifier--; else m_nCurrentSelectedModifier = m_lstModifierClasses.GetNumOfElements()-1; // Remove all old modifiers add the new one pCamera->ClearModifiers(); pCamera->AddModifier(m_lstModifierClasses[m_nCurrentSelectedModifier]->GetClassName()); } // Custom post process effect: "Rainbow" } else if (cControl.GetName() == "Keyboard1") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new one pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCrazyBars", "ColorScaleY=\"0.002\""); } // Custom post process effect: "Cartoon" } else if (cControl.GetName() == "Keyboard2") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new ones pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\""); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCombineMultiplicate"); } // Custom post process effect: "Animated cartoon" } else if (cControl.GetName() == "Keyboard3") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new ones pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\""); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm"); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCombineMultiplicate"); } // Custom post process effect: "Animated old cartoon" } else if (cControl.GetName() == "Keyboard4") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new ones pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\""); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessCombineMultiplicate"); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm"); } // Custom post process effect: "Scratch" } else if (cControl.GetName() == "Keyboard5") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new one pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\""); } // Custom post process effect: "Animated old scratch" } else if (cControl.GetName() == "Keyboard6") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new ones pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "LuminanceConvert=\"-0.2125 -0.7154 -0.0721\""); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessOldFilm"); } // Custom post process effect: "Edge glow" } else if (cControl.GetName() == "Keyboard7") { // Get the currently used camera SceneNode *pCamera = reinterpret_cast<SceneNode*>(GetCamera()); if (pCamera) { // Remove all old modifiers add the new one pCamera->ClearModifiers(); pCamera->AddModifier("PLPostProcessEffects::SNMPostProcessEdgeDetect", "Filename=\"Data/PostProcesses/EdgeGlow.pp\""); } } } }