Original Post
Hi, im developping a game and my dinput is not working after i put di_obj->Release(); I checked some posts here and saw some answers but didnt work here. So I'd like to know if I can create 2 direct input objects for only one window, can I? I made a class:
class input {
public:
LPDIRECTINPUT8 di_obj;
DIPROPDWORD di_prop;
LPDIRECTINPUTDEVICE8 di_dev;
HWND hwnd;
int dev_type;
public:
//Buffer
vector<DWORD> buffer;
vector<DWORD> apertado;
//Erros
bool bufferof;
bool b_erro;
bool i_erro;
};
class mouse:public input{
public:
mouse();
mouse(LPDIRECTINPUT8 diobj, HWND hWnd, int dev);
~mouse();
bool estado();
void ZeroValues();
void verEntrada(bool fimediato, bool fbuffer);
int loadDevice(LPDIRECTINPUT8 diobj, HWND hWnd, int dev);
void LimpaTeclas(bool fimediato, bool fbuffer);
//Imediato
DIMOUSESTATE imediato;
};
class teclado:public input{
public:
teclado();
teclado(LPDIRECTINPUT8 diobj, HWND hWnd, int dev);
~teclado();
bool estado();
void ZeroValues();
void verEntrada(bool fimediato, bool fbuffer);
int loadDevice(LPDIRECTINPUT8 diobj, HWND hWnd, int dev);
void LimpaTeclas(bool fimediato, bool fbuffer);
//Imediato
vector<BYTE> imediato;
};
See that both 'mouse' and 'teclado' (keyboard) class are derived from input class. I'll ajust some functions after. Now im just testing. But the problem is that when the app loads, it creates 2 instances: 1 from mouse class and another from keyboard class. In other words, it creates two different direct input objects with one device each. So I would like to know if this is wrong...can I only create one object for each window? Or there's no problem doing this way? The error is when i shutdown mouse class. It gives me access violation error when i try releasing the object. The funny is that keyboard exists first and correctly. Then when comes mouse, it releases the device but the pointer of the object (not null) is already released, so it goes to an error. Where do you think is the prob? thanks all and mary christmas to you.