2009-01-31 10:33:39 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
#include "Ecore_Fb.h"
|
2006-07-30 21:13:51 -07:00
|
|
|
#include "ecore_fb_private.h"
|
2005-09-14 21:19:45 -07:00
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
static void _ecore_fb_size_get(int *w, int *h);
|
2006-01-06 10:26:37 -08:00
|
|
|
|
|
|
|
EAPI int ECORE_FB_EVENT_KEY_DOWN = 0;
|
|
|
|
EAPI int ECORE_FB_EVENT_KEY_UP = 0;
|
|
|
|
EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = 0;
|
|
|
|
EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_UP = 0;
|
|
|
|
EAPI int ECORE_FB_EVENT_MOUSE_MOVE = 0;
|
2006-07-30 21:13:51 -07:00
|
|
|
EAPI int ECORE_FB_EVENT_MOUSE_WHEEL = 0;
|
2003-09-23 01:09:32 -07:00
|
|
|
|
|
|
|
static int _ecore_fb_init_count = 0;
|
|
|
|
static int _ecore_fb_console_w = 0;
|
|
|
|
static int _ecore_fb_console_h = 0;
|
|
|
|
|
2004-08-23 15:59:00 -07:00
|
|
|
/**
|
|
|
|
* @defgroup Ecore_FB_Library_Group Framebuffer Library Functions
|
|
|
|
*
|
|
|
|
* Functions used to set up and shut down the Ecore_Framebuffer functions.
|
|
|
|
*/
|
|
|
|
|
2003-09-23 01:09:32 -07:00
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Sets up the Ecore_Fb library.
|
2004-08-23 15:59:00 -07:00
|
|
|
* @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_FB_Library_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 10:26:37 -08:00
|
|
|
EAPI int
|
2005-03-01 23:06:44 -08:00
|
|
|
ecore_fb_init(const char *name __UNUSED__)
|
2003-09-23 01:09:32 -07:00
|
|
|
{
|
2009-10-09 22:28:43 -07:00
|
|
|
if (++_ecore_fb_init_count != 1)
|
2010-09-18 20:25:15 -07:00
|
|
|
return _ecore_fb_init_count;
|
|
|
|
|
2009-10-09 22:28:43 -07:00
|
|
|
if (!ecore_fb_vt_init())
|
2010-09-18 20:25:15 -07:00
|
|
|
return --_ecore_fb_init_count;
|
|
|
|
|
2009-10-09 22:28:43 -07:00
|
|
|
ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new();
|
|
|
|
ECORE_FB_EVENT_KEY_UP = ecore_event_type_new();
|
|
|
|
ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
|
|
|
|
ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
|
|
|
|
ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
|
|
|
|
ECORE_FB_EVENT_MOUSE_WHEEL = ecore_event_type_new();
|
|
|
|
_ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
|
|
|
|
|
|
|
|
return _ecore_fb_init_count;
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Shuts down the Ecore_Fb library.
|
2004-08-23 15:59:00 -07:00
|
|
|
* @return @c The number of times the system has been initialised without
|
|
|
|
* being shut down.
|
|
|
|
* @ingroup Ecore_FB_Library_Group
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 10:26:37 -08:00
|
|
|
EAPI int
|
2003-09-23 01:09:32 -07:00
|
|
|
ecore_fb_shutdown(void)
|
|
|
|
{
|
2009-10-09 22:28:43 -07:00
|
|
|
if (--_ecore_fb_init_count != 0)
|
2010-09-18 20:25:15 -07:00
|
|
|
return _ecore_fb_init_count;
|
2009-10-09 22:28:43 -07:00
|
|
|
|
|
|
|
ecore_fb_vt_shutdown();
|
|
|
|
|
|
|
|
return _ecore_fb_init_count;
|
2003-09-23 01:09:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-07-15 06:43:15 -07:00
|
|
|
* Retrieves the width and height of the current frame buffer in pixels.
|
|
|
|
* @param w Pointer to an integer in which to store the width.
|
|
|
|
* @param h Pointer to an interge in which to store the height.
|
2003-09-23 01:09:32 -07:00
|
|
|
*/
|
2006-01-06 10:26:37 -08:00
|
|
|
EAPI void
|
2003-09-23 01:09:32 -07:00
|
|
|
ecore_fb_size_get(int *w, int *h)
|
|
|
|
{
|
|
|
|
if (w) *w = _ecore_fb_console_w;
|
|
|
|
if (h) *h = _ecore_fb_console_h;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_ecore_fb_size_get(int *w, int *h)
|
|
|
|
{
|
|
|
|
struct fb_var_screeninfo fb_var;
|
|
|
|
int fb;
|
|
|
|
|
|
|
|
fb = open("/dev/fb0", O_RDWR);
|
|
|
|
if (fb < 0)
|
|
|
|
{
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
|
|
|
|
{
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
2010-08-28 07:51:56 -07:00
|
|
|
close(fb);
|
2003-09-23 01:09:32 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
close(fb);
|
|
|
|
if (w) *w = fb_var.xres;
|
|
|
|
if (h) *h = fb_var.yres;
|
|
|
|
}
|