浏览代码

input: Ban digit numbers if 'Num Lock' is not on

When 'Num Lock' is not on, we should not send these digit numbers
(0-9 and dot) to the output buffer.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Simon Glass <sjg@chromium.org>
Bin Meng 9 年之前
父节点
当前提交
e5f330c482
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      drivers/input/input.c

+ 6 - 0
drivers/input/input.c

@@ -479,6 +479,12 @@ static int input_keycodes_to_ascii(struct input_config *config,
 			if ((config->flags & FLAG_CAPS_LOCK) &&
 			    ch >= 'a' && ch <= 'z')
 				ch -= 'a' - 'A';
+			/* ban digit numbers if 'Num Lock' is not on */
+			if (!(config->flags & FLAG_NUM_LOCK)) {
+				if (key >= KEY_KP7 && key <= KEY_KPDOT &&
+				    key != KEY_KPMINUS && key != KEY_KPPLUS)
+					ch = 0xff;
+			}
 			if (ch_count < max_chars && ch != 0xff)
 				output_ch[ch_count++] = (uchar)ch;
 		} else {