fusuma-plugin-tap 0.1.3 → 0.4.0.pre

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e02d886ca531aba36e5b71ed134b76062a72430a17a21f7a0a5a5941652c657f
4
- data.tar.gz: 8107fa9c300cd78028589198fe64ee4897bf5abbf3dc1621779102d0a3d66c58
3
+ metadata.gz: 17a8597b18f259832d7d6d0dce336d6d9435d000a1adc6656a1dc67b53d3037e
4
+ data.tar.gz: 5f909eb2fe3be8766cef41235c80710880a51ebde67c0e91e76affe12b000722
5
5
  SHA512:
6
- metadata.gz: 45f9c11102b3b6e530c647c9b8c7c9f10e5ea9820f5742cb858ea2dd2a014e5fbcb0b0ba37821d6c88268111c548a0276b0319a004ccd8ffeb64ca4e9eb31b3e
7
- data.tar.gz: 904e5c91e57005cf20000986621979b2da18abf171161b6b831a7ffb8432d4bed6e408352655107c9c8667ddc7aea9c5d545e48a147b900775325d3a3be361df
6
+ metadata.gz: fe0c32c71db497489620a5ceefbb4ac172c8d7003fe957432f3a779e27ed7ecbe5f4c96c3f23a38f67bc557421d250e0582a729eef31cb00f2b248606826d4f5
7
+ data.tar.gz: 5f8b2730af48d13f85f4bdf42073669f7d8aea9eb0d2a70f4c521327b2aa1506714c50d80c21fbd3e516ced76cf72015976593a6859b602c71ed38b6df6c534a
@@ -18,6 +18,11 @@ Metrics/MethodLength:
18
18
  - 'lib/fusuma/plugin/parsers/tap_parser.rb'
19
19
  - 'lib/fusuma/plugin/parsers/tap_detector.rb'
20
20
 
21
+ Metrics/ClassLength:
22
+ Exclude:
23
+ - 'lib/fusuma/plugin/parsers/tap_parser.rb'
24
+ - 'lib/fusuma/plugin/parsers/tap_detector.rb'
25
+
21
26
  Layout/LineLength:
22
27
  Max: 100
23
28
  Exclude:
@@ -1,19 +1,11 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-04-20 01:40:44 +0900 using RuboCop version 0.82.0.
3
+ # on 2020-07-05 15:49:25 UTC using RuboCop version 0.86.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 1
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: TreatCommentsAsGroupSeparators, Include.
12
- # Include: **/*.gemspec
13
- Gemspec/OrderedDependencies:
14
- Exclude:
15
- - 'fusuma-plugin-tap.gemspec'
16
-
17
9
  # Offense count: 1
18
10
  # Configuration parameters: Include.
19
11
  # Include: **/*.gemspec
@@ -24,7 +16,7 @@ Gemspec/RequiredRubyVersion:
24
16
  # Offense count: 5
25
17
  # Configuration parameters: IgnoredMethods.
26
18
  Metrics/AbcSize:
27
- Max: 38
19
+ Max: 42
28
20
 
29
21
  # Offense count: 1
30
22
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -32,20 +24,20 @@ Metrics/AbcSize:
32
24
  Metrics/BlockLength:
33
25
  Max: 33
34
26
 
35
- # Offense count: 1
27
+ # Offense count: 3
36
28
  # Configuration parameters: IgnoredMethods.
37
29
  Metrics/CyclomaticComplexity:
38
- Max: 22
30
+ Max: 25
39
31
 
40
32
  # Offense count: 5
41
33
  # Configuration parameters: CountComments, ExcludedMethods.
42
34
  Metrics/MethodLength:
43
35
  Max: 45
44
36
 
45
- # Offense count: 1
37
+ # Offense count: 2
46
38
  # Configuration parameters: IgnoredMethods.
47
39
  Metrics/PerceivedComplexity:
48
- Max: 10
40
+ Max: 13
49
41
 
50
42
  # Offense count: 1
51
43
  Style/Documentation:
