static void
_e_comp_wl_device_renew_axis(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
{
+ if (idx >= e_input_touch_max_count_get()) return;
+
_e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_X, radius_x);
e_devicemgr->multi[idx].radius_x = radius_x;
_e_comp_wl_device_send_axis(dev_name, dev_class, ec, TIZEN_INPUT_DEVICE_AXIS_TYPE_RADIUS_Y, radius_y);
static void
_e_comp_wl_device_handle_axes(const char *dev_name, Evas_Device_Class dev_class, E_Client *ec, unsigned int idx, double radius_x, double radius_y, double pressure, double angle)
{
- if (idx >= E_COMP_WL_TOUCH_MAX) return;
+ if (idx >= e_input_touch_max_count_get()) return;
if (e_devicemgr->multi[idx].radius_x != radius_x)
{
#include <tbm_surface.h>
-#define E_COMP_WL_TOUCH_MAX 10
-
typedef struct _E_Comp_Wl_Aux_Hint E_Comp_Wl_Aux_Hint;
typedef struct _E_Comp_Wl_Buffer E_Comp_Wl_Buffer;
typedef struct _E_Comp_Wl_Buffer_Ref E_Comp_Wl_Buffer_Ref;
E_CONFIG_VAL(D, T, fake_output_resolution.w, INT);
E_CONFIG_VAL(D, T, fake_output_resolution.h, INT);
E_CONFIG_VAL(D, T, raise_before_show, UCHAR);
+ E_CONFIG_VAL(D, T, configured_max_touch.use, UCHAR);
+ E_CONFIG_VAL(D, T, configured_max_touch.count, UINT);
}
static Eina_Bool
E_CONFIG_LIMIT(e_config->desk_zoom_effect.duration, 0.0, 10.0);
E_CONFIG_LIMIT(e_config->fake_output_resolution.use, 0, 1);
E_CONFIG_LIMIT(e_config->raise_before_show, 0, 1);
+ E_CONFIG_LIMIT(e_config->configured_max_touch.use, 0, 1);
+ // FIXME : What's the proper maximum value for 'configured_max_touch.count' ?
+ E_CONFIG_LIMIT(e_config->configured_max_touch.count, 1, 20);
}
E_API int
int h; // height of the configured output resolution.
} configured_output_resolution;
+ // Configured for maximum touch count
+ struct
+ {
+ unsigned char use; // use the configured maximum touch count
+ int count; // value of the configured maximum touch count
+ } configured_max_touch;
+
//specific global object( client not to bind )
struct
{
E_Devicemgr_Input_Device *last_device_ptr;
E_Devicemgr_Input_Device *last_device_touch;
E_Devicemgr_Input_Device *last_device_kbd;
- E_Devicemgr_Input_Device_Multi multi[E_COMP_WL_TOUCH_MAX];
+ E_Devicemgr_Input_Device_Multi *multi;
struct
{
e_devicemgr->last_device_ptr = dev;
if (!e_devicemgr->last_device_touch && dev->clas == ECORE_DEVICE_CLASS_TOUCH)
- e_devicemgr->last_device_touch = dev;
+ {
+ e_devicemgr->last_device_touch = dev;
+
+ if (e_devicemgr->multi)
+ {
+ ELOGF("DEVMGR_TOUCH", "Multi pointer is NOT NULL. It'll be updated.\n", NULL);
+ free (e_devicemgr->multi);
+ }
+
+ e_devicemgr->multi = calloc(1, sizeof(E_Devicemgr_Input_Device_Multi)*e_input_touch_max_count_get());
+
+ if (!e_devicemgr->multi)
+ ELOGF("DEVMGR_TOUCH", "Failed to allocate memory for multi ptr. (finger=%d)\n", NULL, e_input_touch_max_count_get());
+ }
if (!e_devicemgr->last_device_kbd && dev->clas == ECORE_DEVICE_CLASS_KEYBOARD)
e_devicemgr->last_device_kbd = dev;
e_devicemgr_destroy_virtual_device(e_devicemgr->virtual_mouse_device_fd);
e_devicemgr->virtual_mouse_device_fd = -1;
}
+
+ if (e_devicemgr->multi)
+ free(e_devicemgr->multi);
}
device->touch.pressed &= ~(1 << i);
}
i++;
- if (i >= INPUTGEN_MAX_TOUCH) break;
+ if (i >= e_input_touch_max_count_get()) break;
+ }
+ if (device->touch.coords)
+ {
+ free(device->touch.coords);
+ device->touch.coords = NULL;
+ }
+ if (device->touch.axis)
+ {
+ free(device->touch.axis);
+ device->touch.axis = NULL;
}
break;
case ECORE_DEVICE_CLASS_MOUSE:
return EINA_FALSE;
}
+static Eina_Bool
+_e_devicemgr_init_touch_coords_and_axis(E_Devicemgr_Inputgen_Device_Data *device)
+{
+ if (device->touch.coords)
+ free(device->touch.coords);
+
+ device->touch.coords = calloc(1, sizeof(E_Devicemgr_Coords)*e_input_touch_max_count_get());
+ if (!device->touch.coords)
+ {
+ DMWRN("Failed to allocate memory for coords ptr ! (finger=%d)\n", e_input_touch_max_count_get());
+ return EINA_FALSE;
+ }
+
+ if (device->touch.axis)
+ free(device->touch.axis);
+
+ device->touch.axis = calloc(1, sizeof(E_Devicemgr_Inputgen_Touch_Axis)*e_input_touch_max_count_get());
+ if (!device->touch.axis)
+ {
+ DMWRN("Failed to allocate memory for axis ptr ! (finger=%d)\n", e_input_touch_max_count_get());
+ free(device->touch.coords);
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+}
+
int
_e_devicemgr_inputgen_create_device(Ecore_Device_Class clas, struct wl_client *client, const char *device_name)
{
device->uinp_fd = uinp_fd;
*dev_list = eina_list_append(*dev_list, device);
- for (i = 0; i < INPUTGEN_MAX_TOUCH; i++)
+ if (!_e_devicemgr_init_touch_coords_and_axis(device))
+ {
+ DMERR("DEVMGR_TOUCH Failed to init touch coords and axis !\n");
+ goto fail_create_device;
+ }
+
+ for (i = 0; i < e_input_touch_max_count_get(); i++)
{
device->touch.coords[i].x = -1;
device->touch.coords[i].y = -1;
name = _e_devicemgr_inputgen_name_get(resource);
- if (finger >= INPUTGEN_MAX_TOUCH)
+ if (finger >= e_input_touch_max_count_get())
{
DMWRN("Invalid fingers: %d\n", finger);
return TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER;
uinp.absmin[ABS_Y] = 0;
uinp.absmax[ABS_Y] = 1000;
uinp.absmin[ABS_MT_SLOT] = 0;
- uinp.absmax[ABS_MT_SLOT] = INPUTGEN_MAX_TOUCH - 1;
+ uinp.absmax[ABS_MT_SLOT] = e_input_touch_max_count_get() - 1;
uinp.absmin[ABS_MT_TOUCH_MAJOR] = 0;
uinp.absmax[ABS_MT_TOUCH_MAJOR] = 255;
uinp.absmin[ABS_MT_TOUCH_MINOR] = 0;
#define INPUT_GENERATOR_DEVICE "Input Generator"
#define DETENT_DEVICE_NAME "tizen_detent"
-#define INPUTGEN_MAX_TOUCH 10
#define INPUTGEN_MAX_BTN 16
typedef struct _E_Devicemgr_Input_Device_User_Data E_Devicemgr_Input_Device_User_Data;
struct
{
unsigned int pressed;
- E_Devicemgr_Coords coords[INPUTGEN_MAX_TOUCH];
- E_Devicemgr_Inputgen_Touch_Axis axis[INPUTGEN_MAX_TOUCH];
+ E_Devicemgr_Coords *coords;
+ E_Devicemgr_Inputgen_Touch_Axis *axis;
E_Devicemgr_Inputgen_Touch_Axis axis_tmp;
} touch;
struct
{
E_Output *output;
int w = 0, h = 0;
+ int max_mt_slot = 9;//set touch max count 10 by default
output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
e_output_size_get(output, &w, &h);
if (w <= 0) w = 4096;
if (h <= 0) h = 4096;
+ if (e_config->configured_max_touch.use)
+ {
+ max_mt_slot = e_input_touch_max_count_get() - 1;
+
+ if (max_mt_slot < 0)
+ max_mt_slot = 9;//set touch max count 10 by default
+ }
+
ioctl(uinput_fd, UI_SET_EVBIT, EV_ABS);
ioctl(uinput_fd, UI_SET_KEYBIT, BTN_TOUCH);
uinput_dev->absmin[ABS_Y] = 0;
uinput_dev->absmax[ABS_Y] = h - 1;
uinput_dev->absmin[ABS_MT_SLOT] = 0;
- uinput_dev->absmax[ABS_MT_SLOT] = 9;
+ uinput_dev->absmax[ABS_MT_SLOT] = max_mt_slot;
uinput_dev->absmin[ABS_MT_TOUCH_MAJOR] = 0;
uinput_dev->absmax[ABS_MT_TOUCH_MAJOR] = 255;
uinput_dev->absmin[ABS_MT_TOUCH_MINOR] = 0;
e_input->input_base_dir = eina_stringshare_add("/dev/input");
e_input->use_thread = EINA_FALSE;
+ e_input->touch_device_count = 0;
+ e_input->touch_max_count = 1;//This is going to updated when a touch device is attached.
+
dev = e_input_device_open();
e_input->ee = ee;
if (ei) return ei->ee;
return NULL;
}
+
+E_API unsigned int
+e_input_touch_max_count_get()
+{
+ if (e_input)
+ return e_input->touch_max_count;
+ else
+ return 0;
+}
\ No newline at end of file
typedef struct _E_Input_Backend E_Input_Backend;
typedef struct _E_Input_Evdev E_Input_Evdev;
typedef struct _E_Input_Seat E_Input_Seat;
+typedef struct _E_Input_Coord E_Input_Coord;
struct _E_Input
{
Eina_List *handlers;
Eina_Bool use_thread : 1;
+ unsigned int touch_max_count;
+ unsigned int touch_device_count;
};
struct _E_Input_Device
E_API unsigned int e_input_device_touch_pressed_get(E_Input_Device *dev);
E_API Eina_Bool e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_keys, int num);
+E_API unsigned int e_input_touch_max_count_get();
+
EINTERN Eina_Bool e_input_device_block(E_Input_Device *dev, unsigned int type, void *client);
EINTERN Eina_Bool e_input_device_unblock(E_Input_Device *dev, void *client);
}
static void
+_device_touch_count_update(E_Input_Evdev *edev)
+{
+ unsigned int device_touch_count = 0;
+ static unsigned int _max_device_touch_count = 0;
+
+ E_Input *ei = e_input_get();
+ EINA_SAFETY_ON_NULL_RETURN(ei);
+
+ device_touch_count = libinput_device_touch_get_touch_count(edev->device);
+
+ if (_max_device_touch_count < device_touch_count)
+ _max_device_touch_count = device_touch_count;
+
+ if (e_config->configured_max_touch.use)
+ {
+ if (_max_device_touch_count > 0 && e_config->configured_max_touch.count > _max_device_touch_count)
+ {
+ ELOGF("E_INPUT_EVDEV_TOUCH", "Touch max count(%d) must be less or equal to device's touch count(%d) !\nTouch max count has been shrinken to %d.\n",
+ NULL, e_config->configured_max_touch.count, _max_device_touch_count, _max_device_touch_count);
+ ei->touch_max_count = _max_device_touch_count;
+ }
+ else
+ {
+ if (ei->touch_max_count != e_config->configured_max_touch.count)
+ {
+ ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n",
+ NULL, ei->touch_max_count, e_config->configured_max_touch.count);
+ ei->touch_max_count = e_config->configured_max_touch.count;
+ }
+ }
+ }
+ else
+ {
+ if (ei->touch_max_count < _max_device_touch_count)
+ {
+ ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n", NULL,
+ ei->touch_max_count, _max_device_touch_count);
+ ei->touch_max_count = _max_device_touch_count;
+ }
+ }
+
+ ei->touch_device_count++;
+ ELOGF("E_INPUT_EVDEV_TOUCH", "Touch device count is %d.\n", NULL, ei->touch_device_count);
+}
+
+static void
_device_configure(E_Input_Evdev *edev)
{
if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
}
}
- if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+ if (edev->mt_slot < e_input_touch_max_count_get())
{
edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
}
}
- if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+ if (edev->mt_slot < e_input_touch_max_count_get())
{
edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
}
}
- if (edev->mt_slot < E_INPUT_MAX_SLOTS)
+ if (edev->mt_slot < e_input_touch_max_count_get())
{
edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
edev->touch.coords[edev->mt_slot].x;
{
libinput_device_touch_set_aux_data(device, palm_code);
}
+
+ _device_touch_count_update(edev);
+
+ edev->touch.coords = calloc(1, sizeof(E_Input_Coord)*e_input_touch_max_count_get());
+
+ if (!edev->touch.coords)
+ ERR("Failed to allocate memory for touch coords !\n");
}
libinput_device_set_user_data(device, edev);
if (edev->path) eina_stringshare_del(edev->path);
if (edev->device) libinput_device_unref(edev->device);
if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
+ if (edev->touch.coords)
+ {
+ free(edev->touch.coords);
+ edev->touch.coords = NULL;
+ }
free(edev);
}
#define E_INPUT_ENV_LIBINPUT_LOG_DISABLE "E_INPUT_LIBINPUT_LOG_DISABLE"
#define E_INPUT_ENV_LIBINPUT_LOG_EINA_LOG "E_INPUT_LIBINPUT_LOG_EINA_LOG"
-#define E_INPUT_MAX_SLOTS 10
+struct _E_Input_Coord
+{
+ int x;
+ int y;
+};
struct _E_Input_Seat
{
int x, y;
int w, h;
} transform;
- struct
- {
- int x;
- int y;
- } coords[E_INPUT_MAX_SLOTS];
+ E_Input_Coord *coords;
unsigned int pressed;
unsigned int raw_pressed;
Eina_Bool blocked;