Handle longclick in PS:Instant mode

This commit is contained in:
hex007 2017-09-21 10:44:00 -07:00
parent 8e7ee6c931
commit 8d4a69cacf
2 changed files with 9 additions and 0 deletions

View file

@ -7,6 +7,7 @@
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "resources/Font.h" #include "resources/Font.h"
#include "Renderer.h" #include "Renderer.h"
#include "PowerSaver.h"
enum CursorState enum CursorState
{ {
@ -191,6 +192,8 @@ protected:
bool listInput(int velocity) // a velocity of 0 = stop scrolling bool listInput(int velocity) // a velocity of 0 = stop scrolling
{ {
PowerSaver::setState(velocity == 0);
// generate an onCursorChanged event in the stopped state when the user lets go of the key // generate an onCursorChanged event in the stopped state when the user lets go of the key
if(velocity == 0 && mScrollVelocity != 0) if(velocity == 0 && mScrollVelocity != 0)
onCursorChanged(CURSOR_STOPPED); onCursorChanged(CURSOR_STOPPED);

View file

@ -1,6 +1,7 @@
#include "guis/GuiDetectDevice.h" #include "guis/GuiDetectDevice.h"
#include "Window.h" #include "Window.h"
#include "Renderer.h" #include "Renderer.h"
#include "PowerSaver.h"
#include "resources/Font.h" #include "resources/Font.h"
#include "guis/GuiInputConfig.h" #include "guis/GuiInputConfig.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
@ -74,9 +75,12 @@ void GuiDetectDevice::onSizeChanged()
bool GuiDetectDevice::input(InputConfig* config, Input input) bool GuiDetectDevice::input(InputConfig* config, Input input)
{ {
PowerSaver::pause();
if(!mFirstRun && input.device == DEVICE_KEYBOARD && input.type == TYPE_KEY && input.value && input.id == SDLK_ESCAPE) if(!mFirstRun && input.device == DEVICE_KEYBOARD && input.type == TYPE_KEY && input.value && input.id == SDLK_ESCAPE)
{ {
// cancel configuring // cancel configuring
PowerSaver::resume();
delete this; delete this;
return true; return true;
} }
@ -109,6 +113,7 @@ void GuiDetectDevice::update(int deltaTime)
{ {
if(mDoneCallback) if(mDoneCallback)
mDoneCallback(); mDoneCallback();
PowerSaver::resume();
delete this; // delete GUI element delete this; // delete GUI element
} }
else else
@ -121,6 +126,7 @@ void GuiDetectDevice::update(int deltaTime)
{ {
// picked one! // picked one!
mWindow->pushGui(new GuiInputConfig(mWindow, mHoldingConfig, true, mDoneCallback)); mWindow->pushGui(new GuiInputConfig(mWindow, mHoldingConfig, true, mDoneCallback));
PowerSaver::resume();
delete this; delete this;
} }
} }