@@ -53,3 +45,12 @@ Style/Documentation:
53
45
  - 'spec/**/*'
54
46
  - 'test/**/*'
55
47
  - 'bin/evemu_recorder.rb'
48
+
49
+ # Offense count: 2
50
+ # Cop supports --auto-correct.
51
+ # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
52
+ # SupportedStyles: predicate, comparison
53
+ Style/NumericPredicate:
54
+ Exclude:
55
+ - 'spec/**/*'
56
+ - 'lib/fusuma/plugin/detectors/tap_detector.rb'
@@ -5,8 +5,9 @@ cache: bundler
5
5
 
6
6
  env:
7
7
  matrix:
8
- - SPEC_LIBINPUT_VERSION=1.10.4
9
- - SPEC_LIBINPUT_VERSION=1.14.1
8
+ - LIBINPUT_VERSION=1.10.4
9
+ - LIBINPUT_VERSION=1.14.1
10
+ - LIBINPUT_VERSION=1.15.5
10
11
 
11
12
  cache:
12
13
  directories:
@@ -17,5 +18,6 @@ rvm:
17
18
  - 2.4
18
19
  - 2.5
19
20
  - 2.6
21
+ - 2.7
20
22
 
21
23
  before_install: gem install bundler --no-document -v 2.0.1
