예제 #1
0
 def get_all_modes(self):
     modes = []
     if System.windows:
         k = 0
         while True:
             try:
                 settings = win32api.EnumDisplaySettingsEx(
                     None, k, EDS_RAWMODE)
             except win32api.error:
                 break
             refresh = float(settings.DisplayFrequency)
             width = int(settings.PelsWidth)
             height = int(settings.PelsHeight)
             bpp = int(settings.BitsPerPel)
             flags = int(settings.DisplayFlags)
             # print(width, height, refresh, bpp, flags)
             modes.append({
                 "width": width,
                 "height": height,
                 "refresh": refresh,
                 "bpp": bpp,
                 "flags": flags,
             })
             k += 1
     elif System.macos:
         # FIXME:
         pass
     else:
         modes = self._get_all_modes_x()
     # modes.extend(self.get_override_modes())
     return modes
 def get_all_modes(self):
     modes = []
     if windows:
         k = 0
         while True:
             try:
                 settings = win32api.EnumDisplaySettingsEx(
                     None, k, EDS_RAWMODE)
             except win32api.error:
                 break
             refresh = float(settings.DisplayFrequency)
             width = int(settings.PelsWidth)
             height = int(settings.PelsHeight)
             bpp = int(settings.BitsPerPel)
             flags = int(settings.DisplayFlags)
             # print(width, height, refresh, bpp, flags)
             modes.append({
                 'width': width,
                 'height': height,
                 'refresh': refresh,
                 'bpp': bpp,
                 'flags': flags
             })
             k += 1
     elif macosx:
         # FIXME:
         pass
     else:
         modes = self._get_all_modes_x()
     # modes.extend(self.get_override_modes())
     return modes
예제 #3
0
 def __init__(self, adapter: win32api.PyDISPLAY_DEVICEType,
              device: win32api.PyDISPLAY_DEVICEType = None,
              config: pywintypes.DEVMODEWType = None):
     self.adapter = adapter
     if device is not None:
         self.device = device
     else:
         self.device = win32api.EnumDisplayDevices(adapter.DeviceName, 0)  # Device is just for readability
     if config is not None:
         self.config = config
     else:
         self.config = win32api.EnumDisplaySettingsEx(adapter.DeviceName, win32con.ENUM_CURRENT_SETTINGS)
예제 #4
0
    def _set_mode_windows(self, mode):
        print("REFRESH RATE TOOL: setting mode", mode)
        if not win32api:
            print("win32api not available, returning")
            return False
        k = 0
        while True:
            try:
                settings = win32api.EnumDisplaySettingsEx(None, k, EDS_RAWMODE)
            except win32api.error:
                break
            refresh = float(settings.DisplayFrequency)
            width = int(settings.PelsWidth)
            height = int(settings.PelsHeight)
            bpp = int(settings.BitsPerPel)
            flags = int(settings.DisplayFlags)
            # print(width, height, refresh, bpp, flags)
            # modes.append({'width': width, 'height': height,
            #        'refresh': refresh, 'bpp': bpp, 'flags': flags})
            if (width == mode["width"] and height == mode["height"]
                    and refresh == mode["refresh"] and bpp == mode["bpp"]
                    and flags == mode["flags"]):

                # print("trying to override with refresh", int(round(self.game_refresh)))
                # #refresh == mode['refresh'] and \
                # settings.DisplayFrequency = int(round(self.game_refresh))
                # result = win32api.ChangeDisplaySettings(settings,
                #         win32con.CDS_UPDATEREGISTRY) #win32con.CDS_FULLSCREEN)
                #         #0) #win32con.CDS_FULLSCREEN)
                # if result == win32con.DISP_CHANGE_SUCCESSFUL:
                #     print("display change was successful")
                #     return True
                # print("failed, falling back to ", mode['refresh'])
                # settings.DisplayFrequency = mode['refresh']
                print("found windows mode, changing display settings")
                result = win32api.ChangeDisplaySettings(
                    settings, win32con.CDS_UPDATEREGISTRY)
                # win32con.CDS_FULLSCREEN)

                if result == win32con.DISP_CHANGE_SUCCESSFUL:
                    print("display change was successful")
                    return True
                else:
                    print("display change failed, result =", result)
                    return False
            k += 1

        # for omode in self.get_override_modes():
        #     print("trying override mode", omode)
        #     if omode['width'] == mode['width'] and \
        #             omode['height'] == mode['height'] and \
        #             omode['refresh'] == mode['refresh'] and \
        #             omode['bpp'] == mode['bpp'] and \
        #             omode['flags'] == mode['flags']:
        #         settings.PelsWidth = omode['width']
        #         settings.PelsHeight = omode['height']
        #         settings.BitsPerPel = omode['bpp']
        #         settings.DisplayFlags = omode['flags']
        #         settings.DisplayFrequency = omode['refresh']
        #         result = win32api.ChangeDisplaySettings(settings,
        #                 win32con.CDS_UPDATEREGISTRY) #win32con.CDS_FULLSCREEN)
        #                 #0) #win32con.CDS_FULLSCREEN)
        #         if result == win32con.DISP_CHANGE_SUCCESSFUL:
        #             print("display change was successful")
        #             return True
        #         else:
        #             print("display change failed, result =", result)
        #             return False
        return False
예제 #5
0
 def update_config(self):
     """
     This function call win32 api to get the current config
     """
     self.config = win32api.EnumDisplaySettingsEx(self.adapter.DeviceName, win32con.ENUM_CURRENT_SETTINGS)