From: Brad A. <br...@us...> - 2013-03-05 16:40:34
|
gemrb: Infinity Engine emulator The branch master has been updated via 952861d13d55dda7fac3d59d229ad54da984f6a2 (commit) via 1fb655f92a65af9a40d41ab44a8381b7f4c97e40 (commit) Summary of changes: gemrb/plugins/SDLVideo/SDL20Video.cpp | 141 +++++++++++++++++---------------- 1 files changed, 71 insertions(+), 70 deletions(-) from d964390271c5a58efbe72b1b71ac80a68ab632e3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=952861d13d55dda7fac3d59d229ad54da984f6a2 commit 952861d13d55dda7fac3d59d229ad54da984f6a2 Author: Brad Allred <bra...@me...> Date: Tue Mar 5 09:40:00 2013 -0700 TouchInput: we are now compatible with mice check the device id and discard any mouse events generated by touch devices diff --git a/gemrb/plugins/SDLVideo/SDL20Video.cpp b/gemrb/plugins/SDLVideo/SDL20Video.cpp index 3688f79..52d6206 100644 --- a/gemrb/plugins/SDLVideo/SDL20Video.cpp +++ b/gemrb/plugins/SDLVideo/SDL20Video.cpp @@ -390,23 +390,6 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) bool ConsolePopped = core->ConsolePopped; switch (event.type) { - //!!!!!!!!!!!! - // !!!: currently SDL 2.0 brodcasts both mouse and touch events on touch for iOS - // there is no API to prevent the mouse events so we will be ignoring mouse events on iOS - // there is no way currently to use a mouse anyay. - // watch future SDL releases to see if/when disabling mouse events from the touchscreen is available - //!!!!!!!!!!!! -#if TARGET_OS_IPHONE || ANDROID - // TODO: we shoud implement this as a preference so we can support mice on these platforms - - // don't include SDL_MOUSEWHEEL here - // note that other platforms needn't implement this - // and should let SDLVideo handle mouse events - case SDL_MOUSEMOTION: - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - break; -#endif // For swipes only. gestures requireing pinch or rotate need to use SDL_MULTIGESTURE or SDL_DOLLARGESTURE case SDL_FINGERMOTION: { @@ -562,6 +545,18 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) */ } break; + // conditionally handle mouse events + // discard them if they are produced by touch events + // do NOT discard mouse wheel events + case SDL_MOUSEMOTION: + if (event.motion.which == SDL_TOUCH_MOUSEID) { + break; + } + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + if (event.button.which == SDL_TOUCH_MOUSEID) { + break; + } default: return SDLVideoDriver::ProcessEvent(event); } http://gemrb.git.sourceforge.net/git/gitweb.cgi?p=gemrb/gemrb;a=commitdiff;h=1fb655f92a65af9a40d41ab44a8381b7f4c97e40 commit 1fb655f92a65af9a40d41ab44a8381b7f4c97e40 Author: Brad Allred <bra...@me...> Date: Tue Mar 5 09:32:12 2013 -0700 TouchInput: update to latest SDL API diff --git a/gemrb/plugins/SDLVideo/SDL20Video.cpp b/gemrb/plugins/SDLVideo/SDL20Video.cpp index 9fbf9db..3688f79 100644 --- a/gemrb/plugins/SDLVideo/SDL20Video.cpp +++ b/gemrb/plugins/SDLVideo/SDL20Video.cpp @@ -359,28 +359,31 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) the digitizer could have a higher resolution then the screen. we need to get the scale factor to convert digitizer touch coordinates to screen pixel coordinates */ - SDL_Touch *state = SDL_GetTouch(event.tfinger.touchId); - float xScaleFactor = 1.0, yScaleFactor = 1.0; - int numFingers = 0; - if(state){ + int fingerX = 0, fingerY = 0; + int numFingers = SDL_GetNumTouchFingers(event.tfinger.touchId);; + int renderW, renderH; + SDL_RenderGetLogicalSize(renderer, &renderW, &renderH); + + if(numFingers){ focusCtrl = EvntManager->GetMouseFocusedControl(); - numFingers = state->num_fingers; + fingerX = (event.tfinger.x * renderW); + fingerY = (event.tfinger.y * renderH); - int w, h; - SDL_RenderGetLogicalSize(renderer, &w, &h); - xScaleFactor = (state->xres / w); - yScaleFactor = (state->yres / h); if (event.type == SDL_FINGERDOWN && numFingers > 1 && firstFingerDown.fingerId < 0) { // this is a rare case where multiple fingers touch simultaniously (within the same tick) // TODO: this is probably simulator only. if so lets ifdef it for the simulator + SDL_Finger* finger0 = SDL_GetTouchFinger(event.tfinger.touchId, 0); + firstFingerDown.timestamp = GetTickCount(); - firstFingerDown.x = (state->fingers[0]->x / xScaleFactor); - firstFingerDown.y = (state->fingers[0]->y / yScaleFactor); - firstFingerDown.dx = state->fingers[0]->xdelta / xScaleFactor; - firstFingerDown.dy = state->fingers[0]->ydelta / yScaleFactor; - firstFingerDown.fingerId = state->fingers[0]->id; - firstFingerDown.pressure = state->fingers[0]->pressure; + firstFingerDown.x = (finger0->x * renderW); + firstFingerDown.y = (finger0->y * renderH); + // for some reason SDL no longer tracks the deltas on a per-finger basis + // we dont use this ATM so no problem + firstFingerDown.dx = 0; + firstFingerDown.dy = 0; + firstFingerDown.fingerId = finger0->id; + firstFingerDown.pressure = finger0->pressure; } } @@ -406,50 +409,53 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) #endif // For swipes only. gestures requireing pinch or rotate need to use SDL_MULTIGESTURE or SDL_DOLLARGESTURE case SDL_FINGERMOTION: - ignoreNextFingerUp = true; - static SDL_TouchID lastFingerId = -1; - - if (numFingers == core->NumFingScroll - || (numFingers != core->NumFingKboard && (focusCtrl && focusCtrl->ControlType == IE_GUI_TEXTAREA))) { - //any # of fingers != NumFingKBoard will scroll a text area - if (focusCtrl && focusCtrl->ControlType == IE_GUI_TEXTAREA) { - // if we are scrolling a text area we dont want the keyboard in the way - HideSoftKeyboard(); - } else { - // ensure the control we touched becomes focused before attempting to scroll it. + { + ignoreNextFingerUp = true; + static SDL_TouchID lastFingerId = -1; + SDL_Finger* finger0 = SDL_GetTouchFinger(event.tfinger.touchId, 0); + + if (numFingers == core->NumFingScroll + || (numFingers != core->NumFingKboard && (focusCtrl && focusCtrl->ControlType == IE_GUI_TEXTAREA))) { + //any # of fingers != NumFingKBoard will scroll a text area + if (focusCtrl && focusCtrl->ControlType == IE_GUI_TEXTAREA) { + // if we are scrolling a text area we dont want the keyboard in the way + HideSoftKeyboard(); + } else { + // ensure the control we touched becomes focused before attempting to scroll it. + ProcessFirstTouch(GEM_MB_ACTION); + } + // invert the coordinates such that dragging down scrolls up etc. + int scrollX = (event.tfinger.dx * renderW) * -1; + int scrollY = (event.tfinger.dy * renderH) * -1; + + EvntManager->MouseWheelScroll( scrollX, scrollY ); + } else if (numFingers == core->NumFingKboard && lastFingerId != finger0->id) { + int delta = (int)(event.tfinger.dy * renderH) * -1; + if (delta > 0){ + // if the keyboard is already up interpret this gesture as console pop + if( SDL_IsScreenKeyboardShown(window) && !ConsolePopped ) core->PopupConsole(); + else ShowSoftKeyboard(); + } else if (delta < 0) { + HideSoftKeyboard(); + } + } else if (numFingers <= 1) { //click and drag + // sometimes numFingers can be 0 here! + // no idea how that is allowed, but it happens ProcessFirstTouch(GEM_MB_ACTION); + ignoreNextFingerUp = false; + // standard mouse movement + MouseMovement((event.tfinger.x * renderW), (event.tfinger.y * renderH)); } - // invert the coordinates such that dragging down scrolls up etc. - int scrollX = (event.tfinger.dx / xScaleFactor) * -1; - int scrollY = (event.tfinger.dy / yScaleFactor) * -1; - - EvntManager->MouseWheelScroll( scrollX, scrollY ); - } else if (numFingers == core->NumFingKboard && lastFingerId != state->fingers[0]->id) { - int delta = (int)(event.tfinger.dy / yScaleFactor) * -1; - if (delta > 0){ - // if the keyboard is already up interpret this gesture as console pop - if( SDL_IsScreenKeyboardShown(window) && !ConsolePopped ) core->PopupConsole(); - else ShowSoftKeyboard(); - } else if (delta < 0) { - HideSoftKeyboard(); - } - } else if (numFingers <= 1) { //click and drag - // sometimes numFingers can be 0 here! - // no idea how that is allowed, but it happens - ProcessFirstTouch(GEM_MB_ACTION); - ignoreNextFingerUp = false; - // standard mouse movement - MouseMovement((event.tfinger.x / xScaleFactor), (event.tfinger.y / yScaleFactor)); + lastFingerId = finger0->id; } - lastFingerId = state->fingers[0]->id; break; case SDL_FINGERDOWN: if (numFingers == 1) { // do not send a mouseDown event. we delay firstTouch until we know more about the context. firstFingerDown = event.tfinger; firstFingerDownTime = GetTickCount(); - firstFingerDown.x /= xScaleFactor; - firstFingerDown.y /= yScaleFactor; + firstFingerDown.x *= renderW; + firstFingerDown.y *= renderH; } else if (EvntManager && numFingers == core->NumFingInfo) { ProcessFirstTouch(GEM_MB_ACTION); EvntManager->OnSpecialKeyPress( GEM_TAB ); @@ -469,8 +475,8 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) CursorPos.x = event.button.x; CursorPos.y = event.button.y; - EvntManager->MouseUp((event.tfinger.x / xScaleFactor), - (event.tfinger.y / yScaleFactor), + EvntManager->MouseUp((event.tfinger.x * renderW), + (event.tfinger.y * renderH), mouseButton, GetModState(SDL_GetModState()) ); } } @@ -494,7 +500,7 @@ int SDL20VideoDriver::ProcessEvent(const SDL_Event & event) GameControl* gc = core->GetGameControl(); if (gc && gc->GetTargetMode() == TARGET_MODE_NONE) { ProcessFirstTouch(GEM_MB_MENU); - SDL_Finger* secondFinger = state->fingers[1]; + SDL_Finger* secondFinger = SDL_GetTouchFinger(event.tfinger.touchId, 1); gc->OnMouseOver(secondFinger->x + Viewport.x, secondFinger->y + Viewport.y); } } else { ----------------------------------------------------------------------- This is an automated email from the git hooks/post-receive script. -- gemrb: Infinity Engine emulator |