change some function names
This commit is contained in:
parent
ada34237c9
commit
d393f9f187
@ -62,7 +62,7 @@ impl MouseInterpolator{
|
|||||||
output:std::collections::VecDeque::new(),
|
output:std::collections::VecDeque::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn push_mouse(&mut self,ins:TimedInstruction<MouseInstruction,PhysicsTimeInner>){
|
fn push_mouse_and_flush_buffer(&mut self,ins:TimedInstruction<MouseInstruction,PhysicsTimeInner>){
|
||||||
self.buffer.push_front(TimedInstruction{
|
self.buffer.push_front(TimedInstruction{
|
||||||
time:ins.time,
|
time:ins.time,
|
||||||
instruction:PhysicsInputInstruction::Mouse(ins.instruction),
|
instruction:PhysicsInputInstruction::Mouse(ins.instruction),
|
||||||
@ -76,7 +76,7 @@ impl MouseInterpolator{
|
|||||||
self.output.append(&mut self.buffer);
|
self.output.append(&mut self.buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn get_timedout_at(&self,time_limit:SessionTime)->Option<SessionTime>{
|
fn get_mouse_timedout_at(&self,time_limit:SessionTime)->Option<SessionTime>{
|
||||||
match &self.buffer_state{
|
match &self.buffer_state{
|
||||||
BufferState::Unbuffered=>None,
|
BufferState::Unbuffered=>None,
|
||||||
BufferState::Initializing(time,_mouse_state)
|
BufferState::Initializing(time,_mouse_state)
|
||||||
@ -86,7 +86,7 @@ impl MouseInterpolator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn timeout(&mut self,time:PhysicsTime){
|
fn timeout_mouse(&mut self,time:PhysicsTime){
|
||||||
let buffer_state=core::mem::replace(&mut self.buffer_state,BufferState::Unbuffered);
|
let buffer_state=core::mem::replace(&mut self.buffer_state,BufferState::Unbuffered);
|
||||||
match buffer_state{
|
match buffer_state{
|
||||||
BufferState::Unbuffered=>(),
|
BufferState::Unbuffered=>(),
|
||||||
@ -96,7 +96,7 @@ impl MouseInterpolator{
|
|||||||
// use the first instruction which should be a mouse instruction
|
// use the first instruction which should be a mouse instruction
|
||||||
// to push a ReplaceMouse instruction
|
// to push a ReplaceMouse instruction
|
||||||
// duplicate the current mouse
|
// duplicate the current mouse
|
||||||
self.push_mouse(TimedInstruction{
|
self.push_mouse_and_flush_buffer(TimedInstruction{
|
||||||
// This should be simulation_timer.time(timeout)
|
// This should be simulation_timer.time(timeout)
|
||||||
// but the timer is not accessible from this scope
|
// but the timer is not accessible from this scope
|
||||||
// and it's just here to say that the mouse isn't moving anyways.
|
// and it's just here to say that the mouse isn't moving anyways.
|
||||||
@ -120,8 +120,8 @@ impl MouseInterpolator{
|
|||||||
// a mouse event is buffered, but no mouse events have transpired within 10ms
|
// a mouse event is buffered, but no mouse events have transpired within 10ms
|
||||||
|
|
||||||
// push buffered mouse instruction and flush buffer to output
|
// push buffered mouse instruction and flush buffer to output
|
||||||
if self.get_timedout_at(ins.time).is_some(){
|
if self.get_mouse_timedout_at(ins.time).is_some(){
|
||||||
self.timeout(ins.instruction.time);
|
self.timeout_mouse(ins.instruction.time);
|
||||||
}
|
}
|
||||||
// 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|{
|
||||||
@ -158,7 +158,7 @@ impl MouseInterpolator{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if let Some(ins)=ins_mouse{
|
if let Some(ins)=ins_mouse{
|
||||||
self.push_mouse(ins);
|
self.push_mouse_and_flush_buffer(ins);
|
||||||
}
|
}
|
||||||
if let Some(ins)=ins_other{
|
if let Some(ins)=ins_other{
|
||||||
let instruction=TimedInstruction{
|
let instruction=TimedInstruction{
|
||||||
@ -176,7 +176,7 @@ impl MouseInterpolator{
|
|||||||
self.output.len()!=0
|
self.output.len()!=0
|
||||||
}
|
}
|
||||||
pub fn buffered_instruction_with_timeout(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,SessionTimeInner>>{
|
pub fn buffered_instruction_with_timeout(&self,time_limit:SessionTime)->Option<TimedInstruction<StepInstruction,SessionTimeInner>>{
|
||||||
match self.get_timedout_at(time_limit){
|
match self.get_mouse_timedout_at(time_limit){
|
||||||
Some(timeout)=>Some(TimedInstruction{
|
Some(timeout)=>Some(TimedInstruction{
|
||||||
time:timeout,
|
time:timeout,
|
||||||
instruction:StepInstruction::Timeout,
|
instruction:StepInstruction::Timeout,
|
||||||
@ -191,7 +191,7 @@ impl MouseInterpolator{
|
|||||||
pub fn pop_buffered_instruction(&mut self,ins:TimedInstruction<StepInstruction,PhysicsTimeInner>)->Option<TimedInstruction<PhysicsInputInstruction,PhysicsTimeInner>>{
|
pub fn pop_buffered_instruction(&mut self,ins:TimedInstruction<StepInstruction,PhysicsTimeInner>)->Option<TimedInstruction<PhysicsInputInstruction,PhysicsTimeInner>>{
|
||||||
match ins.instruction{
|
match ins.instruction{
|
||||||
StepInstruction::Pop=>(),
|
StepInstruction::Pop=>(),
|
||||||
StepInstruction::Timeout=>self.timeout(ins.time),
|
StepInstruction::Timeout=>self.timeout_mouse(ins.time),
|
||||||
}
|
}
|
||||||
self.output.pop_front()
|
self.output.pop_front()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user