cedric's SDL egnine patch - finally.

SVN revision: 30844
This commit is contained in:
Carsten Haitzler 2007-07-16 07:23:11 +00:00
parent 33c1532d5d
commit 64171b5ca6
16 changed files with 1265 additions and 12 deletions

View File

@ -21,6 +21,7 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \
ecore-job.pc \
ecore-txt.pc \
ecore-x.pc \
ecore-sdl.pc \
ecore.pc
bin_SCRIPTS =
@ -39,6 +40,7 @@ EXTRA_DIST = AUTHORS COPYING COPYING-PLAIN ecore.c.in gendoc ecore.supp \
ecore-job.pc.in \
ecore-txt.pc.in \
ecore-x.pc.in \
ecore-sdl.pc.in \
ecore.spec.in ecore.spec \
debian/changelog \
debian/changelog.in \
@ -103,6 +105,10 @@ if BUILD_ECORE_X
px = ecore-x.pc
endif
if BUILD_ECORE_SDL
psdl = ecore-sdl.pc
endif
if BUILD_ECORE_X_XCB
px = ecore-x.pc
endif
@ -110,4 +116,4 @@ endif
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = \
ecore.pc $(pcon) $(pconfig) $(pdfb) $(pevas) \
$(pfb) $(pfile) $(pdesktop) $(pipc) $(pjob) $(ptxt) $(px)
$(pfb) $(pfile) $(pdesktop) $(pipc) $(pjob) $(ptxt) $(px) $(psdl)

View File

@ -72,6 +72,7 @@ requirements_ecore_ipc=""
requirements_ecore_job=""
requirements_ecore_txt=""
requirements_ecore_x=""
requirements_ecore_sdl=""
dnl The first call to PKG_CHECK_MODULES is done conditionally,
dnl so we should include this here:
@ -491,7 +492,6 @@ if test "x$want_ecore_evas_dfb" != "xno" ; then
CFLAGS="$save_CFLAGS"
fi
want_ecore_evas_fb="no";
have_ecore_evas_fb="no";
@ -522,6 +522,62 @@ if test "x$want_ecore_evas_fb" = "xyes" -a "x$have_ecore_fb" = "xyes"; then
)
fi
## SDL
AC_ARG_WITH(sdl-config, [ --with-sdl-config=SDL_CONFIG use sdl-config specified],
[ SDL_CONFIG=$withval;
echo "using "$SDL_CONFIG" for sdl-config"; ],
[ if test -z "$SDL_CONFIG"; then
AC_PATH_PROG(SDL_CONFIG, "sdl-config", "", $PATH)
fi
])
if test -z "$SDL_CONFIG" ; then SDL_CONFIG="sdl-config"; fi
have_sdl="no"
AC_CHECK_HEADER(SDL/SDL.h,
[ have_sdl="yes" ],
[ have_sdl="no" ]
)
ECORE_CHECK_MODULE([SDL], [yes], [$have_sdl],
[requirements_ecore_evas="$requirements_ecore_evas ecore-sdl"])
want_ecore_evas_sdl="yes";
have_ecore_evas_sdl="no";
sdl_cflags="";
sdl_libs="";
AC_MSG_CHECKING(whether ecore_evas sdl support is to be built)
AC_ARG_ENABLE(ecore-evas-sdl,
[ --enable-ecore-evas-sdl enable sdl in the ecore_evas module],
[
if test x"$enableval" = x"yes"; then
AC_MSG_RESULT(yes)
want_ecore_evas_sdl="yes"
else
AC_MSG_RESULT(no)
fi
], [
AC_MSG_RESULT(no)
]
)
if test "x$want_ecore_evas_sdl" = "xyes"; then
AC_CHECK_HEADER(Evas_Engine_SDL.h,
[
AC_DEFINE(BUILD_ECORE_EVAS_SDL, 1, [Support for SDL in Ecore_Evas])
have_ecore_evas_sdl="yes"
sdl_cflags=`$SDL_CONFIG --cflags`
sdl_libs=`$SDL_CONFIG --libs`
], [
dummy=no
], [
#include <Evas.h>
]
)
fi
AC_SUBST(sdl_cflags)
AC_SUBST(sdl_libs)
want_ecore_evas_buffer="yes";
have_ecore_evas_buffer="no";
@ -585,10 +641,7 @@ AC_ARG_ENABLE(abstract-sockets,
[ want_abstract_sockets="yes"]
)
if test "x$want_abstract_sockets" = "xyes"; then
AC_ABSTRACT_SOCKET_TEST(
[AC_DEFINE(HAVE_ABSTRACT_SOCKETS, 1, [Have abstract sockets namespace])],
[]
)
AC_DEFINE(HAVE_ABSTRACT_SOCKETS, 1, [Have abstract sockets namespace])
fi
ECORE_CHECK_MODULE([Con], [yes])
@ -755,6 +808,7 @@ AC_SUBST(requirements_ecore_ipc)
AC_SUBST(requirements_ecore_job)
AC_SUBST(requirements_ecore_txt)
AC_SUBST(requirements_ecore_x)
AC_SUBST(requirements_ecore_sdl)
# set up conditionals
AM_CONDITIONAL(BUILD_ECORE_X, test $have_ecore_x = yes -a $have_ecore_x_xcb = no)
@ -779,6 +833,7 @@ ecore-ipc.pc
ecore-job.pc
ecore-txt.pc
ecore-x.pc
ecore-sdl.pc
ecore.pc
src/Makefile
src/bin/Makefile
@ -787,6 +842,7 @@ src/lib/ecore/Makefile
src/lib/ecore_job/Makefile
src/lib/ecore_x/Makefile
src/lib/ecore_fb/Makefile
src/lib/ecore_sdl/Makefile
src/lib/ecore_evas/Makefile
src/lib/ecore_con/Makefile
src/lib/ecore_ipc/Makefile
@ -815,11 +871,13 @@ else
fi
echo " Ecore_FB.....................: $have_ecore_fb"
echo " Ecore_DFB....................: $have_ecore_directfb"
echo " Ecore_SDL....................: $have_ecore_sdl"
echo " Ecore_Evas...................: $have_ecore_evas"
echo " Ecore_Evas GL Support........: $have_ecore_evas_gl"
echo " Ecore_Evas XRender Support...: $have_ecore_evas_xrender"
echo " Ecore_Evas X11 16bpp Support.: $have_ecore_evas_16_x11"
echo " Ecore_Evas FB Support........: $have_ecore_evas_fb"
echo " Ecore_Evas SDL Support.......: $have_ecore_evas_sdl"
echo " Ecore_Evas DFB Support.......: $have_ecore_evas_dfb"
echo " Ecore_Evas Buffer Support....: $have_ecore_evas_buffer"
echo " Ecore_Ipc....................: $have_ecore_ipc (OpenSSL: $use_openssl)"

