This project is read-only.
1
Vote

byte data is not being passed properly as safearray to queueinputreport

description

For everyone who saw my forum post here is the main problem I am having that is preventing me from moving on to the next step in the project. To fix the code below amounts to about a 1/2 to 1/3 of the work on this project:

STDMETHODIMP CMMEmulator::sendinputreport(BYTE inputreport[5])
{
//SAFEARRAY *inputreport
// TODO: Add your implementation code here
// Create as an Array of Variants becuase that is what the DSF 
// Interface->put_DeviceSpecificDescriptor is expecting an array of Variants
//FADF_STATIC+FADF_FIXEDSIZE+FADF_VARIANT+FADF_HAVEVARTYPE;
// if( test->fFeatures == 0x892)
// {
//  MessageBox(NULL,L"has correct safearray type",L"correct data format",NULL);
// }
// else
// {
// MessageBox(NULL,L"does not have the correct safearray type",L"incorrect data format",NULL);
//}
//  test->fFeatures = 2194;
//if( test == NULL )
//{
    // if the create failed, then goto to exit
    //hr = E_UNEXPECTED;
  //  goto Exit;
//}

// Step through the SAFEARRAY and populate each variant with a Byte value
//INT descSize2 = sizeof(inputreport);
//SAFEARRAYBOUND rgsabound[1];
  //need 2194 instead of 2176 or FADF_STATIC and FADF_FIXEDSIZE included also.
 //VARIANT HUGEP* pDescriptorData = NULL;
    VARIANT pDescriptorData[5];
//ZeroMemory(rgsabound,sizeof(rgsabound));
   // rgsabound[0].lLbound = 0;
    //rgsabound[0].cElements = 5;
    //SAFEARRAY *psaValues = SafeArrayCreateVector(VT_VARIANT|VT_ARRAY, 0,5);
    //BYTE bSampe[5] = {0x01,0x02,0x03,0x04,0x04};
    CComSafeArray<VARIANT> c;  
    //LONG j[5];
    LONG length = 4;
    //SafeArrayLock(psaValues);
     CComVariant v;
    for(int i = 0; i < 5; i++)
     {
        //j[i] = i;
     MessageBox(NULL,L"inputreport assigned to variable",NULL,NULL);
     //pDescriptorData[i].vt = VT_UI1;
    //pDescriptorData[i].bVal = inputreport[i];
    //SafeArrayPutElement(psaValues,&i,&pDescriptorData[i]);
    //VariantClear(&pDescriptorData[i]);
       v.Clear();
       v.vt = VT_UI1;
       v.uiVal = inputreport[i];
       v.Detach(&pDescriptorData[i]);
        c.Add (v, TRUE);
     }

MessageBox(NULL,L"data is successfully assigned to safearray",L"correct data format",NULL);
piSoftHidDevice1[devindex]->QueueInputReport(c,8);
piSoftHidDevice1[devindex]->StartProcessing();
piSoftHidDevice1[devindex]->StopProcessing();

return S_OK;
//Exit:
//SafeArrayUnaccessData(test);
//return 0;
}

comments