Sha256: ae2ba580e148fc9bd9286e560fda731416a22d21a3c360cf03ec8c6909e839d6

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

class ProconBypassMan::Procon::AnalogStickManipulator
  attr_accessor :manipulated_abs_x, :manipulated_abs_y

  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
    else
      warn "error stick manipulator"
      self.manipulated_abs_x = analog_stick.abs_x
      self.manipulated_abs_y = analog_stick.abs_y
    end
  end


  # @return [String]
  def to_binary
    ProconBypassMan::AnalogStickPosition.new(
      x: self.manipulated_abs_x,
      y: self.manipulated_abs_y,
    ).to_binary
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.0 lib/procon_bypass_man/procon/analog_stick_manipulator.rb