This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
/
WinEventsIOS.mm
104 lines (89 loc) · 2.98 KB
/
WinEventsIOS.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Copyright (C) 2012 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "system.h"
#include <list>
#include "WinEventsIOS.h"
#include "input/XBMC_vkeys.h"
#include "Application.h"
#include "windowing/WindowingFactory.h"
#include "threads/CriticalSection.h"
#include "guilib/GUIWindowManager.h"
#include "utils/log.h"
static CCriticalSection g_inputCond;
PHANDLE_EVENT_FUNC CWinEventsBase::m_pEventFunc = NULL;
static std::list<XBMC_Event> events;
void CWinEventsIOS::DeInit()
{
}
void CWinEventsIOS::Init()
{
}
void CWinEventsIOS::MessagePush(XBMC_Event *newEvent)
{
CSingleLock lock(g_inputCond);
events.push_back(*newEvent);
}
bool CWinEventsIOS::MessagePump()
{
bool ret = false;
// Do not always loop, only pump the initial queued count events. else if ui keep pushing
// events the loop won't finish then it will block xbmc main message loop.
for (int pumpEventCount = GetQueueSize(); pumpEventCount > 0; --pumpEventCount)
{
// Pop up only one event per time since in App::OnEvent it may init modal dialog which init
// deeper message loop and call the deeper MessagePump from there.
XBMC_Event pumpEvent;
{
CSingleLock lock(g_inputCond);
if (events.size() == 0)
return ret;
pumpEvent = events.front();
events.pop_front();
}
if (pumpEvent.type == XBMC_USEREVENT)
{
// On ATV2, we push in events as a XBMC_USEREVENT,
// the jbutton.which will be the keyID to translate using joystick.AppleRemote.xml
// jbutton.holdTime is the time the button is hold in ms (for repeated keypresses)
std::string joystickName = "AppleRemote";
bool isAxis = false;
float fAmount = 1.0;
unsigned char wKeyID = pumpEvent.jbutton.which;
unsigned int holdTime = pumpEvent.jbutton.holdTime;
CLog::Log(LOGDEBUG,"CWinEventsIOS: Button press keyID = %i", wKeyID);
ret |= g_application.ProcessJoystickEvent(joystickName, wKeyID, isAxis, fAmount, holdTime);
}
else
ret |= g_application.OnEvent(pumpEvent);
//on ios touch devices - unfocus controls on finger lift
#if !defined(TARGET_DARWIN_IOS_ATV2)
if (pumpEvent.type == XBMC_MOUSEBUTTONUP)
{
g_windowManager.SendMessage(GUI_MSG_UNFOCUS_ALL, 0, 0, 0, 0);
}
#endif
}
return ret;
}
int CWinEventsIOS::GetQueueSize()
{
CSingleLock lock(g_inputCond);
return events.size();
}