x input dev config - go direct to drivers not button mappings

unless. its an old evdev only etc. system - synaptics and libnput can
do thison their own. it's a bit of a mess, but it works.
This commit is contained in:
Carsten Haitzler 2020-11-15 16:19:08 +00:00
parent 0b797a68a7
commit 0bf06c5e1e
7 changed files with 123 additions and 90 deletions

View File

@ -143,7 +143,9 @@ group "E_Config" struct {
value "mouse_natural_scroll" uchar: 0;
value "mouse_emulate_middle_button" uchar: 1;
value "touch_clickpad" uchar: 1;
value "touch_scrolling_mode" uchar: 0;
value "touch_scrolling_2finger" uchar: 1;
value "touch_scrolling_edge" uchar: 1;
value "touch_scrolling_circular" uchar: 0;
value "touch_scrolling_horiz" uchar: 1;
value "touch_palm_detect" uchar: 1;
value "border_raise_on_mouse_action" int: 1;

View File

@ -141,7 +141,9 @@ group "E_Config" struct {
value "mouse_natural_scroll" uchar: 0;
value "mouse_emulate_middle_button" uchar: 1;
value "touch_clickpad" uchar: 1;
value "touch_scrolling_mode" uchar: 0;
value "touch_scrolling_2finger" uchar: 1;
value "touch_scrolling_edge" uchar: 1;
value "touch_scrolling_circular" uchar: 0;
value "touch_scrolling_horiz" uchar: 1;
value "touch_palm_detect" uchar: 1;
value "border_raise_on_mouse_action" int: 1;

View File

@ -141,7 +141,9 @@ group "E_Config" struct {
value "mouse_natural_scroll" uchar: 0;
value "mouse_emulate_middle_button" uchar: 1;
value "touch_clickpad" uchar: 1;
value "touch_scrolling_mode" uchar: 0;
value "touch_scrolling_2finger" uchar: 1;
value "touch_scrolling_edge" uchar: 1;
value "touch_scrolling_circular" uchar: 0;
value "touch_scrolling_horiz" uchar: 1;
value "touch_palm_detect" uchar: 1;
value "border_raise_on_mouse_action" int: 1;

View File

@ -72,41 +72,35 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
}
else if (!strcmp(prop, "libinput Scroll Method Enabled"))
{
unsigned char cfval = 0;
Eina_Bool doit = EINA_TRUE;
if (e_config->touch_scrolling_mode == 0) cfval = 1;
else if (e_config->touch_scrolling_mode == 1) cfval = 0;
else if (e_config->touch_scrolling_mode == 2) cfval = 1;
// 3 bool, 2 finger, edge, button
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, "libinput Scroll Methods Available", &num, &fmt, &size);
if ((val) && (size == 8) && (num == 3))
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num >= 3) &&
((e_config->touch_scrolling_2finger != val[0]) ||
(e_config->touch_scrolling_edge != val[1])))
{
if (!val[cfval]) doit = EINA_FALSE;
val[0] = e_config->touch_scrolling_2finger;
val[1] = e_config->touch_scrolling_edge;
printf("DEV: change [%s] [%s] -> %i %i %i\n", dev, prop, val[0], val[1], val[2]);
ecore_x_input_device_property_set
(dev_slot, prop, val, num, fmt, size);
}
free(val);
}
else if (!strcmp(prop, "libinput Natural Scrolling Enabled"))
{
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num == 1) &&
(e_config->mouse_natural_scroll) != (val[0]))
{
val[0] = e_config->mouse_natural_scroll;
printf("DEV: change [%s] [%s] -> %i\n", dev, prop, val[0]);
ecore_x_input_device_property_set
(dev_slot, prop, val, num, fmt, size);
}
free(val);
if (doit)
{
// 1 bool, 0=2-finger, 1=edge, 2=button
val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num == 1) &&
(cfval) != (val[0]))
{
val[0] = cfval;
printf("DEV: change [%s] [%s] -> %i\n", dev, prop, val[0]);
ecore_x_input_device_property_set
(dev_slot, prop, val, num, fmt, size);
}
free(val);
}
}
// do via button mapping for now - not sure about this evdev can't do this
// else if (!strcmp(prop, "libinput Natural Scrolling Enabled"))
// {
// // 1 bool
// }
// not for now - default
// else if (!strcmp(prop, "libinput Accel Profile Enabled"))
// {
@ -116,17 +110,13 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
// else if (!strcmp(prop, "libinput Left Handed Enabled"))
// {
// // 1 bool
// }
// do via button mapping for now - not sure about this evdev can't do this
// else if (!strcmp(prop, "libinput Natural Scrolling Enabled"))
// {
// // 1 bool
// }
///////////////////////////////////////////////////////////////////////////
// synaptics devices
else if (!strcmp(prop, "Synaptics Middle Button Timeout"))
{
// 1 int - in ms
unsigned int *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 32) && (num == 1) &&
@ -196,6 +186,7 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
}
else if (!strcmp(prop, "Synaptics ClickPad"))
{
// 1 bool
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num == 1) &&
@ -214,12 +205,12 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num >= 2) &&
(((e_config->touch_scrolling_mode == 0) &&
(((e_config->touch_scrolling_edge) &&
((!val[0]) || (val[1] != e_config->touch_scrolling_horiz))) ||
((e_config->touch_scrolling_mode != 0) &&
((!e_config->touch_scrolling_edge) &&
((val[0]) || (val[1])))))
{
if (e_config->touch_scrolling_mode == 0)
if (e_config->touch_scrolling_edge)
{
val[0] = 1;
val[1] = e_config->touch_scrolling_horiz;
@ -241,12 +232,12 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num >= 2) &&
(((e_config->touch_scrolling_mode == 1) &&
(((e_config->touch_scrolling_2finger) &&
((!val[0]) || (val[1] != e_config->touch_scrolling_horiz))) ||
((e_config->touch_scrolling_mode != 1) &&
((!e_config->touch_scrolling_2finger) &&
((val[0]) || (val[1])))))
{
if (e_config->touch_scrolling_mode == 1)
if (e_config->touch_scrolling_2finger)
{
val[0] = 1;
val[1] = e_config->touch_scrolling_horiz;
@ -268,15 +259,9 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
unsigned char *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 8) && (num == 1) &&
(((e_config->touch_scrolling_mode == 2) &&
(!val[0])) ||
((e_config->touch_scrolling_mode != 2) &&
(val[0]))))
(e_config->touch_scrolling_circular != val[0]))
{
if (e_config->touch_scrolling_mode == 2)
val[0] = 1;
else
val[0] = 0;
val[0] = e_config->touch_scrolling_circular;
printf("DEV: change [%s] [%s] -> %i\n", dev, prop, val[0]);
ecore_x_input_device_property_set
(dev_slot, prop, val, num, fmt, size);
@ -298,6 +283,31 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
}
free(val);
}
else if (!strcmp(prop, "Synaptics Scrolling Distance"))
{
// 2 ints v, h - invert them for natural (negative)
int *val = ecore_x_input_device_property_get
(dev_slot, prop, &num, &fmt, &size);
if ((val) && (size == 32) && (num == 2) &&
(((e_config->mouse_natural_scroll && ((val[0] > 0) || (val[1] > 0)))) ||
((!e_config->mouse_natural_scroll && ((val[0] < 0) || (val[1] < 0))))))
{
if (e_config->mouse_natural_scroll)
{
if (val[0] > 0) val[0] = -val[0];
if (val[1] > 0) val[1] = -val[1];
}
else
{
if (val[0] < 0) val[0] = -val[0];
if (val[1] < 0) val[1] = -val[1];
}
printf("DEV: change [%s] [%s] -> %i %i\n", dev, prop, val[0], val[1]);
ecore_x_input_device_property_set
(dev_slot, prop, val, num, fmt, size);
}
free(val);
}
// else if (!strcmp(prop, "Synaptics Off"))
// {
// // 8 bit 0 = on, 1 = off (except physical clicks), 2 =
@ -338,11 +348,10 @@ _handle_dev_prop(int dev_slot, const char *dev, const char *prop)
E_API void
e_comp_x_devices_config_apply(void)
{
// XXX: configure devices based on settings
// list devices - for each device, check properties
// if property does not match the config, set it to
// config val
int num_devs, i;
Eina_Bool driver_evdev = EINA_FALSE;
Eina_Bool driver_libinput = EINA_FALSE;
Eina_Bool driver_synaptics = EINA_FALSE;
num_devs = ecore_x_input_device_num_get();
printf("DEV: CHANGES ... have %i devices\n", num_devs);
@ -360,6 +369,12 @@ e_comp_x_devices_config_apply(void)
for (j = 0; j < num_props; j++)
{
// printf("DEV: PROP=%i: [%s]\n", j, props[j]);
if ((!driver_evdev) && (!strncmp(props[j], "Evdev ", 6)))
driver_evdev = EINA_TRUE;
else if ((!driver_libinput) && (!strncmp(props[j], "libinput ", 9)))
driver_libinput = EINA_TRUE;
else if ((!driver_synaptics) && (!strncmp(props[j], "Synaptics ", 10)))
driver_synaptics = EINA_TRUE;
_handle_dev_prop(i, name, props[j]);
}
ecore_x_input_device_properties_free(props, num_props);
@ -386,21 +401,12 @@ e_comp_x_devices_config_apply(void)
{
if (!map[n]) break;
}
if (n < 12)
if (n < 3)
{
map[0] = 1;
map[1] = 2;
map[2] = 3;
map[3] = 4;
map[4] = 5;
map[5] = 6;
map[6] = 7;
map[7] = 8;
map[8] = 9;
map[9] = 10;
map[10] = 11;
map[11] = 12;
n = 12;
n = 3;
}
if (e_config->mouse_hand == E_MOUSE_HAND_RIGHT)
{
@ -412,16 +418,20 @@ e_comp_x_devices_config_apply(void)
map[0] = 3;
map[2] = 1;
}
if (e_config->mouse_natural_scroll)
// if we are not on libinput or synaptics drivers anywehre then
// swap buttons the old fashioned way
if ((n >= 5) && (!driver_libinput) && (!driver_synaptics))
{
map[3] = 5;
map[4] = 4;
}
else
{
map[3] = 4;
map[4] = 5;
if (e_config->mouse_natural_scroll)
{
map[3] = 5;
map[4] = 4;
}
else
{
map[3] = 4;
map[4] = 5;
}
}
ecore_x_pointer_mapping_set(map, n);
}

View File

@ -840,7 +840,9 @@ _e_config_edd_init(Eina_Bool old)
E_CONFIG_VAL(D, T, mouse_natural_scroll, UCHAR);
E_CONFIG_VAL(D, T, mouse_emulate_middle_button, UCHAR);
E_CONFIG_VAL(D, T, touch_clickpad, UCHAR);
E_CONFIG_VAL(D, T, touch_scrolling_mode, UCHAR);
E_CONFIG_VAL(D, T, touch_scrolling_2finger, UCHAR);
E_CONFIG_VAL(D, T, touch_scrolling_edge, UCHAR);
E_CONFIG_VAL(D, T, touch_scrolling_circular, UCHAR);
E_CONFIG_VAL(D, T, touch_scrolling_horiz, UCHAR);
E_CONFIG_VAL(D, T, touch_palm_detect, UCHAR);
@ -1787,6 +1789,8 @@ e_config_load(void)
e_config->touch_clickpad = 1;
e_config->mouse_emulate_middle_button = 1;
e_config->touch_scrolling_horiz = 1;
e_config->touch_scrolling_2finger = 1;
e_config->touch_scrolling_edge = 1;
e_config->touch_palm_detect = 1;
e_config_save_queue();
}
@ -1932,7 +1936,9 @@ e_config_load(void)
E_CONFIG_LIMIT(e_config->mouse_natural_scroll, 0, 1);
E_CONFIG_LIMIT(e_config->mouse_emulate_middle_button, 0, 1);
E_CONFIG_LIMIT(e_config->touch_clickpad, 0, 1);
E_CONFIG_LIMIT(e_config->touch_scrolling_mode, 0, 2);
E_CONFIG_LIMIT(e_config->touch_scrolling_2finger, 0, 1);
E_CONFIG_LIMIT(e_config->touch_scrolling_edge, 0, 1);
E_CONFIG_LIMIT(e_config->touch_scrolling_circular, 0, 1);
E_CONFIG_LIMIT(e_config->touch_scrolling_horiz, 0, 1);
E_CONFIG_LIMIT(e_config->touch_palm_detect, 0, 1);

View File

@ -249,7 +249,9 @@ struct _E_Config
unsigned char mouse_natural_scroll; // GUI
unsigned char mouse_emulate_middle_button; // GUI
unsigned char touch_clickpad; // GUI
unsigned char touch_scrolling_mode; // GUI 0=edge, 1=2finger, 2=circle
unsigned char touch_scrolling_2finger; // GUI
unsigned char touch_scrolling_edge; // GUI
unsigned char touch_scrolling_circular; // GUI
unsigned char touch_scrolling_horiz; // GUI
unsigned char touch_palm_detect; // GUI

View File

@ -28,7 +28,9 @@ struct _E_Config_Dialog_Data
int tap_to_click;
int clickpad;
int scrolling_mode;
int scrolling_2finger;
int scrolling_edge;
int scrolling_circular;
int scrolling_horiz;
int palm_detect;
};
@ -71,7 +73,9 @@ _fill_data(E_Config_Dialog_Data *cfdata)
cfdata->emulate_middle_button = e_config->mouse_emulate_middle_button;
cfdata->natural_scroll = e_config->mouse_natural_scroll;
cfdata->clickpad = e_config->touch_clickpad;
cfdata->scrolling_mode = e_config->touch_scrolling_mode;
cfdata->scrolling_2finger = e_config->touch_scrolling_2finger;
cfdata->scrolling_edge = e_config->touch_scrolling_edge;
cfdata->scrolling_circular = e_config->touch_scrolling_circular;
cfdata->scrolling_horiz = e_config->touch_scrolling_horiz;
cfdata->palm_detect = e_config->touch_palm_detect;
}
@ -100,7 +104,9 @@ _basic_check_changed(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfd
(cfdata->emulate_middle_button == e_config->mouse_emulate_middle_button) &&
(cfdata->natural_scroll == e_config->mouse_natural_scroll) &&
(cfdata->clickpad == e_config->touch_clickpad) &&
(cfdata->scrolling_mode == e_config->touch_scrolling_mode) &&
(cfdata->scrolling_2finger == e_config->touch_scrolling_2finger) &&
(cfdata->scrolling_edge == e_config->touch_scrolling_edge) &&
(cfdata->scrolling_circular == e_config->touch_scrolling_circular) &&
(cfdata->scrolling_horiz == e_config->touch_scrolling_horiz) &&
(cfdata->palm_detect == e_config->touch_palm_detect) &&
EINA_DBL_EQ(cfdata->accel, e_config->mouse_accel) &&
@ -130,7 +136,9 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, E_Config_Dialog_Data *cfdata
e_config->mouse_emulate_middle_button = cfdata->emulate_middle_button;
e_config->mouse_natural_scroll = cfdata->natural_scroll;
e_config->touch_clickpad = cfdata->clickpad;
e_config->touch_scrolling_mode = cfdata->scrolling_mode;
e_config->touch_scrolling_2finger = cfdata->scrolling_2finger;
e_config->touch_scrolling_edge = cfdata->scrolling_edge;
e_config->touch_scrolling_circular = cfdata->scrolling_circular;
e_config->touch_scrolling_horiz = cfdata->scrolling_horiz;
e_config->touch_palm_detect = cfdata->palm_detect;
e_config_save_queue();
@ -269,13 +277,14 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas, E_Config_Dia
oc = e_widget_check_add(evas, _("Horizontal scrolling"), &(cfdata->scrolling_horiz));
e_widget_framelist_object_append(of, oc);
rg = e_widget_radio_group_new(&(cfdata->scrolling_mode));
ob = e_widget_radio_add(evas, _("Edge scrolling"), 0, rg);
e_widget_framelist_object_append(of, ob);
ob = e_widget_radio_add(evas, _("Two finger scrolling"), 1, rg);
e_widget_framelist_object_append(of, ob);
ob = e_widget_radio_add(evas, _("Circular scrolling"), 2, rg);
e_widget_framelist_object_append(of, ob);
oc = e_widget_check_add(evas, _("Edge scrolling"), &(cfdata->scrolling_edge));
e_widget_framelist_object_append(of, oc);
oc = e_widget_check_add(evas, _("2 finger scrolling"), &(cfdata->scrolling_2finger));
e_widget_framelist_object_append(of, oc);
oc = e_widget_check_add(evas, _("Circular scrolling"), &(cfdata->scrolling_circular));
e_widget_framelist_object_append(of, oc);
e_widget_list_object_append(ol, of, 1, 0, 0.5);
e_widget_toolbook_page_append(otb, NULL, _("Mouse"), ol,