Skip to content

Commit

Permalink
procon specを書く
Browse files Browse the repository at this point in the history
  • Loading branch information
jiikko committed Jul 15, 2023
1 parent 3069bb0 commit d308ba0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/procon_bypass_man/procon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def to_binary(external_input_data: nil)
config[:force_neutral]&.each do |force_neutral_button|
user_operation.unpress_button(force_neutral_button)
end
config[:combined_press_is_pressed]&.each do |combined_press_is_pressed|
combined_press_is_pressed.each { |button| user_operation.press_button(button) }
config[:combined_press_is_pressed]&.each do |button|
user_operation.press_button(button)
end
user_operation.apply_left_analog_stick_cap(cap: config[:cap])
end
Expand Down
42 changes: 41 additions & 1 deletion spec/lib/procon_bypass_man/procon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

context 'with left_analog_stick_caps' do
let(:data) { "30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000" } # no_action
it do
it 'aを押したら発動すること' do
ProconBypassMan.buttons_setting_configure do
prefix_keys_for_changing_layer [:zr]
layer :up do
Expand All @@ -66,6 +66,46 @@
end
end

context 'with left_analog_stick_caps and combined_press_is_pressed' do
let(:data) { "30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000" } # no_action
it 'aを押したらbを押すこと' do
ProconBypassMan.buttons_setting_configure do
prefix_keys_for_changing_layer [:zr]
layer :up do
left_analog_stick_cap cap: 1000, if_pressed: [:a], combined_press_is_pressed: [:b]
end
end

ProconBypassMan::Procon.new(binary).tap do |procon|
procon.user_operation.press_button(:a)
expect(procon.user_operation).to receive(:apply_left_analog_stick_cap).once
procon.to_binary
expect(procon.user_operation).to be_pressed_a
expect(procon.user_operation).to be_pressed_b # 明示的に押していないが、combined_press_is_pressedのため押されている
end
end
end

context 'with left_analog_stick_caps and combined_press_is_pressed' do
let(:data) { "30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000" } # no_action
it 'aを押したらbを押すこと' do
ProconBypassMan.buttons_setting_configure do
prefix_keys_for_changing_layer [:zr]
layer :up do
left_analog_stick_cap cap: 1000, if_pressed: [:a], combined_press_is_pressed: []
end
end

ProconBypassMan::Procon.new(binary).tap do |procon|
procon.user_operation.press_button(:a)
expect(procon.user_operation).to receive(:apply_left_analog_stick_cap).once
procon.to_binary
expect(procon.user_operation).to be_pressed_a
expect(procon.user_operation).not_to be_pressed_b
end
end
end

context 'with flip_interval' do
let(:data) { "30f28100800078c77448287509550274ff131029001b0022005a0271ff191028001e00210064027cff1410280020002100000000000000000000000000000000" } # no_action
it do
Expand Down

0 comments on commit d308ba0

Please sign in to comment.