Class: SDL2::Joystick

Inherits:
Struct
  • Object
show all
Defined in:
lib/sdl2/joystick.rb,
lib/sdl2/joystick/axes.rb,
lib/sdl2/joystick/hats.rb,
lib/sdl2/joystick/balls.rb,
lib/sdl2/joystick/buttons.rb,
lib/sdl2/joystick/components.rb

Overview

A Joystick has all kinds of components, such as

Defined Under Namespace

Classes: Axes, Balls, Buttons, Components, Hats

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#==, cast, create, #free, #initialize, #to_s, #update_members

Methods included from StructHelper

#member_readers, #member_writers

Constructor Details

This class inherits a constructor from SDL2::Struct

Class Method Details

.name(idx) ⇒ Object

Returns the name of a joystick



25
26
27
# File 'lib/sdl2/joystick.rb', line 25

def self.name(idx)
  SDL2.joystick_name_for_index!(idx)
end

.numObject

Returns the number of attached joysticks on success or a exception on failure



15
16
17
# File 'lib/sdl2/joystick.rb', line 15

def self.num
  SDL2.num_joysticks!
end

.open(idx) ⇒ Object

Returns a joystick identifier or raises exception on error



20
21
22
# File 'lib/sdl2/joystick.rb', line 20

def self.open(idx)      
  SDL2.joystick_open!(idx)
end

.release(pointer) ⇒ Object



9
10
11
# File 'lib/sdl2/joystick.rb', line 9

def self.release(pointer)
  SDL2.joystick_close(pointer)
end

.updateObject

update the current state of open joysticks



30
31
32
# File 'lib/sdl2/joystick.rb', line 30

def self.update()
  SDL2.joystick_update()
end

Instance Method Details

#axesObject

Enumerator for Axes



40
41
42
# File 'lib/sdl2/joystick.rb', line 40

def axes
  @axes ||= Axes.new(self)
end

#ballsObject

Enumerator for balls



46
47
48
# File 'lib/sdl2/joystick.rb', line 46

def balls
  @balls ||= Balls.new(self)
end

#buttonsObject

Enumerator for buttons



52
53
54
# File 'lib/sdl2/joystick.rb', line 52

def buttons
  @buttons ||= Buttons.new(self)
end

#event_state(state = SDL2::Event::STATE::QUERY) ⇒ Object

Event state

Parameters:

  • -

    state

    SDL2::Event::STATE::QUERY [default]: Returns current state

    SDL2::Event::STATE::IGNORE : Disables event dispatching

    SDL2::Event::STATE::ENABLE : Enables event dispatching



79
80
81
# File 'lib/sdl2/joystick.rb', line 79

def event_state(state = SDL2::Event::STATE::QUERY)
  SDL2.joystick_event_state(state)
end

#get_guidObject

Get the GUID



69
70
71
# File 'lib/sdl2/joystick.rb', line 69

def get_guid()
  SDL2.joystick_get_guid!(self)
end

#hatsObject

Enumerator for hats



58
59
60
# File 'lib/sdl2/joystick.rb', line 58

def hats
  @hats ||= Hats.new(self)
end

#instance_idObject

Get the device index of an opened joystick



64
65
66
# File 'lib/sdl2/joystick.rb', line 64

def instance_id()
  SDL2.joystick_instance_id!(self)
end

#nameObject

Returns the name of the joystick



35
36
37
# File 'lib/sdl2/joystick.rb', line 35

def name()
  SDL2.joystick_name(self)
end