On Wed, Nov 8, 2017 at 6:39 AM Carsten Haitzler <[email protected]> wrote:
> raster pushed a commit to branch master. > > > http://git.enlightenment.org/core/efl.git/commit/?id=7a7abb043add0af083c46305824d8c341daf2374 > > commit 7a7abb043add0af083c46305824d8c341daf2374 > Author: Carsten Haitzler (Rasterman) <[email protected]> > Date: Tue Nov 7 11:04:03 2017 +0900 > > 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 > --- > src/lib/elput/Elput.h | 27 +++++++++++++++++++++++++++ > src/lib/elput/elput.c | 3 +++ > src/lib/elput/elput_evdev.c | 37 ++++++++++++++++++++++++------------- > 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 > ELPUT_DEVICE_CAPS_TABLET_TOOL = (1 << 3), > ELPUT_DEVICE_CAPS_TABLET_PAD = (1 << 4), > ELPUT_DEVICE_CAPS_GESTURE = (1 << 5), > + ELPUT_DEVICE_CAPS_SWITCH = (1 << 6), > } Elput_Device_Caps; > > /* opaque structure to represent an input manager */ > @@ -112,6 +113,29 @@ typedef struct Elput_Event_Pointer_Motion > double dy_unaccel; > } Elput_Event_Pointer_Motion; > > +/** @since 1.21 */ > +typedef enum > +{ > + ELPUT_SWITCH_TYPE_LID = 1, > + ELPUT_SWITCH_TYPE_TABLET_MODE, > +} Elput_Switch_Type; > + > +/** @since 1.21 */ > +typedef enum > +{ > + ELPUT_SWITCH_STATE_OFF = 0, > + ELPUT_SWITCH_STATE_ON = 1, > +} Elput_Switch_State; > + > +/** @since 1.21 */ > +typedef struct _Elput_Event_Switch > +{ > + Elput_Device *device; > + uint64_t time_usec; > + Elput_Switch_Type type; > + Elput_Switch_State state; > +} Elput_Event_Switch; > + > > EAPI extern int ELPUT_EVENT_SEAT_CAPS; > EAPI extern int ELPUT_EVENT_SEAT_FRAME; > @@ -122,6 +146,9 @@ EAPI extern int ELPUT_EVENT_SESSION_ACTIVE; > /** @since 1.19 */ > EAPI extern int ELPUT_EVENT_POINTER_MOTION; > > +/** @since 1.21 */ > +EAPI extern int ELPUT_EVENT_SWITCH; > + > /** > * @file > * @brief Ecore functions for dealing with libinput > diff --git a/src/lib/elput/elput.c b/src/lib/elput/elput.c > index 9519129759 <(951)%20912-9759>..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; > EAPI int ELPUT_EVENT_DEVICE_CHANGE = 0; > EAPI int ELPUT_EVENT_SESSION_ACTIVE = 0; > EAPI int ELPUT_EVENT_POINTER_MOTION = 0; > +EAPI int ELPUT_EVENT_SWITCH = 0; > EAPI int elput_event_session_ready = 0; > > EAPI int > @@ -41,6 +42,7 @@ elput_init(void) > ELPUT_EVENT_DEVICE_CHANGE = ecore_event_type_new(); > ELPUT_EVENT_SESSION_ACTIVE = ecore_event_type_new(); > ELPUT_EVENT_POINTER_MOTION = ecore_event_type_new(); > + ELPUT_EVENT_SWITCH = ecore_event_type_new(); > elput_event_session_ready = ecore_event_type_new(); > } > > @@ -71,6 +73,7 @@ elput_shutdown(void) > ELPUT_EVENT_DEVICE_CHANGE, > ELPUT_EVENT_SESSION_ACTIVE, > ELPUT_EVENT_POINTER_MOTION, > + ELPUT_EVENT_SWITCH, > elput_event_session_ready); > > 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 > _pointer_button_send(dev, press[state]); > } > > +static void > +_switch_toggle(struct libinput_device *idev, struct libinput_event_switch > *event) > +{ > + Elput_Event_Switch *ev; > + > + ev = calloc(1, sizeof(Elput_Event_Switch)); > + if (!ev) return; > + ev->device = libinput_device_get_user_data(idev); > This needs ev->device->refs++ and a corresponding unref. > + ev->time_usec = libinput_event_switch_get_time_usec(event); > + ev->type = (Elput_Switch_Type)libinput_event_switch_get_switch(event); > + ev->state = > (Elput_Switch_State)libinput_event_switch_get_switch_state(event); > + ecore_event_add(ELPUT_EVENT_SWITCH, ev, NULL, NULL); > +} > + > int > _evdev_event_process(struct libinput_event *event) > { > @@ -1642,6 +1656,9 @@ _evdev_event_process(struct libinput_event *event) > case LIBINPUT_EVENT_TABLET_TOOL_TIP: /* is this useful? */ > _tablet_tool_tip(idev, > libinput_event_get_tablet_tool_event(event)); > break; > + case LIBINPUT_EVENT_SWITCH_TOGGLE: > + _switch_toggle(idev, libinput_event_get_switch_event(event)); > + break; > default: > ret = 0; > break; > @@ -1670,7 +1687,6 @@ _evdev_device_create(Elput_Seat *seat, struct > libinput_device *device) > edev->refs = 1; > edev->seat = seat; > edev->device = device; > - edev->caps = 0; > edev->ow = seat->manager->output_w; > edev->oh = seat->manager->output_h; > > @@ -1679,13 +1695,14 @@ _evdev_device_create(Elput_Seat *seat, struct > libinput_device *device) > oname = libinput_device_get_name(device); > eina_stringshare_replace(&edev->output_name, oname); > > + if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_SWITCH)) > + edev->caps |= ELPUT_DEVICE_CAPS_SWITCH; > if ((libinput_device_has_capability(device, > LIBINPUT_DEVICE_CAP_KEYBOARD)) && > (libinput_device_keyboard_has_key(device, KEY_ENTER))) > - { > - _keyboard_init(seat, seat->manager->cached.keymap); > - edev->caps |= ELPUT_DEVICE_CAPS_KEYBOARD; > - } > - > + edev->caps |= ELPUT_DEVICE_CAPS_KEYBOARD; > + if (edev->caps & (ELPUT_DEVICE_CAPS_SWITCH | > ELPUT_DEVICE_CAPS_KEYBOARD)) > + _keyboard_init(seat, seat->manager->cached.keymap); > + > if ((libinput_device_has_capability(device, > LIBINPUT_DEVICE_CAP_POINTER) && > (libinput_device_pointer_has_button(device, BTN_LEFT)))) > edev->caps |= ELPUT_DEVICE_CAPS_POINTER; > @@ -1694,10 +1711,7 @@ _evdev_device_create(Elput_Seat *seat, struct > libinput_device *device) > if (libinput_device_has_capability(device, > LIBINPUT_DEVICE_CAP_TABLET_PAD)) > edev->caps |= ELPUT_DEVICE_CAPS_TABLET_PAD; > if (edev->caps & ELPUT_DEVICE_CAPS_POINTER) > - { > - _pointer_init(seat); > - edev->caps |= ELPUT_DEVICE_CAPS_POINTER; > - } > + _pointer_init(seat); > > if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH)) > edev->caps |= ELPUT_DEVICE_CAPS_TOUCH; > @@ -1706,8 +1720,6 @@ _evdev_device_create(Elput_Seat *seat, struct > libinput_device *device) > if (edev->caps & ELPUT_DEVICE_CAPS_TOUCH) > _touch_init(seat); > > - if (!edev->caps) goto err; > I think the point of this was to avoid managing devices that are not yet handled so that the user is never able to access a device struct which has no caps; is it now the case that all created devices have caps? > - > libinput_device_set_user_data(device, edev); > libinput_device_ref(edev->device); > > @@ -1721,7 +1733,6 @@ _evdev_device_create(Elput_Seat *seat, struct > libinput_device *device) > > return edev; > > -err: > eina_stringshare_del(edev->output_name); > free(edev); > return NULL; > > -- > > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
