Lines Matching +full:key +full:- +full:up
1 // SPDX-License-Identifier: GPL-2.0-only
6 * Ported to recent 2.6 kernel versions by Greg Kroah-Hartman <gregkh@suse.de>
11 * Copyright (C) 2008 Greg Kroah-Hartman <greg@kroah.com>
21 #include "hid-ids.h"
34 * 25 87 ee 83 0c -
39 * 26 00 00 00 00 for key repeat
45 * 25 87 ee ca 0d -
50 * 26 00 00 00 00 for key repeat
53 * sent after a key is release, which I interpret
61 * 25 87 ee 47 0d -
66 * 26 87 ee 47 ** for key repeat (** is the code of the key being held)
111 struct timer_list key_up_timer; /* timer for key up */
113 int current_key; /* the currently pressed key */
114 int prev_key_idx; /* key index in a 2 packets message */
120 * The key is coded accross bits 2..9: in get_key()
122 * 0x00 or 0x01 ( ) key: 0 -> KEY_RESERVED in get_key()
123 * 0x02 or 0x03 ( menu ) key: 1 -> KEY_MENU in get_key()
124 * 0x04 or 0x05 ( >" ) key: 2 -> KEY_PLAYPAUSE in get_key()
125 * 0x06 or 0x07 ( >> ) key: 3 -> KEY_FORWARD in get_key()
126 * 0x08 or 0x09 ( << ) key: 4 -> KEY_BACK in get_key()
127 * 0x0a or 0x0b ( + ) key: 5 -> KEY_VOLUMEUP in get_key()
128 * 0x0c or 0x0d ( - ) key: 6 -> KEY_VOLUMEDOWN in get_key()
129 * 0x0e or 0x0f ( ) key: 7 -> KEY_RESERVED in get_key()
130 * 0x50 or 0x51 ( ) key: 8 -> KEY_RESERVED in get_key()
131 * 0x52 or 0x53 ( ) key: 9 -> KEY_RESERVED in get_key()
132 * 0x54 or 0x55 ( ) key: 10 -> KEY_RESERVED in get_key()
133 * 0x56 or 0x57 ( ) key: 11 -> KEY_RESERVED in get_key()
134 * 0x58 or 0x59 ( ) key: 12 -> KEY_RESERVED in get_key()
135 * 0x5a or 0x5b ( ) key: 13 -> KEY_RESERVED in get_key()
136 * 0x5c or 0x5d ( middle ) key: 14 -> KEY_ENTER in get_key()
137 * 0x5e or 0x5f ( >" ) key: 15 -> KEY_PLAYPAUSE in get_key()
139 * Packets starting with 0x5 are part of a two-packets message, in get_key()
142 int key = (data >> 1) & KEY_MASK; in get_key() local
145 /* Part of a 2 packets-command */ in get_key()
146 key = -key; in get_key()
148 return key; in get_key()
151 static void key_up(struct hid_device *hid, struct appleir *appleir, int key) in key_up() argument
153 input_report_key(appleir->input_dev, key, 0); in key_up()
154 input_sync(appleir->input_dev); in key_up()
157 static void key_down(struct hid_device *hid, struct appleir *appleir, int key) in key_down() argument
159 input_report_key(appleir->input_dev, key, 1); in key_down()
160 input_sync(appleir->input_dev); in key_down()
165 dev_err(&appleir->input_dev->dev, "possible flat battery?\n"); in battery_flat()
171 struct hid_device *hid = appleir->hid; in key_up_tick()
174 spin_lock_irqsave(&appleir->lock, flags); in key_up_tick()
175 if (appleir->current_key) { in key_up_tick()
176 key_up(hid, appleir, appleir->current_key); in key_up_tick()
177 appleir->current_key = 0; in key_up_tick()
179 spin_unlock_irqrestore(&appleir->lock, flags); in key_up_tick()
191 if (len != 5 || !(hid->claimed & HID_CLAIMED_INPUT)) in appleir_raw_event()
197 spin_lock_irqsave(&appleir->lock, flags); in appleir_raw_event()
199 * If we already have a key down, take it up before marking in appleir_raw_event()
202 if (appleir->current_key) in appleir_raw_event()
203 key_up(hid, appleir, appleir->current_key); in appleir_raw_event()
206 if (appleir->prev_key_idx > 0) in appleir_raw_event()
207 index = appleir->prev_key_idx; in appleir_raw_event()
212 appleir->current_key = appleir->keymap[index]; in appleir_raw_event()
214 key_down(hid, appleir, appleir->current_key); in appleir_raw_event()
216 * Remote doesn't do key up, either pull them up, in in appleir_raw_event()
218 * them up after 1/8 s in appleir_raw_event()
220 mod_timer(&appleir->key_up_timer, jiffies + HZ / 8); in appleir_raw_event()
221 appleir->prev_key_idx = 0; in appleir_raw_event()
223 /* Remember key for next packet */ in appleir_raw_event()
224 appleir->prev_key_idx = -index; in appleir_raw_event()
225 spin_unlock_irqrestore(&appleir->lock, flags); in appleir_raw_event()
229 appleir->prev_key_idx = 0; in appleir_raw_event()
232 key_down(hid, appleir, appleir->current_key); in appleir_raw_event()
234 * Remote doesn't do key up, either pull them up, in the test in appleir_raw_event()
235 * above, or here set a timer which pulls them up after 1/8 s in appleir_raw_event()
237 mod_timer(&appleir->key_up_timer, jiffies + HZ / 8); in appleir_raw_event()
254 struct input_dev *input_dev = hidinput->input; in appleir_input_configured()
258 appleir->input_dev = input_dev; in appleir_input_configured()
260 input_dev->keycode = appleir->keymap; in appleir_input_configured()
261 input_dev->keycodesize = sizeof(unsigned short); in appleir_input_configured()
262 input_dev->keycodemax = ARRAY_SIZE(appleir->keymap); in appleir_input_configured()
264 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); in appleir_input_configured()
266 memcpy(appleir->keymap, appleir_key_table, sizeof(appleir->keymap)); in appleir_input_configured()
268 set_bit(appleir->keymap[i], input_dev->keybit); in appleir_input_configured()
269 clear_bit(KEY_RESERVED, input_dev->keybit); in appleir_input_configured()
278 return -1; in appleir_input_mapping()
286 appleir = devm_kzalloc(&hid->dev, sizeof(struct appleir), GFP_KERNEL); in appleir_probe()
288 return -ENOMEM; in appleir_probe()
290 appleir->hid = hid; in appleir_probe()
293 hid->quirks |= HID_QUIRK_HIDINPUT_FORCE; in appleir_probe()
295 spin_lock_init(&appleir->lock); in appleir_probe()
296 timer_setup(&appleir->key_up_timer, key_up_tick, 0); in appleir_probe()
314 devm_kfree(&hid->dev, appleir); in appleir_probe()
322 del_timer_sync(&appleir->key_up_timer); in appleir_remove()