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 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(request)
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
 
@@ -7,25 +7,30 @@ class FingerPoken::Target
7
7
  end
8
8
 
9
9
  def register
10
- @channel.subscribe do |request|
11
- case request["action"]
12
- when "mousemove_relative"
13
- mousemove_relative(request["rel_x"], request["rel_y"])
14
- when "move_end"
15
- move_end()
16
- when "click"
17
- click(request["button"])
18
- when "mousedown"
19
- mousedown(request["button"])
20
- when "mouseup"
21
- mouseup(request["button"])
22
- when "type"
23
- type(request["string"])
24
- when "keypress"
25
- keypress(request["key"])
26
- else
27
- p ["Unsupported action", request]
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
 
@@ -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
 
@@ -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
@@ -24,7 +24,7 @@
24
24
  %a{:href => "javascript:window.location.reload()", "data-role" => "button", "data-inline" => true} Reload
25
25
  %div.content{"data-role" => "content"}
26
26
  #area
27
- %pre#status
27
+ /%pre#status
28
28
 
29
29
  %div.footer{"data-role" => "footer"}
30
30
  %span.left
data/views/style.sass CHANGED
@@ -20,6 +20,9 @@ html, body
20
20
  color: orange
21
21
 
22
22
  .content
23
+ h1.status
24
+ font-size: 400%
25
+ color: white
23
26
  .header
24
27
  .footer
25
28
  font-size: 120%
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: 40202432048205
4
+ hash: 40202434246515
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 20101216024109
10
- version: 0.2.20101216024109
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-16 00:00:00 -08:00
18
+ date: 2010-12-17 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency