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") } }, } }
// 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") }, } }