Android input library or try to handle natively

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 410
Joined: Mon Apr 14, 2003 11:48 pm
Location: Los Angeles, CA

Android input library or try to handle natively

Postby Slicky » Tue Feb 09, 2016 1:57 pm

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.
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3371
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
Contact:

Re: Android input library or try to handle natively

Postby dark_sylinc » Tue Feb 09, 2016 5:53 pm

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.
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 410
Joined: Mon Apr 14, 2003 11:48 pm
Location: Los Angeles, CA

Re: Android input library or try to handle natively

Postby Slicky » Tue Feb 09, 2016 8:54 pm

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.
0 x

User avatar
c6burns
Beholder
Posts: 1511
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines

Re: Android input library or try to handle natively

Postby c6burns » Wed Feb 10, 2016 2:36 am

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.
0 x

libolt
Halfling
Posts: 48
Joined: Wed Jan 19, 2005 4:48 am

Re: Android input library or try to handle natively

Postby libolt » Thu Feb 11, 2016 11:19 pm

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.
0 x

Slicky
Bronze Sponsor
Bronze Sponsor
Posts: 410
Joined: Mon Apr 14, 2003 11:48 pm
Location: Los Angeles, CA

Re: Android input library or try to handle natively

Postby Slicky » Fri Feb 12, 2016 1:18 pm

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.
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 282
Joined: Sun Mar 30, 2014 2:51 pm
Contact:

Re: Android input library or try to handle natively

Postby paroj » Fri Feb 12, 2016 2:33 pm

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.
0 x

longer
Gnoblar
Posts: 15
Joined: Tue Aug 19, 2014 10:46 am

Re: Android input library or try to handle natively

Postby longer » Tue Jul 19, 2016 10:14 am

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
0 x


Return to “Mobile Devices”

Who is online

Users browsing this forum: No registered users and 1 guest