Permalink
Browse files

touchInput: fix repeat mouse events causing stuck buttons

  • Loading branch information...
bradallred committed May 21, 2013
1 parent a3e8840 commit d602aa97c9af85868f5f4880a4bfe487a3d5310a
Showing with 12 additions and 5 deletions.
  1. +12 −5 gemrb/plugins/SDLVideo/SDL20Video.cpp
@@ -21,6 +21,8 @@
#include "SDL20Video.h"
#include "Interface.h"
+
+#include "GUI/Button.h"
#include "GUI/Console.h"
#include "GUI/GameControl.h" // for TargetMode (contextual information for touch inputs)
@@ -378,11 +380,6 @@ void SDL20VideoDriver::ClearFirstTouch()
bool SDL20VideoDriver::ProcessFirstTouch( int mouseButton )
{
if (!(MouseFlags & MOUSE_DISABLED) && firstFingerDown.fingerId >= 0) {
- lastMouseDownTime = EvntManager->GetRKDelay();
- if (lastMouseDownTime != (unsigned long) ~0) {
- lastMouseDownTime += lastMouseDownTime + lastTime;
- }
-
// do an actual mouse move first! this is important for things such as ground piles to work!
// also ensure any referencing of the cursor is accurate
MouseMovement(firstFingerDown.x, firstFingerDown.y);
@@ -467,6 +464,11 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event)
continuingGesture = true;
break;
case SDL_FINGERDOWN:
+ lastMouseDownTime = EvntManager->GetRKDelay();
+ if (lastMouseDownTime != (unsigned long) ~0) {
+ lastMouseDownTime += lastMouseDownTime + lastTime;
+ }
+
if (!finger0) numFingers++;
continuingGesture = false;
if (numFingers == 1
@@ -521,6 +523,11 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event)
EvntManager->MouseUp(ScaleCoordinateHorizontal(event.tfinger.x),
ScaleCoordinateVertical(event.tfinger.y),
mouseButton, GetModState(SDL_GetModState()) );
+ } else {
+ focusCtrl = EvntManager->GetMouseFocusedControl();
+ if (focusCtrl && focusCtrl->ControlType == IE_GUI_BUTTON)
+ // these are repeat events so the control should stay pressed
+ ((Button*)focusCtrl)->SetState(IE_GUI_BUTTON_UNPRESSED);
}
}
if (numFingers != core->NumFingInfo) {

0 comments on commit d602aa9

Please sign in to comment.