Class: Hokusai::Input

Inherits:
Object
  • Object
show all
Defined in:
ui/src/hokusai/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Input

Returns a new instance of Input.



250
251
252
# File 'ui/src/hokusai/types.rb', line 250

def initialize(raw)
  @raw = raw
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



244
245
246
# File 'ui/src/hokusai/types.rb', line 244

def raw
  @raw
end

Instance Method Details

#hashObject



246
247
248
# File 'ui/src/hokusai/types.rb', line 246

def hash
  [self.class, mouse.pos.x, mouse.pos.y, mouse.scroll, mouse.left.clicked, mouse.left.down, mouse.left.up].hash
end

#hovered?(canvas) ⇒ Boolean

Returns:

  • (Boolean)


262
263
264
# File 'ui/src/hokusai/types.rb', line 262

def hovered?(canvas)
  LibHokusai.hoku_input_is_hovered(raw, canvas.to_hoku_rect)
end

#keyboardObject



254
255
256
# File 'ui/src/hokusai/types.rb', line 254

def keyboard
  Keyboard.new(@raw[:keyboard])
end

#mouseObject



258
259
260
# File 'ui/src/hokusai/types.rb', line 258

def mouse
  @mouse ||= Mouse.new(@raw[:mouse])
end