// Translation or Rotation packet? They come in two different packets.
if (pRawHid->bRawData[0] == 1) // Translation vector
{
all6DOFs[0] = (pRawHid->bRawData[1] & 0x000000ff) | ((signed short)(pRawHid->bRawData[2]<<8>bRawData[3] & 0x000000ff) | ((signed short)(pRawHid->bRawData[4]<<8>bRawData[5] & 0x000000ff) | ((signed short)(pRawHid->bRawData[6]<<8) & 0xffffff00);
bGotTranslation = TRUE;
}
the above code is portion of the wm_input example. all6DOFS is the vector of movement, isn't. But I can not understand the bitwise operation followed.
Can somebody explain the meaning of it?
wm_input example code's question.
Moderator: Moderators
(That code isn't being shown correctly.)
If you refer back to the original code in the sample, it demonstrates how the data from the cap arrives in two 7 byte packets (one for translation, one for rotation). The muxing byte arrives first (1 for translation, 2 for rotation), followed by the three axes (2 bytes per axis). The least significant byte of each axis arrives first. The code shows how the two bytes of the axis are combined into one 16 byte signed integer. The most significant byte is shifted to its proper place then the two integers are OR'ed together.
If you refer back to the original code in the sample, it demonstrates how the data from the cap arrives in two 7 byte packets (one for translation, one for rotation). The muxing byte arrives first (1 for translation, 2 for rotation), followed by the three axes (2 bytes per axis). The least significant byte of each axis arrives first. The code shows how the two bytes of the axis are combined into one 16 byte signed integer. The most significant byte is shifted to its proper place then the two integers are OR'ed together.
