Example #1
0
// GetJoystickAxes returns a slice of axis values.
func GetJoystickAxes(joy Joystick) []float32 {
	var length int

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

	a := make([]float32, length)
	for i := 0; i < length; i++ {
		a[i] = float32(C.GetAxisAtIndex(axis, C.int(i)))
	}
	return a
}
Example #2
0
//GetJoystickAxes returns a slice of axis values.
func GetJoystickAxes(joy Joystick) ([]float32, error) {
	var length int

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

	a := make([]float32, length)
	for i := 0; i < length; i++ {
		a[i] = float32(C.GetAxisAtIndex(axis, C.int(i)))
	}

	return a, nil
}