fusuma-plugin-tap 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bedc73a6f30eada228504ea4b0c09b7c8cfb274a67764f6bcc93df88d63439d
4
- data.tar.gz: 9b00f18217502e62dc83776231bf6de7ef5f7705f04178c67f4dd1f569675a77
3
+ metadata.gz: 0b2d9fc25b57d8e8475739f63334e1996b382790d2f69934cfc4af3a191cf183
4
+ data.tar.gz: 9b7b628758a30e219c902b7e9a62675b415251277c078b2e40b794f7c7c2b1aa
5
5
  SHA512:
6
- metadata.gz: 11ea664f6f1ca08ef08fc0ef759634066a7f813cf5b43502294a034e96349e58fddbce4e223d3ac858c847d9a508a91335b4f262bc25b992e91f3559a9591a82
7
- data.tar.gz: a0db20541d07c7542b7c38b8c6f34cd61160dce875dfd103251446dc80cf173fd6fec1e20cc61d476bf912af7b6c2ae024e4e2e761577c1e87165f157c86cc56
6
+ metadata.gz: 9d6e782d13635368460a1f6f2c6ae04a3f09aec5e4d22b9ef8f9f12030c81570fb0cd174573e0aa5c25b9022163c8d43edd6de84c378cd81c75aaa58c7d31877
7
+ data.tar.gz: ad374930be4394b1bfc503024115b1dd6181eb3d597ba02f4095002fed3fbcca8a60d8ccfa04b11034f5ba42532448f3ddf63d3cff67085edc62dbc8da35af15
data/.rubocop.yml CHANGED
@@ -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:
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-05-10 21:28:27 +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
@@ -16,7 +16,7 @@ Gemspec/RequiredRubyVersion:
16
16
  # Offense count: 5
17
17
  # Configuration parameters: IgnoredMethods.
18
18
  Metrics/AbcSize:
19
- Max: 40
19
+ Max: 42
20
20
 
21
21
  # Offense count: 1
22
22
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -27,17 +27,17 @@ Metrics/BlockLength:
27
27
  # Offense count: 3
28
28
  # Configuration parameters: IgnoredMethods.
29
29
  Metrics/CyclomaticComplexity:
30
- Max: 24
30
+ Max: 25
31
31
 
32
32
  # Offense count: 5
33
33
  # Configuration parameters: CountComments, ExcludedMethods.
34
34
  Metrics/MethodLength:
35
35
  Max: 45
36
36
 
37
- # Offense count: 3
37
+ # Offense count: 2
38
38
  # Configuration parameters: IgnoredMethods.
39
39
  Metrics/PerceivedComplexity:
40
- Max: 11
40
+ Max: 13
41
41
 
42
42
  # Offense count: 1
43
43
  Style/Documentation:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.4.0.pre2](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.4.0.pre2) (2021-03-29)
