diff --git a/README.md b/README.md index e1b4cef1..1a8c8483 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ func main() { * Added hint `CocoaMenubar`. * Added hint `TransparentFramebuffer`. * Added hint value `OSMesaContextAPI`. +* `MonitorEvent` renamed to `PeripheralEvent` for reuse with joystick events. * `Init` Returns `bool` instead of error. * `Joystick.GetButtons` Returns `[]Action` instead of `[]byte`. * `SetMonitorCallback` Returns `MonitorCallback`. diff --git a/v3.3/glfw/input.go b/v3.3/glfw/input.go index de25e813..748f25af 100644 --- a/v3.3/glfw/input.go +++ b/v3.3/glfw/input.go @@ -23,8 +23,6 @@ import ( "unsafe" ) -var fJoystickHolder func(joy, event int) - // Joystick corresponds to a joystick. type Joystick int @@ -308,7 +306,7 @@ const ( ) // JoystickCallback is the joystick configuration callback. -type JoystickCallback func(joy, event int) +type JoystickCallback func(joy Joystick, event PeripheralEvent) // KeyCallback is the key callback. type KeyCallback func(w *Window, key Key, scancode int, action Action, mods ModifierKey) @@ -345,9 +343,11 @@ type GamepadState struct { Axes [6]float32 } +var fJoystickHolder JoystickCallback + //export goJoystickCB func goJoystickCB(joy, event C.int) { - fJoystickHolder(int(joy), int(event)) + fJoystickHolder(Joystick(joy), PeripheralEvent(event)) } //export goMouseButtonCB diff --git a/v3.3/glfw/monitor.go b/v3.3/glfw/monitor.go index 6491415d..decdf35c 100644 --- a/v3.3/glfw/monitor.go +++ b/v3.3/glfw/monitor.go @@ -17,8 +17,8 @@ type Monitor struct { data *C.GLFWmonitor } -// MonitorEvent corresponds to a monitor configuration event. -type MonitorEvent int +// PeripheralEvent corresponds to a monitor configuration event. +type PeripheralEvent int // GammaRamp describes the gamma ramp for a monitor. type GammaRamp struct { @@ -27,10 +27,10 @@ type GammaRamp struct { Blue []uint16 // A slice of value describing the response of the blue channel. } -// Monitor events. +// Peripheral events. const ( - Connected MonitorEvent = C.GLFW_CONNECTED - Disconnected MonitorEvent = C.GLFW_DISCONNECTED + Connected PeripheralEvent = C.GLFW_CONNECTED + Disconnected PeripheralEvent = C.GLFW_DISCONNECTED ) // VidMode describes a single video mode. @@ -44,13 +44,13 @@ type VidMode struct { } // MonitorCallback is the signature of a monitor callback function -type MonitorCallback func(monitor *Monitor, event MonitorEvent) +type MonitorCallback func(monitor *Monitor, event PeripheralEvent) var fMonitorHolder MonitorCallback //export goMonitorCB func goMonitorCB(monitor unsafe.Pointer, event C.int) { - fMonitorHolder(&Monitor{(*C.GLFWmonitor)(monitor)}, MonitorEvent(event)) + fMonitorHolder(&Monitor{(*C.GLFWmonitor)(monitor)}, PeripheralEvent(event)) } // GetMonitors returns a slice of handles for all currently connected monitors.