cwiid 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +1 -0
  2. data/Rakefile +2 -3
  3. data/ext/wiimote.cc +22 -4
  4. metadata +5 -5
data/README.md CHANGED
@@ -34,6 +34,7 @@ Here's a small example displaying the state of the accelerometer:
34
34
  require 'rubygems'
35
35
  require 'opengl'
36
36
  require 'cwiid'
37
+ puts 'Put Wiimote in discoverable mode now (press 1+2)...'
37
38
  wiimote = WiiMote.new
38
39
  wiimote.rpt_mode = WiiMote::RPT_BTN | WiiMote::RPT_ACC
39
40
  $list = nil
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'cwiid'
10
- PKG_VERSION = '0.1.2'
10
+ PKG_VERSION = '0.1.3'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
@@ -81,8 +81,7 @@ end
81
81
  begin
82
82
  require 'yard'
83
83
  YARD::Rake::YardocTask.new :yard do |y|
84
- y.options << '--no-private'
85
- y.files << FileList[ 'lib/**/*.rb' ]
84
+ y.files << RB_FILES
86
85
  end
87
86
  rescue LoadError
88
87
  STDERR.puts 'Please install \'yard\' if you want to generate documentation'
@@ -55,6 +55,8 @@ void WiiMote::close(void)
55
55
 
56
56
  void WiiMote::requestStatus(void) throw (Error)
57
57
  {
58
+ ERRORMACRO( m_wiimote != NULL, Error, , "Wii Remote is closed. "
59
+ "Did you call \"close\" before?" );
58
60
  m_error = false;
59
61
  cwiid_request_status( m_wiimote );
60
62
  ERRORMACRO( !m_error, Error, , "Status request error: " << m_errorMsg );
@@ -62,6 +64,8 @@ void WiiMote::requestStatus(void) throw (Error)
62
64
 
63
65
  void WiiMote::getState(void) throw (Error)
64
66
  {
67
+ ERRORMACRO( m_wiimote != NULL, Error, , "Wii Remote is closed. "
68
+ "Did you call \"close\" before?" );
65
69
  m_error = false;
66
70
  cwiid_get_state( m_wiimote, &m_state );
67
71
  ERRORMACRO( !m_error, Error, , "Error getting state: " << m_errorMsg );
@@ -74,6 +78,8 @@ unsigned char WiiMote::getRptMode(void)
74
78
 
75
79
  void WiiMote::setRptMode( unsigned char mode ) throw (Error)
76
80
  {
81
+ ERRORMACRO( m_wiimote != NULL, Error, , "Wii Remote is closed. "
82
+ "Did you call \"close\" before?" );
77
83
  m_error = false;
78
84
  cwiid_set_rpt_mode( m_wiimote, mode );
79
85
  ERRORMACRO( !m_error, Error, , "Error setting RPT mode: " << m_errorMsg );
@@ -92,6 +98,8 @@ unsigned char WiiMote::getLED(void)
92
98
 
93
99
  void WiiMote::setLED( unsigned char state ) throw (Error)
94
100
  {
101
+ ERRORMACRO( m_wiimote != NULL, Error, , "Wii Remote is closed. "
102
+ "Did you call \"close\" before?" );
95
103
  m_error = false;
96
104
  cwiid_set_led( m_wiimote, state );
97
105
  ERRORMACRO( !m_error, Error, , "Error setting LED state: " << m_errorMsg );
@@ -105,6 +113,8 @@ bool WiiMote::getRumble(void)
105
113
 
106
114
  void WiiMote::setRumble( bool state ) throw( Error )
107
115
  {
116
+ ERRORMACRO( m_wiimote != NULL, Error, , "Wii Remote is closed. "
117
+ "Did you call \"close\" before?" );
108
118
  m_error = false;
109
119
  cwiid_set_rumble( m_wiimote, state ? 1 : 0 );
110
120
  ERRORMACRO( !m_error, Error, , "Error setting rumble state: " << m_errorMsg );
@@ -234,15 +244,23 @@ VALUE WiiMote::wrapClose( VALUE rbSelf )
234
244
 
235
245
  VALUE WiiMote::wrapRequestStatus( VALUE rbSelf )
236
246
  {
237
- WiiMotePtr *self; Data_Get_Struct( rbSelf, WiiMotePtr, self );
238
- (*self)->requestStatus();
247
+ try {
248
+ WiiMotePtr *self; Data_Get_Struct( rbSelf, WiiMotePtr, self );
249
+ (*self)->requestStatus();
250
+ } catch ( exception &e ) {
251
+ rb_raise( rb_eRuntimeError, "%s", e.what() );
252
+ };
239
253
  return rbSelf;
240
254
  }
241
255
 
242
256
  VALUE WiiMote::wrapGetState( VALUE rbSelf )
243
257
  {
244
- WiiMotePtr *self; Data_Get_Struct( rbSelf, WiiMotePtr, self );
245
- (*self)->getState();
258
+ try {
259
+ WiiMotePtr *self; Data_Get_Struct( rbSelf, WiiMotePtr, self );
260
+ (*self)->getState();
261
+ } catch ( exception &e ) {
262
+ rb_raise( rb_eRuntimeError, "%s", e.what() );
263
+ };
246
264
  return rbSelf;
247
265
  }
248
266
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
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-27 00:00:00 +01:00
17
+ date: 2011-02-23 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -44,11 +44,11 @@ files:
44
44
  - COPYING
45
45
  - .document
46
46
  - lib/cwiid_ext.rb
47
- - ext/init.cc
48
47
  - ext/wiimote.cc
48
+ - ext/init.cc
49
49
  - ext/wiimote.hh
50
- - ext/rubyinc.hh
51
50
  - ext/error.hh
51
+ - ext/rubyinc.hh
52
52
  has_rdoc: yard
53
53
  homepage: http://wedesoft.github.com/cwiid/
54
54
  licenses: []