Module: RbSDL2::EventType

Included in:
Event
Defined in:
lib/rb_sdl2/event/event_type.rb

Constant Summary collapse

COMMON_EVENT_TYPES =
::SDL::FIRSTEVENT.succ...::SDL::USEREVENT
USER_EVENT_TYPES =
::SDL::USEREVENT...::SDL::LASTEVENT
ENTITY_MAP =
Hash.new(&default_klass).merge!(table.map { |a| a.first(2) }.to_h).freeze
NAME_MAP =
Hash.new.merge!(table.map { |c, _, s| [c, s.freeze] }.to_h).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.disable(num) ⇒ Object



71
# File 'lib/rb_sdl2/event/event_type.rb', line 71

def disable(num) = ::SDL.EventState(num, ::SDL::DISABLE) == ::SDL::ENABLE

.enable(num) ⇒ Object



73
# File 'lib/rb_sdl2/event/event_type.rb', line 73

def enable(num) = ::SDL.EventState(num, ::SDL::ENABLE) == ::SDL::DISABLE

.ignore?(num) ⇒ Boolean

Returns:

  • (Boolean)


75
# File 'lib/rb_sdl2/event/event_type.rb', line 75

def ignore?(num) = ::SDL.EventState(num, ::SDL::QUERY) == ::SDL::IGNORE

.register_events(num) ⇒ Object



77
78
79
80
81
# File 'lib/rb_sdl2/event/event_type.rb', line 77

def register_events(num)
  if ::SDL.RegisterEvents(num) == 0xFFFFFFFF
    raise RbSDL2Error, "unable to register user events because too many requests"
  end
end

.to_name(num) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/rb_sdl2/event/event_type.rb', line 83

def to_name(num)
  case num
  when COMMON_EVENT_TYPES then NAME_MAP[num]
  when USER_EVENT_TYPES then "SDL_USEREVENT".freeze
  else nil
  end
end

.to_types(obj) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/rb_sdl2/event/event_type.rb', line 91

def to_types(obj)
  case obj
  when nil then [::SDL::FIRSTEVENT, ::SDL::LASTEVENT]
  when Integer then [obj, obj]
  when Range then obj.minmax
  else raise ArgumentError
  end
end

Instance Method Details

#app_did_enter_background?Boolean

Returns:

  • (Boolean)


101
# File 'lib/rb_sdl2/event/event_type.rb', line 101

def app_did_enter_background? = ::SDL::APP_DIDENTERBACKGROUND == type

#app_did_enter_foreground?Boolean

Returns:

  • (Boolean)


103
# File 'lib/rb_sdl2/event/event_type.rb', line 103

def app_did_enter_foreground? = ::SDL::APP_DIDENTERFOREGROUND == type

#app_low_memory?Boolean

Returns:

  • (Boolean)


105
# File 'lib/rb_sdl2/event/event_type.rb', line 105

def app_low_memory? = ::SDL::APP_LOWMEMORY == type

#app_terminating?Boolean

Returns:

  • (Boolean)


107
# File 'lib/rb_sdl2/event/event_type.rb', line 107

def app_terminating? = ::SDL::APP_TERMINATING == type

#app_will_enter_background?Boolean

Returns:

  • (Boolean)


109
# File 'lib/rb_sdl2/event/event_type.rb', line 109

def app_will_enter_background? = ::SDL::APP_WILLENTERBACKGROUND == type

#app_will_enter_foreground?Boolean

Returns:

  • (Boolean)


111
# File 'lib/rb_sdl2/event/event_type.rb', line 111

def app_will_enter_foreground? = ::SDL::APP_WILLENTERFOREGROUND == type

#audio_device_added?Boolean

Returns:

  • (Boolean)


113
# File 'lib/rb_sdl2/event/event_type.rb', line 113

def audio_device_added? = ::SDL::AUDIODEVICEADDED == type

#audio_device_removed?Boolean

Returns:

  • (Boolean)


115
# File 'lib/rb_sdl2/event/event_type.rb', line 115

def audio_device_removed? = ::SDL::AUDIODEVICEREMOVED == type

#clipboard_update?Boolean

Returns:

  • (Boolean)


117
# File 'lib/rb_sdl2/event/event_type.rb', line 117

def clipboard_update? = ::SDL::CLIPBOARDUPDATE == type

#controller_axis_motion?Boolean

Returns:

  • (Boolean)


119
# File 'lib/rb_sdl2/event/event_type.rb', line 119

def controller_axis_motion? = ::SDL::CONTROLLERAXISMOTION == type

#controller_button_down?Boolean

Returns:

  • (Boolean)


121
# File 'lib/rb_sdl2/event/event_type.rb', line 121

def controller_button_down? = ::SDL::CONTROLLERBUTTONDOWN == type

#controller_button_up?Boolean

