1
0

fix underflow on debug build

This commit is contained in:
Daniel Prilik
2020-11-02 18:47:56 -05:00
parent a099750be2
commit 636a12f2e6

View File

@@ -60,7 +60,11 @@ impl DialController {
}
pub fn run(&mut self) -> DynResult<()> {
self.modes[0].on_start(self.device.haptics())?;
let initial_mode = match self.active_mode {
ActiveMode::Normal(i) => i,
ActiveMode::Meta => 0,
};
self.modes[initial_mode].on_start(self.device.haptics())?;
loop {
let evt = self.device.next_event()?;
@@ -182,8 +186,12 @@ impl ControlMode for MetaMode {
if delta > 0 {
self.current_mode += 1;
} else {
self.current_mode -= 1;
}
if self.current_mode == 0 {
self.current_mode = self.metas.len() - 1;
} else {
self.current_mode -= 1;
}
};
self.current_mode %= self.metas.len();