Android input library or try to handle natively

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Post Reply
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

Android input library or try to handle natively

Post 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.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5292
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Android input library or try to handle natively

Post 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.
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

Re: Android input library or try to handle natively

Post 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.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Android input library or try to handle natively

Post 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.
libolt
Greenskin
Posts: 126
Joined: Wed Jan 19, 2005 4:48 am
x 9

Re: Android input library or try to handle natively

Post 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.
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 614
Joined: Mon Apr 14, 2003 11:48 pm
Location: Was LA now France
x 25

Re: Android input library or try to handle natively

Post 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.
paroj
OGRE Team Member
OGRE Team Member
Posts: 1993
Joined: Sun Mar 30, 2014 2:51 pm
x 1073
Contact:

Re: Android input library or try to handle natively

Post 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.
Last edited by paroj on Tue Jul 19, 2016 1:36 pm, edited 1 time in total.
longer
Kobold
Posts: 37
Joined: Tue Aug 19, 2014 10:46 am
x 5

Re: Android input library or try to handle natively

Post 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
Post Reply