Ejemplo n.º 1
0
def GetDisplayModes():
    res = []
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    devMode = DEVMODE()
    devMode.dmSize = sizeof(DEVMODE)
    iDevNum = 0
    while True:
        if EnumDisplayDevices(None, iDevNum, pointer(displayDevice), 0) == 0:
            break
        iDevNum += 1
        if displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER:
            continue
        EnumDisplaySettingsEx(
            displayDevice.DeviceName,
            ENUM_CURRENT_SETTINGS,
            pointer(devMode),
            0
        )
        displayMode = (
            displayDevice.DeviceName,
            devMode.dmPosition.x,
            devMode.dmPosition.y,
            devMode.dmPelsWidth,
            devMode.dmPelsHeight,
            devMode.dmDisplayFrequency,
            devMode.dmBitsPerPel,
            bool(
                displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
            ),
            bool(displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE),
            devMode.dmDisplayFlags,
        )
        res.append(displayMode)
    return tuple(res)
Ejemplo n.º 2
0
def GetDisplayModes():
    res = []
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    devMode = DEVMODE()
    devMode.dmSize = sizeof(DEVMODE)
    iDevNum = 0
    while True:
        if EnumDisplayDevices(None, iDevNum, pointer(displayDevice), 0) == 0:
            break
        iDevNum += 1
        if displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER:
            continue
        EnumDisplaySettingsEx(
            displayDevice.DeviceName,
            ENUM_CURRENT_SETTINGS,
            pointer(devMode),
            0
        )
        displayMode = (
            displayDevice.DeviceName,
            devMode.dmPosition.x,
            devMode.dmPosition.y,
            devMode.dmPelsWidth,
            devMode.dmPelsHeight,
            devMode.dmDisplayFrequency,
            devMode.dmBitsPerPel,
            bool(
                displayDevice.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
            ),
            bool(displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE),
            devMode.dmDisplayFlags,
        )
        res.append(displayMode)
    return tuple(res)
Ejemplo n.º 3
0
    def __init__(self, plugin):
        self.TriggerEvent = plugin.TriggerEvent
        eg.messageReceiver.AddHandler(WM_DEVICECHANGE, self.OnDeviceChange)

        # Disk device class
        self.handle1 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"
                )
            ),
            0
        )
        # HID device class
        self.handle2 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{4d1e55b2-f16f-11cf-88cb-001111000030}"
                )
            ),
            0
        )
        # USB device class
        self.handle3 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{a5dcbf10-6530-11d2-901f-00c04fb951ed}"
                )
            ),
            0
        )
        # Monitor device class
        self.handle4 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{E6F07B5F-EE97-4a90-B076-33F57BF4EAA7}"
                )
            ),
            0
        )
Ejemplo n.º 4
0
    def __init__(self, plugin):
        self.TriggerEvent = plugin.TriggerEvent
        eg.messageReceiver.AddHandler(WM_DEVICECHANGE, self.OnDeviceChange)

        # Disk device class
        self.handle1 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{53f56307-b6bf-11d0-94f2-00a0c91efb8b}"
                )
            ),
            0
        )
        # HID device class
        self.handle2 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{4d1e55b2-f16f-11cf-88cb-001111000030}"
                )
            ),
            0
        )
        # USB device class
        self.handle3 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{a5dcbf10-6530-11d2-901f-00c04fb951ed}"
                )
            ),
            0
        )
        # Monitor device class
        self.handle4 = RegisterDeviceNotification(
            eg.messageReceiver.hwnd,
            pointer(
                DEV_BROADCAST_DEVICEINTERFACE(
                    dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE,
                    dbcc_classguid = "{E6F07B5F-EE97-4a90-B076-33F57BF4EAA7}"
                )
            ),
            0
        )
Ejemplo n.º 5
0
 def __init__(self, iDevNum, displayDevice):
     self.iDevNum = iDevNum
     self.deviceName = displayDevice.DeviceName
     self.deviceString = displayDevice.DeviceString
     self.isPrimary = bool(
         displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE
     )
     self.devMode = DEVMODE()
     self.devMode.dmSize = sizeof(DEVMODE)
     self.dmp = pointer(self.devMode)