Returns:

  • (Boolean)


123
# File 'lib/rb_sdl2/event/event_type.rb', line 123

def controller_button_up? = ::SDL::CONTROLLERBUTTONUP == type

#controller_device_added?Boolean

Returns:

  • (Boolean)


125
# File 'lib/rb_sdl2/event/event_type.rb', line 125

def controller_device_added? = ::SDL::CONTROLLERDEVICEADDED == type

#controller_device_remapped?Boolean

Returns:

  • (Boolean)


127
# File 'lib/rb_sdl2/event/event_type.rb', line 127

def controller_device_remapped? = ::SDL::CONTROLLERDEVICEREMAPPED == type

#controller_device_removed?Boolean

Returns:

  • (Boolean)


129
# File 'lib/rb_sdl2/event/event_type.rb', line 129

def controller_device_removed? = ::SDL::CONTROLLERDEVICEREMOVED == type

#controller_sensor_update?Boolean

Returns:

  • (Boolean)


131
# File 'lib/rb_sdl2/event/event_type.rb', line 131

def controller_sensor_update? = ::SDL::CONTROLLERSENSORUPDATE == type

#controller_touchpad_down?Boolean

Returns:

  • (Boolean)


133
# File 'lib/rb_sdl2/event/event_type.rb', line 133

def controller_touchpad_down? = ::SDL::CONTROLLERTOUCHPADDOWN == type

#controller_touchpad_motion?Boolean

Returns:

  • (Boolean)


135
# File 'lib/rb_sdl2/event/event_type.rb', line 135

def controller_touchpad_motion? = ::SDL::CONTROLLERTOUCHPADMOTION == type

#controller_touchpad_up?Boolean

Returns:

  • (Boolean)


137
# File 'lib/rb_sdl2/event/event_type.rb', line 137

def controller_touchpad_up? = ::SDL::CONTROLLERTOUCHPADUP == type

#display_event?Boolean

Returns:

  • (Boolean)


139
# File 'lib/rb_sdl2/event/event_type.rb', line 139

def display_event? = ::SDL::DISPLAYEVENT == type

#dollar_gesture?Boolean

Returns:

  • (Boolean)


141
# File 'lib/rb_sdl2/event/event_type.rb', line 141

def dollar_gesture? = ::SDL::DOLLARGESTURE == type

#dollar_record?Boolean

Returns:

  • (Boolean)


143
# File 'lib/rb_sdl2/event/event_type.rb', line 143

def dollar_record? = ::SDL::DOLLARRECORD == type

#drop_begin?Boolean

Returns:

  • (Boolean)


145
# File 'lib/rb_sdl2/event/event_type.rb', line 145

def drop_begin? = ::SDL::DROPBEGIN == type

#drop_complete?Boolean

Returns:

  • (Boolean)


147
# File 'lib/rb_sdl2/event/event_type.rb', line 147

def drop_complete? = ::SDL::DROPCOMPLETE == type

#drop_file?Boolean

Returns:

  • (Boolean)


149
# File 'lib/rb_sdl2/event/event_type.rb', line 149

def drop_file? = ::SDL::DROPFILE == type

#drop_text?Boolean

Returns:

  • (Boolean)


151
# File 'lib/rb_sdl2/event/event_type.rb', line 151

def drop_text? = ::SDL::DROPTEXT == type

#finger_down?Boolean

Returns:

  • (Boolean)


153
# File 'lib/rb_sdl2/event/event_type.rb', line 153

def finger_down? = ::SDL::FINGERDOWN == type

#finger_motion?Boolean

Returns:

  • (Boolean)


155
# File 'lib/rb_sdl2/event/event_type.rb', line 155

def finger_motion? = ::SDL::FINGERMOTION == type

#finger_up?Boolean

Returns:

  • (Boolean)


157
# File 'lib/rb_sdl2/event/event_type.rb', line 157

def finger_up? = ::SDL::FINGERUP == type

#joy_axis_motion?Boolean

Returns:

  • (Boolean)


159
# File 'lib/rb_sdl2/event/event_type.rb', line 159

def joy_axis_motion? = ::SDL::JOYAXISMOTION == type

#joy_ball_motion?Boolean

Returns:

  • (Boolean)


161
# File 'lib/rb_sdl2/event/event_type.rb', line 161

def joy_ball_motion? = ::SDL::JOYBALLMOTION == type

#joy_button_down?Boolean

Returns:

  • (Boolean)


163
# File 'lib/rb_sdl2/event/event_type.rb', line 163

def joy_button_down? = ::SDL::JOYBUTTONDOWN == type

#joy_button_up?Boolean

Returns:

  • (Boolean)


165
# File 'lib/rb_sdl2/event/event_type.rb', line 165

def joy_button_up? = ::SDL::JOYBUTTONUP == type

#joy_device_added?Boolean

