Sha256: 3baed934290aa95678b00cf9372fc799a42895bd034b5a52b231bf0e464e7e41

Contents?: true

Size: 1.01 KB

Versions: 5

Compression:

Stored size: 1.01 KB

Contents

module Browser; class Event

class Gamepad < Event
  handles 'gamepadconnected', 'gamepaddisconnected'

  def self.supported?
    Browser.supports? 'Event.Gamepad'
  end

  class Definition < Definition
    def id=(value)
      `#@native.id = #{value}`
    end

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

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

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

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

  if Browser.supports? 'Event.constructor'
    def self.construct(name, desc)
      `return new GamepadEvent(#{name}, {
        bubbles:    desc.bubbles,
        cancelable: desc.cancelable,
        gamepad:    desc })`
    end
  end if supported?

  def id
    `#@native.gamepad.id`
  end

  def index
    `#@native.gamepad.index`
  end

  def at
    `#@native.gamepad.timestamp`
  end

  def axes
    `#@native.gamepad.axes`
  end

  def buttons
    `#@native.gamepad.buttons`
  end
end

end; end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
atome-opal-browser-0.3.9.5 opal/browser/event/gamepad.rb
opal-browser-0.3.3 opal/browser/event/gamepad.rb
opal-browser-0.3.2 opal/browser/event/gamepad.rb
opal-browser-0.3.1 opal/browser/event/gamepad.rb
opal-browser-0.3.0 opal/browser/event/gamepad.rb