@@ -1,5 +1,53 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.4.0.pre](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.4.0.pre) (2020-11-09)
4
+
5
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.2...v0.4.0.pre)
6
+
7
+ ## [v0.3.2](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.2) (2020-08-13)
8
+
9
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.1...v0.3.2)
10
+
11
+ **Fixed bugs:**
12
+
13
+ - Fix Parser when detecting a false 4 finger tap after a pinch gesture [\#5](https://github.com/iberianpig/fusuma-plugin-tap/pull/5) ([iberianpig](https://github.com/iberianpig))
14
+
15
+ **Closed issues:**
16
+
17
+ - tap 4 not registered [\#4](https://github.com/iberianpig/fusuma-plugin-tap/issues/4)
18
+
19
+ **Merged pull requests:**
20
+
21
+ - test\(tap\_parser\): reproduce the bug that 4 finger tap after detecting palm [\#8](https://github.com/iberianpig/fusuma-plugin-tap/pull/8) ([iberianpig](https://github.com/iberianpig))
22
+
23
+ ## [v0.3.1](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.1) (2020-05-15)
24
+
25
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.0...v0.3.1)
26
+
27
+ **Closed issues:**
28
+
29
+ - Reduce false positives with Hold gesture [\#2](https://github.com/iberianpig/fusuma-plugin-tap/issues/2)
30
+
31
+ ## [v0.3.0](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.0) (2020-05-10)
32
+
33
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.2.0...v0.3.0)
34
+
35
+ **Closed issues:**
36
+
37
+ - 4 finger tap / hold is not being registered [\#1](https://github.com/iberianpig/fusuma-plugin-tap/issues/1)
38
+
39
+ ## [v0.2.0](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.2.0) (2020-05-05)
40
+
41
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.3...v0.2.0)
42
+
43
+ **Merged pull requests:**
44
+
45
+ - Support libinput v1.15.5 [\#3](https://github.com/iberianpig/fusuma-plugin-tap/pull/3) ([iberianpig](https://github.com/iberianpig))
46
+
47
+ ## [v0.1.3](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.1.3) (2020-04-20)
48
+
49
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.1...v0.1.3)
50
+
3
51
  ## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.1.1) (2020-04-19)
4
52
 
5
53
  [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.0...v0.1.1)
@@ -0,0 +1,14 @@
1
+ .PHONY: all test clean
2
+
3
+ all: help
4
+
5
+ build: ## build libinput with LIBINPUT_VERSION
6
+ cd $(LIBINPUT_SOURCE_DIR) && \
7
+ git checkout $(LIBINPUT_VERSION) && \
8
+ meson --prefix=/usr builddir/ -Dlibwacom=false -Ddebug-gui=false -Dtests=false -Ddocumentation=false --reconfigure && \
9
+ ninja -C builddir/
10
+ $(LIBINPUT_LIST_DEVICES) --version
11
+
12
+ help: ## show help
13
+ @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | uniq | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
14
+
data/README.md CHANGED
@@ -62,6 +62,11 @@ plugin:
62
62
  verbose: true
63
63
  ```
64
64
 
65
+ ## Known issues
66
+ * `libinput debug-events --verbose` outputs is unstable, so it may not work properly with some versions of libinput.
67
+ * **libinput 1.10.4 contains a bug that suddenly stopped detecting taps.**
68
+ * ref: https://github.com/iberianpig/fusuma-plugin-tap/pull/8
69
+
65
70
  ## Development
66
71
 
67
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.
@@ -12,6 +12,7 @@ class LibinputDebugEventsGenerator
12
12
  @gesture_name = Pathname.new(evemu_record).basename
13
13
  @list_devices = ENV.fetch('LIBINPUT_LIST_DEVICES', 'libinput list-devices')
14
14
  @debug_events = ENV.fetch('LIBINPUT_DEBUG_EVENTS', 'libinput debug-events')
15
+ @libinput_version = ENV.fetch('LIBINPUT_VERSION', 'libinput list-devices')
15
16
  end
16
17
 
17
18
  def generate_debug_events
@@ -89,7 +90,9 @@ class LibinputDebugEventsGenerator
89
90
  end
90
91
 
91
92
  def version
92
- @version ||= `#{@list_devices} --version`.chomp
93
+ raise 'Make rebuild libinput' unless @libinput_version == `#{@list_devices} --version`.chomp
94
+
95
+ @libinput_version
93
96
  end
94
97
  end
95
98
 
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
 
27
27
  spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all&section=main
28
28
 
29
- spec.add_dependency 'fusuma', '~> 1.5'
29
+ spec.add_dependency 'fusuma', '~> 2.0.0.pre'
30
30
 
31
31
  spec.add_development_dependency 'bundler'
32
32
  spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
@@ -14,10 +14,15 @@ module Fusuma
14
14
  }
15
15
  end
16
16
 
17
+ # clear old events
18
+ def clear_expired(*)
19
+ clear if @events.any? { |e| ended?(e) }
20
+ end
21
+
17
22
  # @param event [Event]
18
23
  # @return [NilClass, TapBuffer]
19
24
  def buffer(event)
20
- return if event&.tag != source
25
+ return unless event&.tag == source
21
26
 
22
27
  # NOTE: need to set `begin` event at first of buffer
23
28
  clear && return unless bufferable?(event)
@@ -38,19 +43,21 @@ module Fusuma
38
43
  def bufferable?(event)
39
44
  case event.record.status
40
45
  when 'end'
41
- false
46
+ true
42
47
  when 'begin'
43
48
  if empty?
44
49
  true
45
50
  else
46
51
  false
47
52
  end
48
- else
53
+ when 'keep', 'touch', 'hold', 'release', 'move'
49
54
  if empty?
50
55
  false
51
56
  else
52
57
  true
53
58
  end
59
+ else
60
+ raise "Unexpected status: #{event.record.status}"
54
61
  end
55
62
  end
56
63
 
@@ -12,29 +12,33 @@ module Fusuma
12
12
 
13
13
  BASE_INTERVAL = 0.5
14
14
  BASE_HOLDING_TIME = 0.1
15
- BASE_TAP_TIME = 1
15
+ BASE_TAP_TIME = 0.4
16
16
 
17
17
  # @param buffers [Array<Buffer>]
18
18
  # @return [Event] if event is detected
19
19
  # @return [NilClass] if event is NOT detected
20
20
  def detect(buffers)
21
- buffer = buffers.find { |b| b.type == BUFFER_TYPE }
21
+ tap_buffer = buffers.find { |b| b.type == BUFFER_TYPE }
22
+ gesture_buffer = buffers.find { |b| b.type == 'gesture' }
23
+ timer_buffer = buffers.find { |b| b.type == 'timer' }
22
24
 
23
- return if buffer.empty?
24
-
25
- finger = buffer.finger
25
+ if tap_buffer.empty? || moved?(tap_buffer: tap_buffer, gesture_buffer: gesture_buffer)
26
+ return
27
+ end
26
28
 
27
- holding_time = buffer.events.last.time - buffer.events.first.time
29
+ holding_time = calc_holding_time(tap_buffer: tap_buffer, timer_buffer: timer_buffer)
28
30
 
29
- direction = if hold?(buffer, holding_time)
31
+ direction = if hold?(tap_buffer, holding_time)
30
32
  'hold'
31
- elsif tap?(buffer, holding_time)
33
+ elsif tap?(tap_buffer, holding_time)
32
34
  'tap'
33
35
  end
34
36
 
35
37
  return if direction.nil?
36
38
 
37
- buffer.clear
39
+ finger = tap_buffer.finger
40
+
41
+ tap_buffer.clear # NOTE: Clear after detecting hold
38
42
 
39
43
  index = create_index(finger: finger, direction: direction)
40
44
 
@@ -53,23 +57,33 @@ module Fusuma
53
57
  )
