uinput-device 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 979a38666a26fe0335c2b485a1e40bbb9bc25698
4
+ data.tar.gz: f9f4ab91d9cacaaec2ff3279560eb65b86c278f1
5
+ SHA512:
6
+ metadata.gz: 181839d48aba596cfbeed1017336ec49ef41867c704c4384e4a126d2def2657adda646eb5676996ac8edd056dc4feb439888b3de9ff6239093fdab1b9947f267
7
+ data.tar.gz: cd3cfbb0fc90fca0308ee4f42dcaf97b5287c85358484c4f41f8d27ec5ed73fafcf74fd64aa8fab3cd076baf4880e88f035e85a3ce340e115e2b2848f59050cf
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'uinput', path: '../ruby-uinput'
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Uinput::Device
2
+
3
+ Generic ruby wrapper around uinput to create devices.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'uinput-device'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install uinput-device
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,5 @@
1
+ module Uinput
2
+ class Device
3
+ class Error < StandardError; end
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ module Uinput
2
+ class Device
3
+ class SystemInitializer
4
+ FILE = '/dev/uinput'
5
+
6
+ def initialize(&block)
7
+ @file = File.open(FILE, Fcntl::O_WRONLY | Fcntl::O_NDELAY)
8
+ @device = UinputUserDev.new
9
+
10
+ self.name = "Virtual Ruby Device"
11
+ self.type = BUS_VIRTUAL
12
+ self.vendor = 0
13
+ self.product = 0
14
+ self.version = 0
15
+
16
+ receive_syn_events
17
+
18
+ instance_exec &block if block
19
+ end
20
+
21
+ def name=(name)
22
+ @device[:name] = name
23
+ end
24
+
25
+ def type=(type)
26
+ @device[:id][:bustype] = type
27
+ end
28
+
29
+ def vendor=(vendor)
30
+ @device[:id][:vendor] = vendor
31
+ end
32
+
33
+ def product=(product)
34
+ @device[:id][:product] = product
35
+ end
36
+
37
+ def version=(version)
38
+ @device[:id][:version] = version
39
+ end
40
+
41
+ def add_key(key)
42
+ @file.ioctl(UI_SET_KEYBIT, key)
43
+ end
44
+ alias_method :add_button, :add_key
45
+
46
+ def add_event(event)
47
+ @file.ioctl(UI_SET_EVBIT, event)
48
+ end
49
+
50
+ def receive_key_events
51
+ add_event(EV_KEY)
52
+ end
53
+
54
+ def receive_syn_events
55
+ add_event(EV_SYN)
56
+ end
57
+
58
+ def create
59
+ @file.syswrite(@device.pointer.read_bytes(@device.size))
60
+ @file if @file.ioctl(UI_DEV_CREATE).zero?
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,5 @@
1
+ module Uinput
2
+ class Device
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,35 @@
1
+ require 'uinput'
2
+ require_relative "device/version"
3
+ require_relative "device/factory"
4
+ require_relative "device/error"
5
+ require 'ffi/libc'
6
+
7
+ module Uinput
8
+ class Device
9
+ def initialize(&block)
10
+ @file = self.class::SystemInitializer.new(self, &block).create
11
+ end
12
+
13
+ def destroy
14
+ @file.ioctl(UI_DEV_DESTROY, nil)
15
+ @file = nil
16
+ end
17
+
18
+ def active?
19
+ not @file.nil?
20
+ end
21
+
22
+ def send_event(type, code, value = 0)
23
+ event = InputEvent.new
24
+ FFI::LibC.gettimeofday(event[:time], nil)
25
+ event[:type] = type
26
+ event[:code] = code
27
+ event[:value] = value
28
+ @file.syswrite(event.pointer.read_bytes(event.size))
29
+ end
30
+
31
+ def send_syn_event
32
+ send_event(EV_SYN, SYN_REPORT)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'uinput/device/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "uinput-device"
8
+ spec.version = Uinput::Device::VERSION
9
+ spec.authors = ["Christopher Aue"]
10
+ spec.email = ["mail@christopheraue.net"]
11
+
12
+ spec.summary = %q{Generic ruby wrapper around uinput to create devices.}
13
+ spec.homepage = "https://github.com/christopheraue/ruby-uinput-device"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_runtime_dependency "uinput", "~> 1.0"
20
+ spec.add_runtime_dependency 'ffi-libc', '~> 0.1.0'
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: uinput-device
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christopher Aue
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: uinput
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ffi-libc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - mail@christopheraue.net
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rakeTasks"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - README.md
82
+ - Rakefile
83
+ - lib/uinput/device.rb
84
+ - lib/uinput/device/error.rb
85
+ - lib/uinput/device/factory.rb
86
+ - lib/uinput/device/version.rb
87
+ - uinput-device.gemspec
88
+ homepage: https://github.com/christopheraue/ruby-uinput-device
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.8
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Generic ruby wrapper around uinput to create devices.
112
+ test_files: []