Ejemplo n.º 1
0
// GetJoystickButtons returns a slice of button values.
func GetJoystickButtons(joy Joystick) []byte {
	var length int

	buttons := C.glfwGetJoystickButtons(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
	panicError()
	if buttons == nil {
		return nil
	}

	b := make([]byte, length)
	for i := 0; i < length; i++ {
		b[i] = byte(C.GetButtonsAtIndex(buttons, C.int(i)))
	}
	return b
}
Ejemplo n.º 2
0
//GetJoystickButtons returns a slice of button values.
func GetJoystickButtons(joy Joystick) ([]byte, error) {
	var length int

	buttons := C.glfwGetJoystickButtons(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
	if buttons == nil {
		return nil, errors.New("Joystick is not present.")
	}

	b := make([]byte, length)
	for i := 0; i < length; i++ {
		b[i] = byte(C.GetButtonsAtIndex(buttons, C.int(i)))
	}

	return b, nil
}