Sha256: dca6de120b0f9dfbfdef93d3fd6d48ec59923af1da46ad5fd05a908afcac6e90

Contents?: true

Size: 413 Bytes

Versions: 21

Compression:

Stored size: 413 Bytes

Contents

class ProconBypassMan::AnalogStickPosition
  attr_accessor :x, :y

  def initialize(x:, y:)
    @x = x.to_i
    @y = y.to_i
  end

  def to_binary
    analog_stick_data = [
      (@x & "0xff".to_i(16)),
      ((@y << 4) & "0xf0".to_i(16)) | ((@x >> 8) & "0x0f".to_i(16)),
      (@y >> 4) & "0xff".to_i(16),
    ]
    hex = analog_stick_data.map{ |x| x.to_s(16).rjust(2, "0") }.join
    [hex].pack("H*")
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.5 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb
procon_bypass_man-0.1.23 lib/procon_bypass_man/procon/value_objects/analog_stick_position.rb