4
+
5
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.4.0.pre...v0.4.0.pre2)
6
+
7
+ ## [v0.4.0.pre](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.4.0.pre) (2020-11-09)
8
+
9
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.2...v0.4.0.pre)
10
+
11
+ ## [v0.3.2](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.2) (2020-08-13)
12
+
13
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.1...v0.3.2)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - 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))
18
+
19
+ **Closed issues:**
20
+
21
+ - tap 4 not registered [\#4](https://github.com/iberianpig/fusuma-plugin-tap/issues/4)
22
+
23
+ **Merged pull requests:**
24
+
25
+ - 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))
26
+
27
+ ## [v0.3.1](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.1) (2020-05-15)
28
+
29
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.3.0...v0.3.1)
30
+
31
+ **Closed issues:**
32
+
33
+ - Reduce false positives with Hold gesture [\#2](https://github.com/iberianpig/fusuma-plugin-tap/issues/2)
34
+
35
+ ## [v0.3.0](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.3.0) (2020-05-10)
36
+
37
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.2.0...v0.3.0)
38
+
39
+ **Closed issues:**
40
+
41
+ - 4 finger tap / hold is not being registered [\#1](https://github.com/iberianpig/fusuma-plugin-tap/issues/1)
42
+
3
43
  ## [v0.2.0](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.2.0) (2020-05-05)
4
44
 
5
45
  [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.3...v0.2.0)
data/Makefile CHANGED
@@ -3,11 +3,22 @@
3
3
  all: help
4
4
 
5
5
  build: ## build libinput with LIBINPUT_VERSION
6
- cd $(LIBINPUT_SOURCE_DIR) && \
6
+ cd $(LIBINPUT_REPO) && \
7
+ git fetch && \
7
8
  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
9
+ mkdir -p builddir/$(LIBINPUT_VERSION)/ && \
10
+ meson --prefix=/usr builddir/$(LIBINPUT_VERSION)/ -Dlibwacom=false -Ddebug-gui=false -Dtests=false -Ddocumentation=false && \
11
+ ninja -C builddir/$(LIBINPUT_VERSION)/
12
+ $(LIBINPUT_REPO)/builddir/$(LIBINPUT_VERSION)/libinput-list-devices --version
13
+
14
+ version: ## libinput list-devces --version
15
+ $(LIBINPUT_REPO)/builddir/$(LIBINPUT_VERSION)/libinput-list-devices --version
16
+
17
+ list-devices: ## libinput list-devices
18
+ $(LIBINPUT_REPO)/builddir/$(LIBINPUT_VERSION)/libinput-list-devices
19
+
20
+ debug-events: ## libinput debug-events
21
+ $(LIBINPUT_REPO)/builddir/$(LIBINPUT_VERSION)/libinput-debug-events --enable-tap --verbose
11
22
 
12
23
  help: ## show help
13
24
  @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | uniq | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
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.
@@ -4,15 +4,16 @@
4
4
  require 'fileutils'
5
5
  require 'pathname'
6
6
  require 'fusuma/device'
7
+ require 'fusuma/plugin/inputs/libinput_command_input'
7
8
 
8
9
  # Generate libinput generator
9
10
  class LibinputDebugEventsGenerator
10
11
  def initialize(evemu_record:)
11
12
  @evemu_record = evemu_record
12
13
  @gesture_name = Pathname.new(evemu_record).basename
13
- @list_devices = ENV.fetch('LIBINPUT_LIST_DEVICES', 'libinput list-devices')
14
- @debug_events = ENV.fetch('LIBINPUT_DEBUG_EVENTS', 'libinput debug-events')
15
- @libinput_version = ENV.fetch('LIBINPUT_VERSION', 'libinput list-devices')
14
+ @list_devices = ENV.fetch('LIBINPUT_LIST_DEVICES')
15
+ @debug_events = ENV.fetch('LIBINPUT_DEBUG_EVENTS')
16
+ @libinput_version = ENV.fetch('LIBINPUT_VERSION')
16
17
  end
17
18
 
18
19
  def generate_debug_events
@@ -41,6 +42,10 @@ class LibinputDebugEventsGenerator
41
42
  rescue Timeout::Error
42
43
  puts 'cut out device infos'
43
44
  end
45
+ if `which evemu-play` == ''
46
+ warn 'evemu-play is not found'
47
+ exit 1
48
+ end
44
49
 
45
50
  command = "evemu-play /dev/input/#{device_id} < #{@evemu_record}"
46
51
 
@@ -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.10'
29
+ spec.add_dependency 'fusuma', '~> 2.0.0'
30
30
 
31
31
  spec.add_development_dependency 'bundler'
32
32
  spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
@@ -22,7 +22,7 @@ module Fusuma
22
22
  # @param event [Event]
23
23
  # @return [NilClass, TapBuffer]
24
24
  def buffer(event)
25
- return unless (event&.tag == source) || (event&.tag == 'libinput_gesture_parser')
25
+ return unless event&.tag == source
26
26
 
27
27
  # NOTE: need to set `begin` event at first of buffer
28
28
  clear && return unless bufferable?(event)
@@ -56,12 +56,6 @@ module Fusuma
56
56
  else
57
57
  true
58
58
  end
59
- when 'update' # libinput_gesture_parser
60
- if empty?
61
- false
62
- else
63
- true
64
- end
65
59
  else
66
60
  raise "Unexpected status: #{event.record.status}"
67
61
  end
@@ -7,6 +7,7 @@ module Fusuma
7
7
  module Detectors
8
8
  # Detect tap event
9
9
  class TapDetector < Detector
10
+ SOURCES = ['tap', 'gesture', 'timer']
10
11
  BUFFER_TYPE = 'tap'
11
12
  GESTURE_RECORD_TYPE = 'tap'
12
13
 
@@ -18,24 +19,27 @@ module Fusuma
18
19
  # @return [Event] if event is detected
19
20
  # @return [NilClass] if event is NOT detected
20
21
  def detect(buffers)
21
- buffer = buffers.find { |b| b.type == BUFFER_TYPE }
22
+ tap_buffer = buffers.find { |b| b.type == BUFFER_TYPE }
22
23
  gesture_buffer = buffers.find { |b| b.type == 'gesture' }
24
+ timer_buffer = buffers.find { |b| b.type == 'timer' }
23
25
 
24
- return if buffer.empty? || !gesture_buffer.empty? || moved?(buffer)
26
+ if tap_buffer.empty? || moved?(tap_buffer: tap_buffer, gesture_buffer: gesture_buffer)
27
+ return
28
+ end
25
29
 
26
- holding_time = buffer.events.last.time - buffer.events.first.time
30
+ holding_time = calc_holding_time(tap_buffer: tap_buffer, timer_buffer: timer_buffer)
27
31
 
28
- direction = if hold?(buffer, holding_time)
32
+ direction = if hold?(tap_buffer, holding_time)
29
33
  'hold'
30
- elsif tap?(buffer, holding_time)
34
+ elsif tap?(tap_buffer, holding_time)
31
35
  'tap'
32
36
  end
33
37
 
34
38
  return if direction.nil?
35
39
 
36
- finger = buffer.finger
40
+ finger = tap_buffer.finger
37
41
 
38
- buffer.clear
42
+ tap_buffer.clear # NOTE: Clear after detecting hold
39
43
 
40
44
  index = create_index(finger: finger, direction: direction)
41
45
 
@@ -71,8 +75,10 @@ module Fusuma
71
75
  end
72
76
 
73
77
  # @return [TrueClass, FalseClass]
74
- def moved?(buffer)
75
- buffer.events.any? { |e| e.record.status == 'move' }
78
+ def moved?(tap_buffer:, gesture_buffer:)
79
+ tap_buffer.events.any? { |e| e.record.status == 'move' } ||
80
+ # FIXME: Find good parameter for ignoring
81
+ gesture_buffer.events.count { |e| tap_buffer.events.first.time < e.time } > 5
76
82
  end
77
83
 
78
84
  # @return [TrueClass, FalseClass]
@@ -95,6 +101,16 @@ module Fusuma
95
101
  end
96
102
  end
97
103
 
104
+ def calc_holding_time(tap_buffer:, timer_buffer:)
105
+ last_time = if timer_buffer && !timer_buffer.empty? &&
106
+ (tap_buffer.events.last.time < timer_buffer.events.last.time)
107
+ timer_buffer.events.last.time
108
+ else
109
+ tap_buffer.events.last.time
110
+ end
111
+ last_time - tap_buffer.events.first.time
112
+ end
113
+
98
114
  private
99
115
 
100
116
  def enough?(index:, direction:)
@@ -111,12 +127,12 @@ module Fusuma
111
127
  def interval_time(index:, direction:)
112
128
  @interval_time ||= {}
113
129
  @interval_time[index.cache_key] ||= begin
114
- keys_specific = Config::Index.new [*index.keys, 'interval']
115
- keys_global = Config::Index.new ['interval', direction]
116
- config_value = Config.search(keys_specific) ||
117
- Config.search(keys_global) || 1
118
- BASE_INTERVAL * config_value
119
- end
130
+ keys_specific = Config::Index.new [*index.keys, 'interval']
131
+ keys_global = Config::Index.new ['interval', direction]
132
+ config_value = Config.search(keys_specific) ||
133
+ Config.search(keys_global) || 1
134
+ BASE_INTERVAL * config_value
135
+ end
120
136
  end
121
137
  end
122
138
  end
@@ -67,7 +67,11 @@ module Fusuma
67
67
 
68
68
  finger = case Regexp.last_match(2)
69
69
  when 'TAP_STATE_DEAD'
70
- 4
70
+ if Regexp.last_match(1) == 'TAP_STATE_TOUCH_3'
71
+ 4
72
+ else
73
+ 0
74
+ end
71
75
  when 'TAP_STATE_TOUCH_3'
72
76
  3
73
77
  when 'TAP_STATE_TOUCH_2'
@@ -94,8 +98,7 @@ module Fusuma
94
98
  1
95
99
  end
96
100
  # KEEP
97
- when 'LIBINPUT TIMEOUT', # Timeout Event
98
- /\sgesture(| state):\s/ # 1.10.4 prints "gesture state: GESTURE_STATE_.*"
101
+ when /\sgesture(| state):\s/ # 1.10.4 prints "gesture state: GESTURE_STATE_.*"
99
102
  # NOTE: treat the "gesture(| state):" as KEEP
100
103
  status = 'keep'
101
104
  finger = 0
@@ -144,7 +147,7 @@ module Fusuma
144
147
  Events::Records::GestureRecord.new(status: status,
145
148
  gesture: gesture,
146
149
  finger: finger,
147
- direction: nil)
150
+ delta: nil)
148
151
  end
149
152
 
150
153
  def tag
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Tap
6
- VERSION = '0.3.0'
6
+ VERSION = '0.4.0'
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.3.0
4
+ version: 0.4.0
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-05-10 00:00:00.000000000 Z
11
+ date: 2021-04-12 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.10'
19
+ version: 2.0.0
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.10'
26
+ version: 2.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +169,7 @@ homepage: https://github.com/iberianpig/fusuma-plugin-tap
169
169
  licenses:
170
170
  - MIT
171
171
  metadata: {}
172
- post_install_message:
172
+ post_install_message:
173
173
  rdoc_options: []
174
174
  require_paths:
175
175
  - lib
@@ -184,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  - !ruby/object:Gem::Version
185
185
  version: '0'
186
186
  requirements: []
187
- rubygems_version: 3.0.6
188
- signing_key:
187
+ rubygems_version: 3.1.4
188
+ signing_key:
189
189
  specification_version: 4
190
190
  summary: Tap gesture plugin for Fusuma
191
191
  test_files: []