Exemple #1
0
int GetTabletQueueSize()
//////////////////////////////////////////////////////////////////////////////
{
    if( hContext )
        return( WTQueueSizeGet( hContext ));
    return 0;
}
Exemple #2
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;
}