fusuma-plugin-tap 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f4bc96ae652bcda2a8d1cf2377ba820a07ee825153d6e1882522e58b2ab6858d
4
+ data.tar.gz: f4f4d27eb30547306affe7b89667bbf8eea53e7da2aa0799acd88641593b1b22
5
+ SHA512:
6
+ metadata.gz: e7b8e79803a6d2e2cbd0d3469a041620b7b89fb4e240815b6a91716a67142a42e02192e1fa32a68a964428fb90adc48955dd63894e6cbc551c6509892a34473c
7
+ data.tar.gz: 2abf4137e293d5f0ed47a43258ee8027623347b1b178ccb665e27dccc06bfa49517af73f6902d0f41ca83a523f1899e2e8ce60b5764de02f87b3b86342d345bd
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/ModuleLength:
4
+ Exclude:
5
+ - "**/*_spec.rb"
6
+
7
+ Metrics/BlockLength:
8
+ Exclude:
9
+ - "**/*_spec.rb"
10
+ - "fusuma.gemspec"
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,49 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-03-20 13:09:40 +0900 using RuboCop version 0.80.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ Metrics/AbcSize:
11
+ Max: 38
12
+
13
+ # Offense count: 1
14
+ # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
16
+ Metrics/BlockLength:
17
+ Max: 26
18
+
19
+ # Offense count: 1
20
+ Metrics/CyclomaticComplexity:
21
+ Max: 22
22
+
23
+ # Offense count: 4
24
+ # Configuration parameters: CountComments, ExcludedMethods.
25
+ Metrics/MethodLength:
26
+ Max: 64
27
+
28
+ # Offense count: 1
29
+ Metrics/PerceivedComplexity:
30
+ Max: 10
31
+
32
+ # Offense count: 1
33
+ # Configuration parameters: MinBodyLength.
34
+ Style/GuardClause:
35
+ Exclude:
36
+ - 'lib/fusuma/plugin/detectors/tap_detector.rb'
37
+
38
+ # Offense count: 3
39
+ # Cop supports --auto-correct.
40
+ Style/IfUnlessModifier:
41
+ Exclude:
42
+ - 'lib/fusuma/plugin/detectors/tap_detector.rb'
43
+
44
+ # Offense count: 32
45
+ # Cop supports --auto-correct.
46
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
47
+ # URISchemes: http, https
48
+ Layout/LineLength:
49
+ Max: 135
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.4.1
7
+ before_install: gem install bundler -v 2.0.1
@@ -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
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in fusuma-plugin-tap.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 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,81 @@
1
+ # Fusuma::Plugin::Tap [![Gem Version](https://badge.fury.io/rb/fusuma-plugin-tap.svg)](https://badge.fury.io/rb/fusuma-plugin-tap) [![Build Status](https://travis-ci.com/iberianpig/fusuma-plugin-tap.svg?branch=master)](https://travis-ci.com/iberianpig/fusuma-plugin-tap)
2
+
3
+ Tap gestures plugin for [Fusuma](https://github.com/iberianpig/fusuma)
4
+
5
+ * Add Tap gestures with 1, 2, 3, 4 fingers
6
+ * Add Hold gestures with 1, 2, 3, 4 fingers
7
+
8
+ ## Installation
9
+
10
+ Run the following code in your terminal.
11
+
12
+ ### Install fusuma-plugin-tap
13
+
14
+ ```sh
15
+ $ sudo gem install fusuma-plugin-tap
16
+ ```
17
+
18
+ ### Add verbose and enable-tap
19
+
20
+ NOTE: **Fusuma require "Tap to click" and "verbose" option to libinput**
21
+
22
+ Open `~/.config/fusuma/config.yml` and add the following code at the bottom.
23
+ If you already have `libinput_command_input` section, just add `enable-tap` and `verbose: true`.
24
+
25
+ ```yaml
26
+ plugin:
27
+ inputs:
28
+ libinput_command_input:
29
+ enable-tap: true
30
+ verbose: true
31
+ ```
32
+
33
+ ### Add tap and hold parameter
34
+
35
+ Set `tap:` and `:hold` property and values under gesture in `~/.config/fusuma/config.yml`.
36
+
37
+ ```yaml
38
+ tap:
39
+ 1:
40
+ command: "echo ----------------tap1----------------------------"
41
+ 2:
42
+ command: "echo ----------------tap2----------------------------"
43
+ 3:
44
+ command: "echo ----------------tap3----------------------------"
45
+ 4:
46
+ command: "echo ----------------tap4----------------------------"
47
+
48
+ hold:
49
+ 1:
50
+ command: "echo ----------------hold1----------------------------"
51
+ 2:
52
+ command: "echo ----------------hold2----------------------------"
53
+ 3:
54
+ command: "echo ----------------hold3----------------------------"
55
+ 4:
56
+ command: "echo ----------------hold4----------------------------"
57
+
58
+ plugin:
59
+ inputs:
60
+ libinput_command_input:
61
+ enable-tap: true
62
+ verbose: true
63
+ ```
64
+
65
+ ## Development
66
+
67
+ 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.
68
+
69
+ 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).
70
+
71
+ ## Contributing
72
+
73
+ Bug reports and pull requests are welcome on GitHub at https://github.com/iberianpig/fusuma-plugin-tap. 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.
74
+
75
+ ## License
76
+
77
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
78
+
79
+ ## Code of Conduct
80
+
81
+ Everyone interacting in the Fusuma::Plugin::Tap project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/iberianpig/fusuma-plugin-tap/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'fusuma'
6
+ require 'fusuma/plugin/tap'
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ require 'pry'
13
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'fusuma/plugin/tap/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'fusuma-plugin-tap'
9
+ spec.version = Fusuma::Plugin::Tap::VERSION
10
+ spec.authors = ['iberianpig']
11
+ spec.email = ['yhkyky@gmail.com']
12
+
13
+ spec.summary = ' Tap gesture plugin for Fusuma '
14
+ spec.description = ' fusuma-plugin-tap is Fusuma plugin for recognizing multitouch tap. '
15
+ spec.homepage = 'https://github.com/iberianpig/fusuma-plugin-tap'
16
+ spec.license = 'MIT'
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = 'exe'
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ['lib']
26
+
27
+ spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
28
+
29
+ spec.add_dependency 'fusuma', '~> 1.5'
30
+
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
33
+ spec.add_development_dependency 'pry-byebug', '~> 3.4'
34
+ spec.add_development_dependency 'pry-doc'
35
+ spec.add_development_dependency 'pry-inline'
36
+ spec.add_development_dependency 'rake', '~> 13.0'
37
+ spec.add_development_dependency 'reek'
38
+ spec.add_development_dependency 'rspec', '~> 3.0'
39
+ spec.add_development_dependency 'rubocop'
40
+ spec.add_development_dependency 'yard'
41
+ end
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fusuma
4
+ module Plugin
5
+ module Buffers
6
+ # manage events and generate command
7
+ class TapBuffer < Buffer
8
+ DEFAULT_SOURCE = 'libinput_tap_parser'
9
+ DEFAULT_SECONDS_TO_KEEP = 0.1
10
+
11
+ def config_param_types
12
+ {
13
+ 'source': [String]
14
+ }
15
+ end
16
+
17
+ # @param event [Event]
18
+ # @return [NilClass, TapBuffer]
19
+ def buffer(event)
20
+ return if event&.tag != source
21
+
22
+ # NOTE: need to set `begin` event at first of buffer
23
+ clear && return unless bufferable?(event)
24
+
25
+ @events.push(event)
26
+ self
27
+ end
28
+
29
+ # return [Integer]
30
+ def finger
31
+ @events.map { |e| e.record.finger }.max
32
+ end
33
+
34
+ def empty?
35
+ @events.empty?
36
+ end
37
+
38
+ def bufferable?(event)
39
+ case event.record.status
40
+ when 'end'
41
+ false
42
+ when 'begin'
43
+ if empty?
44
+ true
45
+ else
46
+ false
47
+ end
48
+ else
49
+ if empty?
50
+ false
51
+ else
52
+ true
53
+ end
54
+ end
55
+ end
56
+
57
+ def present?
58
+ !empty?
59
+ end
60
+
61
+ def select_by_events
62
+ return enum_for(:select) unless block_given?
63
+
64
+ events = @events.select { |event| yield event }
65
+ self.class.new events
66
+ end
67
+
68
+ def ended?(event)
69
+ event.record.status == 'end'
70
+ end
71
+
72
+ def begin?(event)
73
+ event.record.status == 'begin'
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,113 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require 'fusuma/plugin/detectors/detector.rb'
4
+
5
+ module Fusuma
6
+ module Plugin
7
+ module Detectors
8
+ # Detect tap event
9
+ class TapDetector < Detector
10
+ BUFFER_TYPE = 'tap'
11
+ GESTURE_RECORD_TYPE = 'tap'
12
+
13
+ BASE_INTERVAL = 0.5
14
+ BASE_HOLDING_TIME = 0.1
15
+ BASE_TAP_TIME = 1
16
+
17
+ # @param buffers [Array<Buffer>]
18
+ # @return [Event] if event is detected
19
+ # @return [NilClass] if event is NOT detected
20
+ def detect(buffers)
21
+ buffer = buffers.find { |b| b.type == BUFFER_TYPE }
22
+
23
+ return if buffer.empty?
24
+
25
+ finger = buffer.finger
26
+
27
+ holding_time = buffer.events.last.time - buffer.events.first.time
28
+
29
+ direction = if hold?(buffer, holding_time)
30
+ 'hold'
31
+ elsif tap?(buffer, holding_time)
32
+ 'tap'
33
+ end
34
+
35
+ return if direction.nil?
36
+
37
+ buffer.clear
38
+
39
+ index = create_index(finger: finger, direction: direction)
40
+
41
+ return create_event(record: Events::Records::IndexRecord.new(index: index)) if enough?(index: index, direction: direction)
42
+
43
+ nil
44
+ end
45
+
46
+ # @return [Config::Index]
47
+ def create_index(finger:, direction:)
48
+ Config::Index.new(
49
+ [
50
+ Config::Index::Key.new(direction),
51
+ Config::Index::Key.new(finger.to_i)
52
+ ]
53
+ )
54
+ end
55
+
56
+ def hold?(buffer, holding_time)
57
+ return false if holding_time < 1
58
+
59
+ true if buffer.finger == 4 || buffer.events.any? { |e| e.record.status == 'hold' }
60
+ end
61
+
62
+ def tap?(buffer, holding_time)
63
+ return false if holding_time > 0.15
64
+
65
+ tap_released?(buffer)
66
+ end
67
+
68
+ def tap_released?(buffer)
69
+ touch_num = buffer.events.count { |e| (e.record.status =~ /begin|touch/) }
70
+ release_num = buffer.events.count { |e| e.record.status == 'release' }
71
+ MultiLogger.debug(touch_num: touch_num, release_num: release_num)
72
+
73
+ case buffer.finger
74
+ when 1
75
+ touch_num == release_num
76
+ when 2
77
+ touch_num == release_num + 1
78
+ when 3
79
+ touch_num == release_num + 1
80
+ when 4
81
+ touch_num == release_num + 1
82
+ else
83
+ false
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ def enough?(index:, direction:)
90
+ enough_interval?(index: index, direction: direction)
91
+ end
92
+
93
+ def enough_interval?(index:, direction:)
94
+ return true if first_time?
95
+ return true if (Time.now - @last_time) > interval_time(index: index, direction: direction)
96
+
97
+ false
98
+ end
99
+
100
+ def interval_time(index:, direction:)
101
+ @interval_time ||= {}
102
+ @interval_time[index.cache_key] ||= begin
103
+ keys_specific = Config::Index.new [*index.keys, 'interval']
104
+ keys_global = Config::Index.new ['interval', direction]
105
+ config_value = Config.search(keys_specific) ||
106
+ Config.search(keys_global) || 1
107
+ BASE_INTERVAL * config_value
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,147 @@
1
+ # frozen_string_literal: true
2
+
3
+ # require 'fusuma/plugin/parsers/parser.rb'
4
+ # require 'fusuma/plugin/events/event.rb'
5
+
6
+ module Fusuma
7
+ module Plugin
8
+ module Parsers
9
+ # parse libinput and generate event
10
+ class TapParser < Parser
11
+ DEFAULT_SOURCE = 'libinput_command_input'
12
+
13
+ # TAP_STATE_IDLE = 4,
14
+ # TAP_STATE_TOUCH,
15
+ # TAP_STATE_HOLD,
16
+ # TAP_STATE_TAPPED,
17
+ # TAP_STATE_TOUCH_2,
18
+ # TAP_STATE_TOUCH_2_HOLD,
19
+ # TAP_STATE_TOUCH_2_RELEASE,
20
+ # TAP_STATE_TOUCH_3,
21
+ # TAP_STATE_TOUCH_3_HOLD,
22
+ # TAP_STATE_DRAGGING_OR_DOUBLETAP,
23
+ # TAP_STATE_DRAGGING_OR_TAP,
24
+ # TAP_STATE_DRAGGING,
25
+ # TAP_STATE_DRAGGING_WAIT,
26
+ # TAP_STATE_DRAGGING_2,
27
+ # TAP_STATE_DEAD
28
+ STATE = {
29
+ idle: 'TAP_STATE_IDLE',
30
+ holds: %w[
31
+ TAP_STATE_TOUCH_3_HOLD
32
+ TAP_STATE_TOUCH_2_HOLD
33
+ TAP_STATE_HOLD
34
+ TAP_STATE_DEAD
35
+ ],
36
+ touches: %w[
37
+ TAP_STATE_TOUCH_3
38
+ TAP_STATE_TOUCH_2
39
+ TAP_STATE_TOUCH
40
+ TAP_STATE_DEAD
41
+ ],
42
+ releases: %w[
43
+ TAP_STATE_TOUCH_2_RELEASE
44
+ TAP_STATE_TOUCH_2_HOLD
45
+ TAP_STATE_TAPPED
46
+ TAP_STATE_HOLD
47
+ TAP_STATE_DEAD
48
+ ]
49
+ }.freeze
50
+
51
+ # @param record [String]
52
+ # @return [Records::Gesture, nil]
53
+ def parse_record(record)
54
+ gesture = 'tap'
55
+
56
+ case record.to_s
57
+ # BEGIN
58
+ when /\stap state:\s.*TAP_STATE_IDLE → TAP_EVENT_TOUCH → TAP_STATE_TOUCH/
59
+ status = 'begin'
60
+ finger = 1
61
+
62
+ # TOUCH
63
+ when /\stap state:\s.*(#{STATE[:touches].join('|')}) → TAP_EVENT_TOUCH → (#{STATE[:touches].join('|')})/
64
+
65
+ status = 'touch'
66
+
67
+ finger = case Regexp.last_match(2)
68
+ when 'TAP_STATE_DEAD'
69
+ 4
70
+ when 'TAP_STATE_TOUCH_3'
71
+ 3
72
+ when 'TAP_STATE_TOUCH_2'
73
+ 2
74
+ when 'TAP_STATE_TOUCH'
75
+ 1
76
+ end
77
+
78
+ # HOLD
79
+ when /\stap state:\s.*(#{STATE[:touches].join('|')}) → TAP_EVENT_TIMEOUT → (#{STATE[:holds].join('|')})/
80
+
81
+ status = 'hold'
82
+
83
+ matched = Regexp.last_match
84
+
85
+ finger = case matched[2]
86
+ when 'TAP_STATE_DEAD'
87
+ 4
88
+ when 'TAP_STATE_TOUCH_3_HOLD'
89
+ 3
90
+ when 'TAP_STATE_TOUCH_2_HOLD'
91
+ 2
92
+ when 'TAP_STATE_HOLD'
93
+ 1
94
+ end
95
+ # KEEP
96
+ when /\sgesture state:\s/
97
+ # NOTE: treat the "gesture state:" as KEEP
98
+ status = 'keep'
99
+ finger = 0
100
+
101
+ # RELEASE
102
+ when /\stap state:\s.*(#{(STATE[:touches] | STATE[:holds]).join('|')}) → TAP_EVENT_RELEASE → (#{STATE[:releases].join('|')})/
103
+
104
+ status = 'release'
105
+ matched = Regexp.last_match
106
+
107
+ finger = case matched[1]
108
+ when 'TAP_STATE_DEAD'
109
+ 4
110
+ when 'TAP_STATE_TOUCH_3', 'TAP_STATE_TOUCH_3_HOLD'
111
+ 3
112
+ when 'TAP_STATE_TOUCH_2', 'TAP_STATE_TOUCH_2_HOLD'
113
+ 2
114
+ when 'TAP_STATE_TOUCH', 'TAP_STATE_HOLD'
115
+ 1
116
+ end
117
+
118
+ # END
119
+ when /\stap state:\s.*(#{STATE[:releases].join('|')}) → TAP_EVENT_(.*) → #{STATE[:idle]}/
120
+ status = 'end'
121
+
122
+ matched = Regexp.last_match
123
+ finger = case matched[1]
124
+ when 'TAP_STATE_TOUCH_3', 'TAP_STATE_TOUCH_3_HOLD'
125
+ 3
126
+ when 'TAP_STATE_TOUCH_2', 'TAP_STATE_TOUCH_2_HOLD', 'TAP_STATE_TOUCH_2_RELEASE'
127
+ 2
128
+ when 'TAP_STATE_TOUCH', 'TAP_STATE_HOLD', 'TAP_STATE_TAPPED'
129
+ 1
130
+ end
131
+ else
132
+ return
133
+ end
134
+
135
+ Events::Records::GestureRecord.new(status: status,
136
+ gesture: gesture,
137
+ finger: finger,
138
+ direction: nil)
139
+ end
140
+
141
+ def tag
142
+ 'libinput_tap_parser'
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './tap/version'
4
+ require_relative './detectors/tap_detector.rb'
5
+ require_relative './parsers/tap_parser.rb'
6
+ require_relative './buffers/tap_buffer.rb'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Fusuma
4
+ module Plugin
5
+ module Tap
6
+ VERSION = '0.1.0'
7
+ end
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fusuma-plugin-tap
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: 2020-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fusuma
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: github_changelog_generator
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.14'
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: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry-doc
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-inline
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '13.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '13.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: reek
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: " fusuma-plugin-tap is Fusuma plugin for recognizing multitouch tap. "
168
+ email:
169
+ - yhkyky@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - ".rubocop.yml"
177
+ - ".rubocop_todo.yml"
178
+ - ".travis.yml"
179
+ - CODE_OF_CONDUCT.md
180
+ - Gemfile
181
+ - LICENSE.txt
182
+ - README.md
183
+ - Rakefile
184
+ - bin/console
185
+ - bin/setup
186
+ - fusuma-plugin-tap.gemspec
187
+ - lib/fusuma/plugin/buffers/tap_buffer.rb
188
+ - lib/fusuma/plugin/detectors/tap_detector.rb
189
+ - lib/fusuma/plugin/parsers/tap_parser.rb
190
+ - lib/fusuma/plugin/tap.rb
191
+ - lib/fusuma/plugin/tap/version.rb
192
+ homepage: https://github.com/iberianpig/fusuma-plugin-tap
193
+ licenses:
194
+ - MIT
195
+ metadata: {}
196
+ post_install_message:
197
+ rdoc_options: []
198
+ require_paths:
199
+ - lib
200
+ required_ruby_version: !ruby/object:Gem::Requirement
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ version: '2.3'
205
+ required_rubygems_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ requirements: []
211
+ rubygems_version: 3.0.6
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Tap gesture plugin for Fusuma
215
+ test_files: []