mirror of
https://github.com/openstf/stf
synced 2025-10-05 19:42:01 +02:00
Initial device control implementation. Works with touches and NUMERIC keycodes.
This commit is contained in:
parent
ad0651a3b6
commit
0e0783b649
5 changed files with 88 additions and 54 deletions
|
@ -8,6 +8,7 @@ var validator = require('express-validator')
|
|||
var socketio = require('socket.io')
|
||||
var zmq = require('zmq')
|
||||
var Promise = require('bluebird')
|
||||
var adb = require('adbkit')
|
||||
|
||||
var logger = require('../util/logger')
|
||||
var pathutil = require('../util/pathutil')
|
||||
|
@ -240,9 +241,9 @@ module.exports = function(options) {
|
|||
})
|
||||
|
||||
function touchSender(klass) {
|
||||
return function(data) {
|
||||
return function(channel, data) {
|
||||
push.send([
|
||||
user.group
|
||||
channel
|
||||
, wireutil.envelope(new klass(
|
||||
data.x
|
||||
, data.y
|
||||
|
@ -252,9 +253,9 @@ module.exports = function(options) {
|
|||
}
|
||||
|
||||
function keySender(klass) {
|
||||
return function(data) {
|
||||
return function(channel, data) {
|
||||
push.send([
|
||||
user.group
|
||||
channel
|
||||
, wireutil.envelope(new klass(
|
||||
data.key
|
||||
))
|
||||
|
@ -271,19 +272,40 @@ module.exports = function(options) {
|
|||
socket.on('input.keyUp', keySender(wire.KeyUpMessage))
|
||||
socket.on('input.keyPress', keySender(wire.KeyPressMessage))
|
||||
|
||||
socket.on('input.type', function(data) {
|
||||
socket.on('input.type', function(channel, data) {
|
||||
push.send([
|
||||
group
|
||||
channel
|
||||
, wireutil.envelope(new wire.TypeMessage(
|
||||
data.text
|
||||
))
|
||||
])
|
||||
})
|
||||
|
||||
// @todo
|
||||
socket.on('input.back', function(data) {})
|
||||
socket.on('input.home', function(data) {})
|
||||
socket.on('input.menu', function(data) {})
|
||||
function fixedKeySender(klass, key) {
|
||||
return function(channel) {
|
||||
push.send([
|
||||
channel
|
||||
, wireutil.envelope(new klass(
|
||||
key
|
||||
))
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
socket.on('input.back', fixedKeySender(
|
||||
wire.KeyPressMessage
|
||||
, adb.Keycode.KEYCODE_BACK
|
||||
))
|
||||
|
||||
socket.on('input.home', fixedKeySender(
|
||||
wire.KeyPressMessage
|
||||
, adb.Keycode.KEYCODE_HOME
|
||||
))
|
||||
|
||||
socket.on('input.menu', fixedKeySender(
|
||||
wire.KeyPressMessage
|
||||
, adb.Keycode.KEYCODE_MENU
|
||||
))
|
||||
|
||||
socket.on('flick', function(data) {})
|
||||
socket.on('back', function(data) {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue