2018-12-29 11:20:41 +01:00
|
|
|
// Copyright 2018 The Ebiten 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.
|
|
|
|
|
2021-06-10 18:03:35 +02:00
|
|
|
//go:build !js
|
2020-10-06 19:20:04 +02:00
|
|
|
|
2018-12-29 11:20:41 +01:00
|
|
|
package glfw
|
|
|
|
|
2018-12-30 07:35:49 +01:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2018-12-29 18:44:51 +01:00
|
|
|
type (
|
2022-05-18 18:04:15 +02:00
|
|
|
Action int
|
|
|
|
ErrorCode int
|
|
|
|
Hint int
|
|
|
|
InputMode int
|
|
|
|
Key int
|
|
|
|
ModifierKey int
|
|
|
|
MouseButton int
|
|
|
|
PeripheralEvent int
|
|
|
|
StandardCursor int
|
2018-12-29 18:44:51 +01:00
|
|
|
)
|
|
|
|
|
2018-12-29 11:20:41 +01:00
|
|
|
const (
|
2021-04-16 19:27:04 +02:00
|
|
|
DontCare = -1
|
|
|
|
False = 0
|
|
|
|
True = 1
|
2018-12-29 11:20:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
Release = Action(0)
|
|
|
|
Press = Action(1)
|
|
|
|
Repeat = Action(2)
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-10-03 20:04:44 +02:00
|
|
|
ModAlt = ModifierKey(0x0004)
|
|
|
|
ModCapsLock = ModifierKey(0x0010)
|
|
|
|
ModControl = ModifierKey(0x0002)
|
|
|
|
ModNumLock = ModifierKey(0x0020)
|
|
|
|
ModShift = ModifierKey(0x0001)
|
|
|
|
ModSuper = ModifierKey(0x0008)
|
2018-12-29 11:20:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-10-03 20:04:44 +02:00
|
|
|
MouseButton1 = MouseButton(0)
|
|
|
|
MouseButton2 = MouseButton(1)
|
|
|
|
MouseButton3 = MouseButton(2)
|
|
|
|
MouseButton4 = MouseButton(3)
|
|
|
|
MouseButton5 = MouseButton(4)
|
|
|
|
MouseButton6 = MouseButton(5)
|
|
|
|
MouseButton7 = MouseButton(6)
|
|
|
|
MouseButton8 = MouseButton(7)
|
|
|
|
MouseButtonLast = MouseButton8
|
|
|
|
MouseButtonLeft = MouseButton1
|
|
|
|
MouseButtonRight = MouseButton2
|
|
|
|
MouseButtonMiddle = MouseButton3
|
2018-12-29 11:20:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-10-03 20:04:44 +02:00
|
|
|
AccumAlphaBits = Hint(0x0002100A)
|
|
|
|
AccumBlueBits = Hint(0x00021009)
|
|
|
|
AccumGreenBits = Hint(0x00021008)
|
|
|
|
AccumRedBits = Hint(0x00021007)
|
|
|
|
AlphaBits = Hint(0x00021004)
|
|
|
|
AutoIconify = Hint(0x00020006)
|
|
|
|
AuxBuffers = Hint(0x0002100B)
|
|
|
|
BlueBits = Hint(0x00021003)
|
|
|
|
CenterCursor = Hint(0x00020009)
|
|
|
|
ClientAPI = Hint(0x00022001)
|
|
|
|
ContextCreationAPI = Hint(0x0002200B)
|
|
|
|
ContextNoError = Hint(0x0002200A)
|
|
|
|
ContextReleaseBehavior = Hint(0x00022009)
|
|
|
|
ContextRevision = Hint(0x00022004)
|
|
|
|
ContextRobustness = Hint(0x00022005)
|
|
|
|
ContextVersionMajor = Hint(0x00022002)
|
|
|
|
ContextVersionMinor = Hint(0x00022003)
|
|
|
|
Decorated = Hint(0x00020005)
|
|
|
|
DepthBits = Hint(0x00021005)
|
|
|
|
DoubleBuffer = Hint(0x00021010)
|
|
|
|
Floating = Hint(0x00020007)
|
|
|
|
Focused = Hint(0x00020001)
|
|
|
|
FocusOnShow = Hint(0x0002000C)
|
|
|
|
GreenBits = Hint(0x00021002)
|
|
|
|
Hovered = Hint(0x0002000B)
|
|
|
|
Iconified = Hint(0x00020002)
|
|
|
|
Maximized = Hint(0x00020008)
|
|
|
|
MousePassthrough = Hint(0x0002000D)
|
|
|
|
OpenGLDebugContext = Hint(0x00022007)
|
|
|
|
OpenGLForwardCompat = Hint(0x00022006)
|
|
|
|
OpenGLProfile = Hint(0x00022008)
|
|
|
|
RedBits = Hint(0x00021001)
|
|
|
|
RefreshRate = Hint(0x0002100F)
|
|
|
|
Resizable = Hint(0x00020003)
|
|
|
|
Samples = Hint(0x0002100D)
|
|
|
|
ScaleToMonitor = Hint(0x0002200C)
|
|
|
|
SRGBCapable = Hint(0x0002100E)
|
|
|
|
StencilBits = Hint(0x00021006)
|
|
|
|
Stereo = Hint(0x0002100C)
|
|
|
|
TransparentFramebuffer = Hint(0x0002000A)
|
|
|
|
Visible = Hint(0x00020004)
|
2018-12-29 11:20:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
CursorMode = InputMode(0x00033001)
|
2023-10-03 20:04:44 +02:00
|
|
|
LockKeyMods = InputMode(0x00033004)
|
|
|
|
RawMouseMotion = InputMode(0x00033005)
|
2018-12-29 11:20:41 +01:00
|
|
|
StickyKeysMode = InputMode(0x00033002)
|
|
|
|
StickyMouseButtonsMode = InputMode(0x00033003)
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2023-10-03 20:04:44 +02:00
|
|
|
AnyReleaseBehavior = 0
|
|
|
|
CursorDisabled = 0x00034003
|
|
|
|
CursorHidden = 0x00034002
|
|
|
|
CursorNormal = 0x00034001
|
|
|
|
EGLContextAPI = 0x00036002
|
|
|
|
LoseContextOnReset = 0x00031002
|
|
|
|
NativeContextAPI = 0x00036001
|
|
|
|
NoAPI = 0
|
|
|
|
NoResetNotification = 0x00031001
|
|
|
|
NoRobustness = 0
|
|
|
|
OpenGLAPI = 0x00030001
|
|
|
|
OpenGLAnyProfile = 0
|
|
|
|
OpenGLCompatProfile = 0x00032002
|
|
|
|
OpenGLCoreProfile = 0x00032001
|
|
|
|
OpenGLESAPI = 0x00030002
|
|
|
|
OSMesaContextAPI = 0x00036003
|
|
|
|
ReleaseBehaviorFlush = 0x00035001
|
|
|
|
ReleaseBehaviorNone = 0x00035002
|
2018-12-29 11:20:41 +01:00
|
|
|
)
|
2018-12-30 07:35:49 +01:00
|
|
|
|
|
|
|
const (
|
|
|
|
NotInitialized = ErrorCode(0x00010001)
|
|
|
|
NoCurrentContext = ErrorCode(0x00010002)
|
|
|
|
InvalidEnum = ErrorCode(0x00010003)
|
|
|
|
InvalidValue = ErrorCode(0x00010004)
|
|
|
|
OutOfMemory = ErrorCode(0x00010005)
|
|
|
|
APIUnavailable = ErrorCode(0x00010006)
|
|
|
|
VersionUnavailable = ErrorCode(0x00010007)
|
|
|
|
PlatformError = ErrorCode(0x00010008)
|
|
|
|
FormatUnavailable = ErrorCode(0x00010009)
|
|
|
|
NoWindowContext = ErrorCode(0x0001000A)
|
|
|
|
)
|
|
|
|
|
2023-10-03 20:04:44 +02:00
|
|
|
func (e ErrorCode) Error() string {
|
2018-12-30 07:35:49 +01:00
|
|
|
switch e {
|
|
|
|
case NotInitialized:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "the GLFW library is not initialized"
|
2018-12-30 07:35:49 +01:00
|
|
|
case NoCurrentContext:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "there is no current context"
|
2018-12-30 07:35:49 +01:00
|
|
|
case InvalidEnum:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "invalid argument for enum parameter"
|
2018-12-30 07:35:49 +01:00
|
|
|
case InvalidValue:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "invalid value for parameter"
|
2018-12-30 07:35:49 +01:00
|
|
|
case OutOfMemory:
|
|
|
|
return "out of memory"
|
|
|
|
case APIUnavailable:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "the requested API is unavailable"
|
2018-12-30 07:35:49 +01:00
|
|
|
case VersionUnavailable:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "the requested API version is unavailable"
|
2018-12-30 07:35:49 +01:00
|
|
|
case PlatformError:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "a platform-specific error occurred"
|
2018-12-30 07:35:49 +01:00
|
|
|
case FormatUnavailable:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "the requested format is unavailable"
|
2018-12-30 07:35:49 +01:00
|
|
|
case NoWindowContext:
|
2023-10-03 20:04:44 +02:00
|
|
|
return "the specified window has no context"
|
2018-12-30 07:35:49 +01:00
|
|
|
default:
|
2023-10-03 20:04:44 +02:00
|
|
|
return fmt.Sprintf("GLFW error (%d)", e)
|
2018-12-30 07:35:49 +01:00
|
|
|
}
|
|
|
|
}
|
2021-04-11 07:21:38 +02:00
|
|
|
|
2023-10-03 20:04:44 +02:00
|
|
|
const (
|
|
|
|
Connected = PeripheralEvent(0x00040001)
|
|
|
|
Disconnected = PeripheralEvent(0x00040002)
|
|
|
|
)
|
|
|
|
|
2021-04-11 07:21:38 +02:00
|
|
|
const (
|
|
|
|
ArrowCursor = StandardCursor(0x00036001)
|
|
|
|
IBeamCursor = StandardCursor(0x00036002)
|
|
|
|
CrosshairCursor = StandardCursor(0x00036003)
|
|
|
|
HandCursor = StandardCursor(0x00036004)
|
|
|
|
HResizeCursor = StandardCursor(0x00036005)
|
|
|
|
VResizeCursor = StandardCursor(0x00036006)
|
2023-01-15 18:26:41 +01:00
|
|
|
|
|
|
|
// v3.4
|
|
|
|
ResizeNWSECursor = StandardCursor(0x00036007)
|
|
|
|
ResizeNESWCursor = StandardCursor(0x00036008)
|
|
|
|
ResizeAllCursor = StandardCursor(0x00036009)
|
|
|
|
NotAllowedCursor = StandardCursor(0x0003600A)
|
2021-04-11 07:21:38 +02:00
|
|
|
)
|