feat(logging): Now logging triggered mappings

This commit is contained in:
2025-08-05 21:02:28 +02:00
parent f0e04b1964
commit 6c49a4a028
2 changed files with 9 additions and 2 deletions

View File

@@ -3,11 +3,13 @@ controller:
vendorID: 0x45e vendorID: 0x45e
productID: 0x285 productID: 0x285
mappings: mappings:
- type: button - comment: Play left
type: button
midiChannel: 1 midiChannel: 1
midiKey: 7 midiKey: 7
button: south button: south
- type: control - comment: Volume left
type: control
midiChannel: 1 midiChannel: 1
midiController: 0 midiController: 0
axis: left-y axis: left-y

View File

@@ -2,6 +2,7 @@ package main
import ( import (
"fmt" "fmt"
"log"
"gitlab.com/gomidi/midi/v2" "gitlab.com/gomidi/midi/v2"
"github.com/bendahl/uinput" "github.com/bendahl/uinput"
@@ -35,8 +36,10 @@ func (m ButtonMapping) TriggerIfMatch(msg midi.Message, virtGamepad uinput.Gamep
if m.Is(msg) { if m.Is(msg) {
switch msg.Type() { switch msg.Type() {
case midi.NoteOnMsg: case midi.NoteOnMsg:
log.Printf("%s: Button down\n", m.comment)
return virtGamepad.ButtonDown(m.gamepadKey) return virtGamepad.ButtonDown(m.gamepadKey)
case midi.NoteOffMsg: case midi.NoteOffMsg:
log.Printf("%s: Button up\n", m.comment)
return virtGamepad.ButtonUp(m.gamepadKey) return virtGamepad.ButtonUp(m.gamepadKey)
default: default:
return fmt.Errorf("Invalid message type triggered ButtonMapping") return fmt.Errorf("Invalid message type triggered ButtonMapping")
@@ -93,6 +96,8 @@ func (m ControlMapping) TriggerIfMatch(msg midi.Message, virtGamepad uinput.Game
valueNormalised -= 1 valueNormalised -= 1
} }
log.Printf("%s: value %v\n", m.comment, valueNormalised)
switch m.axis { switch m.axis {
case LeftX: case LeftX:
return virtGamepad.LeftStickMoveX(valueNormalised) return virtGamepad.LeftStickMoveX(valueNormalised)