Module: RbSDL2::Event::EventType

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

Constant Summary collapse

RANGE =
::SDL2::SDL_FIRSTEVENT..::SDL2::SDL_LASTEVENT
EVENT_TYPES =
RANGE.first.succ...::SDL2::SDL_LASTEVENT
COMMON_EVENT_TYPES =
EVENT_TYPES.first...::SDL2::SDL_USEREVENT
USER_EVENT_TYPES =
::SDL2::SDL_USEREVENT...EVENT_TYPES.last
MEMBER_MAP =
Hash.new(&default_type).merge!(
  ::SDL2::SDL_AUDIODEVICEADDED => :adevice,
  ::SDL2::SDL_AUDIODEVICEREMOVED => :adevice,
  ::SDL2::SDL_DISPLAYEVENT => :display,
  ::SDL2::SDL_KEYDOWN => :key,
  ::SDL2::SDL_KEYUP => :key,
  ::SDL2::SDL_CONTROLLERAXISMOTION => :caxis,
  ::SDL2::SDL_CONTROLLERBUTTONDOWN => :cbutton,
  ::SDL2::SDL_CONTROLLERBUTTONUP => :cbutton,
  ::SDL2::SDL_CONTROLLERDEVICEADDED => :cdevice,
  ::SDL2::SDL_CONTROLLERDEVICEREMAPPED => :cdevice,
  ::SDL2::SDL_CONTROLLERDEVICEREMOVED => :cdevice,
  ::SDL2::SDL_CONTROLLERSENSORUPDATE => :csensor,
  ::SDL2::SDL_CONTROLLERTOUCHPADDOWN => :ctouchpad,
  ::SDL2::SDL_CONTROLLERTOUCHPADMOTION => :ctouchpad,
  ::SDL2::SDL_CONTROLLERTOUCHPADUP => :ctouchpad,
  ::SDL2::SDL_DOLLARGESTURE => :dgesture,
  ::SDL2::SDL_DOLLARRECORD => :dgesture,
  ::SDL2::SDL_DROPBEGIN => :drop,
  ::SDL2::SDL_DROPCOMPLETE => :drop,
  ::SDL2::SDL_DROPFILE => :drop,
  ::SDL2::SDL_DROPTEXT => :drop,
  ::SDL2::SDL_FINGERDOWN => :tfinger,
  ::SDL2::SDL_FINGERMOTION => :tfinger,
  ::SDL2::SDL_FINGERUP => :tfinger,
  ::SDL2::SDL_JOYAXISMOTION => :jaxis,
  ::SDL2::SDL_JOYBALLMOTION => :jball,
  ::SDL2::SDL_JOYBUTTONDOWN => :jbutton,
  ::SDL2::SDL_JOYBUTTONUP => :jbutton,
  ::SDL2::SDL_JOYDEVICEADDED => :jdevice,
  ::SDL2::SDL_JOYDEVICEREMOVED => :jdevice,
  ::SDL2::SDL_JOYHATMOTION => :jhat,
  ::SDL2::SDL_MOUSEBUTTONDOWN => :button,
  ::SDL2::SDL_MOUSEBUTTONUP => :button,
  ::SDL2::SDL_MOUSEMOTION => :motion,
  ::SDL2::SDL_MOUSEWHEEL => :wheel,
  ::SDL2::SDL_MULTIGESTURE => :mgesture,
  ::SDL2::SDL_QUIT => :quit,
  ::SDL2::SDL_SENSORUPDATE => :sensor,
  ::SDL2::SDL_SYSWMEVENT => :syswm,
  ::SDL2::SDL_TEXTEDITING => :edit,
  ::SDL2::SDL_TEXTINPUT => :text,
  ::SDL2::SDL_WINDOWEVENT => :window,
).freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define_user_event(name = "user_event") ⇒ Object



132
133
134
135
136
137
138
139
140
141
# File 'lib/rb_sdl2/event/event_type.rb', line 132

def define_user_event(name = "user_event")
  @mutex.synchronize do
    num = ::SDL2::SDL_RegisterEvents(1)
    if num == 0xFFFFFFFF
      raise RbSDL2Error, "unable to register user events because too many requests"
    end
    @name_map[num] = name
    num
  end
end

.disable(type) ⇒ Object



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

def disable(type) = ::SDL2.SDL_EventState(type, ::SDL2::SDL_DISABLE) == ::SDL2::SDL_ENABLE

.enable(type) ⇒ Object



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

def enable(type) = ::SDL2.SDL_EventState(type, ::SDL2::SDL_ENABLE) == ::SDL2::SDL_DISABLE

.ignore?(type) ⇒ Boolean

Returns:

  • (Boolean)


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

