internal/glfwwin: skip detecting monitors for Xbox

Updates #2084
This commit is contained in:
Hajime Hoshi 2022-05-27 15:55:21 +09:00
parent cbe42ddddc
commit f7172f41c8
3 changed files with 29 additions and 15 deletions

View File

@ -1181,6 +1181,10 @@ func _EnumDisplayDevicesW(device string, iDevNum uint32, dwFlags uint32) (_DISPL
return displayDevice, true
}
func _EnumDisplayDevicesW_Available() bool {
return procEnumDisplayDevicesW.Find() == nil
}
func _EnumDisplayMonitors(hdc _HDC, lprcClip *_RECT, lpfnEnum uintptr, dwData _LPARAM) error {
r, _, e := procEnumDisplayMonitors.Call(uintptr(hdc), uintptr(unsafe.Pointer(lprcClip)), uintptr(lpfnEnum), uintptr(dwData))
if int32(r) == 0 {
@ -1533,6 +1537,10 @@ func _RegisterDeviceNotificationW(hRecipient windows.Handle, notificationFilter
return _HDEVNOTIFY(r), nil
}
func _RegisterDeviceNotificationW_Available() bool {
return procRegisterDeviceNotificationW.Find() == nil
}
func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
r, _, e := procRegisterRawInputDevices.Call(uintptr(unsafe.Pointer(&pRawInputDevices[0])), uintptr(len(pRawInputDevices)), unsafe.Sizeof(pRawInputDevices[0]))
if int32(r) == 0 {

View File

@ -185,23 +185,25 @@ func createHelperWindow() error {
// process passed along a STARTUPINFO, so clear that with a no-op call
_ShowWindow(_glfw.win32.helperWindowHandle, _SW_HIDE)
_GUID_DEVINTERFACE_HID := windows.GUID{
Data1: 0x4d1e55b2,
Data2: 0xf16f,
Data3: 0x11cf,
Data4: [...]byte{0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30},
}
// Register for HID device notifications
var dbi _DEV_BROADCAST_DEVICEINTERFACE_W
dbi.dbcc_size = uint32(unsafe.Sizeof(dbi))
dbi.dbcc_devicetype = _DBT_DEVTYP_DEVICEINTERFACE
dbi.dbcc_classguid = _GUID_DEVINTERFACE_HID
notify, err := _RegisterDeviceNotificationW(windows.Handle(_glfw.win32.helperWindowHandle), unsafe.Pointer(&dbi), _DEVICE_NOTIFY_WINDOW_HANDLE)
if err != nil {
return err
if _RegisterDeviceNotificationW_Available() {
_GUID_DEVINTERFACE_HID := windows.GUID{
Data1: 0x4d1e55b2,
Data2: 0xf16f,
Data3: 0x11cf,
Data4: [...]byte{0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30},
}
var dbi _DEV_BROADCAST_DEVICEINTERFACE_W
dbi.dbcc_size = uint32(unsafe.Sizeof(dbi))
dbi.dbcc_devicetype = _DBT_DEVTYP_DEVICEINTERFACE
dbi.dbcc_classguid = _GUID_DEVINTERFACE_HID
notify, err := _RegisterDeviceNotificationW(windows.Handle(_glfw.win32.helperWindowHandle), unsafe.Pointer(&dbi), _DEVICE_NOTIFY_WINDOW_HANDLE)
if err != nil {
return err
}
_glfw.win32.deviceNotificationHandle = notify
}
_glfw.win32.deviceNotificationHandle = notify
var msg _MSG
for _PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, _PM_REMOVE) {

View File

@ -102,6 +102,10 @@ func createMonitor(adapter *_DISPLAY_DEVICEW, display *_DISPLAY_DEVICEW) (*Monit
}
func pollMonitorsWin32() error {
if !_EnumDisplayDevicesW_Available() {
return nil
}
disconnected := make([]*Monitor, len(_glfw.monitors))
copy(disconnected, _glfw.monitors)