2013-11-29 09:23:00 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Temp input handler, not stable!
|
|
|
|
// When starting the program, don't click anywhere until the program starts
|
|
|
|
// because that breaks the input..
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-11-26 11:33:16 +01:00
|
|
|
#ifndef _INPUTCLASS_H_
|
|
|
|
#define _INPUTCLASS_H_
|
|
|
|
|
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
|
|
|
|
#pragma comment(lib, "dinput8.lib")
|
|
|
|
#pragma comment(lib, "dxguid.lib")
|
|
|
|
|
|
|
|
#include <dinput.h>
|
|
|
|
|
|
|
|
class InputClass
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
IDirectInput8* m_directInput;
|
|
|
|
IDirectInputDevice8* m_keyboard;
|
|
|
|
IDirectInputDevice8* m_mouse;
|
|
|
|
|
|
|
|
unsigned char m_keyboardState[256];
|
|
|
|
DIMOUSESTATE m_mouseState;
|
|
|
|
|
2014-02-14 11:26:50 +01:00
|
|
|
float mousePosX, mousePosY;
|
|
|
|
|
2013-11-26 11:33:16 +01:00
|
|
|
bool ReadKeyboard();
|
|
|
|
bool ReadMouse();
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
InputClass();
|
|
|
|
~InputClass();
|
|
|
|
|
|
|
|
// Initialize DirectInput8Create and acquire the mouse and keyboard
|
|
|
|
bool Initialize(HINSTANCE, HWND, int, int);
|
|
|
|
|
|
|
|
//read the mouse and keyboard and send back
|
|
|
|
// delta mouse pos and if any button is pressed
|
|
|
|
bool Update();
|
2014-02-14 11:26:50 +01:00
|
|
|
bool Update( float mousePosX, float mousePosY );
|
2013-11-26 11:33:16 +01:00
|
|
|
|
|
|
|
bool IsKeyPressed(int key);
|
|
|
|
bool IsMousePressed();
|
2013-11-29 10:04:44 +01:00
|
|
|
|
|
|
|
// Call if mouse is pressed
|
|
|
|
float GetYaw();
|
|
|
|
float GetPitch();
|
|
|
|
|
2014-02-14 11:26:50 +01:00
|
|
|
void SetMousePos( float x, float y );
|
|
|
|
void GetMousePos( float &x, float &y );
|
2013-11-26 11:33:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|