class ProconBypassMan::Configuration::Layer

Constants

PRESET_MACROS

Attributes

flips[RW]
macros[RW]
mode[RW]
remaps[RW]

Public Class Methods

new(mode: :manual, &block) click to toggle source
# File lib/procon_bypass_man/configuration/layer.rb, line 6
def initialize(mode: :manual, &block)
  self.mode = mode
  self.flips = {}
  self.macros = {}
  self.remaps = {}
  instance_eval(&block) if block_given?
end

Public Instance Methods

flip(button, if_pressed: false, force_neutral: nil, flip_interval: nil) click to toggle source

@param [Symbol] button

# File lib/procon_bypass_man/configuration/layer.rb, line 15
def flip(button, if_pressed: false, force_neutral: nil, flip_interval: nil)
  case if_pressed
  when TrueClass
    if_pressed = [button]
  when Symbol, String
    if_pressed = [if_pressed]
  when Array, FalseClass
    # sono mama
  else
    raise "not support class"
  end
  hash = { if_pressed: if_pressed }
  if force_neutral
    case force_neutral
    when TrueClass, FalseClass
      raise "ボタンを渡してください"
    when Symbol, String
      hash[:force_neutral] = [force_neutral]
    when Array
      hash[:force_neutral] = force_neutral
    end
  end

  if flip_interval
    if /\A(\d+)F\z/i =~ flip_interval
      interval =  ((frame = $1.to_i) / 60.0).floor(2)
    else
      raise "8F みたいなフォーマットで入力してください"
    end
    hash[:flip_interval] = interval
  end
  if self.flips[button]
    raise "#{button}への設定をすでに割り当て済みです"
  else
    self.flips[button] = hash
  end
end
flip_buttons() click to toggle source

@return [Array]

# File lib/procon_bypass_man/configuration/layer.rb, line 76
def flip_buttons
  flips
end
macro(name, if_pressed: ) click to toggle source
# File lib/procon_bypass_man/configuration/layer.rb, line 54
def macro(name, if_pressed: )
  if name.respond_to?(:name)
    macro_name = name.name.to_sym
  else
    macro_name = name
  end
  self.macros[macro_name] = { if_pressed: if_pressed }
end
remap(button, to: ) click to toggle source
# File lib/procon_bypass_man/configuration/layer.rb, line 63
def remap(button, to: )
  case to
  when TrueClass, FalseClass
    raise "ボタンを渡してください"
  when Symbol, String
    self.remaps[button] = { to: [to] }
  when Array
    raise "ボタンを渡してください" if to.size.zero?
    self.remaps[button] = { to: to }
  end
end