summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/media/stagefright/AudioSource.h6
-rw-r--r--include/ui/Input.h85
-rw-r--r--include/ui/KeyLayoutMap.h12
-rw-r--r--include/ui/Keyboard.h12
-rwxr-xr-xinclude/ui/KeycodeLabels.h43
5 files changed, 93 insertions, 65 deletions
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index b35a6e6..9e6f0e2 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -59,12 +59,12 @@ private:
// After the initial mute, we raise the volume linearly
// over kAutoRampDurationUs.
- kAutoRampDurationUs = 700000,
+ kAutoRampDurationUs = 300000,
// This is the initial mute duration to suppress
// the video recording signal tone
- kAutoRampStartUs = 1000000,
- };
+ kAutoRampStartUs = 0,
+ };
Mutex mLock;
Condition mFrameAvailableCondition;
diff --git a/include/ui/Input.h b/include/ui/Input.h
index b7b5a8d..86ce098 100644
--- a/include/ui/Input.h
+++ b/include/ui/Input.h
@@ -170,10 +170,10 @@ struct InputConfiguration {
* Pointer coordinate data.
*/
struct PointerCoords {
- static const size_t MAX_AXES = 15; // 15 so that sizeof(PointerCoords) == 16 * 4 == 64
+ enum { MAX_AXES = 14 }; // 14 so that sizeof(PointerCoords) == 64
// Bitfield of axes that are present in this structure.
- uint32_t bits; // 32bits are enough for now, can raise to 64bit when needed
+ uint64_t bits;
// Values of axes that are stored in this structure packed in order by axis id
// for each axis that is present in the structure according to 'bits'.
@@ -183,40 +183,9 @@ struct PointerCoords {
bits = 0;
}
- inline float getAxisValue(int32_t axis) const {
- uint32_t axisBit = 1 << axis;
- if (!(bits & axisBit)) {
- return 0;
- }
- uint32_t index = __builtin_popcount(bits & (axisBit - 1));
- return values[index];
- }
-
- inline void setAxisValue(int32_t axis, float value) {
- uint32_t axisBit = 1 << axis;
- uint32_t index = __builtin_popcount(bits & (axisBit - 1));
- if (!(bits & axisBit)) {
- uint32_t count = __builtin_popcount(bits);
- if (count >= MAX_AXES) {
- tooManyAxes(axis);
- return;
- }
- bits |= axisBit;
- for (uint32_t i = count; i > index; i--) {
- values[i] = values[i - 1];
- }
- }
- values[index] = value;
- }
-
- inline float* editAxisValue(int32_t axis) {
- uint32_t axisBit = 1 << axis;
- if (!(bits & axisBit)) {
- return NULL;
- }
- uint32_t index = __builtin_popcount(bits & (axisBit - 1));
- return &values[index];
- }
+ float getAxisValue(int32_t axis) const;
+ status_t setAxisValue(int32_t axis, float value);
+ float* editAxisValue(int32_t axis);
#ifdef HAVE_ANDROID_OS
status_t readFromParcel(Parcel* parcel);
@@ -351,49 +320,49 @@ public:
float getRawAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getRawX(size_t pointerIndex) const {
- return getRawAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex);
+ return getRawAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
}
inline float getRawY(size_t pointerIndex) const {
- return getRawAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex);
+ return getRawAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
}
float getAxisValue(int32_t axis, size_t pointerIndex) const;
inline float getX(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_X, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_X, pointerIndex);
}
inline float getY(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_Y, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_Y, pointerIndex);
}
inline float getPressure(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_PRESSURE, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pointerIndex);
}
inline float getSize(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_SIZE, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_SIZE, pointerIndex);
}
inline float getTouchMajor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex);
}
inline float getTouchMinor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex);
}
inline float getToolMajor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex);
}
inline float getToolMinor(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex);
}
inline float getOrientation(size_t pointerIndex) const {
- return getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex);
+ return getAxisValue(AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex);
}
inline size_t getHistorySize() const { return mSampleEventTimes.size() - 1; }
@@ -410,59 +379,59 @@ public:
inline float getHistoricalRawX(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalRawAxisValue(
- AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
}
inline float getHistoricalRawY(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalRawAxisValue(
- AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
}
float getHistoricalAxisValue(int32_t axis, size_t pointerIndex, size_t historicalIndex) const;
inline float getHistoricalX(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_X, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_X, pointerIndex, historicalIndex);
}
inline float getHistoricalY(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_Y, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_Y, pointerIndex, historicalIndex);
}
inline float getHistoricalPressure(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_PRESSURE, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_PRESSURE, pointerIndex, historicalIndex);
}
inline float getHistoricalSize(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_SIZE, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_SIZE, pointerIndex, historicalIndex);
}
inline float getHistoricalTouchMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOUCH_MAJOR, pointerIndex, historicalIndex);
}
inline float getHistoricalTouchMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOUCH_MINOR, pointerIndex, historicalIndex);
}
inline float getHistoricalToolMajor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOOL_MAJOR, pointerIndex, historicalIndex);
}
inline float getHistoricalToolMinor(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_TOOL_MINOR, pointerIndex, historicalIndex);
}
inline float getHistoricalOrientation(size_t pointerIndex, size_t historicalIndex) const {
return getHistoricalAxisValue(
- AINPUT_MOTION_AXIS_ORIENTATION, pointerIndex, historicalIndex);
+ AMOTION_EVENT_AXIS_ORIENTATION, pointerIndex, historicalIndex);
}
void initialize(
diff --git a/include/ui/KeyLayoutMap.h b/include/ui/KeyLayoutMap.h
index f0a6d00..904c8f3 100644
--- a/include/ui/KeyLayoutMap.h
+++ b/include/ui/KeyLayoutMap.h
@@ -25,7 +25,7 @@
namespace android {
/**
- * Describes a mapping from keyboard scan codes to Android key codes.
+ * Describes a mapping from keyboard scan codes and joystick axes to Android key codes and axes.
*/
class KeyLayoutMap {
public:
@@ -33,8 +33,10 @@ public:
static status_t load(const String8& filename, KeyLayoutMap** outMap);
- status_t map(int32_t scanCode, int32_t* keyCode, uint32_t* flags) const;
- status_t findScanCodes(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
+ status_t mapKey(int32_t scanCode, int32_t* keyCode, uint32_t* flags) const;
+ status_t findScanCodesForKey(int32_t keyCode, Vector<int32_t>* outScanCodes) const;
+
+ status_t mapAxis(int32_t scanCode, int32_t* axis) const;
private:
struct Key {
@@ -42,7 +44,8 @@ private:
uint32_t flags;
};
- KeyedVector<int32_t,Key> mKeys;
+ KeyedVector<int32_t, Key> mKeys;
+ KeyedVector<int32_t, int32_t> mAxes;
KeyLayoutMap();
@@ -57,6 +60,7 @@ private:
private:
status_t parseKey();
+ status_t parseAxis();
};
};
diff --git a/include/ui/Keyboard.h b/include/ui/Keyboard.h
index 50296e2..54bc968 100644
--- a/include/ui/Keyboard.h
+++ b/include/ui/Keyboard.h
@@ -111,6 +111,18 @@ extern int32_t getKeyCodeByLabel(const char* label);
extern uint32_t getKeyFlagByLabel(const char* label);
/**
+ * Gets a 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.
+ * Returns NULL if unknown.
+ */
+extern const char* getAxisLabel(int32_t axisId);
+
+/**
* 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/ui/KeycodeLabels.h b/include/ui/KeycodeLabels.h
index dbccf29..bdfbf7c 100755
--- a/include/ui/KeycodeLabels.h
+++ b/include/ui/KeycodeLabels.h
@@ -250,4 +250,47 @@ static const KeycodeLabel FLAGS[] = {
{ NULL, 0 }
};
+static const KeycodeLabel AXES[] = {
+ { "X", 0 },
+ { "Y", 1 },
+ { "PRESSURE", 2 },
+ { "SIZE", 3 },
+ { "TOUCH_MAJOR", 4 },
+ { "TOUCH_MINOR", 5 },
+ { "TOOL_MAJOR", 6 },
+ { "TOOL_MINOR", 7 },
+ { "ORIENTATION", 8 },
+ { "VSCROLL", 9 },
+ { "HSCROLL", 10 },
+ { "Z", 11 },
+ { "RX", 12 },
+ { "RY", 13 },
+ { "RZ", 14 },
+ { "HAT_X", 15 },
+ { "HAT_Y", 16 },
+ { "LTRIGGER", 17 },
+ { "RTRIGGER", 18 },
+ { "GENERIC_1", 32 },
+ { "GENERIC_2", 33 },
+ { "GENERIC_3", 34 },
+ { "GENERIC_4", 35 },
+ { "GENERIC_5", 36 },
+ { "GENERIC_6", 37 },
+ { "GENERIC_7", 38 },
+ { "GENERIC_8", 39 },
+ { "GENERIC_9", 40 },
+ { "GENERIC_10", 41 },
+ { "GENERIC_11", 42 },
+ { "GENERIC_12", 43 },
+ { "GENERIC_13", 44 },
+ { "GENERIC_14", 45 },
+ { "GENERIC_15", 46 },
+ { "GENERIC_16", 47 },
+
+ // NOTE: If you add a new axis here you must also add it to several other files.
+ // Refer to frameworks/base/core/java/android/view/MotionEvent.java for the full list.
+
+ { NULL, -1 }
+};
+
#endif // _UI_KEYCODE_LABELS_H