54
58
  end
55
59
 
60
+ # @return [TrueClass, FalseClass]
56
61
  def hold?(buffer, holding_time)
57
- return false if holding_time < 1
62
+ return false if holding_time < 0.7
58
63
 
59
64
  return true if buffer.finger == 4
60
65
 
61
66
  true if buffer.events.any? { |e| e.record.status == 'hold' }
62
67
  end
63
68
 
69
+ # @return [TrueClass, FalseClass]
64
70
  def tap?(buffer, holding_time)
65
71
  return false if holding_time > 0.15
66
72
 
67
- tap_released?(buffer)
73
+ released_all?(buffer)
74
+ end
75
+
76
+ # @return [TrueClass, FalseClass]
77
+ def moved?(tap_buffer:, gesture_buffer:)
78
+ tap_buffer.events.any? { |e| e.record.status == 'move' } ||
79
+ # FIXME: Find good parameter for ignoring
80
+ gesture_buffer.events.count { |e| tap_buffer.events.first.time < e.time } > 5
68
81
  end
69
82
 
70
- def tap_released?(buffer)
83
+ # @return [TrueClass, FalseClass]
84
+ def released_all?(buffer)
71
85
  touch_num = buffer.events.count { |e| (e.record.status =~ /begin|touch/) }
72
- release_num = buffer.events.count { |e| e.record.status == 'release' }
86
+ release_num = buffer.events.count { |e| e.record.status =~ /release|end/ }
73
87
  MultiLogger.debug(touch_num: touch_num, release_num: release_num)
74
88
 
75
89
  case buffer.finger
@@ -80,12 +94,22 @@ module Fusuma
80
94
  when 3
81
95
  touch_num == release_num + 1
82
96
  when 4
83
- touch_num == release_num + 1
97
+ touch_num > 0 && release_num > 0
84
98
  else
85
99
  false
86
100
  end
87
101
  end
88
102
 
103
+ def calc_holding_time(tap_buffer:, timer_buffer:)
104
+ last_time = if timer_buffer && !timer_buffer.empty? &&
105
+ (tap_buffer.events.last.time < timer_buffer.events.last.time)
106
+ timer_buffer.events.last.time
107
+ else
108
+ tap_buffer.events.last.time
109
+ end
110
+ last_time - tap_buffer.events.first.time
111
+ end
112
+
89
113
  private
90
114
 
91
115
  def enough?(index:, direction:)
@@ -54,19 +54,24 @@ module Fusuma
54
54
  gesture = 'tap'
55
55
 
56
56
  case record.to_s
57
- # BEGIN
57
+
58
+ # BEGIN
58
59
  when /\stap(?:| state):\s.*TAP_STATE_IDLE → TAP_EVENT_TOUCH → TAP_STATE_TOUCH/