Ejemplo n.º 6
0
 def __init__(self, iDevNum, displayDevice):
     self.iDevNum = iDevNum
     self.deviceName = displayDevice.DeviceName
     self.deviceString = displayDevice.DeviceString
     self.isPrimary = bool(
         displayDevice.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE
     )
     self.devMode = DEVMODE()
     self.devMode.dmSize = sizeof(DEVMODE)
     self.dmp = pointer(self.devMode)
Ejemplo n.º 7
0
 def SetDisplayMode(self, size, frequency, bitdepth, flags=0):
     devMode = DEVMODE()
     devMode.dmSize = sizeof(DEVMODE)
     devMode.dmPelsWidth = size[0]
     devMode.dmPelsHeight = size[1]
     devMode.dmBitsPerPel = bitdepth
     devMode.dmDisplayFrequency = frequency
     devMode.dmFields = (
         DM_BITSPERPEL
         |DM_PELSWIDTH
         |DM_PELSHEIGHT
         |DM_DISPLAYFREQUENCY
     )
     ChangeDisplaySettingsEx(self.deviceName, pointer(devMode), 0, flags, 0)
Ejemplo n.º 8
0
 def SetDisplayMode(self, size, frequency, bitdepth, flags=0):
     devMode = DEVMODE()
     devMode.dmSize = sizeof(DEVMODE)
     devMode.dmPelsWidth = size[0]
     devMode.dmPelsHeight = size[1]
     devMode.dmBitsPerPel = bitdepth
     devMode.dmDisplayFrequency = frequency
     devMode.dmFields = (
         DM_BITSPERPEL
         |DM_PELSWIDTH
         |DM_PELSHEIGHT
         |DM_DISPLAYFREQUENCY
     )
     ChangeDisplaySettingsEx(self.deviceName, pointer(devMode), 0, flags, 0)
Ejemplo n.º 9
0
    def GetControl(self, mixer, controlId):
        mixerControl = MIXERCONTROL()
        mixerControl.cbStruct = sizeof(MIXERCONTROL)
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)

        mixerLineControls.dwControlID = controlId
        mixerLineControls.cControls = 1
        mixerLineControls.cbmxctrl = sizeof(mixerControl)
        mixerLineControls.pamxctrl = pointer(mixerControl)

        rc = mixerGetLineControls(mixer, byref(mixerLineControls), 1) #MIXER_GETLINECONTROLSF_ONEBYID
        if MMSYSERR_NOERROR != rc:
            raise SoundMixerException()
        return mixerControl
Ejemplo n.º 10
0
def GetDisplays():
    res = []
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    iDevNum = 0
    while True:
        if EnumDisplayDevices(None, iDevNum, pointer(displayDevice), 0) == 0:
            break
        #DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 1
        if not (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER):
            disp = Display(iDevNum, displayDevice)
            res.append(disp)
            displayDevice = DISPLAY_DEVICE()
            displayDevice.cb = sizeof(DISPLAY_DEVICE)
        iDevNum += 1
    return res
Ejemplo n.º 11
0
def GetDisplays():
    res = []
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    iDevNum = 0
    while True:
        if EnumDisplayDevices(None, iDevNum, pointer(displayDevice), 0) == 0:
            break
        #DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 1
        if not (displayDevice.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER):
            disp = Display(iDevNum, displayDevice)
            res.append(disp)
            displayDevice = DISPLAY_DEVICE()
            displayDevice.cb = sizeof(DISPLAY_DEVICE)
        iDevNum += 1
    return res
Ejemplo n.º 12
0
def GetMixerControl(componentType, ctrlType, deviceId=0):
    '''
    Obtains an appropriate pointer and info for the volume control
    This function attempts to obtain a mixer control. Raises
    SoundMixerException if not successful.
    '''
    hmixer = HMIXER()

    # Obtain the hmixer struct
    rc = mixerOpen(byref(hmixer), deviceId, 0, 0, 0)
    if rc != MMSYSERR_NOERROR:
        raise SoundMixerException()

    mixerLineControls = MIXERLINECONTROLS()
    mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
    mixerLine = MIXERLINE()
    mixerLine.cbStruct = sizeof(MIXERLINE)
    mixerControl = MIXERCONTROL()
    mixerControl.cbStruct = sizeof(MIXERCONTROL)

    mixerLine.dwComponentType = componentType

    # Obtain a line corresponding to the component type
    rc = mixerGetLineInfo(
        hmixer,
        byref(mixerLine),
        MIXER_GETLINEINFOF_COMPONENTTYPE
    )
    if rc != MMSYSERR_NOERROR:
        raise SoundMixerException()

    mixerLineControls.dwLineID = mixerLine.dwLineID
    mixerLineControls.dwControlType = ctrlType
    mixerLineControls.cControls = 1
    mixerLineControls.cbmxctrl = sizeof(mixerControl)
    mixerLineControls.pamxctrl = pointer(mixerControl)

    # Get the control
    rc = mixerGetLineControls(
        hmixer,
        byref(mixerLineControls),
        MIXER_GETLINECONTROLSF_ONEBYTYPE
    )
    if MMSYSERR_NOERROR != rc:
        raise SoundMixerException()
    return hmixer, mixerControl
Ejemplo n.º 13
0
 def GetDisplayModes(self, allModes=False):
     devMode = DEVMODE()
     devMode.dmSize = sizeof(DEVMODE)
     lpDevMode = pointer(devMode)
     modes = {}
     if allModes:
         flag = EDS_RAWMODE
     else:
         flag = 0
     iModeNum = 0
     while 0 != EnumDisplaySettingsEx(self.deviceName, iModeNum, lpDevMode, flag):
         iModeNum += 1
         resolution = (devMode.dmPelsWidth, devMode.dmPelsHeight)
         deepthDict = modes.setdefault(resolution, {})
         frequencyList = deepthDict.setdefault(devMode.dmBitsPerPel, [])
         frequencyList.append(devMode.dmDisplayFrequency)
     return modes
Ejemplo n.º 14
0
 def GetDisplayModes(self, allModes=False):
     devMode = DEVMODE()
     devMode.dmSize = sizeof(DEVMODE)
     lpDevMode = pointer(devMode)
     modes = {}
     if allModes:
         flag = EDS_RAWMODE
     else:
         flag = 0
     iModeNum = 0
     while 0 != EnumDisplaySettingsEx(
         self.deviceName, iModeNum, lpDevMode, flag
     ):
         iModeNum += 1
         resolution = (devMode.dmPelsWidth, devMode.dmPelsHeight)
         deepthDict = modes.setdefault(resolution, {})
         frequencyList = deepthDict.setdefault(devMode.dmBitsPerPel, [])
         frequencyList.append(devMode.dmDisplayFrequency)
     return modes
Ejemplo n.º 15
0
 def GetAllPorts(cls):
     """
     Returns a list with all available serial ports.
     """
     serialPortList = cls._serialPortList
     if serialPortList is not None:
         return serialPortList
     serialPortList = []
     commconfig = COMMCONFIG()
     commconfig.dwSize = sizeof(COMMCONFIG)
     lpCC = pointer(commconfig)
     dwSize = DWORD(0)
     lpdwSize = byref(dwSize)
     for i in range(0, 255):
         name = 'COM%d' % (i+1)
         res = GetDefaultCommConfig(name, lpCC, lpdwSize)
         if res == 1 or (res == 0 and GetLastError() == 122):
             serialPortList.append(i)
     cls._serialPortList = serialPortList
     return serialPortList
Ejemplo n.º 16
0
 def GetAllPorts(cls):
     """
     Returns a list with all available serial ports.
     """
     serialPortList = cls._serialPortList
     if serialPortList is not None:
         return serialPortList
     serialPortList = []
     commconfig = COMMCONFIG()
     commconfig.dwSize = sizeof(COMMCONFIG)
     lpCC = pointer(commconfig)
     dwSize = DWORD(0)
     lpdwSize = byref(dwSize)
     for i in range(0, 255):
         name = 'COM%d' % (i + 1)
         res = GetDefaultCommConfig(name, lpCC, lpdwSize)
         if res == 1 or (res == 0 and GetLastError() == 122):
             serialPortList.append(i)
     cls._serialPortList = serialPortList
     return serialPortList
