# define EAPI
#endif
-/**
- * @file
- * @brief Ecore frame buffer system functions.
- */
-
/* FIXME:
* maybe a new module?
* - code to get battery info
extern "C" {
#endif
-typedef struct _Ecore_Fb_Input_Device Ecore_Fb_Input_Device; /* an input device handler */
+/**
+ * @defgroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
+ *
+ * Functions used to set up and shut down the Ecore_Framebuffer functions.
+ *
+ * @{
+ */
+
+/**
+ * @typedef Ecore_Fb_Input_Device
+ * Input device handler.
+ */
+typedef struct _Ecore_Fb_Input_Device Ecore_Fb_Input_Device;
-/* device capabilities */
+/**
+ * @enum _Ecore_Fb_Input_Device_Cap
+ * Device capabilities.
+ */
enum _Ecore_Fb_Input_Device_Cap
{
ECORE_FB_INPUT_DEVICE_CAP_NONE = 0x00000000,
ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE = 0x00000002,
ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS = 0x00000004
};
+
+/**
+ * @typedef Ecore_Fb_Input_Device_Cap
+ * Device capabilities.
+ */
typedef enum _Ecore_Fb_Input_Device_Cap Ecore_Fb_Input_Device_Cap;
EAPI extern int ECORE_FB_EVENT_KEY_DOWN; /**< FB Key Down event */
typedef struct _Ecore_Fb_Event_Mouse_Move Ecore_Fb_Event_Mouse_Move; /**< FB Mouse Move event */
typedef struct _Ecore_Fb_Event_Mouse_Wheel Ecore_Fb_Event_Mouse_Wheel; /**< FB Mouse Wheel event */
-struct _Ecore_Fb_Event_Key_Down /** FB Key Down event */
+/**
+ * @struct _Ecore_Fb_Event_Key_Down
+ * Framebuffer Key Down event.
+ */
+struct _Ecore_Fb_Event_Key_Down
{
Ecore_Fb_Input_Device *dev; /**< The device associated with the event */
char *keyname; /**< The name of the key that was pressed */
char *keysymbol; /**< The logical symbol of the key that was pressed */
char *key_compose; /**< The UTF-8 string conversion if any */
};
-
-struct _Ecore_Fb_Event_Key_Up /** FB Key Up event */
+
+/**
+ * @struct _Ecore_Fb_Event_Key_Up
+ * Framebuffer Key Up event.
+ */
+struct _Ecore_Fb_Event_Key_Up
{
Ecore_Fb_Input_Device *dev; /**< The device associated with the event */
char *keyname; /**< The name of the key that was released */
char *keysymbol; /**< The logical symbol of the key that was pressed */
char *key_compose; /**< The UTF-8 string conversion if any */
};
-
-struct _Ecore_Fb_Event_Mouse_Button_Down /** FB Mouse Down event */
+
+/**
+ * @struct _Ecore_Fb_Event_Mouse_Button_Down
+ * Framebuffer Mouse Down event.
+ */
+struct _Ecore_Fb_Event_Mouse_Button_Down
{
Ecore_Fb_Input_Device *dev; /**< The device associated with the event */
int button; /**< Mouse button that was pressed (1 - 32) */
int double_click : 1; /**< Set if click was a double click */
int triple_click : 1; /**< Set if click was a triple click */
};
-
-struct _Ecore_Fb_Event_Mouse_Button_Up /** FB Mouse Up event */
+
+/**
+ * @struct _Ecore_Fb_Event_Mouse_Button_Up
+ * Framebuffer Mouse Up event.
+ */
+struct _Ecore_Fb_Event_Mouse_Button_Up
{
Ecore_Fb_Input_Device *dev; /**< The device associated with the event */
int button; /**< Mouse button that was released (1 - 32) */
int double_click : 1; /**< Set if click was a double click */
int triple_click : 1; /**< Set if click was a triple click */
};
-
-struct _Ecore_Fb_Event_Mouse_Move /** FB Mouse Move event */
+
+/**
+ * @struct _Ecore_Fb_Event_Mouse_Move
+ * Framebuffer Mouse Move event.
+ */
+struct _Ecore_Fb_Event_Mouse_Move
{
Ecore_Fb_Input_Device *dev; /**< The device associated with the event */
int x; /**< Mouse co-ordinates where the mouse cursor moved to */
int y; /**< Mouse co-ordinates where the mouse cursor moved to */
};
-
-struct _Ecore_Fb_Event_Mouse_Wheel /** FB Mouse Wheel event */
+
+/**
+ * @struct _Ecore_Fb_Event_Mouse_Wheel
+ * Framebuffer Mouse Wheel event.
+ */
+struct _Ecore_Fb_Event_Mouse_Wheel
{
Ecore_Fb_Input_Device *dev;
int x,y;
EAPI double ecore_fb_input_threshold_click_get(Ecore_Fb_Input_Device *dev);
/* ecore_fb.c */
+
EAPI int ecore_fb_init(const char *name);
EAPI int ecore_fb_shutdown(void);
-EAPI void ecore_fb_size_get(int *w, int *h);
+EAPI void ecore_fb_size_get(int *w, int *h);
EAPI void ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap);
EAPI void ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap);
-
+
+/**
+ * @}
+ */
+
#ifdef __cplusplus
}
#endif
static int _ecore_fb_console_h = 0;
/**
- * @defgroup Ecore_FB_Library_Group Framebuffer Library Functions
+ * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
*
- * Functions used to set up and shut down the Ecore_Framebuffer functions.
+ * @{
*/
/**
- * Sets up the Ecore_Fb 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_FB_Library_Group
+ * @brief Initialize the Ecore_Fb library.
+ *
+ * @param name Device target name.
+ * @return 1 or greater on success, 0 on error.
+ *
+ * This function sets up all the Ecore_Fb library. It returns 0 on
+ * failure, otherwise it returns the number of times it has already
+ * been called.
+ *
+ * When Ecore_Fb is not used anymore, call ecore_fb_shutdown() to shut down
+ * the Ecore_Fb library.
*/
EAPI int
ecore_fb_init(const char *name __UNUSED__)
}
/**
- * Shuts down the Ecore_Fb library.
- * @return @c The number of times the system has been initialised without
- * being shut down.
- * @ingroup Ecore_FB_Library_Group
+ * @brief Shut down the Ecore_Fb library.
+ *
+ * @return 0 when the library is completely shut down, 1 or
+ * greater otherwise.
+ *
+ * This function shuts down the Ecore_Fb library. It returns 0 when it has
+ * been called the same number of times than ecore_fb_init().
*/
EAPI int
ecore_fb_shutdown(void)
/**
- * Retrieves the width and height of the current frame buffer in pixels.
+ * @brief Retrieve 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.
+ *
+ * This function retrieves the size of the current frame buffer in
+ * pixels. @p w and @p h can be buffers that will be filled with the
+ * corresponding values. If one of them is @c NULL, nothing will be
+ * done for that parameter.
*/
EAPI void
ecore_fb_size_get(int *w, int *h)
if (w) *w = fb_var.xres;
if (h) *h = fb_var.yres;
}
+
+/**
+ * @}
+ */
else long_has_neither_32_nor_64_bits();
}
-static void
+static void
_ecore_fb_li_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);
free(e);
}
-static void
+static void
_ecore_fb_li_event_free_key_up(void *data __UNUSED__, void *ev)
{
Ecore_Fb_Event_Key_Up *e;
-
+
e = ev;
free(e->keyname);
if (e->keysymbol) free(e->keysymbol);
_ecore_fb_li_device_event_key(Ecore_Fb_Input_Device *dev, struct input_event *iev)
{
if (!dev->listen) return;
-
+
/* check for basic keyboard keys */
if ((iev->code >= KEY_ESC) && (iev->code <= KEY_COMPOSE))
{
{
int offset = 0;
Ecore_Fb_Event_Key_Down *ev;
-
+
ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Down));
if (dev->keyboard.shift) offset = 1;
else if (dev->keyboard.lock) offset = 2;
ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]);
-
+
ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]);
ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]);
ev->dev = dev;
{
int offset = 0;
Ecore_Fb_Event_Key_Up *ev;
-
+
ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Up));
if (dev->keyboard.shift) offset = 1;
else if (dev->keyboard.lock) offset = 2;
ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]);
-
+
ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]);
ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]);
ev->dev = dev;
else if ((iev->code >= BTN_MOUSE) && (iev->code < BTN_JOYSTICK))
{
int button;
-
+
button = ((iev->code & 0x00F) + 1);
if (iev->value)
{
Ecore_Fb_Event_Mouse_Button_Down *ev;
double current;
-
+
ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down));
ev->dev = dev;
ev->button = button;
ev->x = dev->mouse.x;
ev->y = dev->mouse.y;
-
+
current = ecore_time_get();
if ((current - dev->mouse.prev) <= dev->mouse.threshold)
ev->double_click = 1;
else
{
Ecore_Fb_Event_Mouse_Button_Up *ev;
-
+
ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Button_Up));
ev->dev = dev;
ev->button = button;
ev->x = dev->mouse.x;
ev->y = dev->mouse.y;
ev->dev = dev;
-
+
ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE,ev,NULL,NULL);
break;
}
{
Ecore_Fb_Event_Mouse_Wheel *ev;
ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Wheel));
-
+
ev->x = dev->mouse.x;
ev->y = dev->mouse.y;
if (iev->code == REL_HWHEEL) ev->direction = 1;
{
static int prev_pressure = 0;
int pressure;
-
+
if (!dev->listen) return;
switch (iev->code)
{
if (dev->mouse.w != 0)
{
int tmp;
-
+
tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w);
if (tmp < 0) dev->mouse.x = 0;
else if (tmp > dev->mouse.w) dev->mouse.x = dev->mouse.w;
dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE;
}
break;
-
+
case ABS_Y:
if(dev->mouse.h != 0)
{
int tmp;
-
+
tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h);
if (tmp < 0) dev->mouse.y = 0;
else if (tmp > dev->mouse.h) dev->mouse.y = dev->mouse.h;
dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE;
}
break;
-
+
case ABS_PRESSURE:
pressure = iev->value;
if ((pressure) && (!prev_pressure))
_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev __UNUSED__)
{
if (!dev->listen) return;
-
+
if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_MOVE)
{
Ecore_Fb_Event_Mouse_Move *ev;
struct input_event ev[64];
int len;
int i;
-
+
dev = (Ecore_Fb_Input_Device*)data;
/* read up to 64 events at once */
len = read(dev->fd, &ev, sizeof(ev));
return EINA_TRUE;
}
-/**
- * @brief Sets the listen mode for an input device
- * @param dev The device to set the mode of
- * @param listen The mode of listening (EINA_FALSE for off, EINA_TRUE for on)
- * This enables or disables listening on an input device.
+/**
+ * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions.
+ *
+ * @{
+ */
+
+/**
+ * @brief Set the listen mode for an input device .
+ *
+ * @param dev The device to set the mode of.
+ * @param listen EINA_FALSE to disable listening mode, EINA_TRUE to enable it.
+ *
+ * This function enables or disables listening on the input device @p
+ * dev. If @p listen is #EINA_FALSE, listening mode is disabled, if it
+ * is #EINA_TRUE, it is enabled.
*/
-EAPI void
+EAPI void
ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, Eina_Bool listen)
{
if (!dev) return;
/* if the device already had a handler */
if (!dev->handler)
dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL);
-
+
}
dev->listen = listen;
}
# define EV_CNT (EV_MAX+1)
#endif
-/*
- * @brief Opens an input device
- * @param dev The device to open
- * @return The @ref Ecore_Fb_Input_Device object that has been opened
- * This opens an input device and returns the object for it, or returns NULL on failure.
+/**
+ * @brief Open an input device.
+ *
+ * @param dev The device to open.
+ * @return The @ref Ecore_Fb_Input_Device object that has been opened.
+ *
+ * This function opens the input device named @p dev and returns the
+ * object for it, or returns @c NULL on failure.
*/
EAPI Ecore_Fb_Input_Device *
ecore_fb_input_device_open(const char *dev)
unsigned long event_type_bitmask[EV_CNT / 32 + 1];
int event_type;
int fd;
-
+
if (!dev) return NULL;
device = calloc(1, sizeof(Ecore_Fb_Input_Device));
if (!device) return NULL;
-
+
if ((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0)
{
fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno));
device->info.dev = strdup(dev);
/* common */
device->mouse.threshold = CLICK_THRESHOLD_DEFAULT;
-
+
/* set info */
for (event_type = 0; event_type < EV_MAX; event_type++)
{
}
_ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device);
return device;
-
+
error_caps:
close(fd);
error_open:
return NULL;
}
+/**
+ * @brief Close the given device.
+ *
+ * @param dev The device to close
+ *
+ * This function closes the device @p dev. If @p dev is @c NULL, this
+ * function does nothing.
+ */
EAPI void
ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev)
{
+ if (!fd) return;
/* close the fd */
close(dev->fd);
/* remove the element from the list */
}
-/*
- * If the device is a relative input device,
- * we must set a width and height for it. If its
- * absolute set the ioctl correctly, if not, unsupported
- * device
+/**
+ * @brief Set the axis size of the given device.
+ *
+ * @param dev The device to set the axis size to.
+ * @param w The width of the axis.
+ * @param h The height of the axis.
+ *
+ * This function sets set the width @p w and height @p h of the axis
+ * of device @p dev. If @p dev is a relative input device, a width and
+ * height must set for it. If its absolute set the ioctl correctly, if
+ * not, unsupported device.
*/
EAPI void
ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h)
{
if (!dev) return;
if ((w < 0) || (h < 0)) return;
- /* FIXME
- * this code is for a touchscreen device,
+ /* FIXME
+ * this code is for a touchscreen device,
* make it configurable (ABSOLUTE | RELATIVE)
*/
if (dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)
{
/* FIXME looks like some kernels dont include this struct */
struct input_absinfo abs_features;
-
+
ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features);
dev->mouse.min_w = abs_features.minimum;
dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w);
-
+
ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features);
dev->mouse.min_h = abs_features.minimum;
dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h);
}
else if (!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE))
return;
-
+
/* update the local values */
if (dev->mouse.x > w - 1) dev->mouse.x = w -1;
if (dev->mouse.y > h - 1) dev->mouse.y = h -1;
dev->mouse.h = h;
}
-
+/**
+ * @brief Retrieve the name of the given device.
+ *
+ * @param dev The device to get the name from.
+ * @return The name of the device.
+ *
+ * This function returns the name of the device @p dev. If @p dev is
+ * @c NULL, this function returns @c NULL.
+ */
EAPI const char *
ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev)
{
return dev->info.name;
}
+/**
+ * @brief Retrieve the capability of the given device.
+ *
+ * @param dev The device to get the name from.
+ * @return The capability of the device.
+ *
+ * This function returns the capability of the device @p dev. If @p dev is
+ * @c NULL, this function returns #ECORE_FB_INPUT_DEVICE_CAP_NONE.
+ */
EAPI Ecore_Fb_Input_Device_Cap
ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev)
{
return dev->info.cap;
}
+/**
+ * @brief Set the threshold of mouse clicks of the given device.
+ *
+ * @param dev The device to set the threshodl mouse click to.
+ * @param threshold The threshold value.
+ *
+ * This function sets the threshold of mouse clicks of the device
+ * @p dev to @p threshold. If @p dev is @c NULL, this function does
+ * nothing.
+ */
EAPI void
ecore_fb_input_device_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold)
{
dev->mouse.threshold = threshold;
}
+/**
+ * @brief Get the threshold of mouse clicks of the given device.
+ *
+ * @param dev The device to set the threshodl mouse click from.
+ * @return The threshold value.
+ *
+ * This function returns the threshold of mouse clicks of the device
+ * @p dev. If @p dev is @c NULL, this function returns 0.0.
+ */
EAPI double
ecore_fb_input_device_threshold_click_get(Ecore_Fb_Input_Device *dev)
{
if (!dev) return 0;
return dev->mouse.threshold;
}
+
+/**
+ * @}
+ */