59
60
  status = 'begin'
60
61
  finger = 1
61
62
 
62
- # TOUCH
63
- when /\stap(?:| state):\s.*(#{STATE[:touches].join('|')}) → TAP_EVENT_TOUCH → (#{STATE[:touches].join('|')})/
63
+ # TOUCH
64
+ when /\stap(?:| state):\s.*(#{STATE[:touches].join('|')}) → TAP_EVENT_(?:TOUCH|MOTION) → (#{STATE[:touches].join('|')})/
64
65
 
65
66
  status = 'touch'
66
67
 
67
68
  finger = case Regexp.last_match(2)
68
69
  when 'TAP_STATE_DEAD'
69
- 4
70
+ if Regexp.last_match(1) == 'TAP_STATE_TOUCH_3'
71
+ 4
72
+ else
73
+ 0
74
+ end
70
75
  when 'TAP_STATE_TOUCH_3'
71
76
  3
72
77
  when 'TAP_STATE_TOUCH_2'
@@ -93,11 +98,16 @@ module Fusuma
93
98
  1
94
99
  end
95
100
  # KEEP
96
- when /\sgesture(| state):\s/
101
+ when /\sgesture(| state):\s/ # 1.10.4 prints "gesture state: GESTURE_STATE_.*"
97
102
  # NOTE: treat the "gesture(| state):" as KEEP
98
103
  status = 'keep'
99
104
  finger = 0
100
105
 
106
+ # MOVE
107
+ when /\sPOINTER_AXIS\s/, /\sPOINTER_MOTION\s/, /\sTAP_EVENT_PALM\s/
108
+ status = 'move'
109
+ finger = 0
110
+
101
111
  # RELEASE
102
112
  when /\stap(?:| state):\s.*(#{(STATE[:touches] | STATE[:holds]).join('|')}) → TAP_EVENT_RELEASE → (#{STATE[:releases].join('|')})/
103
113
 
@@ -121,6 +131,8 @@ module Fusuma
121
131
 
122
132
  matched = Regexp.last_match
123
133
  finger = case matched[1]
134
+ when 'TAP_STATE_DEAD' # NOTE: 2 finger hold -> scroll become TAP_STATE_DEAD
135
+ 0
124
136
  when 'TAP_STATE_TOUCH_3', 'TAP_STATE_TOUCH_3_HOLD'
125
137
  3
126
138
  when 'TAP_STATE_TOUCH_2', 'TAP_STATE_TOUCH_2_HOLD', 'TAP_STATE_TOUCH_2_RELEASE'
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Tap
6
- VERSION = '0.1.3'
6
+ VERSION = '0.4.0.pre'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fusuma-plugin-tap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.4.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-20 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusuma
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.5'
19
+ version: 2.0.0.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.5'
26
+ version: 2.0.0.pre
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +152,7 @@ files:
152
152
  - CODE_OF_CONDUCT.md
153
153
  - Gemfile
154
154
  - LICENSE.txt
155
+ - Makefile
155
156
  - README.md
156
157
  - Rakefile
157
158
  - bin/console
@@ -168,7 +169,7 @@ homepage: https://github.com/iberianpig/fusuma-plugin-tap
168
169
  licenses:
169
170
  - MIT
170
171
  metadata: {}
171
- post_install_message:
172
+ post_install_message:
172
173
  rdoc_options: []
173
174
  require_paths:
174
175
  - lib
@@ -179,12 +180,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
180
  version: '2.3'
180
181
  required_rubygems_version: !ruby/object:Gem::Requirement
181
182
  requirements:
182
- - - ">="
183
+ - - ">"
183
184
  - !ruby/object:Gem::Version
184
- version: '0'
185
+ version: 1.3.1
185
186
  requirements: []
186
- rubygems_version: 3.0.6
187
- signing_key:
187
+ rubygems_version: 3.1.4
188
+ signing_key:
188
189
  specification_version: 4
189
190
  summary: Tap gesture plugin for Fusuma
190
191
  test_files: []