cwiid 0.1.0
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/.document +1 -0
- data/COPYING +679 -0
- data/README.md +57 -0
- data/Rakefile +177 -0
- data/ext/error.hh +50 -0
- data/ext/init.cc +35 -0
- data/ext/rubyinc.hh +54 -0
- data/ext/wiimote.cc +333 -0
- data/ext/wiimote.hh +73 -0
- data/lib/cwiid_ext.rb +37 -0
- metadata +86 -0
data/ext/wiimote.hh
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
/* ruby-cwiid - Wii Remote interface.
|
2
|
+
Copyright (C) 2010 Jan Wedekind
|
3
|
+
|
4
|
+
This program is free software: you can redistribute it and/or modify
|
5
|
+
it under the terms of the GNU General Public License as published by
|
6
|
+
the Free Software Foundation, either version 3 of the License, or
|
7
|
+
(at your option) any later version.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it will be useful,
|
10
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
GNU General Public License for more details.
|
13
|
+
|
14
|
+
You should have received a copy of the GNU General Public License
|
15
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
16
|
+
#ifndef WIIMOTE_HH
|
17
|
+
#define WIIMOTE_HH
|
18
|
+
#include <boost/shared_ptr.hpp>
|
19
|
+
#include <cwiid.h>
|
20
|
+
#include <map>
|
21
|
+
#include "rubyinc.hh"
|
22
|
+
#include "error.hh"
|
23
|
+
|
24
|
+
class WiiMote
|
25
|
+
{
|
26
|
+
public:
|
27
|
+
WiiMote(void) throw (Error);
|
28
|
+
virtual ~WiiMote(void);
|
29
|
+
void close(void);
|
30
|
+
void requestStatus(void) throw (Error);
|
31
|
+
void getState(void) throw (Error);
|
32
|
+
unsigned char getRptMode(void);
|
33
|
+
void setRptMode( unsigned char mode ) throw (Error);
|
34
|
+
unsigned char getBattery(void);
|
35
|
+
unsigned char getLED(void);
|
36
|
+
void setLED( unsigned char state ) throw (Error);
|
37
|
+
bool getRumble(void);
|
38
|
+
void setRumble( bool state ) throw(Error);
|
39
|
+
unsigned short int getButtons(void);
|
40
|
+
unsigned char getAcc( int id );
|
41
|
+
bool irValid( int i );
|
42
|
+
unsigned short int getIRX( int i );
|
43
|
+
unsigned short int getIRY( int i );
|
44
|
+
char getIRSize( int i );
|
45
|
+
void err( const char *s, va_list ap );
|
46
|
+
static VALUE cRubyClass;
|
47
|
+
static VALUE registerRubyClass(void);
|
48
|
+
static void deleteRubyObject( void *ptr );
|
49
|
+
static VALUE wrapNew( VALUE rbClass );
|
50
|
+
static VALUE wrapClose( VALUE rbSelf );
|
51
|
+
static VALUE wrapRequestStatus( VALUE rbSelf );
|
52
|
+
static VALUE wrapGetState( VALUE rbSelf );
|
53
|
+
static VALUE wrapGetRptMode( VALUE rbSelf );
|
54
|
+
static VALUE wrapSetRptMode( VALUE rbSelf, VALUE rbMode );
|
55
|
+
static VALUE wrapGetBattery( VALUE rbSelf );
|
56
|
+
static VALUE wrapGetLED( VALUE rbSelf );
|
57
|
+
static VALUE wrapSetLED( VALUE rbSelf, VALUE rbState );
|
58
|
+
static VALUE wrapGetRumble( VALUE rbSelf );
|
59
|
+
static VALUE wrapSetRumble( VALUE rbSelf, VALUE rbState );
|
60
|
+
static VALUE wrapGetButtons( VALUE rbSelf );
|
61
|
+
static VALUE wrapGetAcc( VALUE rbSelf );
|
62
|
+
static VALUE wrapGetIR( VALUE rbSelf );
|
63
|
+
static WiiMote *current;
|
64
|
+
protected:
|
65
|
+
cwiid_wiimote_t *m_wiimote;
|
66
|
+
struct cwiid_state m_state;
|
67
|
+
bool m_error;
|
68
|
+
std::string m_errorMsg;
|
69
|
+
};
|
70
|
+
|
71
|
+
typedef boost::shared_ptr< WiiMote > WiiMotePtr;
|
72
|
+
|
73
|
+
#endif
|
data/lib/cwiid_ext.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# ruby-cwiid - Wii Remote interface for Ruby.
|
2
|
+
# Copyright (C) 2010 Jan Wedekind
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
|
+
#
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
+
class WiiMote
|
17
|
+
|
18
|
+
class << self
|
19
|
+
|
20
|
+
alias_method :orig_new, :new
|
21
|
+
|
22
|
+
def new
|
23
|
+
retval = orig_new
|
24
|
+
retval.rpt_mode = RPT_STATUS | RPT_BTN | RPT_ACC | RPT_IR
|
25
|
+
retval
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method :orig_battery, :battery
|
31
|
+
|
32
|
+
def battery
|
33
|
+
orig_battery.to_f / BATTERY_MAX
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cwiid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jan Wedekind
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-24 00:00:00 +00:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rake
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
description: This Ruby extension provides an inerface to access a Wii Remote using the libcwiid library.
|
34
|
+
email: jan@wedesoft.de
|
35
|
+
executables: []
|
36
|
+
|
37
|
+
extensions:
|
38
|
+
- Rakefile
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- Rakefile
|
43
|
+
- README.md
|
44
|
+
- COPYING
|
45
|
+
- .document
|
46
|
+
- lib/cwiid_ext.rb
|
47
|
+
- ext/init.cc
|
48
|
+
- ext/wiimote.cc
|
49
|
+
- ext/wiimote.hh
|
50
|
+
- ext/rubyinc.hh
|
51
|
+
- ext/error.hh
|
52
|
+
has_rdoc: yard
|
53
|
+
homepage: http://wedesoft.github.com/cwiid/
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options:
|
58
|
+
- --no-private
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
- ext
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Using the Wii Remote with Ruby
|
85
|
+
test_files: []
|
86
|
+
|