Page 1 of 1

Android input library or try to handle natively

Posted: Tue Feb 09, 2016 1:57 pm
by Slicky
What are you using for input when coding for Ogre on Android?

I was thinking about OIS but I also see there is some native capability. Has anyone grappled with this much? I'm mainly interested in non java solutions.

Re: Android input library or try to handle natively

Posted: Tue Feb 09, 2016 5:53 pm
by dark_sylinc
I'm mainly interested in non java solutions
That is impossible. On Android, Java launches the native routine. And it is the Java process that gets notified of touch events.

Fortunately, sending the touch events from Java to Native is just a couple of lines to redirect the touch events to a native routine; and from there on you can handle the event in C++. Just beware of the quircks to prevent your touch events from being overwritten while you're still reading from them.

Re: Android input library or try to handle natively

Posted: Tue Feb 09, 2016 8:54 pm
by Slicky
Thanks for the info I will now read the link you provided. I'm using the native app glue approach and without a library am getting notifications of touches on the screen. Maybe I should pursue that further. Maybe I don't need an input library. I'm off to read your link.

Re: Android input library or try to handle natively

Posted: Wed Feb 10, 2016 2:36 am
by c6burns
I immediately pull input data into my library through JNI. I have almost no Java structure at all, just the bare minimum necessary. I briefly looked at how SDL sets up an android project (since I use SDL on other platforms), but it's all done through JNI anyway. As Matias is saying, there's no avoiding Java on android, the best you can do is minimize it.

Re: Android input library or try to handle natively

Posted: Thu Feb 11, 2016 11:19 pm
by libolt
I use SDL2 to handle input on all platforms that my game runs on. Getting it working on Android stumped me for a long time. I finally ended up creating an android implementation of create Window From that I patched into my local copy of SDL2. I should send a patch to the SDL developers at some point.

Re: Android input library or try to handle natively

Posted: Fri Feb 12, 2016 1:18 pm
by Slicky
I thought about SDL2 but have never used it. I'm struggling with some other problems but input will be up soon again. SDL2 seems to do more than input but might still be a good solution. I had thought of OIS too. Without any library I am getting inputs triggered when I touch the screen. I haven't tried typing because I don't need it yet.

It's good to hear what others are using though.

Re: Android input library or try to handle natively

Posted: Fri Feb 12, 2016 2:33 pm
by paroj
actually you do not need any Input library on Android. Currently the Ogre SampleBrowser wraps the native events in OIS events and thus depends on OIS.
In my github fork I introduced a thin compatibility layer to SDL and removed OIS completely. See here:
https://github.com/OGRECave/ogre/blob/m ... greInput.h

This way you can use SDL2 on desktop without having any dependencies on Android.

Re: Android input library or try to handle natively

Posted: Tue Jul 19, 2016 10:14 am
by longer
I think the jni is the best way.pure c/c++ solution not always perfect.
Some thing like:
1.Show IEM at android and notify the IEM event at native(c/c++).
2.not only android,i think the ios need special input context.
3.if you need some billing sdk at app.The sdk always write by java,how to do this?Can not avoid it,just use it.

It's simple deal the jni input context.
you can have a look for my solution(only implement android):https://bitbucket.org/longer5562/cold,
cold/flake/src/Platform
cold/flake/proj/android/src