summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2018-08-08 12:35:37 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-16 13:14:46 -0700
commit7ef6291e33c31388652e66ebf0f96ec6d836d528 (patch)
tree675b2d1f463df13a94ea3e7621b714009f4d83c7 /common
parent50e52e2182a09eb862e5a0b4cbb25d052c94364d (diff)
downloadchrome-ec-7ef6291e33c31388652e66ebf0f96ec6d836d528.tar.gz
keyboard: Change scan code magic values to enum.
The key codes are now always scan code set 2 so we can create a list of scan codes and use them easily. BUG=None TEST=make buildall -j; boots properly BRANCH=None Change-Id: I1fdd7ab81bc13c97c4139afc19d71f5898e22f96 Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1166743
Diffstat (limited to 'common')
-rw-r--r--common/keyboard_8042.c23
-rw-r--r--common/keyboard_8042_sharedlib.c24
2 files changed, 25 insertions, 22 deletions
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index 4b2b9a5db9..50320807cb 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -776,30 +776,33 @@ static void i8042_handle_from_host(void)
static void keyboard_special(uint16_t k)
{
static uint8_t s;
- static const uint16_t a[] = {0xe075, 0xe075, 0xe072, 0xe072, 0xe06b,
- 0xe074, 0xe06b, 0xe074, 0x0032, 0x001c};
+ static const uint16_t a[] = {
+ SCANCODE_UP, SCANCODE_UP, SCANCODE_DOWN, SCANCODE_DOWN,
+ SCANCODE_LEFT, SCANCODE_RIGHT, SCANCODE_LEFT, SCANCODE_RIGHT,
+ SCANCODE_B, SCANCODE_A};
+
#ifdef HAS_TASK_LIGHTBAR
/* Lightbar demo mode: keyboard can fake the battery state */
switch (k) {
- case 0xe075: /* up */
+ case SCANCODE_UP:
demo_battery_level(1);
break;
- case 0xe072: /* down */
+ case SCANCODE_DOWN:
demo_battery_level(-1);
break;
- case 0xe06b: /* left */
+ case SCANCODE_LEFT:
demo_is_charging(0);
break;
- case 0xe074: /* right */
+ case SCANCODE_RIGHT:
demo_is_charging(1);
break;
- case 0x000b: /* dim */
+ case SCANCODE_F6: /* dim */
demo_brightness(-1);
break;
- case 0x0083: /* bright */
+ case SCANCODE_F7: /* bright */
demo_brightness(1);
break;
- case 0x002c: /* T */
+ case SCANCODE_T:
demo_tap();
break;
}
@@ -807,7 +810,7 @@ static void keyboard_special(uint16_t k)
if (k == a[s])
s++;
- else if (k != 0xe075)
+ else if (k != SCANCODE_UP)
s = 0;
else if (s != 2)
s = 1;
diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c
index 0ea4dca792..513a27913d 100644
--- a/common/keyboard_8042_sharedlib.c
+++ b/common/keyboard_8042_sharedlib.c
@@ -76,20 +76,20 @@ uint8_t scancode_translate_set2_to_1(uint8_t code)
}
/*
- * Button scancodes in code set 2.
+ * Button scan codes.
* Must be in the same order as defined in keyboard_button_type.
*/
SHAREDLIB(const struct button_8042_t buttons_8042[] = {
- {0xe037, 0}, /* Power */
- {0xe021, 1}, /* Volume Down */
- {0xe032, 1}, /* Volume Up */
- {0x0016, 1}, /* 1 */
- {0x001e, 1}, /* 2 */
- {0x0026, 1}, /* 3 */
- {0x0025, 1}, /* 4 */
- {0x002e, 1}, /* 5 */
- {0x0036, 1}, /* 6 */
- {0x003d, 1}, /* 7 */
- {0x003e, 1}, /* 8 */
+ {SCANCODE_POWER, 0},
+ {SCANCODE_VOLUME_DOWN, 1},
+ {SCANCODE_VOLUME_UP, 1},
+ {SCANCODE_1, 1},
+ {SCANCODE_2, 1},
+ {SCANCODE_3, 1},
+ {SCANCODE_4, 1},
+ {SCANCODE_5, 1},
+ {SCANCODE_6, 1},
+ {SCANCODE_7, 1},
+ {SCANCODE_8, 1},
});
BUILD_ASSERT(ARRAY_SIZE(buttons_8042) == KEYBOARD_BUTTON_COUNT);