mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
5c63c4a4aa
commit
ef7d10a36e
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2022 The Ebiten Authors
|
// Copyright 2022 The Ebitengine Authors
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
@ -1133,10 +1133,6 @@ func _EnumDisplayDevicesW(device string, iDevNum uint32, dwFlags uint32) (_DISPL
|
|||||||
return displayDevice, true
|
return displayDevice, true
|
||||||
}
|
}
|
||||||
|
|
||||||
func _EnumDisplayDevicesW_Available() bool {
|
|
||||||
return procEnumDisplayDevicesW.Find() == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _EnumDisplayMonitors(hdc _HDC, lprcClip *_RECT, lpfnEnum uintptr, dwData _LPARAM) error {
|
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))
|
r, _, e := procEnumDisplayMonitors.Call(uintptr(hdc), uintptr(unsafe.Pointer(lprcClip)), uintptr(lpfnEnum), uintptr(dwData))
|
||||||
if int32(r) == 0 {
|
if int32(r) == 0 {
|
||||||
@ -1395,19 +1391,11 @@ func _LoadImageW(hInst _HINSTANCE, name uintptr, typ uint32, cx int32, cy int32,
|
|||||||
return windows.Handle(r), nil
|
return windows.Handle(r), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _LoadImageW_Available() bool {
|
|
||||||
return procLoadImageW.Find() == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 {
|
func _MapVirtualKeyW(uCode uint32, uMapType uint32) uint32 {
|
||||||
r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType))
|
r, _, _ := procMapVirtualKeyW.Call(uintptr(uCode), uintptr(uMapType))
|
||||||
return uint32(r)
|
return uint32(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _MapVirtualKeyW_Available() bool {
|
|
||||||
return procMapVirtualKeyW.Find() == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _MonitorFromWindow(hwnd windows.HWND, dwFlags uint32) _HMONITOR {
|
func _MonitorFromWindow(hwnd windows.HWND, dwFlags uint32) _HMONITOR {
|
||||||
r, _, _ := procMonitorFromWindow.Call(uintptr(hwnd), uintptr(dwFlags))
|
r, _, _ := procMonitorFromWindow.Call(uintptr(hwnd), uintptr(dwFlags))
|
||||||
return _HMONITOR(r)
|
return _HMONITOR(r)
|
||||||
@ -1489,10 +1477,6 @@ func _RegisterDeviceNotificationW(hRecipient windows.Handle, notificationFilter
|
|||||||
return _HDEVNOTIFY(r), nil
|
return _HDEVNOTIFY(r), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _RegisterDeviceNotificationW_Available() bool {
|
|
||||||
return procRegisterDeviceNotificationW.Find() == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
|
func _RegisterRawInputDevices(pRawInputDevices []_RAWINPUTDEVICE) error {
|
||||||
r, _, e := procRegisterRawInputDevices.Call(uintptr(unsafe.Pointer(&pRawInputDevices[0])), uintptr(len(pRawInputDevices)), unsafe.Sizeof(pRawInputDevices[0]))
|
r, _, e := procRegisterRawInputDevices.Call(uintptr(unsafe.Pointer(&pRawInputDevices[0])), uintptr(len(pRawInputDevices)), unsafe.Sizeof(pRawInputDevices[0]))
|
||||||
if int32(r) == 0 {
|
if int32(r) == 0 {
|
||||||
@ -1629,10 +1613,6 @@ func _SetProcessDpiAwarenessContext(value _DPI_AWARENESS_CONTEXT) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func _SetProcessDpiAwarenessContext_Available() bool {
|
|
||||||
return procSetProcessDpiAwarenessContext.Find() == nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func _SetThreadExecutionState(esFlags _EXECUTION_STATE) _EXECUTION_STATE {
|
func _SetThreadExecutionState(esFlags _EXECUTION_STATE) _EXECUTION_STATE {
|
||||||
r, _, _ := procSetThreadExecutionState.Call(uintptr(esFlags))
|
r, _, _ := procSetThreadExecutionState.Call(uintptr(esFlags))
|
||||||
return _EXECUTION_STATE(r)
|
return _EXECUTION_STATE(r)
|
||||||
|
50
internal/glfwwin/microsoftgdk_windows.go
Normal file
50
internal/glfwwin/microsoftgdk_windows.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright 2022 The Ebitengine Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build microsoftgdk
|
||||||
|
// +build microsoftgdk
|
||||||
|
|
||||||
|
package glfwwin
|
||||||
|
|
||||||
|
// This file does not include the headers of Microsoft GDK in order to compile easier.
|
||||||
|
// In order to compile this, create a dummy DLL with empty implementations like below,
|
||||||
|
// and link it.
|
||||||
|
//
|
||||||
|
// #include <stdint.h>
|
||||||
|
// __declspec(dllexport) __cdecl uint32_t XSystemGetDeviceType(void) {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Unfortunately, some functions like XSystemGetDeviceType is not implemented in a DLL,
|
||||||
|
// so LoadLibrary is not available.
|
||||||
|
|
||||||
|
// typedef enum {
|
||||||
|
// Unknown = 0x00,
|
||||||
|
// Pc = 0x01,
|
||||||
|
// XboxOne = 0x02,
|
||||||
|
// XboxOneS = 0x03,
|
||||||
|
// XboxOneX = 0x04,
|
||||||
|
// XboxOneXDevkit = 0x05,
|
||||||
|
// XboxScarlettLockhart = 0x06,
|
||||||
|
// XboxScarlettAnaconda = 0x07,
|
||||||
|
// XboxScarlettDevkit = 0x08,
|
||||||
|
// } XSystemDeviceType;
|
||||||
|
//
|
||||||
|
// XSystemDeviceType XSystemGetDeviceType(void);
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
func isXbox() bool {
|
||||||
|
t := C.XSystemGetDeviceType()
|
||||||
|
return t != C.Unknown && t != C.Pc
|
||||||
|
}
|
22
internal/glfwwin/notmicrosoftgdk_windows.go
Normal file
22
internal/glfwwin/notmicrosoftgdk_windows.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2022 The Ebitengine Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !microsoftgdk
|
||||||
|
// +build !microsoftgdk
|
||||||
|
|
||||||
|
package glfwwin
|
||||||
|
|
||||||
|
func isXbox() bool {
|
||||||
|
return false
|
||||||
|
}
|
@ -168,7 +168,7 @@ func createHelperWindow() error {
|
|||||||
_ShowWindow(_glfw.win32.helperWindowHandle, _SW_HIDE)
|
_ShowWindow(_glfw.win32.helperWindowHandle, _SW_HIDE)
|
||||||
|
|
||||||
// Register for HID device notifications
|
// Register for HID device notifications
|
||||||
if _RegisterDeviceNotificationW_Available() {
|
if !isXbox() {
|
||||||
_GUID_DEVINTERFACE_HID := windows.GUID{
|
_GUID_DEVINTERFACE_HID := windows.GUID{
|
||||||
Data1: 0x4d1e55b2,
|
Data1: 0x4d1e55b2,
|
||||||
Data2: 0xf16f,
|
Data2: 0xf16f,
|
||||||
@ -238,7 +238,7 @@ func platformInit() error {
|
|||||||
createKeyTables()
|
createKeyTables()
|
||||||
|
|
||||||
if isWindows10CreatorsUpdateOrGreaterWin32() {
|
if isWindows10CreatorsUpdateOrGreaterWin32() {
|
||||||
if _SetProcessDpiAwarenessContext_Available() {
|
if !isXbox() {
|
||||||
if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
|
if err := _SetProcessDpiAwarenessContext(_DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); err != nil && !errors.Is(err, windows.ERROR_ACCESS_DENIED) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -258,8 +258,14 @@ func platformInit() error {
|
|||||||
if err := createHelperWindow(); err != nil {
|
if err := createHelperWindow(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := pollMonitorsWin32(); err != nil {
|
if isXbox() {
|
||||||
return err
|
// TODO: Create a dummy window.
|
||||||
|
// The resolution can be deterined based on a device.
|
||||||
|
// See https://github.com/microsoft/Xbox-GDK-Samples/blob/1f44bdabed6e340170e2c7d1007500e4dff897bb/Samples/IntroGraphics/SimpleDynamicResources/Main.cpp#L118-L148
|
||||||
|
} else {
|
||||||
|
if err := pollMonitorsWin32(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ func createMonitor(adapter *_DISPLAY_DEVICEW, display *_DISPLAY_DEVICEW) (*Monit
|
|||||||
}
|
}
|
||||||
|
|
||||||
func pollMonitorsWin32() error {
|
func pollMonitorsWin32() error {
|
||||||
if !_EnumDisplayDevicesW_Available() {
|
if isXbox() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -714,7 +714,7 @@ func windowProc(hWnd windows.HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM)
|
|||||||
|
|
||||||
scancode := uint32((_HIWORD(uint32(lParam)) & (_KF_EXTENDED | 0xff)))
|
scancode := uint32((_HIWORD(uint32(lParam)) & (_KF_EXTENDED | 0xff)))
|
||||||
if scancode == 0 {
|
if scancode == 0 {
|
||||||
if !_MapVirtualKeyW_Available() {
|
if isXbox() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
// NOTE: Some synthetic key messages have a scancode of zero
|
// NOTE: Some synthetic key messages have a scancode of zero
|
||||||
@ -1337,7 +1337,7 @@ func registerWindowClassWin32() error {
|
|||||||
// In the original GLFW implementation, an embedded resource GLFW_ICON is used if possible.
|
// In the original GLFW implementation, an embedded resource GLFW_ICON is used if possible.
|
||||||
// See https://www.glfw.org/docs/3.3/group__window.html
|
// See https://www.glfw.org/docs/3.3/group__window.html
|
||||||
|
|
||||||
if _LoadImageW_Available() {
|
if !isXbox() {
|
||||||
icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
|
icon, err := _LoadImageW(0, _IDI_APPLICATION, _IMAGE_ICON, 0, 0, _LR_DEFAULTSIZE|_LR_SHARED)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -2123,7 +2123,7 @@ func (c *Cursor) platformCreateCursor(image *Image, xhot, yhot int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error {
|
func (c *Cursor) platformCreateStandardCursor(shape StandardCursor) error {
|
||||||
if !_LoadImageW_Available() {
|
if isXbox() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user