Ejemplo n.º 1
0
static CGEventRef callback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon) {
  if(CGEventGetIntegerValueField(event, kCGScrollWheelEventIsContinuous))
    return event;
  CGEventSetDoubleValueField(event, kCGScrollWheelEventFixedPtDeltaAxis1, -CGEventGetDoubleValueField(event, kCGScrollWheelEventFixedPtDeltaAxis1));
  CGEventSetDoubleValueField(event, kCGScrollWheelEventFixedPtDeltaAxis2, -CGEventGetDoubleValueField(event, kCGScrollWheelEventFixedPtDeltaAxis2));
  return event;
}
Ejemplo n.º 2
0
bool GTMouseDriver::doubleClick() {

    QPoint mousePos = QCursor::pos();
    CGEventType eventTypeMouseDown = kCGEventLeftMouseDown ;
    CGEventRef eventPress = CGEventCreateMouseEvent(NULL, eventTypeMouseDown, CGPointMake(mousePos.x(), mousePos.y()), 0 /*ignored*/);
    DRIVER_CHECK(eventPress != NULL, "Can't create event");

    CGEventType eventTypeMouseUp = kCGEventLeftMouseUp ;
    CGEventRef eventRelease = CGEventCreateMouseEvent(NULL, eventTypeMouseUp, CGPointMake(mousePos.x(), mousePos.y()), 0 /*ignored*/);
    DRIVER_CHECK(eventRelease != NULL, "Can't create event");

    CGEventPost(kCGSessionEventTap, eventPress);
    GTGlobals::sleep(0); // don't touch, it's Mac's magic
    CGEventPost(kCGSessionEventTap, eventRelease);
    GTGlobals::sleep(0);

    CGEventSetDoubleValueField(eventPress, kCGMouseEventClickState, 2);
    CGEventSetDoubleValueField(eventRelease, kCGMouseEventClickState, 2);

    CGEventPost(kCGSessionEventTap, eventPress);
    GTGlobals::sleep(0); // don't touch, it's Mac's magic
    CGEventPost(kCGSessionEventTap, eventRelease);
    GTGlobals::sleep(0);

    GTGlobals::sleep(100);

    CFRelease(eventPress);
    CFRelease(eventRelease);

    return true;
}
void QGeneralSettingWidget::TPDP_OnGST(T3K_DEVICE_INFO /*devInfo*/, ResponsePart /*Part*/, unsigned short /*ticktime*/, const char */*partid*/,
                                       unsigned char /*cActionGroup*/, unsigned char cAction, unsigned short /*wFeasibleness*/,
                                       unsigned short /*x*/, unsigned short /*y*/, unsigned short /*w*/, unsigned short /*h*/, float fZoom, const char */*msg*/)
{
    if( cAction == t3kgstNoAction || (fZoom == 0.0f || fZoom == 1.0f) /*|| cAction != t3kgstFingersMove*/ )
    {
        if( g_fZoom != 0.0f && g_fZoom != 1.0f )
        {
            // end gesture
            CGEventRef e = CGEventCreate(NULL);
            CGEventSetType(e, 0x1D);
            CGEventSetFlags(e, 0x100);

            CGEventSetTimestamp(e, 0);
            CGEventSetIntegerValueField(e, 0x6E, 0x3E);
            CGEventSetIntegerValueField(e, 0x75, 0x00);
            CGEventPost(kCGHIDEventTap, e);

            CFRelease(e);

            g_fZoom = 0.0f;

            qDebug() << "end gesture";
        }
    }
    else if( fZoom != 0.0f && fZoom != 1.0f )
    {
        CGEventRef e = CGEventCreate(NULL);
        CGEventSetType(e, 0x1D);
        CGEventSetFlags(e, 0x100);

        if( g_fZoom == 0.0f || g_fZoom == 1.0f )
        {
            g_fZoom = fZoom;
            qDebug() << "begin gesture : " << g_fZoom;
            CGEventSetTimestamp(e, 0);
            CGEventSetIntegerValueField(e, 0x6E, 0x3D);
            CGEventSetIntegerValueField(e, 0x75, 0x08);
            CGEventPost(kCGHIDEventTap, e);
        }
        else
        {
            float dZoom = g_fZoom - fZoom;
            qDebug() << "=== " << g_fZoom << " " << fZoom << " changed Zoom : " << dZoom;
            if( qAbs(dZoom) >= 0.02 && qAbs(dZoom) <= 0.05 )
            {
                CGEventSetTimestamp(e, 0);
                CGEventSetIntegerValueField(e, 0x6E, 0x08);
                CGEventSetDoubleValueField(e, 0x71, -dZoom);
                CGEventPost(kCGHIDEventTap, e);
            }

            g_fZoom = fZoom;
        }

        CFRelease(e);
    }

    qDebug() << "Zoom : " << fZoom << " " << cAction;
//    qDebug() << QString("Gesture : AG(%1), A(%2), F(%3), X(%4), Y(%5), W(%6), H(%7), ZOOM(%8), MSG(%9)").arg(cActionGroup).arg(cAction).arg(wFeasibleness)
//            .arg(x).arg(y).arg(w).arg(h).arg(fZoom).arg(msg);
}