ruby_hid 0.0.0 → 0.0.1
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.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/lib/ruby_hid/axis.rb +1 -1
- data/lib/ruby_hid/button.rb +2 -1
- data/lib/ruby_hid/device.rb +2 -1
- data/lib/ruby_hid/observer.rb +1 -1
- data/lib/ruby_hid/store.rb +37 -0
- data/lib/ruby_hid.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f77ff9705448676fcba81e4d570be6735fb76e83
|
4
|
+
data.tar.gz: b2662f69540b32c1d96b14e7933b3e8501189197
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1b5529b242fe09f9e78dcc1b539f9688bb127260d1c2bf78c7478441ed42b9259c9c473c0ef0f7c40741c43db306ad66eb8411f2289fb9c13d020f3d455e62e
|
7
|
+
data.tar.gz: 404875e0fa3ffd3e22f599fb8845bda9895725d15a306a378635c6510cd427461947faa65c73fcc6ab4f938450509f45bc7e4e643deb82dca44205ecc9aaf42c
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
ruby_hid
|
2
2
|
==========
|
3
3
|
|
4
4
|
A ruby library for observing HID game controllers. Currently supports
|
@@ -263,7 +263,6 @@ axes as small as possible, and modify a shared object.
|
|
263
263
|
|
264
264
|
```ruby
|
265
265
|
require 'ostruct'
|
266
|
-
require_relative '../lib/ruby_hid.rb'
|
267
266
|
|
268
267
|
@cursor = OpenStruct.new(
|
269
268
|
:x => 50.0, :y => 50.0,
|
@@ -300,6 +299,26 @@ loop do
|
|
300
299
|
end
|
301
300
|
```
|
302
301
|
|
302
|
+
The ruby_hid Store
|
303
|
+
-----------------
|
304
|
+
|
305
|
+
Don't want to worry about setting up all those observers? The ruby_hid store
|
306
|
+
is an object which, once initialised, holds all of the values from the first
|
307
|
+
controller found.
|
308
|
+
|
309
|
+
This is ruby_hid with all the difficulty taken out.
|
310
|
+
|
311
|
+
```ruby
|
312
|
+
require 'ruby_hid'
|
313
|
+
|
314
|
+
store = RubyHid::Store.new
|
315
|
+
|
316
|
+
loop do
|
317
|
+
puts store.to_h
|
318
|
+
sleep 0.1
|
319
|
+
end
|
320
|
+
```
|
321
|
+
|
303
322
|
Helping Out
|
304
323
|
===========
|
305
324
|
|
data/lib/ruby_hid/axis.rb
CHANGED
data/lib/ruby_hid/button.rb
CHANGED
data/lib/ruby_hid/device.rb
CHANGED
data/lib/ruby_hid/observer.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
module RubyHid
|
2
|
+
|
3
|
+
class Store < OpenStruct
|
4
|
+
|
5
|
+
attr_accessor :device
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
init_observers
|
10
|
+
init_device
|
11
|
+
end
|
12
|
+
|
13
|
+
def init_device
|
14
|
+
if device.nil?
|
15
|
+
self.device = Device.new(
|
16
|
+
RubyHid::Device.list[0]
|
17
|
+
)
|
18
|
+
end
|
19
|
+
device.start_watching
|
20
|
+
end
|
21
|
+
|
22
|
+
def init_observers
|
23
|
+
events = Axis::EVENTS.values + Button::EVENTS.values
|
24
|
+
store = self
|
25
|
+
events.each do |name|
|
26
|
+
send("#{name}=", 0)
|
27
|
+
control = Axis.find_by_name(name)
|
28
|
+
control ||= Button.find_by_name(name)
|
29
|
+
control.add_event(
|
30
|
+
lambda {|val| store.send("#{name}=", val)}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
data/lib/ruby_hid.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
`sudo chmod 777 /sys/class/leds/*/brightness`
|
2
2
|
`sudo chmod 777 /dev/input/event*`
|
3
3
|
|
4
|
+
require 'ostruct'
|
4
5
|
require_relative './ruby_hid/device.rb'
|
5
6
|
require_relative './ruby_hid/observer.rb'
|
6
7
|
require_relative './ruby_hid/button.rb'
|
7
8
|
require_relative './ruby_hid/axis.rb'
|
9
|
+
require_relative './ruby_hid/store.rb'
|
8
10
|
|
9
11
|
RubyHid::Axis.build
|
10
12
|
RubyHid::Button.build
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_hid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Faraday
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: HID device observer library for Ruby applications. Currently only ubuntu
|
14
14
|
Linux distributions.
|
@@ -24,6 +24,7 @@ files:
|
|
24
24
|
- lib/ruby_hid/button.rb
|
25
25
|
- lib/ruby_hid/device.rb
|
26
26
|
- lib/ruby_hid/observer.rb
|
27
|
+
- lib/ruby_hid/store.rb
|
27
28
|
homepage: https://github.com/AJFaraday/ruby-hid
|
28
29
|
licenses:
|
29
30
|
- MIT
|