fusuma 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config.yml +24 -0
- data/exe/fusuma +5 -0
- data/fusuma.gemspec +27 -0
- data/lib/fusuma.rb +87 -0
- data/lib/fusuma/action_stack.rb +90 -0
- data/lib/fusuma/config.yml +24 -0
- data/lib/fusuma/gesture_action.rb +56 -0
- data/lib/fusuma/version.rb +3 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 210ffddb66e6e96beba56784fdcba46872b84bd7
|
4
|
+
data.tar.gz: 99a6e185643a0616816176ce49076fcf1afa57db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f799865b93d7b33a7721a63b18103f006f51760cd71aa7a1e3d404bd74d3f764954b3e8bbaa9b39c460280d6c0616f601ad0823bc8bfbeafc619c2e66fd54c2
|
7
|
+
data.tar.gz: 40afda3397ac78ac92914cadf7163356d9828c49d93563209008a2a1afdc2100c9f3da631a51a4bc3698686f4e8680f1b2fffc86315143948f1a04a1270888bb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at yhkyky@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 iberianpig
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 iberianpig
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Fusuma
|
2
|
+
|
3
|
+
Fusuma is multitouch gesture recognizer.
|
4
|
+
This gem makes your linux PC able to recognize swipes or pinchs and assign shortcuts to them.
|
5
|
+
|
6
|
+
[![https://gyazo.com/757fef526310b9d68f68e80eb1e4540f](https://i.gyazo.com/757fef526310b9d68f68e80eb1e4540f.png)](https://gyazo.com/757fef526310b9d68f68e80eb1e4540f)
|
7
|
+
|
8
|
+
襖(Fusuma) means sliding door used to partition off rooms in a Japanese house.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
IMPORTANT: You must be a member of the _input_ group to have permission
|
13
|
+
to read the touchpad device:
|
14
|
+
|
15
|
+
$ sudo gpasswd -a $USER input # Log out and back in to assign this group
|
16
|
+
|
17
|
+
You need libinput release 1.0 or later. Install prerequisites:
|
18
|
+
|
19
|
+
If you are using pacman (for archlinux).
|
20
|
+
|
21
|
+
$ sudo pacman -S xdotool
|
22
|
+
|
23
|
+
If you are using apt (for ubuntu/debian based distributions).
|
24
|
+
|
25
|
+
$ sudo apt-get install xdotool
|
26
|
+
|
27
|
+
|
28
|
+
Install Fusuma
|
29
|
+
|
30
|
+
$ gem install fusuma
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
$ fusuma
|
35
|
+
|
36
|
+
## Customize
|
37
|
+
|
38
|
+
|
39
|
+
You can customize the settings for gestues to put and edit `~/.config/fusuma/config.yml`.
|
40
|
+
|
41
|
+
### Sample (default keymap for Elementary OS)
|
42
|
+
|
43
|
+
```yaml
|
44
|
+
swipe:
|
45
|
+
3:
|
46
|
+
left:
|
47
|
+
shortcut: 'alt+Right'
|
48
|
+
right:
|
49
|
+
shortcut: 'alt+Left'
|
50
|
+
up:
|
51
|
+
shortcut: 'ctrl+t'
|
52
|
+
down:
|
53
|
+
shortcut: 'ctrl+w'
|
54
|
+
4:
|
55
|
+
left:
|
56
|
+
shortcut: 'super+Right'
|
57
|
+
right:
|
58
|
+
shortcut: 'super+Left'
|
59
|
+
up:
|
60
|
+
shortcut: 'super+a'
|
61
|
+
down:
|
62
|
+
shortcut: 'super+s'
|
63
|
+
pinch:
|
64
|
+
in:
|
65
|
+
shortcut: 'ctrl+plus'
|
66
|
+
out:
|
67
|
+
shortcut: 'ctrl+minus'
|
68
|
+
```
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/iberianpig/fusuma. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
79
|
+
|
80
|
+
|
81
|
+
## License
|
82
|
+
|
83
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
84
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "fusuma"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/config.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
swipe:
|
2
|
+
3:
|
3
|
+
left:
|
4
|
+
shortcut: 'alt+Right'
|
5
|
+
right:
|
6
|
+
shortcut: 'alt+Left'
|
7
|
+
up:
|
8
|
+
shortcut: 'ctrl+t'
|
9
|
+
down:
|
10
|
+
shortcut: 'ctrl+w'
|
11
|
+
4:
|
12
|
+
left:
|
13
|
+
shortcut: 'super+Right'
|
14
|
+
right:
|
15
|
+
shortcut: 'super+Left'
|
16
|
+
up:
|
17
|
+
shortcut: 'super+a'
|
18
|
+
down:
|
19
|
+
shortcut: 'super+s'
|
20
|
+
pinch:
|
21
|
+
in:
|
22
|
+
shortcut: 'ctrl+plus'
|
23
|
+
out:
|
24
|
+
shortcut: 'ctrl+minus'
|
data/exe/fusuma
ADDED
data/fusuma.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fusuma/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fusuma"
|
8
|
+
spec.version = Fusuma::VERSION
|
9
|
+
spec.authors = ["iberianpig"]
|
10
|
+
spec.email = ["yhkyky@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ Multitouch gestures with libinput dirver on X11, Linux }
|
13
|
+
spec.homepage = "https://github.com/iberianpig/fusuma"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_development_dependency "pry-byebug"
|
27
|
+
end
|
data/lib/fusuma.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative 'fusuma/version'
|
2
|
+
require_relative 'fusuma/action_stack'
|
3
|
+
require_relative 'fusuma/gesture_action'
|
4
|
+
require 'logger'
|
5
|
+
require 'open3'
|
6
|
+
require 'yaml'
|
7
|
+
|
8
|
+
# this is top level module
|
9
|
+
module Fusuma
|
10
|
+
class << self
|
11
|
+
def run
|
12
|
+
read_libinput
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def read_libinput
|
18
|
+
Open3.popen3(libinput_command) do |_i, o, _e, _w|
|
19
|
+
o.each do |line|
|
20
|
+
gesture_action = GestureAction.initialize_by_libinput(line, device_name)
|
21
|
+
next if gesture_action.nil?
|
22
|
+
@action_stack ||= ActionStack.new
|
23
|
+
@action_stack.push gesture_action
|
24
|
+
gesture_info = @action_stack.gesture_info
|
25
|
+
trigger_keyevent(gesture_info) unless gesture_info.nil?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def libinput_command
|
31
|
+
@libinput_command ||= "stdbuf -oL -- libinput-debug-events --device \
|
32
|
+
/dev/input/#{device_name}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def device_name
|
36
|
+
return @device_name unless @device_name.nil?
|
37
|
+
Open3.popen3('libinput-list-devices') do |_i, o, _e, _w|
|
38
|
+
o.each do |line|
|
39
|
+
extracted_input_device_from(line)
|
40
|
+
next unless touch_is_available?(line)
|
41
|
+
return @device_name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def extracted_input_device_from(line)
|
47
|
+
return unless line =~ /^Kernel: /
|
48
|
+
@device_name = line.match(/event[0-9]/).to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
def touch_is_available?(line)
|
52
|
+
return false unless line =~ /^Tap-to-click: /
|
53
|
+
return false if line =~ %r{n/a}
|
54
|
+
true
|
55
|
+
end
|
56
|
+
|
57
|
+
def trigger_keyevent(gesture_info)
|
58
|
+
case gesture_info.action
|
59
|
+
when 'swipe'
|
60
|
+
swipe(gesture_info.finger, gesture_info.direction.move)
|
61
|
+
when 'pinch'
|
62
|
+
pinch(gesture_info.direction.pinch)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def swipe(finger, direction)
|
67
|
+
shortcut = event_map['swipe'][finger.to_i][direction]['shortcut']
|
68
|
+
`xdotool key #{shortcut}`
|
69
|
+
end
|
70
|
+
|
71
|
+
def pinch(zoom)
|
72
|
+
shortcut = event_map['pinch'][zoom]['shortcut']
|
73
|
+
`xdotool key #{shortcut}`
|
74
|
+
end
|
75
|
+
|
76
|
+
def event_map
|
77
|
+
@event_map ||= YAML.load_file(config_file)
|
78
|
+
end
|
79
|
+
|
80
|
+
def config_file
|
81
|
+
filename = 'fusuma/config.yml'
|
82
|
+
original_path = File.expand_path "~/.config/#{filename}"
|
83
|
+
default_path = File.expand_path "../#{filename}"
|
84
|
+
File.exist?(original_path) ? original_path : default_path
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Fusuma
|
2
|
+
# manage actions
|
3
|
+
class ActionStack < Array
|
4
|
+
def initialize(*args)
|
5
|
+
super(*args)
|
6
|
+
end
|
7
|
+
|
8
|
+
# return { finger:, direction:, action: } or nil
|
9
|
+
def gesture_info
|
10
|
+
return unless enough_actions?
|
11
|
+
direction = detect_direction
|
12
|
+
finger = detect_finger
|
13
|
+
action = detect_action
|
14
|
+
clear
|
15
|
+
GestureInfo.new(finger, direction, action)
|
16
|
+
end
|
17
|
+
|
18
|
+
def push(gesture_action)
|
19
|
+
super(gesture_action)
|
20
|
+
clear if action_end?
|
21
|
+
end
|
22
|
+
alias << push
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
GestureInfo = Struct.new(:finger, :direction, :action)
|
27
|
+
Direction = Struct.new(:move, :pinch)
|
28
|
+
|
29
|
+
def detect_direction
|
30
|
+
direction_hash = sum_direction
|
31
|
+
move = detect_move(direction_hash)
|
32
|
+
pinch = detect_pinch(direction_hash)
|
33
|
+
Direction.new(move, pinch)
|
34
|
+
end
|
35
|
+
|
36
|
+
def detect_move(direction_hash)
|
37
|
+
if direction_hash[:move][:x].abs > direction_hash[:move][:y].abs
|
38
|
+
return direction_hash[:move][:x] > 0 ? 'right' : 'left'
|
39
|
+
end
|
40
|
+
direction_hash[:move][:y] > 0 ? 'down' : 'up'
|
41
|
+
end
|
42
|
+
|
43
|
+
def detect_pinch(direction_hash)
|
44
|
+
direction_hash[:pinch] > 1 ? 'in' : 'out'
|
45
|
+
end
|
46
|
+
|
47
|
+
def detect_finger
|
48
|
+
last.finger
|
49
|
+
end
|
50
|
+
|
51
|
+
def sum_direction
|
52
|
+
move_x = sum_attrs(:move_x)
|
53
|
+
move_y = sum_attrs(:move_y)
|
54
|
+
pinch = mul_attrs(:pinch)
|
55
|
+
{ move: { x: move_x, y: move_y }, pinch: pinch }
|
56
|
+
end
|
57
|
+
|
58
|
+
def sum_attrs(attr)
|
59
|
+
send('map') do |gesture_action|
|
60
|
+
gesture_action.send(attr.to_sym.to_s)
|
61
|
+
end.compact.inject(:+)
|
62
|
+
end
|
63
|
+
|
64
|
+
def mul_attrs(attr)
|
65
|
+
send('map') do |gesture_action|
|
66
|
+
num = gesture_action.send(attr.to_sym.to_s)
|
67
|
+
# NOTE: ignore 0.0, treat as 1(immutable)
|
68
|
+
num.zero? ? 1 : num
|
69
|
+
end.compact.inject(:*)
|
70
|
+
end
|
71
|
+
|
72
|
+
def action_end?
|
73
|
+
last_action_name =~ /_END$/
|
74
|
+
end
|
75
|
+
|
76
|
+
def last_action_name
|
77
|
+
return false if last.class != GestureAction
|
78
|
+
last.action
|
79
|
+
end
|
80
|
+
|
81
|
+
def enough_actions?
|
82
|
+
length > 7 # TODO: should be detected by move per time
|
83
|
+
end
|
84
|
+
|
85
|
+
def detect_action
|
86
|
+
first.action =~ /GESTURE_(.*?)_/
|
87
|
+
Regexp.last_match(1).downcase
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
swipe:
|
2
|
+
3:
|
3
|
+
left:
|
4
|
+
shortcut: 'alt+Right'
|
5
|
+
right:
|
6
|
+
shortcut: 'alt+Left'
|
7
|
+
up:
|
8
|
+
shortcut: 'ctrl+t'
|
9
|
+
down:
|
10
|
+
shortcut: 'ctrl+w'
|
11
|
+
4:
|
12
|
+
left:
|
13
|
+
shortcut: 'super+Right'
|
14
|
+
right:
|
15
|
+
shortcut: 'super+Left'
|
16
|
+
up:
|
17
|
+
shortcut: 'super+a'
|
18
|
+
down:
|
19
|
+
shortcut: 'super+s'
|
20
|
+
pinch:
|
21
|
+
in:
|
22
|
+
shortcut: 'ctrl+plus'
|
23
|
+
out:
|
24
|
+
shortcut: 'ctrl+minus'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Fusuma
|
2
|
+
# pinch or swipe action
|
3
|
+
class GestureAction
|
4
|
+
def initialize(time, action, finger, directions)
|
5
|
+
@time = time
|
6
|
+
@action = action
|
7
|
+
@finger = finger
|
8
|
+
@move_x = directions[:move][:x].to_f
|
9
|
+
@move_y = directions[:move][:y].to_f
|
10
|
+
@pinch = directions[:pinch].to_f
|
11
|
+
end
|
12
|
+
attr_reader :time, :action, :finger,
|
13
|
+
:move_x, :move_y, :pinch
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def initialize_by_libinput(line, device_name)
|
17
|
+
return unless line.to_s =~ /^#{device_name}/
|
18
|
+
return if line.to_s =~ /_BEGIN/
|
19
|
+
return unless line.to_s =~ /GESTURE_SWIPE|GESTURE_PINCH/
|
20
|
+
time, action, finger, directions = gesture_action_arguments(line)
|
21
|
+
logger.debug(line)
|
22
|
+
logger.debug(directions)
|
23
|
+
GestureAction.new(time, action, finger, directions)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def gesture_action_arguments(libinput_line)
|
29
|
+
action, time, finger_directions = parse_libinput(libinput_line)
|
30
|
+
finger, move_x, move_y, pinch = parse_finger_directions(finger_directions)
|
31
|
+
directions = { move: { x: move_x, y: move_y }, pinch: pinch }
|
32
|
+
[time, action, finger, directions]
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_libinput(line)
|
36
|
+
_device, action_time, finger_directions = line.split("\t").map(&:strip)
|
37
|
+
action, time = action_time.split
|
38
|
+
[action, time, finger_directions]
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_finger_directions(finger_directions_line)
|
42
|
+
finger_num, move_x, move_y, _, _, _, pinch =
|
43
|
+
finger_directions_line.tr('/', ' ').split
|
44
|
+
[finger_num, move_x, move_y, pinch]
|
45
|
+
end
|
46
|
+
|
47
|
+
def logger
|
48
|
+
@logger ||= begin
|
49
|
+
log = Logger.new(STDOUT)
|
50
|
+
log.level = Logger::WARN
|
51
|
+
log
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fusuma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- iberianpig
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- yhkyky@gmail.com
|
72
|
+
executables:
|
73
|
+
- fusuma
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".rspec"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- config.yml
|
89
|
+
- exe/fusuma
|
90
|
+
- fusuma.gemspec
|
91
|
+
- lib/fusuma.rb
|
92
|
+
- lib/fusuma/action_stack.rb
|
93
|
+
- lib/fusuma/config.yml
|
94
|
+
- lib/fusuma/gesture_action.rb
|
95
|
+
- lib/fusuma/version.rb
|
96
|
+
homepage: https://github.com/iberianpig/fusuma
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Multitouch gestures with libinput dirver on X11, Linux
|
120
|
+
test_files: []
|