summaryrefslogtreecommitdiff
path: root/src/lib/elput
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-07 11:04:03 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-08 20:37:50 +0900
commit7a7abb043add0af083c46305824d8c341daf2374 (patch)
treee25ef8ac67091ebc612b831361ece2a0f7420963 /src/lib/elput
parent10b6eb627abe7f0419b1c76ff73faf90274e940b (diff)
elput - re-enable switches (power buttons, lid etc.)
this is needed for devices that no longer produce aspi events for these. otherwise good luck getting any event on lid open/close or on pressing the power button. this also stops hiding switch events from libinput and now you can get switch events to find lid or tablet mode switching changes. @fix
Diffstat (limited to 'src/lib/elput')
-rw-r--r--src/lib/elput/Elput.h27
-rw-r--r--src/lib/elput/elput.c3
-rw-r--r--src/lib/elput/elput_evdev.c37
3 files changed, 54 insertions, 13 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index b05536130b..db62c52d10 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -38,6 +38,7 @@ typedef enum
38 ELPUT_DEVICE_CAPS_TABLET_TOOL = (1 << 3), 38 ELPUT_DEVICE_CAPS_TABLET_TOOL = (1 << 3),
39 ELPUT_DEVICE_CAPS_TABLET_PAD = (1 << 4), 39 ELPUT_DEVICE_CAPS_TABLET_PAD = (1 << 4),
40 ELPUT_DEVICE_CAPS_GESTURE = (1 << 5), 40 ELPUT_DEVICE_CAPS_GESTURE = (1 << 5),
41 ELPUT_DEVICE_CAPS_SWITCH = (1 << 6),
41} Elput_Device_Caps; 42} Elput_Device_Caps;
42 43
43/* opaque structure to represent an input manager */ 44/* opaque structure to represent an input manager */
@@ -112,6 +113,29 @@ typedef struct Elput_Event_Pointer_Motion
112 double dy_unaccel; 113 double dy_unaccel;
113} Elput_Event_Pointer_Motion; 114} Elput_Event_Pointer_Motion;
114 115
116/** @since 1.21 */
117typedef enum
118{
119 ELPUT_SWITCH_TYPE_LID = 1,
120 ELPUT_SWITCH_TYPE_TABLET_MODE,
121} Elput_Switch_Type;
122
123/** @since 1.21 */
124typedef enum
125{
126 ELPUT_SWITCH_STATE_OFF = 0,
127 ELPUT_SWITCH_STATE_ON = 1,
128} Elput_Switch_State;
129
130/** @since 1.21 */
131typedef struct _Elput_Event_Switch
132{
133 Elput_Device *device;
134 uint64_t time_usec;
135 Elput_Switch_Type type;
136 Elput_Switch_State state;
137} Elput_Event_Switch;
138
115 139
116EAPI extern int ELPUT_EVENT_SEAT_CAPS; 140EAPI extern int ELPUT_EVENT_SEAT_CAPS;
117EAPI extern int ELPUT_EVENT_SEAT_FRAME; 141EAPI extern int ELPUT_EVENT_SEAT_FRAME;
@@ -122,6 +146,9 @@ EAPI extern int ELPUT_EVENT_SESSION_ACTIVE;
122/** @since 1.19 */ 146/** @since 1.19 */
123EAPI extern int ELPUT_EVENT_POINTER_MOTION; 147EAPI extern int ELPUT_EVENT_POINTER_MOTION;
124 148
149/** @since 1.21 */
150EAPI extern int ELPUT_EVENT_SWITCH;
151
125/** 152/**
126 * @file 153 * @file
127 * @brief Ecore functions for dealing with libinput 154 * @brief Ecore functions for dealing with libinput
diff --git a/src/lib/elput/elput.c b/src/lib/elput/elput.c
index 9519129759..f3cda411ea 100644
--- a/src/lib/elput/elput.c
+++ b/src/lib/elput/elput.c
@@ -13,6 +13,7 @@ EAPI int ELPUT_EVENT_MODIFIERS_SEND = 0;
13EAPI int ELPUT_EVENT_DEVICE_CHANGE = 0; 13EAPI int ELPUT_EVENT_DEVICE_CHANGE = 0;
14EAPI int ELPUT_EVENT_SESSION_ACTIVE = 0; 14EAPI int ELPUT_EVENT_SESSION_ACTIVE = 0;
15EAPI int ELPUT_EVENT_POINTER_MOTION = 0; 15EAPI int ELPUT_EVENT_POINTER_MOTION = 0;
16EAPI int ELPUT_EVENT_SWITCH = 0;
16EAPI int elput_event_session_ready = 0; 17EAPI int elput_event_session_ready = 0;
17 18
18EAPI int 19EAPI int
@@ -41,6 +42,7 @@ elput_init(void)
41 ELPUT_EVENT_DEVICE_CHANGE = ecore_event_type_new(); 42 ELPUT_EVENT_DEVICE_CHANGE = ecore_event_type_new();
42 ELPUT_EVENT_SESSION_ACTIVE = ecore_event_type_new(); 43 ELPUT_EVENT_SESSION_ACTIVE = ecore_event_type_new();
43 ELPUT_EVENT_POINTER_MOTION = ecore_event_type_new(); 44 ELPUT_EVENT_POINTER_MOTION = ecore_event_type_new();
45 ELPUT_EVENT_SWITCH = ecore_event_type_new();
44 elput_event_session_ready = ecore_event_type_new(); 46 elput_event_session_ready = ecore_event_type_new();
45 } 47 }
46 48
@@ -71,6 +73,7 @@ elput_shutdown(void)
71 ELPUT_EVENT_DEVICE_CHANGE, 73 ELPUT_EVENT_DEVICE_CHANGE,
72 ELPUT_EVENT_SESSION_ACTIVE, 74 ELPUT_EVENT_SESSION_ACTIVE,
73 ELPUT_EVENT_POINTER_MOTION, 75 ELPUT_EVENT_POINTER_MOTION,
76 ELPUT_EVENT_SWITCH,
74 elput_event_session_ready); 77 elput_event_session_ready);
75 78
76 eina_log_domain_unregister(_elput_log_dom); 79 eina_log_domain_unregister(_elput_log_dom);
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 09d75932f8..afa42df68c 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -1595,6 +1595,20 @@ _tablet_tool_tip(struct libinput_device *idev, struct libinput_event_tablet_tool
1595 _pointer_button_send(dev, press[state]); 1595 _pointer_button_send(dev, press[state]);
1596} 1596}
1597 1597
1598static void
1599_switch_toggle(struct libinput_device *idev, struct libinput_event_switch *event)
1600{
1601 Elput_Event_Switch *ev;
1602
1603 ev = calloc(1, sizeof(Elput_Event_Switch));
1604 if (!ev) return;
1605 ev->device = libinput_device_get_user_data(idev);
1606 ev->time_usec = libinput_event_switch_get_time_usec(event);
1607 ev->type = (Elput_Switch_Type)libinput_event_switch_get_switch(event);
1608 ev->state = (Elput_Switch_State)libinput_event_switch_get_switch_state(event);
1609 ecore_event_add(ELPUT_EVENT_SWITCH, ev, NULL, NULL);
1610}
1611
1598int 1612int
1599_evdev_event_process(struct libinput_event *event) 1613_evdev_event_process(struct libinput_event *event)
1600{ 1614{
@@ -1642,6 +1656,9 @@ _evdev_event_process(struct libinput_event *event)
1642 case LIBINPUT_EVENT_TABLET_TOOL_TIP: /* is this useful? */ 1656 case LIBINPUT_EVENT_TABLET_TOOL_TIP: /* is this useful? */
1643 _tablet_tool_tip(idev, libinput_event_get_tablet_tool_event(event)); 1657 _tablet_tool_tip(idev, libinput_event_get_tablet_tool_event(event));
1644 break; 1658 break;
1659 case LIBINPUT_EVENT_SWITCH_TOGGLE:
1660 _switch_toggle(idev, libinput_event_get_switch_event(event));
1661 break;
1645 default: 1662 default:
1646 ret = 0; 1663 ret = 0;
1647 break; 1664 break;
@@ -1670,7 +1687,6 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1670 edev->refs = 1; 1687 edev->refs = 1;
1671 edev->seat = seat; 1688 edev->seat = seat;
1672 edev->device = device; 1689 edev->device = device;
1673 edev->caps = 0;
1674 edev->ow = seat->manager->output_w; 1690 edev->ow = seat->manager->output_w;
1675 edev->oh = seat->manager->output_h; 1691 edev->oh = seat->manager->output_h;
1676 1692
@@ -1679,13 +1695,14 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1679 oname = libinput_device_get_name(device); 1695 oname = libinput_device_get_name(device);
1680 eina_stringshare_replace(&edev->output_name, oname); 1696 eina_stringshare_replace(&edev->output_name, oname);
1681 1697
1698 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_SWITCH))
1699 edev->caps |= ELPUT_DEVICE_CAPS_SWITCH;
1682 if ((libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) && 1700 if ((libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD)) &&
1683 (libinput_device_keyboard_has_key(device, KEY_ENTER))) 1701 (libinput_device_keyboard_has_key(device, KEY_ENTER)))
1684 { 1702 edev->caps |= ELPUT_DEVICE_CAPS_KEYBOARD;
1685 _keyboard_init(seat, seat->manager->cached.keymap); 1703 if (edev->caps & (ELPUT_DEVICE_CAPS_SWITCH | ELPUT_DEVICE_CAPS_KEYBOARD))
1686 edev->caps |= ELPUT_DEVICE_CAPS_KEYBOARD; 1704 _keyboard_init(seat, seat->manager->cached.keymap);
1687 } 1705
1688
1689 if ((libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER) && 1706 if ((libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER) &&
1690 (libinput_device_pointer_has_button(device, BTN_LEFT)))) 1707 (libinput_device_pointer_has_button(device, BTN_LEFT))))
1691 edev->caps |= ELPUT_DEVICE_CAPS_POINTER; 1708 edev->caps |= ELPUT_DEVICE_CAPS_POINTER;
@@ -1694,10 +1711,7 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1694 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD)) 1711 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TABLET_PAD))
1695 edev->caps |= ELPUT_DEVICE_CAPS_TABLET_PAD; 1712 edev->caps |= ELPUT_DEVICE_CAPS_TABLET_PAD;
1696 if (edev->caps & ELPUT_DEVICE_CAPS_POINTER) 1713 if (edev->caps & ELPUT_DEVICE_CAPS_POINTER)
1697 { 1714 _pointer_init(seat);
1698 _pointer_init(seat);
1699 edev->caps |= ELPUT_DEVICE_CAPS_POINTER;
1700 }
1701 1715
1702 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) 1716 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
1703 edev->caps |= ELPUT_DEVICE_CAPS_TOUCH; 1717 edev->caps |= ELPUT_DEVICE_CAPS_TOUCH;
@@ -1706,8 +1720,6 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1706 if (edev->caps & ELPUT_DEVICE_CAPS_TOUCH) 1720 if (edev->caps & ELPUT_DEVICE_CAPS_TOUCH)
1707 _touch_init(seat); 1721 _touch_init(seat);
1708 1722
1709 if (!edev->caps) goto err;
1710
1711 libinput_device_set_user_data(device, edev); 1723 libinput_device_set_user_data(device, edev);
1712 libinput_device_ref(edev->device); 1724 libinput_device_ref(edev->device);
1713 1725
@@ -1721,7 +1733,6 @@ _evdev_device_create(Elput_Seat *seat, struct libinput_device *device)
1721 1733
1722 return edev; 1734 return edev;
1723 1735
1724err:
1725 eina_stringshare_del(edev->output_name); 1736 eina_stringshare_del(edev->output_name);
1726 free(edev); 1737 free(edev);
1727 return NULL; 1738 return NULL;