Ticket #1634: mythgesture.cpp.patch
File mythgesture.cpp.patch, 3.8 KB (added by , 14 years ago) 


mythgesture.cpp
old new 61 61 scale_ratio(scale_ratio), bin_percent(bin_percent) 62 62 { 63 63 /* default to an invalid event */ 64 last_gesture = MythGestureEvent:: MaxGesture;64 last_gesture = MythGestureEvent::WrongGesture; 65 65 66 66 /* create new private information */ 67 67 p = new MythGesturePrivate(); … … 90 90 p>sequences.insert("98741",MythGestureEvent::LeftThenUp); 91 91 p>sequences.insert("12369",MythGestureEvent::RightThenDown); 92 92 p>sequences.insert("78963",MythGestureEvent::RightThenUp); 93 94 /*ClockWise rotation*/ 95 p>sequences.insert("123698741",MythGestureEvent::ClockWise); 96 p>sequences.insert("236987412",MythGestureEvent::ClockWise); 97 p>sequences.insert("369874123",MythGestureEvent::ClockWise); 98 p>sequences.insert("698741236",MythGestureEvent::ClockWise); 99 p>sequences.insert("987412369",MythGestureEvent::ClockWise); 100 p>sequences.insert("874123698",MythGestureEvent::ClockWise); 101 p>sequences.insert("741236987",MythGestureEvent::ClockWise); 102 p>sequences.insert("412369874",MythGestureEvent::ClockWise); 103 p>sequences.insert("123698741",MythGestureEvent::ClockWise); 104 105 /*CounterClockWise rotation*/ 106 p>sequences.insert("147896321",MythGestureEvent::CounterClockWise); 107 p>sequences.insert("214789632",MythGestureEvent::CounterClockWise); 108 p>sequences.insert("321478963",MythGestureEvent::CounterClockWise); 109 p>sequences.insert("632147896",MythGestureEvent::CounterClockWise); 110 p>sequences.insert("963214789",MythGestureEvent::CounterClockWise); 111 p>sequences.insert("896321478",MythGestureEvent::CounterClockWise); 112 p>sequences.insert("789632147",MythGestureEvent::CounterClockWise); 113 p>sequences.insert("478963214",MythGestureEvent::CounterClockWise); 114 p>sequences.insert("147896321",MythGestureEvent::CounterClockWise); 115 116 //steps 117 p>sequences.insert("78523",MythGestureEvent::StepUp); 118 p>sequences.insert("12589",MythGestureEvent::StepDown); 119 120 //double steps 121 p>sequences.insert("74563",MythGestureEvent::DoubleStepUp); 122 p>sequences.insert("14569",MythGestureEvent::DoubleStepDown); 123 p>sequences.insert("1235789",MythGestureEvent::Z); 124 125 126 127 128 129 93 130 } 94 131 95 132 /* comments in header */ 96 133 void MythGesture::adjustExtremes(int x, int y) 97 134 { 98 min_x = min(min_x, x);99 max_x = max(max_y, x);100 min_y = min(min_y, y);101 max_y = max(max_y, y);135 if (((int) x) < min_x) min_x = (int) x; 136 if (((int) x) > max_x) max_x = (int) x; 137 if (((int) y) < min_y) min_y = (int) y; 138 if (((int) y) > max_y) max_y = (int) y; 102 139 } 103 140 104 141 bool MythGesture::recording(void) const … … 122 159 { 123 160 p>m.lock(); 124 161 162 QString trans; 125 163 if (m_recording) 126 164 { 127 165 m_recording = false; 128 166 129 167 /* translate before resetting maximums */ 130 last_gesture = p>sequences[translate()]; 168 trans=translate(); 169 if(p>sequences.find(trans)!=p>sequences.end()) 170 last_gesture = p>sequences[trans]; 171 else 172 last_gesture = MythGestureEvent::WrongGesture; 173 131 174 132 175 min_x = min_y = 10000; 133 176 max_x = max_y = 1; … … 252 295 } 253 296 254 297 /* add the last run of points to the sequence */ 255 sequence += '0' + current_bin; 256 sequence_count++; 298 if(sequence_count<=9){ 299 sequence += '0' + current_bin; 300 sequence_count++; 301 } 257 302 258 303 /* bail out on error cases */ 259 304 if (sequence_count > max_sequence) … … 343 388 "LeftThenDown", 344 389 "RightThenUp", 345 390 "RightThenDown", 391 "ClockWise", 392 "CounterClockWise", 393 "StepUp", 394 "StepDown", 395 "DoubleStepUp", 396 "DoubleStepDown", 397 "Z", 346 398 "Click", 347 " MaxGesture"399 "WrongGesture" 348 400 }; 349 401 350 402 /* comments in header */