Initial device control implementation. Works with touches and NUMERIC keycodes.

This commit is contained in:
Simo Kinnunen
2014-02-06 11:54:19 +09:00
parent ad0651a3b6
commit 0e0783b649
5 changed files with 88 additions and 54 deletions

View File

@@ -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