From 5f2f9160f8e95b8f7b63e31bb8ce285aa4f0a8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6glund?= Date: Sat, 29 Aug 2015 21:52:53 +0200 Subject: [PATCH] Introduce DEVICE_ID_ANY, update operator == for KeyDef to match --- input/input_state.cpp | 1 + input/input_state.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/input/input_state.cpp b/input/input_state.cpp index 9cf5315733..c6923d338e 100644 --- a/input/input_state.cpp +++ b/input/input_state.cpp @@ -4,6 +4,7 @@ const char *GetDeviceName(int deviceId) { switch (deviceId) { + case DEVICE_ID_ANY: return "any"; case DEVICE_ID_DEFAULT: return "built-in"; case DEVICE_ID_KEYBOARD: return "kbd"; case DEVICE_ID_PAD_0: return "pad1"; diff --git a/input/input_state.h b/input/input_state.h index e839053a59..bf4cd7b5b5 100644 --- a/input/input_state.h +++ b/input/input_state.h @@ -19,6 +19,7 @@ // Default device IDs enum { + DEVICE_ID_ANY = -1, // Represents any device ID DEVICE_ID_DEFAULT = 0, // Old Android DEVICE_ID_KEYBOARD = 1, // PC keyboard, android keyboards DEVICE_ID_MOUSE = 2, // PC mouse only (not touchscreen!) @@ -94,7 +95,7 @@ public: return false; } bool operator == (const KeyDef &other) const { - if (deviceId != other.deviceId) return false; + if (deviceId != other.deviceId && deviceId != DEVICE_ID_ANY && other.deviceId != DEVICE_ID_ANY) return false; if (keyCode != other.keyCode) return false; return true; }