Hi
First of all sorry for large post. I know its big, probably most won't
get to the end, but I'm running out of options.
I've searched web, I've found some demo project on www.codeproject.com
but there is only basic info about it. :-(
Could someone please translated it for me? I'm sitting on it for a few
days now and I can't get through :-(
First of all structures. I've translated most of them but I want to be sure:
<C>
/* TWON_ONEVALUE. Container for one value. */
typedef struct {
TW_UINT16 ItemType;
TW_UINT32 Item;
} TW_ONEVALUE, FAR * pTW_ONEVALUE;
/* DAT_CAPABILITY. Used by application to get/set capability from/in a
data source. */
typedef struct {
TW_UINT16 Cap; /* id of capability to set or get, e.g.
CAP_BRIGHTNESS */
TW_UINT16 ConType; /* TWON_ONEVALUE, _RANGE, _ENUMERATION or _ARRAY
*/
TW_HANDLE hContainer; /* Handle to container of type Dat
*/
} TW_CAPABILITY, FAR * pTW_CAPABILITY;
/* Fixed point structure type. */
typedef struct {
TW_INT16 Whole; /* maintains the sign */
TW_UINT16 Frac;
} TW_FIX32, FAR *pTW_FIX32;
</C>
And now the code that these structs are use in:
<C>
TW_UINT16 HandleSetCap(pCAP_STATESTORAGEITEM pCapData, pTW_CAPABILITY
pCap, TW_UINT16 *pStatus)
{
int i=0;
TW_UINT16 twRc = TWRC_FAILURE;
*pStatus = TWCC_BADVALUE;
pTW_ONEVALUE pOne=(pTW_ONEVALUE)GlobalLock(pCap->hContainer);
if(pOne)
{
if(pOne->ItemType == pCapData->Header.ItemType)
{
void *pAppValue = malloc(AltTWItemSize(pCapData->Header.ItemType));
if(pAppValue)
{
TW_UINT16 twSize = AltTWItemSize(pCapData->Header.ItemType);
ExtractOneValue(pCap, pAppValue);
if(pOne->ItemType==TWTY_FIX32)
{
//I THINK THIS IS WHERE THE VALUE IS SET
//CAPSLOCK FOR BETTER VISIBILITY
*(float*)pAppValue = FIX32ToFloat(*(pTW_FIX32)pAppValue);
twSize = sizeof(float);
}
if(IsItemInList(&pCapData->DefaultSupported, pAppValue, twSize))
{
memcpy(pCapData->CurrentValue.pItems, pAppValue, twSize);
twRc = TWRC_SUCCESS;
*pStatus = TWCC_SUCCESS;
free(pAppValue);
pAppValue = NULL;
GlobalUnlock(pCap->hContainer);
break;
}
free(pAppValue);
pAppValue = NULL;
}
}
GlobalUnlock(pCap->hContainer);
}
return twRc;
}
VOID ExtractOneValue (pTW_CAPABILITY pData, LPVOID pVoid)
{
pTW_ONEVALUE pOneValue = NULL;
ASSERT(pData);
ASSERT(pVoid);
ASSERT(pData->ConType == TWON_ONEVALUE);
if ((pOneValue = (pTW_ONEVALUE)GlobalLock(pData->hContainer)) != NULL)
{
switch (pOneValue->ItemType)
{
case TWTY_FIX32:
*(float *)pVoid = FIX32ToFloat(*(pTW_FIX32)&pOneValue->Item);
break;
default:
break;
}
GlobalUnlock(pData->hContainer);
}
return;
}
</C>
Big thanks in advance for help
best regards
Mateusz [PEYN] Adamus