I want to slow down mouse sensitivity as soon as I'm aiming at the nearest target. How can I change mouse sensitivity of a game which is using direct input? I can display mousestate.lX and IY but changing it does not work.
Code:
#include <ddraw.h>
#include <dinput.h>
#pragma comment (lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
LPDIRECTINPUT8 din; // pointer to the DirectInput interface
LPDIRECTINPUTDEVICE8 dmouse; // pointer to the mouse device
DIMOUSESTATE mouse_state; // pointer t about the mouse information
void init_mouse(HINSTANCE hInstance, HWND hWnd){
// create a direct input interface
DirectInput8Create(hInstance, // Handle to the application
DIRECTINPUT_VERSION, // compatible version
IID_IDirectInput8, // DirectInput interface version
(void**)&din, // pointer to the interface
NULL); // COM, leave it NULL
//create device
din->CreateDevice(GUID_SysMouse,
&dmouse,
NULL);
//set format
dmouse->SetDataFormat(&c_dfDIMouse);
//set control you will have over the device
dmouse->SetCooperativeLevel(hWnd, DISCL_EXCLUSIVE | DISCL_FOREGROUND);
}
float mouse_x, mouse_y, mouse_z;
void detect_mouse(){
//access the the input if you dnt already have access
dmouse->Acquire();
//access mouse information
dmouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mouse_state);
//mousestate.lX; //movement on the X axis
//mousestate****; //movement on the Y axis
//does NOT do crap
mouse_state.lX += (float)mouse_state.lX / 2;
mouse_state**** += (float)mouse_state**** / 2; //for inverse -=
// ***** check for mouse movements *****
// this is done seperately so that you can adjust mouse sensitivity
// check if mouse is going forward - player looks up
if (mouse_state**** < 0)
{
// now what?
}
// check if mouse is going back - player looks down
if (mouse_state**** > 0)
{
}
// check if mouse is going left - player rotates left
if (mouse_state.lX < 0)
{
}
// check if mouse is going right - player rotates right
if (mouse_state.lX > 0)
{
}
}
void clean_mouse(){
dmouse->Unacquire(); // close mouse
din->Release(); // close directinput
}