transpose next buffer state calculation
This commit is contained in:
parent
7476d7cdc7
commit
292df72709
@ -124,47 +124,37 @@ impl MouseInterpolator{
|
|||||||
}
|
}
|
||||||
// replace_with allows the enum variant to safely be replaced from behind a mutable reference
|
// replace_with allows the enum variant to safely be replaced from behind a mutable reference
|
||||||
let (ins_mouse,ins_other)=replace_with::replace_with_or_abort_and_return(&mut self.buffer_state,|buffer_state|{
|
let (ins_mouse,ins_other)=replace_with::replace_with_or_abort_and_return(&mut self.buffer_state,|buffer_state|{
|
||||||
let next_state=match buffer_state{
|
match ins.instruction.instruction{
|
||||||
BufferState::Unbuffered=>{
|
Instruction::MoveMouse(pos)=>{
|
||||||
if let Instruction::MoveMouse(pos)=ins.instruction.instruction{
|
let next_mouse_state=MouseState{pos,time:ins.instruction.time};
|
||||||
return ((None,None),BufferState::Initializing(ins.time,MouseState{pos,time:ins.instruction.time}));
|
match buffer_state{
|
||||||
|
BufferState::Unbuffered=>{
|
||||||
|
((None,None),BufferState::Initializing(ins.time,next_mouse_state))
|
||||||
|
},
|
||||||
|
BufferState::Initializing(_time,mouse_state)=>{
|
||||||
|
let ins_mouse=TimedInstruction{
|
||||||
|
time:mouse_state.time,
|
||||||
|
instruction:MouseInstruction::ReplaceMouse{
|
||||||
|
m0:mouse_state,
|
||||||
|
m1:next_mouse_state.clone(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
((Some(ins_mouse),None),BufferState::Buffered(ins.time,next_mouse_state))
|
||||||
|
},
|
||||||
|
BufferState::Buffered(_time,mouse_state)=>{
|
||||||
|
let ins_mouse=TimedInstruction{
|
||||||
|
time:mouse_state.time,
|
||||||
|
instruction:MouseInstruction::SetNextMouse(next_mouse_state.clone()),
|
||||||
|
};
|
||||||
|
((Some(ins_mouse),None),BufferState::Buffered(ins.time,next_mouse_state))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
BufferState::Unbuffered
|
|
||||||
},
|
},
|
||||||
BufferState::Initializing(time,mouse_state)=>{
|
Instruction::Other(other_instruction)=>((None,Some(TimedInstruction{
|
||||||
if let Instruction::MoveMouse(pos)=ins.instruction.instruction{
|
|
||||||
let next_mouse_state=MouseState{pos,time:ins.instruction.time};
|
|
||||||
let ins_mouse=TimedInstruction{
|
|
||||||
time:mouse_state.time,
|
|
||||||
instruction:MouseInstruction::ReplaceMouse{
|
|
||||||
m0:mouse_state,
|
|
||||||
m1:next_mouse_state.clone(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
return ((Some(ins_mouse),None),BufferState::Buffered(ins.time,next_mouse_state));
|
|
||||||
}
|
|
||||||
BufferState::Initializing(time,mouse_state)
|
|
||||||
},
|
|
||||||
BufferState::Buffered(time,mouse_state)=>{
|
|
||||||
if let Instruction::MoveMouse(pos)=ins.instruction.instruction{
|
|
||||||
let next_mouse_state=MouseState{pos,time:ins.instruction.time};
|
|
||||||
let ins_mouse=TimedInstruction{
|
|
||||||
time:mouse_state.time,
|
|
||||||
instruction:MouseInstruction::SetNextMouse(next_mouse_state.clone()),
|
|
||||||
};
|
|
||||||
return ((Some(ins_mouse),None),BufferState::Buffered(ins.time,next_mouse_state));
|
|
||||||
}
|
|
||||||
BufferState::Buffered(time,mouse_state)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let ins_other=match ins.instruction.instruction{
|
|
||||||
Instruction::MoveMouse(_)=>None,
|
|
||||||
Instruction::Other(other_instruction)=>Some(TimedInstruction{
|
|
||||||
time:ins.instruction.time,
|
time:ins.instruction.time,
|
||||||
instruction:other_instruction,
|
instruction:other_instruction,
|
||||||
}),
|
})),buffer_state),
|
||||||
};
|
}
|
||||||
((None,ins_other),next_state)
|
|
||||||
});
|
});
|
||||||
if let Some(ins)=ins_mouse{
|
if let Some(ins)=ins_mouse{
|
||||||
self.push_mouse(ins);
|
self.push_mouse(ins);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user