Пример #1
0
void PainterInterface::DestroyTabletWindow()
	{
	DestroyWindow(painterTabletPressure);
	painterTabletPressure = NULL;
	InitTablet(FALSE);

	}
Пример #2
0
void PainterInterface::CreateTabletWindow()
	{
	painterTabletPressure = CreateDialogParam(hInstance,
					  MAKEINTRESOURCE(IDD_DIALOG1),
					  GetCOREInterface()->GetMAXHWnd(),
					  TabletFloaterDlgProc,
					  (LPARAM)this);
	InitTablet(GetPressureEnable());
	}
int main(int argc, char** argv)
{
    const char* pszFile = NULL;
    const char* arg;
    WACOMENGINE hEngine = NULL;
    WACOMTABLET hTablet = NULL;
    int nLevel = (int)WACOMLOGLEVEL_WARN;
    const char* pszDeviceCls = NULL;
    const char* pszDeviceType = NULL;
    WACOMMODEL model = { 0 };

    //pszDeviceCls    // serial and usb class overrides
    pszDeviceType = "tpc";
    pszFile = "/dev/ttyUSB0";

    /* check for device */
    if (!pszFile)
    {
        fprintf(stderr, "unable to open %s\n", pszFile);
        exit(1);
    }

    /* set device class, if provided */
    if (pszDeviceCls)
    {
        model.uClass = WacomGetClassFromName(pszDeviceCls);
        if (!model.uClass)
        {
            fprintf(stderr, "Unrecognized class: %s\n",pszDeviceCls);
            exit(1);
        }
    }

    /* set device type, if provided */
    if (pszDeviceType)
    {
        model.uDevice = WacomGetDeviceFromName(pszDeviceType,model.uClass);
        if (!model.uDevice)
        {
            fprintf(stderr, "Unrecognized device: %s\n",pszDeviceType);
            exit(1);
        }
    }

    /* open engine */
    hEngine = WacomInitEngine();
    if (!hEngine)
    {
        perror("failed to open tablet engine");
        exit(1);
    }

    WacomSetLogFunc(hEngine,LogCallback);
    WacomSetLogLevel(hEngine,(WACOMLOGLEVEL)nLevel);

    WacomLog(hEngine,WACOMLOGLEVEL_INFO,"Opening log");

    /* open tablet */
    hTablet = WacomOpenTablet(hEngine,pszFile,&model);
    if (!hTablet)
    {
        perror("WacomOpenTablet");
        exit(1);
    }

    /* get device capabilities, build screen */
    if (InitTablet(hTablet))
    {
        perror("InitTablet");
        WacomCloseTablet(hTablet);
        exit(1);
    }

    /* read, parse, and display */
    FetchTablet(hTablet);

    /* close device */
    WacomCloseTablet(hTablet);
    WacomTermEngine(hEngine);

    /* close log file, if open */
    if (gLogFile)
        fclose(gLogFile);

    return 0;
}
Пример #4
0
MOboolean moTablet::Init()
{
	MOuint n, i, coparam;
	moText conf;
    moText text;

	// Primero, ponemos todo en falso:(indefinido)
	for(i = 0; i <= TABLET_PEN_CURSOR; i++) Pen[i].Init();
	Codes = NULL;

	// Levantamos el config del tablet
	//levantamos el config del tablet
    if (moMoldeoObject::Init()) {
        moMoldeoObject::CreateConnectors();
    } else return false;

	//levantamos los codes definidos
	coparam = m_Config.GetParamIndex("code");
	m_Config.SetCurrentParamIndex(coparam);
	ncodes = m_Config.GetValuesCount(coparam);
	Codes = new moTabletCode [ncodes];

	// Ahora traduzco la info
	printf("\nTABLET: ncodes:%i\n",ncodes);

	for( i = 0; i < ncodes; i++) {
		m_Config.SetCurrentValueIndex(coparam,i);
		Codes[i].strcod = m_Config.GetParam().GetValue().GetSubValue(MO_TABLET_CFG_STRCOD).Text();
		Codes[i].code = i;
		Codes[i].tabletcod = getTabletCod( Codes[i].strcod );
		Codes[i].type = m_Config.GetParam().GetValue().GetSubValue(MO_TABLET_CFG_TYPE).Int();
		Codes[i].state = MO_FALSE;//inicializamos en vacio

		if(Codes[i].tabletcod==-1) {
                        text = "ERROR(tablet):\n no se encuentra el code: ";
                        text +=  Codes[i].strcod;
                        text += moText( "\n");
			cout  << text << endl;
			exit(0);
		} else {
#ifdef MO_DEBUG
                        text = "strcod: ";
                        text += Codes[i].strcod;
                        text += moText(" ");
			cout  << text << endl;
			printf("cod: %i ",Codes[i].code);
			printf("type: %i ",Codes[i].type);
			printf("cod interno: %i\n",Codes[i].tabletcod);
#endif
		}
	}

//#ifdef MO_LINUX
moGUIManager* GUIMAN = m_pResourceManager->GetGuiMan();
if (GUIMAN) {
  m_Disp = (Display*)GUIMAN->GetDisplay();
  m_Win = GUIMAN->GetOpWindowHandle();
  if (EasyTab_Load(m_Disp, m_Win) != EASYTAB_OK)                   // Load
  {
      MODebug2->Error("moTablet::Init > Tablet init failed. \n");
  } else {
    MODebug2->Message("moTablet::Init > Tablet init OK! \n");
  }
}

  for( i = 0; i < ncodes; i++) Codes[i].CreateValuesArray(100);

#ifdef MO_WIN32
	//TABLET: Graphics Tablet
	t_hTablet = NULL;		// Tablet context handle, required.
	t_prsNew = 0;
	t_curNew = 0;
	t_ortNew.orAzimuth = 0;		// 0 = north
	t_ortNew.orAltitude = 900;	// 900 = vertical
	t_ortNew.orTwist = 0;

	t_pkXNew = 0;
	t_pkYNew = 0;
	t_pkZNew = 0;

	//EXAMPLE: extra tablet adjustments, used for this example,
	//	they may be useful in some other applications
	t_bTiltSupport = TRUE;	// Table. Is tilt supported
	t_dblAltAdjust = 1;		// Tablet Altitude zero adjust
	t_dblAltFactor = 1;		// Tablet Altitude factor
	t_dblAziFactor = 1;		// Table Azimuth factor

	if (IsTabletInstalled())
	{
		MO_HANDLE hWnd = m_pResourceManager->GetGuiMan()->GetOpWindowHandle();

		// Getting tablet context.
		if (hWnd != NULL) t_hTablet = InitTablet(hWnd);
		else
		{
			MODebug2->Push("Cannot get window handle.");
			exit(0);
			return false;
		}
		MODebug2->Push( moText("Tablet installed with name = ") + GetTabletName() );

        // Checking the queue size with
		// int WTQueueSizeGet(hCtx), where
	    // This function returns the number of packets the context's queue can hold.
	    // Parameter	Type/Description
	    // hCtx	HCTX  Identifies the context whose queue size is being returned.
	    //WTQueueSizeSet( t_hTablet, 200 );
	    m_cMaxPkts = WTQueueSizeGet(t_hTablet);
		MODebug2->Push( moText("Tablet queue size = ") + IntToStr( m_cMaxPkts ) );

		// Creating packet buffer.
    	m_lpPkts = new PACKET[m_cMaxPkts];
		for( i = 0; i < ncodes; i++) Codes[i].CreateValuesArray(m_cMaxPkts);
	}
	else
	{
		MODebug2->Error("Tablet not detected.");
		return false;
	}
#endif // MO_WIN32

	return true;
}
Пример #5
0
int mwOpen(const char *title) {

    pszFile = title;
    
   // printf("Le chemins : %s\n",title);
    
    
    /* check for device */
    /*if (!pszFile) {
        Usage();
        exit(1);
    }*/

    /* check for log file */
    /*  if (pszLogFile) {
          gLogFile = fopen(pszLogFile, "w");
          if (!gLogFile) {
              perror("failed to open log file for writing");
              exit(1);
          }
      }*/

    /* set device class, if provided */
    if (pszDeviceCls) {
        model.uClass = WacomGetClassFromName(pszDeviceCls);
        if (!model.uClass) {
            fprintf(stderr, "Unrecognized class: %s\n", pszDeviceCls);
            exit(1);
        }
    }

    /* set device type, if provided */
    if (pszDeviceType) {
        model.uDevice = WacomGetDeviceFromName(pszDeviceType, model.uClass);
        if (!model.uDevice) {
            fprintf(stderr, "Unrecognized device: %s\n", pszDeviceType);
            exit(1);
        }
    }

    /* open engine */
    hEngine = WacomInitEngine();
    if (!hEngine) {
        perror("failed to open tablet engine");
        exit(1);
    }

    /*WacomSetLogFunc(hEngine, LogCallback);
    WacomSetLogLevel(hEngine, (WACOMLOGLEVEL) nLevel);

    WacomLog(hEngine, WACOMLOGLEVEL_INFO, "Opening log");*/

    /* open tablet */
    hTablet = WacomOpenTablet(hEngine, pszFile, &model);
    if (!hTablet) {
        perror("WacomOpenTablet");
        exit(1);
    }

    /* get device capabilities, build screen */
    if (InitTablet(hTablet)) {
        perror("InitTablet");
        WacomCloseTablet(hTablet);
        exit(1);
    }
    
    
    gettimeofday(&sto, 0);
    
    pthread_t t;
     /* Creation du thread du magasin. */
   //printf ("Creation du thread du magasin !\n");
   int ret = pthread_create (&t, NULL,sampler, NULL);


   /* Creation des threads des clients si celui du magasin a reussi. */
   if (ret){
      fprintf (stderr, "%s", strerror (ret));
   }
   
   
    
    return 1;
}