7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/doom/platform/sdl.rb', line 7
def self.setup
require 'fiddle'
gosu_spec = Gem.loaded_specs['gosu']
lib_ext = RbConfig::CONFIG['DLEXT'] || 'so'
bundle = File.join(gosu_spec.full_gem_path, 'lib', "gosu.#{lib_ext}")
@lib = Fiddle.dlopen(bundle)
@shared_window = Fiddle::Function.new(
@lib['_ZN4Gosu13shared_windowEv'], [], Fiddle::TYPE_VOIDP
)
@set_kb_grab = Fiddle::Function.new(
@lib['SDL_SetWindowKeyboardGrab'],
[Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT], Fiddle::TYPE_VOID
)
@ready = true
rescue StandardError, LoadError => e
warn "SDLKeyboardGrab.setup failed: #{e.class}: #{e.message}"
@ready = false
end
|