fa67e8ac13e5108acf89b7169b5c070ee8bbe25b
[neverball] / share / maemo.c
1 /*
2  *  Copyright (C) 2011  Neverball authors
3  *
4  *  This  program is  free software;  you can  redistribute  it and/or
5  *  modify it  under the  terms of the  GNU General Public  License as
6  *  published by the Free Software Foundation; either version 2 of the
7  *  License, or (at your option) any later version.
8  *
9  *  This program  is distributed in the  hope that it  will be useful,
10  *  but  WITHOUT ANY WARRANTY;  without even  the implied  warranty of
11  *  MERCHANTABILITY or FITNESS FOR  A PARTICULAR PURPOSE.  See the GNU
12  *  General Public License for more details.
13  *
14  *  You should have received a  copy of the GNU General Public License
15  *  along  with this  program;  if  not, write  to  the Free  Software
16  *  Foundation,  Inc.,   59  Temple  Place,  Suite   330,  Boston,  MA
17  *  02111-1307 USA
18  */
19
20 #include "maemo.h"
21 #include <SDL/SDL_timer.h>
22 #include <libosso.h>
23
24 static osso_context_t *osso_context = NULL;
25 static SDL_TimerID screen_timer_id = 0;
26
27 static Uint32 disable_display_blank(Uint32 interval, void *param)
28 {
29     int ret;
30     ret = osso_display_blanking_pause(osso_context);
31     return interval;
32 }
33
34 int maemo_init(const char *program)
35 {
36     osso_context = osso_initialize(program, "1.0", 0, NULL);
37     if (!osso_context) {
38         fprintf(stderr, "osso_initialize failed!\n");
39         return 0;
40     }
41
42     osso_display_blanking_pause(osso_context);
43     screen_timer_id = SDL_AddTimer(30000, disable_display_blank, NULL);
44     return 1;
45 }
46
47 void maemo_quit(void)
48 {
49     if (osso_context)
50         osso_deinitialize(osso_context);
51
52     SDL_RemoveTimer(screen_timer_id);
53 }
54