Returns:

  • (Boolean)


167
# File 'lib/rb_sdl2/event/event_type.rb', line 167

def joy_device_added? = ::SDL::JOYDEVICEADDED == type

#joy_device_removed?Boolean

Returns:

  • (Boolean)


169
# File 'lib/rb_sdl2/event/event_type.rb', line 169

def joy_device_removed? = ::SDL::JOYDEVICEREMOVED == type

#joy_hat_motion?Boolean

Returns:

  • (Boolean)


171
# File 'lib/rb_sdl2/event/event_type.rb', line 171

def joy_hat_motion? = ::SDL::JOYHATMOTION == type

#key_down?Boolean

Returns:

  • (Boolean)


173
# File 'lib/rb_sdl2/event/event_type.rb', line 173

def key_down? = ::SDL::KEYDOWN == type

#key_up?Boolean

Returns:

  • (Boolean)


175
# File 'lib/rb_sdl2/event/event_type.rb', line 175

def key_up? = ::SDL::KEYUP == type

#keymap_changed?Boolean

Returns:

  • (Boolean)


177
# File 'lib/rb_sdl2/event/event_type.rb', line 177

def keymap_changed? = ::SDL::KEYMAPCHANGED == type

#locale_changed?Boolean

Returns:

  • (Boolean)


179
# File 'lib/rb_sdl2/event/event_type.rb', line 179

def locale_changed? = ::SDL::LOCALECHANGED == type

#mouse_button_down?Boolean

Returns:

  • (Boolean)


183
# File 'lib/rb_sdl2/event/event_type.rb', line 183

def mouse_button_down? = ::SDL::MOUSEBUTTONDOWN == type

#mouse_button_up?Boolean

Returns:

  • (Boolean)


185
# File 'lib/rb_sdl2/event/event_type.rb', line 185

def mouse_button_up? = ::SDL::MOUSEBUTTONUP == type

#mouse_motion?Boolean

Returns:

  • (Boolean)


187
# File 'lib/rb_sdl2/event/event_type.rb', line 187

def mouse_motion? = ::SDL::MOUSEMOTION == type

#mouse_wheel?Boolean

Returns:

  • (Boolean)


189
# File 'lib/rb_sdl2/event/event_type.rb', line 189

def mouse_wheel? = ::SDL::MOUSEWHEEL == type

#multi_gesture?Boolean

Returns:

  • (Boolean)


181
# File 'lib/rb_sdl2/event/event_type.rb', line 181

def multi_gesture? = ::SDL::MULTIGESTURE == type

#poll_sentinel?Boolean

Returns:

  • (Boolean)


191
# File 'lib/rb_sdl2/event/event_type.rb', line 191

def poll_sentinel? = ::SDL::POLLSENTINEL == type

#quit?Boolean

Returns:

  • (Boolean)


193
# File 'lib/rb_sdl2/event/event_type.rb', line 193

def quit? = ::SDL::QUIT == type

#render_device_reset?Boolean

Returns:

  • (Boolean)


195
# File 'lib/rb_sdl2/event/event_type.rb', line 195

def render_device_reset? = ::SDL::RENDER_DEVICE_RESET == type

#render_targets_reset?Boolean

Returns:

  • (Boolean)


197
# File 'lib/rb_sdl2/event/event_type.rb', line 197

def render_targets_reset? = ::SDL::RENDER_TARGETS_RESET == type

#sensor_update?Boolean

Returns:

  • (Boolean)


199
# File 'lib/rb_sdl2/event/event_type.rb', line 199

def sensor_update? = ::SDL::SENSORUPDATE == type

#sys_wm_event?Boolean

Returns:

  • (Boolean)


201
# File 'lib/rb_sdl2/event/event_type.rb', line 201

def sys_wm_event? = ::SDL::SYSWMEVENT == type

#text_editing?Boolean

Returns:

  • (Boolean)


203
# File 'lib/rb_sdl2/event/event_type.rb', line 203

def text_editing? = ::SDL::TEXTEDITING == type

#text_editing_ext?Boolean

Returns:

  • (Boolean)


205
# File 'lib/rb_sdl2/event/event_type.rb', line 205

def text_editing_ext? = ::SDL::TEXTEDITING_EXT == type

#text_input?Boolean

Returns:

  • (Boolean)


207
# File 'lib/rb_sdl2/event/event_type.rb', line 207

def text_input? = ::SDL::TEXTINPUT == type

#user_event?Boolean

Returns:

  • (Boolean)


209
# File 'lib/rb_sdl2/event/event_type.rb', line 209

def user_event? = USER_EVENT_TYPES === type

#window_event?Boolean

Returns:

  • (Boolean)


211
# File 'lib/rb_sdl2/event/event_type.rb', line 211

def window_event? = ::SDL::WINDOWEVENT == type