leapmotion 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -2
- data/History.txt +4 -0
- data/README.md +17 -2
- data/lib/leapmotion.rb +1 -0
- data/lib/leapmotion/main.rb +16 -5
- data/lib/leapmotion/options.rb +6 -0
- data/lib/leapmotion/version.rb +1 -1
- data/samples/dump.rb +9 -3
- data/samples/gesture.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35139984cdd09f3f3f8bf67990f7e58347867731
|
4
|
+
data.tar.gz: 2841285ba6400c24b521a07c03988c7b01a6e8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61486825ef5c23d471328e31b33d814b43cc4717c59566eca7f84ea30800fb2ab90d0abe609a0345991ddaf6fa2a8ee393168963c1c8b3e327127fa0f9a25fd9
|
7
|
+
data.tar.gz: a0dc82c0ca83c23d35d917ff4596e174e1298fe067f35e7b2ce91e097f7874bd51fcd922d566c504f999124a7ed687613027e9550c36ca1fcb9d9cb1000d49be
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
leapmotion (0.0.
|
4
|
+
leapmotion (0.0.2)
|
5
5
|
event_emitter
|
6
6
|
hashie
|
7
7
|
json
|
@@ -13,7 +13,6 @@ GEM
|
|
13
13
|
event_emitter (0.2.5)
|
14
14
|
hashie (2.0.5)
|
15
15
|
json (1.8.0)
|
16
|
-
json (1.8.0-java)
|
17
16
|
rake (10.1.0)
|
18
17
|
websocket (1.1.1)
|
19
18
|
websocket-client-simple (0.0.5)
|
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -23,7 +23,7 @@ Samples
|
|
23
23
|
Usage
|
24
24
|
-----
|
25
25
|
|
26
|
-
###
|
26
|
+
### Start "Leap Motion.app"
|
27
27
|
|
28
28
|
- `/Applications/Leap Motion.app`
|
29
29
|
- It provides WebSocket API.
|
@@ -31,7 +31,7 @@ Usage
|
|
31
31
|
<img src="http://shokai.org/archive/file/31d034b4fa72350a67a94f85a00b83a2.png">
|
32
32
|
|
33
33
|
|
34
|
-
###
|
34
|
+
### Run Ruby
|
35
35
|
|
36
36
|
```ruby
|
37
37
|
require 'rubygems'
|
@@ -62,6 +62,21 @@ end
|
|
62
62
|
leap.wait
|
63
63
|
```
|
64
64
|
|
65
|
+
### Gestures
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
leap = LeapMotion.connect :gestures => true
|
69
|
+
|
70
|
+
leap.on :gestures do |gestures|
|
71
|
+
gestures.each do |g|
|
72
|
+
puts g.type
|
73
|
+
puts g
|
74
|
+
end
|
75
|
+
puts "-"*5
|
76
|
+
end
|
77
|
+
|
78
|
+
leap.wait
|
79
|
+
```
|
65
80
|
|
66
81
|
Contributing
|
67
82
|
------------
|
data/lib/leapmotion.rb
CHANGED
data/lib/leapmotion/main.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
module LeapMotion
|
2
|
-
def self.connect(
|
3
|
-
|
4
|
-
|
2
|
+
def self.connect(opts={})
|
3
|
+
DEFAULT_OPTION.each do |k,v|
|
4
|
+
opts[k] = v unless opts.has_key? k
|
5
|
+
end
|
6
|
+
LeapMotion::Device.new opts
|
5
7
|
end
|
6
8
|
|
7
9
|
class Data < Hashie::Mash
|
@@ -10,13 +12,18 @@ module LeapMotion
|
|
10
12
|
class Device
|
11
13
|
include EventEmitter
|
12
14
|
attr_accessor :version
|
15
|
+
attr_reader :options
|
13
16
|
|
14
|
-
def initialize(
|
15
|
-
@ws = WebSocket::Client::Simple.connect
|
17
|
+
def initialize(opts)
|
18
|
+
@ws = WebSocket::Client::Simple.connect opts[:websocket]
|
19
|
+
@options = opts
|
16
20
|
@version = nil
|
17
21
|
this = self
|
18
22
|
@ws.on :message do |msg|
|
19
23
|
data = Data.new JSON.parse msg.data rescue this.emit :error, "JSON parse error"
|
24
|
+
if data.has_key? "gestures" and !data.gestures.empty?
|
25
|
+
this.emit :gestures, data.gestures
|
26
|
+
end
|
20
27
|
if data.has_key? "currentFrameRate"
|
21
28
|
this.emit :data, data
|
22
29
|
elsif data.has_key? "version"
|
@@ -25,6 +32,10 @@ module LeapMotion
|
|
25
32
|
end
|
26
33
|
|
27
34
|
@ws.on :open do
|
35
|
+
if this.options[:gestures]
|
36
|
+
data = {:enableGestures => true}.to_json
|
37
|
+
send data
|
38
|
+
end
|
28
39
|
this.emit :connect
|
29
40
|
end
|
30
41
|
|
data/lib/leapmotion/version.rb
CHANGED
data/samples/dump.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
$:.unshift File.expand_path "../lib", File.dirname(__FILE__)
|
2
3
|
require 'leapmotion'
|
3
4
|
|
4
|
-
leap = LeapMotion.connect
|
5
|
+
leap = LeapMotion.connect
|
5
6
|
|
6
7
|
leap.on :connect do
|
7
8
|
puts "connect"
|
@@ -13,8 +14,13 @@ leap.on :disconnect do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
leap.on :data do |data|
|
16
|
-
puts "hands
|
17
|
-
|
17
|
+
puts "hands #{data.hands.size}"
|
18
|
+
if data.hands.size > 0
|
19
|
+
data.hands.each do |hand|
|
20
|
+
puts "sphereRadius #{hand.sphereRadius}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
puts "pointables #{data.pointables.size}"
|
18
24
|
puts data
|
19
25
|
puts "-"*5
|
20
26
|
end
|
data/samples/gesture.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
$:.unshift File.expand_path "../lib", File.dirname(__FILE__)
|
3
|
+
require 'leapmotion'
|
4
|
+
|
5
|
+
leap = LeapMotion.connect :gestures => true
|
6
|
+
|
7
|
+
leap.on :connect do
|
8
|
+
puts "connect"
|
9
|
+
end
|
10
|
+
|
11
|
+
leap.on :gestures do |gestures|
|
12
|
+
gestures.each do |g|
|
13
|
+
puts g.type
|
14
|
+
puts g
|
15
|
+
end
|
16
|
+
puts "-"*5
|
17
|
+
end
|
18
|
+
|
19
|
+
leap.on :data do |data|
|
20
|
+
# puts data
|
21
|
+
end
|
22
|
+
|
23
|
+
leap.wait
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leapmotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
@@ -111,8 +111,10 @@ files:
|
|
111
111
|
- leapmotion.gemspec
|
112
112
|
- lib/leapmotion.rb
|
113
113
|
- lib/leapmotion/main.rb
|
114
|
+
- lib/leapmotion/options.rb
|
114
115
|
- lib/leapmotion/version.rb
|
115
116
|
- samples/dump.rb
|
117
|
+
- samples/gesture.rb
|
116
118
|
homepage: https://github.com/shokai/ruby-leapmotion
|
117
119
|
licenses:
|
118
120
|
- MIT
|