Sha256: bddbb5843a60776a8d72cd0ee422bda1a97e7569b106daed38548eac30538ea0

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

module Browser; module DOM; class Event

class Gamepad < Event
  def self.supported?
    not $$[:GamepadEvent].nil?
  end

  class Definition < Definition
    def initialize(*)
      super

      `#@native.gamepad = {}`
    end

    def id=(value)
      `#@native.gamepad.id = #{value}`
    end

    def index=(value)
      `#@native.gamepad.index = #{value}`
    end

    def timestamp=(value)
      `#@native.gamepad.timestamp = #{value}`
    end

    def axes=(value)
      `#@native.gamepad.axes = #{value}`
    end

    def buttons=(value)
      `#@native.gamepad.buttons = #{value}`
    end
  end

  def self.create(name, &block)
    new(`new GamepadEvent(#{name}, #{Definition.new(&block)})`)
  end

  %w(id index timestamp axes buttons).each {|name|
    define_method name do
      `#@native.gamepad[#{name}]`
    end
  }
end

end; end; end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 opal/browser/dom/event/gamepad.rb