mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 08:33:24 +02:00
Added stf namespace.
This commit is contained in:
55
res/app/components/stf/control/control-service.js
Normal file
55
res/app/components/stf/control/control-service.js
Normal file
@@ -0,0 +1,55 @@
|
||||
module.exports = function ControlServiceFactory($rootScope, socket) {
|
||||
var controlService = {
|
||||
}
|
||||
|
||||
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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
controlService.forChannel = function (channel) {
|
||||
return new ControlService(channel)
|
||||
}
|
||||
|
||||
return controlService
|
||||
}
|
||||
Reference in New Issue
Block a user