-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
600 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package input | ||
|
||
import ( | ||
"reflect" | ||
|
||
gopi "github.com/djthorpe/gopi/v3" | ||
graph "github.com/djthorpe/gopi/v3/pkg/graph" | ||
) | ||
|
||
func init() { | ||
// Register gopi.InputManager | ||
graph.RegisterUnit(reflect.TypeOf(&Manager{}), reflect.TypeOf((*gopi.InputManager)(nil))) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package input | ||
|
||
import ( | ||
"sync" | ||
|
||
gopi "github.com/djthorpe/gopi/v3" | ||
) | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// TYPES | ||
|
||
type Manager struct { | ||
sync.RWMutex | ||
gopi.Unit | ||
gopi.Logger | ||
gopi.FilePoll | ||
|
||
devices map[uintptr]gopi.InputDevice | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// LIFECYCLE | ||
|
||
func (this *Manager) New(gopi.Config) error { | ||
this.Require(this.Logger, this.FilePoll) | ||
|
||
// Create devices | ||
this.devices = make(map[uintptr]gopi.InputDevice) | ||
|
||
return nil | ||
} | ||
|
||
func (this *Manager) Dispose() error { | ||
this.RWMutex.Lock() | ||
defer this.RWMutex.Unlock() | ||
|
||
// Free devices | ||
var result error | ||
this.devices = nil | ||
|
||
return result | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// PUBLIC METHODS | ||
|
||
func (this *Manager) Devices() []gopi.InputDevice { | ||
return nil | ||
} | ||
|
||
func (this *Manager) RegisterDevice(gopi.InputDevice) error { | ||
return gopi.ErrNotImplemented | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// PRIVATE METHODS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// +build linux | ||
|
||
package input_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
gopi "github.com/djthorpe/gopi/v3" | ||
tool "github.com/djthorpe/gopi/v3/pkg/tool" | ||
|
||
_ "github.com/djthorpe/gopi/v3/pkg/file" | ||
) | ||
|
||
type InputApp struct { | ||
gopi.Unit | ||
gopi.Logger | ||
gopi.InputManager | ||
} | ||
|
||
func (this *InputApp) Run(ctx context.Context) error { | ||
<-ctx.Done() | ||
return ctx.Err() | ||
} | ||
|
||
func Test_InputManager_001(t *testing.T) { | ||
tool.Test(t, nil, new(InputApp), func(app *InputApp) { | ||
app.Require(app.Logger, app.InputManager) | ||
}) | ||
} |
Oops, something went wrong.