예제 #1
0
//------------------------------------------------------------  SetTablet()
//
int SetTablet()
{
	int i, nCaps;
	int nMajor, nMinor, nRelease;

	WACOMMODEL model;
	WACOMSTATE ranges = WACOMSTATE_INIT;
	
	const char* pszName;
	const char* pszClass = "UNK_CLS";
	const char* pszVendor = "UNK_VNDR";
	const char* pszDevice = "UNK_DEV";
	const char* pszSub = "UNK_SUB";

	/* get model */
	model = WacomGetModel(ghTablet);
	pszVendor = WacomGetVendorName(ghTablet);
	pszClass = WacomGetClassName(ghTablet);
	pszDevice = WacomGetDeviceName(ghTablet);
	pszSub = WacomGetSubTypeName(ghTablet);
	pszName = WacomGetModelName(ghTablet);
	WacomGetROMVersion(ghTablet,&nMajor,&nMinor,&nRelease);

	/* get event types supported, ranges, and immediate values */
	nCaps = WacomGetCapabilities(ghTablet);
	WacomGetState(ghTablet,&ranges);

	for (i=WACOMFIELD_TOOLTYPE; i<WACOMFIELD_MAX; ++i)
	{
		if (nCaps & (1<<i))
		{
			gAbsState[i].bValid = 1;
			gAbsState[i].nValue = ranges.values[i].nValue;
			gAbsState[i].nMin = ranges.values[i].nMin;
			gAbsState[i].nMax = ranges.values[i].nMax;
		}
	}

	/* get key event types */
	for (i=0; i<WACOMBUTTON_MAX; ++i)
	{
		gKeyState[i].bValid = 1;
	}
	return 1;
}
static int InitTablet(WACOMTABLET hTablet)
{
    int i, nCaps, nItem, nRow=0;
    int nMajor, nMinor, nRelease;
    char chBuf[256];
    WACOMMODEL model;
    WACOMSTATE ranges = WACOMSTATE_INIT;
    const char* pszName;
    const char* pszClass = "UNK_CLS";
    const char* pszVendor = "UNK_VNDR";
    const char* pszDevice = "UNK_DEV";
    const char* pszSub = "UNK_SUB";

    /* get model */
    model = WacomGetModel(hTablet);
    pszVendor = WacomGetVendorName(hTablet);
    pszClass = WacomGetClassName(hTablet);
    pszDevice = WacomGetDeviceName(hTablet);
    pszSub = WacomGetSubTypeName(hTablet);
    pszName = WacomGetModelName(hTablet);
    WacomGetROMVersion(hTablet,&nMajor,&nMinor,&nRelease);

    snprintf(chBuf,sizeof(chBuf),"MODEL=%s",pszName);
    printf("%s\n", chBuf);
    snprintf(chBuf,sizeof(chBuf),"ROM=%d.%d-%d",nMajor, nMinor, nRelease);
    printf("%s\n", chBuf);
    snprintf(chBuf,sizeof(chBuf),"CLS=%s  VNDR=%s  DEV=%s  SUB=%s",
             pszClass, pszVendor, pszDevice, pszSub);
    printf("%s\n", chBuf);

    /* get event types supported, ranges, and immediate values */
    nCaps = WacomGetCapabilities(hTablet);
    WacomGetState(hTablet,&ranges);

    nItem = 0;
    for (i=0; i<31; ++i)
    {
        if (nCaps & (1<<i))
        {
            gAbsState[i].bValid = 1;
            gAbsState[i].nValue = ranges.values[i].nValue;
            gAbsState[i].nMin = ranges.values[i].nMin;
            gAbsState[i].nMax = ranges.values[i].nMax;
            gAbsState[i].nRow = nRow + nItem / 2;
            gAbsState[i].nCol = nItem % 2;
            DisplaySerialValue(i);
            printf("param: %d\tvalue: %d\tmin: %d\tmax: %d\n", i, gAbsState[i].nValue,
                   gAbsState[i].nMin,
                   gAbsState[i].nMax);
            ++nItem;
        }
    }
    nRow += ((nItem + 1) / 2) + 1;

    /* get key event types */
    nItem = 0;
    for (i=0; i<WACOMBUTTON_MAX; ++i)
    {
        gKeyState[i].bValid = 1;
        gKeyState[i].nRow = nRow + nItem / 4;
        gKeyState[i].nCol = nItem % 4;
        DisplaySerialButton(i);
        ++nItem;
    }
    nRow += ((nItem + 3) / 4) + 1;
    return 0;
}