internal/glfw: skip some Win32APIs for Xbox

Updates #1162
This commit is contained in:
Hajime Hoshi 2022-05-29 15:53:43 +09:00
parent 05d49c5a52
commit 2efbb819e0
2 changed files with 19 additions and 3 deletions

View File

@ -271,9 +271,8 @@ func platformInit() error {
RefreshRate: 0, // TODO: Is it possible to get an appropriate refresh rate?
}
m := &Monitor{
name: "Xbox Monitor",
modes: []*VidMode{mode},
currentMode: mode,
name: "Xbox Monitor",
modes: []*VidMode{mode},
}
if err := inputMonitor(m, Connected, _GLFW_INSERT_LAST); err != nil {
return err

View File

@ -234,6 +234,10 @@ func getMonitorContentScaleWin32(handle _HMONITOR) (xscale, yscale float32, err
}
func (m *Monitor) platformGetMonitorPos() (xpos, ypos int, ok bool) {
if isXbox() {
return 0, 0, true
}
dm, ok := _EnumDisplaySettingsExW(m.win32.adapterName, _ENUM_CURRENT_SETTINGS, _EDS_ROTATEDMODE)
if !ok {
return 0, 0, false
@ -242,10 +246,19 @@ func (m *Monitor) platformGetMonitorPos() (xpos, ypos int, ok bool) {
}
func (m *Monitor) platformGetMonitorContentScale() (xscale, yscale float32, err error) {
if isXbox() {
return 1, 1, nil
}
return getMonitorContentScaleWin32(m.win32.handle)
}
func (m *Monitor) platformGetMonitorWorkarea() (xpos, ypos, width, height int) {
if isXbox() {
w, h := monitorResolution()
return 0, 0, w, h
}
mi, ok := _GetMonitorInfoW(m.win32.handle)
if !ok {
return 0, 0, 0, 0
@ -307,6 +320,10 @@ loop:
}
func (m *Monitor) platformGetVideoMode() *VidMode {
if isXbox() {
return m.modes[0]
}
dm, _ := _EnumDisplaySettingsW(m.win32.adapterName, _ENUM_CURRENT_SETTINGS)
r, g, b := splitBPP(int(dm.dmBitsPerPel))
return &VidMode{