am bdb706e4: Merge "Pipe through device resolution information" into jb-mr2-dev
* commit 'bdb706e48d71af498156efbb10d0f0c1fcef8878': Pipe through device resolution information
This commit is contained in:
@@ -24523,6 +24523,7 @@ package android.view {
|
||||
method public float getMax();
|
||||
method public float getMin();
|
||||
method public float getRange();
|
||||
method public float getResolution();
|
||||
method public int getSource();
|
||||
method public boolean isFromSource(int);
|
||||
}
|
||||
|
||||
@@ -371,8 +371,8 @@ public final class InputDevice implements Parcelable {
|
||||
if (axis < 0) {
|
||||
break;
|
||||
}
|
||||
addMotionRange(axis, in.readInt(),
|
||||
in.readFloat(), in.readFloat(), in.readFloat(), in.readFloat());
|
||||
addMotionRange(axis, in.readInt(), in.readFloat(), in.readFloat(), in.readFloat(),
|
||||
in.readFloat(), in.readFloat());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,8 +584,8 @@ public final class InputDevice implements Parcelable {
|
||||
|
||||
// Called from native code.
|
||||
private void addMotionRange(int axis, int source,
|
||||
float min, float max, float flat, float fuzz) {
|
||||
mMotionRanges.add(new MotionRange(axis, source, min, max, flat, fuzz));
|
||||
float min, float max, float flat, float fuzz, float resolution) {
|
||||
mMotionRanges.add(new MotionRange(axis, source, min, max, flat, fuzz, resolution));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -625,14 +625,17 @@ public final class InputDevice implements Parcelable {
|
||||
private float mMax;
|
||||
private float mFlat;
|
||||
private float mFuzz;
|
||||
private float mResolution;
|
||||
|
||||
private MotionRange(int axis, int source, float min, float max, float flat, float fuzz) {
|
||||
private MotionRange(int axis, int source, float min, float max, float flat, float fuzz,
|
||||
float resolution) {
|
||||
mAxis = axis;
|
||||
mSource = source;
|
||||
mMin = min;
|
||||
mMax = max;
|
||||
mFlat = flat;
|
||||
mFuzz = fuzz;
|
||||
mResolution = resolution;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -711,6 +714,14 @@ public final class InputDevice implements Parcelable {
|
||||
public float getFuzz() {
|
||||
return mFuzz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resolution for input device measurements with respect to this axis.
|
||||
* @return The resolution in units per millimeter, or units per radian for rotational axes.
|
||||
*/
|
||||
public float getResolution() {
|
||||
return mResolution;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -734,6 +745,7 @@ public final class InputDevice implements Parcelable {
|
||||
out.writeFloat(range.mMax);
|
||||
out.writeFloat(range.mFlat);
|
||||
out.writeFloat(range.mFuzz);
|
||||
out.writeFloat(range.mResolution);
|
||||
}
|
||||
out.writeInt(-1);
|
||||
}
|
||||
@@ -788,6 +800,7 @@ public final class InputDevice implements Parcelable {
|
||||
description.append(" max=").append(range.mMax);
|
||||
description.append(" flat=").append(range.mFlat);
|
||||
description.append(" fuzz=").append(range.mFuzz);
|
||||
description.append(" resolution=").append(range.mResolution);
|
||||
description.append("\n");
|
||||
}
|
||||
return description.toString();
|
||||
|
||||
@@ -62,8 +62,8 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
|
||||
const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
|
||||
for (size_t i = 0; i < ranges.size(); i++) {
|
||||
const InputDeviceInfo::MotionRange& range = ranges.itemAt(i);
|
||||
env->CallVoidMethod(inputDeviceObj.get(), gInputDeviceClassInfo.addMotionRange,
|
||||
range.axis, range.source, range.min, range.max, range.flat, range.fuzz);
|
||||
env->CallVoidMethod(inputDeviceObj.get(), gInputDeviceClassInfo.addMotionRange, range.axis,
|
||||
range.source, range.min, range.max, range.flat, range.fuzz, range.resolution);
|
||||
if (env->ExceptionCheck()) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ int register_android_view_InputDevice(JNIEnv* env)
|
||||
"<init>", "(IILjava/lang/String;Ljava/lang/String;ZIILandroid/view/KeyCharacterMap;Z)V");
|
||||
|
||||
GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz,
|
||||
"addMotionRange", "(IIFFFF)V");
|
||||
"addMotionRange", "(IIFFFFF)V");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
float max;
|
||||
float flat;
|
||||
float fuzz;
|
||||
float resolution;
|
||||
};
|
||||
|
||||
void initialize(int32_t id, int32_t generation, const InputDeviceIdentifier& identifier,
|
||||
@@ -83,7 +84,7 @@ public:
|
||||
|
||||
void addSource(uint32_t source);
|
||||
void addMotionRange(int32_t axis, uint32_t source,
|
||||
float min, float max, float flat, float fuzz);
|
||||
float min, float max, float flat, float fuzz, float resolution);
|
||||
void addMotionRange(const MotionRange& range);
|
||||
|
||||
inline void setKeyboardType(int32_t keyboardType) { mKeyboardType = keyboardType; }
|
||||
|
||||
@@ -172,8 +172,8 @@ void InputDeviceInfo::addSource(uint32_t source) {
|
||||
}
|
||||
|
||||
void InputDeviceInfo::addMotionRange(int32_t axis, uint32_t source, float min, float max,
|
||||
float flat, float fuzz) {
|
||||
MotionRange range = { axis, source, min, max, flat, fuzz };
|
||||
float flat, float fuzz, float resolution) {
|
||||
MotionRange range = { axis, source, min, max, flat, fuzz, resolution };
|
||||
mMotionRanges.add(range);
|
||||
}
|
||||
|
||||
|
||||
@@ -882,8 +882,9 @@ void InputDevice::dump(String8& dump) {
|
||||
snprintf(name, sizeof(name), "%d", range.axis);
|
||||
}
|
||||
dump.appendFormat(INDENT3 "%s: source=0x%08x, "
|
||||
"min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f\n",
|
||||
name, range.source, range.min, range.max, range.flat, range.fuzz);
|
||||
"min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
|
||||
name, range.source, range.min, range.max, range.flat, range.fuzz,
|
||||
range.resolution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2247,20 +2248,20 @@ void CursorInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
|
||||
if (mParameters.mode == Parameters::MODE_POINTER) {
|
||||
float minX, minY, maxX, maxY;
|
||||
if (mPointerController->getBounds(&minX, &minY, &maxX, &maxY)) {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, minX, maxX, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, minY, maxY, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, minX, maxX, 0.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, minY, maxY, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
} else {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_X, mSource, -1.0f, 1.0f, 0.0f, mXScale, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_Y, mSource, -1.0f, 1.0f, 0.0f, mYScale, 0.0f);
|
||||
}
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_PRESSURE, mSource, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
if (mCursorScrollAccumulator.haveRelativeVWheel()) {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
if (mCursorScrollAccumulator.haveRelativeHWheel()) {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2611,10 +2612,12 @@ void TouchInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
|
||||
}
|
||||
|
||||
if (mCursorScrollAccumulator.haveRelativeVWheel()) {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_VSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f);
|
||||
}
|
||||
if (mCursorScrollAccumulator.haveRelativeHWheel()) {
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f);
|
||||
info->addMotionRange(AMOTION_EVENT_AXIS_HSCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3063,6 +3066,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.touchMajor.max = diagonalSize;
|
||||
mOrientedRanges.touchMajor.flat = 0;
|
||||
mOrientedRanges.touchMajor.fuzz = 0;
|
||||
mOrientedRanges.touchMajor.resolution = 0;
|
||||
|
||||
mOrientedRanges.touchMinor = mOrientedRanges.touchMajor;
|
||||
mOrientedRanges.touchMinor.axis = AMOTION_EVENT_AXIS_TOUCH_MINOR;
|
||||
@@ -3073,6 +3077,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.toolMajor.max = diagonalSize;
|
||||
mOrientedRanges.toolMajor.flat = 0;
|
||||
mOrientedRanges.toolMajor.fuzz = 0;
|
||||
mOrientedRanges.toolMajor.resolution = 0;
|
||||
|
||||
mOrientedRanges.toolMinor = mOrientedRanges.toolMajor;
|
||||
mOrientedRanges.toolMinor.axis = AMOTION_EVENT_AXIS_TOOL_MINOR;
|
||||
@@ -3083,6 +3088,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.size.max = 1.0;
|
||||
mOrientedRanges.size.flat = 0;
|
||||
mOrientedRanges.size.fuzz = 0;
|
||||
mOrientedRanges.size.resolution = 0;
|
||||
} else {
|
||||
mSizeScale = 0.0f;
|
||||
}
|
||||
@@ -3106,6 +3112,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.pressure.max = 1.0;
|
||||
mOrientedRanges.pressure.flat = 0;
|
||||
mOrientedRanges.pressure.fuzz = 0;
|
||||
mOrientedRanges.pressure.resolution = 0;
|
||||
|
||||
// Tilt
|
||||
mTiltXCenter = 0;
|
||||
@@ -3129,6 +3136,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.tilt.max = M_PI_2;
|
||||
mOrientedRanges.tilt.flat = 0;
|
||||
mOrientedRanges.tilt.fuzz = 0;
|
||||
mOrientedRanges.tilt.resolution = 0;
|
||||
}
|
||||
|
||||
// Orientation
|
||||
@@ -3142,6 +3150,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.orientation.max = M_PI;
|
||||
mOrientedRanges.orientation.flat = 0;
|
||||
mOrientedRanges.orientation.fuzz = 0;
|
||||
mOrientedRanges.orientation.resolution = 0;
|
||||
} else if (mCalibration.orientationCalibration !=
|
||||
Calibration::ORIENTATION_CALIBRATION_NONE) {
|
||||
if (mCalibration.orientationCalibration
|
||||
@@ -3165,6 +3174,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.orientation.max = M_PI_2;
|
||||
mOrientedRanges.orientation.flat = 0;
|
||||
mOrientedRanges.orientation.fuzz = 0;
|
||||
mOrientedRanges.orientation.resolution = 0;
|
||||
}
|
||||
|
||||
// Distance
|
||||
@@ -3190,6 +3200,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.distance.flat = 0;
|
||||
mOrientedRanges.distance.fuzz =
|
||||
mRawPointerAxes.distance.fuzz * mDistanceScale;
|
||||
mOrientedRanges.distance.resolution = 0;
|
||||
}
|
||||
|
||||
// Compute oriented precision, scales and ranges.
|
||||
@@ -3204,12 +3215,14 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.x.min = mYTranslate;
|
||||
mOrientedRanges.x.max = mSurfaceHeight + mYTranslate - 1;
|
||||
mOrientedRanges.x.flat = 0;
|
||||
mOrientedRanges.x.fuzz = mYScale;
|
||||
mOrientedRanges.x.fuzz = 0;
|
||||
mOrientedRanges.x.resolution = mRawPointerAxes.y.resolution * mYScale;
|
||||
|
||||
mOrientedRanges.y.min = mXTranslate;
|
||||
mOrientedRanges.y.max = mSurfaceWidth + mXTranslate - 1;
|
||||
mOrientedRanges.y.flat = 0;
|
||||
mOrientedRanges.y.fuzz = mXScale;
|
||||
mOrientedRanges.y.fuzz = 0;
|
||||
mOrientedRanges.y.resolution = mRawPointerAxes.x.resolution * mXScale;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -3219,12 +3232,14 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) {
|
||||
mOrientedRanges.x.min = mXTranslate;
|
||||
mOrientedRanges.x.max = mSurfaceWidth + mXTranslate - 1;
|
||||
mOrientedRanges.x.flat = 0;
|
||||
mOrientedRanges.x.fuzz = mXScale;
|
||||
mOrientedRanges.x.fuzz = 0;
|
||||
mOrientedRanges.x.resolution = mRawPointerAxes.x.resolution * mXScale;
|
||||
|
||||
mOrientedRanges.y.min = mYTranslate;
|
||||
mOrientedRanges.y.max = mSurfaceHeight + mYTranslate - 1;
|
||||
mOrientedRanges.y.flat = 0;
|
||||
mOrientedRanges.y.fuzz = mYScale;
|
||||
mOrientedRanges.y.fuzz = 0;
|
||||
mOrientedRanges.y.resolution = mRawPointerAxes.y.resolution * mYScale;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6045,10 +6060,10 @@ void JoystickInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
|
||||
for (size_t i = 0; i < mAxes.size(); i++) {
|
||||
const Axis& axis = mAxes.valueAt(i);
|
||||
info->addMotionRange(axis.axisInfo.axis, AINPUT_SOURCE_JOYSTICK,
|
||||
axis.min, axis.max, axis.flat, axis.fuzz);
|
||||
axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
|
||||
if (axis.axisInfo.mode == AxisInfo::MODE_SPLIT) {
|
||||
info->addMotionRange(axis.axisInfo.highAxis, AINPUT_SOURCE_JOYSTICK,
|
||||
axis.min, axis.max, axis.flat, axis.fuzz);
|
||||
axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6078,8 +6093,8 @@ void JoystickInputMapper::dump(String8& dump) {
|
||||
dump.append(" (invert)");
|
||||
}
|
||||
|
||||
dump.appendFormat(": min=%0.5f, max=%0.5f, flat=%0.5f, fuzz=%0.5f\n",
|
||||
axis.min, axis.max, axis.flat, axis.fuzz);
|
||||
dump.appendFormat(": min=%0.5f, max=%0.5f, flat=%0.5f, fuzz=%0.5f, resolution=%0.5f\n",
|
||||
axis.min, axis.max, axis.flat, axis.fuzz, axis.resolution);
|
||||
dump.appendFormat(INDENT4 " scale=%0.5f, offset=%0.5f, "
|
||||
"highScale=%0.5f, highOffset=%0.5f\n",
|
||||
axis.scale, axis.offset, axis.highScale, axis.highOffset);
|
||||
@@ -6125,18 +6140,21 @@ void JoystickInputMapper::configure(nsecs_t when,
|
||||
float highScale = 1.0f / (rawAxisInfo.maxValue - axisInfo.splitValue);
|
||||
axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
|
||||
scale, 0.0f, highScale, 0.0f,
|
||||
0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale);
|
||||
0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
|
||||
rawAxisInfo.resolution * scale);
|
||||
} else if (isCenteredAxis(axisInfo.axis)) {
|
||||
float scale = 2.0f / (rawAxisInfo.maxValue - rawAxisInfo.minValue);
|
||||
float offset = avg(rawAxisInfo.minValue, rawAxisInfo.maxValue) * -scale;
|
||||
axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
|
||||
scale, offset, scale, offset,
|
||||
-1.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale);
|
||||
-1.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
|
||||
rawAxisInfo.resolution * scale);
|
||||
} else {
|
||||
float scale = 1.0f / (rawAxisInfo.maxValue - rawAxisInfo.minValue);
|
||||
axis.initialize(rawAxisInfo, axisInfo, explicitlyMapped,
|
||||
scale, 0.0f, scale, 0.0f,
|
||||
0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale);
|
||||
0.0f, 1.0f, rawFlat * scale, rawAxisInfo.fuzz * scale,
|
||||
rawAxisInfo.resolution * scale);
|
||||
}
|
||||
|
||||
// To eliminate noise while the joystick is at rest, filter out small variations
|
||||
|
||||
@@ -1730,10 +1730,11 @@ private:
|
||||
float highScale; // scale factor from raw to normalized values of high split
|
||||
float highOffset; // offset to add after scaling for normalization of high split
|
||||
|
||||
float min; // normalized inclusive minimum
|
||||
float max; // normalized inclusive maximum
|
||||
float flat; // normalized flat region size
|
||||
float fuzz; // normalized error tolerance
|
||||
float min; // normalized inclusive minimum
|
||||
float max; // normalized inclusive maximum
|
||||
float flat; // normalized flat region size
|
||||
float fuzz; // normalized error tolerance
|
||||
float resolution; // normalized resolution in units/mm
|
||||
|
||||
float filter; // filter out small variations of this size
|
||||
float currentValue; // current value
|
||||
@@ -1744,7 +1745,7 @@ private:
|
||||
void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo,
|
||||
bool explicitlyMapped, float scale, float offset,
|
||||
float highScale, float highOffset,
|
||||
float min, float max, float flat, float fuzz) {
|
||||
float min, float max, float flat, float fuzz, float resolution) {
|
||||
this->rawAxisInfo = rawAxisInfo;
|
||||
this->axisInfo = axisInfo;
|
||||
this->explicitlyMapped = explicitlyMapped;
|
||||
@@ -1756,6 +1757,7 @@ private:
|
||||
this->max = max;
|
||||
this->flat = flat;
|
||||
this->fuzz = fuzz;
|
||||
this->resolution = resolution;
|
||||
this->filter = 0;
|
||||
resetValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user