Sha256: 49d6a2486b289f0b391abe718487f1deb45c6b36e0cff560cb9317cd807fd96b
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
require "procon_bypass_man/bypass/bypass_command" class ProconBypassMan::Bypass::SwitchToProcon include ProconBypassMan::Callbacks define_callbacks :run set_callback :run, :after, :log_after_run attr_accessor :gadget, :procon, :bypass_value def initialize(gadget: , procon: ) self.gadget = gadget self.procon = procon end # ゆっくりでいい def run self.bypass_value = ProconBypassMan::Bypass::BypassValue.new(nil) run_callbacks(:run) do next if $will_terminate_token raw_input = nil begin raw_input = self.gadget.read_nonblock(64) self.bypass_value.binary = ProconBypassMan::Domains::InboundProconBinary.new(binary: raw_input) rescue IO::EAGAINWaitReadable next end if self.bypass_value.binary begin raw_data = case when self.bypass_value.binary.rumble_data? # TODO そもそも無効になっているので消していい binary = ProconBypassMan::RumbleBinary.new(binary: self.bypass_value.binary.raw) binary.noop! binary.raw else self.bypass_value.binary.raw end # バイブレーションを無効にしているのでおそらく書き込む必要はない # self.procon.write_nonblock(raw_data) rescue IO::EAGAINWaitReadable next end end end end private def log_after_run return unless bypass_value.to_text if ProconBypassMan.config.verbose_bypass_log ProconBypassMan.logger.debug { ">>> #{bypass_value.to_text}" } else ProconBypassMan.cache.fetch key: 'bypass_log', expires_in: 1 do ProconBypassMan.logger.debug { ">>> #{bypass_value.to_text}" } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
procon_bypass_man-0.2.3 | lib/procon_bypass_man/bypass/switch_to_procon.rb |