fusuma-plugin-tap 0.2.0 → 0.4.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8d626266cb1c6e86fce7c6e8f70d864dd705750299e0dce5e9c7ea30ddc27d2
4
- data.tar.gz: f230dbefeaf8e249b7d05e880f55164841335580ae521f08e482cf0e91d64990
3
+ metadata.gz: c46c3f606aa83757b439afac123cd8efd4a87b3205ccb0364ca565998ee4e6e2
4
+ data.tar.gz: cd0db523002ead56784c44df3b8443d635cb5c8dc4c8aa0a1616994eabf1c44e
5
5
  SHA512:
6
- metadata.gz: cd656a66fcd871a8fcee663df9b37595f5c0f5beae784104e4fc3a3bf75e7d9192bafdda5c6229e94873a8efbec61fde6527426d20b0f93ac4e4691396eb8c9e
7
- data.tar.gz: b29ba3b5929c037731d8f759e007436fa8db1f2b83b30e455a0ef8daa7658a8f8b367ac83513b6e20cd647def3257c0ea486e7c4768b11d2ee1f1cc21a80d075
6
+ metadata.gz: 920c2f083dde9a3c67edb42de1295941812e992e0753b05da482169aba8f2596c1a18802c6d67218bb8b5f07c44862a067e9a02945041b6c0c6ee7eaeeae8e80
7
+ data.tar.gz: fb8b27a7ed3853428ecc810c3ffdaf941676a2575eced35d4d264f6191df782cb0f1e7bf770f21d01caaeb92611821e1c825b99dcc96a242866c02ab83fd74ac
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-04 22:12:29 +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: 38
19
+ Max: 42
20
20
 
21
21
  # Offense count: 1
22
22
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -24,20 +24,20 @@ Metrics/AbcSize:
24
24
  Metrics/BlockLength:
25
25
  Max: 33
26
26
 
27
- # Offense count: 1
27
+ # Offense count: 3
28
28
  # Configuration parameters: IgnoredMethods.
29
29
  Metrics/CyclomaticComplexity:
30
- Max: 23
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: 1
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,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)
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,6 +4,7 @@
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
@@ -12,6 +13,7 @@ class LibinputDebugEventsGenerator
12
13
  @gesture_name = Pathname.new(evemu_record).basename
13
14
  @list_devices = ENV.fetch('LIBINPUT_LIST_DEVICES', 'libinput list-devices')
14
15
  @debug_events = ENV.fetch('LIBINPUT_DEBUG_EVENTS', 'libinput debug-events')
16
+ @libinput_version = ENV.fetch('LIBINPUT_VERSION', 'libinput list-devices')
15
17
  end
16
18
 
17
19
  def generate_debug_events
@@ -40,6 +42,10 @@ class LibinputDebugEventsGenerator
40
42
  rescue Timeout::Error
41
43
  puts 'cut out device infos'
42
44
  end
45
+ if `which evemu-play` == ''
46
+ warn 'evemu-play is not found'
47
+ exit 1
48
+ end
43
49
 
44
50
  command = "evemu-play /dev/input/#{device_id} < #{@evemu_record}"
45
51
 
@@ -89,7 +95,9 @@ class LibinputDebugEventsGenerator
89
95
  end
90
96
 
91
97
  def version
92
- @version ||= `#{@list_devices} --version`.chomp
98
+ raise 'Make rebuild libinput' unless @libinput_version == `#{@list_devices} --version`.chomp
99
+
100
+ @libinput_version
93
101
  end
94
102
  end
95
103
 
@@ -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.pre2'
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 if event&.tag != source
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)
@@ -50,12 +50,14 @@ module Fusuma
50
50
  else
51
51
  false
52
52
  end
53
- else # 'keep', 'touch', 'hold', 'release'
53
+ when 'keep', 'touch', 'hold', 'release', 'move'
54
54
  if empty?
55
55
  false
56
56
  else
57
57
  true
58
58
  end
59
+ else
60
+ raise "Unexpected status: #{event.record.status}"
59
61
  end
60
62
  end
61
63
 
@@ -7,34 +7,39 @@ 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
 
13
14
  BASE_INTERVAL = 0.5
14
15
  BASE_HOLDING_TIME = 0.1
15
- BASE_TAP_TIME = 1
16
+ BASE_TAP_TIME = 0.4
16
17
 
17
18
  # @param buffers [Array<Buffer>]
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 }
23
+ gesture_buffer = buffers.find { |b| b.type == 'gesture' }
24
+ timer_buffer = buffers.find { |b| b.type == 'timer' }
22
25
 
23
- return if buffer.empty?
24
-
25
- finger = buffer.finger
26
+ if tap_buffer.empty? || moved?(tap_buffer: tap_buffer, gesture_buffer: gesture_buffer)
27
+ return
28
+ end
26
29
 
27
- holding_time = buffer.events.last.time - buffer.events.first.time
30
+ holding_time = calc_holding_time(tap_buffer: tap_buffer, timer_buffer: timer_buffer)
28
31
 
