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.
Android input library or try to handle natively
-
- Bronze Sponsor
- Posts: 614
- Joined: Mon Apr 14, 2003 11:48 pm
- Location: Was LA now France
- x 26
-
- OGRE Team Member
- Posts: 5458
- Joined: Sat Jul 21, 2007 4:55 pm
- Location: Buenos Aires, Argentina
- x 1353
Re: Android input library or try to handle natively
That is impossible. On Android, Java launches the native routine. And it is the Java process that gets notified of touch events.I'm mainly interested in non java solutions
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.
-
- Bronze Sponsor
- Posts: 614
- Joined: Mon Apr 14, 2003 11:48 pm
- Location: Was LA now France
- x 26
Re: Android input library or try to handle natively
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.
-
- Beholder
- Posts: 1512
- Joined: Fri Feb 22, 2013 4:44 am
- Location: Deep behind enemy lines
- x 139
Re: Android input library or try to handle natively
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.
-
- Greenskin
- Posts: 126
- Joined: Wed Jan 19, 2005 4:48 am
- x 9
Re: Android input library or try to handle natively
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.
-
- Bronze Sponsor
- Posts: 614
- Joined: Mon Apr 14, 2003 11:48 pm
- Location: Was LA now France
- x 26
Re: Android input library or try to handle natively
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.
It's good to hear what others are using though.
-
- OGRE Team Member
- Posts: 2137
- Joined: Sun Mar 30, 2014 2:51 pm
- x 1145
Re: Android input library or try to handle natively
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.
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.
-
- Kobold
- Posts: 37
- Joined: Tue Aug 19, 2014 10:46 am
- x 5
Re: Android input library or try to handle natively
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
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