SDL 2.0 Andriod KEYCODE_BACK (SDL events to handle it) |
SDL 2.0 Andriod KEYCODE_BACK (SDL events to handle it) |
gabomdq
|
2013/12/27 Timodor
Look in SDL source code, in test/controllermap.c, search for "SDLK_AC_BACK", you'll see an example of how to get the back button key presses.
If you quit your app from the C side (return from main ), the Java side will exit as well. Gabriel. |
|||||||||||||||
|
... |
Timodor
|
I had to update to last snapshot of the SDL 2.0 code also changed to a new Java file.
The events are workings now, but it seems like the Java Back and SDL back are working at the same time. As it now going back to the menu screen for a split second. If I disable it to ignore the back button, SDL not longer receives it either. I guess what i want is for SDL to receive but for Java to ignore. |
|||||||||||
|
..... |
Timodor
|
Also
if (keyCode == KeyEvent.KEYCODE_POWER) { //return true; Log.v("SDL", "POWER key pressed"); System.exit(0); } With this new code and new Java file it no longer pick's KEYCODE _POWER event. Before if anyone pressed the power, button it will be Automatic Exit. Now it longer pick it's up, goes on pause and loss's the GL Context. Which makes it impossible to quit. |
|||||||||||
|
... |
Timodor
|
I ended up going back to the old SDL source since the new Java file broke the layout of the screen also needed a new SDL source for it work.
The events work with both my applications, same SDL source and same Java file. But one application works perfectly fine when hitting the back button, the other works for 1 second then exits. I'm so baffled since the code is the same. |
|||||||||||
|
... |
Timodor
|
Finally fixed that issue by commenting out a few event checks.
The issue is now exiting out. since I'm using an older version of SDL 2.0 older Java file, I don't think exit feature works. If i implement the new SDL source. Means my screen-layout wouldn't function. (Which means ADMOB won't work) " // Add to layout LinearLayout root = (LinearLayout) findViewById(R.id.root); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); root.addView(mSurface, lp); " Can't believe something so simple on SDL PC computer, is thehardest thing on the Android. |
|||||||||||
|
... |
Timodor
|
Ok, I downloaded latest version of SDL via Planet Mercury!
Used the latest Java file, fixed up all the Layout and Ad's It's working, the events, the back Only one last problem, it's exiting out of the application find. But the process seems to be still active, when you try loading it again. a It's black screen. I've returned Returned 0; in my main function. No idea. |
|||||||||||
|
... |
Timodor
|
got it working!!!!!!!!!!!!!!!!
Just added exit() code in the main() Thanks Dude.... |
|||||||||||
|
SDL 2.0 Andriod KEYCODE_BACK (SDL events to handle it) |
Jonny D
|
Were you using SDL_Quit()? I think it does call exit() on Android and cleans up stuff besides.
Jonny D On Sat, Dec 28, 2013 at 5:03 AM, Timodor wrote:
|
|||||||||||||
|
.... |
Timodor
|
int main(int argc, char *argv[])
{ exit(0); } I didn't call SDL exit I never tried exit(o); maybe it would of worked in the old SDL source file? Even will all this updated, there seem to be on-pause issues. Doesn't seem to be working 100%, but 97%. One phone has 50% major slow down in game, after return from onpause. The other 2 devices worked fine. |
|||||||||||
|
... |
Timodor
|
seems like exit(0); is working fine with the old Java file and the Older SDL 2.0 source.
I think I might have updated all this for no reason. TO USE BACK BUTTON ON THE ANDROID DEVICE if (event.type == SDL_KEYDOWN) if (event.key.keysym.sym == SDLK_AC_BACK ) // exit loop then exit(0); in the main.cpp or main.c make sure you remove SDL_Quit(); ...I think seems to hang. There you go |
|||||||||||
|
SDL 2.0 Andriod KEYCODE_BACK (SDL events to handle it) |
gabomdq
|
2013/12/28 Timodor
Do not issue the exit command, that terminates all threads. Simply exit from the main loop and the Java thread will detect that and terminate in turn. -- Gabriel. |
|||||||||||||
|
SDL 2.0 Andriod KEYCODE_BACK (SDL events to handle it) |
M. Gerhardy
Guest
|
Btw. I've seen the audio thread of sdl mixer (at least the music) still running even after the mainloop was left. Can anyone confirm? Am 31.12.2013 01:25 schrieb "Gabriel Jacobo":
|
|||||||||||||||
|
... |
Timodor
|
int main(int argc, char *argv[])
{ gameloop exit(0); } It's been done in the main, you mean the SDL_Exit()? I tried Return 0, Return 1, it never worked, but exit(0); in the main.cpp worked. |
|||||||||||
|