machine/usb/hid/joystick: allow joystick settings override
Этот коммит содержится в:
родитель
9e97566b5f
коммит
71b44e79b3
1 изменённых файлов: 17 добавлений и 2 удалений
|
@ -18,11 +18,26 @@ type joystick struct {
|
|||
|
||||
func init() {
|
||||
if Joystick == nil {
|
||||
Joystick = newJoystick()
|
||||
Joystick = newDefaultJoystick()
|
||||
}
|
||||
}
|
||||
|
||||
func newJoystick() *joystick {
|
||||
// UseSettings overrides the Joystick settings. This function must be
|
||||
// called from init().
|
||||
func UseSettings(def Definitions, rxHandlerFunc func(b []byte), setupFunc func(setup usb.Setup) bool, hidDesc []byte) *joystick {
|
||||
js := &joystick{
|
||||
buf: hid.NewRingBuffer(),
|
||||
State: def.NewState(),
|
||||
}
|
||||
if setupFunc == nil {
|
||||
setupFunc = js.setupFunc
|
||||
}
|
||||
machine.EnableJoystick(js.handler, rxHandlerFunc, setupFunc, hidDesc)
|
||||
Joystick = js
|
||||
return js
|
||||
}
|
||||
|
||||
func newDefaultJoystick() *joystick {
|
||||
def := DefaultDefinitions()
|
||||
js := &joystick{
|
||||
State: def.NewState(),
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче