Class: ProconBypassMan::Procon::AnalogStickManipulator
- Inherits:
-
Object
- Object
- ProconBypassMan::Procon::AnalogStickManipulator
- Defined in:
- lib/procon_bypass_man/procon/analog_stick_manipulator.rb
Instance Attribute Summary collapse
-
#manipulated_abs_x ⇒ Object
Returns the value of attribute manipulated_abs_x.
-
#manipulated_abs_y ⇒ Object
Returns the value of attribute manipulated_abs_y.
Instance Method Summary collapse
-
#initialize(binary, method:) ⇒ AnalogStickManipulator
constructor
A new instance of AnalogStickManipulator.
- #to_binary ⇒ String
Constructor Details
#initialize(binary, method:) ⇒ AnalogStickManipulator
Returns a new instance of AnalogStickManipulator.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/procon_bypass_man/procon/analog_stick_manipulator.rb', line 6 def initialize(binary, method: ) analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary) if method =~ /tilt_left_stick_(completely)_to_(left|right)/ power_level = $1 direction = $2 case direction when 'left' self.manipulated_abs_x = 400 # yを引き継ぐとタンサンボムの溜まりが悪くなったので固定値を入れる self.manipulated_abs_y = analog_stick.abs_y # self.manipulated_abs_y = 1808 when 'right' self.manipulated_abs_x = 3400 self.manipulated_abs_y = 1808 end return end if method =~ /tilt_left_stick_(completely)_to_(\d+)deg/ power_level = $1 arc_degree = $2.to_i syahen = 1800 # 最大まで傾けた状態 neutral_position = ProconBypassMan..neutral_position self.manipulated_abs_x = (syahen * Math.cos(arc_degree * Math::PI / 180)).to_i - neutral_position.x self.manipulated_abs_y = (syahen * Math.sin(arc_degree * Math::PI / 180)).to_i - neutral_position.y return end warn "error stick manipulator" self.manipulated_abs_x = analog_stick.abs_x self.manipulated_abs_y = analog_stick.abs_y end |
Instance Attribute Details
#manipulated_abs_x ⇒ Object
Returns the value of attribute manipulated_abs_x.
4 5 6 |
# File 'lib/procon_bypass_man/procon/analog_stick_manipulator.rb', line 4 def manipulated_abs_x @manipulated_abs_x end |
#manipulated_abs_y ⇒ Object
Returns the value of attribute manipulated_abs_y.
4 5 6 |
# File 'lib/procon_bypass_man/procon/analog_stick_manipulator.rb', line 4 def manipulated_abs_y @manipulated_abs_y end |
Instance Method Details
#to_binary ⇒ String
44 45 46 47 48 49 |
# File 'lib/procon_bypass_man/procon/analog_stick_manipulator.rb', line 44 def to_binary ProconBypassMan::AnalogStickPosition.new( x: self.manipulated_abs_x, y: self.manipulated_abs_y, ).to_binary end |