Start implementing a channel for timer-based events.
This commit is contained in:
parent
f12d119116
commit
bf1bb868e5
2 changed files with 50 additions and 23 deletions
|
@ -69,7 +69,15 @@ func main() {
|
|||
mapEvents(vBuffers, pDevices, rules)
|
||||
}
|
||||
|
||||
type ChannelEventType int
|
||||
|
||||
const (
|
||||
ChannelEventInput ChannelEventType = iota
|
||||
ChannelEventTimer
|
||||
)
|
||||
|
||||
type ChannelEvent struct {
|
||||
Type ChannelEventType
|
||||
Device *evdev.InputDevice
|
||||
Event *evdev.InputEvent
|
||||
}
|
||||
|
@ -89,6 +97,8 @@ func mapEvents(vBuffers map[string]*virtualdevice.EventBuffer, pDevices map[stri
|
|||
// Get an event (blocks if necessary)
|
||||
wrapper := <-eventChannel
|
||||
|
||||
switch wrapper.Type {
|
||||
case ChannelEventInput:
|
||||
switch wrapper.Event.Type {
|
||||
case evdev.EV_SYN:
|
||||
// We've received a SYN_REPORT, so now we send all of our pending events
|
||||
|
@ -115,6 +125,11 @@ func mapEvents(vBuffers map[string]*virtualdevice.EventBuffer, pDevices map[stri
|
|||
default:
|
||||
logger.Logf("DEBUG: Unprocessed event: %d %d %d", wrapper.Event.Type, wrapper.Event.Code, wrapper.Event.Value)
|
||||
}
|
||||
case ChannelEventTimer:
|
||||
// Timer events give us the device and event to use directly
|
||||
// TODO: we need a vbuffer map with device keys
|
||||
// vBuffers[wrapper.Device].AddEvent(wrapper.Event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package mappingrules
|
||||
|
||||
import "github.com/holoplot/go-evdev"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/holoplot/go-evdev"
|
||||
)
|
||||
|
||||
type MappingRule interface {
|
||||
MatchEvent(*evdev.InputDevice, *evdev.InputEvent, *string) *evdev.InputEvent
|
||||
|
@ -32,6 +36,14 @@ type LatchedMappingRule struct {
|
|||
State bool
|
||||
}
|
||||
|
||||
// TODO: How are we going to implement this? It needs to operate on a timer...
|
||||
type ProportionalAxisMappingRule struct {
|
||||
MappingRuleBase
|
||||
Input RuleTarget
|
||||
Output RuleTarget
|
||||
LastEvent time.Time
|
||||
}
|
||||
|
||||
type RuleTarget struct {
|
||||
DeviceName string
|
||||
ModeSelect []string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue