From 4c258c2ef9dd637466e4130377412161480df27e Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Sun, 22 Jun 2014 17:31:00 +0200 Subject: [PATCH 1/9] Making pauseOnLoseFocus more powerful: no more rendering / updating of the core, temporally setting fps down to 2. --- Core/Contents/Include/PolyCore.h | 4 +++- Core/Contents/Include/PolyWinCore.h | 6 ++++++ .../Contents/PolycodeView/MSVC/PolycodeView.cpp | 6 ++++++ Core/Contents/Source/PolyCore.cpp | 17 ++++++++++++++--- Core/Contents/Source/PolyWinCore.cpp | 9 +++++++++ IDE/Build/WindowsShared/PolycodeWinIDEView.cpp | 6 ++++++ IDE/Contents/Source/PolycodeIDEApp.cpp | 10 +--------- 7 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Core/Contents/Include/PolyCore.h b/Core/Contents/Include/PolyCore.h index 4b1f1f4a6..eb4d6d244 100755 --- a/Core/Contents/Include/PolyCore.h +++ b/Core/Contents/Include/PolyCore.h @@ -404,7 +404,9 @@ namespace Polycode { String defaultWorkingDirectory; void *userPointer; - + + //used for pausing workaround.. + int frameRate; long refreshInterval; unsigned int timeSleptMs; diff --git a/Core/Contents/Include/PolyWinCore.h b/Core/Contents/Include/PolyWinCore.h index 5a0d84723..53ece0f66 100644 --- a/Core/Contents/Include/PolyWinCore.h +++ b/Core/Contents/Include/PolyWinCore.h @@ -228,6 +228,12 @@ class Gamepad_devicePrivate { void initTouch(); void handleViewResize(int width, int height); + + /** + * Handles focus changes + * @param newFocus bool value: true if gained focus, false if lost focus + */ + void handleFocusChange(bool newFocus); String executeExternalCommand(String command, String args, String inDirectory); std::vector openFilePicker(std::vector extensions, bool allowMultiple); diff --git a/Core/Contents/PolycodeView/MSVC/PolycodeView.cpp b/Core/Contents/PolycodeView/MSVC/PolycodeView.cpp index 2de1ca730..a6395e062 100644 --- a/Core/Contents/PolycodeView/MSVC/PolycodeView.cpp +++ b/Core/Contents/PolycodeView/MSVC/PolycodeView.cpp @@ -146,6 +146,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_DESTROY: PostQuitMessage(0); break; + case WM_KILLFOCUS: + core->handleFocusChange(false); + break; + case WM_SETFOCUS: + core->handleFocusChange(true); + break; default: useDefault = true; break; diff --git a/Core/Contents/Source/PolyCore.cpp b/Core/Contents/Source/PolyCore.cpp index f6f18d564..c6825c9ff 100755 --- a/Core/Contents/Source/PolyCore.cpp +++ b/Core/Contents/Source/PolyCore.cpp @@ -82,6 +82,7 @@ namespace Polycode { frameRate = 60; setFramerate(frameRate); + refreshInterval = 1000 / frameRate; threadedEventMutex = NULL; } @@ -98,6 +99,7 @@ namespace Polycode { } void Core::setFramerate(int frameRate, int maxFixedCycles) { + this->frameRate = frameRate; refreshInterval = 1000 / frameRate; fixedTimestep = 1.0 / ((double) frameRate); maxFixedElapsed = fixedTimestep * maxFixedCycles; @@ -170,6 +172,7 @@ namespace Polycode { paused = true; } input->clearInput(); + refreshInterval = 1000 / 2; dispatchEvent(new Event(), EVENT_LOST_FOCUS); } @@ -177,7 +180,8 @@ namespace Polycode { if(pauseOnLoseFocus) { paused = false; } - input->clearInput(); + input->clearInput(); + refreshInterval = 1000 / frameRate; dispatchEvent(new Event(), EVENT_GAINED_FOCUS); } @@ -196,8 +200,15 @@ namespace Polycode { } bool Core::updateAndRender() { - bool ret = Update(); - Render(); + bool ret; + if (!paused){ + ret = Update(); + Render(); + } + else { + doSleep(); + ret = running; + } return ret; } diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 85713dda0..27b3bb260 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -1411,3 +1411,12 @@ String Win32Core::getClipboardString() { GlobalUnlock(clip0); return retString; } + +void Win32Core::handleFocusChange(bool newFocus){ + if (newFocus){ + gainFocus(); + } + else { + loseFocus(); + } +} diff --git a/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp b/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp index 420a3b4f0..dda05e728 100644 --- a/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp +++ b/IDE/Build/WindowsShared/PolycodeWinIDEView.cpp @@ -254,6 +254,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_DESTROY: PostQuitMessage(0); break; + case WM_KILLFOCUS: + core->handleFocusChange(false); + break; + case WM_SETFOCUS: + core->handleFocusChange(true); + break; default: useDefault = true; break; diff --git a/IDE/Contents/Source/PolycodeIDEApp.cpp b/IDE/Contents/Source/PolycodeIDEApp.cpp index 90e9a5edf..da20ddcbd 100644 --- a/IDE/Contents/Source/PolycodeIDEApp.cpp +++ b/IDE/Contents/Source/PolycodeIDEApp.cpp @@ -39,7 +39,7 @@ PolycodeIDEApp::PolycodeIDEApp(PolycodeView *view) : EventDispatcher() { core = new POLYCODE_CORE((PolycodeView*)view, 1100, 700,false,false, 0, 0,60, -1, true); #endif -// core->pauseOnLoseFocus = true; + core->pauseOnLoseFocus = true; printf("DIR: %s\n", core->getDefaultWorkingDirectory().c_str()); @@ -55,8 +55,6 @@ core = new POLYCODE_CORE((PolycodeView*)view, 1100, 700,false,false, 0, 0,60, -1 runNextFrame = false; core->addEventListener(this, Core::EVENT_CORE_RESIZE); - core->addEventListener(this, Core::EVENT_LOST_FOCUS); - core->addEventListener(this, Core::EVENT_GAINED_FOCUS); globalClipboard = new PolycodeClipboard(); @@ -828,12 +826,6 @@ void PolycodeIDEApp::handleEvent(Event *event) { if(event->getDispatcher() == core) { switch(event->getEventCode()) { - case Core::EVENT_LOST_FOCUS: - core->setFramerate(3); - break; - case Core::EVENT_GAINED_FOCUS: - core->setFramerate(60); - break; case Core::EVENT_CORE_RESIZE: if(menuBar) { frame->Resize(core->getXRes(), core->getYRes()-25); From 5fd98d535851b4129db2f92acc0a2d3ea482d707 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Sun, 22 Jun 2014 18:11:30 +0200 Subject: [PATCH 2/9] *Fix issues on Linux and Mac(not tested), *clean up the Update process of the IDE --- Core/Contents/Source/PolyCocoaCore.mm | 13 ++--- Core/Contents/Source/PolyCore.cpp | 12 ++--- Core/Contents/Source/PolySDLCore.cpp | 6 ++- Core/Contents/Source/PolyWinCore.cpp | 12 +++-- IDE/Contents/Source/PolycodeIDEApp.cpp | 70 +++++++++++++------------- 5 files changed, 56 insertions(+), 57 deletions(-) diff --git a/Core/Contents/Source/PolyCocoaCore.mm b/Core/Contents/Source/PolyCocoaCore.mm index f29b5f9af..6344155b3 100644 --- a/Core/Contents/Source/PolyCocoaCore.mm +++ b/Core/Contents/Source/PolyCocoaCore.mm @@ -659,13 +659,14 @@ long getThreadID() { if(!running) return false; doSleep(); - - if(modeChangeInfo.needResolutionChange) { - _setVideoMode(modeChangeInfo.xRes, modeChangeInfo.yRes, modeChangeInfo.fullScreen, modeChangeInfo.vSync, modeChangeInfo.aaLevel, modeChangeInfo.anisotropyLevel); - modeChangeInfo.needResolutionChange = false; - } + if(!paused){ + if(modeChangeInfo.needResolutionChange) { + _setVideoMode(modeChangeInfo.xRes, modeChangeInfo.yRes, modeChangeInfo.fullScreen, modeChangeInfo.vSync, modeChangeInfo.aaLevel, modeChangeInfo.anisotropyLevel); + modeChangeInfo.needResolutionChange = false; + } - updateCore(); + updateCore(); + } checkEvents(); return running; } diff --git a/Core/Contents/Source/PolyCore.cpp b/Core/Contents/Source/PolyCore.cpp index c6825c9ff..98630f132 100755 --- a/Core/Contents/Source/PolyCore.cpp +++ b/Core/Contents/Source/PolyCore.cpp @@ -200,15 +200,9 @@ namespace Polycode { } bool Core::updateAndRender() { - bool ret; - if (!paused){ - ret = Update(); - Render(); - } - else { - doSleep(); - ret = running; - } + bool ret = Update(); + Render(); + return ret; } diff --git a/Core/Contents/Source/PolySDLCore.cpp b/Core/Contents/Source/PolySDLCore.cpp index 831ef3e8f..8fb9aedef 100644 --- a/Core/Contents/Source/PolySDLCore.cpp +++ b/Core/Contents/Source/PolySDLCore.cpp @@ -318,8 +318,10 @@ bool SDLCore::systemUpdate() { return false; doSleep(); - updateCore(); - + if(!paused) { + updateCore(); + } + SDL_Event event; while ( SDL_PollEvent(&event) ) { switch (event.type) { diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 27b3bb260..2eb4c1c40 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -214,10 +214,12 @@ bool Win32Core::systemUpdate() { if(!running) return false; captureMouse(Core::mouseCaptured); - doSleep(); - checkEvents(); - Gamepad_processEvents(); - updateCore(); + doSleep(); + if(!paused){ + checkEvents(); + Gamepad_processEvents(); + updateCore(); + } return running; } @@ -1419,4 +1421,4 @@ void Win32Core::handleFocusChange(bool newFocus){ else { loseFocus(); } -} +} diff --git a/IDE/Contents/Source/PolycodeIDEApp.cpp b/IDE/Contents/Source/PolycodeIDEApp.cpp index da20ddcbd..991526e65 100644 --- a/IDE/Contents/Source/PolycodeIDEApp.cpp +++ b/IDE/Contents/Source/PolycodeIDEApp.cpp @@ -1360,51 +1360,51 @@ PolycodeIDEApp::~PolycodeIDEApp() { bool PolycodeIDEApp::Update() { + if(!core->paused){ + if(willRunProject) { + willRunProject = false; + runProject(); + } - if(willRunProject) { - willRunProject = false; - runProject(); - } - - if(runNextFrame) { - runNextFrame = false; - doRunProject(); - } + if(runNextFrame) { + runNextFrame = false; + doRunProject(); + } - if(lastConnected != debugger->isConnected()) { - needsRedraw = true; - lastConnected = debugger->isConnected(); - } + if(lastConnected != debugger->isConnected()) { + needsRedraw = true; + lastConnected = debugger->isConnected(); + } - if(debugger->isConnected()) { - frame->stopButton->visible = true; - frame->stopButton->enabled = true; + if(debugger->isConnected()) { + frame->stopButton->visible = true; + frame->stopButton->enabled = true; - frame->playButton->visible = false; - frame->playButton->enabled = false; + frame->playButton->visible = false; + frame->playButton->enabled = false; - } else { - frame->stopButton->visible = false; - frame->stopButton->enabled = false; + } else { + frame->stopButton->visible = false; + frame->stopButton->enabled = false; - frame->playButton->visible = true; - frame->playButton->enabled = true; - } + frame->playButton->visible = true; + frame->playButton->enabled = true; + } - if(projectManager->getProjectCount() == 1) { - projectManager->setActiveProject(projectManager->getProjectByIndex(0)); - } + if(projectManager->getProjectCount() == 1) { + projectManager->setActiveProject(projectManager->getProjectByIndex(0)); + } - if(projectManager->getProjectCount() > 0) { - frame->welcomeEntity->enabled = false; + if(projectManager->getProjectCount() > 0) { + frame->welcomeEntity->enabled = false; - frame->getConsoleSizer()->enabled = true; - } else { - frame->welcomeEntity->enabled = true; - frame->getConsoleSizer()->enabled = false; - } - + frame->getConsoleSizer()->enabled = true; + } else { + frame->welcomeEntity->enabled = true; + frame->getConsoleSizer()->enabled = false; + } + } return core->updateAndRender(); } From 44ef5798eca1f6e546110eb242ecc649b8dd982d Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Mon, 23 Jun 2014 17:38:49 +0200 Subject: [PATCH 3/9] If paused shouldn't render. --- Core/Contents/Source/PolyCore.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/Contents/Source/PolyCore.cpp b/Core/Contents/Source/PolyCore.cpp index 98630f132..8e4732885 100755 --- a/Core/Contents/Source/PolyCore.cpp +++ b/Core/Contents/Source/PolyCore.cpp @@ -201,7 +201,10 @@ namespace Polycode { bool Core::updateAndRender() { bool ret = Update(); - Render(); + + if (!paused){ + Render(); + } return ret; } From dae270778463073dd8fa29cc671b6b10a6c8be5d Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Tue, 24 Jun 2014 15:32:58 +0200 Subject: [PATCH 4/9] Shouldn't warpCursor when paused. --- Core/Contents/Source/PolyCocoaCore.mm | 19 ++++++++++--------- Core/Contents/Source/PolySDLCore.cpp | 3 ++- Core/Contents/Source/PolyWinCore.cpp | 16 +++++++++------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Core/Contents/Source/PolyCocoaCore.mm b/Core/Contents/Source/PolyCocoaCore.mm index 6344155b3..b1a05db9c 100644 --- a/Core/Contents/Source/PolyCocoaCore.mm +++ b/Core/Contents/Source/PolyCocoaCore.mm @@ -426,16 +426,17 @@ long getThreadID() { } void CocoaCore::warpCursor(int x, int y) { - - CGSetLocalEventsSuppressionInterval(0); - NSArray *theScreens = [NSScreen screens]; - for (NSScreen *theScreen in theScreens) { - CGPoint CenterOfWindow = CGPointMake([glView window].frame.origin.x+x, (-1)*([glView window].frame.origin.y-theScreen.frame.size.height)-yRes+y); - CGDisplayMoveCursorToPoint (kCGDirectMainDisplay, CenterOfWindow); - break; + if(!paused){ + CGSetLocalEventsSuppressionInterval(0); + NSArray *theScreens = [NSScreen screens]; + for (NSScreen *theScreen in theScreens) { + CGPoint CenterOfWindow = CGPointMake([glView window].frame.origin.x+x, (-1)*([glView window].frame.origin.y-theScreen.frame.size.height)-yRes+y); + CGDisplayMoveCursorToPoint (kCGDirectMainDisplay, CenterOfWindow); + break; + } + lastMouseX = x; + lastMouseY = y; } - lastMouseX = x; - lastMouseY = y; } diff --git a/Core/Contents/Source/PolySDLCore.cpp b/Core/Contents/Source/PolySDLCore.cpp index 8fb9aedef..b6a13e1d8 100644 --- a/Core/Contents/Source/PolySDLCore.cpp +++ b/Core/Contents/Source/PolySDLCore.cpp @@ -419,7 +419,8 @@ void SDLCore::setCursor(int cursorType) { } void SDLCore::warpCursor(int x, int y) { - SDL_WarpMouse(x, y); + if(!paused) + SDL_WarpMouse(x, y); } void SDLCore::lockMutex(CoreMutex *mutex) { diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 2eb4c1c40..52618e908 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -188,13 +188,15 @@ void Win32Core::captureMouse(bool newval) { } void Win32Core::warpCursor(int x, int y) { - POINT point; - point.x = x; - point.y = y; - ClientToScreen(hWnd, &point); - SetCursorPos(point.x,point.y); - lastMouseX = x; - lastMouseY = y; + if(!paused){ + POINT point; + point.x = x; + point.y = y; + ClientToScreen(hWnd, &point); + SetCursorPos(point.x,point.y); + lastMouseX = x; + lastMouseY = y; + } } unsigned int Win32Core::getTicks() { From 13420b2d0cf509026931071b91eb0748b2277412 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Sat, 5 Jul 2014 19:42:24 +0200 Subject: [PATCH 5/9] Add changes to Player and Standalone --- Player/Build/MSVC/PolycodePlayer/PolycodePlayerView.cpp | 6 ++++++ Player/Contents/Source/PolycodePlayerView.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Player/Build/MSVC/PolycodePlayer/PolycodePlayerView.cpp b/Player/Build/MSVC/PolycodePlayer/PolycodePlayerView.cpp index cb5a806f9..99441a917 100644 --- a/Player/Build/MSVC/PolycodePlayer/PolycodePlayerView.cpp +++ b/Player/Build/MSVC/PolycodePlayer/PolycodePlayerView.cpp @@ -122,6 +122,12 @@ ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; break; } break; + case WM_KILLFOCUS: + core->handleFocusChange(false); + break; + case WM_SETFOCUS: + core->handleFocusChange(true); + break; default: return DefWindowProc(hWnd, message, wParam, lParam); } diff --git a/Player/Contents/Source/PolycodePlayerView.cpp b/Player/Contents/Source/PolycodePlayerView.cpp index 0d0066930..c5a95ffab 100644 --- a/Player/Contents/Source/PolycodePlayerView.cpp +++ b/Player/Contents/Source/PolycodePlayerView.cpp @@ -146,6 +146,12 @@ ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; break; } break; + case WM_KILLFOCUS: + core->handleFocusChange(false); + break; + case WM_SETFOCUS: + core->handleFocusChange(true); + break; default: useDefault = true; break; From 5066e539dbcb8aa43f59ab2ca38385401c7cd399 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Thu, 31 Jul 2014 09:12:27 +0200 Subject: [PATCH 6/9] Fix Mouse capturing after rebase while paused. --- Core/Contents/Source/PolyWinCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 52618e908..42d756d2e 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -215,12 +215,12 @@ void Win32Core::Render() { bool Win32Core::systemUpdate() { if(!running) return false; - captureMouse(Core::mouseCaptured); doSleep(); if(!paused){ checkEvents(); Gamepad_processEvents(); updateCore(); + captureMouse(Core::mouseCaptured); } return running; } From 10890becb7c1587ea56efda058825837522403ac Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Mon, 10 Nov 2014 20:42:13 +0100 Subject: [PATCH 7/9] Fixes that IDE would not update when Debugging Project. Issue mentioned in the PR (#519) --- IDE/Contents/Source/PolycodeIDEApp.cpp | 2 ++ IDE/Contents/Source/PolycodeRemoteDebugger.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/IDE/Contents/Source/PolycodeIDEApp.cpp b/IDE/Contents/Source/PolycodeIDEApp.cpp index 991526e65..1d9e1d0c8 100644 --- a/IDE/Contents/Source/PolycodeIDEApp.cpp +++ b/IDE/Contents/Source/PolycodeIDEApp.cpp @@ -481,6 +481,8 @@ void PolycodeIDEApp::doRunProject() { frame->showConsole(); + CoreServices::getInstance()->getCore()->pauseOnLoseFocus = false; + String outPath = PolycodeToolLauncher::generateTempPath(projectManager->getActiveProject()) + ".polyapp"; PolycodeToolLauncher::buildProject(projectManager->getActiveProject(), outPath, false); PolycodeToolLauncher::runPolyapp(outPath); diff --git a/IDE/Contents/Source/PolycodeRemoteDebugger.cpp b/IDE/Contents/Source/PolycodeRemoteDebugger.cpp index 46602ff35..806da2291 100644 --- a/IDE/Contents/Source/PolycodeRemoteDebugger.cpp +++ b/IDE/Contents/Source/PolycodeRemoteDebugger.cpp @@ -52,6 +52,7 @@ void PolycodeRemoteDebugger::Disconnect() { for(int i=0; i < debuggerClients.size(); i++) { server->DisconnectClient(debuggerClients[i]->client); } + CoreServices::getInstance()->getCore()->pauseOnLoseFocus = true; debuggerClients.clear(); } @@ -124,16 +125,20 @@ void PolycodeRemoteDebugger::handleEvent(Event *event) { PolycodeConsole::print("Remote debugger client disconnected...\n"); } } + if (debuggerClients.size() == 0){ + CoreServices::getInstance()->getCore()->pauseOnLoseFocus = true; + } } break; case ServerEvent::EVENT_CLIENT_CONNECTED: { + CoreServices::getInstance()->getCore()->pauseOnLoseFocus = false; DebuggerClient *newClient = new DebuggerClient(); newClient->client = serverEvent->client; PolycodeConsole::print("Remote debugger client connected...\n"); printf("CLIENT CONNECTED\n"); - debuggerClients.push_back(newClient); + debuggerClients.push_back(newClient); } break; From 98d19bc5c1465874bfe4c30864639fcac12f67db Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Wed, 12 Nov 2014 18:47:23 +0100 Subject: [PATCH 8/9] Fix that the Mouse state change is not applied when the it changes out of the window (leave the window while pressing a mouse button - and going up outside - and going in the window again, the programm will think the mousebutton is still pressed). --- Core/Contents/Source/PolyWinCore.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Core/Contents/Source/PolyWinCore.cpp b/Core/Contents/Source/PolyWinCore.cpp index 42d756d2e..9a64c3baf 100644 --- a/Core/Contents/Source/PolyWinCore.cpp +++ b/Core/Contents/Source/PolyWinCore.cpp @@ -735,6 +735,25 @@ bool Win32Core::checkSpecialKeyEvents(PolyKEY key) { void Win32Core::checkEvents() { lockMutex(eventMutex); + + if ((GetKeyState(VK_LBUTTON) & 0x80) != 0 && !input->getMouseButtonState(CoreInput::MOUSE_BUTTON1)){ + input->setMouseButtonState(CoreInput::MOUSE_BUTTON1, true, getTicks()); + } else if ((GetKeyState(VK_LBUTTON) & 0x80) == 0 && input->getMouseButtonState(CoreInput::MOUSE_BUTTON1)) { + input->setMouseButtonState(CoreInput::MOUSE_BUTTON1, false, getTicks()); + } + + if ((GetKeyState(VK_RBUTTON) & 0x80) != 0 && !input->getMouseButtonState(CoreInput::MOUSE_BUTTON2)){ + input->setMouseButtonState(CoreInput::MOUSE_BUTTON2, true, getTicks()); + } else if ((GetKeyState(VK_RBUTTON) & 0x80) == 0 && input->getMouseButtonState(CoreInput::MOUSE_BUTTON2)){ + input->setMouseButtonState(CoreInput::MOUSE_BUTTON2, false, getTicks()); + } + + if ((GetKeyState(VK_MBUTTON) & 0x80) != 0 && !input->getMouseButtonState(CoreInput::MOUSE_BUTTON3)){ + input->setMouseButtonState(CoreInput::MOUSE_BUTTON3, true, getTicks()); + } else if ((GetKeyState(VK_MBUTTON) & 0x80) == 0 && input->getMouseButtonState(CoreInput::MOUSE_BUTTON3)) { + input->setMouseButtonState(CoreInput::MOUSE_BUTTON3, false, getTicks()); + } + Win32Event event; for(int i=0; i < win32Events.size(); i++) { event = win32Events[i]; @@ -756,12 +775,6 @@ void Win32Core::checkEvents() { lastMouseY = event.mouseY; input->setMousePosition(event.mouseX, event.mouseY, getTicks()); break; - case InputEvent::EVENT_MOUSEDOWN: - input->setMouseButtonState(event.mouseButton, true, getTicks()); - break; - case InputEvent::EVENT_MOUSEUP: - input->setMouseButtonState(event.mouseButton, false, getTicks()); - break; case InputEvent::EVENT_MOUSEWHEEL_UP: input->mouseWheelUp(getTicks()); break; From 763d4b48b7889f449b2d9634ac1045a4e539cad0 Mon Sep 17 00:00:00 2001 From: Joachim Meyer Date: Tue, 30 Dec 2014 10:45:48 +0100 Subject: [PATCH 9/9] FPS no longer set to 2 when loosing focus but pauseOnLooseFocus = false; --- Core/Contents/Source/PolyCore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Contents/Source/PolyCore.cpp b/Core/Contents/Source/PolyCore.cpp index 8e4732885..39b71091d 100755 --- a/Core/Contents/Source/PolyCore.cpp +++ b/Core/Contents/Source/PolyCore.cpp @@ -170,9 +170,9 @@ namespace Polycode { void Core::loseFocus() { if(pauseOnLoseFocus) { paused = true; + refreshInterval = 1000 / 2; } input->clearInput(); - refreshInterval = 1000 / 2; dispatchEvent(new Event(), EVENT_LOST_FOCUS); }