fingerpoken 0.2.20101216024109 → 0.2.20101217123250
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/fingerpoken.rb +4 -1
- data/lib/fingerpoken/target.rb +23 -18
- data/lib/fingerpoken/tivo.rb +12 -0
- data/public/js/fingerpoken.js +16 -0
- data/views/index.haml +1 -1
- data/views/style.sass +3 -0
- metadata +4 -4
data/bin/fingerpoken.rb
CHANGED
@@ -63,7 +63,10 @@ def main(args)
|
|
63
63
|
ws.onmessage do |message|
|
64
64
|
request = JSON.parse(message)
|
65
65
|
puts "Request: #{request.inspect}"
|
66
|
-
channel.push(
|
66
|
+
channel.push(
|
67
|
+
:request => request,
|
68
|
+
:callback => proc { |message| ws.send(JSON.dump(message)) }
|
69
|
+
)
|
67
70
|
end # ws.onmessage
|
68
71
|
end # WebSocket
|
69
72
|
|
data/lib/fingerpoken/target.rb
CHANGED
@@ -7,25 +7,30 @@ class FingerPoken::Target
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def register
|
10
|
-
@channel.subscribe do |
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
@channel.subscribe do |obj|
|
11
|
+
request = obj[:request]
|
12
|
+
callback = obj[:callback]
|
13
|
+
response = case request["action"]
|
14
|
+
when "mousemove_relative"
|
15
|
+
mousemove_relative(request["rel_x"], request["rel_y"])
|
16
|
+
when "move_end"
|
17
|
+
move_end()
|
18
|
+
when "click"
|
19
|
+
click(request["button"])
|
20
|
+
when "mousedown"
|
21
|
+
mousedown(request["button"])
|
22
|
+
when "mouseup"
|
23
|
+
mouseup(request["button"])
|
24
|
+
when "type"
|
25
|
+
type(request["string"])
|
26
|
+
when "keypress"
|
27
|
+
keypress(request["key"])
|
28
|
+
else
|
29
|
+
p ["Unsupported action", request]
|
28
30
|
end
|
31
|
+
|
32
|
+
p [callback, response]
|
33
|
+
callback.call(response)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
data/lib/fingerpoken/tivo.rb
CHANGED
@@ -41,24 +41,36 @@ class FingerPoken::Target::Tivo < FingerPoken::Target
|
|
41
41
|
# decrease to it
|
42
42
|
end
|
43
43
|
@state.speed = want_speed
|
44
|
+
|
45
|
+
if @state.speed > 0
|
46
|
+
char = "\\u23E9" * @state.speed
|
47
|
+
else
|
48
|
+
char = "\\u23EA" * @state.speed.abs
|
49
|
+
end
|
50
|
+
return { "action" => "status", "status" => char }
|
44
51
|
end
|
45
52
|
|
46
53
|
def move_end
|
47
54
|
@tivo.send_data("IRCODE PLAY\r\n")
|
55
|
+
return { "action" => "status", "status" => "\\u25b6" }
|
48
56
|
end
|
49
57
|
|
50
58
|
def click(button)
|
51
59
|
case button.to_i
|
52
60
|
when 1
|
53
61
|
@tivo.send_data("IRCODE PAUSE\r\n")
|
62
|
+
return { "action" => "status", "status" => "Pause" }
|
54
63
|
when 2 # 'middle' click (three fingers)
|
55
64
|
@tivo.send_data("IRCODE SELECT\r\n")
|
65
|
+
return { "action" => "status", "status" => "Select" }
|
56
66
|
#when 2 # 'middle' click (three fingers)
|
57
67
|
#@tivo.send_data("IRCODE TIVO\r\n")
|
58
68
|
when 4 # scroll up
|
59
69
|
@tivo.send_data("IRCODE UP\r\n")
|
70
|
+
return { "action" => "status", "status" => "Up" }
|
60
71
|
when 5 # scroll down
|
61
72
|
@tivo.send_data("IRCODE DOWN\r\n")
|
73
|
+
return { "action" => "status", "status" => "Down" }
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
data/public/js/fingerpoken.js
CHANGED
@@ -29,6 +29,17 @@
|
|
29
29
|
}
|
30
30
|
};
|
31
31
|
|
32
|
+
state.message_callback = function(request) {
|
33
|
+
action = request["action"];
|
34
|
+
switch (action) {
|
35
|
+
case "status":
|
36
|
+
//$("#area").html("<h1 class='status'>" + request["status"] + "</h1>");
|
37
|
+
/* Use eval to do unicode escaping */
|
38
|
+
$("#area").html("<h1 class='status'>" + eval("\"" + request["status"] + "\"") + "</h1>");
|
39
|
+
break;
|
40
|
+
}
|
41
|
+
};
|
42
|
+
|
32
43
|
/* Sync configuration elements */
|
33
44
|
|
34
45
|
/* Mouse movement */
|
@@ -78,6 +89,11 @@
|
|
78
89
|
}, 1000);
|
79
90
|
}
|
80
91
|
|
92
|
+
websocket.onmessage = function(event) {
|
93
|
+
var request = JSON.parse(event.data);
|
94
|
+
state.message_callback(request)
|
95
|
+
}
|
96
|
+
|
81
97
|
state.websocket = websocket;
|
82
98
|
}
|
83
99
|
|
data/views/index.haml
CHANGED
data/views/style.sass
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingerpoken
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 40202434246515
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 20101217123250
|
10
|
+
version: 0.2.20101217123250
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jordan Sissel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-17 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|