def set_items(self): if not SDL_WasInit(SDL_INIT_VIDEO): SDL_InitSubSystem(SDL_INIT_VIDEO) self.get_opts(), self.get_keys() self.set_opts(), self.set_keys() if SDL_WasInit(SDL_INIT_VIDEO): SDL_QuitSubSystem(SDL_INIT_VIDEO)
def test_init_quit(self): sdl2ext.init() self.assertEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.init() sdl2ext.init() sdl2ext.init() self.assertEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() sdl2ext.quit() sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO)
def test_SDL_INIT_AUDIO(self): ret = SDL_Init(SDL_INIT_AUDIO) if ret != 0: pytest.skip('Audio subsystem not supported') ret = SDL_WasInit(SDL_INIT_AUDIO) assert ret == SDL_INIT_AUDIO SDL_QuitSubSystem(SDL_INIT_AUDIO)
def test_SDL_INIT_TIMER(self): ret = SDL_Init(SDL_INIT_TIMER) if ret != 0: pytest.skip('Timer subsystem not supported') ret = SDL_WasInit(SDL_INIT_TIMER) assert ret == SDL_INIT_TIMER SDL_QuitSubSystem(SDL_INIT_TIMER)
def test_SDL_INIT_VIDEO(self): ret = SDL_Init(SDL_INIT_VIDEO) if ret != 0: self.skipTest('Video subsystem not supported') ret = SDL_WasInit(SDL_INIT_VIDEO) self.assertEqual(ret, SDL_INIT_VIDEO) SDL_QuitSubSystem(SDL_INIT_VIDEO)
def test_SDL_INIT_JOYSTICK(self): ret = SDL_Init(SDL_INIT_JOYSTICK) if ret != 0: pytest.skip('Joystick subsystem not supported') ret = SDL_WasInit(SDL_INIT_JOYSTICK) assert ret == SDL_INIT_JOYSTICK SDL_QuitSubSystem(SDL_INIT_JOYSTICK)
def test_SDL_INIT_HAPTIC(self): ret = SDL_Init(SDL_INIT_HAPTIC) if ret != 0: pytest.skip('Haptic subsystem not supported') ret = SDL_WasInit(SDL_INIT_HAPTIC) assert ret == SDL_INIT_HAPTIC SDL_QuitSubSystem(SDL_INIT_HAPTIC)
def test_SDL_INIT_HAPTIC(self): ret = SDL_Init(SDL_INIT_HAPTIC) if ret != 0: self.skipTest('Haptic subsystem not supported') ret = SDL_WasInit(SDL_INIT_HAPTIC) self.assertEqual(ret, SDL_INIT_HAPTIC) SDL_QuitSubSystem(SDL_INIT_HAPTIC)
def test_SDL_INIT_JOYSTICK(self): ret = SDL_Init(SDL_INIT_JOYSTICK) if ret != 0: self.skipTest('Joystick subsystem not supported') ret = SDL_WasInit(SDL_INIT_JOYSTICK) self.assertEqual(ret, SDL_INIT_JOYSTICK) SDL_QuitSubSystem(SDL_INIT_JOYSTICK)
def test_SDL_INIT_VIDEO(self): ret = SDL_Init(SDL_INIT_VIDEO) if ret != 0: pytest.skip('Video subsystem not supported') ret = SDL_WasInit(SDL_INIT_VIDEO) assert ret == SDL_INIT_VIDEO SDL_QuitSubSystem(SDL_INIT_VIDEO)
def test_SDL_INIT_TIMER(self): ret = SDL_Init(SDL_INIT_TIMER) if ret != 0: self.skipTest('Timer subsystem not supported') ret = SDL_WasInit(SDL_INIT_TIMER) self.assertEqual(ret, SDL_INIT_TIMER) SDL_QuitSubSystem(SDL_INIT_TIMER)
def init(self): if not SDL_WasInit(SDL_INIT_JOYSTICK): if SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0: for i in range(SDL_NumJoysticks()): self.joystick_names.append(SDL_JoystickNameForIndex(i)) self.joystick_timer.timeout.connect(self.process_events) else: log.info("couldn't initialize SDL joystick support")
def test_init_quit(self): try: sdl2ext.init() except sdl2ext.SDLError: raise unittest.SkipTest('Video subsystem not supported') self.assertEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.init() sdl2ext.init() sdl2ext.init() self.assertEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO) sdl2ext.quit() sdl2ext.quit() sdl2ext.quit() self.assertNotEqual(SDL_WasInit(SDL_INIT_VIDEO), SDL_INIT_VIDEO)
def test_init_quit(self): try: sdl2ext.init() except sdl2ext.SDLError: raise pytest.skip('Video subsystem not supported') assert SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO sdl2ext.quit() assert SDL_WasInit(SDL_INIT_VIDEO) != SDL_INIT_VIDEO sdl2ext.init() sdl2ext.init() sdl2ext.init() assert SDL_WasInit(SDL_INIT_VIDEO) == SDL_INIT_VIDEO sdl2ext.quit() assert SDL_WasInit(SDL_INIT_VIDEO) != SDL_INIT_VIDEO sdl2ext.quit() sdl2ext.quit() sdl2ext.quit() assert SDL_WasInit(SDL_INIT_VIDEO) != SDL_INIT_VIDEO
def signal_handler(signum, frame): signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) if tty_fd: os.close(tty_fd) if SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK: SDL_QuitSubSystem(SDL_INIT_JOYSTICK) SDL_Quit() LOG.debug(f'{sys.argv[0]} exiting cleanly') sys.exit(0)
def init(self): if not SDL_WasInit(SDL_INIT_JOYSTICK): if SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0: for i in range(SDL_NumJoysticks()): joystick_name = SDL_JoystickNameForIndex(i) if isinstance(joystick_name, bytes): joystick_name = joystick_name.decode() self.joystick_names.append(joystick_name.strip()) self.joystick_timer.timeout.connect(self.process_events) else: log.info("couldn't initialize SDL joystick support")
# nvidia hack from OpenGL import GL glimport = True except: glimport = False from PyQt5.QtOpenGL import QGLFormat from sdl2 import SDL_WasInit, SDL_InitSubSystem, SDL_QuitSubSystem, SDL_INIT_VIDEO from sdl2 import SDL_GetNumDisplayModes, SDL_DisplayMode, SDL_GetDisplayMode from m64py.core.defs import * from m64py.frontend.log import log try: if not SDL_WasInit(SDL_INIT_VIDEO): SDL_InitSubSystem(SDL_INIT_VIDEO) MODES = [] display = SDL_DisplayMode() for mode in range(SDL_GetNumDisplayModes(0)): ret = SDL_GetDisplayMode(0, mode, ctypes.byref(display)) if (display.w, display.h) not in MODES: MODES.append((display.w, display.h)) if SDL_WasInit(SDL_INIT_VIDEO): SDL_QuitSubSystem(SDL_INIT_VIDEO) except Exception as err: log.warn(str(err)) class Video(): """Mupen64Plus video extension"""
def test_SDL_INIT_HAPTIC(self): ret = SDL_Init(SDL_INIT_HAPTIC) self.assertEqual(ret, 0, SDL_GetError()) ret = SDL_WasInit(SDL_INIT_HAPTIC) self.assertEqual(ret, SDL_INIT_HAPTIC) SDL_QuitSubSystem(SDL_INIT_HAPTIC)