Exemplo n.º 1
0
 def __init__(self):
     try:
         import dbus
         self.screensaver = dbus.SessionBus().get_object(
             "org.freedesktop.ScreenSaver", "/ScreenSaver")
     except Exception, err:
         log.info("ScreenSaver not available: %s" % str(err))
Exemplo n.º 2
0
    def attach_plugins(self, plugins):
        """Attaches plugins to the emulator core."""
        self.plugins = plugins
        for plugin_type in PLUGIN_ORDER:
            plugin = self.plugins[plugin_type]

            if not plugin:
                plugin_map = list(self.plugin_map[plugin_type].values())[0]
            else:
                try:
                    plugin_map = self.plugin_map[plugin_type][plugin]
                except KeyError:
                    continue

            (plugin_handle, plugin_path, plugin_name,
             plugin_desc, plugin_version) = plugin_map

            rval = self.m64p.CoreAttachPlugin(
                C.c_int(plugin_type), C.c_void_p(plugin_handle._handle))
            if rval != M64ERR_SUCCESS:
                log.debug("attach_plugins()")
                log.warn(self.error_message(rval))
                log.warn("core failed to attach %s plugin." % (
                    plugin_name))
            else:
                log.info("using %s plugin: '%s' v%s" % (
                    plugin_name.decode(), plugin_desc, version_split(plugin_version)))
Exemplo n.º 3
0
    def attach_plugins(self, plugins):
        """Attaches plugins to the emulator core."""
        self.plugins = plugins
        for plugin_type in PLUGIN_ORDER:
            plugin = self.plugins[plugin_type]
            if not plugin:
                plugin_maps = list(self.plugin_map[plugin_type].values())
                if not plugin_maps:
                    continue
                plugin_map = plugin_maps[0]
            else:
                plugin_map = self.plugin_map[plugin_type][plugin]
            (plugin_handle, plugin_path, plugin_name, plugin_desc,
             plugin_version) = plugin_map

            rval = self.m64p.CoreAttachPlugin(
                C.c_int(plugin_type), C.c_void_p(plugin_handle._handle))
            if rval != M64ERR_SUCCESS:
                log.debug("attach_plugins()")
                log.warn(self.error_message(rval))
                log.warn("core failed to attach %s plugin." % (plugin_name))
            else:
                log.info("using %s plugin: '%s' v%s" %
                         (plugin_name.decode(), plugin_desc,
                          version_split(plugin_version)))
Exemplo n.º 4
0
 def __init__(self):
     try:
         import dbus
         self.screensaver = dbus.SessionBus().get_object(
             "org.freedesktop.ScreenSaver", "/ScreenSaver")
     except Exception as err:
         log.info("ScreenSaver not available: %s" % str(err))
 def disable(self):
     if self.screensaver:
         try:
             self.cookie = self.screensaver.Inhibit("M64Py", "Emulation started")
             log.info("ScreenSaver disabled")
         except Exception as err:
             log.exception(str(err))
Exemplo n.º 6
0
 def toggle_speed_limit(self):
     """Toggles speed limiter."""
     if self.core_state_query(M64CORE_SPEED_LIMITER):
         self.core_state_set(M64CORE_SPEED_LIMITER, 0)
         log.info("Speed limiter disabled")
     else:
         self.core_state_set(M64CORE_SPEED_LIMITER, 1)
         log.info("Speed limiter enabled")
Exemplo n.º 7
0
 def enable(self):
     if self.cookie:
         try:
             self.screensaver.UnInhibit(self.cookie)
             log.info("ScreenSaver enabled")
             self.cookie = None
         except Exception as err:
             log.exception(str(err))
Exemplo n.º 8
0
 def disable(self):
     if self.screensaver:
         try:
             self.cookie = self.screensaver.Inhibit("M64Py",
                                                    "Emulation started")
             log.info("ScreenSaver disabled")
         except Exception as err:
             log.exception(str(err))
Exemplo n.º 9
0
 def toggle_speed_limit(self):
     """Toggles speed limiter."""
     if self.core_state_query(M64CORE_SPEED_LIMITER):
         self.core_state_set(M64CORE_SPEED_LIMITER, 0)
         log.info("Speed limiter disabled")
     else:
         self.core_state_set(M64CORE_SPEED_LIMITER, 1)
         log.info("Speed limiter enabled")
Exemplo n.º 10
0
 def enable(self):
     if self.cookie:
         try:
             self.screensaver.UnInhibit(self.cookie)
             log.info("ScreenSaver enabled")
             self.cookie = None
         except Exception, err:
             log.exception(str(err))
Exemplo n.º 11
0
 def override_vidext(self):
     """Overrides the core's internal SDL-based OpenGL functions."""
     rval = self.m64p.CoreOverrideVidExt(C.pointer(vidext))
     if rval != M64ERR_SUCCESS:
         log.debug("override_vidext()")
         log.warn(self.error_message(rval))
     else:
         log.info("video extension enabled")
     return rval
Exemplo n.º 12
0
 def override_vidext(self):
     """Overrides the core's internal SDL-based OpenGL functions."""
     rval = self.m64p.CoreOverrideVidExt(C.pointer(vidext))
     if rval != M64ERR_SUCCESS:
         log.debug("override_vidext()")
         log.warn(self.error_message(rval))
     else:
         log.info("video extension enabled")
     return rval
Exemplo n.º 13
0
    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")
Exemplo n.º 14
0
 def init(self):
     if not SDL_WasInit(SDL_INIT_JOYSTICK):
         if SDL_InitSubSystem(SDL_INIT_JOYSTICK) == 0:
             for i in range(SDL_NumJoysticks()):
                 if SDL2:
                     self.joystick_names.append(SDL_JoystickNameForIndex(i))
                 else:
                     self.joystick_names.append(SDL_JoystickName(i))
             self.connect(self.joystick_timer, SIGNAL("timeout()"), self.process_events)
         else:
             log.info("couldn't initialize SDL joystick support")
Exemplo n.º 15
0
 def cheat_enabled(self, cheat_name, enabled=True):
     """Enables or disables a specified Cheat Function"""
     rval = self.m64p.CoreCheatEnabled(
         C.c_char_p(cheat_name.encode()), C.c_int(enabled))
     if rval != M64ERR_SUCCESS:
         log.debug("cheat_enabled()")
         log.info("CoreCheatEnabled() failed for cheat code '%s'" % cheat_name)
         log.warn(self.error_message(rval))
     else:
         state = 'activated' if enabled else 'deactivated'
         log.info("cheat code '%s' %s" % (cheat_name, state))
     return rval
Exemplo n.º 16
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")
Exemplo n.º 17
0
 def cheat_enabled(self, cheat_name, enabled=True):
     """Enables or disables a specified Cheat Function"""
     rval = self.m64p.CoreCheatEnabled(
         C.c_char_p(cheat_name.encode()), C.c_int(enabled))
     if rval != M64ERR_SUCCESS:
         log.debug("cheat_enabled()")
         log.info("CoreCheatEnabled() failed for cheat code '%s'" % cheat_name)
         log.warn(self.error_message(rval))
     else:
         state = 'activated' if enabled else 'deactivated'
         log.info("cheat code '%s' %s" % (cheat_name, state))
     return rval
Exemplo n.º 18
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")
Exemplo n.º 19
0
 def add_cheat(self, cheat_name, cheat_code):
     """Adds a Cheat Function to a list of currently active cheats
     which are applied to the open ROM, and set its state to Enabled"""
     rval = self.m64p.CoreAddCheat(C.c_char_p(cheat_name.encode()),
                                   C.pointer(cheat_code),
                                   C.c_int(C.sizeof(cheat_code)))
     if rval != M64ERR_SUCCESS:
         log.debug("add_cheat()")
         log.info("CoreAddCheat() failed for cheat code '%s'" % cheat_name)
         log.warn(self.error_message(rval))
     else:
         log.info("cheat code '%s' activated" % cheat_name)
     return rval
Exemplo n.º 20
0
 def add_cheat(self, cheat_name, cheat_code):
     """Adds a Cheat Function to a list of currently active cheats
     which are applied to the open ROM, and set its state to Enabled"""
     rval = self.m64p.CoreAddCheat(
         C.c_char_p(cheat_name.encode()), C.pointer(cheat_code),
         C.c_int(C.sizeof(cheat_code)))
     if rval != M64ERR_SUCCESS:
         log.debug("add_cheat()")
         log.info("CoreAddCheat() failed for cheat code '%s'" % cheat_name)
         log.warn(self.error_message(rval))
     else:
         log.info("cheat code '%s' activated" % cheat_name)
     return rval
Exemplo n.º 21
0
 def __init__(self, parent):
     """Constructor."""
     QDialog.__init__(self, parent)
     self.setupUi(self)
     self.parent = parent
     self.cheats = self.read_file()
     if not self.cheats:
         log.info("no cheat codes found for ROM image %s" %
                  (self.parent.worker.core.rom_header.Name))
         return
     group = self.group_cheats(self.cheats)
     self.build_tree(group)
     self.parent.actionCheats.setEnabled(False)
