fix underflow on debug build
This commit is contained in:
@@ -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()?;
|
||||
@@ -181,9 +185,13 @@ impl ControlMode for MetaMode {
|
||||
fn on_dial(&mut self, _haptics: &DialHaptics, delta: i32) -> DynResult<()> {
|
||||
if delta > 0 {
|
||||
self.current_mode += 1;
|
||||
} else {
|
||||
if self.current_mode == 0 {
|
||||
self.current_mode = self.metas.len() - 1;
|
||||
} else {
|
||||
self.current_mode -= 1;
|
||||
}
|
||||
};
|
||||
|
||||
self.current_mode %= self.metas.len();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user