Skip to content
This repository has been archived by the owner on Sep 30, 2018. It is now read-only.

Commit

Permalink
[droid] add Android window events
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory Fields committed Aug 3, 2012
1 parent 02b7a0c commit a905a54
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
4 changes: 4 additions & 0 deletions xbmc/windowing/WinEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class CWinEventsBase
#include "osx/WinEventsIOS.h"
#define CWinEvents CWinEventsIOS

#elif defined(TARGET_ANDROID)
#include "android/WinEventsAndroid.h"
#define CWinEvents CWinEventsAndroid

#elif defined(TARGET_FREEBSD) && defined(HAS_SDL_WIN_EVENTS)
#include "WinEventsSDL.h"
#define CWinEvents CWinEventsSDL
Expand Down
2 changes: 1 addition & 1 deletion xbmc/windowing/WinEventsSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "osx/CocoaInterface.h"
#endif

#if defined(_LINUX) && !defined(__APPLE__)
#if defined(_LINUX) && !defined(__APPLE__) && !defined(__ANDROID__)
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
#include "input/XBMC_keysym.h"
Expand Down
7 changes: 7 additions & 0 deletions xbmc/windowing/android/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SRCS= \
WinEventsAndroid.cpp \

LIB=windowing_android.a

include ../../../Makefile.include
-include $(patsubst %.cpp,%.P,$(patsubst %.c,%.P,$(SRCS)))
67 changes: 67 additions & 0 deletions xbmc/windowing/android/WinEventsAndroid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright (C) 2010 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, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/

#include "system.h"
#include "windowing/WinEvents.h"
#include "WinEventsAndroid.h"
#include "input/XBMC_vkeys.h"
#include "Application.h"
#include "windowing/WindowingFactory.h"
#include "threads/CriticalSection.h"
#include "utils/log.h"

static CCriticalSection g_inputCond;

PHANDLE_EVENT_FUNC CWinEventsBase::m_pEventFunc = NULL;

static std::vector<XBMC_Event> events;

void CWinEventsAndroid::DeInit()
{
}

void CWinEventsAndroid::Init()
{
}

void CWinEventsAndroid::MessagePush(XBMC_Event *newEvent)
{
CSingleLock lock(g_inputCond);
events.push_back(*newEvent);
}

bool CWinEventsAndroid::MessagePump()
{
bool ret = false;
std::vector<XBMC_Event> copy_events;
{ // double-buffered events to avoid constant locking for OnEvent().
CSingleLock lock(g_inputCond);
copy_events = events;
events.clear();
}

for (std::vector<XBMC_Event>::iterator iter = copy_events.begin(); iter != copy_events.end(); iter++)
{
ret |= g_application.OnEvent(*iter);
}

return ret;
}
42 changes: 42 additions & 0 deletions xbmc/windowing/android/WinEventsAndroid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2010 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, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/

#pragma once

#ifndef WINDOW_EVENTS_ANDROID_H
#define WINDOW_EVENTS_ANDROID_H

#include "windowing/WinEvents.h"
#include "input/MouseStat.h"

class CWinEventsAndroid : public CWinEventsBase
{
public:
static void Init();
static void DeInit();
static void MessagePush(XBMC_Event *newEvent);
static bool MessagePump();

protected:

};

#endif // WINDOW_EVENTS_ANDROID_H

0 comments on commit a905a54

Please sign in to comment.