forked from koying/SPMC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIX: [droid] proper JNI device listener
- Loading branch information
Showing
9 changed files
with
151 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../xbmc/src/XBMCInputDeviceListener.java.in → ...nterfaces/XBMCInputDeviceListener.java.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
xbmc/platform/android/activity/JNIXBMCInputDeviceListener.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (C) 2018 Christian Browet | ||
* http://kodi.tv | ||
* | ||
* 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 <algorithm> | ||
|
||
#include "JNIXBMCInputDeviceListener.h" | ||
#include <androidjni/jutils-details.hpp> | ||
|
||
#include "CompileInfo.h" | ||
|
||
using namespace jni; | ||
|
||
static std::string s_className = std::string(CCompileInfo::GetClass()) + "/interfaces/XBMCInputDeviceListener"; | ||
|
||
CJNIXBMCInputDeviceListener::CJNIXBMCInputDeviceListener() | ||
: CJNIBase() | ||
{ | ||
add_instance(m_object, this); | ||
} | ||
|
||
CJNIXBMCInputDeviceListener::CJNIXBMCInputDeviceListener(const CJNIXBMCInputDeviceListener& other) | ||
: CJNIBase(other) | ||
{ | ||
add_instance(m_object, this); | ||
} | ||
|
||
CJNIXBMCInputDeviceListener::~CJNIXBMCInputDeviceListener() | ||
{ | ||
remove_instance(this); | ||
} | ||
|
||
void CJNIXBMCInputDeviceListener::RegisterNatives(JNIEnv* env) | ||
{ | ||
jclass cClass = env->FindClass(s_className.c_str()); | ||
if(cClass) | ||
{ | ||
JNINativeMethod methods[] = | ||
{ | ||
{ "_onInputDeviceAdded", "(I)V", (void*)&CJNIXBMCInputDeviceListener::_onInputDeviceAdded }, | ||
{ "_onInputDeviceChanged", "(I)V", (void*)&CJNIXBMCInputDeviceListener::_onInputDeviceChanged }, | ||
{ "_onInputDeviceRemoved", "(I)V", (void*)&CJNIXBMCInputDeviceListener::_onInputDeviceRemoved } | ||
}; | ||
|
||
env->RegisterNatives(cClass, methods, sizeof(methods)/sizeof(methods[0])); | ||
} | ||
} | ||
|
||
void CJNIXBMCInputDeviceListener::_onInputDeviceAdded(JNIEnv *env, jobject thiz, jint deviceId) | ||
{ | ||
(void)env; | ||
|
||
CJNIXBMCInputDeviceListener *inst = find_instance(thiz); | ||
if (inst) | ||
inst->onInputDeviceAdded(deviceId); | ||
} | ||
|
||
void CJNIXBMCInputDeviceListener::_onInputDeviceChanged(JNIEnv *env, jobject thiz, jint deviceId) | ||
{ | ||
(void)env; | ||
|
||
CJNIXBMCInputDeviceListener *inst = find_instance(thiz); | ||
if (inst) | ||
inst->onInputDeviceChanged(deviceId); | ||
} | ||
|
||
void CJNIXBMCInputDeviceListener::_onInputDeviceRemoved(JNIEnv *env, jobject thiz, jint deviceId) | ||
{ | ||
(void)env; | ||
|
||
CJNIXBMCInputDeviceListener *inst = find_instance(thiz); | ||
if (inst) | ||
inst->onInputDeviceRemoved(deviceId); | ||
} |
51 changes: 51 additions & 0 deletions
51
xbmc/platform/android/activity/JNIXBMCInputDeviceListener.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2018 Christian Browet | ||
* http://kodi.tv | ||
* | ||
* 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 <androidjni/JNIBase.h> | ||
|
||
#include <androidjni/InputManager.h> | ||
|
||
namespace jni | ||
{ | ||
|
||
class CJNIXBMCInputDeviceListener : public CJNIInputManagerInputDeviceListener, public CJNIInterfaceImplem<CJNIXBMCInputDeviceListener> | ||
{ | ||
public: | ||
CJNIXBMCInputDeviceListener(); | ||
CJNIXBMCInputDeviceListener(const CJNIXBMCInputDeviceListener& other); | ||
CJNIXBMCInputDeviceListener(const jni::jhobject &object) : CJNIBase(object) {} | ||
virtual ~CJNIXBMCInputDeviceListener(); | ||
|
||
static void RegisterNatives(JNIEnv* env); | ||
|
||
// CJNINsdManagerDiscoveryListener interface | ||
public: | ||
void onInputDeviceAdded(int deviceId) = 0; | ||
void onInputDeviceChanged(int deviceId) = 0; | ||
void onInputDeviceRemoved(int deviceId) = 0; | ||
|
||
protected: | ||
static void _onInputDeviceAdded(JNIEnv *env, jobject thiz, jint deviceId); | ||
static void _onInputDeviceChanged(JNIEnv *env, jobject thiz, jint deviceId); | ||
static void _onInputDeviceRemoved(JNIEnv *env, jobject thiz, jint deviceId); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters