Esempio n. 1
0
static void event_sdl_watch_startthread(GPtrArray *watch_list) {
	dbg(lvl_debug, "enter\n");
	if (sdl_watch_thread)
		event_sdl_watch_stopthread();

	int ret;
	ret = pthread_create(&sdl_watch_thread, NULL,
			(void *) event_sdl_watch_thread, (void *) watch_list);

	dbg_assert(ret == 0);
}
Esempio n. 2
0
static void event_sdl_remove_watch(struct event_watch *ew) {
	dbg(lvl_debug, "enter %p\n", ew);

	event_sdl_watch_stopthread();

	g_ptr_array_remove(sdl_watch_list, ew);
	g_free(ew->pfd);
	g_free(ew);

	if (sdl_watch_list->len > 0)
		event_sdl_watch_startthread(sdl_watch_list);
}
Esempio n. 3
0
static void event_sdl_main_loop_run(void) {
#ifdef USE_WEBOS_ACCELEROMETER
	struct callback* accel_cb = NULL;
	struct event_timeout* accel_to = NULL;
	if (PDL_GetPDKVersion() > 100) {
		accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr);
		accel_to = event_add_timeout(200, 1, accel_cb);
	}
#endif
	graphics_sdl_idle(NULL);

	event_sdl_watch_stopthread();

#ifdef USE_WEBOS_ACCELEROMETER
	SDL_JoystickClose(accelerometer);
	if (PDL_GetPDKVersion() > 100) {
		event_remove_timeout(accel_to);
		callback_destroy(accel_cb);
	}
#endif
}
Esempio n. 4
0
static struct event_watch *
event_sdl_add_watch(int fd, enum event_watch_cond cond, struct callback *cb)
{
   dbg(lvl_debug,"fd(%d) cond(%x) cb(%x)\n", fd, cond, cb);

   event_sdl_watch_stopthread();

   if (!sdl_watch_list)
      sdl_watch_list = g_ptr_array_new();

   struct event_watch *new_ew = g_new0 (struct event_watch, 1);
   struct pollfd *pfd = g_new0 (struct pollfd, 1);

   pfd->fd = fd;

   /* Modify watchlist here */
   switch (cond) {
      case event_watch_cond_read:
	 pfd->events = POLLIN;
	 break;
      case event_watch_cond_write:
	 pfd->events = POLLOUT;
	 break;
      case event_watch_cond_except:
	 pfd->events = POLLERR|POLLHUP;
	 break;
   }

   new_ew->pfd = (struct pollfd*) pfd;
   new_ew->cb = cb;

   g_ptr_array_add (sdl_watch_list, (gpointer)new_ew);

   event_sdl_watch_startthread(sdl_watch_list);

   return new_ew;
}
Esempio n. 5
0
static void
event_sdl_main_loop_run(void)
{
   graphics_sdl_idle(NULL);
   event_sdl_watch_stopthread();
}