reapmotion 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ require 'reapmotion/core_ext/circle_gesture'
2
+ require 'reapmotion/core_ext/controller'
3
+ require 'reapmotion/core_ext/device_list'
4
+ require 'reapmotion/core_ext/finger_list'
5
+ require 'reapmotion/core_ext/frame'
6
+ require 'reapmotion/core_ext/hand_list'
7
+ require 'reapmotion/core_ext/pointable_list'
8
+ require 'reapmotion/core_ext/tool_list'
9
+
10
+
@@ -0,0 +1,9 @@
1
+ class com::leapmotion::leap::CircleGesture
2
+ def clockwise?
3
+ pointable.direction.angleTo(normal) <= Math::PI/4
4
+ end
5
+
6
+ def counter_clockwise?
7
+ !clock_wise?
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ class com::leapmotion::leap::Controller
2
+ java_import com.leapmotion.leap.Gesture
3
+
4
+ GESTURE_MAP = {
5
+ "swipe" => Gesture::Type::TYPE_SWIPE,
6
+ "circle" => Gesture::Type::TYPE_CIRCLE,
7
+ "screen_tap" => Gesture::Type::TYPE_SCREEN_TAP,
8
+ "key_tap" => Gesture::Type::TYPE_KEY_TAP
9
+ }
10
+
11
+ def enable_gestures(*list)
12
+ list.each do |sym|
13
+ type = GESTURE_MAP[sym.to_s]
14
+
15
+ raise TypeError.new("#{sym} is not a valid gesture type") unless type
16
+
17
+ enable_gesture(type)
18
+ end
19
+ end
20
+
21
+ def self.run(*listeners)
22
+ controller = Controller.new
23
+ listeners.each { |listener| controller.add_listener listener }
24
+ yield
25
+ ensure
26
+ listeners.each { |listener| controller.remove_listener listener }
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::DeviceList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::FingerList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,30 @@
1
+ class com::leapmotion::leap::Frame
2
+ java_import com.leapmotion.leap.Gesture
3
+ java_import com.leapmotion.leap.CircleGesture
4
+ java_import com.leapmotion.leap.SwipeGesture
5
+ java_import com.leapmotion.leap.ScreenTapGesture
6
+ java_import com.leapmotion.leap.KeyTapGesture
7
+
8
+ GESTURE_TYPE_MAP = {
9
+ Gesture::Type::TYPE_CIRCLE => CircleGesture,
10
+ Gesture::Type::TYPE_SWIPE => SwipeGesture,
11
+ Gesture::Type::TYPE_SCREEN_TAP => ScreenTapGesture,
12
+ Gesture::Type::TYPE_KEY_TAP => KeyTapGesture,
13
+ }
14
+
15
+ alias gestures_original gestures
16
+
17
+ def gestures
18
+ # Original Java path
19
+ return gestures_original unless block_given?
20
+
21
+ gestures_original.each do |gesture|
22
+ type = GESTURE_TYPE_MAP[gesture.type]
23
+
24
+ raise ArgumentError.new("unknown type #{gesture.type}") unless type
25
+
26
+ yield type.new(gesture)
27
+ end
28
+ end
29
+
30
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::GestureList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::HandList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::PointableList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'reapmotion/util/list_helper'
2
+
3
+ class com::leapmotion::leap::ToolList
4
+ include ReapMotion::ListHelper
5
+ end
@@ -0,0 +1,20 @@
1
+ module ReapMotion
2
+ module ListHelper
3
+ include Enumerable
4
+
5
+ def <<(other)
6
+ append(other)
7
+ end
8
+
9
+ def [](index)
10
+ get(index)
11
+ end
12
+
13
+ def each
14
+ iter = iterator
15
+ while iter.has_next
16
+ yield iter.next
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module ReapMotion
2
+ VERSION = "0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: reapmotion
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Thomas E. Enebo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-23 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: A thin Ruby wrapper around Java LeapMotion API
15
+ email: tom.enebo@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/reapmotion.rb
21
+ - lib/reapmotion/core_ext/circle_gesture.rb
22
+ - lib/reapmotion/core_ext/controller.rb
23
+ - lib/reapmotion/core_ext/device_list.rb
24
+ - lib/reapmotion/core_ext/finger_list.rb
25
+ - lib/reapmotion/core_ext/frame.rb
26
+ - lib/reapmotion/core_ext/gesture_list.rb
27
+ - lib/reapmotion/core_ext/hand_list.rb
28
+ - lib/reapmotion/core_ext/pointable_list.rb
29
+ - lib/reapmotion/core_ext/tool_list.rb
30
+ - lib/reapmotion/util/list_helper.rb
31
+ - lib/reapmotion/version.rb
32
+ homepage: http://github.com/enebo/reapmotion
33
+ licenses: []
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project: reapmotion
52
+ rubygems_version: 1.8.23
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: A thin Ruby wrapper around Java LeapMotion API
56
+ test_files: []
57
+ has_rdoc: true