summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elput/elput_evdev.c43
-rw-r--r--src/lib/elput/elput_private.h18
2 files changed, 60 insertions, 1 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 222c5087a2..b041bb6785 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -38,9 +38,25 @@ _seat_frame_send(Elput_Seat *seat)
38} 38}
39 39
40static void 40static void
41_evdev_leds_update(Elput_Device *edev, Elput_Leds leds)
42{
43 enum libinput_led input_leds = 0;
44
45 if (leds & ELPUT_LED_NUM)
46 input_leds |= LIBINPUT_LED_NUM_LOCK;
47 if (leds & ELPUT_LED_CAPS)
48 input_leds |= LIBINPUT_LED_CAPS_LOCK;
49 if (leds & ELPUT_LED_SCROLL)
50 input_leds |= LIBINPUT_LED_SCROLL_LOCK;
51
52 libinput_device_led_update(edev->device, input_leds);
53}
54
55static void
41_keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat) 56_keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat)
42{ 57{
43 xkb_mod_mask_t mask; 58 xkb_mod_mask_t mask;
59 Elput_Leds leds = 0;
44 60
45 kbd->mods.depressed = 61 kbd->mods.depressed =
46 xkb_state_serialize_mods(kbd->state, XKB_STATE_DEPRESSED); 62 xkb_state_serialize_mods(kbd->state, XKB_STATE_DEPRESSED);
@@ -64,6 +80,26 @@ _keyboard_modifiers_update(Elput_Keyboard *kbd, Elput_Seat *seat)
64 seat->modifiers |= ECORE_EVENT_MODIFIER_WIN; 80 seat->modifiers |= ECORE_EVENT_MODIFIER_WIN;
65 if (mask & kbd->info->mods.altgr) 81 if (mask & kbd->info->mods.altgr)
66 seat->modifiers |= ECORE_EVENT_MODIFIER_ALTGR; 82 seat->modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
83
84 if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.num))
85 leds |= ELPUT_LED_NUM;
86
87 if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.caps))
88 leds |= ELPUT_LED_CAPS;
89
90 if (xkb_state_led_index_is_active(kbd->state, kbd->info->leds.scroll))
91 leds |= ELPUT_LED_SCROLL;
92
93 if (kbd->leds != leds)
94 {
95 Eina_List *l;
96 Elput_Device *edev;
97
98 EINA_LIST_FOREACH(seat->devices, l, edev)
99 _evdev_leds_update(edev, leds);
100
101 kbd->leds = leds;
102 }
67} 103}
68 104
69static Elput_Keyboard_Info * 105static Elput_Keyboard_Info *
@@ -90,6 +126,13 @@ _keyboard_info_create(struct xkb_keymap *keymap)
90 info->mods.altgr = 126 info->mods.altgr =
91 1 << xkb_keymap_mod_get_index(info->keymap.map, "ISO_Level3_Shift"); 127 1 << xkb_keymap_mod_get_index(info->keymap.map, "ISO_Level3_Shift");
92 128
129 info->leds.num =
130 xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_NUM);
131 info->leds.caps =
132 xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_CAPS);
133 info->leds.scroll =
134 xkb_keymap_led_get_index(info->keymap.map, XKB_LED_NAME_SCROLL);
135
93 return info; 136 return info;
94} 137}
95 138
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 54ef2c2ba0..5b38c14ab6 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -86,6 +86,13 @@ typedef struct _Elput_Input
86 Eina_Bool suspended : 1; 86 Eina_Bool suspended : 1;
87} Elput_Input; 87} Elput_Input;
88 88
89typedef enum _Elput_Leds
90{
91 ELPUT_LED_NUM = (1 << 0),
92 ELPUT_LED_CAPS = (1 << 1),
93 ELPUT_LED_SCROLL = (1 << 2)
94} Elput_Leds;
95
89typedef struct _Elput_Keyboard_Info 96typedef struct _Elput_Keyboard_Info
90{ 97{
91 int refs; 98 int refs;
@@ -104,6 +111,13 @@ typedef struct _Elput_Keyboard_Info
104 xkb_mod_index_t altgr; 111 xkb_mod_index_t altgr;
105 xkb_mod_index_t super; 112 xkb_mod_index_t super;
106 } mods; 113 } mods;
114
115 struct
116 {
117 xkb_led_index_t num;
118 xkb_led_index_t caps;
119 xkb_led_index_t scroll;
120 } leds;
107} Elput_Keyboard_Info; 121} Elput_Keyboard_Info;
108 122
109struct _Elput_Keyboard 123struct _Elput_Keyboard
@@ -132,6 +146,8 @@ struct _Elput_Keyboard
132 struct xkb_compose_table *compose_table; 146 struct xkb_compose_table *compose_table;
133 struct xkb_compose_state *compose_state; 147 struct xkb_compose_state *compose_state;
134 148
149 Elput_Leds leds;
150
135 Elput_Seat *seat; 151 Elput_Seat *seat;
136 152
137 Eina_Bool pending_keymap : 1; 153 Eina_Bool pending_keymap : 1;
@@ -295,6 +311,6 @@ extern Elput_Interface _logind_interface;
295void _keyboard_keymap_update(Elput_Seat *seat); 311void _keyboard_keymap_update(Elput_Seat *seat);
296void _keyboard_group_update(Elput_Seat *seat); 312void _keyboard_group_update(Elput_Seat *seat);
297 313
298
299void _udev_seat_destroy(Elput_Seat *eseat); 314void _udev_seat_destroy(Elput_Seat *eseat);
315
300#endif 316#endif