View File

@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Name: ecore-sdl
Description: E core library, SDL module
Requires: ecore @requirements_ecore_sdl@
Version: @VERSION@
Libs: -L${libdir} -lecore_sdl
Cflags: -I${includedir}

View File

@ -23,7 +23,10 @@ ecore_config_SOURCES = \
ecore_config.c
ecore_config_LDADD = \
$(ECORE_CONFIG_LIB)
$(ECORE_CONFIG_LIB) \
../lib/ecore_ipc/.libs/libecore_ipc.so \
../lib/ecore_con/.libs/libecore_con.so \
../lib/ecore/.libs/libecore.so
ecore_config_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la \

View File

@ -7,6 +7,7 @@ ecore_fb \
ecore_directfb \
ecore_con \
ecore_x \
ecore_sdl \
ecore_ipc \
ecore_evas \
ecore_config \

View File

@ -33,6 +33,8 @@ Ecore_Config.h
#config_DATA = $(DB)
#configdir = $(pkgdatadir)
if BUILD_ECORE_IPC
libecore_config_la_SOURCES = \
ecore_config.c \
ecore_config_ipc_main.c \
@ -53,6 +55,26 @@ libecore_config_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la \
$(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la
else
libecore_config_la_SOURCES = \
ecore_config.c \
ecore_config_util.c \
ecore_config_storage.c \
ecore_config_extra.c \
ecore_config_db.c \
ecore_config_private.h
libecore_config_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
@EET_LIBS@ \
@EVAS_LIBS@
libecore_config_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la
endif
endif

View File

@ -63,6 +63,7 @@ typedef enum _Ecore_Evas_Engine_Type
ECORE_EVAS_ENGINE_XRENDER_X11,
ECORE_EVAS_ENGINE_DIRECTFB,
ECORE_EVAS_ENGINE_SOFTWARE_X11_16,
ECORE_EVAS_ENGINE_SDL
} Ecore_Evas_Engine_Type;
#ifndef _ECORE_X_H
@ -126,6 +127,8 @@ EAPI const int *ecore_evas_buffer_pixels_get(Ecore_Evas *ee);
EAPI Evas_Object *ecore_evas_object_image_new(Ecore_Evas *ee_target);
EAPI Ecore_Evas *ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha);
/* generic manipulation calls */
EAPI Ecore_Evas *ecore_evas_ecore_evas_get(Evas *e);
EAPI void ecore_evas_free(Ecore_Evas *ee);

View File