Exemplo n.º 22
0
 def __init__(self, parent):
     """Constructor."""
     QDialog.__init__(self, parent)
     self.setupUi(self)
     self.parent = parent
     self.cheats = self.read_file()
     if not self.cheats:
         log.info("no cheat codes found for ROM image %s" % (
             self.parent.worker.core.rom_header.Name))
         return
     group = self.group_cheats(self.cheats)
     self.build_tree(group)
     self.parent.actionCheats.setEnabled(False)
Exemplo n.º 23
0
 def save_image(self, title=True):
     """Saves snapshot or title image."""
     data_path = self.core.config.get_path("UserData")
     capture = "title" if title else "snapshot"
     dst_path = os.path.join(data_path, capture)
     if not os.path.isdir(dst_path):
         os.makedirs(dst_path)
     screenshot = self.get_screenshot(os.path.join(data_path, "screenshot"))
     if screenshot:
         image_name = "%X%X.png" % (sl(
             self.core.rom_header.CRC1), sl(self.core.rom_header.CRC2))
         try:
             shutil.copyfile(screenshot, os.path.join(dst_path, image_name))
             log.info("Captured %s" % capture)
         except IOError:
             log.exception("couldn't save image %s" % image_name)
Exemplo n.º 24
0
 def save_image(self, title=True):
     """Saves snapshot or title image."""
     data_path = self.core.config.get_path("UserData")
     capture = "title" if title else "snapshot"
     dst_path = os.path.join(data_path, capture)
     if not os.path.isdir(dst_path):
         os.makedirs(dst_path)
     screenshot = self.get_screenshot(
         os.path.join(data_path, "screenshot"))
     if screenshot:
         image_name = "%X%X.png" % (
             sl(self.core.rom_header.CRC1), sl(self.core.rom_header.CRC2))
         try:
             shutil.copyfile(screenshot, os.path.join(dst_path, image_name))
             log.info("Captured %s" % capture)
         except IOError:
             log.exception("couldn't save image %s" % image_name)
Exemplo n.º 25
0
    def check_version(self):
        """Checks core API version."""
        version = self.plugin_get_version(self.m64p, self.core_path)
        if version:
            plugin_type, plugin_version, plugin_api, plugin_name, plugin_cap = version
            if plugin_type != M64PLUGIN_CORE:
                raise Exception("library '%s' is invalid, "
                                "this is not the emulator core." %
                                (os.path.basename(self.core_path)))
            elif plugin_version < MINIMUM_CORE_VERSION:
                raise Exception(
                    "library '%s' is incompatible, "
                    "core version %s is below minimum supported %s." %
                    (os.path.basename(
                        self.core_path), version_split(plugin_version),
                     version_split(MINIMUM_CORE_VERSION)))
            elif plugin_api & 0xffff0000 != CORE_API_VERSION & 0xffff0000:
                raise Exception(
                    "library '%s' is incompatible, "
                    "core API major version %s doesn't match application (%s)."
                    % (os.path.basename(
                        self.core_path), version_split(plugin_version),
                       version_split(CORE_API_VERSION)))
            else:
                config_ver, debug_ver, vidext_ver = self.get_api_versions()
                if config_ver & 0xffff0000 != CONFIG_API_VERSION & 0xffff0000:
                    raise Exception(
                        "emulator core '%s' is incompatible, "
                        "config API major version %s doesn't match application: (%s)"
                        % (os.path.basename(
                            self.core_path), version_split(config_ver),
                           version_split(CONFIG_API_VERSION)))

                self.core_name = plugin_name
                self.core_version = plugin_version

                if LDD_CMD:
                    proc = subprocess.Popen(
                        LDD_CMD % self.core_path,
                        shell=True,
                        preexec_fn=lambda: signal.signal(
                            signal.SIGPIPE, signal.SIG_DFL))
                    proc.communicate()
                    if proc.returncode == 0:
                        self.core_sdl2 = True

                log.info("attached to library '%s' version %s" %
                         (self.core_name, version_split(self.core_version)))
                if plugin_cap & M64CAPS_DYNAREC:
                    log.info("includes support for Dynamic Recompiler.")
                if plugin_cap & M64CAPS_DEBUGGER:
                    log.info("includes support for MIPS r4300 Debugger.")
                if plugin_cap & M64CAPS_CORE_COMPARE:
                    log.info("includes support for r4300 Core Comparison.")
