Beispiel #1
0
func Keystate(key string) int {
	if key == "joy1stick1x" {
		makestickopened()
		return int(C.SDL_JoystickGetAxis(joy, 0))
	}
	if key == "joy1stick1y" {
		makestickopened()
		return int(C.SDL_JoystickGetAxis(joy, 1))
	}
	if key == "joy1stick2x" {
		makestickopened()
		return int(C.SDL_JoystickGetAxis(joy, 3))
	}
	if key == "joy1stick2y" {
		makestickopened()
		return int(C.SDL_JoystickGetAxis(joy, 4))
	}
	if key == "joy1a" {
		makestickopened()
		return int(C.SDL_JoystickGetButton(joy, 0))
	}
	var length C.int
	keys := C.SDL_GetKeyboardState(&length)
	return int(*(*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(keys)) + uintptr(str2scancode(key))))) //letter scancodes start at 4

}
Beispiel #2
0
// Get the current state of an axis control on a joystick. The axis
// indices start at index 0. The state is a value ranging from -32768
// to 32767.
func (joystick *Joystick) GetAxis(axis int) int16 {
	return int16(C.SDL_JoystickGetAxis(joystick.cJoystick, C.int(axis)))
}
Beispiel #3
0
func (joystick *Joystick) GetAxis(axis int) int16 {
	_joystick := (*C.SDL_Joystick)(joystick)
	_axis := (C.int)(axis)
	return (int16)(C.SDL_JoystickGetAxis(_joystick, _axis))
}
Beispiel #4
0
// Joystick (https://wiki.libsdl.org/SDL_JoystickGetAxis)
func (joy *Joystick) GetAxis(axis int) int16 {
	return (int16)(C.SDL_JoystickGetAxis(joy.cptr(), C.int(axis)))
}
Beispiel #5
0
func (j *Joystick) GetAxis(n int) int16 {
	return int16(C.SDL_JoystickGetAxis((*C.SDL_Joystick)(unsafe.Pointer(j)), C.int(n)))
}
Beispiel #6
0
// Get the current state of an axis control on a joystick
// The state is a value ranging from -32768 to 32767.
// The axis indices start at index 0.
func JoystickGetAxis(joystick *C.SDL_Joystick, axis int) int16 {
	return int16(C.SDL_JoystickGetAxis(joystick, C.int(axis)))
}