Ejemplo n.º 17
0
 def SendRawCodes1(self, keyData):
     """
     Uses the SendInput-API function to send the virtual keycode.
     Can only send to the frontmost window.
     """
     sendInputStruct = self.sendInputStruct
     sendInputStructPointer = pointer(sendInputStruct)
     sendInputStructSize = sizeof(sendInputStruct)
     keyboardStruct = sendInputStruct.ki
     for block in keyData:
         keyboardStruct.dwFlags = 0
         for virtualKey in block:
             keyboardStruct.wVk = virtualKey & 0xFF
             SendInput(1, sendInputStructPointer, sendInputStructSize)
             self.WaitForInputProcessed()
         keyboardStruct.dwFlags = KEYEVENTF_KEYUP
         for virtualKey in reversed(block):
             keyboardStruct.wVk = virtualKey & 0xFF
             SendInput(1, sendInputStructPointer, sendInputStructSize)
             self.WaitForInputProcessed()
Ejemplo n.º 18
0
 def SendRawCodes1(self, keyData):
     """
     Uses the SendInput-API function to send the virtual keycode.
     Can only send to the frontmost window.
     """
     sendInputStruct = self.sendInputStruct
     sendInputStructPointer = pointer(sendInputStruct)
     sendInputStructSize = sizeof(sendInputStruct)
     keyboardStruct = sendInputStruct.ki
     for block in keyData:
         keyboardStruct.dwFlags = 0
         for virtualKey in block:
             keyboardStruct.wVk = virtualKey & 0xFF
             SendInput(1, sendInputStructPointer, sendInputStructSize)
             self.WaitForInputProcessed()
         keyboardStruct.dwFlags = KEYEVENTF_KEYUP
         for virtualKey in reversed(block):
             keyboardStruct.wVk = virtualKey & 0xFF
             SendInput(1, sendInputStructPointer, sendInputStructSize)
             self.WaitForInputProcessed()
Ejemplo n.º 19
0
    def GetControls(self, hmixer, mixerline):
        numCtrls = mixerline.cControls
        if numCtrls == 0:
            return []

        mixerControlArray = (MIXERCONTROL * numCtrls)()
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
        mixerLineControls.cControls = numCtrls
        mixerLineControls.dwLineID = mixerline.dwLineID
        mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
        mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
        mixerGetLineControls(hmixer, byref(mixerLineControls), MIXER_GETLINECONTROLSF_ALL)
        result = []

        for i in range(numCtrls):
            mixerControl = mixerControlArray[i]
            dwControlType = mixerControl.dwControlType
            controlClass = MIXER_CONTROL_CLASSES[dwControlType & MIXERCONTROL_CT_CLASS_MASK]
            controlClassTypeName = controlClass["types"][dwControlType]
            flagNames = []
            fdwControl =  mixerControl.fdwControl
            if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
                flagNames.append("Disabled")
            if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
                flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
            if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
                flagNames.append("Uniform")
            result.append(
                (
                    mixerControl.dwControlID,
                    mixerControl.szName, 
                    controlClass["name"], 
                    controlClassTypeName,
                    ", ".join(flagNames)
                )
            )

        return result
Ejemplo n.º 20
0
 def AddControls(self, parentItem, mixerline):
     numCtrls = mixerline.cControls
     if numCtrls == 0:
         return []
     mixerControlArray = (MIXERCONTROL * numCtrls)()
     mixerLineControls = MIXERLINECONTROLS()
     mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
     mixerLineControls.cControls = numCtrls
     mixerLineControls.dwLineID = mixerline.dwLineID
     mixerLineControls.pamxctrl = pointer(mixerControlArray[0])
     mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
     mixerGetLineControls(
         self.mixerHandle,
         byref(mixerLineControls),
         MIXER_GETLINECONTROLSF_ALL
     )
     for i in range(numCtrls):
         mixerControl = mixerControlArray[i]
         ctrlItem = self.AppendItem(
             parentItem,
             mixerControl.szName
         )
         self.SetPyData(ctrlItem, mixerControl.dwControlID)
