Sha256: a50db9d6f5597cf0c818b981669858ced2b520d31f50ed980f4c063ee18dad42

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

class ProconBypassMan::Bypass
  module UsbHidLogger
    extend ProconBypassMan::Callbacks::ClassMethods
    include ProconBypassMan::Callbacks

    define_callbacks :send_gadget_to_procon
    define_callbacks :send_procon_to_gadget

    set_callback :send_gadget_to_procon, :after, :log_send_gadget_to_procon
    set_callback :send_procon_to_gadget, :after, :log_procon_to_gadget

    def log_send_gadget_to_procon
      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

    def log_procon_to_gadget
      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

      if ProconBypassMan.config.enable_reporting_pressed_buttons
        ProconBypassMan.cache.fetch key: 'pressed_buttons_reporter', expires_in: 5 do
          ProconBypassMan::ReportPressedButtonsJob.perform_async(
            bypass_value.binary.to_procon_reader.to_hash
          )
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
procon_bypass_man-0.1.21 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.20.2 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.20.1 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.20 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.19.1 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.19 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.18 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.17 lib/procon_bypass_man/bypass/usb_hid_logger.rb
procon_bypass_man-0.1.16.1 lib/procon_bypass_man/bypass/usb_hid_logger.rb