コード例 #1
0
func NewJoystickAdaptor(name string) *JoystickAdaptor {
	return &JoystickAdaptor{
		connect: func(j *JoystickAdaptor) {
			sdl.Init(sdl.INIT_JOYSTICK)
			if sdl.NumJoysticks() > 0 {
				j.joystick = sdl.JoystickOpen(0)
			} else {
				panic("No joystick available")
			}
		},
	}
}
コード例 #2
0
ファイル: joystick_adaptor.go プロジェクト: aryanugroho/gobot
// NewJoystickAdaptor returns a new JoystickAdaptor with specified name.
func NewJoystickAdaptor(name string) *JoystickAdaptor {
	return &JoystickAdaptor{
		name: name,
		connect: func(j *JoystickAdaptor) (err error) {
			sdl.Init(sdl.INIT_JOYSTICK)
			if sdl.NumJoysticks() > 0 {
				j.joystick = sdl.JoystickOpen(0)
				return
			}
			return errors.New("No joystick available")
		},
	}
}