Ejemplo n.º 21
0
def SetDisplayModes(*args):
    for (
        deviceName,
        x,
        y,
        width,
        height,
        freq,
        bitdepth,
        isAttached,
        isPrimary,
        displayFlags
    ) in args:
        devMode = DEVMODE()
        devMode.dmSize = sizeof(DEVMODE)
        if isAttached:
            devMode.dmPosition.x = x
            devMode.dmPosition.y = y
            devMode.dmPelsWidth = width
            devMode.dmPelsHeight = height
            devMode.dmBitsPerPel = bitdepth
            devMode.dmDisplayFrequency = freq
            devMode.dmDisplayFlags = displayFlags
        devMode.dmFields = (
            DM_POSITION
            |DM_BITSPERPEL
            |DM_PELSWIDTH
            |DM_PELSHEIGHT
            |DM_DISPLAYFLAGS
            |DM_DISPLAYFREQUENCY
        )
        flags = (CDS_UPDATEREGISTRY | CDS_NORESET)
        if isPrimary:
            flags |= CDS_SET_PRIMARY
        ChangeDisplaySettingsEx(deviceName, pointer(devMode), 0, flags, 0)
    ChangeDisplaySettingsEx(None, None, 0, 0, 0)
Ejemplo n.º 22
0
def SetDisplayModes(*args):
    for (
        deviceName,
        x,
        y,
        width,
        height,
        freq,
        bitdepth,
        isAttached,
        isPrimary,
        displayFlags
    ) in args:
        devMode = DEVMODE()
        devMode.dmSize = sizeof(DEVMODE)
        if isAttached:
            devMode.dmPosition.x = x
            devMode.dmPosition.y = y
            devMode.dmPelsWidth = width
            devMode.dmPelsHeight = height
            devMode.dmBitsPerPel = bitdepth
            devMode.dmDisplayFrequency = freq
            devMode.dmDisplayFlags = displayFlags
        devMode.dmFields = (
            DM_POSITION
            |DM_BITSPERPEL
            |DM_PELSWIDTH
            |DM_PELSHEIGHT
            |DM_DISPLAYFLAGS
            |DM_DISPLAYFREQUENCY
        )
        flags = (CDS_UPDATEREGISTRY | CDS_NORESET)
        if isPrimary:
            flags |= CDS_SET_PRIMARY
        ChangeDisplaySettingsEx(deviceName, pointer(devMode), 0, flags, 0)
    ChangeDisplaySettingsEx(None, None, 0, 0, 0)