def ignore?(type) = ::SDL2.SDL_EventState(type, ::SDL2::SDL_QUERY) == ::SDL2::SDL_IGNORE

.minmaxObject



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

def minmax = RANGE.minmax

.to_name(num) ⇒ Object



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

def to_name(num) = @name_map[num]

.to_num(obj) ⇒ Object

Raises:

  • (ArgumentError)


153
154
155
156
157
# File 'lib/rb_sdl2/event/event_type.rb', line 153

def to_num(obj)
  num =  @name_map.key(obj.to_s)
  raise ArgumentError unless num
  num
end

.to_type(num) ⇒ Object



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

def to_type(num) = MEMBER_MAP[num]

Instance Method Details

#app_did_enter_background?Boolean

Returns:

  • (Boolean)


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

def app_did_enter_background? = ::SDL2::SDL_APP_DIDENTERBACKGROUND == type

#app_did_enter_foreground?Boolean

Returns:

  • (Boolean)


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

def app_did_enter_foreground? = ::SDL2::SDL_APP_DIDENTERFOREGROUND == type

#app_low_memory?Boolean

Returns:

  • (Boolean)


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

def app_low_memory? = ::SDL2::SDL_APP_LOWMEMORY == type

#app_terminating?Boolean

Returns:

  • (Boolean)


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

def app_terminating? = ::SDL2::SDL_APP_TERMINATING == type

#app_will_enter_background?Boolean

Returns:

  • (Boolean)


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

def app_will_enter_background? = ::SDL2::SDL_APP_WILLENTERBACKGROUND == type

#app_will_enter_foreground?Boolean

Returns:

  • (Boolean)


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

def app_will_enter_foreground? = ::SDL2::SDL_APP_WILLENTERFOREGROUND == type

#audio_device_added?Boolean

Returns:

  • (Boolean)


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

def audio_device_added? = ::SDL2::SDL_AUDIODEVICEADDED == type

#audio_device_removed?Boolean

Returns:

  • (Boolean)


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

def audio_device_removed? = ::SDL2::SDL_AUDIODEVICEREMOVED == type

#clipboard_update?Boolean

Returns:

  • (Boolean)


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

def clipboard_update? = ::SDL2::SDL_CLIPBOARDUPDATE == type

#controller_axis_motion?Boolean

Returns:

  • (Boolean)


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

def controller_axis_motion? = ::SDL2::SDL_CONTROLLERAXISMOTION == type

#controller_button_down?Boolean

Returns:

  • (Boolean)


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

def controller_button_down? = ::SDL2::SDL_CONTROLLERBUTTONDOWN == type

#controller_button_up?Boolean

Returns:

  • (Boolean)


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

def controller_button_up? = ::SDL2::SDL_CONTROLLERBUTTONUP == type

#controller_device_added?Boolean

Returns:

  • (Boolean)


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

def controller_device_added? = ::SDL2::SDL_CONTROLLERDEVICEADDED == type

#controller_device_remapped?Boolean

Returns:

  • (Boolean)


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

def controller_device_remapped? = ::SDL2::SDL_CONTROLLERDEVICEREMAPPED == type

#controller_device_removed?Boolean

Returns:

  • (Boolean)


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

def controller_device_removed? = ::SDL2::SDL_CONTROLLERDEVICEREMOVED == type

#controller_sensor_update?Boolean

Returns:

  • (Boolean)


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

def controller_sensor_update? = ::SDL2::SDL_CONTROLLERSENSORUPDATE == type

#controller_touchpad_down?Boolean

Returns:

  • (Boolean)


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

def controller_touchpad_down? = ::SDL2::SDL_CONTROLLERTOUCHPADDOWN == type

#controller_touchpad_motion?Boolean

Returns:

  • (Boolean)


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

def controller_touchpad_motion? = ::SDL2::SDL_CONTROLLERTOUCHPADMOTION == type

#controller_touchpad_up?Boolean

Returns:

  • (Boolean)


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

def controller_touchpad_up? = ::SDL2::SDL_CONTROLLERTOUCHPADUP == type

#display_event?Boolean

Returns:

  • (Boolean)


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

def display_event? = ::SDL2::SDL_DISPLAYEVENT == type

#dollar_gesture?Boolean

Returns:

  • (Boolean)


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

def dollar_gesture? = ::SDL2::SDL_DOLLARGESTURE == type

#dollar_record?Boolean

Returns:

  • (Boolean)


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

def dollar_record? = ::SDL2::SDL_DOLLARRECORD == type

#drop_begin?Boolean

Returns:

  • (Boolean)


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

def drop_begin? = ::SDL2::SDL_DROPBEGIN == type

