Class: ProconBypassMan::Domains::ProcessingProconBinary
Overview
Constant Summary
collapse
- ALL_ZERO_BIT =
["0"].pack("H*").freeze
Instance Method Summary
collapse
#binary
#binary, #initialize, #raw, #to_procon_reader, #unpack
Instance Method Details
#set_no_action! ⇒ Object
9
10
11
12
13
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 9
def set_no_action!
binary[3] = ALL_ZERO_BIT
binary[4] = ALL_ZERO_BIT
binary[5] = ALL_ZERO_BIT
end
|
#write_as_apply_left_analog_stick_cap(cap:) ⇒ Object
69
70
71
72
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 69
def write_as_apply_left_analog_stick_cap(cap: )
analog_stick_cap = ProconBypassMan::Procon::AnalogStickCap.new(binary)
binary[6..8] = analog_stick_cap.capped_position(cap_hypotenuse: cap).to_binary
end
|
アナログスティックは上書きし、ボタンだけマージする
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 18
def write_as_merge!(target_binary)
current_buttons = ProconBypassMan::ProconReader.new(binary: binary).pressing
target_buttons = ProconBypassMan::ProconReader.new(binary: target_binary.raw).pressing
set_no_action!
(current_buttons + target_buttons).uniq.each do |button|
write_as_press_button(button)
end
tb = [target_binary.raw].pack("H*")
binary[6] = tb[6]
binary[7] = tb[7]
binary[8] = tb[8]
binary[9] = tb[9]
binary[10] = tb[10]
binary[11] = tb[11]
self
end
|
40
41
42
43
44
45
46
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 40
def write_as_press_button(button)
return if ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
button_obj = ProconBypassMan::Procon::Button.new(button)
value = binary[button_obj.byte_position].unpack("C").first + (2**button_obj.bit_position)
binary[button_obj.byte_position] = ["%02X" % value.to_s].pack("H*")
end
|
63
64
65
66
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 63
def write_as_press_button_only(button)
set_no_action!
write_as_press_button(button)
end
|
#write_as_tilt_left_stick(step) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/procon_bypass_man/procon/value_objects/binary/processing_procon_binary.rb', line 54
def write_as_unpress_button(button)
raise "do not press button(#{button}) yet" if not ProconBypassMan::PressButtonAware.new(binary).pressing_button?(button)
button_obj = ProconBypassMan::Procon::Button.new(button)
value = binary[button_obj.byte_position].unpack("C").first - (2**button_obj.bit_position)
binary[button_obj.byte_position] = ["%02X" % value.to_s].pack("H*")
end
|