Ticket #1634: mythgesture.cpp.patch

File mythgesture.cpp.patch, 3.8 KB (added by anonymous, 14 years ago)
  • mythgesture.cpp

    old new  
    6161    scale_ratio(scale_ratio), bin_percent(bin_percent)
    6262{
    6363    /* default to an invalid event */
    64     last_gesture = MythGestureEvent::MaxGesture;
     64    last_gesture = MythGestureEvent::WrongGesture;
    6565
    6666    /* create new private information */
    6767    p = new MythGesturePrivate();
     
    9090    p->sequences.insert("98741",MythGestureEvent::LeftThenUp);
    9191    p->sequences.insert("12369",MythGestureEvent::RightThenDown);
    9292    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       
    93130}
    94131
    95132/* comments in header */
    96133void MythGesture::adjustExtremes(int x, int y)
    97134{
    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;
    102139}
    103140
    104141bool MythGesture::recording(void) const
     
    122159{
    123160    p->m.lock();
    124161
     162    QString trans;
    125163    if (m_recording)
    126164    {
    127165        m_recording = false;
    128166
    129167        /* 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       
    131174
    132175        min_x = min_y = 10000;
    133176        max_x = max_y = -1;
     
    252295    }
    253296
    254297    /* 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    }
    257302   
    258303    /* bail out on error cases */
    259304    if (sequence_count > max_sequence)
     
    343388    "LeftThenDown",
    344389    "RightThenUp",
    345390    "RightThenDown",
     391    "ClockWise",
     392    "CounterClockWise",
     393    "StepUp",
     394    "StepDown",
     395    "DoubleStepUp",
     396    "DoubleStepDown",
     397    "Z",
    346398    "Click",
    347     "MaxGesture"
     399    "WrongGesture"
    348400};
    349401
    350402/* comments in header */