@ -30,6 +30,16 @@ ECORE_DIRECTFB_LIB =
ECORE_DIRECTFB_LDF =
endif
if BUILD_ECORE_SDL
ECORE_SDL_INC = -I$(top_srcdir)/src/lib/ecore_sdl
ECORE_SDL_LIB = $(top_builddir)/src/lib/ecore_sdl/libecore_sdl.la
ECORE_SDL_LDF = -L$(top_builddir)/src/lib/ecore_sdl/.libs
else
ECORE_SDL_INC =
ECORE_SDL_LIB =
ECORE_SDL_LDF =
endif
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_srcdir)/src/lib/ecore_evas \
@ -38,6 +48,7 @@ INCLUDES = \
$(ECORE_X_INC) \
$(ECORE_FB_INC) \
$(ECORE_DIRECTFB_INC) \
$(ECORE_SDL_INC) \
@EVAS_CFLAGS@ \
@XCB_CFLAGS@
@ -45,6 +56,7 @@ libecore_evas_la_LDFLAGS = -version-info 1:0:0 \
$(ECORE_X_LDF) \
$(ECORE_FB_LDF) \
$(ECORE_DIRECTFB_LDF) \
$(ECORE_SDL_LDF) \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_EVAS
@ -59,12 +71,14 @@ ecore_evas_private.h \
ecore_evas_x.c \
ecore_evas_fb.c \
ecore_evas_buffer.c \
ecore_evas_directfb.c
ecore_evas_directfb.c \
ecore_evas_sdl.c
libecore_evas_la_LIBADD = \
$(ECORE_X_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_DIRECTFB_LIB) \
$(ECORE_SDL_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la \
@EVAS_LIBS@ \
@XCB_LIBS@
@ -73,6 +87,7 @@ libecore_evas_la_DEPENDENCIES = \
$(ECORE_X_LIB) \
$(ECORE_FB_LIB) \
$(ECORE_DIRECTFB_LIB) \
$(ECORE_SDL_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la
endif
@ -83,5 +98,5 @@ ecore_evas_private.h \
ecore_evas_x.c \
ecore_evas_fb.c \
ecore_evas_buffer.c \
ecore_evas_directfb.c
ecore_evas_directfb.c \
ecore_evas_sdl.c

View File

@ -64,8 +64,15 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine)
case ECORE_EVAS_ENGINE_DIRECTFB:
#ifdef BUILD_ECORE_EVAS_DIRECTFB
return 1;
#endif
#else
return 0;
#endif
case ECORE_EVAS_ENGINE_SDL:
#ifdef BUILD_ECORE_EVAS_SDL
return 1;
#else
return 0;
#endif
default:
return 0;
break;

View File

@ -0,0 +1,502 @@
#include "config.h"
#include "Ecore.h"
#include "ecore_private.h"
#include "ecore_evas_private.h"
#include "Ecore_Evas.h"
#ifdef BUILD_ECORE_EVAS_SDL
#include "Ecore_Sdl.h"
#include "Evas_Engine_SDL.h"
#endif
#ifdef BUILD_ECORE_EVAS_SDL
/* static char *ecore_evas_default_display = "0"; */
/* static Ecore_List *ecore_evas_input_devices = NULL; */
static int _ecore_evas_init_count = 0;
static int _ecore_evas_fps_debug = 0;
static Ecore_Evas *ecore_evases = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[10] = {
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
};
static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
static Ecore_Idler *ecore_evas_event = NULL;
static const char *ecore_evas_sdl_default = "EFL SDL";
static void
_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp)
{
ee->mouse.x = x;
ee->mouse.y = y;
if (ee->prop.cursor.object)
{
evas_object_show(ee->prop.cursor.object);
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
}
evas_event_feed_mouse_move(ee->evas, x, y, timestamp, NULL);
}
static Ecore_Evas *
_ecore_evas_sdl_match(void)
{
return ecore_evases;
}
static int
_ecore_evas_sdl_event_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Key_Down *e;
Ecore_Evas *ee;
e = event;
ee = _ecore_evas_sdl_match();
if (!ee) return 1;
/* pass on event */
evas_event_feed_key_down(ee->evas, e->keyname, NULL, e->keycompose, NULL, e->time, NULL);
return 0; /* dont pass it on */
}
static int
_ecore_evas_sdl_event_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Key_Up *e;
Ecore_Evas *ee;
e = event;
ee = _ecore_evas_sdl_match();
if (!ee) return 1;
/* pass on event */
evas_event_feed_key_up(ee->evas, e->keyname, NULL, e->keycompose, NULL, e->time, NULL);
return 0;
}
static int
_ecore_evas_sdl_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Mouse_Move *e;
Ecore_Evas *ee;
e = event;
ee = _ecore_evas_sdl_match();
if (!ee) return 1; /* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
return 0;
}
static int
_ecore_evas_sdl_event_button_down(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Mouse_Button_Down *e;
Ecore_Evas *ee;
Evas_Button_Flags flags;
e = event;
ee = _ecore_evas_sdl_match();
flags = EVAS_BUTTON_NONE;
if (!ee) return 1;
/* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
evas_event_feed_mouse_down(ee->evas, e->button, flags, e->time, NULL);
return 0;
}
static int
_ecore_evas_sdl_event_button_up(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Mouse_Button_Up *e;
Ecore_Evas *ee;
Evas_Button_Flags flags;
e = event;
ee = _ecore_evas_sdl_match();
flags = EVAS_BUTTON_NONE;
if (!ee) return 1;
/* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
evas_event_feed_mouse_up(ee->evas, e->button, flags, e->time, NULL);
return 0;
}
static int
_ecore_evas_sdl_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Mouse_Wheel *e;
Ecore_Evas *ee;
e = event;
ee = _ecore_evas_sdl_match();
if (!ee) return 1; /* pass on event */
_ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
evas_event_feed_mouse_wheel(ee->evas, e->direction, e->wheel, e->time, NULL);
return 0;
}
static int
_ecore_evas_sdl_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Evas *ee;
ee = _ecore_evas_sdl_match();
if (!ee) return 1;
/* pass on event */
ee->prop.focused = 1;
return 0;
}
static int
_ecore_evas_sdl_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Evas *ee;
ee = _ecore_evas_sdl_match();
if (!ee) return 1;
/* pass on event */
ee->prop.focused = 0;
return 0;
}
static int
_ecore_evas_sdl_event_video_resize(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Sdl_Event_Video_Resize *e;
Ecore_Evas *ee;
e = event;
ee = _ecore_evas_sdl_match();
if (!ee) return 1; /* pass on event */
evas_output_size_set(ee->evas, e->w, e->h);
return 0;
}
static int
_ecore_evas_sdl_event_video_expose(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
{
Ecore_Evas *ee;
int w;
int h;
ee = _ecore_evas_sdl_match();
if (!ee) return 1;
evas_output_size_get(ee->evas, &w, &h);
evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
return 0;
}
static int
_ecore_evas_idle_enter(void *data __UNUSED__)
{
Ecore_List2 *l;
double t1 = 0.;
double t2 = 0.;
if (_ecore_evas_fps_debug)
{
t1 = ecore_time_get();
}
for (l = (Ecore_List2 *)ecore_evases; l; l = l->next)
{
Ecore_Evas *ee;
ee = (Ecore_Evas *)l;
if (ee->visible)
{
if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee);
evas_render(ee->evas);
if (ee->func.fn_post_render) ee->func.fn_post_render(ee);
}
else
evas_norender(ee->evas);
}
if (_ecore_evas_fps_debug)
{
t2 = ecore_time_get();
_ecore_evas_fps_debug_rendertime_add(t2 - t1);
}
return 1;
}
static int
_ecore_evas_sdl_event(void *data)
{
ecore_sdl_feed_events();
return 1;
}
static int
_ecore_evas_sdl_init(int w, int h)
{
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
if (getenv("ECORE_EVAS_FPS_DEBUG")) _ecore_evas_fps_debug = 1;
ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
ecore_evas_event = ecore_timer_add(0.008, _ecore_evas_sdl_event, NULL);
if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_init();
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_SDL_EVENT_KEY_DOWN, _ecore_evas_sdl_event_key_down, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_SDL_EVENT_KEY_UP, _ecore_evas_sdl_event_key_up, NULL);
ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_SDL_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_sdl_event_button_down, NULL);
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_SDL_EVENT_MOUSE_BUTTON_UP, _ecore_evas_sdl_event_button_up, NULL);
ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_SDL_EVENT_MOUSE_MOVE, _ecore_evas_sdl_event_mouse_move, NULL);
ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_SDL_EVENT_MOUSE_WHEEL, _ecore_evas_sdl_event_mouse_wheel, NULL);
ecore_evas_event_handlers[6] = ecore_event_handler_add(ECORE_SDL_EVENT_GOT_FOCUS, _ecore_evas_sdl_event_got_focus, NULL);
ecore_evas_event_handlers[7] = ecore_event_handler_add(ECORE_SDL_EVENT_LOST_FOCUS, _ecore_evas_sdl_event_lost_focus, NULL);
ecore_evas_event_handlers[8] = ecore_event_handler_add(ECORE_SDL_EVENT_RESIZE, _ecore_evas_sdl_event_video_resize, NULL);
ecore_evas_event_handlers[9] = ecore_event_handler_add(ECORE_SDL_EVENT_EXPOSE, _ecore_evas_sdl_event_video_expose, NULL);
return _ecore_evas_init_count;
}
static int
_ecore_evas_sdl_shutdown(void)
{
_ecore_evas_init_count--;
if (_ecore_evas_init_count == 0)
{
int i;
while (ecore_evases) _ecore_evas_free(ecore_evases);
for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
ecore_event_handler_del(ecore_evas_event_handlers[i]);
ecore_idle_enterer_del(ecore_evas_idle_enterer);
ecore_evas_idle_enterer = NULL;
ecore_timer_del(ecore_evas_event);
ecore_evas_event = NULL;
if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown();
}
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
return _ecore_evas_init_count;
}
static void
_ecore_evas_sdl_free(Ecore_Evas *ee)
{
ecore_evases = _ecore_list2_remove(ecore_evases, ee);
_ecore_evas_sdl_shutdown();
ecore_sdl_shutdown();
}
static void
_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
{
if ((w == ee->w) && (h == ee->h)) return;
ee->w = w;
ee->h = h;
evas_output_size_set(ee->evas, ee->w, ee->h);
evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
static void
_ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
{
if ((w == ee->w) && (h == ee->h)) return;
ee->w = w;
ee->h = h;
evas_output_size_set(ee->evas, ee->w, ee->h);
evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
}
static void
_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
{
int x, y;
if (!file)
{
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.object = NULL;
ee->prop.cursor.file = NULL;
ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0;
return;
}
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
ee->prop.cursor.file = strdup(file);
ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y;
evas_pointer_output_xy_get(ee->evas, &x, &y);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y);
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
evas_object_resize(ee->prop.cursor.object, x, y);
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
}
static const Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
{
_ecore_evas_sdl_free,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_ecore_evas_resize,
_ecore_evas_move_resize,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_ecore_evas_cursor_set,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL
};
#endif
EAPI Ecore_Evas*
ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, int hwsurface, int noframe, int alpha)
{
#ifdef BUILD_ECORE_EVAS_SDL
Evas_Engine_Info_SDL *einfo;
Ecore_Evas *ee;
int rmethod;
if (!name)
name = ecore_evas_sdl_default;
rmethod = evas_render_method_lookup("software_sdl");
fprintf(stderr, "rmethod: %i\n", rmethod);
if (!rmethod) return NULL;
if (!ecore_sdl_init(name)) return NULL;
ee = calloc(1, sizeof(Ecore_Evas));
if (!ee) return NULL;
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
_ecore_evas_sdl_init(w, h);
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_sdl_engine_func;
ee->driver = "sdl";
if (name) ee->name = strdup(name);
if (w < 1) w = 1;
if (h < 1) h = 1;
ee->visible = 1;
ee->w = w;
ee->h = h;
ee->prop.max.w = 0;
ee->prop.max.h = 0;
ee->prop.layer = 0;
ee->prop.focused = 1;
ee->prop.borderless = 1;
ee->prop.override = 1;
ee->prop.maximized = 1;
ee->prop.fullscreen = fullscreen;
ee->prop.withdrawn = 0;
ee->prop.sticky = 0;
/* init evas here */
ee->evas = evas_new();
evas_data_attach_set(ee->evas, ee);
evas_output_method_set(ee->evas, rmethod);
evas_output_size_set(ee->evas, w, h);
evas_output_viewport_set(ee->evas, 0, 0, w, h);
einfo = (Evas_Engine_Info_SDL*) evas_engine_info_get(ee->evas);
if (einfo)
{
einfo->info.fullscreen = fullscreen;
einfo->info.hwsurface = hwsurface;
einfo->info.noframe = noframe;
einfo->info.alpha = alpha;
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
}
evas_key_modifier_add(ee->evas, "Shift");
evas_key_modifier_add(ee->evas, "Control");
evas_key_modifier_add(ee->evas, "Alt");
evas_key_modifier_add(ee->evas, "Meta");
evas_key_modifier_add(ee->evas, "Hyper");
evas_key_modifier_add(ee->evas, "Super");
evas_key_lock_add(ee->evas, "Caps_Lock");
evas_key_lock_add(ee->evas, "Num_Lock");
evas_key_lock_add(ee->evas, "Scroll_Lock");
evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
ecore_evases = _ecore_list2_prepend(ecore_evases, ee);
return ee;
#else
fprintf(stderr, "OUTCH !\n");
return NULL;
#endif
}

