Esempio n. 1
0
HCTX PenAPI::open(HWND hwnd)
{
  if (!m_wintabLib && !loadWintab())
    return nullptr;

  LOGCONTEXTW logctx;
  memset(&logctx, 0, sizeof(LOGCONTEXTW));
  UINT infoRes = WTInfo(WTI_DEFSYSCTX, 0, &logctx);
  ASSERT(infoRes == sizeof(LOGCONTEXTW));
  ASSERT(logctx.lcOptions & CXO_SYSTEM);

  logctx.lcOptions =
    CXO_SYSTEM |
    CXO_MESSAGES |
    CXO_CSRMESSAGES;
  logctx.lcPktData = PACKETDATA;
  logctx.lcPktMode = PACKETMODE;
  logctx.lcMoveMask = PACKETDATA;

  HCTX ctx = WTOpen(hwnd, &logctx, TRUE);
  if (!ctx) {
    LOG("Error attaching pen to display\n");
    return nullptr;
  }

  LOG("Pen attached to display\n");
  return ctx;
}
Esempio n. 2
0
TabletSupport::TabletSupport(QWidget *window)
      :wintab_module(nullptr),
      window_(window),
      logContext(nullptr)
{
    if(!loadWintab()) {
        return;
    }
    if(!mapWintabFuns()){
        qCritical()<<"Error with function mapping!";
        return;
    }
    if(!hasDevice()){
        qCritical()<<"No Device found!";
        return;
    }
    logContext = new tagLOGCONTEXTA;
    auto handle = (HWND)window_->winId();

    callFunc().ptrWTInfoA(WTI_DEFSYSCTX, 0, logContext);
    logContext->lcOptions |= CXO_MESSAGES;
    logContext->lcMoveMask = PACKETDATA;
    logContext->lcBtnUpMask = logContext->lcBtnDnMask;

    AXIS TabletX;
    AXIS TabletY;
    callFunc().ptrWTInfoA( WTI_DEVICES, DVC_X, &TabletX );
    callFunc().ptrWTInfoA( WTI_DEVICES, DVC_Y, &TabletY );

    logContext->lcInOrgX = 0;
    logContext->lcInOrgY = 0;
    logContext->lcInExtX = TabletX.axMax;
    logContext->lcInExtY = TabletY.axMax;

    /* output the data in screen coords */
    logContext->lcOutOrgX = logContext->lcOutOrgY = 0;
    logContext->lcOutExtX = GetSystemMetrics(SM_CXSCREEN);
    /* move origin to upper left */
    logContext->lcOutExtY = -GetSystemMetrics(SM_CYSCREEN);

    logContext->lcPktData = PACKETDATA;
    logContext->lcPktMode = PACKETMODE;

    tabapis.context_ = callFunc().ptrWTOpenA(handle,
                                             (LPLOGCONTEXTA)logContext,
                                             true);
}