Ejemplo n.º 23
0
    def OnSelectionChanged(self, event):
        dwControlID = self.GetPyData(event.GetItem())
        panel = self.panel
        panel.DestroyChildren()
        sizer = wx.BoxSizer(wx.VERTICAL)

        idCtrl = wx.StaticText(panel, -1, "ID: " + str(dwControlID))
        sizer.Add(idCtrl)
        if dwControlID is None:
            panel.SetSizerAndFit(sizer)
            return

        mixerControl = MIXERCONTROL()
        mixerLineControls = MIXERLINECONTROLS()
        mixerLineControls.cbStruct = sizeof(MIXERLINECONTROLS)
        mixerLineControls.cControls = 1
        mixerLineControls.dwControlID = dwControlID
        mixerLineControls.pamxctrl = pointer(mixerControl)
        mixerLineControls.cbmxctrl = sizeof(MIXERCONTROL)
        err = mixerGetLineControls(
            self.mixerHandle,
            byref(mixerLineControls),
            MIXER_GETLINECONTROLSF_ONEBYID
        )
        if err:
            print "error", err
            return

        idCtrl = wx.StaticText(panel, -1, "Name: " + mixerControl.szName)
        sizer.Add(idCtrl)

        idCtrl = wx.StaticText(panel, -1, "Short Name: " + mixerControl.szShortName)
        sizer.Add(idCtrl)

        dwControlType = mixerControl.dwControlType

        controlClass = MIXER_CONTROL_CLASSES[dwControlType & MIXERCONTROL_CT_CLASS_MASK]
        idCtrl = wx.StaticText(panel, -1, "Classification: " + controlClass["name"])
        sizer.Add(idCtrl)

        controlClassTypeName = controlClass["types"][dwControlType]
        idCtrl = wx.StaticText(panel, -1, "Type: " + controlClassTypeName)
        sizer.Add(idCtrl)

        fdwControl =  mixerControl.fdwControl
        cMultipleItems = 0
        numMultipleItems = 1
        flagNames = []
        if fdwControl & MIXERCONTROL_CONTROLF_DISABLED:
            flagNames.append("Disabled")
        if fdwControl & MIXERCONTROL_CONTROLF_MULTIPLE:
            flagNames.append("Multiple(%i)" % mixerControl.cMultipleItems)
            numMultipleItems = mixerControl.cMultipleItems
            cMultipleItems = mixerControl.cMultipleItems
        if fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            flagNames.append("Uniform")
        idCtrl = wx.StaticText(panel, -1, "Flags: " + ", ".join(flagNames))
        sizer.Add(idCtrl)

        valueType = CONTROLTYPES[dwControlType][1]
        valueTypeName = MIXERCONTROLDETAILS_NAMES[valueType]
        idCtrl = wx.StaticText(panel, -1, "Value Type: " + valueTypeName)
        sizer.Add(idCtrl)

        if dwControlType == MIXERCONTROL_CONTROLTYPE_CUSTOM:
            cChannels = 0
        elif fdwControl & MIXERCONTROL_CONTROLF_UNIFORM:
            cChannels = 1
        else:
            # TODO: Get the number of channels
            cChannels = 2
        details = (valueType * (cChannels * numMultipleItems))()
        mixerControlDetails = MIXERCONTROLDETAILS()
        mixerControlDetails.cbStruct = sizeof(MIXERCONTROLDETAILS)
        mixerControlDetails.dwControlID = dwControlID
        mixerControlDetails.cChannels = cChannels
        mixerControlDetails.cMultipleItems = cMultipleItems
        mixerControlDetails.cbDetails = sizeof(details)
        mixerControlDetails.paDetails = cast(pointer(details), c_void_p)
        pmxcd = valueType()
        mixerGetControlDetails(
            self.mixerHandle,
            byref(mixerControlDetails),
            MIXER_GETCONTROLDETAILSF_VALUE
        )
        values = []
        for i in range(cChannels * numMultipleItems):
            if valueType == MIXERCONTROLDETAILS_BOOLEAN:
                values.append(details[i].fValue)
            elif valueType == MIXERCONTROLDETAILS_SIGNED:
                values.append(details[i].lValue)
            elif valueType == MIXERCONTROLDETAILS_UNSIGNED:
                values.append(details[i].dwValue)

        idCtrl = wx.StaticText(panel, -1, "Value: %r" % values)
        sizer.Add(idCtrl)

        if dwControlType & MIXERCONTROL_CT_CLASS_MASK == MIXERCONTROL_CT_CLASS_LIST:
            labels = (MIXERCONTROLDETAILS_LISTTEXT * (cChannels * numMultipleItems))()
            mixerControlDetails.cbDetails = sizeof(MIXERCONTROLDETAILS_LISTTEXT)
            mixerControlDetails.paDetails = cast(pointer(labels), c_void_p)
            mixerGetControlDetails(
                self.mixerHandle,
                byref(mixerControlDetails),
                MIXER_GETCONTROLDETAILSF_LISTTEXT
            )
            for i in range(cChannels * numMultipleItems):
                print labels[i].szName
        panel.SetSizerAndFit(sizer)
Ejemplo n.º 24
0
def GetDisplay(displayNum):
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    if EnumDisplayDevices(None, displayNum, pointer(displayDevice), 0) == 0:
        return None
    return Display(displayNum, displayDevice)
Ejemplo n.º 25
0
def GetDisplay(displayNum):
    displayDevice = DISPLAY_DEVICE()
    displayDevice.cb = sizeof(DISPLAY_DEVICE)
    if EnumDisplayDevices(None, displayNum, pointer(displayDevice), 0) == 0:
        return None
    return Display(displayNum, displayDevice)