mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-21 16:25:13 +02:00
Initial device control implementation. Works with touches and NUMERIC keycodes.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
define(['./_module'], function(controllers) {
|
||||
function DeviceControlCtrl($scope, $routeParams, deviceService) {
|
||||
function DeviceControlCtrl($scope, $routeParams, deviceService, controlService) {
|
||||
$scope.device = null
|
||||
$scope.control = null
|
||||
|
||||
deviceService.get($routeParams.serial)
|
||||
.then(function(device) {
|
||||
$scope.device = device
|
||||
$scope.control = controlService.forChannel(device.channel)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -12,6 +14,7 @@ define(['./_module'], function(controllers) {
|
||||
, [ '$scope'
|
||||
, '$routeParams'
|
||||
, 'DeviceService'
|
||||
, 'ControlService'
|
||||
, DeviceControlCtrl
|
||||
])
|
||||
})
|
||||
|
||||
@@ -1,51 +1,56 @@
|
||||
define(['./_module', 'lodash'], function(services, _) {
|
||||
function ControlServiceFactory($rootScope, socket) {
|
||||
var controlService = {
|
||||
members: []
|
||||
}
|
||||
|
||||
function touchSender(type) {
|
||||
return function(x, y) {
|
||||
socket.emit(type, {
|
||||
x: x
|
||||
, y: y
|
||||
function ControlService(channel) {
|
||||
function touchSender(type) {
|
||||
return function(x, y) {
|
||||
socket.emit(type, channel, {
|
||||
x: x
|
||||
, y: y
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function keySender(type) {
|
||||
return function(key) {
|
||||
socket.emit(type, channel, {
|
||||
key: key
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
this.touchDown = touchSender('input.touchDown')
|
||||
this.touchMove = touchSender('input.touchMove')
|
||||
this.touchUp = touchSender('input.touchUp')
|
||||
this.tap = touchSender('input.tap')
|
||||
|
||||
this.keyDown = keySender('input.keyDown')
|
||||
this.keyUp = keySender('input.keyUp')
|
||||
this.keyPress = keySender('input.keyPress')
|
||||
|
||||
this.home = function() {
|
||||
socket.emit('input.home', channel)
|
||||
}
|
||||
|
||||
this.menu = function() {
|
||||
socket.emit('input.menu', channel)
|
||||
}
|
||||
|
||||
this.back = function() {
|
||||
socket.emit('input.back', channel)
|
||||
}
|
||||
|
||||
this.type = function(text) {
|
||||
socket.emit('input.type', channel, {
|
||||
text: text
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function keySender(type) {
|
||||
return function(key) {
|
||||
socket.emit(type, {
|
||||
key: key
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
controlService.touchDown = touchSender('input.touchDown')
|
||||
controlService.touchMove = touchSender('input.touchMove')
|
||||
controlService.touchUp = touchSender('input.touchUp')
|
||||
controlService.tap = touchSender('input.tap')
|
||||
|
||||
controlService.keyDown = keySender('input.keyDown')
|
||||
controlService.keyUp = keySender('input.keyUp')
|
||||
controlService.keyPress = keySender('input.keyPress')
|
||||
|
||||
controlService.home = function() {
|
||||
socket.emit('input.home')
|
||||
}
|
||||
|
||||
controlService.menu = function() {
|
||||
socket.emit('input.menu')
|
||||
}
|
||||
|
||||
controlService.back = function() {
|
||||
socket.emit('input.back')
|
||||
}
|
||||
|
||||
controlService.type = function(text) {
|
||||
socket.emit('input.type', {
|
||||
text: text
|
||||
})
|
||||
controlService.forChannel = function(channel) {
|
||||
return new ControlService(channel)
|
||||
}
|
||||
|
||||
return controlService
|
||||
|
||||
Reference in New Issue
Block a user