feat(Controller): Added error logging in update loop
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
|
|
||||||
"gitlab.com/gomidi/midi/v2"
|
"gitlab.com/gomidi/midi/v2"
|
||||||
"github.com/bendahl/uinput"
|
"github.com/bendahl/uinput"
|
||||||
)
|
)
|
||||||
@@ -53,6 +55,9 @@ func (c Controller) Stop() {
|
|||||||
|
|
||||||
func (c Controller) update(msg midi.Message) {
|
func (c Controller) update(msg midi.Message) {
|
||||||
for _, mapping := range c.mappings {
|
for _, mapping := range c.mappings {
|
||||||
mapping.TriggerIfMatch(msg, c.virtGamepad)
|
err := mapping.TriggerIfMatch(msg, c.virtGamepad)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error in Mapping \"%s\": %v\n", mapping.Comment(), err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ import (
|
|||||||
type Mapping interface {
|
type Mapping interface {
|
||||||
Is(midi.Message) bool
|
Is(midi.Message) bool
|
||||||
TriggerIfMatch(midi.Message, uinput.Gamepad) error
|
TriggerIfMatch(midi.Message, uinput.Gamepad) error
|
||||||
|
Comment() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type ButtonMapping struct {
|
type ButtonMapping struct {
|
||||||
@@ -45,6 +46,10 @@ func (m ButtonMapping) TriggerIfMatch(msg midi.Message, virtGamepad uinput.Gamep
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m ButtonMapping) Comment() string {
|
||||||
|
return m.comment
|
||||||
|
}
|
||||||
|
|
||||||
type ControllerAxis int
|
type ControllerAxis int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -102,3 +107,7 @@ func (m ControlMapping) TriggerIfMatch(msg midi.Message, virtGamepad uinput.Game
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m ControlMapping) Comment() string {
|
||||||
|
return m.comment
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user