<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , ) <EOL> from kivy . config import Config <EOL> class InputPostprocDejitter ( object ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self ) : <EOL> self . jitterdist = Config . getfloat ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> ignore_devices = Config . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . ignore_devices = ignore_devices . split ( '<STR_LIT:U+002C>' ) <EOL> self . last_touches = { } <EOL> def taxicab_distance ( self , p , q ) : <EOL> return abs ( p [ <NUM_LIT:0> ] - q [ <NUM_LIT:0> ] ) + abs ( p [ <NUM_LIT:1> ] - q [ <NUM_LIT:1> ] ) <EOL> def process ( self , events ) : <EOL> if not self . jitterdist : <EOL> return events <EOL> processed = [ ] <EOL> for etype , touch in events : <EOL> if not touch . is_touch : <EOL> continue <EOL> if touch . device in self . ignore_devices : <EOL> processed . append ( ( etype , touch ) ) <EOL> continue <EOL> if etype == '<STR_LIT>' : <EOL> self . last_touches [ touch . id ] = touch . spos <EOL> if etype == '<STR_LIT:end>' : <EOL> del self . last_touches [ touch . id ] <EOL> if etype != '<STR_LIT>' : <EOL> processed . append ( ( etype , touch ) ) <EOL> continue <EOL> last_spos = self . last_touches [ touch . id ] <EOL> dist = self . taxicab_distance ( last_spos , touch . spos ) <EOL> if dist > self . jitterdist : <EOL> self . last_touches [ touch . id ] = touch . spos <EOL> processed . append ( ( etype , touch ) ) <EOL> return processed </s>