Exemplo n.º 26
0
    def check_version(self):
        """Checks core API version."""
        version = self.plugin_get_version(self.m64p, self.core_path)
        if version:
            plugin_type, plugin_version, plugin_api, plugin_name, plugin_cap = version
            if plugin_type != M64PLUGIN_CORE:
                raise Exception(
                    "library '%s' is invalid, "
                    "this is not the emulator core." % (
                        os.path.basename(self.core_path)))
            elif plugin_version < MINIMUM_CORE_VERSION:
                raise Exception(
                    "library '%s' is incompatible, "
                    "core version %s is below minimum supported %s." % (
                        os.path.basename(self.core_path),
                        version_split(plugin_version),
                        version_split(MINIMUM_CORE_VERSION)))
            elif plugin_api & 0xffff0000 != CORE_API_VERSION & 0xffff0000:
                raise Exception(
                    "library '%s' is incompatible, "
                    "core API major version %s doesn't match application (%s)." % (
                        os.path.basename(self.core_path),
                        version_split(plugin_version),
                        version_split(CORE_API_VERSION)))
            else:
                config_ver, debug_ver, vidext_ver = self.get_api_versions()
                if config_ver & 0xffff0000 != CONFIG_API_VERSION & 0xffff0000:
                    raise Exception(
                        "emulator core '%s' is incompatible, "
                        "config API major version %s doesn't match application: (%s)" % (
                        os.path.basename(self.core_path),
                        version_split(config_ver),
                        version_split(CONFIG_API_VERSION)))

                self.core_name = plugin_name
                self.core_version = plugin_version

                if LDD_CMD:
                    proc = subprocess.Popen(
                        LDD_CMD % self.core_path, shell=True,
                        preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL))
                    proc.communicate()
                    if proc.returncode == 0:
                        self.core_sdl2 = True

                log.info("attached to library '%s' version %s" %
                        (self.core_name, version_split(self.core_version)))
                if plugin_cap & M64CAPS_DYNAREC:
                    log.info("includes support for Dynamic Recompiler.")
                if plugin_cap & M64CAPS_DEBUGGER:
                    log.info("includes support for MIPS r4300 Debugger.")
                if plugin_cap & M64CAPS_CORE_COMPARE:
                    log.info("includes support for r4300 Core Comparison.")
Exemplo n.º 27
0
 def enable(self):
     self.sys_param_info(self.SPI_SETSCREENSAVEACTIVE, True, None, 0)
     log.info("ScreenSaver enabled")
Exemplo n.º 28
0
 def disable(self):
     self.sys_param_info(self.SPI_SETSCREENSAVEACTIVE, False, None, 0)
     log.info("ScreenSaver disabled")
Exemplo n.º 29
0
 def __init__(self):
     try:
         self.sys_param_info = ctypes.windll.user32.SystemParametersInfoA
     except Exception as err:
         log.info("ScreenSaver not available: %s" % str(err))
Exemplo n.º 30
0
 def enable(self):
     subprocess.call(
         "defaults -currentHost write com.apple.screensaver idleTime %s" %
         self.idle_time,
         shell=True)
     log.info("ScreenSaver enabled")
Exemplo n.º 31
0
 def disable(self):
     subprocess.call(
         "defaults -currentHost write com.apple.screensaver idleTime 0",
         shell=True)
     log.info("ScreenSaver disabled")
Exemplo n.º 32
0
 def disable(self):
     subprocess.call(
         "defaults -currentHost write com.apple.screensaver idleTime 0",
         shell=True)
     log.info("ScreenSaver disabled")
Exemplo n.º 33
0
 def enable(self):
     subprocess.call(
         "defaults -currentHost write com.apple.screensaver idleTime %s" % self.idle_time,
         shell=True)
     log.info("ScreenSaver enabled")
Exemplo n.º 34
0
 def __init__(self):
     try:
         self.sys_param_info = ctypes.windll.user32.SystemParametersInfoA
     except Exception, err:
         log.info("ScreenSaver not available: %s" % str(err))
Exemplo n.º 35
0
 def disable(self):
     self.sys_param_info(self.SPI_SETSCREENSAVEACTIVE, False, None, 0)
     log.info("ScreenSaver disabled")
Exemplo n.º 36
0
 def enable(self):
     self.sys_param_info(self.SPI_SETSCREENSAVEACTIVE, True, None, 0)
     log.info("ScreenSaver enabled")