cwiid 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -18
- data/Rakefile +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -31,27 +31,53 @@ Simply run Interactive Ruby:
|
|
31
31
|
|
32
32
|
Here's a small example displaying the state of the accelerometer:
|
33
33
|
|
34
|
-
#!/usr/bin/env ruby
|
35
34
|
require 'rubygems'
|
35
|
+
require 'opengl'
|
36
36
|
require 'cwiid'
|
37
|
-
require 'hornetseye_rmagick'
|
38
|
-
require 'hornetseye_xorg'
|
39
|
-
include Hornetseye
|
40
|
-
include Magick
|
41
37
|
wiimote = WiiMote.new
|
42
|
-
|
43
|
-
display.status = wiimote.buttons != WiiMote::BTN_1
|
44
|
-
wiimote.get_state
|
38
|
+
display = proc do
|
45
39
|
acc = wiimote.acc
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
glClear GL_COLOR_BUFFER_BIT
|
41
|
+
glLineWidth 3.0
|
42
|
+
glColor 1.0, 0.0, 0.0
|
43
|
+
glBegin GL_LINES
|
44
|
+
glVertex 120, 120
|
45
|
+
glVertex acc[0], acc[2]
|
46
|
+
glEnd
|
47
|
+
glColor 0.0, 1.0, 0.0
|
48
|
+
glBegin GL_LINES
|
49
|
+
glVertex 120, 120
|
50
|
+
glVertex acc[1], acc[2]
|
51
|
+
glEnd
|
52
|
+
glutSwapBuffers
|
53
|
+
end
|
54
|
+
reshape = proc do |w, h|
|
55
|
+
glViewport 0, 0, w, h
|
56
|
+
glMatrixMode GL_PROJECTION
|
57
|
+
glLoadIdentity
|
58
|
+
GLU.Ortho2D 0.0, w, 0.0, h
|
59
|
+
end
|
60
|
+
keyboard = proc do |key, x, y|
|
61
|
+
case key
|
62
|
+
when ?\e
|
63
|
+
exit 0
|
64
|
+
end
|
65
|
+
end
|
66
|
+
animate = proc do
|
67
|
+
wiimote.get_state
|
68
|
+
exit 0 if wiimote.buttons == WiiMote::BTN_1
|
69
|
+
glutPostRedisplay
|
56
70
|
end
|
71
|
+
glutInit
|
72
|
+
glutInitDisplayMode GLUT_DOUBLE | GLUT_RGB
|
73
|
+
glutInitWindowSize 240, 240
|
74
|
+
glutCreateWindow 'Wii Remote'
|
75
|
+
glClearColor 1.0, 1.0, 1.0, 0.0
|
76
|
+
glShadeModel GL_FLAT
|
77
|
+
|
78
|
+
glutDisplayFunc display
|
79
|
+
glutReshapeFunc reshape
|
80
|
+
glutKeyboardFunc keyboard
|
81
|
+
glutIdleFunc animate
|
82
|
+
glutMainLoop
|
57
83
|
|
data/Rakefile
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jan Wedekind
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-25 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|