SDL port for Android SDK/NDK 1.6

Quickly share your Android Code Snippets here...

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Mon Dec 17, 2012 8:02 pm

I've applied your patch, thanks. Also I've fixed the bug when SDL returns non-zero unicode value on key up.
SDL for Android sets scancode value to SDL keysym, I did not bother to replicate PC scancodes. If you want to fix that - here's code that fills up SDL_keysym structure, here's code that processes Unicode events, it also calls this function to substitute "!@#..." symbols with Shift+"123..." keypresses, and that's exactly how SDL on PC works.
Note that this code is only for QWERTY keyboard input, the on-screen buttons provided by SDL will always set unicode value to 0 - this part of code submits key evens that come from on-screen SDL buttons.

SDL will try to get you an audio buffer of size that you request from it using SDL_OpenAudio(), it may return bigger buffer, but it never returns smaller buffer, and that's the actual buffer size it requests from Java code, so you may just increase buffer size inside SDLSoundDriver.cc:28 in OpenMSX code, to prevent choppy audio.
CompatibilityHacksPreventAudioChopping parameter fixes audio chopping for one particular Chinese tablet, I don't think it will be useful for other devices.

I have no idea why SDL crashes on that Samsung phone. Could you ask that person to try to run OpenTTD, or some other SDL-based app I've published?
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Top

Re: SDL port for Android SDK/NDK 1.6

Postby sunrise3500 » Fri Dec 28, 2012 3:37 am

Hi,
I'm currently porting an open source SDL game to Android. All of the graphics and sounds seem to be good which is great - thanks a lot pelya!
One issue I'm having is working out how to set the onscreen keyboard theme for the user so they dont have to go in the SDL menu and change the theme. My app keeps defaulting to the 'Sun' theme after a clean install.
I would think being able to set the default keyboard theme in the AndroidAppSettings.cfg would be helpful, unless there's something I've missed/don't understand. Thanks

edit: Ive found the settings.java file which contains the config for the available themes and loading of their corresponding raw files, so I've modified this file to suit my needs. :) :)
sunrise3500
Freshman
Freshman
 
Posts: 4
Joined: Fri Dec 28, 2012 3:21 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Fri Dec 28, 2012 8:26 am

Why would anyone dislike the Sun theme? It looks way better than two other themes, it does not look much like a keyboard, but that can't be a bug, right? ;)
If you want to use your own keyboard images, the easiest way is to replace .png files inside project/themes with your own, then go to project/themes/converter, and launch
make
./convert.sh
so it will pack images into assets. I was too lazy to do a proper .png loading,so that script puts all images uncompressed into a binary file.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby sunrise3500 » Fri Dec 28, 2012 3:31 pm

I was able to work out the convert util but thanks for clarifying anyway, I'm sure it will be helpful to someone out there!
One other thing I'd like to check is how to do a release build - surely that's already covered somewhere in the project as it is. I'm guessing it's not as simple as just signing the apk with my own key using the .ap_ which is the apk before it gets signed with the debug key.. (I've tried this already and failed, atleast in terms of getting an apk that is willing to install.. the object/class files must be different between a debug and release build anyway)
sunrise3500
Freshman
Freshman
 
Posts: 4
Joined: Fri Dec 28, 2012 3:21 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Fri Dec 28, 2012 5:57 pm

I'm not building release package at all, I'm just removing the debug certificate from .apk file, and signing it again with my certificate. The impact on application speed is minimal, as far as I can tell, because most of the time application executes C/C++ code, which is already optimized, Java code only executed in SDL_Flip()/SDL_GL_SwapBuffers(), in input events, and for filling audio buffer. But it gives you the possibility to debug the same .apk file right on your device, just by launching ndk-gdb (ndk-gdb is still buggy, but usable).

I've added script sign.sh, which I'm using to sign .apk files, it will use file project/bin/MainActivity-debug.apk
If you want to generate release build - build the application as usual, using build.sh, then execute command "ant release" from the "project" directory, and replace MainActivity-debug.apk with MainActivity-release-unsigned.apk inside script sign.sh. You may also try to set android:debuggable="false" inside files project/AndroidManifest.xml and project/AndroidManifestTemplate.xml, then your .apk file will not contain gdbserver binary, and you won't be able to debug it with ndk-gdb. If you'll bother to do that, please reply if you noticed any speed difference between debug and release builds.

Also, If you try to install signed package onto your device, and it already contains debug version of your application, the installation will fail - you'll need to uninstall the debug version first.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby sunrise3500 » Sat Dec 29, 2012 4:51 am

So I was kind of on the right track, but not quite there. Anyway, thanks your script simplified the process for me..

You've made all of this too easy :) I went from installing an Ubuntu VM two nights ago to a released apk today which I think is impressive (especially given the app ive ported is someone else's codebase)

aside from minor things, maybe reskin the keyboard properly, fix up some of the existing menus/interfaces to work better with hand held devices, probable issues with devices that dont have physical back button, aspect ratio needs refinement, tweak character controls/movement - but it's still a working product! Thanks again!

https://play.google.com/store/apps/deta ... kbloodshed
sunrise3500
Freshman
Freshman
 
Posts: 4
Joined: Fri Dec 28, 2012 3:21 am

Top

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Sat Dec 29, 2012 5:09 pm

Two nights? Well, that's impressive :D
You need to fix the controls first, othwerwise users will downvote your game into oblivion. Just make the game character to aim at the mouse cursor on PC build, and he'll aim at your finger on Android. The joystick may be replaced with up/down buttons, you don't need more to play or navigate game menu. Here's an example how to change on-screen button layout, you'll need to include header SDL_screenkeyboard.h, also you'll need to use the physical screen size when changing buttons layout, not the size that was specified in SDL_SetVideoMode() - use SDL_ListModes(NULL, 0)[0]->w and SDL_ListModes(NULL, 0)[0]->h to get the physical screen dimensions.
You'll also need to set following vars inside AndroidAppSettings.cfg:
AppUsesMouse=y
Do not show mouse config dialog:
HiddenMenuOptions='OptionalDownloadConfig DisplaySizeConfig'
SDL will save old on-screen keys layout between updates, so you'll also need to reset SDL config file:
ResetSdlConfigForThisVersion=y
Also, all Android devices will have the Back button, either physical or on-screen, and application cannot disable system on-screen buttons, so you don't need to worry about that. And I did not notice any issues with the aspect ratio, because I never played this game before (you may safely expect most users to think the same way).
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby sunrise3500 » Sun Dec 30, 2012 10:21 am

Thanks for the feedback, I agree users will downvote it, but hopefully they atleast bother to write a comment so improvements can be made - all devs say release release release to get that feedback! Currently the controls is the main issue imo, I'll have a go in the next few days at trying your suggestion. it does sound a lot more intuitive what you have in mind, especially given that users expect apps to just work with touch as opposed to having to use arrow buttons to navigate menus, and your method could simplify player movement and again, make it more intuitive..

even two year olds these days 'get' zoom/pinch, and just pressing on screen at what you want.. but then they assume every app to work like that too
sunrise3500
Freshman
Freshman
 
Posts: 4
Joined: Fri Dec 28, 2012 3:21 am

Re: SDL port for Android SDK/NDK 1.6

Postby awulms » Sun Dec 30, 2012 10:47 am

It seems like parameter SdlVideoResizeKeepAspect in the AndroidAppSettings.cfg is ignored. I have set following values for this parameter and its sibling SdlVideoResize:
SdlVideoResize=y
SdlVideoResizeKeepAspect=y

I have run changeAppSettings.sh -a, re-build the app, re-installed it (I have even uninstalled the previous version before installing the new one) but upon launch, the video setting "Keep 4:3 screen aspect ratio" is *not* checked. The screen gets resized to fill the screen (as expected) but it gets resized to 16:9 aspect ratio and not to 4:3. When I manually change the setting "Keep 4:3 screen aspect ratio", then it works correctly.

I would however expect that when I set the parameter to y in the config file, that the corresponding check-box will be automatically checked.

Any advise on what to do is welcome

PS: I have done a fresh 'git pull' so that I'm on the latest version of the code base
awulms
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 11, 2012 11:48 am

Re: SDL port for Android SDK/NDK 1.6

Postby pelya » Tue Jan 08, 2013 6:22 pm

SdlVideoResizeKeepAspect is currently broken, I hope I'll fix it in two weeks. Also I've got a request to put the 4:3 picture at the center of the screen, not at the left, as it is now.
pelya
Master Developer
Master Developer
 
Posts: 323
Joined: Mon Nov 23, 2009 11:31 am

Re: SDL port for Android SDK/NDK 1.6

Postby awulms » Tue Jan 08, 2013 10:41 pm

Hi Pelya,

Thanks for the feedback. I very much like the idea of putting the 4:3 picture in the center of the screen.

Brs,
Alex
awulms
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 11, 2012 11:48 am

Re: SDL port for Android SDK/NDK 1.6

Postby awulms » Sat Jan 12, 2013 8:47 am

Hi Pelya, would it be possible to add the default keyboard theme as a setting to the AndroidAppSettings file? Most openMSX users prefer to use the simple theme instead of the sun theme, so I would like to set that one as the default at build time. I noticed a post on the 2012/12/28 on how to completely change the theme but that is not my intention. I simply want to be able to change the default setting.
Kind regards,
Alex
awulms
Junior Developer
Junior Developer
 
Posts: 13
Joined: Sun Nov 11, 2012 11:48 am

Re: SDL port for Android SDK/NDK 1.6

Postby Beuc » Sun Jan 13, 2013 1:22 pm

Hi Pelya,

Thanks for the nice port and build environment!

I was able to port the Meritous game to Android with it :)
https://play.google.com/store/apps/deta ... i.meritous

I also added it to F-Droid:
http://f-droid.org/repository/browse/?f ... i.meritous
I had to provide a slightly patched fork of your repository to satisfy the "rebuild from source" requirement there though (to adapt the permissions, the default key skin and add a submodule to my app). Maybe at a point we'll be able to provide SDL as an external build dependency (an f-droid "srclib").
Beuc
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Jan 13, 2013 11:23 am

Re: SDL port for Android SDK/NDK 1.6

Postby rojola » Tue Jan 15, 2013 9:25 pm

Hi pelya, we ( xperia play owners) crossing our finger to have compatible version with touchpad support. It would be just like using a laptop touchpad on your phone! (has a synaptic touchpad with a two point multi touch operation)

The following links should help with development:
http://developer.sonyericsson.com/wportal/devworld/technology/android/xperiaplay/overview?cc=gb&lc=en
http://www.sonyericsson.com/cws/download/1/921/870/1308033582/Accessing_Touch%20Events.pdf
http://forum.xda-developers.com/showthread.php?t=1045374

How difficult/possible could you support this in SDL port ?
rojola
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jan 15, 2013 9:12 pm

Re: SDL port for Android SDK/NDK 1.6

Postby wakawaka » Mon Feb 04, 2013 6:37 am

Can anybody help me in understanding what is SDL?
Android Development Tutorials and Code Snippets: http://forum.gssdaily.com/
wakawaka
Experienced Developer
Experienced Developer
 
Posts: 79
Joined: Tue Jan 11, 2011 1:51 pm

Top
PreviousNext

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests