6 #include "ecore_fb_private.h"
8 static void _ecore_fb_size_get(int *w, int *h);
10 EAPI int ECORE_FB_EVENT_KEY_DOWN = 0;
11 EAPI int ECORE_FB_EVENT_KEY_UP = 0;
12 EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = 0;
13 EAPI int ECORE_FB_EVENT_MOUSE_BUTTON_UP = 0;
14 EAPI int ECORE_FB_EVENT_MOUSE_MOVE = 0;
15 EAPI int ECORE_FB_EVENT_MOUSE_WHEEL = 0;
17 static int _ecore_fb_init_count = 0;
18 static int _ecore_fb_console_w = 0;
19 static int _ecore_fb_console_h = 0;
22 * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
28 * @brief Initialize the Ecore_Fb library.
30 * @param name Device target name.
31 * @return 1 or greater on success, 0 on error.
33 * This function sets up all the Ecore_Fb library. It returns 0 on
34 * failure, otherwise it returns the number of times it has already
37 * When Ecore_Fb is not used anymore, call ecore_fb_shutdown() to shut down
38 * the Ecore_Fb library.
41 ecore_fb_init(const char *name __UNUSED__)
43 if (++_ecore_fb_init_count != 1)
44 return _ecore_fb_init_count;
46 if (!ecore_fb_vt_init())
47 return --_ecore_fb_init_count;
49 ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new();
50 ECORE_FB_EVENT_KEY_UP = ecore_event_type_new();
51 ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
52 ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
53 ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
54 ECORE_FB_EVENT_MOUSE_WHEEL = ecore_event_type_new();
55 _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
57 return _ecore_fb_init_count;
61 * @brief Shut down the Ecore_Fb library.
63 * @return 0 when the library is completely shut down, 1 or
66 * This function shuts down the Ecore_Fb library. It returns 0 when it has
67 * been called the same number of times than ecore_fb_init().
70 ecore_fb_shutdown(void)
72 if (--_ecore_fb_init_count != 0)
73 return _ecore_fb_init_count;
75 ecore_fb_vt_shutdown();
77 return _ecore_fb_init_count;
82 * @brief Retrieve the width and height of the current frame buffer in
85 * @param w Pointer to an integer in which to store the width.
86 * @param h Pointer to an interge in which to store the height.
88 * This function retrieves the size of the current frame buffer in
89 * pixels. @p w and @p h can be buffers that will be filled with the
90 * corresponding values. If one of them is @c NULL, nothing will be
91 * done for that parameter.
94 ecore_fb_size_get(int *w, int *h)
96 if (w) *w = _ecore_fb_console_w;
97 if (h) *h = _ecore_fb_console_h;
101 _ecore_fb_size_get(int *w, int *h)
103 struct fb_var_screeninfo fb_var;
106 fb = open("/dev/fb0", O_RDWR);
113 if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1)
121 if (w) *w = fb_var.xres;
122 if (h) *h = fb_var.yres;