KeyEvent dose not inherit from InputEvent
#1
I have a problem about that KeyEvent inherits from CJNIBase in /xbmc/platform/android/jni/KeyEvent.h, but not InputEvent. While in /frameworks/base/core/java/android/view/KwyEvent.java, KeyEvent inherits from InputEvent?The injectInputEvent(InputEvent ev, int mod);I want to put the keyevent into the InputEvent,This dose't work.Please help me?
Reply
#2
And?
Just make KeyEvent inherit from InputEvent if you require so... See for instance ByteBuffer which inherits from Buffer https://github.com/xbmc/xbmc/blob/master...ffer.h#L27

Just be aware that C++/jni inheritance and java inheritance are 2 different things.
Even if the C++/jni interface does not inherit from InputEvent, a KeyEvent jni object still inherits from InputEvent java-wise.
Reply
#3
Thankyou for your reply. When I make KeyEvent inherit from InputEvent and run the kodi ,I got the fatal information: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 4587. I dont't know what cause the fatal. I want to know if I want to send keyevent to android, from jni to call inputManager.injectInputEvent ,the idea is right? or have other way to realize it in kodi ?Thankyou again for your reply.
Reply
#4
Show us some code, and please expose clearly what you are trying to achieve, i.e. what keypress are you trying to send from Kodi, to whom and why.
Reply
#5
I want to call inputManager.injectInputEvent() to realize sending keyevent (as power like) to android.
I add InputEvent.h and InputEvent.cpp.Then add some code in /xbmc/platform/android/jni/InputManager.h
Code:
static CJNIInputManager getInstance();
bool injectInputEvent(const CJNIInputEvent &event, int mode);

/xbmc/platform/android/jni/InputManager.cpp
CJNIInputManager CJNIInputManager::getInstance()
{
  return call_static_method<jhobject>("android/hardware/input/InputManager",
    "getInstance", "()Landroid/hardware/input/InputManager;");
}

bool CJNIInputManager::injectInputEvent(const CJNIInputEvent &event, int mode)
{
  return call_method<jboolean>(m_object,
    "injectInputEvent", "(Landroid/view/InputEvent;I)Z",
    event.get_raw(), mode);
}

use the function
CJNIKeyEvent ev = CJNIKeyEvent::obtain(....);
CJNIInputManager::getInstance().injectInputEvent(ev, mode);

Is it right?
Reply

Logout Mark Read Team Forum Stats Members Help
KeyEvent dose not inherit from InputEvent0