Implement axis targets, axis -> button and axis -> relative axis mappings. (#1)

Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com>
Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
Anna Rose Wiggins 2025-07-15 19:55:19 +00:00 committed by Anna Rose Wiggins
parent ff38db6596
commit e617a6eda6
25 changed files with 903 additions and 130 deletions

View file

@ -75,7 +75,7 @@ func main() {
timerCount := 0
for _, rule := range rules {
if timedRule, ok := rule.(*mappingrules.MappingRuleAxisToButton); ok {
if timedRule, ok := rule.(mappingrules.TimedEventEmitter); ok {
go timerWatcher(timedRule, eventChannel)
timerCount++
}
@ -95,7 +95,8 @@ func main() {
case ChannelEventInput:
switch channelEvent.Event.Type {
case evdev.EV_SYN:
// We've received a SYN_REPORT, so now we send all of our pending events
// We've received a SYN_REPORT, so now we send all pending events; since SYN_REPORTs
// might come from multiple input devices, we'll always flush, just to be sure.
for _, buffer := range vBuffersByName {
buffer.SendEvents()
}
@ -114,6 +115,8 @@ func main() {
case ChannelEventTimer:
// Timer events give us the device and event to use directly
vBuffersByDevice[channelEvent.Device].AddEvent(channelEvent.Event)
// If we get a timer event, flush the output device buffer immediately
vBuffersByDevice[channelEvent.Device].SendEvents()
}
}
}

View file

@ -9,7 +9,7 @@ import (
)
const (
TimerCheckIntervalMs = 250
TimerCheckIntervalMs = 1
DeviceCheckIntervalMs = 1
)
@ -28,12 +28,12 @@ func eventWatcher(device *evdev.InputDevice, channel chan<- ChannelEvent) {
}
}
func timerWatcher(rule *mappingrules.MappingRuleAxisToButton, channel chan<- ChannelEvent) {
func timerWatcher(rule mappingrules.TimedEventEmitter, channel chan<- ChannelEvent) {
for {
event := rule.TimerEvent()
if event != nil {
channel <- ChannelEvent{
Device: rule.Output.Device,
Device: rule.GetOutputDevice(),
Event: event,
Type: ChannelEventTimer,
}