Lines Matching +full:key +full:- +full:release

1 // SPDX-License-Identifier: GPL-2.0-only
14 #include <linux/input/sparse-keymap.h>
25 struct key_entry *key; in sparse_keymap_get_key_index() local
28 for (key = dev->keycode; key->type != KE_END; key++) { in sparse_keymap_get_key_index()
29 if (key->type == KE_KEY) { in sparse_keymap_get_key_index()
30 if (key == k) in sparse_keymap_get_key_index()
42 struct key_entry *key; in sparse_keymap_entry_by_index() local
45 for (key = dev->keycode; key->type != KE_END; key++) in sparse_keymap_entry_by_index()
46 if (key->type == KE_KEY) in sparse_keymap_entry_by_index()
48 return key; in sparse_keymap_entry_by_index()
54 * sparse_keymap_entry_from_scancode - perform sparse keymap lookup
64 struct key_entry *key; in sparse_keymap_entry_from_scancode() local
66 for (key = dev->keycode; key->type != KE_END; key++) in sparse_keymap_entry_from_scancode()
67 if (code == key->code) in sparse_keymap_entry_from_scancode()
68 return key; in sparse_keymap_entry_from_scancode()
75 * sparse_keymap_entry_from_keycode - perform sparse keymap lookup
77 * @keycode: Key code
85 struct key_entry *key; in sparse_keymap_entry_from_keycode() local
87 for (key = dev->keycode; key->type != KE_END; key++) in sparse_keymap_entry_from_keycode()
88 if (key->type == KE_KEY && keycode == key->keycode) in sparse_keymap_entry_from_keycode()
89 return key; in sparse_keymap_entry_from_keycode()
98 struct key_entry *key; in sparse_keymap_locate() local
101 if (ke->flags & INPUT_KEYMAP_BY_INDEX) in sparse_keymap_locate()
102 key = sparse_keymap_entry_by_index(dev, ke->index); in sparse_keymap_locate()
104 key = sparse_keymap_entry_from_scancode(dev, scancode); in sparse_keymap_locate()
106 key = NULL; in sparse_keymap_locate()
108 return key; in sparse_keymap_locate()
114 const struct key_entry *key; in sparse_keymap_getkeycode() local
116 if (dev->keycode) { in sparse_keymap_getkeycode()
117 key = sparse_keymap_locate(dev, ke); in sparse_keymap_getkeycode()
118 if (key && key->type == KE_KEY) { in sparse_keymap_getkeycode()
119 ke->keycode = key->keycode; in sparse_keymap_getkeycode()
120 if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) in sparse_keymap_getkeycode()
121 ke->index = in sparse_keymap_getkeycode()
122 sparse_keymap_get_key_index(dev, key); in sparse_keymap_getkeycode()
123 ke->len = sizeof(key->code); in sparse_keymap_getkeycode()
124 memcpy(ke->scancode, &key->code, sizeof(key->code)); in sparse_keymap_getkeycode()
129 return -EINVAL; in sparse_keymap_getkeycode()
136 struct key_entry *key; in sparse_keymap_setkeycode() local
138 if (dev->keycode) { in sparse_keymap_setkeycode()
139 key = sparse_keymap_locate(dev, ke); in sparse_keymap_setkeycode()
140 if (key && key->type == KE_KEY) { in sparse_keymap_setkeycode()
141 *old_keycode = key->keycode; in sparse_keymap_setkeycode()
142 key->keycode = ke->keycode; in sparse_keymap_setkeycode()
143 set_bit(ke->keycode, dev->keybit); in sparse_keymap_setkeycode()
145 clear_bit(*old_keycode, dev->keybit); in sparse_keymap_setkeycode()
150 return -EINVAL; in sparse_keymap_setkeycode()
154 * sparse_keymap_setup - set up sparse keymap for an input device
176 for (e = keymap; e->type != KE_END; e++) in sparse_keymap_setup()
179 map = devm_kmemdup(&dev->dev, keymap, map_size * sizeof(*map), in sparse_keymap_setup()
182 return -ENOMEM; in sparse_keymap_setup()
193 switch (entry->type) { in sparse_keymap_setup()
195 __set_bit(EV_KEY, dev->evbit); in sparse_keymap_setup()
196 __set_bit(entry->keycode, dev->keybit); in sparse_keymap_setup()
201 __set_bit(EV_SW, dev->evbit); in sparse_keymap_setup()
202 __set_bit(entry->sw.code, dev->swbit); in sparse_keymap_setup()
207 if (test_bit(EV_KEY, dev->evbit)) { in sparse_keymap_setup()
208 __set_bit(KEY_UNKNOWN, dev->keybit); in sparse_keymap_setup()
209 __set_bit(EV_MSC, dev->evbit); in sparse_keymap_setup()
210 __set_bit(MSC_SCAN, dev->mscbit); in sparse_keymap_setup()
213 dev->keycode = map; in sparse_keymap_setup()
214 dev->keycodemax = map_size; in sparse_keymap_setup()
215 dev->getkeycode = sparse_keymap_getkeycode; in sparse_keymap_setup()
216 dev->setkeycode = sparse_keymap_setkeycode; in sparse_keymap_setup()
223 * sparse_keymap_report_entry - report event corresponding to given key entry
225 * @ke: key entry describing event
227 * @autorelease: Signals whether release event should be emitted for %KE_KEY
237 switch (ke->type) { in sparse_keymap_report_entry()
239 input_event(dev, EV_MSC, MSC_SCAN, ke->code); in sparse_keymap_report_entry()
240 input_report_key(dev, ke->keycode, value); in sparse_keymap_report_entry()
243 input_report_key(dev, ke->keycode, 0); in sparse_keymap_report_entry()
249 value = ke->sw.value; in sparse_keymap_report_entry()
253 input_report_switch(dev, ke->sw.code, value); in sparse_keymap_report_entry()
261 * sparse_keymap_report_event - report event corresponding to given scancode
265 * @autorelease: Signals whether release event should be emitted for %KE_KEY
285 /* Report an unknown key event as a debugging aid */ in sparse_keymap_report_event()