fusuma-plugin-tap 0.2.0 → 0.3.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: b8d626266cb1c6e86fce7c6e8f70d864dd705750299e0dce5e9c7ea30ddc27d2
4
- data.tar.gz: f230dbefeaf8e249b7d05e880f55164841335580ae521f08e482cf0e91d64990
3
+ metadata.gz: 2bedc73a6f30eada228504ea4b0c09b7c8cfb274a67764f6bcc93df88d63439d
4
+ data.tar.gz: 9b00f18217502e62dc83776231bf6de7ef5f7705f04178c67f4dd1f569675a77
5
5
  SHA512:
6
- metadata.gz: cd656a66fcd871a8fcee663df9b37595f5c0f5beae784104e4fc3a3bf75e7d9192bafdda5c6229e94873a8efbec61fde6527426d20b0f93ac4e4691396eb8c9e
7
- data.tar.gz: b29ba3b5929c037731d8f759e007436fa8db1f2b83b30e455a0ef8daa7658a8f8b367ac83513b6e20cd647def3257c0ea486e7c4768b11d2ee1f1cc21a80d075
6
+ metadata.gz: 11ea664f6f1ca08ef08fc0ef759634066a7f813cf5b43502294a034e96349e58fddbce4e223d3ac858c847d9a508a91335b4f262bc25b992e91f3559a9591a82
7
+ data.tar.gz: a0db20541d07c7542b7c38b8c6f34cd61160dce875dfd103251446dc80cf173fd6fec1e20cc61d476bf912af7b6c2ae024e4e2e761577c1e87165f157c86cc56
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-05-10 21:28:27 +0900 using RuboCop version 0.82.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: 40
20
20
 
21
21
  # Offense count: 1
22
22
  # Configuration parameters: CountComments, ExcludedMethods.
@@ -24,17 +24,17 @@ 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: 24
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: 3
38
38
  # Configuration parameters: IgnoredMethods.
39
39
  Metrics/PerceivedComplexity:
40
40
  Max: 11
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.2.0](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.2.0) (2020-05-05)
4
+
5
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.3...v0.2.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Support libinput v1.15.5 [\#3](https://github.com/iberianpig/fusuma-plugin-tap/pull/3) ([iberianpig](https://github.com/iberianpig))
10
+
11
+ ## [v0.1.3](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.1.3) (2020-04-20)
12
+
13
+ [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.1...v0.1.3)
14
+
3
15
  ## [v0.1.1](https://github.com/iberianpig/fusuma-plugin-tap/tree/v0.1.1) (2020-04-19)
4
16
 
5
17
  [Full Changelog](https://github.com/iberianpig/fusuma-plugin-tap/compare/v0.1.0...v0.1.1)
@@ -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
 
@@ -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) || (event&.tag == 'libinput_gesture_parser')
26
26
 
27
27
  # NOTE: need to set `begin` event at first of buffer
28
28
  clear && return unless bufferable?(event)
@@ -50,12 +50,20 @@ 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
+ when 'update' # libinput_gesture_parser
60
+ if empty?
61
+ false
62
+ else
63
+ true
64
+ end
65
+ else
66
+ raise "Unexpected status: #{event.record.status}"
59
67
  end
60
68
  end
61
69
 
@@ -12,17 +12,16 @@ 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
21
  buffer = buffers.find { |b| b.type == BUFFER_TYPE }
22
+ gesture_buffer = buffers.find { |b| b.type == 'gesture' }
22
23
 
23
- return if buffer.empty?
24
-
25
- finger = buffer.finger
24
+ return if buffer.empty? || !gesture_buffer.empty? || moved?(buffer)
26
25
 
27
26
  holding_time = buffer.events.last.time - buffer.events.first.time
28
27
 
@@ -34,6 +33,8 @@ module Fusuma
34
33
 
35
34
  return if direction.nil?
36
35
 
36
+ finger = buffer.finger
37
+
37
38
  buffer.clear
38
39
 
39
40
  index = create_index(finger: finger, direction: direction)
@@ -53,21 +54,29 @@ module Fusuma
53
54
  )
54
55
  end
55
56
 
57
+ # @return [TrueClass, FalseClass]
56
58
  def hold?(buffer, holding_time)
57
- return false if holding_time < 1
59
+ return false if holding_time < 0.7
58
60
 
59
61
  return true if buffer.finger == 4
60
62
 
61
63
  true if buffer.events.any? { |e| e.record.status == 'hold' }
62
64
  end
63
65
 
66
+ # @return [TrueClass, FalseClass]
64
67
  def tap?(buffer, holding_time)
65
68
  return false if holding_time > 0.15
66
69
 
67
- tap_released?(buffer)
70
+ released_all?(buffer)
71
+ end
72
+
73
+ # @return [TrueClass, FalseClass]
74
+ def moved?(buffer)
75
+ buffer.events.any? { |e| e.record.status == 'move' }
68
76
  end
69
77
 
70
- def tap_released?(buffer)
78
+ # @return [TrueClass, FalseClass]
79
+ def released_all?(buffer)
71
80
  touch_num = buffer.events.count { |e| (e.record.status =~ /begin|touch/) }
72
81
  release_num = buffer.events.count { |e| e.record.status =~ /release|end/ }
73
82
  MultiLogger.debug(touch_num: touch_num, release_num: release_num)
@@ -94,11 +94,17 @@ module Fusuma
94
94
  1
95
95
  end
96
96
  # KEEP
97
- when /\sgesture(| state):\s/, 'LIBINPUT TIMEOUT'
97
+ when 'LIBINPUT TIMEOUT', # Timeout Event
98
+ /\sgesture(| state):\s/ # 1.10.4 prints "gesture state: GESTURE_STATE_.*"
98
99
  # NOTE: treat the "gesture(| state):" as KEEP
99
100
  status = 'keep'
100
101
  finger = 0
101
102
 
103
+ # MOVE
104
+ when /\sPOINTER_AXIS\s/, /\sPOINTER_MOTION\s/, /\sTAP_EVENT_PALM\s/
105
+ status = 'move'
106
+ finger = 0
107
+
102
108
  # RELEASE
103
109
  when /\stap(?:| state):\s.*(#{(STATE[:touches] | STATE[:holds]).join('|')}) → TAP_EVENT_RELEASE → (#{STATE[:releases].join('|')})/
104
110
 
@@ -122,8 +128,8 @@ module Fusuma
122
128
 
123
129
  matched = Regexp.last_match
124
130
  finger = case matched[1]
125
- when 'TAP_STATE_DEAD'
126
- 4
131
+ when 'TAP_STATE_DEAD' # NOTE: 2 finger hold -> scroll become TAP_STATE_DEAD
132
+ 0
127
133
  when 'TAP_STATE_TOUCH_3', 'TAP_STATE_TOUCH_3_HOLD'
128
134
  3
129
135
  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.2.0'
6
+ VERSION = '0.3.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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - iberianpig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-05 00:00:00.000000000 Z
11
+ date: 2020-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fusuma