mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/goglfw: separate windows specific struct from common structs (#2567)
Many of the structs found in internal.h (internal_windows.go) contain defines such as GLFW_WIN32_WINDOW_STATE which gets replaced with a struct defined in win32platform_windows.go (win32_platform.h). Originally, these structs where directly placed inside of internal_windows.go. However, to make it easier to add macOS and Linux these cannot be in this file. This commit separates the windows specific structs into the respective windows file and updates the field to be named state. Updates #2546
This commit is contained in:
parent
fb51e67910
commit
b359985e97
@ -7,8 +7,6 @@ package goglfw
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -93,11 +91,7 @@ type context struct {
|
||||
getProcAddress func(string) uintptr
|
||||
destroy func(*Window) error
|
||||
|
||||
wgl struct {
|
||||
dc _HDC
|
||||
handle _HGLRC
|
||||
interval int
|
||||
}
|
||||
platform platformContextState
|
||||
}
|
||||
|
||||
type (
|
||||
@ -174,29 +168,7 @@ type Window struct {
|
||||
drop DropCallback
|
||||
}
|
||||
|
||||
win32 struct {
|
||||
handle windows.HWND
|
||||
bigIcon _HICON
|
||||
smallIcon _HICON
|
||||
|
||||
cursorTracked bool
|
||||
frameAction bool
|
||||
iconified bool
|
||||
maximized bool
|
||||
transparent bool // Whether to enable framebuffer transparency on DWM
|
||||
scaleToMonitor bool
|
||||
|
||||
// Cached size used to filter out duplicate events
|
||||
width int
|
||||
height int
|
||||
|
||||
// The last received cursor position, regardless of source
|
||||
lastCursorPosX int
|
||||
lastCursorPosY int
|
||||
|
||||
// The last recevied high surrogate when decoding pairs of UTF-16 messages
|
||||
highSurrogate uint16
|
||||
}
|
||||
platform platformWindowState
|
||||
}
|
||||
|
||||
type Monitor struct {
|
||||
@ -206,28 +178,15 @@ type Monitor struct {
|
||||
|
||||
modes []*VidMode
|
||||
|
||||
win32 struct {
|
||||
handle _HMONITOR
|
||||
|
||||
// This size matches the static size of DISPLAY_DEVICE.DeviceName
|
||||
adapterName string
|
||||
displayName string
|
||||
modesPruned bool
|
||||
modeChanged bool
|
||||
}
|
||||
platform platformMonitorState
|
||||
}
|
||||
|
||||
type Cursor struct {
|
||||
win32 struct {
|
||||
handle _HCURSOR
|
||||
}
|
||||
platform platformCursorState
|
||||
}
|
||||
|
||||
type tls struct {
|
||||
win32 struct {
|
||||
allocated bool
|
||||
index uint32
|
||||
}
|
||||
platform platformTLSState
|
||||
}
|
||||
|
||||
type library struct {
|
||||
@ -253,42 +212,8 @@ type library struct {
|
||||
monitor MonitorCallback
|
||||
}
|
||||
|
||||
win32 struct {
|
||||
instance _HINSTANCE
|
||||
helperWindowHandle windows.HWND
|
||||
deviceNotificationHandle _HDEVNOTIFY
|
||||
acquiredMonitorCount int
|
||||
clipboardString string
|
||||
keycodes [512]Key
|
||||
scancodes [KeyLast + 1]int
|
||||
keynames [KeyLast + 1]string
|
||||
|
||||
// Where to place the cursor when re-enabled
|
||||
restoreCursorPosX float64
|
||||
restoreCursorPosY float64
|
||||
|
||||
// The window whose disabled cursor mode is active
|
||||
disabledCursorWindow *Window
|
||||
rawInput []byte
|
||||
mouseTrailSize uint32
|
||||
}
|
||||
|
||||
wgl struct {
|
||||
inited bool
|
||||
|
||||
EXT_swap_control bool
|
||||
EXT_colorspace bool
|
||||
ARB_multisample bool
|
||||
ARB_framebuffer_sRGB bool
|
||||
EXT_framebuffer_sRGB bool
|
||||
ARB_pixel_format bool
|
||||
ARB_create_context bool
|
||||
ARB_create_context_profile bool
|
||||
EXT_create_context_es2_profile bool
|
||||
ARB_create_context_robustness bool
|
||||
ARB_create_context_no_error bool
|
||||
ARB_context_flush_control bool
|
||||
}
|
||||
platformWindow platformLibraryWindowState
|
||||
platformContext platformLibraryContextState
|
||||
}
|
||||
|
||||
func boolToInt(x bool) int {
|
||||
|
@ -29,9 +29,9 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
var nativeCount int32
|
||||
var attribs []int32
|
||||
|
||||
if _glfw.wgl.ARB_pixel_format {
|
||||
if _glfw.platformContext.ARB_pixel_format {
|
||||
var attrib int32 = _WGL_NUMBER_PIXEL_FORMATS_ARB
|
||||
if err := wglGetPixelFormatAttribivARB(w.context.wgl.dc, 1, 0, 1, &attrib, &nativeCount); err != nil {
|
||||
if err := wglGetPixelFormatAttribivARB(w.context.platform.dc, 1, 0, 1, &attrib, &nativeCount); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@ -59,21 +59,21 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
_WGL_STEREO_ARB,
|
||||
_WGL_DOUBLE_BUFFER_ARB)
|
||||
|
||||
if _glfw.wgl.ARB_multisample {
|
||||
if _glfw.platformContext.ARB_multisample {
|
||||
attribs = append(attribs, _WGL_SAMPLES_ARB)
|
||||
}
|
||||
|
||||
if ctxconfig.client == OpenGLAPI {
|
||||
if _glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB {
|
||||
if _glfw.platformContext.ARB_framebuffer_sRGB || _glfw.platformContext.EXT_framebuffer_sRGB {
|
||||
attribs = append(attribs, _WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB)
|
||||
}
|
||||
} else {
|
||||
if _glfw.wgl.EXT_colorspace {
|
||||
if _glfw.platformContext.EXT_colorspace {
|
||||
attribs = append(attribs, _WGL_COLORSPACE_EXT)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c, err := _DescribePixelFormat(w.context.wgl.dc, 1, uint32(unsafe.Sizeof(_PIXELFORMATDESCRIPTOR{})), nil)
|
||||
c, err := _DescribePixelFormat(w.context.platform.dc, 1, uint32(unsafe.Sizeof(_PIXELFORMATDESCRIPTOR{})), nil)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -85,10 +85,10 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
var u fbconfig
|
||||
pixelFormat := uintptr(i) + 1
|
||||
|
||||
if _glfw.wgl.ARB_pixel_format {
|
||||
if _glfw.platformContext.ARB_pixel_format {
|
||||
// Get pixel format attributes through "modern" extension
|
||||
values := make([]int32, len(attribs))
|
||||
if err := wglGetPixelFormatAttribivARB(w.context.wgl.dc, int32(pixelFormat), 0, uint32(len(attribs)), &attribs[0], &values[0]); err != nil {
|
||||
if err := wglGetPixelFormatAttribivARB(w.context.platform.dc, int32(pixelFormat), 0, uint32(len(attribs)), &attribs[0], &values[0]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@ -131,18 +131,18 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
u.stereo = true
|
||||
}
|
||||
|
||||
if _glfw.wgl.ARB_multisample {
|
||||
if _glfw.platformContext.ARB_multisample {
|
||||
u.samples = int(findAttribValue(_WGL_SAMPLES_ARB))
|
||||
}
|
||||
|
||||
if ctxconfig.client == OpenGLAPI {
|
||||
if _glfw.wgl.ARB_framebuffer_sRGB || _glfw.wgl.EXT_framebuffer_sRGB {
|
||||
if _glfw.platformContext.ARB_framebuffer_sRGB || _glfw.platformContext.EXT_framebuffer_sRGB {
|
||||
if findAttribValue(_WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB) != 0 {
|
||||
u.sRGB = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if _glfw.wgl.EXT_colorspace {
|
||||
if _glfw.platformContext.EXT_colorspace {
|
||||
if findAttribValue(_WGL_COLORSPACE_EXT) == _WGL_COLORSPACE_SRGB_EXT {
|
||||
u.sRGB = true
|
||||
}
|
||||
@ -152,7 +152,7 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
// Get pixel format attributes through legacy PFDs
|
||||
|
||||
var pfd _PIXELFORMATDESCRIPTOR
|
||||
if _, err := _DescribePixelFormat(w.context.wgl.dc, int32(pixelFormat), uint32(unsafe.Sizeof(pfd)), &pfd); err != nil {
|
||||
if _, err := _DescribePixelFormat(w.context.platform.dc, int32(pixelFormat), uint32(unsafe.Sizeof(pfd)), &pfd); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ func (w *Window) choosePixelFormat(ctxconfig *ctxconfig, fbconfig_ *fbconfig) (i
|
||||
|
||||
func makeContextCurrentWGL(window *Window) error {
|
||||
if window != nil {
|
||||
if err := wglMakeCurrent(window.context.wgl.dc, window.context.wgl.handle); err != nil {
|
||||
if err := wglMakeCurrent(window.context.platform.dc, window.context.platform.handle); err != nil {
|
||||
_ = _glfw.contextSlot.set(0)
|
||||
return err
|
||||
}
|
||||
@ -244,14 +244,14 @@ func swapBuffersWGL(window *Window) error {
|
||||
|
||||
// HACK: Use DwmFlush when desktop composition is enabled
|
||||
if enabled {
|
||||
for i := 0; i < window.context.wgl.interval; i++ {
|
||||
for i := 0; i < window.context.platform.interval; i++ {
|
||||
// Ignore an error from DWM functions as they might not be implemented e.g. on Proton (#2113).
|
||||
_ = _DwmFlush()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := _SwapBuffers(window.context.wgl.dc); err != nil {
|
||||
if err := _SwapBuffers(window.context.platform.dc); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
@ -264,7 +264,7 @@ func swapIntervalWGL(interval int) error {
|
||||
}
|
||||
window := (*Window)(unsafe.Pointer(ptr))
|
||||
|
||||
window.context.wgl.interval = interval
|
||||
window.context.platform.interval = interval
|
||||
|
||||
if window.monitor == nil && _IsWindowsVistaOrGreater() {
|
||||
// DWM Composition is always enabled on Win8+
|
||||
@ -285,7 +285,7 @@ func swapIntervalWGL(interval int) error {
|
||||
}
|
||||
}
|
||||
|
||||
if _glfw.wgl.EXT_swap_control {
|
||||
if _glfw.platformContext.EXT_swap_control {
|
||||
if err := wglSwapIntervalEXT(int32(interval)); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -323,14 +323,14 @@ func getProcAddressWGL(procname string) uintptr {
|
||||
}
|
||||
|
||||
func destroyContextWGL(window *Window) error {
|
||||
if window.context.wgl.handle != 0 {
|
||||
if window.context.platform.handle != 0 {
|
||||
// Ignore ERROR_BUSY. This happens when the thread is different from the context thread (#2518).
|
||||
// This is a known issue of GLFW (glfw/glfw#2239).
|
||||
// TODO: Delete the context on an appropriate thread.
|
||||
if err := wglDeleteContext(window.context.wgl.handle); err != nil && !errors.Is(err, windows.ERROR_BUSY) {
|
||||
if err := wglDeleteContext(window.context.platform.handle); err != nil && !errors.Is(err, windows.ERROR_BUSY) {
|
||||
return err
|
||||
}
|
||||
window.context.wgl.handle = 0
|
||||
window.context.platform.handle = 0
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -340,7 +340,7 @@ func initWGL() error {
|
||||
return fmt.Errorf("goglfw: WGL is not available in Xbox")
|
||||
}
|
||||
|
||||
if _glfw.wgl.inited {
|
||||
if _glfw.platformContext.inited {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ func initWGL() error {
|
||||
// NOTE: This code will accept the Microsoft GDI ICD; accelerated context
|
||||
// creation failure occurs during manual pixel format enumeration
|
||||
|
||||
dc, err := _GetDC(_glfw.win32.helperWindowHandle)
|
||||
dc, err := _GetDC(_glfw.platformWindow.helperWindowHandle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -397,18 +397,18 @@ func initWGL() error {
|
||||
|
||||
// NOTE: WGL_ARB_extensions_string and WGL_EXT_extensions_string are not
|
||||
// checked below as we are already using them
|
||||
_glfw.wgl.ARB_multisample = extensionSupportedWGL("WGL_ARB_multisample")
|
||||
_glfw.wgl.ARB_framebuffer_sRGB = extensionSupportedWGL("WGL_ARB_framebuffer_sRGB")
|
||||
_glfw.wgl.EXT_framebuffer_sRGB = extensionSupportedWGL("WGL_EXT_framebuffer_sRGB")
|
||||
_glfw.wgl.ARB_create_context = extensionSupportedWGL("WGL_ARB_create_context")
|
||||
_glfw.wgl.ARB_create_context_profile = extensionSupportedWGL("WGL_ARB_create_context_profile")
|
||||
_glfw.wgl.EXT_create_context_es2_profile = extensionSupportedWGL("WGL_EXT_create_context_es2_profile")
|
||||
_glfw.wgl.ARB_create_context_robustness = extensionSupportedWGL("WGL_ARB_create_context_robustness")
|
||||
_glfw.wgl.ARB_create_context_no_error = extensionSupportedWGL("WGL_ARB_create_context_no_error")
|
||||
_glfw.wgl.EXT_swap_control = extensionSupportedWGL("WGL_EXT_swap_control")
|
||||
_glfw.wgl.EXT_colorspace = extensionSupportedWGL("WGL_EXT_colorspace")
|
||||
_glfw.wgl.ARB_pixel_format = extensionSupportedWGL("WGL_ARB_pixel_format")
|
||||
_glfw.wgl.ARB_context_flush_control = extensionSupportedWGL("WGL_ARB_context_flush_control")
|
||||
_glfw.platformContext.ARB_multisample = extensionSupportedWGL("WGL_ARB_multisample")
|
||||
_glfw.platformContext.ARB_framebuffer_sRGB = extensionSupportedWGL("WGL_ARB_framebuffer_sRGB")
|
||||
_glfw.platformContext.EXT_framebuffer_sRGB = extensionSupportedWGL("WGL_EXT_framebuffer_sRGB")
|
||||
_glfw.platformContext.ARB_create_context = extensionSupportedWGL("WGL_ARB_create_context")
|
||||
_glfw.platformContext.ARB_create_context_profile = extensionSupportedWGL("WGL_ARB_create_context_profile")
|
||||
_glfw.platformContext.EXT_create_context_es2_profile = extensionSupportedWGL("WGL_EXT_create_context_es2_profile")
|
||||
_glfw.platformContext.ARB_create_context_robustness = extensionSupportedWGL("WGL_ARB_create_context_robustness")
|
||||
_glfw.platformContext.ARB_create_context_no_error = extensionSupportedWGL("WGL_ARB_create_context_no_error")
|
||||
_glfw.platformContext.EXT_swap_control = extensionSupportedWGL("WGL_EXT_swap_control")
|
||||
_glfw.platformContext.EXT_colorspace = extensionSupportedWGL("WGL_EXT_colorspace")
|
||||
_glfw.platformContext.ARB_pixel_format = extensionSupportedWGL("WGL_ARB_pixel_format")
|
||||
_glfw.platformContext.ARB_context_flush_control = extensionSupportedWGL("WGL_ARB_context_flush_control")
|
||||
|
||||
if err := wglMakeCurrent(pdc, prc); err != nil {
|
||||
return err
|
||||
@ -416,7 +416,7 @@ func initWGL() error {
|
||||
if err := wglDeleteContext(rc); err != nil {
|
||||
return err
|
||||
}
|
||||
_glfw.wgl.inited = true
|
||||
_glfw.platformContext.inited = true
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -426,14 +426,14 @@ func terminateWGL() {
|
||||
func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) error {
|
||||
var share _HGLRC
|
||||
if ctxconfig.share != nil {
|
||||
share = ctxconfig.share.context.wgl.handle
|
||||
share = ctxconfig.share.context.platform.handle
|
||||
}
|
||||
|
||||
dc, err := _GetDC(w.win32.handle)
|
||||
dc, err := _GetDC(w.platform.handle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.context.wgl.dc = dc
|
||||
w.context.platform.dc = dc
|
||||
|
||||
pixelFormat, err := w.choosePixelFormat(ctxconfig, fbconfig)
|
||||
if err != nil {
|
||||
@ -441,29 +441,29 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
||||
}
|
||||
|
||||
var pfd _PIXELFORMATDESCRIPTOR
|
||||
if _, err := _DescribePixelFormat(w.context.wgl.dc, int32(pixelFormat), uint32(unsafe.Sizeof(pfd)), &pfd); err != nil {
|
||||
if _, err := _DescribePixelFormat(w.context.platform.dc, int32(pixelFormat), uint32(unsafe.Sizeof(pfd)), &pfd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := _SetPixelFormat(w.context.wgl.dc, int32(pixelFormat), &pfd); err != nil {
|
||||
if err := _SetPixelFormat(w.context.platform.dc, int32(pixelFormat), &pfd); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if ctxconfig.client == OpenGLAPI {
|
||||
if ctxconfig.forward && !_glfw.wgl.ARB_create_context {
|
||||
if ctxconfig.forward && !_glfw.platformContext.ARB_create_context {
|
||||
return fmt.Errorf("goglfw: a forward compatible OpenGL context requested but WGL_ARB_create_context is unavailable: %w", VersionUnavailable)
|
||||
}
|
||||
|
||||
if ctxconfig.profile != 0 && !_glfw.wgl.ARB_create_context_profile {
|
||||
if ctxconfig.profile != 0 && !_glfw.platformContext.ARB_create_context_profile {
|
||||
return fmt.Errorf("goglfw: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable: %w", VersionUnavailable)
|
||||
}
|
||||
} else {
|
||||
if !_glfw.wgl.ARB_create_context || !_glfw.wgl.ARB_create_context_profile || !_glfw.wgl.EXT_create_context_es2_profile {
|
||||
if !_glfw.platformContext.ARB_create_context || !_glfw.platformContext.ARB_create_context_profile || !_glfw.platformContext.EXT_create_context_es2_profile {
|
||||
return fmt.Errorf("goglfw: OpenGL ES requested but WGL_ARB_create_context_es2_profile is unavailable: %w", ApiUnavailable)
|
||||
}
|
||||
}
|
||||
|
||||
if _glfw.wgl.ARB_create_context {
|
||||
if _glfw.platformContext.ARB_create_context {
|
||||
var flags int32
|
||||
var mask int32
|
||||
if ctxconfig.client == OpenGLAPI {
|
||||
@ -486,7 +486,7 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
||||
|
||||
var attribs []int32
|
||||
if ctxconfig.robustness != 0 {
|
||||
if _glfw.wgl.ARB_create_context_robustness {
|
||||
if _glfw.platformContext.ARB_create_context_robustness {
|
||||
if ctxconfig.robustness == NoResetNotification {
|
||||
attribs = append(attribs, _WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, _WGL_NO_RESET_NOTIFICATION_ARB)
|
||||
} else if ctxconfig.robustness == LoseContextOnReset {
|
||||
@ -497,7 +497,7 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
||||
}
|
||||
|
||||
if ctxconfig.release != 0 {
|
||||
if _glfw.wgl.ARB_context_flush_control {
|
||||
if _glfw.platformContext.ARB_context_flush_control {
|
||||
if ctxconfig.release == ReleaseBehaviorNone {
|
||||
attribs = append(attribs, _WGL_CONTEXT_RELEASE_BEHAVIOR_ARB, _WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB)
|
||||
} else if ctxconfig.release == ReleaseBehaviorFlush {
|
||||
@ -507,7 +507,7 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
||||
}
|
||||
|
||||
if ctxconfig.noerror {
|
||||
if _glfw.wgl.ARB_create_context_no_error {
|
||||
if _glfw.platformContext.ARB_create_context_no_error {
|
||||
attribs = append(attribs, _WGL_CONTEXT_OPENGL_NO_ERROR_ARB, 1)
|
||||
}
|
||||
}
|
||||
@ -531,19 +531,19 @@ func (w *Window) createContextWGL(ctxconfig *ctxconfig, fbconfig *fbconfig) erro
|
||||
attribs = append(attribs, 0, 0)
|
||||
|
||||
var err error
|
||||
w.context.wgl.handle, err = wglCreateContextAttribsARB(w.context.wgl.dc, share, &attribs[0])
|
||||
w.context.platform.handle, err = wglCreateContextAttribsARB(w.context.platform.dc, share, &attribs[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
var err error
|
||||
w.context.wgl.handle, err = wglCreateContext(w.context.wgl.dc)
|
||||
w.context.platform.handle, err = wglCreateContext(w.context.platform.dc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if share != 0 {
|
||||
if err := wglShareLists(share, w.context.wgl.handle); err != nil {
|
||||
if err := wglShareLists(share, w.context.platform.handle); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -568,5 +568,5 @@ func getWGLContext(handle *Window) _HGLRC {
|
||||
// TODO: Should this return an error?
|
||||
return 0
|
||||
}
|
||||
return window.context.wgl.handle
|
||||
return window.context.platform.handle
|
||||
}
|
||||
|
@ -15,138 +15,138 @@ import (
|
||||
)
|
||||
|
||||
func createKeyTables() {
|
||||
for i := range _glfw.win32.keycodes {
|
||||
_glfw.win32.keycodes[i] = -1
|
||||
for i := range _glfw.platformWindow.keycodes {
|
||||
_glfw.platformWindow.keycodes[i] = -1
|
||||
}
|
||||
for i := range _glfw.win32.scancodes {
|
||||
_glfw.win32.keycodes[i] = -1
|
||||
for i := range _glfw.platformWindow.scancodes {
|
||||
_glfw.platformWindow.keycodes[i] = -1
|
||||
}
|
||||
|
||||
_glfw.win32.keycodes[0x00B] = Key0
|
||||
_glfw.win32.keycodes[0x002] = Key1
|
||||
_glfw.win32.keycodes[0x003] = Key2
|
||||
_glfw.win32.keycodes[0x004] = Key3
|
||||
_glfw.win32.keycodes[0x005] = Key4
|
||||
_glfw.win32.keycodes[0x006] = Key5
|
||||
_glfw.win32.keycodes[0x007] = Key6
|
||||
_glfw.win32.keycodes[0x008] = Key7
|
||||
_glfw.win32.keycodes[0x009] = Key8
|
||||
_glfw.win32.keycodes[0x00A] = Key9
|
||||
_glfw.win32.keycodes[0x01E] = KeyA
|
||||
_glfw.win32.keycodes[0x030] = KeyB
|
||||
_glfw.win32.keycodes[0x02E] = KeyC
|
||||
_glfw.win32.keycodes[0x020] = KeyD
|
||||
_glfw.win32.keycodes[0x012] = KeyE
|
||||
_glfw.win32.keycodes[0x021] = KeyF
|
||||
_glfw.win32.keycodes[0x022] = KeyG
|
||||
_glfw.win32.keycodes[0x023] = KeyH
|
||||
_glfw.win32.keycodes[0x017] = KeyI
|
||||
_glfw.win32.keycodes[0x024] = KeyJ
|
||||
_glfw.win32.keycodes[0x025] = KeyK
|
||||
_glfw.win32.keycodes[0x026] = KeyL
|
||||
_glfw.win32.keycodes[0x032] = KeyM
|
||||
_glfw.win32.keycodes[0x031] = KeyN
|
||||
_glfw.win32.keycodes[0x018] = KeyO
|
||||
_glfw.win32.keycodes[0x019] = KeyP
|
||||
_glfw.win32.keycodes[0x010] = KeyQ
|
||||
_glfw.win32.keycodes[0x013] = KeyR
|
||||
_glfw.win32.keycodes[0x01F] = KeyS
|
||||
_glfw.win32.keycodes[0x014] = KeyT
|
||||
_glfw.win32.keycodes[0x016] = KeyU
|
||||
_glfw.win32.keycodes[0x02F] = KeyV
|
||||
_glfw.win32.keycodes[0x011] = KeyW
|
||||
_glfw.win32.keycodes[0x02D] = KeyX
|
||||
_glfw.win32.keycodes[0x015] = KeyY
|
||||
_glfw.win32.keycodes[0x02C] = KeyZ
|
||||
_glfw.platformWindow.keycodes[0x00B] = Key0
|
||||
_glfw.platformWindow.keycodes[0x002] = Key1
|
||||
_glfw.platformWindow.keycodes[0x003] = Key2
|
||||
_glfw.platformWindow.keycodes[0x004] = Key3
|
||||
_glfw.platformWindow.keycodes[0x005] = Key4
|
||||
_glfw.platformWindow.keycodes[0x006] = Key5
|
||||
_glfw.platformWindow.keycodes[0x007] = Key6
|
||||
_glfw.platformWindow.keycodes[0x008] = Key7
|
||||
_glfw.platformWindow.keycodes[0x009] = Key8
|
||||
_glfw.platformWindow.keycodes[0x00A] = Key9
|
||||
_glfw.platformWindow.keycodes[0x01E] = KeyA
|
||||
_glfw.platformWindow.keycodes[0x030] = KeyB
|
||||
_glfw.platformWindow.keycodes[0x02E] = KeyC
|
||||
_glfw.platformWindow.keycodes[0x020] = KeyD
|
||||
_glfw.platformWindow.keycodes[0x012] = KeyE
|
||||
_glfw.platformWindow.keycodes[0x021] = KeyF
|
||||
_glfw.platformWindow.keycodes[0x022] = KeyG
|
||||
_glfw.platformWindow.keycodes[0x023] = KeyH
|
||||
_glfw.platformWindow.keycodes[0x017] = KeyI
|
||||
_glfw.platformWindow.keycodes[0x024] = KeyJ
|
||||
_glfw.platformWindow.keycodes[0x025] = KeyK
|
||||
_glfw.platformWindow.keycodes[0x026] = KeyL
|
||||
_glfw.platformWindow.keycodes[0x032] = KeyM
|
||||
_glfw.platformWindow.keycodes[0x031] = KeyN
|
||||
_glfw.platformWindow.keycodes[0x018] = KeyO
|
||||
_glfw.platformWindow.keycodes[0x019] = KeyP
|
||||
_glfw.platformWindow.keycodes[0x010] = KeyQ
|
||||
_glfw.platformWindow.keycodes[0x013] = KeyR
|
||||
_glfw.platformWindow.keycodes[0x01F] = KeyS
|
||||
_glfw.platformWindow.keycodes[0x014] = KeyT
|
||||
_glfw.platformWindow.keycodes[0x016] = KeyU
|
||||
_glfw.platformWindow.keycodes[0x02F] = KeyV
|
||||
_glfw.platformWindow.keycodes[0x011] = KeyW
|
||||
_glfw.platformWindow.keycodes[0x02D] = KeyX
|
||||
_glfw.platformWindow.keycodes[0x015] = KeyY
|
||||
_glfw.platformWindow.keycodes[0x02C] = KeyZ
|
||||
|
||||
_glfw.win32.keycodes[0x028] = KeyApostrophe
|
||||
_glfw.win32.keycodes[0x02B] = KeyBackslash
|
||||
_glfw.win32.keycodes[0x033] = KeyComma
|
||||
_glfw.win32.keycodes[0x00D] = KeyEqual
|
||||
_glfw.win32.keycodes[0x029] = KeyGraveAccent
|
||||
_glfw.win32.keycodes[0x01A] = KeyLeftBracket
|
||||
_glfw.win32.keycodes[0x00C] = KeyMinus
|
||||
_glfw.win32.keycodes[0x034] = KeyPeriod
|
||||
_glfw.win32.keycodes[0x01B] = KeyRightBracket
|
||||
_glfw.win32.keycodes[0x027] = KeySemicolon
|
||||
_glfw.win32.keycodes[0x035] = KeySlash
|
||||
_glfw.win32.keycodes[0x056] = KeyWorld2
|
||||
_glfw.platformWindow.keycodes[0x028] = KeyApostrophe
|
||||
_glfw.platformWindow.keycodes[0x02B] = KeyBackslash
|
||||
_glfw.platformWindow.keycodes[0x033] = KeyComma
|
||||
_glfw.platformWindow.keycodes[0x00D] = KeyEqual
|
||||
_glfw.platformWindow.keycodes[0x029] = KeyGraveAccent
|
||||
_glfw.platformWindow.keycodes[0x01A] = KeyLeftBracket
|
||||
_glfw.platformWindow.keycodes[0x00C] = KeyMinus
|
||||
_glfw.platformWindow.keycodes[0x034] = KeyPeriod
|
||||
_glfw.platformWindow.keycodes[0x01B] = KeyRightBracket
|
||||
_glfw.platformWindow.keycodes[0x027] = KeySemicolon
|
||||
_glfw.platformWindow.keycodes[0x035] = KeySlash
|
||||
_glfw.platformWindow.keycodes[0x056] = KeyWorld2
|
||||
|
||||
_glfw.win32.keycodes[0x00E] = KeyBackspace
|
||||
_glfw.win32.keycodes[0x153] = KeyDelete
|
||||
_glfw.win32.keycodes[0x14F] = KeyEnd
|
||||
_glfw.win32.keycodes[0x01C] = KeyEnter
|
||||
_glfw.win32.keycodes[0x001] = KeyEscape
|
||||
_glfw.win32.keycodes[0x147] = KeyHome
|
||||
_glfw.win32.keycodes[0x152] = KeyInsert
|
||||
_glfw.win32.keycodes[0x15D] = KeyMenu
|
||||
_glfw.win32.keycodes[0x151] = KeyPageDown
|
||||
_glfw.win32.keycodes[0x149] = KeyPageUp
|
||||
_glfw.win32.keycodes[0x045] = KeyPause
|
||||
_glfw.win32.keycodes[0x039] = KeySpace
|
||||
_glfw.win32.keycodes[0x00F] = KeyTab
|
||||
_glfw.win32.keycodes[0x03A] = KeyCapsLock
|
||||
_glfw.win32.keycodes[0x145] = KeyNumLock
|
||||
_glfw.win32.keycodes[0x046] = KeyScrollLock
|
||||
_glfw.win32.keycodes[0x03B] = KeyF1
|
||||
_glfw.win32.keycodes[0x03C] = KeyF2
|
||||
_glfw.win32.keycodes[0x03D] = KeyF3
|
||||
_glfw.win32.keycodes[0x03E] = KeyF4
|
||||
_glfw.win32.keycodes[0x03F] = KeyF5
|
||||
_glfw.win32.keycodes[0x040] = KeyF6
|
||||
_glfw.win32.keycodes[0x041] = KeyF7
|
||||
_glfw.win32.keycodes[0x042] = KeyF8
|
||||
_glfw.win32.keycodes[0x043] = KeyF9
|
||||
_glfw.win32.keycodes[0x044] = KeyF10
|
||||
_glfw.win32.keycodes[0x057] = KeyF11
|
||||
_glfw.win32.keycodes[0x058] = KeyF12
|
||||
_glfw.win32.keycodes[0x064] = KeyF13
|
||||
_glfw.win32.keycodes[0x065] = KeyF14
|
||||
_glfw.win32.keycodes[0x066] = KeyF15
|
||||
_glfw.win32.keycodes[0x067] = KeyF16
|
||||
_glfw.win32.keycodes[0x068] = KeyF17
|
||||
_glfw.win32.keycodes[0x069] = KeyF18
|
||||
_glfw.win32.keycodes[0x06A] = KeyF19
|
||||
_glfw.win32.keycodes[0x06B] = KeyF20
|
||||
_glfw.win32.keycodes[0x06C] = KeyF21
|
||||
_glfw.win32.keycodes[0x06D] = KeyF22
|
||||
_glfw.win32.keycodes[0x06E] = KeyF23
|
||||
_glfw.win32.keycodes[0x076] = KeyF24
|
||||
_glfw.win32.keycodes[0x038] = KeyLeftAlt
|
||||
_glfw.win32.keycodes[0x01D] = KeyLeftControl
|
||||
_glfw.win32.keycodes[0x02A] = KeyLeftShift
|
||||
_glfw.win32.keycodes[0x15B] = KeyLeftSuper
|
||||
_glfw.win32.keycodes[0x137] = KeyPrintScreen
|
||||
_glfw.win32.keycodes[0x138] = KeyRightAlt
|
||||
_glfw.win32.keycodes[0x11D] = KeyRightControl
|
||||
_glfw.win32.keycodes[0x036] = KeyRightShift
|
||||
_glfw.win32.keycodes[0x15C] = KeyRightSuper
|
||||
_glfw.win32.keycodes[0x150] = KeyDown
|
||||
_glfw.win32.keycodes[0x14B] = KeyLeft
|
||||
_glfw.win32.keycodes[0x14D] = KeyRight
|
||||
_glfw.win32.keycodes[0x148] = KeyUp
|
||||
_glfw.platformWindow.keycodes[0x00E] = KeyBackspace
|
||||
_glfw.platformWindow.keycodes[0x153] = KeyDelete
|
||||
_glfw.platformWindow.keycodes[0x14F] = KeyEnd
|
||||
_glfw.platformWindow.keycodes[0x01C] = KeyEnter
|
||||
_glfw.platformWindow.keycodes[0x001] = KeyEscape
|
||||
_glfw.platformWindow.keycodes[0x147] = KeyHome
|
||||
_glfw.platformWindow.keycodes[0x152] = KeyInsert
|
||||
_glfw.platformWindow.keycodes[0x15D] = KeyMenu
|
||||
_glfw.platformWindow.keycodes[0x151] = KeyPageDown
|
||||
_glfw.platformWindow.keycodes[0x149] = KeyPageUp
|
||||
_glfw.platformWindow.keycodes[0x045] = KeyPause
|
||||
_glfw.platformWindow.keycodes[0x039] = KeySpace
|
||||
_glfw.platformWindow.keycodes[0x00F] = KeyTab
|
||||
_glfw.platformWindow.keycodes[0x03A] = KeyCapsLock
|
||||
_glfw.platformWindow.keycodes[0x145] = KeyNumLock
|
||||
_glfw.platformWindow.keycodes[0x046] = KeyScrollLock
|
||||
_glfw.platformWindow.keycodes[0x03B] = KeyF1
|
||||
_glfw.platformWindow.keycodes[0x03C] = KeyF2
|
||||
_glfw.platformWindow.keycodes[0x03D] = KeyF3
|
||||
_glfw.platformWindow.keycodes[0x03E] = KeyF4
|
||||
_glfw.platformWindow.keycodes[0x03F] = KeyF5
|
||||
_glfw.platformWindow.keycodes[0x040] = KeyF6
|
||||
_glfw.platformWindow.keycodes[0x041] = KeyF7
|
||||
_glfw.platformWindow.keycodes[0x042] = KeyF8
|
||||
_glfw.platformWindow.keycodes[0x043] = KeyF9
|
||||
_glfw.platformWindow.keycodes[0x044] = KeyF10
|
||||
_glfw.platformWindow.keycodes[0x057] = KeyF11
|
||||
_glfw.platformWindow.keycodes[0x058] = KeyF12
|
||||
_glfw.platformWindow.keycodes[0x064] = KeyF13
|
||||
_glfw.platformWindow.keycodes[0x065] = KeyF14
|
||||
_glfw.platformWindow.keycodes[0x066] = KeyF15
|
||||
_glfw.platformWindow.keycodes[0x067] = KeyF16
|
||||
_glfw.platformWindow.keycodes[0x068] = KeyF17
|
||||
_glfw.platformWindow.keycodes[0x069] = KeyF18
|
||||
_glfw.platformWindow.keycodes[0x06A] = KeyF19
|
||||
_glfw.platformWindow.keycodes[0x06B] = KeyF20
|
||||
_glfw.platformWindow.keycodes[0x06C] = KeyF21
|
||||
_glfw.platformWindow.keycodes[0x06D] = KeyF22
|
||||
_glfw.platformWindow.keycodes[0x06E] = KeyF23
|
||||
_glfw.platformWindow.keycodes[0x076] = KeyF24
|
||||
_glfw.platformWindow.keycodes[0x038] = KeyLeftAlt
|
||||
_glfw.platformWindow.keycodes[0x01D] = KeyLeftControl
|
||||
_glfw.platformWindow.keycodes[0x02A] = KeyLeftShift
|
||||
_glfw.platformWindow.keycodes[0x15B] = KeyLeftSuper
|
||||
_glfw.platformWindow.keycodes[0x137] = KeyPrintScreen
|
||||
_glfw.platformWindow.keycodes[0x138] = KeyRightAlt
|
||||
_glfw.platformWindow.keycodes[0x11D] = KeyRightControl
|
||||
_glfw.platformWindow.keycodes[0x036] = KeyRightShift
|
||||
_glfw.platformWindow.keycodes[0x15C] = KeyRightSuper
|
||||
_glfw.platformWindow.keycodes[0x150] = KeyDown
|
||||
_glfw.platformWindow.keycodes[0x14B] = KeyLeft
|
||||
_glfw.platformWindow.keycodes[0x14D] = KeyRight
|
||||
_glfw.platformWindow.keycodes[0x148] = KeyUp
|
||||
|
||||
_glfw.win32.keycodes[0x052] = KeyKP0
|
||||
_glfw.win32.keycodes[0x04F] = KeyKP1
|
||||
_glfw.win32.keycodes[0x050] = KeyKP2
|
||||
_glfw.win32.keycodes[0x051] = KeyKP3
|
||||
_glfw.win32.keycodes[0x04B] = KeyKP4
|
||||
_glfw.win32.keycodes[0x04C] = KeyKP5
|
||||
_glfw.win32.keycodes[0x04D] = KeyKP6
|
||||
_glfw.win32.keycodes[0x047] = KeyKP7
|
||||
_glfw.win32.keycodes[0x048] = KeyKP8
|
||||
_glfw.win32.keycodes[0x049] = KeyKP9
|
||||
_glfw.win32.keycodes[0x04E] = KeyKPAdd
|
||||
_glfw.win32.keycodes[0x053] = KeyKPDecimal
|
||||
_glfw.win32.keycodes[0x135] = KeyKPDivide
|
||||
_glfw.win32.keycodes[0x11C] = KeyKPEnter
|
||||
_glfw.win32.keycodes[0x059] = KeyKPEqual
|
||||
_glfw.win32.keycodes[0x037] = KeyKPMultiply
|
||||
_glfw.win32.keycodes[0x04A] = KeyKPSubtract
|
||||
_glfw.platformWindow.keycodes[0x052] = KeyKP0
|
||||
_glfw.platformWindow.keycodes[0x04F] = KeyKP1
|
||||
_glfw.platformWindow.keycodes[0x050] = KeyKP2
|
||||
_glfw.platformWindow.keycodes[0x051] = KeyKP3
|
||||
_glfw.platformWindow.keycodes[0x04B] = KeyKP4
|
||||
_glfw.platformWindow.keycodes[0x04C] = KeyKP5
|
||||
_glfw.platformWindow.keycodes[0x04D] = KeyKP6
|
||||
_glfw.platformWindow.keycodes[0x047] = KeyKP7
|
||||
_glfw.platformWindow.keycodes[0x048] = KeyKP8
|
||||
_glfw.platformWindow.keycodes[0x049] = KeyKP9
|
||||
_glfw.platformWindow.keycodes[0x04E] = KeyKPAdd
|
||||
_glfw.platformWindow.keycodes[0x053] = KeyKPDecimal
|
||||
_glfw.platformWindow.keycodes[0x135] = KeyKPDivide
|
||||
_glfw.platformWindow.keycodes[0x11C] = KeyKPEnter
|
||||
_glfw.platformWindow.keycodes[0x059] = KeyKPEqual
|
||||
_glfw.platformWindow.keycodes[0x037] = KeyKPMultiply
|
||||
_glfw.platformWindow.keycodes[0x04A] = KeyKPSubtract
|
||||
|
||||
for scancode := 0; scancode < 512; scancode++ {
|
||||
if _glfw.win32.keycodes[scancode] > 0 {
|
||||
_glfw.win32.scancodes[_glfw.win32.keycodes[scancode]] = scancode
|
||||
if _glfw.platformWindow.keycodes[scancode] > 0 {
|
||||
_glfw.platformWindow.scancodes[_glfw.platformWindow.keycodes[scancode]] = scancode
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -157,14 +157,14 @@ func updateKeyNamesWin32() {
|
||||
return
|
||||
}
|
||||
|
||||
for i := range _glfw.win32.keynames {
|
||||
_glfw.win32.keynames[i] = ""
|
||||
for i := range _glfw.platformWindow.keynames {
|
||||
_glfw.platformWindow.keynames[i] = ""
|
||||
}
|
||||
|
||||
var state [256]byte
|
||||
|
||||
for key := KeySpace; key <= KeyLast; key++ {
|
||||
scancode := _glfw.win32.scancodes[key]
|
||||
scancode := _glfw.platformWindow.scancodes[key]
|
||||
if scancode == -1 {
|
||||
continue
|
||||
}
|
||||
@ -193,21 +193,21 @@ func updateKeyNamesWin32() {
|
||||
continue
|
||||
}
|
||||
|
||||
_glfw.win32.keynames[key] = windows.UTF16ToString(chars[:length])
|
||||
_glfw.platformWindow.keynames[key] = windows.UTF16ToString(chars[:length])
|
||||
}
|
||||
}
|
||||
|
||||
func createHelperWindow() error {
|
||||
h, err := _CreateWindowExW(_WS_EX_OVERLAPPEDWINDOW, _GLFW_WNDCLASSNAME, "GLFW message window", _WS_CLIPSIBLINGS|_WS_CLIPCHILDREN, 0, 0, 1, 1, 0, 0, _glfw.win32.instance, nil)
|
||||
h, err := _CreateWindowExW(_WS_EX_OVERLAPPEDWINDOW, _GLFW_WNDCLASSNAME, "GLFW message window", _WS_CLIPSIBLINGS|_WS_CLIPCHILDREN, 0, 0, 1, 1, 0, 0, _glfw.platformWindow.instance, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_glfw.win32.helperWindowHandle = h
|
||||
_glfw.platformWindow.helperWindowHandle = h
|
||||
|
||||
// HACK: The command to the first ShowWindow call is ignored if the parent
|
||||
// process passed along a STARTUPINFO, so clear that with a no-op call
|
||||
_ShowWindow(_glfw.win32.helperWindowHandle, _SW_HIDE)
|
||||
_ShowWindow(_glfw.platformWindow.helperWindowHandle, _SW_HIDE)
|
||||
|
||||
// Register for HID device notifications
|
||||
if !microsoftgdk.IsXbox() {
|
||||
@ -222,15 +222,15 @@ func createHelperWindow() error {
|
||||
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)
|
||||
notify, err := _RegisterDeviceNotificationW(windows.Handle(_glfw.platformWindow.helperWindowHandle), unsafe.Pointer(&dbi), _DEVICE_NOTIFY_WINDOW_HANDLE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_glfw.win32.deviceNotificationHandle = notify
|
||||
_glfw.platformWindow.deviceNotificationHandle = notify
|
||||
}
|
||||
|
||||
var msg _MSG
|
||||
for _PeekMessageW(&msg, _glfw.win32.helperWindowHandle, 0, 0, _PM_REMOVE) {
|
||||
for _PeekMessageW(&msg, _glfw.platformWindow.helperWindowHandle, 0, 0, _PM_REMOVE) {
|
||||
_TranslateMessage(&msg)
|
||||
_DispatchMessageW(&msg)
|
||||
}
|
||||
@ -281,7 +281,7 @@ func platformInit() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_glfw.win32.instance = _HINSTANCE(m)
|
||||
_glfw.platformWindow.instance = _HINSTANCE(m)
|
||||
|
||||
createKeyTables()
|
||||
updateKeyNamesWin32()
|
||||
@ -335,15 +335,15 @@ func platformInit() error {
|
||||
}
|
||||
|
||||
func platformTerminate() error {
|
||||
if _glfw.win32.deviceNotificationHandle != 0 {
|
||||
if err := _UnregisterDeviceNotification(_glfw.win32.deviceNotificationHandle); err != nil {
|
||||
if _glfw.platformWindow.deviceNotificationHandle != 0 {
|
||||
if err := _UnregisterDeviceNotification(_glfw.platformWindow.deviceNotificationHandle); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if _glfw.win32.helperWindowHandle != 0 {
|
||||
if _glfw.platformWindow.helperWindowHandle != 0 {
|
||||
if !microsoftgdk.IsXbox() {
|
||||
if err := _DestroyWindow(_glfw.win32.helperWindowHandle); err != nil {
|
||||
if err := _DestroyWindow(_glfw.platformWindow.helperWindowHandle); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import (
|
||||
|
||||
func monitorCallback(handle _HMONITOR, dc _HDC, rect *_RECT, monitor *Monitor /* _LPARAM */) uintptr /* _BOOL */ {
|
||||
if mi, ok := _GetMonitorInfoW_Ex(handle); ok {
|
||||
if windows.UTF16ToString(mi.szDevice[:]) == monitor.win32.adapterName {
|
||||
monitor.win32.handle = handle
|
||||
if windows.UTF16ToString(mi.szDevice[:]) == monitor.platform.adapterName {
|
||||
monitor.platform.handle = handle
|
||||
}
|
||||
}
|
||||
return 1
|
||||
@ -47,12 +47,12 @@ func createMonitor(adapter *_DISPLAY_DEVICEW, display *_DISPLAY_DEVICEW) (*Monit
|
||||
}
|
||||
|
||||
if adapter.StateFlags&_DISPLAY_DEVICE_MODESPRUNED != 0 {
|
||||
monitor.win32.modesPruned = true
|
||||
monitor.platform.modesPruned = true
|
||||
}
|
||||
|
||||
monitor.win32.adapterName = adapterDeviceName
|
||||
monitor.platform.adapterName = adapterDeviceName
|
||||
if display != nil {
|
||||
monitor.win32.displayName = windows.UTF16ToString(display.DeviceName[:])
|
||||
monitor.platform.displayName = windows.UTF16ToString(display.DeviceName[:])
|
||||
}
|
||||
|
||||
rect := _RECT{
|
||||
@ -103,7 +103,7 @@ adapterLoop:
|
||||
}
|
||||
|
||||
for i, monitor := range disconnected {
|
||||
if monitor != nil && monitor.win32.displayName == windows.UTF16ToString(display.DeviceName[:]) {
|
||||
if monitor != nil && monitor.platform.displayName == windows.UTF16ToString(display.DeviceName[:]) {
|
||||
disconnected[i] = nil
|
||||
err := _EnumDisplayMonitors(0, nil, monitorCallbackPtr, _LPARAM(unsafe.Pointer(_glfw.monitors[i])))
|
||||
if err != nil {
|
||||
@ -132,7 +132,7 @@ adapterLoop:
|
||||
// (as sometimes happens), add it directly as a monitor
|
||||
if !found {
|
||||
for i, monitor := range disconnected {
|
||||
if monitor != nil && monitor.win32.displayName == windows.UTF16ToString(adapter.DeviceName[:]) {
|
||||
if monitor != nil && monitor.platform.displayName == windows.UTF16ToString(adapter.DeviceName[:]) {
|
||||
disconnected[i] = nil
|
||||
continue adapterLoop
|
||||
}
|
||||
@ -184,9 +184,9 @@ func (m *Monitor) setVideoModeWin32(desired *VidMode) error {
|
||||
if dm.dmBitsPerPel < 15 || dm.dmBitsPerPel >= 24 {
|
||||
dm.dmBitsPerPel = 32
|
||||
}
|
||||
switch _ChangeDisplaySettingsExW(m.win32.adapterName, &dm, 0, _CDS_FULLSCREEN, nil) {
|
||||
switch _ChangeDisplaySettingsExW(m.platform.adapterName, &dm, 0, _CDS_FULLSCREEN, nil) {
|
||||
case _DISP_CHANGE_SUCCESSFUL:
|
||||
m.win32.modeChanged = true
|
||||
m.platform.modeChanged = true
|
||||
return nil
|
||||
case _DISP_CHANGE_BADDUALVIEW:
|
||||
return errors.New("goglfw: the system uses DualView at Monitor.setVideoModeWin32")
|
||||
@ -208,9 +208,9 @@ func (m *Monitor) setVideoModeWin32(desired *VidMode) error {
|
||||
}
|
||||
|
||||
func (m *Monitor) restoreVideoModeWin32() {
|
||||
if m.win32.modeChanged {
|
||||
_ChangeDisplaySettingsExW(m.win32.adapterName, nil, 0, _CDS_FULLSCREEN, nil)
|
||||
m.win32.modeChanged = false
|
||||
if m.platform.modeChanged {
|
||||
_ChangeDisplaySettingsExW(m.platform.adapterName, nil, 0, _CDS_FULLSCREEN, nil)
|
||||
m.platform.modeChanged = false
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ func (m *Monitor) platformGetMonitorPos() (xpos, ypos int, ok bool) {
|
||||
return 0, 0, true
|
||||
}
|
||||
|
||||
dm, ok := _EnumDisplaySettingsExW(m.win32.adapterName, _ENUM_CURRENT_SETTINGS, _EDS_ROTATEDMODE)
|
||||
dm, ok := _EnumDisplaySettingsExW(m.platform.adapterName, _ENUM_CURRENT_SETTINGS, _EDS_ROTATEDMODE)
|
||||
if !ok {
|
||||
return 0, 0, false
|
||||
}
|
||||
@ -256,7 +256,7 @@ func (m *Monitor) platformGetMonitorContentScale() (xscale, yscale float32, err
|
||||
return 1, 1, nil
|
||||
}
|
||||
|
||||
return getMonitorContentScaleWin32(m.win32.handle)
|
||||
return getMonitorContentScaleWin32(m.platform.handle)
|
||||
}
|
||||
|
||||
func (m *Monitor) platformGetMonitorWorkarea() (xpos, ypos, width, height int) {
|
||||
@ -265,7 +265,7 @@ func (m *Monitor) platformGetMonitorWorkarea() (xpos, ypos, width, height int) {
|
||||
return 0, 0, w, h
|
||||
}
|
||||
|
||||
mi, ok := _GetMonitorInfoW(m.win32.handle)
|
||||
mi, ok := _GetMonitorInfoW(m.platform.handle)
|
||||
if !ok {
|
||||
return 0, 0, 0, 0
|
||||
}
|
||||
@ -280,7 +280,7 @@ func (m *Monitor) platformAppendVideoModes(monitors []*VidMode) ([]*VidMode, err
|
||||
origLen := len(monitors)
|
||||
loop:
|
||||
for modeIndex := uint32(0); ; modeIndex++ {
|
||||
dm, ok := _EnumDisplaySettingsW(m.win32.adapterName, modeIndex)
|
||||
dm, ok := _EnumDisplaySettingsW(m.platform.adapterName, modeIndex)
|
||||
if !ok {
|
||||
break
|
||||
}
|
||||
@ -307,9 +307,9 @@ loop:
|
||||
}
|
||||
}
|
||||
|
||||
if m.win32.modesPruned {
|
||||
if m.platform.modesPruned {
|
||||
// Skip modes not supported by the connected displays
|
||||
if _ChangeDisplaySettingsExW(m.win32.adapterName, &dm, 0, _CDS_TEST, nil) != _DISP_CHANGE_SUCCESSFUL {
|
||||
if _ChangeDisplaySettingsExW(m.platform.adapterName, &dm, 0, _CDS_TEST, nil) != _DISP_CHANGE_SUCCESSFUL {
|
||||
continue
|
||||
}
|
||||
}
|
||||
@ -330,7 +330,7 @@ func (m *Monitor) platformGetVideoMode() *VidMode {
|
||||
return m.modes[0]
|
||||
}
|
||||
|
||||
dm, _ := _EnumDisplaySettingsW(m.win32.adapterName, _ENUM_CURRENT_SETTINGS)
|
||||
dm, _ := _EnumDisplaySettingsW(m.platform.adapterName, _ENUM_CURRENT_SETTINGS)
|
||||
r, g, b := splitBPP(int(dm.dmBitsPerPel))
|
||||
return &VidMode{
|
||||
Width: int(dm.dmPelsWidth),
|
||||
@ -346,12 +346,12 @@ func (m *Monitor) in32Adapter() (string, error) {
|
||||
if !_glfw.initialized {
|
||||
return "", NotInitialized
|
||||
}
|
||||
return m.win32.adapterName, nil
|
||||
return m.platform.adapterName, nil
|
||||
}
|
||||
|
||||
func (m *Monitor) win32Monitor() (string, error) {
|
||||
if !_glfw.initialized {
|
||||
return "", NotInitialized
|
||||
}
|
||||
return m.win32.displayName, nil
|
||||
return m.platform.displayName, nil
|
||||
}
|
||||
|
@ -5,10 +5,98 @@
|
||||
|
||||
package goglfw
|
||||
|
||||
import "golang.org/x/sys/windows"
|
||||
|
||||
const (
|
||||
_GLFW_WNDCLASSNAME = "GLFW30"
|
||||
)
|
||||
|
||||
type platformWindowState struct {
|
||||
handle windows.HWND
|
||||
bigIcon _HICON
|
||||
smallIcon _HICON
|
||||
|
||||
cursorTracked bool
|
||||
frameAction bool
|
||||
iconified bool
|
||||
maximized bool
|
||||
transparent bool // Whether to enable framebuffer transparency on DWM
|
||||
scaleToMonitor bool
|
||||
|
||||
// Cached size used to filter out duplicate events
|
||||
width int
|
||||
height int
|
||||
|
||||
// The last received cursor position, regardless of source
|
||||
lastCursorPosX int
|
||||
lastCursorPosY int
|
||||
|
||||
// The last recevied high surrogate when decoding pairs of UTF-16 messages
|
||||
highSurrogate uint16
|
||||
}
|
||||
|
||||
type platformContextState struct {
|
||||
dc _HDC
|
||||
handle _HGLRC
|
||||
interval int
|
||||
}
|
||||
|
||||
type platformMonitorState struct {
|
||||
handle _HMONITOR
|
||||
|
||||
// This size matches the static size of DISPLAY_DEVICE.DeviceName
|
||||
adapterName string
|
||||
displayName string
|
||||
modesPruned bool
|
||||
modeChanged bool
|
||||
}
|
||||
|
||||
type platformCursorState struct {
|
||||
handle _HCURSOR
|
||||
}
|
||||
|
||||
type platformTLSState struct {
|
||||
allocated bool
|
||||
index uint32
|
||||
}
|
||||
|
||||
type platformLibraryWindowState struct {
|
||||
instance _HINSTANCE
|
||||
helperWindowHandle windows.HWND
|
||||
deviceNotificationHandle _HDEVNOTIFY
|
||||
acquiredMonitorCount int
|
||||
clipboardString string
|
||||
keycodes [512]Key
|
||||
scancodes [KeyLast + 1]int
|
||||
keynames [KeyLast + 1]string
|
||||
|
||||
// Where to place the cursor when re-enabled
|
||||
restoreCursorPosX float64
|
||||
restoreCursorPosY float64
|
||||
|
||||
// The window whose disabled cursor mode is active
|
||||
disabledCursorWindow *Window
|
||||
rawInput []byte
|
||||
mouseTrailSize uint32
|
||||
}
|
||||
|
||||
type platformLibraryContextState struct {
|
||||
inited bool
|
||||
|
||||
EXT_swap_control bool
|
||||
EXT_colorspace bool
|
||||
ARB_multisample bool
|
||||
ARB_framebuffer_sRGB bool
|
||||
EXT_framebuffer_sRGB bool
|
||||
ARB_pixel_format bool
|
||||
ARB_create_context bool
|
||||
ARB_create_context_profile bool
|
||||
EXT_create_context_es2_profile bool
|
||||
ARB_create_context_robustness bool
|
||||
ARB_create_context_no_error bool
|
||||
ARB_context_flush_control bool
|
||||
}
|
||||
|
||||
func _IsWindowsXPOrGreater() bool {
|
||||
return isWindowsVersionOrGreaterWin32(uint16(_HIBYTE(_WIN32_WINNT_WINXP)), uint16(_LOBYTE(_WIN32_WINNT_WINXP)), 0)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
package goglfw
|
||||
|
||||
func (t *tls) create() error {
|
||||
if t.win32.allocated {
|
||||
if t.platform.allocated {
|
||||
panic("goglfw: TLS must not be allocated")
|
||||
}
|
||||
|
||||
@ -14,34 +14,34 @@ func (t *tls) create() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t.win32.index = i
|
||||
t.win32.allocated = true
|
||||
t.platform.index = i
|
||||
t.platform.allocated = true
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tls) destroy() error {
|
||||
if t.win32.allocated {
|
||||
if err := _TlsFree(t.win32.index); err != nil {
|
||||
if t.platform.allocated {
|
||||
if err := _TlsFree(t.platform.index); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
t.win32.allocated = false
|
||||
t.win32.index = 0
|
||||
t.platform.allocated = false
|
||||
t.platform.index = 0
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tls) get() (uintptr, error) {
|
||||
if !t.win32.allocated {
|
||||
if !t.platform.allocated {
|
||||
panic("goglfw: TLS must be allocated")
|
||||
}
|
||||
|
||||
return _TlsGetValue(t.win32.index)
|
||||
return _TlsGetValue(t.platform.index)
|
||||
}
|
||||
|
||||
func (t *tls) set(value uintptr) error {
|
||||
if !t.win32.allocated {
|
||||
if !t.platform.allocated {
|
||||
panic("goglfw: TLS must be allocated")
|
||||
}
|
||||
|
||||
return _TlsSetValue(t.win32.index, value)
|
||||
return _TlsSetValue(t.platform.index, value)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user