IFC Reference |
If your application is exclusively for pointing products like a Logitech tactile feedback mouse or Wingman Force Feedback Mouse, you should use a CImmMouse object. In your application code, declare a CImmMouse object pointer and initialize it.
CImmMouse* m_pTSMouse;
// initialize to NULL
m_pTSMouse = NULL;
// Initialize the ImmMouse and check success or failure
m_pTSMouse = new CImmMouse;
if ( !(m_pTSMouse->Initialize( AfxGetInstanceHandle(), m_pMainWnd->m_hWnd )) )
{
// failed Initialize call
delete m_pTSMouse;
m_pTSMouse = NULL;
}
Tactile sensations can feel quite differently on a full force feedback device versus a tactile feedback mouse, so it is sometime necessary to detect the type of mouse that has been found. IFC21 currently does not have an easy to use function to accomplish this, but the following code shows how it should be done. IFC22 will contain a better interface that will allow developers easy access to this information.
// check the type of the device
LPIIMM_DEVICE piDevice= m_pTSMouse->GetDevice();
if (piDevice)
{
IMM_DEVCAPS devcaps;
devcaps.dwSize = sizeof(IMM_DEVCAPS);
HRESULT hRes = piDevice->GetCapabilities(&devcaps);
if (SUCCEEDED(hRes))
{
switch(devcaps.dwDevType)
{
case 0x00000022: //Old API
case 0x00000202: //New API
//Full force feedback device found!
break;
case 0x00000302: //New API only
//Tactile feedback mouse found!
break;
}
}
}
Since any TouchSense enabled mouse is a standard system mouse, there are no methods to read mouse position in IFC. You can use the same methods to read input from a regular mouse. IFC is solely for output. That said, you do need to know how your application currently reads mouse input. If your application is not using the standard Win32 mouse messages (e.g., WM_MOUSEMOVE) and functions (e.g., GetCursorPos) to read mouse movement and display the cursor, you will also need to notify IFC that your CImmMouse device should work in relative mode. (Information concerning absolute mode is only applicable to full Force Feedback mice that are attached to their mouse pad such as the Wingman Force Feedback mice. The tactile feedback mice report information in relative mode and will work with standard windows and Dinput position calls). The CImmMouse is by default in absolute mode, meaning it reports an actual screen cursor position and assumes your application is using the standard Win32 mouse services. DirectX is not part of the standard Win32 mouse services, so if you are using DirectX, you need to switch your CImmMouse object to relative mode with the following method:
// change from standard Win32 mouse services to relative position reporting
m_pTSMouse->UsesWin32MouseServices(FALSE);
If you are not sure which mode to use, use the following guidelines. Applications that don’t have a screen cursor and/or allow you to move the physical mouse infinitely in one direction and continually rotate or pan (e.g., 1st person action games) generally use relative mode. Applications that actually have a cursor that stops at the edge of the screen even if you keep moving the physical mouse further generally use the absolute Win32 mouse services. A game like Microsoft’s Age of Empires allows continual panning. However, the actual cursor stops at the edge of the screen while panning, so it is using absolute mode.
IMPORTANT: If while using your Immersion device you can move the cursor in other applications but cannot get mouse movement in your application, you most likely need to either switch your CImmMouse to relative mode or use GetCursorPos if that is suitable for your application.
IMPORTANT: If your application switches your CImmMouse to relative mode, you will not be able to use the two screen-position based effects - Enclosure and Ellipse. Both these effects require you to specify their screen locations and are active only when the cursor is in those locations. If you want to use Enclosure and Ellipse effects, your application needs to leave the CImmMouse object in absolute mode and use the Win32 mouse services for mouse input.