}
void TouchButtonAccumulator::configure(InputDevice* device) {
- mHaveBtnTouch = device->hasKey(BTN_TOUCH);
+ mHaveBtnTouch = device->hasKey(BTN_TOUCH) || device->hasKey(BTN_LEFT);
mHaveStylus = device->hasKey(BTN_TOOL_PEN)
|| device->hasKey(BTN_TOOL_RUBBER)
|| device->hasKey(BTN_TOOL_BRUSH)
}
void TouchButtonAccumulator::reset(InputDevice* device) {
- mBtnTouch = device->isKeyPressed(BTN_TOUCH);
+ mBtnTouch = device->isKeyPressed(BTN_TOUCH) || device->isKeyPressed(BTN_LEFT);
mBtnStylus = device->isKeyPressed(BTN_STYLUS);
// BTN_0 is what gets mapped for the HID usage Digitizers.SecondaryBarrelSwitch
mBtnStylus2 =
if (rawEvent->type == EV_KEY) {
switch (rawEvent->code) {
case BTN_TOUCH:
+ case BTN_LEFT:
mBtnTouch = rawEvent->value;
break;
case BTN_STYLUS:
configureSurface(when, &resetNeeded);
}
+ if (!changes || (changes & InputReaderConfiguration::CHANGE_DEVICE_ALIAS)) {
+ // Get 5-point calibration parameters
+ int *p = mCalibration.fiveCal;
+ p[6] = 0;
+ if (FILE *file = fopen("/data/misc/tscal/pointercal", "r")) {
+ if (fscanf(file, "%d %d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6]) == 7) {
+ p[0] *= mXScale, p[1] *= mYScale, p[3] *= mXScale, p[4] *= mYScale;
+ ALOGD("pointercal loaded ok");
+ }
+ fclose(file);
+ }
+ }
+
if (changes && resetNeeded) {
// Send reset, unless this is the first time the device has been configured,
// in which case the reader will call reset itself after all mappers are ready.
out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_PHYSICAL;
} else if (pressureCalibrationString == "amplitude") {
out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_AMPLITUDE;
+ } else if (pressureCalibrationString == "disable") {
+ out.pressureCalibration = Calibration::PRESSURE_CALIBRATION_DISABLE;
} else if (pressureCalibrationString != "default") {
ALOGW("Invalid value for touch.pressure.calibration: '%s'",
pressureCalibrationString.string());
if (mRawPointerAxes.pressure.valid) {
if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_DEFAULT) {
mCalibration.pressureCalibration = Calibration::PRESSURE_CALIBRATION_PHYSICAL;
+ } else if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_DISABLE) {
+ mRawPointerAxes.pressure.valid = false;
+ mCalibration.pressureCalibration = Calibration::PRESSURE_CALIBRATION_NONE;
}
} else {
mCalibration.pressureCalibration = Calibration::PRESSURE_CALIBRATION_NONE;
// Adjust X, Y, and coverage coords for surface orientation.
float x, y;
float left, top, right, bottom;
+ float x_temp = float(xTransformed - mRawPointerAxes.x.minValue);
+ float y_temp = float(yTransformed - mRawPointerAxes.y.minValue);
+ float x_cal, y_cal;
+ int *p = mCalibration.fiveCal;
+ if (p[6]) {
+ // Apply 5-point calibration algorithm
+ x_cal = (x_temp * p[0] + y_temp * p[1] + p[2] ) / p[6];
+ y_cal = (x_temp * p[3] + y_temp * p[4] + p[5] ) / p[6];
+ ALOGV("5cal: x_temp=%f y_temp=%f x_cal=%f y_cal=%f", x_temp, y_temp, x_cal, y_cal);
+ } else {
+ x_cal = x_temp * mXScale;
+ y_cal = y_temp * mYScale;
+ }
switch (mSurfaceOrientation) {
case DISPLAY_ORIENTATION_90:
- x = float(yTransformed - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
- y = float(mRawPointerAxes.x.maxValue - xTransformed) * mXScale + mXTranslate;
+ x = y_cal + mYTranslate;
+ y = mSurfaceWidth - x_cal + mXTranslate;
left = float(rawTop - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
right = float(rawBottom- mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
bottom = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
}
break;
case DISPLAY_ORIENTATION_180:
- x = float(mRawPointerAxes.x.maxValue - xTransformed) * mXScale + mXTranslate;
- y = float(mRawPointerAxes.y.maxValue - yTransformed) * mYScale + mYTranslate;
+ x = mSurfaceWidth - x_cal + mXTranslate;
+ y = mSurfaceHeight - y_cal + mYTranslate;
left = float(mRawPointerAxes.x.maxValue - rawRight) * mXScale + mXTranslate;
right = float(mRawPointerAxes.x.maxValue - rawLeft) * mXScale + mXTranslate;
bottom = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
}
break;
case DISPLAY_ORIENTATION_270:
- x = float(mRawPointerAxes.y.maxValue - yTransformed) * mYScale + mYTranslate;
- y = float(xTransformed - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
+ x = mSurfaceHeight - y_cal + mYTranslate;
+ y = x_cal + mXTranslate;
left = float(mRawPointerAxes.y.maxValue - rawBottom) * mYScale + mYTranslate;
right = float(mRawPointerAxes.y.maxValue - rawTop) * mYScale + mYTranslate;
bottom = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
}
break;
default:
- x = float(xTransformed - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
- y = float(yTransformed - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;
+ x = x_cal + mXTranslate;
+ y = y_cal + mYTranslate;
left = float(rawLeft - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
right = float(rawRight - mRawPointerAxes.x.minValue) * mXScale + mXTranslate;
bottom = float(rawBottom - mRawPointerAxes.y.minValue) * mYScale + mYTranslate;