I used the “androidbuildlibs.sh” script of the build-scripts directory and compile with success the “libSDL2.so” and “libhidapi.so”. So I want use in my app android, I tried use SDL2 in the Common Lisp with ECL and cffi. I can load the libs and use the simple function to get SDL version:
(format nil "Using SDL Library Version: ~D.~D.~D~%"
sdl2-ffi:+sdl-major-version+
sdl2-ffi:+sdl-minor-version+
sdl2-ffi:+sdl-patchlevel+) => "Using SDL Library Version: 2.0.10"
But when I tried to init SDL with:
(cl:defconstant SDL-INIT-VIDEO #x00000020)
(cffi:foreign-funcall "SDL_Init" :uint32 SDL-INIT-VIDEO :int)
(when (< (cffi:foreign-funcall "SDL_Init" :uint32 SDL-INIT-VIDEO :int) 0)
(cffi:foreign-funcall "SDL_GetError" :string))
I get: “Application didn’t initialize properly, did you include SDL_main.h in the file containing your main() function?”
So, I tried:
(cl:defconstant SDL-INIT-VIDEO #x00000020)
(cffi:foreign-funcall "SDL_SetMainReady")
(cffi:foreign-funcall "SDL_Init" :uint32 SDL-INIT-VIDEO :int)
(when (< (cffi:foreign-funcall "SDL_Init" :uint32 SDL-INIT-VIDEO :int) 0)
(cffi:foreign-funcall "SDL_GetError" :string))
So, I get: “ERROR in eval”, this means that something can’t evaluate in the ECL, and I see that the problem is with “SDL_Init”. So, I think that the SDL2 need be called in one thread, but I don’t know for sure, because I think that the SDL2 already make it.
- Am I need or not init the SDL2 in one thread?
up I tried called “SDL_Init” into one thread created with pthread of C and doesn’t work. The app crashes.
- I need include some code Java to SDL2 to work?
up I tried compile my project with the SDL2 Java files of the android-project directory and I get:
src/org/libsdl/app/SDLActivity.java:84: error: cannot find symbol
protected static Hashtable<Integer, PointerIcon> mCursors;
^
symbol: class PointerIcon
location: class SDLActivity
src/org/libsdl/app/SDLControllerManager.java:422: error: cannot find symbol
haptic.vib.vibrate(VibrationEffect.createOneShot(length, vibeValue));
^
symbol: variable VibrationEffect
location: class SDLHapticHandler_API26
src/org/libsdl/app/SDLControllerManager.java:626: error: cannot find symbol
float x = event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
^
symbol: variable AXIS_RELATIVE_X
location: class MotionEvent
src/org/libsdl/app/SDLControllerManager.java:627: error: cannot find symbol
float y = event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
^
symbol: variable AXIS_RELATIVE_Y
location: class MotionEvent
src/org/libsdl/app/SDLControllerManager.java:657: error: cannot find symbol
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_X);
^
symbol: variable AXIS_RELATIVE_X
location: class MotionEvent
src/org/libsdl/app/SDLControllerManager.java:667: error: cannot find symbol
return event.getAxisValue(MotionEvent.AXIS_RELATIVE_Y);
^
symbol: variable AXIS_RELATIVE_Y
location: class MotionEvent
src/org/libsdl/app/SDLControllerManager.java:713: error: cannot find symbol
case InputDevice.SOURCE_MOUSE_RELATIVE:
^
symbol: variable SOURCE_MOUSE_RELATIVE
location: class InputDevice
src/org/libsdl/app/SDLControllerManager.java:755: error: cannot find symbol
SDLActivity.getContentView().requestPointerCapture();
^
symbol: method requestPointerCapture()
location: class View
src/org/libsdl/app/SDLControllerManager.java:758: error: cannot find symbol
SDLActivity.getContentView().releasePointerCapture();
^
symbol: method releasePointerCapture()
location: class View
src/org/libsdl/app/SDLControllerManager.java:773: error: cannot find symbol
SDLActivity.getContentView().requestPointerCapture();
^
symbol: method requestPointerCapture()
location: class View
src/org/libsdl/app/SDLActivity.java:175: error: cannot find symbol
mCursors = new Hashtable<Integer, PointerIcon>();
^
symbol: class PointerIcon
location: class SDLActivity
src/org/libsdl/app/SDLActivity.java:1489: error: cannot find symbol
mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY));
^
symbol: variable PointerIcon
location: class SDLActivity
src/org/libsdl/app/SDLActivity.java:1561: error: cannot find symbol
mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type));
^
symbol: variable PointerIcon
location: class SDLActivity
src/org/libsdl/app/SDLActivity.java:1776: error: cannot find symbol
if (SDLActivity.mSingleton.isInMultiWindowMode()) {
^
symbol: method isInMultiWindowMode()
location: variable mSingleton of type SDLActivity
Note: src/org/libsdl/app/SDLActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: src/org/libsdl/app/SDL.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
14 errors
I’m compiling with:
SDL2_ORG_DIRS=src/org/libsdl/app
javac -source 1.7 -target 1.7 \
-bootclasspath "${JAVA_HOME}/jre/lib/rt.jar" \
-classpath "${PLATFORM}/android.jar" \
-d build/obj \
build/gen/"${ORG_DIRS}"/R.java \
"${SDL2_ORG_DIRS}"/HIDDevice.java \
"${SDL2_ORG_DIRS}"/HIDDeviceBLESteamController.java \
"${SDL2_ORG_DIRS}"/HIDDeviceManager.java \
"${SDL2_ORG_DIRS}"/HIDDeviceUSB.java \
"${SDL2_ORG_DIRS}"/SDL.java \
"${SDL2_ORG_DIRS}"/SDLAudioManager.java \
"${SDL2_ORG_DIRS}"/SDLControllerManager.java \
"${SDL2_ORG_DIRS}"/SDLActivity.java \
src/"${ORG_DIRS}"/EmbeddedCommonLisp.java \
src/"${ORG_DIRS}"/HelloEclActivity.java
I also tried with Java8 and doens’t work.