// =======================================-====================================
// Filename: DIMouse.h
// Description: Header file for the DirectInput Mouse class
//
// This code corresponds to DirectX Techniques Series 1 Tutorial 5, at
// www.32bits.co.uk
// ============================================================================
#include <dinput.h>
#include <d3d8.h>
#include "D3DFuncs.h"
#pragma once
#ifndef _DIMOUSE_H
#define _DIMOUSE_H
// We only use the left
#define DIMOUSE_LEFTBUTTON 0
#define DIMOUSE_RIGHTBUTTON 1
#define DIMOUSE_MIDDLEBUTTON 2
class CDIMouse
{
public:
CDIMouse();
~CDIMouse();
HRESULT Initialise(HWND hWnd, int iWindowWidth, int iWindowHeight);
BOOL Update(); // Called every frame to poll the mouse for data
HRESULT Render(LPDIRECT3DDEVICE8 pDevice); // Renders the mouse cursor sprite
int GetRelativeX(); // Doesn't include hotspot
int GetRelativeY(); // Doesn't include hotspot
int GetAbsoluteX(); // Doesn't include hotspot
int GetAbsoluteY(); // Doesn't include hotspot
void GetAbsolutePos(POINT* kMousePos=NULL); // Includes hotspot (for hit testing)
void SetHotSpot(int iX, int iY);
// Returns true if button is down. If kClickPoint != NULL, it's set to the pixel pos on screen of the hotspot
BOOL IsMouseButtonDown(int iButton, POINT* kClickPoint=NULL);
private:
LPDIRECTINPUT8 m_pDIObject;
LPDIRECTINPUTDEVICE8 m_pDIMouseDevice;
int m_iWindowWidth;
int m_iWindowHeight;
DIMOUSESTATE m_kMouseState;
int m_iCursorX;
int m_iCursorY;
int m_iHotSpotX;
int m_iHotSpotY;
};
#endif // _DIMOUSE_H