fusuma-plugin-tap 0.4.0.pre → 0.4.2
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 +4 -4
- data/README.md +43 -0
- data/bin/libinput_debug_events_generator.rb +8 -3
- data/fusuma-plugin-tap.gemspec +3 -14
- data/lib/fusuma/plugin/detectors/tap_detector.rb +7 -6
- data/lib/fusuma/plugin/parsers/tap_parser.rb +1 -1
- data/lib/fusuma/plugin/tap/version.rb +1 -1
- data/spec/fusuma/plugin/buffers/tap_buffer_spec.rb +164 -0
- data/spec/fusuma/plugin/detectors/tap_detector_spec.rb +169 -0
- data/spec/fusuma/plugin/parsers/1.10.4/1finger-double-tap.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.10.4/1finger-hold.txt +6 -0
- data/spec/fusuma/plugin/parsers/1.10.4/1finger-tap.txt +8 -0
- data/spec/fusuma/plugin/parsers/1.10.4/2finger-hold-invalid.txt +259 -0
- data/spec/fusuma/plugin/parsers/1.10.4/2finger-hold.txt +116 -0
- data/spec/fusuma/plugin/parsers/1.10.4/2finger-pinch-and-hold-bug.txt +356 -0
- data/spec/fusuma/plugin/parsers/1.10.4/2finger-tap.txt +12 -0
- data/spec/fusuma/plugin/parsers/1.10.4/3finger-hold-invalid.txt +241 -0
- data/spec/fusuma/plugin/parsers/1.10.4/3finger-hold.txt +162 -0
- data/spec/fusuma/plugin/parsers/1.10.4/3finger-tap.txt +32 -0
- data/spec/fusuma/plugin/parsers/1.10.4/4finger-hold-invalid.txt +262 -0
- data/spec/fusuma/plugin/parsers/1.10.4/4finger-hold.txt +686 -0
- data/spec/fusuma/plugin/parsers/1.10.4/4finger-tap-after-palm-detected-bug.txt +27 -0
- data/spec/fusuma/plugin/parsers/1.10.4/4finger-tap.txt +34 -0
- data/spec/fusuma/plugin/parsers/1.14.1/1finger-double-tap.txt +13 -0
- data/spec/fusuma/plugin/parsers/1.14.1/1finger-hold.txt +5 -0
- data/spec/fusuma/plugin/parsers/1.14.1/1finger-tap.txt +7 -0
- data/spec/fusuma/plugin/parsers/1.14.1/2finger-hold-invalid.txt +137 -0
- data/spec/fusuma/plugin/parsers/1.14.1/2finger-hold.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.14.1/2finger-pinch-and-hold-bug.txt +32 -0
- data/spec/fusuma/plugin/parsers/1.14.1/2finger-tap.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.14.1/3finger-hold-invalid.txt +173 -0
- data/spec/fusuma/plugin/parsers/1.14.1/3finger-hold.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.14.1/3finger-tap.txt +16 -0
- data/spec/fusuma/plugin/parsers/1.14.1/4finger-hold-invalid.txt +158 -0
- data/spec/fusuma/plugin/parsers/1.14.1/4finger-hold.txt +9 -0
- data/spec/fusuma/plugin/parsers/1.14.1/4finger-tap-after-palm-detected-bug.txt +20 -0
- data/spec/fusuma/plugin/parsers/1.14.1/4finger-tap.txt +17 -0
- data/spec/fusuma/plugin/parsers/1.15.5/1finger-double-tap.txt +13 -0
- data/spec/fusuma/plugin/parsers/1.15.5/1finger-hold.txt +5 -0
- data/spec/fusuma/plugin/parsers/1.15.5/1finger-tap.txt +7 -0
- data/spec/fusuma/plugin/parsers/1.15.5/2finger-hold-invalid.txt +139 -0
- data/spec/fusuma/plugin/parsers/1.15.5/2finger-hold.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.15.5/2finger-pinch-and-hold-bug.txt +48 -0
- data/spec/fusuma/plugin/parsers/1.15.5/2finger-tap.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.15.5/3finger-hold-invalid.txt +172 -0
- data/spec/fusuma/plugin/parsers/1.15.5/3finger-hold.txt +14 -0
- data/spec/fusuma/plugin/parsers/1.15.5/3finger-tap.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.15.5/4finger-hold-invalid.txt +158 -0
- data/spec/fusuma/plugin/parsers/1.15.5/4finger-hold.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.15.5/4finger-tap-after-palm-detected-bug.txt +20 -0
- data/spec/fusuma/plugin/parsers/1.15.5/4finger-tap.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.16.5/1finger-double-tap.txt +13 -0
- data/spec/fusuma/plugin/parsers/1.16.5/1finger-hold.txt +5 -0
- data/spec/fusuma/plugin/parsers/1.16.5/1finger-tap.txt +7 -0
- data/spec/fusuma/plugin/parsers/1.16.5/2finger-hold-invalid.txt +142 -0
- data/spec/fusuma/plugin/parsers/1.16.5/2finger-hold.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.16.5/2finger-pinch-and-hold-bug.txt +48 -0
- data/spec/fusuma/plugin/parsers/1.16.5/2finger-tap.txt +10 -0
- data/spec/fusuma/plugin/parsers/1.16.5/3finger-hold-invalid.txt +172 -0
- data/spec/fusuma/plugin/parsers/1.16.5/3finger-hold.txt +14 -0
- data/spec/fusuma/plugin/parsers/1.16.5/3finger-tap.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.16.5/4finger-hold-invalid.txt +159 -0
- data/spec/fusuma/plugin/parsers/1.16.5/4finger-hold.txt +15 -0
- data/spec/fusuma/plugin/parsers/1.16.5/4finger-tap-after-palm-detected-bug.txt +20 -0
- data/spec/fusuma/plugin/parsers/1.16.5/4finger-tap.txt +15 -0
- data/spec/fusuma/plugin/parsers/evemu/1finger-double-tap.txt +190 -0
- data/spec/fusuma/plugin/parsers/evemu/1finger-hold.txt +646 -0
- data/spec/fusuma/plugin/parsers/evemu/1finger-tap.txt +156 -0
- data/spec/fusuma/plugin/parsers/evemu/2finger-hold-invalid.txt +1789 -0
- data/spec/fusuma/plugin/parsers/evemu/2finger-hold.txt +426 -0
- data/spec/fusuma/plugin/parsers/evemu/2finger-pinch-and-hold-bug.txt +925 -0
- data/spec/fusuma/plugin/parsers/evemu/2finger-tap.txt +164 -0
- data/spec/fusuma/plugin/parsers/evemu/3finger-hold-invalid.txt +2129 -0
- data/spec/fusuma/plugin/parsers/evemu/3finger-hold.txt +471 -0
- data/spec/fusuma/plugin/parsers/evemu/3finger-tap.txt +169 -0
- data/spec/fusuma/plugin/parsers/evemu/4finger-hold-invalid.txt +2374 -0
- data/spec/fusuma/plugin/parsers/evemu/4finger-hold.txt +575 -0
- data/spec/fusuma/plugin/parsers/evemu/4finger-tap-after-palm-detected-bug.txt +250 -0
- data/spec/fusuma/plugin/parsers/evemu/4finger-tap.txt +206 -0
- data/spec/fusuma/plugin/parsers/tap_parser_spec.rb +200 -0
- data/spec/fusuma/plugin/tap_spec.rb +9 -0
- data/spec/helpers/config_helper.rb +16 -0
- data/spec/spec_helper.rb +18 -0
- metadata +162 -132
- data/.gitignore +0 -15
- data/.rspec +0 -3
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -56
- data/.travis.yml +0 -23
- data/CHANGELOG.md +0 -61
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -6
- data/Makefile +0 -14
- data/Rakefile +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 589a25158b72255c93f69c61ca7fdb74e6a489f987eeb8b0fc9df29135dfd89f
|
|
4
|
+
data.tar.gz: 3138445357bd209a43914f1b5563fced9bd188c2e4d3caf5a5076c2608187fcc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 213c141a633f7d172240446177fec600435a58b8dbcfdb7b5f7b6fb8a91616a8444bf1e2beb0df14e25d2474dcd24630e0b42f4c56d6f8d2078c4ce9cb0158a5
|
|
7
|
+
data.tar.gz: 2fa6133e9b73050f1333f34ba38eb2a4b339c9c8c52abffe7be95f666767c35db256e37dcaaa20aa3a65eeb0811e6e5539d5f8a60ca9b16dda011aaa8f4d28b9
|
data/README.md
CHANGED
|
@@ -73,6 +73,49 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
|
73
73
|
|
|
74
74
|
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).
|
|
75
75
|
|
|
76
|
+
### Testing with multiple version of libinput
|
|
77
|
+
|
|
78
|
+
See: [Use latest libinput on fusuma · iberianpig/fusuma Wiki](https://github.com/iberianpig/fusuma/wiki/Use-latest-libinput-on-fusuma)
|
|
79
|
+
|
|
80
|
+
Install direnv to change the version of libinput from environment variables.
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
sudo apt install direnv
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
create .envrc
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
touch .envrc
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
modify .envrc
|
|
93
|
+
```sh
|
|
94
|
+
export LIBINPUT_VERSION=1.17.0
|
|
95
|
+
export LIBINPUT_REPO=/path/to/git/repository/of/libinput
|
|
96
|
+
export LIBINPUT_REPO=/path/to/git/repository/of/libinput
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Apply changes `.envrc`
|
|
100
|
+
```sh
|
|
101
|
+
$ direnv allow
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Build libinput
|
|
105
|
+
```sh
|
|
106
|
+
$ make build
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Change to pre-built version
|
|
110
|
+
* modify `LIBINPUT_VERSION` in `.envrc`
|
|
111
|
+
* check version with `$ direnv allow && make version`
|
|
112
|
+
|
|
113
|
+
### Generate stub of libinput-debug-events for RSpec
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
bundle exec bin/libinput_debug_events_generator.rb
|
|
117
|
+
```
|
|
118
|
+
|
|
76
119
|
## Contributing
|
|
77
120
|
|
|
78
121
|
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.
|
|
@@ -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'
|
|
14
|
-
@debug_events = ENV.fetch('LIBINPUT_DEBUG_EVENTS'
|
|
15
|
-
@libinput_version = ENV.fetch('LIBINPUT_VERSION'
|
|
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
|
|
data/fusuma-plugin-tap.gemspec
CHANGED
|
@@ -16,24 +16,13 @@ Gem::Specification.new do |spec|
|
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
|
19
|
-
|
|
20
|
-
spec.
|
|
21
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
|
-
end
|
|
19
|
+
spec.files = Dir['{bin,lib,exe}/**/*', 'LICENSE*', 'README*', '*.gemspec']
|
|
20
|
+
spec.test_files = Dir['{test,spec,features}/**/*']
|
|
23
21
|
spec.bindir = 'exe'
|
|
24
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
23
|
spec.require_paths = ['lib']
|
|
26
24
|
|
|
27
25
|
spec.required_ruby_version = '>= 2.3' # https://packages.ubuntu.com/search?keywords=ruby&searchon=names&exact=1&suite=all§ion=main
|
|
28
26
|
|
|
29
|
-
spec.add_dependency 'fusuma', '~> 2.0
|
|
30
|
-
|
|
31
|
-
spec.add_development_dependency 'bundler'
|
|
32
|
-
spec.add_development_dependency 'github_changelog_generator', '~> 1.14'
|
|
33
|
-
spec.add_development_dependency 'pry-byebug'
|
|
34
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
|
35
|
-
spec.add_development_dependency 'reek'
|
|
36
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
37
|
-
spec.add_development_dependency 'rubocop'
|
|
38
|
-
spec.add_development_dependency 'yard'
|
|
27
|
+
spec.add_dependency 'fusuma', '~> 2.0'
|
|
39
28
|
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
|
|
|
@@ -126,12 +127,12 @@ module Fusuma
|
|
|
126
127
|
def interval_time(index:, direction:)
|
|
127
128
|
@interval_time ||= {}
|
|
128
129
|
@interval_time[index.cache_key] ||= begin
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
135
136
|
end
|
|
136
137
|
end
|
|
137
138
|
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
require 'fusuma/plugin/events/records/gesture_record.rb'
|
|
6
|
+
require 'fusuma/plugin/events/event.rb'
|
|
7
|
+
require 'fusuma/plugin/buffers/buffer.rb'
|
|
8
|
+
|
|
9
|
+
module Fusuma
|
|
10
|
+
module Plugin
|
|
11
|
+
module Buffers
|
|
12
|
+
RSpec.describe TapBuffer do
|
|
13
|
+
before do
|
|
14
|
+
@buffer = TapBuffer.new
|
|
15
|
+
@event_generator = lambda { |time = nil, finger = 1, status = 'begin'|
|
|
16
|
+
Events::Event.new(time: time,
|
|
17
|
+
tag: 'libinput_tap_parser',
|
|
18
|
+
record: Events::Records::GestureRecord.new(
|
|
19
|
+
status: status,
|
|
20
|
+
gesture: 'tap',
|
|
21
|
+
finger: finger,
|
|
22
|
+
delta: nil
|
|
23
|
+
))
|
|
24
|
+
}
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#type' do
|
|
28
|
+
it { expect(@buffer.type).to eq 'tap' }
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
describe '#buffer' do
|
|
32
|
+
it 'should buffer gesture event' do
|
|
33
|
+
event = @event_generator.call(Time.now)
|
|
34
|
+
@buffer.buffer(event)
|
|
35
|
+
expect(@buffer.events).to eq [event]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'should NOT buffer other event' do
|
|
39
|
+
event = Events::Event.new(tag: 'SHOULD NOT BUFFER', record: 'dummy record')
|
|
40
|
+
@buffer.buffer(event)
|
|
41
|
+
expect(@buffer.events).to eq []
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#clear_expired' do
|
|
46
|
+
context 'with including end' do
|
|
47
|
+
it 'should NOT clear any events' do
|
|
48
|
+
time = Time.now
|
|
49
|
+
event1 = @event_generator.call(time, 1, 'begin')
|
|
50
|
+
event2 = @event_generator.call(time + 0.1, 2, 'touch')
|
|
51
|
+
event3 = @event_generator.call(time + 0.2, 1, 'release')
|
|
52
|
+
event4 = @event_generator.call(time + 0.2, 1, 'end')
|
|
53
|
+
@buffer.buffer(event1)
|
|
54
|
+
@buffer.buffer(event2)
|
|
55
|
+
@buffer.buffer(event3)
|
|
56
|
+
@buffer.buffer(event4)
|
|
57
|
+
|
|
58
|
+
@buffer.clear_expired(current_time: time + 100)
|
|
59
|
+
|
|
60
|
+
expect(@buffer.events).to eq []
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
context 'WITHOUT including end' do
|
|
64
|
+
it 'should NOT clear any events' do
|
|
65
|
+
time = Time.now
|
|
66
|
+
event1 = @event_generator.call(time, 1, 'begin')
|
|
67
|
+
event2 = @event_generator.call(time + 0.1, 2, 'touch')
|
|
68
|
+
event3 = @event_generator.call(time + 0.2, 1, 'release')
|
|
69
|
+
@buffer.buffer(event1)
|
|
70
|
+
@buffer.buffer(event2)
|
|
71
|
+
@buffer.buffer(event3)
|
|
72
|
+
|
|
73
|
+
@buffer.clear_expired(current_time: time + 100)
|
|
74
|
+
|
|
75
|
+
expect(@buffer.events).to eq [event1, event2, event3]
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '#bufferable?' do
|
|
81
|
+
it 'should buffer first begin event' do
|
|
82
|
+
time = Time.now
|
|
83
|
+
event1 = @event_generator.call(time, 1, 'begin')
|
|
84
|
+
expect(@buffer.bufferable?(event1)).to eq true
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
context 'already exists events in buffer' do
|
|
88
|
+
before do
|
|
89
|
+
event2 = @event_generator.call(Time.now, 1, 'begin')
|
|
90
|
+
@buffer.buffer(event2)
|
|
91
|
+
end
|
|
92
|
+
it 'should NOT buffer begin event' do
|
|
93
|
+
event2 = @event_generator.call(Time.now, 1, 'begin')
|
|
94
|
+
expect(@buffer.bufferable?(event2)).to eq false
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'should buffer touch event' do
|
|
98
|
+
event2 = @event_generator.call(Time.now, 2, 'touch')
|
|
99
|
+
expect(@buffer.bufferable?(event2)).to eq true
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'should buffer release event' do
|
|
103
|
+
event2 = @event_generator.call(Time.now, 1, 'release')
|
|
104
|
+
expect(@buffer.bufferable?(event2)).to eq true
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'should buffer end event' do
|
|
108
|
+
event2 = @event_generator.call(Time.now, 1, 'end')
|
|
109
|
+
expect(@buffer.bufferable?(event2)).to eq true
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
describe '#source' do
|
|
115
|
+
it { expect(@buffer.source).to eq TapBuffer::DEFAULT_SOURCE }
|
|
116
|
+
|
|
117
|
+
context 'with config' do
|
|
118
|
+
around do |example|
|
|
119
|
+
@source = 'custom_event'
|
|
120
|
+
|
|
121
|
+
ConfigHelper.load_config_yml = <<~CONFIG
|
|
122
|
+
plugin:
|
|
123
|
+
buffers:
|
|
124
|
+
tap_buffer:
|
|
125
|
+
source: #{@source}
|
|
126
|
+
CONFIG
|
|
127
|
+
|
|
128
|
+
example.run
|
|
129
|
+
|
|
130
|
+
Config.custom_path = nil
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it { expect(@buffer.source).to eq @source }
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
describe '#finger' do
|
|
138
|
+
it 'should return number of fingers in gestures' do
|
|
139
|
+
@buffer.buffer(@event_generator.call(Time.now, 1, 'begin'))
|
|
140
|
+
expect(@buffer.finger).to eq 1
|
|
141
|
+
@buffer.buffer(@event_generator.call(Time.now, 2, 'touch'))
|
|
142
|
+
expect(@buffer.finger).to eq 2
|
|
143
|
+
@buffer.buffer(@event_generator.call(Time.now, 3, 'touch'))
|
|
144
|
+
expect(@buffer.finger).to eq 3
|
|
145
|
+
@buffer.buffer(@event_generator.call(Time.now, 3, 'release'))
|
|
146
|
+
expect(@buffer.finger).to eq 3
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
describe '#empty?' do
|
|
151
|
+
context 'no gestures in buffer' do
|
|
152
|
+
before { @buffer.clear }
|
|
153
|
+
it { expect(@buffer.empty?).to be true }
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
context 'buffered some gestures' do
|
|
157
|
+
before { @buffer.buffer(@event_generator.call(Time.now, 'begin')) }
|
|
158
|
+
it { expect(@buffer.empty?).to be false }
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
require 'fusuma/plugin/detectors/detector.rb'
|
|
6
|
+
require 'fusuma/plugin/buffers/gesture_buffer.rb'
|
|
7
|
+
require 'fusuma/plugin/events/event.rb'
|
|
8
|
+
|
|
9
|
+
module Fusuma
|
|
10
|
+
module Plugin
|
|
11
|
+
module Detectors
|
|
12
|
+
RSpec.describe TapDetector do
|
|
13
|
+
before do
|
|
14
|
+
@detector = TapDetector.new
|
|
15
|
+
@buffer = Buffers::TapBuffer.new
|
|
16
|
+
@buffers = [@buffer, Buffers::GestureBuffer.new]
|
|
17
|
+
|
|
18
|
+
@event_generator = lambda { |time, finger, status|
|
|
19
|
+
Events::Event.new(
|
|
20
|
+
time: time,
|
|
21
|
+
tag: 'libinput_tap_parser',
|
|
22
|
+
record: Events::Records::GestureRecord.new(
|
|
23
|
+
finger: finger,
|
|
24
|
+
gesture: 'tap',
|
|
25
|
+
status: status,
|
|
26
|
+
delta: Events::Records::GestureRecord::Delta.new(0, 0, 0, 0)
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
describe '#detect' do
|
|
33
|
+
context 'with 1 finger tap events in buffer' do
|
|
34
|
+
before do
|
|
35
|
+
[
|
|
36
|
+
@event_generator.call(Time.now, 1, 'begin'),
|
|
37
|
+
@event_generator.call(Time.now, 1, 'release')
|
|
38
|
+
].each { |event| @buffer.buffer(event) }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'should generate tap index' do
|
|
42
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
43
|
+
expect(key_symbol).to eq [:tap, 1]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'with 2 fingers tap events in buffer' do
|
|
48
|
+
before do
|
|
49
|
+
[
|
|
50
|
+
@event_generator.call(Time.now, 1, 'begin'),
|
|
51
|
+
@event_generator.call(Time.now, 2, 'touch'),
|
|
52
|
+
@event_generator.call(Time.now, 2, 'release')
|
|
53
|
+
].each { |event| @buffer.buffer(event) }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'should generate tap index' do
|
|
57
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
58
|
+
expect(key_symbol).to eq [:tap, 2]
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context 'with 3 fingers tap events in buffer' do
|
|
63
|
+
before do
|
|
64
|
+
time = Time.now
|
|
65
|
+
[
|
|
66
|
+
@event_generator.call(time, 1, 'begin'),
|
|
67
|
+
@event_generator.call(time, 2, 'touch'),
|
|
68
|
+
@event_generator.call(time, 3, 'touch'),
|
|
69
|
+
@event_generator.call(time, 3, 'release'),
|
|
70
|
+
@event_generator.call(time + 0.1, 2, 'release')
|
|
71
|
+
].each { |event| @buffer.buffer(event) }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'should generate tap index' do
|
|
75
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
76
|
+
expect(key_symbol).to eq [:tap, 3]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
context 'with 4 fingers tap events in buffer' do
|
|
80
|
+
before do
|
|
81
|
+
time = Time.now
|
|
82
|
+
[
|
|
83
|
+
@event_generator.call(time, 1, 'begin'),
|
|
84
|
+
@event_generator.call(time, 2, 'touch'),
|
|
85
|
+
@event_generator.call(time, 3, 'touch'),
|
|
86
|
+
@event_generator.call(time, 4, 'touch'),
|
|
87
|
+
@event_generator.call(time + 0.1, 4, 'end')
|
|
88
|
+
].each { |event| @buffer.buffer(event) }
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'should generate tap index' do
|
|
92
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
93
|
+
expect(key_symbol).to eq [:tap, 4]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
context 'with 1 finger hold events in buffer' do
|
|
98
|
+
before do
|
|
99
|
+
time = Time.now
|
|
100
|
+
[
|
|
101
|
+
@event_generator.call(time, 1, 'begin'),
|
|
102
|
+
@event_generator.call(time + 2, 1, 'hold')
|
|
103
|
+
].each { |event| @buffer.buffer(event) }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'should generate tap index' do
|
|
107
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
108
|
+
expect(key_symbol).to eq [:hold, 1]
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
context 'with 2 fingers hold events in buffer' do
|
|
113
|
+
before do
|
|
114
|
+
time = Time.now
|
|
115
|
+
[
|
|
116
|
+
@event_generator.call(time, 1, 'begin'),
|
|
117
|
+
@event_generator.call(time, 2, 'touch'),
|
|
118
|
+
@event_generator.call(time, 2, 'hold'),
|
|
119
|
+
@event_generator.call(time + 1, 2, 'release')
|
|
120
|
+
].each { |event| @buffer.buffer(event) }
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it 'should generate tap index' do
|
|
124
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
125
|
+
expect(key_symbol).to eq [:hold, 2]
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
context 'with 3 fingers hold events in buffer' do
|
|
129
|
+
before do
|
|
130
|
+
time = Time.now
|
|
131
|
+
[
|
|
132
|
+
@event_generator.call(time, 1, 'begin'),
|
|
133
|
+
@event_generator.call(time, 2, 'touch'),
|
|
134
|
+
@event_generator.call(time, 3, 'hold'),
|
|
135
|
+
@event_generator.call(time, 3, 'release'),
|
|
136
|
+
@event_generator.call(time + 1, 2, 'release')
|
|
137
|
+
].each { |event| @buffer.buffer(event) }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'should generate hold index' do
|
|
141
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
142
|
+
expect(key_symbol).to eq [:hold, 3]
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
context 'with 4 fingers hold events in buffer' do
|
|
146
|
+
before do
|
|
147
|
+
time = Time.now
|
|
148
|
+
[
|
|
149
|
+
@event_generator.call(time, 1, 'begin'),
|
|
150
|
+
@event_generator.call(time, 2, 'touch'),
|
|
151
|
+
@event_generator.call(time, 3, 'touch'),
|
|
152
|
+
@event_generator.call(time, 4, 'touch'),
|
|
153
|
+
@event_generator.call(time, 0, 'keep'),
|
|
154
|
+
@event_generator.call(time, 0, 'keep'),
|
|
155
|
+
@event_generator.call(time, 0, 'keep'),
|
|
156
|
+
@event_generator.call(time + 1, 2, 'release')
|
|
157
|
+
].each { |event| @buffer.buffer(event) }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it 'should generate hold index' do
|
|
161
|
+
key_symbol = @detector.detect(@buffers).record.index.keys.map(&:symbol)
|
|
162
|
+
expect(key_symbol).to eq [:hold, 4]
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
event12 - thumb state: THUMB_STATE_MAYBE → THUMB_STATE_NO
|
|
2
|
+
event12 - button state: from BUTTON_STATE_NONE, event BUTTON_EVENT_IN_AREA to BUTTON_STATE_AREA
|
|
3
|
+
event12 - tap state: TAP_STATE_IDLE → TAP_EVENT_TOUCH → TAP_STATE_TOUCH
|
|
4
|
+
event12 - button state: from BUTTON_STATE_AREA, event BUTTON_EVENT_UP to BUTTON_STATE_NONE
|
|
5
|
+
event12 - tap state: TAP_STATE_TOUCH → TAP_EVENT_RELEASE → TAP_STATE_TAPPED
|
|
6
|
+
event12 POINTER_BUTTON +5.00s BTN_LEFT (272) pressed, seat count: 1
|
|
7
|
+
event12 - thumb state: THUMB_STATE_MAYBE → THUMB_STATE_NO
|
|
8
|
+
event12 - button state: from BUTTON_STATE_NONE, event BUTTON_EVENT_IN_AREA to BUTTON_STATE_AREA
|
|
9
|
+
event12 - tap state: TAP_STATE_TAPPED → TAP_EVENT_TOUCH → TAP_STATE_DRAGGING_OR_DOUBLETAP
|
|
10
|
+
event12 - button state: from BUTTON_STATE_AREA, event BUTTON_EVENT_UP to BUTTON_STATE_NONE
|
|
11
|
+
event12 - tap state: TAP_STATE_DRAGGING_OR_DOUBLETAP → TAP_EVENT_RELEASE → TAP_STATE_MULTITAP
|
|
12
|
+
event12 POINTER_BUTTON +5.06s BTN_LEFT (272) released, seat count: 0
|
|
13
|
+
event12 - tap state: TAP_STATE_MULTITAP → TAP_EVENT_TIMEOUT → TAP_STATE_IDLE
|
|
14
|
+
event12 POINTER_BUTTON +5.17s BTN_LEFT (272) pressed, seat count: 1
|
|
15
|
+
event12 POINTER_BUTTON +5.21s BTN_LEFT (272) released, seat count: 0
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
event12 - thumb state: THUMB_STATE_MAYBE → THUMB_STATE_NO
|
|
2
|
+
event12 - button state: from BUTTON_STATE_NONE, event BUTTON_EVENT_IN_AREA to BUTTON_STATE_AREA
|
|
3
|
+
event12 - tap state: TAP_STATE_IDLE → TAP_EVENT_TOUCH → TAP_STATE_TOUCH
|
|
4
|
+
event12 - tap state: TAP_STATE_TOUCH → TAP_EVENT_TIMEOUT → TAP_STATE_HOLD
|
|
5
|
+
event12 - button state: from BUTTON_STATE_AREA, event BUTTON_EVENT_UP to BUTTON_STATE_NONE
|
|
6
|
+
event12 - tap state: TAP_STATE_HOLD → TAP_EVENT_RELEASE → TAP_STATE_IDLE
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
event12 - thumb state: THUMB_STATE_MAYBE → THUMB_STATE_NO
|
|
2
|
+
event12 - button state: from BUTTON_STATE_NONE, event BUTTON_EVENT_IN_AREA to BUTTON_STATE_AREA
|
|
3
|
+
event12 - tap state: TAP_STATE_IDLE → TAP_EVENT_TOUCH → TAP_STATE_TOUCH
|
|
4
|
+
event12 - button state: from BUTTON_STATE_AREA, event BUTTON_EVENT_UP to BUTTON_STATE_NONE
|
|
5
|
+
event12 - tap state: TAP_STATE_TOUCH → TAP_EVENT_RELEASE → TAP_STATE_TAPPED
|
|
6
|
+
event12 POINTER_BUTTON +5.00s BTN_LEFT (272) pressed, seat count: 1
|
|
7
|
+
event12 - tap state: TAP_STATE_TAPPED → TAP_EVENT_TIMEOUT → TAP_STATE_IDLE
|
|
8
|
+
event12 POINTER_BUTTON +5.07s BTN_LEFT (272) released, seat count: 0
|