summaryrefslogtreecommitdiffstats
path: root/include/input
diff options
context:
space:
mode:
Diffstat (limited to 'include/input')
-rw-r--r--include/input/Input.h50
-rw-r--r--include/input/InputDevice.h5
-rw-r--r--include/input/KeyLayoutMap.h10
-rw-r--r--include/input/Keyboard.h10
-rw-r--r--include/input/KeycodeLabels.h24
5 files changed, 87 insertions, 12 deletions
diff --git a/include/input/Input.h b/include/input/Input.h
index 44e4027..235813e 100644
--- a/include/input/Input.h
+++ b/include/input/Input.h
@@ -22,11 +22,12 @@
*/
#include <android/input.h>
-#include <utils/Vector.h>
+#include <utils/BitSet.h>
#include <utils/KeyedVector.h>
-#include <utils/Timers.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
+#include <utils/Timers.h>
+#include <utils/Vector.h>
#include <stdint.h>
/*
@@ -66,6 +67,34 @@ enum {
AINPUT_SOURCE_SWITCH = 0x80000000,
};
+enum {
+ /**
+ * Constants for LEDs. Hidden from the API since we don't actually expose a way to interact
+ * with LEDs to developers
+ *
+ * NOTE: If you add LEDs here, you must also add them to KeycodeLabels.h
+ */
+
+ ALED_NUM_LOCK = 0x00,
+ ALED_CAPS_LOCK = 0x01,
+ ALED_SCROLL_LOCK = 0x02,
+ ALED_COMPOSE = 0x03,
+ ALED_KANA = 0x04,
+ ALED_SLEEP = 0x05,
+ ALED_SUSPEND = 0x06,
+ ALED_MUTE = 0x07,
+ ALED_MISC = 0x08,
+ ALED_MAIL = 0x09,
+ ALED_CHARGING = 0x0a,
+ ALED_CONTROLLER_1 = 0x10,
+ ALED_CONTROLLER_2 = 0x11,
+ ALED_CONTROLLER_3 = 0x12,
+ ALED_CONTROLLER_4 = 0x13,
+};
+
+/* Maximum number of controller LEDs we support */
+#define MAX_CONTROLLER_LEDS 4
+
/*
* SystemUiVisibility constants from View.
*/
@@ -155,13 +184,9 @@ enum {
/* These flags are set by the input reader policy as it intercepts each event. */
- // Indicates that the screen was off when the event was received and the event
- // should wake the device.
- POLICY_FLAG_WOKE_HERE = 0x10000000,
-
- // Indicates that the screen was dim when the event was received and the event
- // should brighten the device.
- POLICY_FLAG_BRIGHT_HERE = 0x20000000,
+ // Indicates that the device was in an interactive state when the
+ // event was intercepted.
+ POLICY_FLAG_INTERACTIVE = 0x20000000,
// Indicates that the event should be dispatched to applications.
// The input event should still be sent to the InputDispatcher so that it can see all
@@ -183,13 +208,18 @@ struct PointerCoords {
float values[MAX_AXES];
inline void clear() {
- bits = 0;
+ BitSet64::clear(bits);
+ }
+
+ bool isEmpty() const {
+ return BitSet64::isEmpty(bits);
}
float getAxisValue(int32_t axis) const;
status_t setAxisValue(int32_t axis, float value);
void scale(float scale);
+ void applyOffset(float xOffset, float yOffset);
inline float getX() const {
return getAxisValue(AMOTION_EVENT_AXIS_X);
diff --git a/include/input/InputDevice.h b/include/input/InputDevice.h
index 1419b45..adf9fb9 100644
--- a/include/input/InputDevice.h
+++ b/include/input/InputDevice.h
@@ -46,6 +46,11 @@ struct InputDeviceIdentifier {
// Ideally, the way this value is computed should not change between Android releases
// because that would invalidate persistent settings that rely on it.
String8 descriptor;
+
+ // A value added to uniquely identify a device in the absence of a unique id. This
+ // is intended to be a minimum way to distinguish from other active devices and may
+ // reuse values that are not associated with an input anymore.
+ uint16_t nonce;
};
/*
diff --git a/include/input/KeyLayoutMap.h b/include/input/KeyLayoutMap.h
index eec11cf..1e8de71 100644
--- a/include/input/KeyLayoutMap.h
+++ b/include/input/KeyLayoutMap.h
@@ -67,6 +67,8 @@ public:
status_t mapKey(int32_t scanCode, int32_t usageCode,
int32_t* outKeyCode, uint32_t* outFlags) const;
status_t findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
+ status_t findScanCodeForLed(int32_t ledCode, int32_t* outScanCode) const;
+ status_t findUsageCodeForLed(int32_t ledCode, int32_t* outUsageCode) const;
status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const;
@@ -79,9 +81,16 @@ private:
uint32_t flags;
};
+ struct Led {
+ int32_t ledCode;
+ };
+
+
KeyedVector<int32_t, Key> mKeysByScanCode;
KeyedVector<int32_t, Key> mKeysByUsageCode;
KeyedVector<int32_t, AxisInfo> mAxes;
+ KeyedVector<int32_t, Led> mLedsByScanCode;
+ KeyedVector<int32_t, Led> mLedsByUsageCode;
KeyLayoutMap();
@@ -99,6 +108,7 @@ private:
private:
status_t parseKey();
status_t parseAxis();
+ status_t parseLed();
};
};
diff --git a/include/input/Keyboard.h b/include/input/Keyboard.h
index 846cb0c..25b2f07 100644
--- a/include/input/Keyboard.h
+++ b/include/input/Keyboard.h
@@ -94,18 +94,24 @@ extern int32_t getKeyCodeByLabel(const char* label);
extern uint32_t getKeyFlagByLabel(const char* label);
/**
- * Gets a axis by its short form label, eg. "X".
+ * Gets an axis by its short form label, eg. "X".
* Returns -1 if unknown.
*/
extern int32_t getAxisByLabel(const char* label);
/**
- * Gets a axis label by its id.
+ * Gets an axis label by its id.
* Returns NULL if unknown.
*/
extern const char* getAxisLabel(int32_t axisId);
/**
+ * Gets an LED by its short form label, eg. "CAPS_LOCK".
+ * Returns -1 if unknown.
+ */
+extern int32_t getLedByLabel(const char* label);
+
+/**
* Updates a meta state field when a key is pressed or released.
*/
extern int32_t updateMetaState(int32_t keyCode, bool down, int32_t oldMetaState);
diff --git a/include/input/KeycodeLabels.h b/include/input/KeycodeLabels.h
index c64c5d8..a8d63da 100644
--- a/include/input/KeycodeLabels.h
+++ b/include/input/KeycodeLabels.h
@@ -247,6 +247,8 @@ static const KeycodeLabel KEYCODES[] = {
{ "BRIGHTNESS_DOWN", 220 },
{ "BRIGHTNESS_UP", 221 },
{ "MEDIA_AUDIO_TRACK", 222 },
+ { "SLEEP", 223 },
+ { "WAKEUP", 224 },
// NOTE: If you add a new keycode here you must also add it to several other files.
// Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.
@@ -319,4 +321,26 @@ static const KeycodeLabel AXES[] = {
{ NULL, -1 }
};
+static const KeycodeLabel LEDS[] = {
+ { "NUM_LOCK", 0x00 },
+ { "CAPS_LOCK", 0x01 },
+ { "SCROLL_LOCK", 0x02 },
+ { "COMPOSE", 0x03 },
+ { "KANA", 0x04 },
+ { "SLEEP", 0x05 },
+ { "SUSPEND", 0x06 },
+ { "MUTE", 0x07 },
+ { "MISC", 0x08 },
+ { "MAIL", 0x09 },
+ { "CHARGING", 0x0a },
+ { "CONTROLLER_1", 0x10 },
+ { "CONTROLLER_2", 0x11 },
+ { "CONTROLLER_3", 0x12 },
+ { "CONTROLLER_4", 0x13 },
+
+ // NOTE: If you add new LEDs here, you must also add them to Input.h
+
+ { NULL, -1 }
+};
+
#endif // _LIBINPUT_KEYCODE_LABELS_H