mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 13:53:22 +02:00
Fix touch coordinates on Yoga Tablet 8.
This commit is contained in:
@@ -14,7 +14,8 @@ module.exports = syrup.serial()
|
||||
.dependency(require('../support/adb'))
|
||||
.dependency(require('../support/router'))
|
||||
.dependency(require('../resources/minitouch'))
|
||||
.define(function(options, adb, router, minitouch) {
|
||||
.dependency(require('./flags'))
|
||||
.define(function(options, adb, router, minitouch, flags) {
|
||||
var log = logger.createLogger('device:plugins:touch')
|
||||
var plugin = Object.create(null)
|
||||
|
||||
@@ -94,12 +95,34 @@ module.exports = syrup.serial()
|
||||
socket.write(command)
|
||||
}
|
||||
|
||||
var getX = function(point) {
|
||||
return Math.floor(point.x * socket.maxX)
|
||||
}
|
||||
|
||||
var getY = function(point) {
|
||||
return Math.floor(point.y * socket.maxY)
|
||||
}
|
||||
|
||||
switch (flags.get('forceTouchOrigin', 'top left')) {
|
||||
case 'bottom left':
|
||||
// So far the only device we've seen exhibiting this behavior
|
||||
// is Yoga Tablet 8.
|
||||
log.info('Touch origin is bottom left')
|
||||
getX = function(point) {
|
||||
return Math.floor((1 - point.y) * socket.maxX)
|
||||
}
|
||||
getY = function(point) {
|
||||
return Math.floor(point.x * socket.maxY)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
plugin.touchDown = function(point) {
|
||||
send(util.format(
|
||||
'd %s %s %s %s\n'
|
||||
, point.contact
|
||||
, Math.floor(point.x * socket.maxX)
|
||||
, Math.floor(point.y * socket.maxY)
|
||||
, getX(point)
|
||||
, getY(point)
|
||||
, Math.floor((point.pressure || 0.5) * socket.maxPressure)
|
||||
))
|
||||
}
|
||||
@@ -108,8 +131,8 @@ module.exports = syrup.serial()
|
||||
send(util.format(
|
||||
'm %s %s %s %s\n'
|
||||
, point.contact
|
||||
, Math.floor(point.x * socket.maxX)
|
||||
, Math.floor(point.y * socket.maxY)
|
||||
, getX(point)
|
||||
, getY(point)
|
||||
, Math.floor((point.pressure || 0.5) * socket.maxPressure)
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user