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
productID: 0x285
mappings:
- type: button
- comment: Play left
type: button
midiChannel: 1
midiKey: 7
button: south
- type: control
- comment: Volume left
type: control
midiChannel: 1
midiController: 0
axis: left-y

View File

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