aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jcmarsha@gmail.com>2014-02-10 08:05:02 +1300
committerjmarshallnz <jcmarsha@gmail.com>2014-02-10 08:05:02 +1300
commita75ebdd1ea5e2db91965f4380242bd129ddd25d2 (patch)
tree330ee784d1d28c42cd18c35f02c0460dbede9c65
parent6b5044180c75551b5a5099035d5ab0422a1ea5e3 (diff)
parent590de11f2fff94062710168e20dca90251ca9d1f (diff)
Merge pull request #3996 from koying/fixgesture
Revert "FIX: Send Touch actions to the proper window" and properly solve
-rw-r--r--xbmc/Application.cpp64
-rw-r--r--xbmc/input/ButtonTranslator.cpp5
-rw-r--r--xbmc/input/ButtonTranslator.h2
-rw-r--r--xbmc/input/touch/generic/GenericTouchActionHandler.cpp9
-rw-r--r--xbmc/osx/ios/XBMCController.mm57
-rw-r--r--xbmc/video/windows/GUIWindowFullScreen.cpp2
-rw-r--r--xbmc/windowing/XBMC_events.h8
7 files changed, 98 insertions, 49 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index d310d47d75..23da2bc791 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -515,23 +515,66 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
return g_application.OnAppCommand(newEvent.appcommand.action);
case XBMC_TOUCH:
{
- int windowId = g_windowManager.GetActiveWindow() & WINDOW_ID_MASK;
-
if (newEvent.touch.action == ACTION_TOUCH_TAP)
{ // Send a mouse motion event with no dx,dy for getting the current guiitem selected
g_application.OnAction(CAction(ACTION_MOUSE_MOVE, 0, newEvent.touch.x, newEvent.touch.y, 0, 0));
}
int actionId = 0;
if (newEvent.touch.action == ACTION_GESTURE_BEGIN || newEvent.touch.action == ACTION_GESTURE_END)
- {
actionId = newEvent.touch.action;
- windowId = WINDOW_INVALID;
+ else
+ {
+ int iWin = g_windowManager.GetActiveWindow() & WINDOW_ID_MASK;
+ // change this if we have a dialog up
+ if (g_windowManager.HasModalDialog())
+ {
+ iWin = g_windowManager.GetTopMostModalDialogID() & WINDOW_ID_MASK;
+ }
+ if (iWin == WINDOW_DIALOG_FULLSCREEN_INFO)
+ { // fullscreen info dialog - special case
+ CButtonTranslator::GetInstance().TranslateTouchAction(iWin, newEvent.touch.action, newEvent.touch.pointers, actionId);
+ if (actionId <= 0)
+ iWin = WINDOW_FULLSCREEN_VIDEO; // fallthrough to the main window
+ }
+ if (actionId <= 0)
+ {
+ if (iWin == WINDOW_FULLSCREEN_VIDEO)
+ {
+ // current active window is full screen video.
+ if (g_application.m_pPlayer->IsInMenu())
+ {
+ // if player is in some sort of menu, (ie DVDMENU) map buttons differently
+ CButtonTranslator::GetInstance().TranslateTouchAction(WINDOW_VIDEO_MENU, newEvent.touch.action, newEvent.touch.pointers, actionId);
+ }
+ else if (g_PVRManager.IsStarted() && g_application.CurrentFileItem().HasPVRChannelInfoTag())
+ {
+ // check for PVR specific keymaps in FULLSCREEN_VIDEO window
+ CButtonTranslator::GetInstance().TranslateTouchAction(WINDOW_FULLSCREEN_LIVETV, newEvent.touch.action, newEvent.touch.pointers, actionId);
+
+ // if no PVR specific action/mapping is found, fall back to default
+ if (actionId <= 0)
+ CButtonTranslator::GetInstance().TranslateTouchAction(iWin, newEvent.touch.action, newEvent.touch.pointers, actionId);
+ }
+ else
+ {
+ // in any other case use the fullscreen window section of keymap.xml to map key->action
+ CButtonTranslator::GetInstance().TranslateTouchAction(iWin, newEvent.touch.action, newEvent.touch.pointers, actionId);
+ }
+ }
+ else // iWin != WINDOW_FULLSCREEN_VIDEO
+ CButtonTranslator::GetInstance().TranslateTouchAction(iWin, newEvent.touch.action, newEvent.touch.pointers, actionId);
+ }
}
- else if (!CButtonTranslator::GetInstance().TranslateTouchAction(newEvent.touch.action, newEvent.touch.pointers, windowId, actionId) ||
- actionId <= 0)
+
+ if (actionId <= 0)
return false;
- CApplicationMessenger::Get().SendAction(CAction(actionId, 0, newEvent.touch.x, newEvent.touch.y, newEvent.touch.x2, newEvent.touch.y2), windowId, false);
+ if ((actionId >= ACTION_TOUCH_TAP && actionId <= ACTION_GESTURE_END)
+ || (actionId >= ACTION_MOUSE_START && actionId <= ACTION_MOUSE_END) )
+ CApplicationMessenger::Get().SendAction(CAction(actionId, 0, newEvent.touch.x, newEvent.touch.y, newEvent.touch.x2, newEvent.touch.y2), WINDOW_INVALID, false);
+ else
+ CApplicationMessenger::Get().SendAction(CAction(actionId), WINDOW_INVALID, false);
+
// Post an unfocus message for touch device after the action.
if (newEvent.touch.action == ACTION_GESTURE_END || newEvent.touch.action == ACTION_TOUCH_TAP)
{
@@ -540,6 +583,13 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
}
break;
}
+ case XBMC_SETFOCUS:
+ // Reset the screensaver
+ g_application.ResetScreenSaver();
+ g_application.WakeUpScreenSaverAndDPMS();
+ // Send a mouse motion event with no dx,dy for getting the current guiitem selected
+ g_application.OnAction(CAction(ACTION_MOUSE_MOVE, 0, newEvent.focus.x, newEvent.focus.y, 0, 0));
+ break;
}
return true;
}
diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp
index c9d3161066..4724b83911 100644
--- a/xbmc/input/ButtonTranslator.cpp
+++ b/xbmc/input/ButtonTranslator.cpp
@@ -889,7 +889,7 @@ bool CButtonTranslator::TranslateJoystickString(int window, const char* szDevice
return (action > 0);
}
-bool CButtonTranslator::TranslateTouchAction(int touchAction, int touchPointers, int &window, int &action)
+bool CButtonTranslator::TranslateTouchAction(int window, int touchAction, int touchPointers, int &action)
{
action = 0;
if (touchPointers <= 0)
@@ -900,10 +900,7 @@ bool CButtonTranslator::TranslateTouchAction(int touchAction, int touchPointers,
action = GetTouchActionCode(window, touchAction);
if (action <= 0)
- {
- window = WINDOW_INVALID;
action = GetTouchActionCode(-1, touchAction);
- }
return action > 0;
}
diff --git a/xbmc/input/ButtonTranslator.h b/xbmc/input/ButtonTranslator.h
index e150e919ed..11ac033cc1 100644
--- a/xbmc/input/ButtonTranslator.h
+++ b/xbmc/input/ButtonTranslator.h
@@ -98,7 +98,7 @@ public:
bool &fullrange);
#endif
- bool TranslateTouchAction(int touchAction, int touchPointers, int &window, int &action);
+ bool TranslateTouchAction(int window, int touchAction, int touchPointers, int &action);
private:
typedef std::multimap<uint32_t, CButtonAction> buttonMap; // our button map to fill in
diff --git a/xbmc/input/touch/generic/GenericTouchActionHandler.cpp b/xbmc/input/touch/generic/GenericTouchActionHandler.cpp
index c28e287d3c..db57c987a0 100644
--- a/xbmc/input/touch/generic/GenericTouchActionHandler.cpp
+++ b/xbmc/input/touch/generic/GenericTouchActionHandler.cpp
@@ -184,14 +184,13 @@ void CGenericTouchActionHandler::sendEvent(int actionId, float x, float y, float
void CGenericTouchActionHandler::focusControl(float x, float y)
{
- // Send a mouse motion event for getting the current guiitem selected
XBMC_Event newEvent;
memset(&newEvent, 0, sizeof(newEvent));
- newEvent.type = XBMC_MOUSEMOTION;
- newEvent.motion.type = XBMC_MOUSEMOTION;
- newEvent.motion.x = (uint16_t)x;
- newEvent.motion.y = (uint16_t)y;
+ newEvent.type = XBMC_SETFOCUS;
+ newEvent.focus.type = XBMC_SETFOCUS;
+ newEvent.focus.x = (uint16_t)x;
+ newEvent.focus.y = (uint16_t)y;
CWinEvents::MessagePush(&newEvent);
}
diff --git a/xbmc/osx/ios/XBMCController.mm b/xbmc/osx/ios/XBMCController.mm
index 693a5fcd39..da7aa33fad 100644
--- a/xbmc/osx/ios/XBMCController.mm
+++ b/xbmc/osx/ios/XBMCController.mm
@@ -388,7 +388,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UITapGestureRecognizer *singleFingerSingleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleFingerSingleTap:)];
- singleFingerSingleTap.delaysTouchesBegan = YES;
+ singleFingerSingleTap.delaysTouchesBegan = NO;
singleFingerSingleTap.numberOfTapsRequired = 1;
singleFingerSingleTap.numberOfTouchesRequired = 1;
@@ -401,7 +401,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UITapGestureRecognizer *doubleFingerSingleTap = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleDoubleFingerSingleTap:)];
- doubleFingerSingleTap.delaysTouchesBegan = YES;
+ doubleFingerSingleTap.delaysTouchesBegan = NO;
doubleFingerSingleTap.numberOfTapsRequired = 1;
doubleFingerSingleTap.numberOfTouchesRequired = 2;
[m_glView addGestureRecognizer:doubleFingerSingleTap];
@@ -411,8 +411,8 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UILongPressGestureRecognizer *singleFingerSingleLongTap = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSingleFingerSingleLongTap:)];
- singleFingerSingleLongTap.delaysTouchesBegan = YES;
- singleFingerSingleLongTap.delaysTouchesEnded = YES;
+ singleFingerSingleLongTap.delaysTouchesBegan = NO;
+ singleFingerSingleLongTap.delaysTouchesEnded = NO;
[m_glView addGestureRecognizer:singleFingerSingleLongTap];
[singleFingerSingleLongTap release];
@@ -420,7 +420,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UISwipeGestureRecognizer *swipeLeft2 = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
- swipeLeft2.delaysTouchesBegan = YES;
+ swipeLeft2.delaysTouchesBegan = NO;
swipeLeft2.numberOfTouchesRequired = 2;
swipeLeft2.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft2.delegate = self;
@@ -431,7 +431,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
- swipeLeft.delaysTouchesBegan = YES;
+ swipeLeft.delaysTouchesBegan = NO;
swipeLeft.numberOfTouchesRequired = 1;
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
@@ -442,7 +442,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
- swipeRight.delaysTouchesBegan = YES;
+ swipeRight.delaysTouchesBegan = NO;
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
@@ -453,7 +453,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
- swipeUp.delaysTouchesBegan = YES;
+ swipeUp.delaysTouchesBegan = NO;
swipeUp.numberOfTouchesRequired = 1;
swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
swipeUp.delegate = self;
@@ -464,7 +464,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(handleSwipe:)];
- swipeDown.delaysTouchesBegan = YES;
+ swipeDown.delaysTouchesBegan = NO;
swipeDown.numberOfTouchesRequired = 1;
swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
swipeDown.delegate = self;
@@ -475,7 +475,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePan:)];
- pan.delaysTouchesBegan = YES;
+ pan.delaysTouchesBegan = NO;
pan.maximumNumberOfTouches = 1;
[m_glView addGestureRecognizer:pan];
[pan release];
@@ -484,7 +484,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc]
initWithTarget:self action:@selector(handlePinch:)];
- pinch.delaysTouchesBegan = YES;
+ pinch.delaysTouchesBegan = NO;
pinch.delegate = self;
[m_glView addGestureRecognizer:pinch];
[pinch release];
@@ -493,7 +493,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
UIRotationGestureRecognizer *rotate = [[UIRotationGestureRecognizer alloc]
initWithTarget:self action:@selector(handleRotate:)];
- rotate.delaysTouchesBegan = YES;
+ rotate.delaysTouchesBegan = NO;
rotate.delegate = self;
[m_glView addGestureRecognizer:rotate];
[rotate release];
@@ -512,7 +512,19 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
[self becomeFirstResponder];
}
//--------------------------------------------------------------
--(void)handlePinch:(UIPinchGestureRecognizer*)sender
+-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
+{
+ if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
+ {
+ UITouch *touch = (UITouch *)[[touches allObjects] objectAtIndex:0];
+ CGPoint point = [touch locationInView:m_glView];
+ point.x *= screenScale;
+ point.y *= screenScale;
+ CGenericTouchActionHandler::Get().OnSingleTouchStart(point.x, point.y);
+ }
+}
+//--------------------------------------------------------------
+-(void)handlePinch:(UIPinchGestureRecognizer*)sender
{
if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
{
@@ -660,23 +672,6 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
}
}
//--------------------------------------------------------------
-- (void)postMouseMotionEvent:(CGPoint)point
-{
- XBMC_Event newEvent;
-
- memset(&newEvent, 0, sizeof(newEvent));
-
- newEvent.type = XBMC_MOUSEMOTION;
- newEvent.motion.type = XBMC_MOUSEMOTION;
- newEvent.motion.which = 0;
- newEvent.motion.state = 0;
- newEvent.motion.x = point.x;
- newEvent.motion.y = point.y;
- newEvent.motion.xrel = 0;
- newEvent.motion.yrel = 0;
- CWinEvents::MessagePush(&newEvent);
-}
-//--------------------------------------------------------------
- (IBAction)handleSingleFingerSingleTap:(UIGestureRecognizer *)sender
{
if( [m_glView isXBMCAlive] )//NO GESTURES BEFORE WE ARE UP AND RUNNING
@@ -713,7 +708,7 @@ AnnounceReceiver *AnnounceReceiver::g_announceReceiver = NULL;
{
lastGesturePoint = point;
// mark the control
- CGenericTouchActionHandler::Get().OnSingleTouchStart((float)point.x, (float)point.y);
+ //CGenericTouchActionHandler::Get().OnSingleTouchStart((float)point.x, (float)point.y);
}
if (sender.state == UIGestureRecognizerStateEnded)
diff --git a/xbmc/video/windows/GUIWindowFullScreen.cpp b/xbmc/video/windows/GUIWindowFullScreen.cpp
index 548d0ff3ea..a4f5729f6e 100644
--- a/xbmc/video/windows/GUIWindowFullScreen.cpp
+++ b/xbmc/video/windows/GUIWindowFullScreen.cpp
@@ -518,7 +518,7 @@ EVENT_RESULT CGUIWindowFullScreen::OnMouseEvent(const CPoint &point, const CMous
{
return g_application.OnAction(CAction(ACTION_ANALOG_SEEK_BACK, 0.5f)) ? EVENT_RESULT_HANDLED : EVENT_RESULT_UNHANDLED;
}
- if (event.m_id == ACTION_GESTURE_NOTIFY)
+ if (event.m_id >= ACTION_GESTURE_NOTIFY && event.m_id <= ACTION_GESTURE_END) // gestures
return EVENT_RESULT_UNHANDLED;
if (event.m_id != ACTION_MOUSE_MOVE || event.m_offsetX || event.m_offsetY)
{ // some other mouse action has occurred - bring up the OSD
diff --git a/xbmc/windowing/XBMC_events.h b/xbmc/windowing/XBMC_events.h
index 479fa2b3d9..31667f54a6 100644
--- a/xbmc/windowing/XBMC_events.h
+++ b/xbmc/windowing/XBMC_events.h
@@ -68,6 +68,7 @@ typedef enum {
XBMC_VIDEOEXPOSE, /* Screen needs to be redrawn */
XBMC_APPCOMMAND, /* Media commands, such as WM_APPCOMMAND on Windows for media keys. */
XBMC_TOUCH,
+ XBMC_SETFOCUS,
XBMC_USEREVENT,
XBMC_MAXEVENT = 256 /* XBMC_EventType is represented as uchar */
@@ -204,6 +205,12 @@ typedef struct XBMC_TouchEvent {
int pointers; /* number of touch pointers */
} XBMC_TouchEvent;
+typedef struct XBMC_SetFocusEvent {
+ unsigned char type; /* XBMC_SETFOCUS */
+ int x; /* x position */
+ int y; /* y position */
+} XBMC_SetFocusEvent;
+
/* General event structure */
typedef union XBMC_Event {
unsigned char type;
@@ -223,6 +230,7 @@ typedef union XBMC_Event {
XBMC_SysWMEvent syswm;
XBMC_AppCommandEvent appcommand;
XBMC_TouchEvent touch;
+ XBMC_SetFocusEvent focus;
} XBMC_Event;
#endif /* _XBMC_events_h */