Module: RbSDL2::Mouse

Extended by:
MouseButton
Defined in:
lib/rb_sdl2/mouse/mouse.rb,
lib/rb_sdl2/mouse/mouse_class.rb,
lib/rb_sdl2/mouse/mouse_wheel.rb,
lib/rb_sdl2/mouse/global_mouse.rb,
lib/rb_sdl2/mouse/mouse_button.rb,
lib/rb_sdl2/mouse/relative_mouse.rb

Defined Under Namespace

Modules: MouseButton Classes: GlobalMouse, MouseClass, MouseWheel, RelativeMouse

Constant Summary

Constants included from MouseButton

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

Class Method Summary collapse

Methods included from MouseButton

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

Class Method Details

.buttonObject



28
# File 'lib/rb_sdl2/mouse/mouse.rb', line 28

def button = ::SDL.GetMouseState(nil, nil)

.capture=(bool) ⇒ Object

Raises:



4
5
6
7
# File 'lib/rb_sdl2/mouse/mouse.rb', line 4

def capture=(bool)
  err = ::SDL.CaptureMouse(bool ? ::SDL::TRUE : ::SDL::FALSE)
  raise RbSDL2Error if err < 0
end

.global_mouseObject



24
# File 'lib/rb_sdl2/mouse/mouse.rb', line 24

def global_mouse = GlobalMouse.new.update

.positionObject



33
34
35
36
# File 'lib/rb_sdl2/mouse/mouse.rb', line 33

def position
  ::SDL.GetMouseState(@x, @y)
  [@x.read_int, @y.read_int]
end

.position=(x_y) ⇒ Object



38
39
40
# File 'lib/rb_sdl2/mouse/mouse.rb', line 38

def position=(x_y)
  ::SDL.WarpMouseInWindow(nil, *x_y)
end

.relative=(bool) ⇒ Object

Raises:



9
10
11
12
# File 'lib/rb_sdl2/mouse/mouse.rb', line 9

def relative=(bool)
  err = ::SDL.SetRelativeMouseMode(bool ? ::SDL::TRUE : ::SDL::FALSE)
  raise RbSDL2Error if err < 0
end

.relative?Boolean

Returns:

  • (Boolean)


14
# File 'lib/rb_sdl2/mouse/mouse.rb', line 14

def relative? = ::SDL.GetRelativeMouseMode == ::SDL::TRUE

.relative_mouseObject



26
# File 'lib/rb_sdl2/mouse/mouse.rb', line 26

def relative_mouse = RelativeMouse.instance

.wheelObject



61
# File 'lib/rb_sdl2/mouse/mouse.rb', line 61

def wheel = @wheel&.update.wheel_y

.wheel=(bool) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/rb_sdl2/mouse/mouse.rb', line 52

def wheel=(bool)
  if bool
    @wheel ||= MouseWheel.new.tap { |obj| obj.wheel = true }
  else
    @wheel.wheel = false
    @wheel = nil
  end
end

.xObject



42
43
44
45
# File 'lib/rb_sdl2/mouse/mouse.rb', line 42

def x
  ::SDL.GetMouseState(@x, nil)
  @x.read_int
end

.yObject



47
48
49
50
# File 'lib/rb_sdl2/mouse/mouse.rb', line 47

def y
  ::SDL.GetMouseState(nil, @y)
  @y.read_int
end