locked
how to get the dopod s900 Accelerometer information, current value of x,y,z axis RRS feed

Answers

  • #define SENSOR_DLL      L"HTCSensorSDK.dll"

    typedef struct _SENSORDATA
    {
     SHORT   TiltX;          // From -1000 to 1000 (about), 0 is flat
     SHORT   TiltY;          // From -1000 to 1000 (about), 0 is flat
     SHORT   TiltZ;    // From -1000 to 1000 (about) 0 = Straight up, -1000 = Flat, 1000 = Upside down
     WORD    Unknown1;       // Always zero
     DWORD   AngleY;         // From 0 to 359
     DWORD   AngleX;         // From 0 to 359
     DWORD   Unknown2;       // Bit field?
    } SENSORDATA, *PSENSORDATA;

    typedef HANDLE (WINAPI * PFN_HTCSensorOpen)(DWORD);
    typedef void (WINAPI * PFN_HTCSensorClose)(HANDLE);
    typedef DWORD (WINAPI * PFN_HTCSensorGetDataOutput)(HANDLE, PSENSORDATA);

    PFN_HTCSensorOpen           pfnHTCSensorOpen;
    PFN_HTCSensorClose          pfnHTCSensorClose;
    PFN_HTCSensorGetDataOutput  pfnHTCSensorGetDataOutput;

    #define SENSOR_TILT     1

    int getAccelerometerInfo(  )
    {
     HMODULE hSensorLib = LoadLibrary(SENSOR_DLL);
     SENSORDATA sd;
     if (hSensorLib == NULL)
     {
      return -1;
     }

     pfnHTCSensorOpen = (PFN_HTCSensorOpen)
      GetProcAddress(hSensorLib, L"HTCSensorOpen");
     pfnHTCSensorClose = (PFN_HTCSensorClose)
      GetProcAddress(hSensorLib, L"HTCSensorClose");
     pfnHTCSensorGetDataOutput = (PFN_HTCSensorGetDataOutput)
      GetProcAddress(hSensorLib, L"HTCSensorGetDataOutput");

     if (pfnHTCSensorOpen == NULL ||
      pfnHTCSensorClose == NULL ||
      pfnHTCSensorGetDataOutput == NULL)
     {
      return -1;
     }

     HANDLE g_hSensor = pfnHTCSensorOpen(SENSOR_TILT);
     pfnHTCSensorGetDataOutput(g_hSensor, &sd);
     pfnHTCSensorClose(g_hSensor);
    return = 0;

    }

    Monday, July 13, 2009 8:39 AM

All replies

  • Hi phoenix_zg,

    Could you elaborate on what your intention is?



    Best regards,
    Guang-Ming Bian - MSFT
    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Monday, July 13, 2009 8:36 AM
  • #define SENSOR_DLL      L"HTCSensorSDK.dll"

    typedef struct _SENSORDATA
    {
     SHORT   TiltX;          // From -1000 to 1000 (about), 0 is flat
     SHORT   TiltY;          // From -1000 to 1000 (about), 0 is flat
     SHORT   TiltZ;    // From -1000 to 1000 (about) 0 = Straight up, -1000 = Flat, 1000 = Upside down
     WORD    Unknown1;       // Always zero
     DWORD   AngleY;         // From 0 to 359
     DWORD   AngleX;         // From 0 to 359
     DWORD   Unknown2;       // Bit field?
    } SENSORDATA, *PSENSORDATA;

    typedef HANDLE (WINAPI * PFN_HTCSensorOpen)(DWORD);
    typedef void (WINAPI * PFN_HTCSensorClose)(HANDLE);
    typedef DWORD (WINAPI * PFN_HTCSensorGetDataOutput)(HANDLE, PSENSORDATA);

    PFN_HTCSensorOpen           pfnHTCSensorOpen;
    PFN_HTCSensorClose          pfnHTCSensorClose;
    PFN_HTCSensorGetDataOutput  pfnHTCSensorGetDataOutput;

    #define SENSOR_TILT     1

    int getAccelerometerInfo(  )
    {
     HMODULE hSensorLib = LoadLibrary(SENSOR_DLL);
     SENSORDATA sd;
     if (hSensorLib == NULL)
     {
      return -1;
     }

     pfnHTCSensorOpen = (PFN_HTCSensorOpen)
      GetProcAddress(hSensorLib, L"HTCSensorOpen");
     pfnHTCSensorClose = (PFN_HTCSensorClose)
      GetProcAddress(hSensorLib, L"HTCSensorClose");
     pfnHTCSensorGetDataOutput = (PFN_HTCSensorGetDataOutput)
      GetProcAddress(hSensorLib, L"HTCSensorGetDataOutput");

     if (pfnHTCSensorOpen == NULL ||
      pfnHTCSensorClose == NULL ||
      pfnHTCSensorGetDataOutput == NULL)
     {
      return -1;
     }

     HANDLE g_hSensor = pfnHTCSensorOpen(SENSOR_TILT);
     pfnHTCSensorGetDataOutput(g_hSensor, &sd);
     pfnHTCSensorClose(g_hSensor);
    return = 0;

    }

    Monday, July 13, 2009 8:39 AM
  • this is the solution
    Monday, July 13, 2009 8:40 AM