Sha256: fa2d5a60fc3f04eb07b836440c54554255fd55b26879334a57b237872b0d9e81

Contents?: true

Size: 924 Bytes

Versions: 31

Compression:

Stored size: 924 Bytes

Contents

module ProconBypassMan
  class ProconReader
    def initialize(binary: )
      @binary = binary
      @analog_stick = ProconBypassMan::Procon::AnalogStick.new(binary: binary)
      freeze
    end

    # @return [Array<Symbol>]
    def pressing
      aware = ProconBypassMan::PressButtonAware.new(@binary)
      pressed_table = ::ProconBypassMan::Procon::ButtonCollection::BUTTONS.reduce({}) do |acc, button|
        acc[button] = aware.pressing_button?(button)
        acc
      end
      pressed_table.select { |_key, value| value }.keys
    end

    def left_analog_stick
      { x: @analog_stick.relative_x, y: @analog_stick.relative_y }
    end

    def left_analog_stick_by_abs
      { x: @analog_stick.abs_x, y: @analog_stick.abs_y }
    end

    def to_hash
      { left_analog_stick: left_analog_stick,
        left_analog_stick_by_abs: left_analog_stick_by_abs,
        buttons: pressing,
      }
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

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