mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 04:53:28 +02:00
Support pressure in touches. Attempt to fix らくらく phones with device data overrides, but even though all buttons are now clickable, they trigger too easily in the homescreen.
This commit is contained in:
@@ -14,7 +14,8 @@ module.exports = syrup.serial()
|
||||
.dependency(require('../support/router'))
|
||||
.dependency(require('../resources/remote'))
|
||||
.dependency(require('./display'))
|
||||
.define(function(options, adb, router, remote, display) {
|
||||
.dependency(require('./data'))
|
||||
.define(function(options, adb, router, remote, display, data) {
|
||||
var log = logger.createLogger('device:plugins:touch')
|
||||
var plugin = Object.create(null)
|
||||
|
||||
@@ -58,53 +59,84 @@ module.exports = syrup.serial()
|
||||
return openService()
|
||||
.then(function(monkey) {
|
||||
var queue = new SeqQueue()
|
||||
, pressure = (data && data.touch && data.touch.defaultPressure) || 50
|
||||
|
||||
log.info('Setting default pressure to %d', pressure)
|
||||
|
||||
plugin.touchDown = function(point) {
|
||||
modifyCoords(point)
|
||||
monkey.sendAsync([
|
||||
'touch down'
|
||||
, point.x
|
||||
, point.y
|
||||
, pressure
|
||||
].join(' '))
|
||||
.catch(function(err) {
|
||||
log.error('touchDown failed', err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
plugin.touchMove = function(point) {
|
||||
modifyCoords(point)
|
||||
monkey.sendAsync([
|
||||
'touch move'
|
||||
, point.x
|
||||
, point.y
|
||||
, pressure
|
||||
].join(' '))
|
||||
.catch(function(err) {
|
||||
log.error('touchMove failed', err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
plugin.touchUp = function(point) {
|
||||
modifyCoords(point)
|
||||
monkey.sendAsync([
|
||||
'touch up'
|
||||
, point.x
|
||||
, point.y
|
||||
, pressure
|
||||
].join(' '))
|
||||
.catch(function(err) {
|
||||
log.error('touchUp failed', err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
plugin.tap = function(point) {
|
||||
modifyCoords(point)
|
||||
monkey.sendAsync([
|
||||
'tap'
|
||||
, point.x
|
||||
, point.y
|
||||
, pressure
|
||||
].join(' '))
|
||||
.catch(function(err) {
|
||||
log.error('tap failed', err.stack)
|
||||
})
|
||||
}
|
||||
|
||||
router
|
||||
.on(wire.TouchDownMessage, function(channel, message) {
|
||||
modifyCoords(message)
|
||||
queue.push(message.seq, function() {
|
||||
monkey.touchDownAsync(message.x, message.y)
|
||||
.catch(function(err) {
|
||||
log.error('touchDown failed', err.stack)
|
||||
})
|
||||
plugin.touchDown(message)
|
||||
})
|
||||
})
|
||||
.on(wire.TouchMoveMessage, function(channel, message) {
|
||||
modifyCoords(message)
|
||||
queue.push(message.seq, function() {
|
||||
monkey.touchMoveAsync(message.x, message.y)
|
||||
.catch(function(err) {
|
||||
log.error('touchMove failed', err.stack)
|
||||
})
|
||||
plugin.touchMove(message)
|
||||
})
|
||||
})
|
||||
.on(wire.TouchUpMessage, function(channel, message) {
|
||||
modifyCoords(message)
|
||||
queue.push(message.seq, function() {
|
||||
monkey.touchUpAsync(message.x, message.y)
|
||||
.catch(function(err) {
|
||||
log.error('touchUp failed', err.stack)
|
||||
})
|
||||
plugin.touchUp(message)
|
||||
})
|
||||
|
||||
// Reset queue
|
||||
queue = new SeqQueue()
|
||||
})
|
||||
.on(wire.TapMessage, function(channel, message) {
|
||||
modifyCoords(message)
|
||||
monkey.tapAsync(message.x, message.y)
|
||||
.catch(function(err) {
|
||||
log.error('tap failed', err.stack)
|
||||
})
|
||||
plugin.tap(message)
|
||||
})
|
||||
|
||||
plugin.tap = function(coord) {
|
||||
modifyCoords(coord)
|
||||
monkey.tapAsync(coord.x, coord.y)
|
||||
.catch(function(err) {
|
||||
log.error('tap failed', err.stack)
|
||||
})
|
||||
}
|
||||
}).return(plugin)
|
||||
|
||||
})
|
||||
.return(plugin)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user