#drop_complete?Boolean

Returns:

  • (Boolean)


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

def drop_complete? = ::SDL2::SDL_DROPCOMPLETE == type

#drop_file?Boolean

Returns:

  • (Boolean)


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

def drop_file? = ::SDL2::SDL_DROPFILE == type

#drop_text?Boolean

Returns:

  • (Boolean)


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

def drop_text? = ::SDL2::SDL_DROPTEXT == type

#finger_down?Boolean

Returns:

  • (Boolean)


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

def finger_down? = ::SDL2::SDL_FINGERDOWN == type

#finger_motion?Boolean

Returns:

  • (Boolean)


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

def finger_motion? = ::SDL2::SDL_FINGERMOTION == type

#finger_up?Boolean

Returns:

  • (Boolean)


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

def finger_up? = ::SDL2::SDL_FINGERUP == type

#joy_axis_motion?Boolean

Returns:

  • (Boolean)


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

def joy_axis_motion? = ::SDL2::SDL_JOYAXISMOTION == type

#joy_ball_motion?Boolean

Returns:

  • (Boolean)


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

def joy_ball_motion? = ::SDL2::SDL_JOYBALLMOTION == type

#joy_button_down?Boolean

Returns:

  • (Boolean)


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

def joy_button_down? = ::SDL2::SDL_JOYBUTTONDOWN == type

#joy_button_up?Boolean

Returns:

  • (Boolean)


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

def joy_button_up? = ::SDL2::SDL_JOYBUTTONUP == type

#joy_device_added?Boolean

Returns:

  • (Boolean)


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

def joy_device_added? = ::SDL2::SDL_JOYDEVICEADDED == type

#joy_device_removed?Boolean

Returns:

  • (Boolean)


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

def joy_device_removed? = ::SDL2::SDL_JOYDEVICEREMOVED == type

#joy_hat_motion?Boolean

Returns:

  • (Boolean)


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

def joy_hat_motion? = ::SDL2::SDL_JOYHATMOTION == type

#key_down?Boolean

Returns:

  • (Boolean)


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

def key_down? = ::SDL2::SDL_KEYDOWN == type

#key_up?Boolean

Returns:

  • (Boolean)


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

def key_up? = ::SDL2::SDL_KEYUP == type

#keymap_changed?Boolean

Returns:

  • (Boolean)


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

def keymap_changed? = ::SDL2::SDL_KEYMAPCHANGED == type

#locale_changed?Boolean

Returns:

  • (Boolean)


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

def locale_changed? = ::SDL2::SDL_LOCALECHANGED == type

#mouse_button_down?Boolean

Returns:

  • (Boolean)


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

def mouse_button_down? = ::SDL2::SDL_MOUSEBUTTONDOWN == type

#mouse_button_up?Boolean

Returns:

  • (Boolean)


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

def mouse_button_up? = ::SDL2::SDL_MOUSEBUTTONUP == type

#mouse_motion?Boolean

Returns:

  • (Boolean)


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

def mouse_motion? = ::SDL2::SDL_MOUSEMOTION == type

#mouse_wheel?Boolean

Returns:

  • (Boolean)


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

def mouse_wheel? = ::SDL2::SDL_MOUSEWHEEL == type

#multi_gesture?Boolean

Returns:

  • (Boolean)


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

def multi_gesture? = ::SDL2::SDL_MULTIGESTURE == type

#quit?Boolean

Returns:

  • (Boolean)


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

def quit? = ::SDL2::SDL_QUIT == type

#render_device_reset?Boolean

Returns:

  • (Boolean)


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

def render_device_reset? = ::SDL2::SDL_RENDER_DEVICE_RESET == type

#render_targets_reset?Boolean

Returns:

  • (Boolean)


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

def render_targets_reset? = ::SDL2::SDL_RENDER_TARGETS_RESET == type

#sensor_update?Boolean

Returns:

  • (Boolean)


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

def sensor_update? = ::SDL2::SDL_SENSORUPDATE == type

#sys_wm_event?Boolean

Returns:

  • (Boolean)


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

def sys_wm_event? = ::SDL2::SDL_SYSWMEVENT == type

#text_editing?Boolean

Returns:

  • (Boolean)


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

def text_editing? = ::SDL2::SDL_TEXTEDITING == type

#text_input?Boolean

Returns:

  • (Boolean)


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

def text_input? = ::SDL2::SDL_TEXTINPUT == type

#user_event?Boolean

Returns:

  • (Boolean)


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

def user_event? = USER_EVENT_TYPES === type

#window_event?Boolean

Returns:

  • (Boolean)


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

def window_event? = ::SDL2::SDL_WINDOWEVENT == type