Skip to content

Commit

Permalink
Fixes #170
Browse files Browse the repository at this point in the history
  • Loading branch information
tapir committed Aug 6, 2018
1 parent c4f752a commit ce778ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 4 additions & 4 deletions v3.3/glfw/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"unsafe"
)

var fJoystickHolder func(joy, event int)

// Joystick corresponds to a joystick.
type Joystick int

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions v3.3/glfw/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit ce778ad

Please sign in to comment.