- Link with library libosso, call osso_initialize
 - Call every 50s osso_display_blanking_pause for keeping backlight alive
 - Do not create WM icon, on Maemo is not supported
This commit is contained in:
Pali Rohár 2010-07-14 10:33:28 +02:00
parent eb9822b382
commit 6329e3bb13
2 changed files with 67 additions and 2 deletions

View file

@ -31,6 +31,9 @@ fi
if test "$ARCH" = "linux" && test -f /etc/maemo_version; then
CPPFLAGS="$CPPFLAGS -DUSE_MAEMO"
MAEMO=yes
CFLAGS="$CFLAGS $(pkg-config --cflags libosso)"
CXXFLAGS="$CXXFLAGS $(pkg-config --cflags libosso)"
LDFLAGS="$LDFLAGS $(pkg-config --libs libosso)"
fi
if test "$ARCH" = "bsd" ; then

View file

@ -75,6 +75,10 @@
#include "attachconsole.h"
#endif
#ifdef USE_MAEMO
#include <libosso.h>
#endif
#include "video.h"
#include "font.h"
#include "interface.h"
@ -164,6 +168,7 @@ void SetVideoSync(void)
-- Video
----------------------------------------------------------------------------*/
#ifndef USE_GLES
/**
** Check if an extension is supported
*/
@ -199,6 +204,7 @@ static bool IsExtensionSupported(const char *extension)
}
return false;
}
#endif
/**
** Initialize OpenGL extensions
@ -429,6 +435,56 @@ static void InitKey2Str()
Key2Str[SDLK_UNDO] = "undo";
}
#ifdef USE_MAEMO
osso_context_t * osso = NULL;
SDL_TimerID timer;
static Uint32 OssoKeepBacklightAlive(Uint32 interval, void *param)
{
if (!osso)
return interval;
osso_display_state_on(osso);
osso_display_blanking_pause(osso);
return interval;
}
void OssoInitialize()
{
char * application;
if (FullGameName.empty())
application = (char *)"org.stratagus";
else
application = (char *)std::string("org.stratagus." + FullGameName).c_str();
if (strlen(application) > 14)
application[14] = tolower(application[14]);
osso = osso_initialize(application, VERSION, TRUE, NULL);
if (!osso) {
fprintf(stderr, "Couldn't initialize OSSO\n");
exit(OSSO_ERROR);
}
timer = SDL_AddTimer(50000, OssoKeepBacklightAlive, NULL);
if (!timer) {
fprintf(stderr, "Couldn't initialize SDL_AddTimer: %s\n", SDL_GetError());
exit(1);
}
}
void OssoDeinitialize()
{
SDL_RemoveTimer(timer);
osso_deinitialize(osso);
}
#endif
/**
** Initialize the video part for SDL.
*/
@ -467,7 +523,7 @@ void InitVideoSdl(void)
else
SDL_WM_SetCaption(FullGameName.c_str(), FullGameName.c_str());
#ifndef USE_WIN32
#if ! defined(USE_WIN32) && ! defined(USE_MAEMO)
// Make sure, that we not create OpenGL textures (and do not call OpenGL functions), when creating icon surface
bool UseOpenGL_orig = UseOpenGL;
UseOpenGL = false;
@ -500,7 +556,8 @@ void InitVideoSdl(void)
CGraphic::Free(g);
UseOpenGL = UseOpenGL_orig;
#else
#endif
#ifdef USE_WIN32
int argc = 0;
LPWSTR * argv = NULL;
HWND hwnd = NULL;
@ -598,6 +655,11 @@ void InitVideoSdl(void)
InitOpenGL();
}
#ifdef USE_MAEMO
OssoInitialize();
atexit(OssoDeinitialize);
#endif
InitKey2Str();
ColorBlack = Video.MapRGB(TheScreen->format, 0, 0, 0);