revdev 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,20 +4,21 @@
4
4
  *.so
5
5
  *.dll
6
6
  *~
7
- .bundle
8
- .config
9
- .yardoc
10
- Gemfile.lock
7
+ /.bundle
8
+ /.config
9
+ /.yardoc
10
+ /Gemfile.lock
11
11
  InstalledFiles
12
12
  Makefile
13
13
  _yardoc
14
14
  core
15
15
  coverage
16
- doc/
17
- lib/bundler/man
16
+ /doc/
17
+ /lib/bundler/man
18
18
  pkg
19
19
  rdoc
20
20
  spec/reports
21
- test/tmp
22
- test/version_tmp
21
+ /test/tmp
22
+ /test/version_tmp
23
23
  tmp
24
+ .ruby-version
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
- # Revdev
1
+ Revdev
2
+ =================
2
3
 
3
4
  revdev is a ruby binding to handling event devices.
4
5
 
5
- ## Installation
6
+ Installation
7
+ --------------
6
8
 
7
9
  Add this line to your application's Gemfile:
8
10
 
@@ -22,14 +24,24 @@ Or install it yourself as:
22
24
  $ gem install revdev
23
25
  ```
24
26
 
25
- ## Usage
26
27
 
27
- TODO: Write usage instructions here
28
+ Example Usage
29
+ ----------------------
28
30
 
29
- ## Contributing
31
+ In terminal:
32
+
33
+ ```sh
34
+ ruby -Ilib sample/device_name /dev/input/event*
35
+ ruby -Ilib sample/key_dump /dev/input/event4
36
+ ...
37
+ ```
38
+
39
+ Contributing
40
+ -------------------------
30
41
 
31
42
  1. Fork it
32
43
  2. Create your feature branch (`git checkout -b my-new-feature`)
33
44
  3. Commit your changes (`git commit -am 'Added some feature'`)
45
+ * Please check with `test` to execute `$ rake`
34
46
  4. Push to the branch (`git push origin my-new-feature`)
35
47
  5. Create new Pull Request
@@ -1,3 +1,18 @@
1
1
  require "mkmf"
2
2
 
3
+ # version => micro
4
+ map = {
5
+ '1.8.' => 'RUBY_1_8',
6
+ '1.9.' => 'RUBY_1_9',
7
+ }
8
+ version, micro = map.find do |v, m|
9
+ RUBY_VERSION.start_with? v
10
+ end
11
+
12
+ if micro.nil?
13
+ abort "Not supported ruby-version: #{RUBY_VERSION}"
14
+ else
15
+ $defs << "-D#{micro}"
16
+ end
17
+
3
18
  create_makefile "revdev/revdev"
data/ext/revdev/revdev.c CHANGED
@@ -5,7 +5,12 @@
5
5
  #include <linux/input.h>
6
6
 
7
7
  #include <ruby.h>
8
+ #ifdef RUBY_1_8
8
9
  #include <rubyio.h>
10
+ #endif
11
+ #ifdef RUBY_1_9
12
+ #include <ruby/io.h>
13
+ #endif
9
14
 
10
15
  #define NAME "Revdev"
11
16
  #define BUFF_SIZE 255
@@ -38,7 +43,7 @@ VALUE input_event_raw_initialize(VALUE self, VALUE byte)
38
43
  struct input_event *ie;
39
44
  struct timeval t;
40
45
 
41
- ie = RSTRING(byte)->ptr;
46
+ ie = RSTRING_PTR(byte);
42
47
  t = ie->time;
43
48
 
44
49
  rb_iv_set(self, "@time", rb_time_new(t.tv_sec, t.tv_usec));
@@ -52,10 +57,14 @@ VALUE input_event_raw_initialize(VALUE self, VALUE byte)
52
57
  VALUE input_event_to_byte_string(VALUE self)
53
58
  {
54
59
  struct input_event ie;
60
+ #ifdef RUBY_1_8
55
61
  struct timeval *t;
56
-
57
62
  Data_Get_Struct(rb_iv_get(self, "@time"), struct time_object, t);
58
63
  ie.time = *t;
64
+ #endif
65
+ #ifdef RUBY_1_9
66
+ ie.time = rb_time_timeval(rb_iv_get(self, "@time"));
67
+ #endif
59
68
 
60
69
  ie.type = FIX2UINT(rb_iv_get(self, "@type"));
61
70
  ie.code = FIX2UINT(rb_iv_get(self, "@code"));
@@ -67,7 +76,7 @@ VALUE input_event_to_byte_string(VALUE self)
67
76
  VALUE input_id_raw_initialize(VALUE self, VALUE byte)
68
77
  {
69
78
  struct input_id *ii;
70
- ii = RSTRING(byte)->ptr;
79
+ ii = RSTRING_PTR(byte);
71
80
 
72
81
  rb_iv_set(self, "@bustype", INT2FIX(ii->bustype));
73
82
  rb_iv_set(self, "@vendor", INT2FIX(ii->vendor));
@@ -1,3 +1,3 @@
1
1
  module Revdev
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -74,7 +74,9 @@ class EventDeviceTest < Test::Unit::TestCase
74
74
  evdev = EventDevice.new file
75
75
  assert_nothing_raised do
76
76
  iee = evdev.read_input_event
77
- assert_equal ie, iee
77
+ assert_equal ie.code, iee.code
78
+ assert_equal ie.type, iee.type
79
+ assert_equal ie.value, iee.value
78
80
  end
79
81
  end
80
82
 
@@ -27,8 +27,15 @@ class InputEventTest < Test::Unit::TestCase
27
27
  ieee = InputEvent.new ie.to_byte_string
28
28
  p ieee
29
29
  end
30
- assert_equal ie, iee
31
- assert_equal ie, ieee
30
+
31
+ assert_equal ie.code, iee.code
32
+ assert_equal ie.type, iee.type
33
+ assert_equal ie.time, iee.time
34
+ assert_equal ie.value, iee.value
35
+
36
+ assert_equal ie.code, ieee.code
37
+ assert_equal ie.type, ieee.type
38
+ assert_equal ie.value, ieee.value
32
39
  end
33
40
 
34
41
  def test_hr_blar
@@ -54,7 +61,10 @@ class InputEventTest < Test::Unit::TestCase
54
61
  assert_nothing_raised do
55
62
  iee = InputEvent.new ie.to_byte_string
56
63
  end
57
- assert_equal ie, iee
64
+
65
+ assert_equal ie.code, iee.code
66
+ assert_equal ie.type, iee.type
67
+ assert_equal ie.value, iee.value
58
68
  end
59
69
 
60
70
  end
metadata CHANGED
@@ -1,60 +1,56 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: revdev
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Keiichiro Ui
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-21 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: bundler
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
38
33
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :development
47
- version_requirements: *id002
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
48
46
  description: revdev is a ruby binding to handling event devices.
49
- email:
47
+ email:
50
48
  - keiichiro.ui@gmail.com
51
49
  executables: []
52
-
53
- extensions:
50
+ extensions:
54
51
  - ext/revdev/extconf.rb
55
52
  extra_rdoc_files: []
56
-
57
- files:
53
+ files:
58
54
  - .gitignore
59
55
  - Gemfile
60
56
  - LICENSE
@@ -79,38 +75,29 @@ files:
79
75
  - test/test_revdev.rb
80
76
  homepage: https://rubygems.org/gems/revdev
81
77
  licenses: []
82
-
83
78
  post_install_message:
84
79
  rdoc_options: []
85
-
86
- require_paths:
80
+ require_paths:
87
81
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
82
+ required_ruby_version: !ruby/object:Gem::Requirement
89
83
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- hash: 3
94
- segments:
95
- - 0
96
- version: "0"
97
- required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
89
  none: false
99
- requirements:
100
- - - ">="
101
- - !ruby/object:Gem::Version
102
- hash: 3
103
- segments:
104
- - 0
105
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
106
94
  requirements: []
107
-
108
95
  rubyforge_project:
109
- rubygems_version: 1.7.2
96
+ rubygems_version: 1.8.23
110
97
  signing_key:
111
98
  specification_version: 3
112
99
  summary: ruby binding to handling event devices.
113
- test_files:
100
+ test_files:
114
101
  - test/test_event_device.rb
115
102
  - test/test_input_event.rb
116
103
  - test/test_input_id.rb