demo / network-computer
Public
Copy of github.com/askrobots/network-computer (MIT): a desk you reach from anything. The original lives on GitHub.
GitStable demo
README: say this is a copy and where the original is
cde82c2
13 hours, 41 minutes ago
History
input.go · 787 bytes · 33 lines
| 1 | // Package input injects keyboard and mouse events into the host OS. |
| 2 | package input |
| 3 | |
| 4 | import ( |
| 5 | "log" |
| 6 | |
| 7 | "github.com/askrobots/network-computer/internal/proto" |
| 8 | ) |
| 9 | |
| 10 | // Injector turns InputEvents into OS events. |
| 11 | type Injector interface { |
| 12 | Handle(proto.InputEvent) |
| 13 | ReleaseAll() // release held buttons and keys, e.g. when a client drops |
| 14 | } |
| 15 | |
| 16 | // New returns the platform injector for the given display, or a logger when |
| 17 | // dryRun is set or the platform has no implementation yet. |
| 18 | func New(display int, dryRun bool) (Injector, error) { |
| 19 | if dryRun { |
| 20 | return logInjector{}, nil |
| 21 | } |
| 22 | return newPlatform(display) |
| 23 | } |
| 24 | |
| 25 | type logInjector struct{} |
| 26 | |
| 27 | func (logInjector) Handle(e proto.InputEvent) { |
| 28 | if e.T == "mm" { |
| 29 | return // too chatty |
| 30 | } |
| 31 | log.Printf("input: %+v", e) |
| 32 | } |
| 33 | func (logInjector) ReleaseAll() {} |