Adding SDL support for controllers ONLY on Android

Hello,

I’ve got an existing, multi-platform game with a variety of technologies providing the controllers.
I was looking to use SDL to unify this, and so far it’s worked well for win32, UWP, OSX, iOS and Linux. Couple of hours for the first one, a few minutes to port it to all the others. All works. Lives in its own folder. Lovely.

Then we get to Android.

Now I knew this would be different, as there’s the Java layer to think about, but the way it’s implemented seems to assume that

  • You are starting a new Android Studio project from scratch
  • You want to use ALL the features

I have an existing project, and I only want one of the features. I also would rather not have to copy source files from the SDL folder into my own project (which, if nothing else, makes version upgrades difficult).

Has anyone attempted this before, and if so do they have any tips?

My current best idea is to rip the controller functions out of SDLActivity and crudely stuff them into my own Activity.

You can link to the SDL source outside of the project, if that helps.

And define SDL_LEAN_AND_MEAN to strip out some unwanted stuff at least.

Besides them two things, I’d have thought the controller logic would be too intertwined with the rest of SDL to make it feasible.

Didn’t know about that one, but it looks useful.
I’ve actually got all the JNI/C code in just fine - added this to my Android.mk file:

include $(AS_RELATIVE_ROOT)/third_party/SDL2-2.0.12/Android.mk

and

LOCAL_STATIC_LIBRARIES := <blah> libSDL2

and it brings it all in nicely.
Unfortunately, it’s the Java layer that’s the ‘interesting’ part. Making progress though.