mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/microsoftgdk: initialize GDK on the Ebitengine side
Updats #2084
This commit is contained in:
parent
91797a6589
commit
0578a831cc
@ -22,10 +22,25 @@ package microsoftgdk
|
||||
|
||||
// #include <stdint.h>
|
||||
//
|
||||
// uint32_t XGameRuntimeInitialize(void);
|
||||
// uint32_t XSystemGetDeviceType(void);
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
kernel32 = windows.NewLazyDLL("kernel32")
|
||||
|
||||
procGetACP = kernel32.NewProc("GetACP")
|
||||
)
|
||||
|
||||
const (
|
||||
_CP_UTF8 = 65001
|
||||
|
||||
_XSystemDeviceType_Unknown = 0x00
|
||||
_XSystemDeviceType_Pc = 0x01
|
||||
_XSystemDeviceType_XboxOne = 0x02
|
||||
@ -37,6 +52,11 @@ const (
|
||||
_XSystemDeviceType_XboxScarlettDevkit = 0x08
|
||||
)
|
||||
|
||||
func _GetACP() uint32 {
|
||||
r, _, _ := procGetACP.Call()
|
||||
return uint32(r)
|
||||
}
|
||||
|
||||
func IsXbox() bool {
|
||||
t := C.XSystemGetDeviceType()
|
||||
return t != _XSystemDeviceType_Unknown && t != _XSystemDeviceType_Pc
|
||||
@ -67,3 +87,12 @@ func D3D12DLLName() string {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
if r := C.XGameRuntimeInitialize(); uint32(r) != uint32(windows.S_OK) {
|
||||
panic(fmt.Sprintf("microsoftgdk: XSystemGetDeviceType failed: HRESULT(%d)", r))
|
||||
}
|
||||
if got, want := _GetACP(), uint32(_CP_UTF8); got != want {
|
||||
panic(fmt.Sprintf("microsoftgdk: GetACP(): got %d, want %d", got, want))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user