Fixed rotating layouts; Added Shader layout
This commit is contained in:
13 files changed
+207
-93
No files matched your search
+45
-9
@@ -168,23 +168,34 @@ func (c *controllerContext) handleInput(event hardware.InputEvent) {
|
||||
switch event := event.(type) {
|
||||
case hardware.RotaryEvent:
|
||||
for _, layout := range c.layouts {
|
||||
if handler, ok := layout.(app.RotaryInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch rotary input")
|
||||
handler.HandleRotary(c, event.Delta)
|
||||
if layout.IsVisible() {
|
||||
if handler, ok := layout.(app.RotaryInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch rotary input")
|
||||
handler.HandleRotary(c, event.Delta)
|
||||
}
|
||||
}
|
||||
}
|
||||
case hardware.RotaryPressEvent:
|
||||
var handled bool
|
||||
for _, layout := range c.layouts {
|
||||
if handler, ok := layout.(app.ButtonInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch button press")
|
||||
handler.HandleButtonPress(c)
|
||||
if layout.IsVisible() {
|
||||
if handler, ok := layout.(app.ButtonInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch button press")
|
||||
handler.HandleButtonPress(c)
|
||||
handled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !handled {
|
||||
c.handleRotaryPress()
|
||||
}
|
||||
case hardware.RotaryLongPressEvent:
|
||||
for _, layout := range c.layouts {
|
||||
if handler, ok := layout.(app.ButtonInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch button long press")
|
||||
handler.HandleButtonLongPress(c)
|
||||
if layout.IsVisible() {
|
||||
if handler, ok := layout.(app.ButtonInputHandler); ok {
|
||||
log.WithField("layout", layout.String()).Debug("dispatch button long press")
|
||||
handler.HandleButtonLongPress(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
@@ -192,4 +203,29 @@ func (c *controllerContext) handleInput(event hardware.InputEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *controllerContext) handleRotaryPress() {
|
||||
log := logrus.NewEntry(logrus.StandardLogger())
|
||||
log.Debug("no handler for rotary press event, switching layouts")
|
||||
|
||||
var activeIndex int
|
||||
for i, layout := range c.layouts {
|
||||
if layout == c.active {
|
||||
activeIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if activeIndex == 0 {
|
||||
// We're in settings, shouldn't be able to get here since settings handle rotary press events
|
||||
log.Debug("huh? how did we get here?")
|
||||
return
|
||||
}
|
||||
|
||||
nextIndex := activeIndex + 1
|
||||
if nextIndex >= len(c.layouts) {
|
||||
nextIndex = 1
|
||||
}
|
||||
|
||||
c.Show(c.layouts[nextIndex])
|
||||
}
|
||||
|
||||
var _ app.Context = (*controllerContext)(nil)
|
||||
Reference in new issue
Block a user