Class: RbSDL2::Mouse::GlobalMouse

Inherits:
MouseClass show all
Defined in:
lib/rb_sdl2/mouse/global_mouse.rb

Constant Summary

Constants included from MouseButton

MouseButton::BUTTON, MouseButton::BUTTON_LMASK, MouseButton::BUTTON_MMASK, MouseButton::BUTTON_RMASK, MouseButton::BUTTON_X1MASK, MouseButton::BUTTON_X2MASK

Instance Attribute Summary

Attributes inherited from MouseClass

#button, #x, #y

Instance Method Summary collapse

Methods inherited from MouseClass

#position

Methods included from MouseButton

#any_button?, #button?, #left_button?, #middle_button?, #right_button?, #x1_button?, #x2_button?

Constructor Details

#initializeGlobalMouse

Returns a new instance of GlobalMouse.



6
7
8
9
10
# File 'lib/rb_sdl2/mouse/global_mouse.rb', line 6

def initialize
  @_x = ::FFI::MemoryPointer.new(:int)
  @_y = ::FFI::MemoryPointer.new(:int)
  super
end

Instance Method Details

#position=(x_y) ⇒ Object

Raises:



12
13
14
15
16
# File 'lib/rb_sdl2/mouse/global_mouse.rb', line 12

def position=(x_y)
  err = ::SDL.WarpMouseGlobal(*x_y)
  raise RbSDL2Error if err < 0
  super
end

#updateObject



18
19
20
21
22
# File 'lib/rb_sdl2/mouse/global_mouse.rb', line 18

def update
  self.button, self.x, self.y =
    ::SDL.GetGlobalMouseState(@_x, @_y), @_x.read_int, @_y.read_int
  self
end