View File

@ -134,7 +134,6 @@ static void
_ecore_fb_event_free_key_down(void *data __UNUSED__, void *ev)
{
Ecore_Fb_Event_Key_Up *e;
e = ev;
free(e->keyname);
if (e->keysymbol) free(e->keysymbol);

View File

@ -0,0 +1,6 @@
.deps
.libs
Makefile
Makefile.in
*.lo
*.la

View File

@ -0,0 +1,113 @@
#ifndef _ECORE_FB_H
#define _ECORE_FB_H
#ifdef EAPI
#undef EAPI
#endif
#ifdef _MSC_VER
# ifdef BUILDING_DLL
# define EAPI __declspec(dllexport)
# else
# define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
# else
# define EAPI
# endif
# else
# define EAPI
# endif
#endif
/**
* @file
* @brief Ecore SDL system functions.
*/
#ifdef __cplusplus
extern "C" {
#endif
EAPI extern int ECORE_SDL_EVENT_KEY_DOWN; /**< SDL Key Down event */
EAPI extern int ECORE_SDL_EVENT_KEY_UP; /**< SDL Key Up event */
EAPI extern int ECORE_SDL_EVENT_MOUSE_BUTTON_DOWN; /**< SDL Mouse Down event */
EAPI extern int ECORE_SDL_EVENT_MOUSE_BUTTON_UP; /**< SDL Mouse Up event */
EAPI extern int ECORE_SDL_EVENT_MOUSE_MOVE; /**< SDL Mouse Move event */
EAPI extern int ECORE_SDL_EVENT_MOUSE_WHEEL; /**< SDL Mouse Wheel event */
EAPI extern int ECORE_SDL_EVENT_GOT_FOCUS; /**< SDL Mouse Wheel event */
EAPI extern int ECORE_SDL_EVENT_LOST_FOCUS; /**< SDL Mouse Wheel event */
EAPI extern int ECORE_SDL_EVENT_RESIZE;
EAPI extern int ECORE_SDL_EVENT_EXPOSE;
typedef struct _Ecore_Sdl_Event_Key_Down Ecore_Sdl_Event_Key_Down;
struct _Ecore_Sdl_Event_Key_Down /** SDL Key Down event */
{
const char *keyname; /**< The name of the key that was pressed */
const char *keycompose; /**< The UTF-8 string conversion if any */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Key_Up Ecore_Sdl_Event_Key_Up;
struct _Ecore_Sdl_Event_Key_Up /** SDL Key Up event */
{
const char *keyname; /**< The name of the key that was released */
const char *keycompose; /**< The UTF-8 string conversion if any */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Mouse_Button_Down Ecore_Sdl_Event_Mouse_Button_Down;
struct _Ecore_Sdl_Event_Mouse_Button_Down /** SDL Mouse Down event */
{
int button; /**< Mouse button that was pressed (1 - 32) */
int x; /**< Mouse co-ordinates when mouse button was pressed */
int y; /**< Mouse co-ordinates when mouse button was pressed */
int double_click : 1; /**< Set if click was a double click */
int triple_click : 1; /**< Set if click was a triple click */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Mouse_Button_Up Ecore_Sdl_Event_Mouse_Button_Up;
struct _Ecore_Sdl_Event_Mouse_Button_Up /** SDL Mouse Up event */
{
int button; /**< Mouse button that was released (1 - 32) */
int x; /**< Mouse co-ordinates when mouse button was raised */
int y; /**< Mouse co-ordinates when mouse button was raised */
int double_click : 1; /**< Set if click was a double click */
int triple_click : 1; /**< Set if click was a triple click */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Mouse_Move Ecore_Sdl_Event_Mouse_Move;
struct _Ecore_Sdl_Event_Mouse_Move /** SDL Mouse Move event */
{
int x; /**< Mouse co-ordinates where the mouse cursor moved to */
int y; /**< Mouse co-ordinates where the mouse cursor moved to */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Mouse_Wheel Ecore_Sdl_Event_Mouse_Wheel;
struct _Ecore_Sdl_Event_Mouse_Wheel /** SDL Mouse Wheel event */
{
int x,y;
int direction; /* 0 = vertical, 1 = horizontal */
int wheel; /* value 1 (left/up), -1 (right/down) */
unsigned int time;
};
typedef struct _Ecore_Sdl_Event_Video_Resize Ecore_Sdl_Event_Video_Resize;
struct _Ecore_Sdl_Event_Video_Resize
{
int w;
int h;
};
EAPI int ecore_sdl_init(const char *name);
EAPI int ecore_sdl_shutdown(void);
EAPI void ecore_sdl_feed_events(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,263 @@
#ifndef ECORE_SDL_KEYS_H__
# define ECORE_SDL_KEYS_H__
struct _ecore_sdl_keys_s
{
int code;
const char* name;
const char* compose;
};
static const struct _ecore_sdl_keys_s keystable[] =
{
{ SDLK_UNKNOWN, "0x00", "" },
{ SDLK_FIRST, "First", "" },
{ SDLK_BACKSPACE, "BackSpace", "\010" },
{ SDLK_TAB, "Tab", "\011" },
{ SDLK_CLEAR, "Clear", "" },
{ SDLK_RETURN, "Return", "\015" },
{ SDLK_PAUSE, "Pause", "" },
{ SDLK_ESCAPE, "Escape", "" },
{ SDLK_SPACE, "space", " " },
{ SDLK_EXCLAIM, "exclam", "!" },
{ SDLK_QUOTEDBL, "quotedbl", "\"" },
{ SDLK_HASH, "numbersign", "#" },
{ SDLK_DOLLAR, "dollar", "$" },
{ SDLK_AMPERSAND, "ampersand", "&" },
{ SDLK_QUOTE, "apostrophe", "'" },
{ SDLK_LEFTPAREN, "parenleft", "(" },
{ SDLK_RIGHTPAREN, "parenright", ")" },
{ SDLK_ASTERISK, "asterik", "*" },
{ SDLK_PLUS, "plus", "+" },
{ SDLK_COMMA, "comma", "," },
{ SDLK_MINUS, "minus", "-" },
{ SDLK_PERIOD, "period", "." },
{ SDLK_SLASH, "slash", "/" },
{ SDLK_0, "0", "0" },
{ SDLK_1, "1", "1" },
{ SDLK_2, "2", "2" },
{ SDLK_3, "3", "3" },
{ SDLK_4, "4", "4" },
{ SDLK_5, "5", "5" },
{ SDLK_6, "6", "6" },
{ SDLK_7, "7", "7" },
{ SDLK_8, "8", "8" },
{ SDLK_9, "9", "9" },
{ SDLK_COLON, "colon", ";" },
{ SDLK_SEMICOLON, "semicolon", ";" },
{ SDLK_LESS, "less", "<" },
{ SDLK_EQUALS, "equal", "=" },
{ SDLK_GREATER, "greater", ">" },
{ SDLK_QUESTION, "question", "?" },
{ SDLK_AT, "at", "@" },
/* Skip uppercase letters */
{ SDLK_LEFTBRACKET, "bracketleft", "[" },
{ SDLK_BACKSLASH, "backslash", "\\" },
{ SDLK_RIGHTBRACKET, "bracketright", "]" },
{ SDLK_CARET, "asciicircumm", "^" },
{ SDLK_UNDERSCORE, "underscore", "_" },
{ SDLK_BACKQUOTE, "asciitilde", "`" },
{ SDLK_a, "a", "a" },
{ SDLK_b, "b", "b" },
{ SDLK_c, "c", "c" },
{ SDLK_d, "d", "d" },
{ SDLK_e, "e", "e" },
{ SDLK_f, "f", "f" },
{ SDLK_g, "g", "g" },
{ SDLK_h, "h", "h" },
{ SDLK_i, "i", "i" },
{ SDLK_j, "j", "j" },
{ SDLK_k, "k", "k" },
{ SDLK_l, "l", "l" },
{ SDLK_m, "m", "m" },
{ SDLK_n, "n", "n" },
{ SDLK_o, "o", "o" },
{ SDLK_p, "p", "p" },
{ SDLK_q, "q", "q" },
{ SDLK_r, "r", "r" },
{ SDLK_s, "s", "s" },
{ SDLK_t, "t", "t" },
{ SDLK_u, "u", "u" },
{ SDLK_v, "v", "v" },
{ SDLK_w, "w", "w" },
{ SDLK_x, "x", "x" },
{ SDLK_y, "y", "y" },
{ SDLK_z, "z", "z" },
{ SDLK_DELETE, "Delete", "\177" },
/* End of ASCII mapped keysyms */
/* International keyboard syms */
{ SDLK_WORLD_0, "w0", "" }, /* 0xA0 */
{ SDLK_WORLD_1, "w1", "" },
{ SDLK_WORLD_2, "w2", "" },
{ SDLK_WORLD_3, "w3", "" },
{ SDLK_WORLD_4, "w4", "" },
{ SDLK_WORLD_5, "w5", "" },
{ SDLK_WORLD_6, "w6", "" },
{ SDLK_WORLD_7, "w7", "" },
{ SDLK_WORLD_8, "w8", "" },
{ SDLK_WORLD_9, "w9", "" },
{ SDLK_WORLD_10, "w10", "" },
{ SDLK_WORLD_11, "w11", "" },
{ SDLK_WORLD_12, "w12", "" },
{ SDLK_WORLD_13, "w13", "" },
{ SDLK_WORLD_14, "w14", "" },
{ SDLK_WORLD_15, "w15", "" },
{ SDLK_WORLD_16, "w16", "" },
{ SDLK_WORLD_17, "w17", "" },
{ SDLK_WORLD_18, "w18", "" },
{ SDLK_WORLD_19, "w19", "" },
{ SDLK_WORLD_20, "w20", "" },
{ SDLK_WORLD_21, "w21", "" },
{ SDLK_WORLD_22, "w22", "" },
{ SDLK_WORLD_23, "w23", "" },
{ SDLK_WORLD_24, "w24", "" },
{ SDLK_WORLD_25, "w25", "" },
{ SDLK_WORLD_26, "w26", "" },
{ SDLK_WORLD_27, "w27", "" },
{ SDLK_WORLD_28, "w28", "" },
{ SDLK_WORLD_29, "w29", "" },
{ SDLK_WORLD_30, "w30", "" },
{ SDLK_WORLD_31, "w31", "" },
{ SDLK_WORLD_32, "w32", "" },
{ SDLK_WORLD_33, "w33", "" },
{ SDLK_WORLD_34, "w34", "" },
{ SDLK_WORLD_35, "w35", "" },
{ SDLK_WORLD_36, "w36", "" },
{ SDLK_WORLD_37, "w37", "" },
{ SDLK_WORLD_38, "w38", "" },
{ SDLK_WORLD_39, "w39", "" },
{ SDLK_WORLD_40, "w40", "" },
{ SDLK_WORLD_41, "w41", "" },
{ SDLK_WORLD_42, "w42", "" },
{ SDLK_WORLD_43, "w43", "" },
{ SDLK_WORLD_44, "w44", "" },
{ SDLK_WORLD_45, "w45", "" },
{ SDLK_WORLD_46, "w46", "" },
{ SDLK_WORLD_47, "w47", "" },
{ SDLK_WORLD_48, "w48", "" },
{ SDLK_WORLD_49, "w49", "" },
{ SDLK_WORLD_50, "w50", "" },
{ SDLK_WORLD_51, "w51", "" },
{ SDLK_WORLD_52, "w52", "" },
{ SDLK_WORLD_53, "w53", "" },
{ SDLK_WORLD_54, "w54", "" },
{ SDLK_WORLD_55, "w55", "" },
{ SDLK_WORLD_56, "w56", "" },
{ SDLK_WORLD_57, "w57", "" },
{ SDLK_WORLD_58, "w58", "" },
{ SDLK_WORLD_59, "w59", "" },
{ SDLK_WORLD_60, "w60", "" },
{ SDLK_WORLD_61, "w61", "" },
{ SDLK_WORLD_62, "w62", "" },
{ SDLK_WORLD_63, "w63", "" },
{ SDLK_WORLD_64, "w64", "" },
{ SDLK_WORLD_65, "w65", "" },
{ SDLK_WORLD_66, "w66", "" },
{ SDLK_WORLD_67, "w67", "" },
{ SDLK_WORLD_68, "w68", "" },
{ SDLK_WORLD_69, "w69", "" },
{ SDLK_WORLD_70, "w70", "" },
{ SDLK_WORLD_71, "w71", "" },
{ SDLK_WORLD_72, "w72", "" },
{ SDLK_WORLD_73, "w73", "" },
{ SDLK_WORLD_74, "w74", "" },
{ SDLK_WORLD_75, "w75", "" },
{ SDLK_WORLD_76, "w76", "" },
{ SDLK_WORLD_77, "w77", "" },
{ SDLK_WORLD_78, "w78", "" },
{ SDLK_WORLD_79, "w79", "" },
{ SDLK_WORLD_80, "w80", "" },
{ SDLK_WORLD_81, "w81", "" },
{ SDLK_WORLD_82, "w82", "" },
{ SDLK_WORLD_83, "w83", "" },
{ SDLK_WORLD_84, "w84", "" },
{ SDLK_WORLD_85, "w85", "" },
{ SDLK_WORLD_86, "w86", "" },
{ SDLK_WORLD_87, "w87", "" },
{ SDLK_WORLD_88, "w88", "" },
{ SDLK_WORLD_89, "w89", "" },
{ SDLK_WORLD_90, "w90", "" },
{ SDLK_WORLD_91, "w91", "" },
{ SDLK_WORLD_92, "w92", "" },
{ SDLK_WORLD_93, "w93", "" },
{ SDLK_WORLD_94, "w94", "" },
{ SDLK_WORLD_95, "w95", "" },
/* Numeric keypad */
{ SDLK_KP0, "KP0", "0" },
{ SDLK_KP1, "KP1", "1" },
{ SDLK_KP2, "KP2", "2" },
{ SDLK_KP3, "KP3", "3" },
{ SDLK_KP4, "KP4", "4" },
{ SDLK_KP5, "KP5", "5" },
{ SDLK_KP6, "KP6", "6" },
{ SDLK_KP7, "KP7", "7" },
{ SDLK_KP8, "KP8", "8" },
{ SDLK_KP9, "KP9", "9" },
{ SDLK_KP_PERIOD, "period", "." },
{ SDLK_KP_DIVIDE, "KP_Divide", "/" },
{ SDLK_KP_MULTIPLY, "KP_Multiply", "*" },
{ SDLK_KP_MINUS, "KP_Minus", "-" },
{ SDLK_KP_PLUS, "KP_Plus", "+" },
{ SDLK_KP_ENTER, "KP_Enter", "\015" },
{ SDLK_KP_EQUALS, "KP_Equals", "=" },
/* Arrows + Home/End pad */
{ SDLK_UP, "Up", "" },
{ SDLK_DOWN, "Down", "" },
{ SDLK_RIGHT, "Right", "" },
{ SDLK_LEFT, "Left", "" },
{ SDLK_INSERT, "Insert", "" },
{ SDLK_HOME, "Home", "" },
{ SDLK_END, "End", "" },
{ SDLK_PAGEUP, "Page_Up", "" },
{ SDLK_PAGEDOWN, "Page_Down", "" },
/* Function keys */
{ SDLK_F1, "F1", "" },
{ SDLK_F2, "F2", "" },
{ SDLK_F3, "F3", "" },
{ SDLK_F4, "F4", "" },
{ SDLK_F5, "F5", "" },
{ SDLK_F6, "F6", "" },
{ SDLK_F7, "F7", "" },
{ SDLK_F8, "F8", "" },
{ SDLK_F9, "F9", "" },
{ SDLK_F10, "F10", "" },
{ SDLK_F11, "F11", "" },
{ SDLK_F12, "F12", "" },
{ SDLK_F13, "F13", "" },
{ SDLK_F14, "F14", "" },
{ SDLK_F15, "F15", "" },
/* Key state modifier keys */
{ SDLK_NUMLOCK, "Num_Lock", "" },
{ SDLK_CAPSLOCK, "Caps_Lock", "" },
{ SDLK_SCROLLOCK, "Scroll_Lock", "" },
{ SDLK_RSHIFT, "Shift_R", "" },
{ SDLK_LSHIFT, "Shift_L", "" },
{ SDLK_RCTRL, "Control_R", "" },
{ SDLK_LCTRL, "Control_L", "" },
{ SDLK_RALT, "Alt_R", "" },
{ SDLK_LALT, "Alt_L", "" },
{ SDLK_RMETA, "Meta_R", "" },
{ SDLK_LMETA, "Meta_L", "" },
{ SDLK_LSUPER, "Super_L", "" }, /* Left "Windows" key */
{ SDLK_RSUPER, "Super_R", "" }, /* Right "Windows" key */
{ SDLK_MODE, "Mode", "" }, /* "Alt Gr" key */
{ SDLK_COMPOSE, "Compose", "" }, /* Multi-key compose key */
/* Miscellaneous function keys */
{ SDLK_HELP, "Help", "" },
{ SDLK_PRINT, "Print", "" },
{ SDLK_SYSREQ, "SysReq", "" },
{ SDLK_BREAK, "Break", "" },
{ SDLK_MENU, "Menu", "" },
{ SDLK_POWER, "Power", "" }, /* Power Macintosh power key */
{ SDLK_EURO, "Euro", "" }, /* Some european keyboards */
{ SDLK_UNDO, "Undo", "" } /* Atari keyboard has Undo */
};
#endif /* ECORE_SDL_KEYS_H__ */

View File

@ -0,0 +1,33 @@
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = \
-I$(top_srcdir)/src/lib/ecore \
-I$(top_builddir)/src/lib/ecore \
@sdl_cflags@
libecore_sdl_la_LDFLAGS = -version-info 1:0:0 \
-L$(top_builddir)/src/lib/ecore/.libs
if BUILD_ECORE_SDL
lib_LTLIBRARIES = libecore_sdl.la
include_HEADERS = \
Ecore_Sdl.h
libecore_sdl_la_SOURCES = \
ecore_sdl.c \
Ecore_Sdl_Keys.h
libecore_sdl_la_LIBADD = \
$(top_builddir)/src/lib/ecore/libecore.la \
@sdl_libs@
libecore_sdl_la_DEPENDENCIES = \
$(top_builddir)/src/lib/ecore/libecore.la
endif
EXTRA_DIST = \
Ecore_Sdl.h \
Ecore_Sdl_Keys.h \
ecore_sdl.c

View File

@ -0,0 +1,211 @@
#include <SDL/SDL.h>
#include "Ecore_Sdl.h"
#include "ecore_private.h"
#include "Ecore.h"
#include "Ecore_Data.h"
#include "Ecore_Sdl_Keys.h"
EAPI int ECORE_SDL_EVENT_KEY_DOWN = 0;
EAPI int ECORE_SDL_EVENT_KEY_UP = 0;
EAPI int ECORE_SDL_EVENT_MOUSE_BUTTON_DOWN = 0;
EAPI int ECORE_SDL_EVENT_MOUSE_BUTTON_UP = 0;
EAPI int ECORE_SDL_EVENT_MOUSE_MOVE = 0;
EAPI int ECORE_SDL_EVENT_MOUSE_WHEEL = 0;
EAPI int ECORE_SDL_EVENT_GOT_FOCUS = 0;
EAPI int ECORE_SDL_EVENT_LOST_FOCUS = 0;
EAPI int ECORE_SDL_EVENT_RESIZE = 0;
EAPI int ECORE_SDL_EVENT_EXPOSE = 0;
static int _ecore_sdl_init_count = 0;
/**
* @defgroup Ecore_Sdl_Library_Group Framebuffer Library Functions
*
* Functions used to set up and shut down the Ecore_Framebuffer functions.
*/
/**
* Sets up the Ecore_Sdl library.
* @param name device target name
* @return @c 0 on failure. Otherwise, the number of times the library has
* been initialised without being shut down.
* @ingroup Ecore_SDL_Library_Group
*/
EAPI int
ecore_sdl_init(const char *name __UNUSED__)
{
if(!_ecore_sdl_init_count)
{
ECORE_SDL_EVENT_KEY_DOWN = ecore_event_type_new();
ECORE_SDL_EVENT_KEY_UP = ecore_event_type_new();
ECORE_SDL_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
ECORE_SDL_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
ECORE_SDL_EVENT_MOUSE_MOVE = ecore_event_type_new();
ECORE_SDL_EVENT_MOUSE_WHEEL = ecore_event_type_new();
ECORE_SDL_EVENT_GOT_FOCUS = ecore_event_type_new();
ECORE_SDL_EVENT_LOST_FOCUS = ecore_event_type_new();
ECORE_SDL_EVENT_RESIZE = ecore_event_type_new();
ECORE_SDL_EVENT_EXPOSE = ecore_event_type_new();
}
return ++_ecore_sdl_init_count;
}
/**
* Shuts down the Ecore_Sdl library.
* @return @c The number of times the system has been initialised without
* being shut down.
* @ingroup Ecore_SDL_Library_Group
*/
EAPI int
ecore_sdl_shutdown(void)
{
_ecore_sdl_init_count--;
return _ecore_sdl_init_count;
}
EAPI void
ecore_sdl_feed_events(void)
{
SDL_Event event;
unsigned int time;
while(SDL_PollEvent(&event))
{
time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
switch(event.type)
{
case SDL_MOUSEMOTION:
{
Ecore_Sdl_Event_Mouse_Move *ev;
ev = malloc(sizeof(Ecore_Sdl_Event_Mouse_Move));
ev->x = event.motion.x;
ev->y = event.motion.y;
ev->time = time;
ecore_event_add(ECORE_SDL_EVENT_MOUSE_MOVE, ev, NULL, NULL);
break;
}
case SDL_MOUSEBUTTONDOWN:
{
if (event.button.button == 5 ||
event.button.button == 6)
{
Ecore_Sdl_Event_Mouse_Wheel *ev;
ev = malloc(sizeof (Ecore_Sdl_Event_Mouse_Wheel));
ev->x = event.button.x;
ev->y = event.button.y;
ev->direction = 0;
ev->wheel = event.button.button == 5 ? -1 : 1;
ev->time = time;
ecore_event_add(ECORE_SDL_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
}
else
{
Ecore_Sdl_Event_Mouse_Button_Down *ev;
ev = malloc(sizeof (Ecore_Sdl_Event_Mouse_Button_Down));
ev->x = event.button.x;
ev->y = event.button.y;
ev->button = event.button.button;
ev->double_click = 0;
ev->triple_click = 0;
ev->time = time;
ecore_event_add(ECORE_SDL_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
}
break;
}
case SDL_MOUSEBUTTONUP:
{
Ecore_Sdl_Event_Mouse_Button_Up *ev;
ev = malloc(sizeof (Ecore_Sdl_Event_Mouse_Button_Up));
ev->x = event.button.x;
ev->y = event.button.y;
ev->button = event.button.button;
ev->double_click = 0;
ev->triple_click = 0;
ev->time = time;
ecore_event_add(ECORE_SDL_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
break;
}
case SDL_VIDEORESIZE:
{
Ecore_Sdl_Event_Video_Resize *ev;
ev = malloc(sizeof (Ecore_Sdl_Event_Video_Resize));
ev->w = event.resize.w;
ev->h = event.resize.h;
ecore_event_add(ECORE_SDL_EVENT_RESIZE, ev, NULL, NULL);
break;
}
case SDL_VIDEOEXPOSE:
ecore_event_add(ECORE_SDL_EVENT_EXPOSE, NULL, NULL, NULL);
break;
case SDL_QUIT:
ecore_main_loop_quit();
break;
case SDL_KEYDOWN:
{
Ecore_Sdl_Event_Key_Down *ev;
unsigned int i;
ev = malloc(sizeof (Ecore_Sdl_Event_Key_Down));
ev->time = time;
for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_sdl_keys_s); ++i)
if (keystable[i].code == event.key.keysym.sym)
{
ev->keyname = keystable[i].name;
ev->keycompose = keystable[i].compose;
ecore_event_add(ECORE_SDL_EVENT_KEY_DOWN, ev, NULL, NULL);
return ;
}
free(ev);
break;
}
case SDL_KEYUP:
{
Ecore_Sdl_Event_Key_Up *ev;
unsigned int i;
ev = malloc(sizeof (Ecore_Sdl_Event_Key_Up));
ev->time = time;
for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_sdl_keys_s); ++i)
if (keystable[i].code == event.key.keysym.sym)
{
ev->keyname = keystable[i].name;
ev->keycompose = keystable[i].compose;
ecore_event_add(ECORE_SDL_EVENT_KEY_UP, ev, NULL, NULL);
return ;
}
free(ev);
break;
}
case SDL_ACTIVEEVENT:
/* FIXME: Focus gain. */
break;
case SDL_SYSWMEVENT:
case SDL_USEREVENT:
case SDL_JOYAXISMOTION:
case SDL_JOYBALLMOTION:
case SDL_JOYHATMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
default:
break;
}
}
}