mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-26 15:55:31 +02:00
Attempting to make it easier to work with a single device. Still not bound to the new controlService.
This commit is contained in:
59
res/app/scripts/services/controlService.js
Normal file
59
res/app/scripts/services/controlService.js
Normal file
@@ -0,0 +1,59 @@
|
||||
define(['./module', 'lodash'], function(mod, _) {
|
||||
function ControlServiceFactory($rootScope, socket) {
|
||||
var controlService = {
|
||||
members: []
|
||||
}
|
||||
|
||||
function touchSender(type) {
|
||||
return function(x, y) {
|
||||
socket.emit(type, {
|
||||
x: x
|
||||
, y: y
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
|
||||
return controlService
|
||||
}
|
||||
|
||||
mod.factory('controlService'
|
||||
, [ '$rootScope'
|
||||
, 'socketService'
|
||||
, ControlServiceFactory
|
||||
])
|
||||
})
|
||||
Reference in New Issue
Block a user