29
- direction = if hold?(buffer, holding_time)
32
+ direction = if hold?(tap_buffer, holding_time)
30
33
  'hold'
31
- elsif tap?(buffer, holding_time)
34
+ elsif tap?(tap_buffer, holding_time)
32
35
  'tap'
33
36
  end
34
37
 
35
38
  return if direction.nil?
36
39
 
37
- buffer.clear
40
+ finger = tap_buffer.finger
41
+
42
+ tap_buffer.clear # NOTE: Clear after detecting hold
38
43
 
39
44
  index = create_index(finger: finger, direction: direction)
40
45
 
@@ -53,21 +58,31 @@ module Fusuma
53
58
  )
54
59
  end
55
60
 
61
+ # @return [TrueClass, FalseClass]
56
62
  def hold?(buffer, holding_time)
57
- return false if holding_time < 1
63
+ return false if holding_time < 0.7
58
64
 
59
65
  return true if buffer.finger == 4
60
66
 
61
67
  true if buffer.events.any? { |e| e.record.status == 'hold' }
62
68
  end
63
69
 
70
+ # @return [TrueClass, FalseClass]
64
71
  def tap?(buffer, holding_time)
65
72
  return false if holding_time > 0.15
66
73
 
67
- tap_released?(buffer)
74
+ released_all?(buffer)
75
+ end
76
+
77
+ # @return [TrueClass, FalseClass]
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
68
82
  end
69
83
 
70
- def tap_released?(buffer)
84
+ # @return [TrueClass, FalseClass]
85
+ def released_all?(buffer)
71
86
  touch_num = buffer.events.count { |e| (e.record.status =~ /begin|touch/) }
72
87
  release_num = buffer.events.count { |e| e.record.status =~ /release|end/ }
73
88
  MultiLogger.debug(touch_num: touch_num, release_num: release_num)
@@ -86,6 +101,16 @@ module Fusuma
86
101
  end
87
102
  end
88
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
+
89
114
  private
90
115
 
91
116
  def enough?(index:, direction:)
@@ -102,12 +127,12 @@ module Fusuma
102
127
  def interval_time(index:, direction:)
103
128
  @interval_time ||= {}
104
129
  @interval_time[index.cache_key] ||= begin
105
- keys_specific = Config::Index.new [*index.keys, 'interval']
106
- keys_global = Config::Index.new ['interval', direction]
107
- config_value = Config.search(keys_specific) ||
108
- Config.search(keys_global) || 1
109
- BASE_INTERVAL * config_value
110
- 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
111
136
  end
112
137
  end
113
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,11 +98,16 @@ module Fusuma
94
98
  1
95
99
  end
96
100
  # KEEP
97
- when /\sgesture(| state):\s/, 'LIBINPUT TIMEOUT'
101
+ when /\sgesture(| state):\s/ # 1.10.4 prints "gesture state: GESTURE_STATE_.*"
98
102
  # NOTE: treat the "gesture(| state):" as KEEP
99
103
  status = 'keep'
100
104
  finger = 0
101
105
 
106
+ # MOVE
107
+ when /\sPOINTER_AXIS\s/, /\sPOINTER_MOTION\s/, /\sTAP_EVENT_PALM\s/
108
+ status = 'move'
109
+ finger = 0
110
+
102
111
  # RELEASE
103
112
  when /\stap(?:| state):\s.*(#{(STATE[:touches] | STATE[:holds]).join('|')}) → TAP_EVENT_RELEASE → (#{STATE[:releases].join('|')})/
104
113
 
@@ -122,8 +131,8 @@ module Fusuma
122
131
 
123
132
  matched = Regexp.last_match
124
133
  finger = case matched[1]
125
- when 'TAP_STATE_DEAD'
126
- 4
134
+ when 'TAP_STATE_DEAD' # NOTE: 2 finger hold -> scroll become TAP_STATE_DEAD
135
+ 0
127
136
  when 'TAP_STATE_TOUCH_3', 'TAP_STATE_TOUCH_3_HOLD'
128
137
  3
129
138
  when 'TAP_STATE_TOUCH_2', 'TAP_STATE_TOUCH_2_HOLD', 'TAP_STATE_TOUCH_2_RELEASE'
@@ -138,7 +147,7 @@ module Fusuma
138
147
  Events::Records::GestureRecord.new(status: status,
139
148
  gesture: gesture,
140
149
  finger: finger,
141
- direction: nil)
150
+ delta: nil)
142
151
  end
143
152
 
144
153
  def tag
@@ -3,7 +3,7 @@
3
3
  module Fusuma
4
4
  module Plugin
5
5
  module Tap
6
- VERSION = '0.2.0'
6
+ VERSION = '0.4.0.pre2'
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.2.0
4
+ version: 0.4.0.pre2
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-05 00:00:00.000000000 Z
11
+ date: 2021-03-29 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.pre2
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.pre2
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
@@ -180,12 +180,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '2.3'
181
181
  required_rubygems_version: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - ">="
183
+ - - ">"
184
184
  - !ruby/object:Gem::Version
185
- version: '0'
185
+ version: 1.3.1
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: []