Original Post
I started working on this project using DirectInput (as that's what both of my DirectX books have taught me and now I have countless files relying on it) and have managed to get everything working except for the mouse click event. Currently I'm just experimenting with my menu, but no matter what I try, I can't seem to get the game to recognise that I've pressed the left mouse button. My most recent revision of code is:
#define DIRECT_INPUT_DEFINED
#define BUTTON_DEFINED
#include "headers.h"
#include "globals.h"
int Mouse_X();
int Mouse_Y();
int Mouse_Button(char button);
POINT location;
void MouseCheck()
{
dimouse->Poll();
if (!SUCCEEDED(dimouse->GetDeviceState(sizeof(mouse_state), (LPVOID)&mouse_state)))
{
dimouse->Acquire();
}
GetCursorPos(&location);
if (location.x >= SCREEN_POSITION_X + 24 && location.x <= SCREEN_POSITION_X + 280 && location.y >= SCREEN_POSITION_Y + 24 && location.y <= SCREEN_POSITION_Y + 192)
{
myButton.currentSurface = true;
if (mouse_state.rgbButtons[0] & 0x80)
{
MessageBox(window, "", "", 0);
}
}
else
{
myButton.currentSurface = false;
}
}[/code
Things to know:
DIRECT_INPUT_DEFINED is merely a header guard that allows dinput.h and associated libraries to be included. I've got ones for D3D and FMOD as well. BUTTON_DEFINED includes the button class.
Anyway, regardless of how I word the mouse_state.rgbButtons bit, the message box just will not show. I've tried inside the if block, outside it, hell I've even removed the if block. Just can't seem to get it to work.
Ideas anyone?