Duoas: thanks for the help but its not what i needed to know. I am so sorry for not being direct its my fault, if you woult let me let me explain my problem again and i will also show you my code.
so i am making a simple game in the console window, its not to fancy hehe ok maybe a little bit. here is a actual screenshot of one of the maps i made in tiled for my game
http://s17.postimg.org/p6asy0cbj/Window.png well ok then enough of showing off what i a making.
Console_Mouse.cpp is where i do all my mouse event stuff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#include "Console_Mouse.h"
#include <iostream>
#include <Windowsx.h>
Console_Mouse Console_Mouse::GetMouse()
{
static Console_Mouse m;
return m;
}
Console_Mouse::Console_Mouse()
{
mMouseState = Mouse::State();
}
void Console_Mouse::ProcessEvent(const MOUSE_EVENT_RECORD& msg)
{
switch (msg.dwEventFlags)
{
case MOUSE_MOVED:
GetMouse().Motion(msg);
break;
case 0: //button click
case DOUBLE_CLICK:
GetMouse().Button(msg);
break;
case MOUSE_HWHEELED:
case MOUSE_WHEELED:
GetMouse().Wheel(msg);
break;
}
}
void Console_Mouse::Reset()
{
Console_Mouse* m = &GetMouse();
m->mMouseState->LeftButton = ButtonState::Released;
m->mMouseState->MiddleButton = ButtonState::Released;
m->mMouseState->RightButton = ButtonState::Released;
m->mMouseState->XButton1 = ButtonState::Released;
}
int OldX = 0;
int OldY = 0;
void Console_Mouse::Motion(const MOUSE_EVENT_RECORD& msg)
{
mMouseState->Position.X = msg.dwMousePosition.X;
mMouseState->Position.Y = msg.dwMousePosition.Y;
mMouseState->ReletivePos.X = mMouseState->Position.X - OldX;
mMouseState->ReletivePos.Y = mMouseState->Position.Y - OldY;
if (OldX != mMouseState->Position.X || OldY != mMouseState->Position.Y)
mMouseState->StateChanged = true;
OldX = msg.dwMousePosition.X;
OldY = msg.dwMousePosition.Y;
}
int OldButton = 0;
void Console_Mouse::Button(const MOUSE_EVENT_RECORD& msg)
{
ButtonState bState; //http://msdn.microsoft.com/en-us/library/windows/desktop/ms645610(v=vs.85).aspx
int CurrentButton = msg.dwButtonState;
//set the type of button event
if (CurrentButton) // 0 = button release note we don't know what was released so store last button
bState = ButtonState::Pressed;
else
bState = ButtonState::Released;
if (CurrentButton == FROM_LEFT_1ST_BUTTON_PRESSED || OldButton == FROM_LEFT_1ST_BUTTON_PRESSED) //left
{
mMouseState->LeftButton = bState;
}
else if (CurrentButton == RIGHTMOST_BUTTON_PRESSED || OldButton == RIGHTMOST_BUTTON_PRESSED) //right
{
mMouseState->RightButton = bState;
}
else if (CurrentButton == FROM_LEFT_2ND_BUTTON_PRESSED || OldButton == FROM_LEFT_2ND_BUTTON_PRESSED) //middle
{
mMouseState->MiddleButton = bState;
}
OldButton = CurrentButton;
}
int OldWheelX = 0;
int OldWheelY = 0;
void Console_Mouse::Wheel(const MOUSE_EVENT_RECORD& msg)
{
switch (msg.dwEventFlags)
{
case MOUSE_HWHEELED: // horizontal
mMouseState->ScrollWheel.X = (short)HIWORD(msg.dwButtonState);
mMouseState->ScrollWheel.Y = 0;
break;
case MOUSE_WHEELED: // vertical
mMouseState->ScrollWheel.X = 0;
mMouseState->ScrollWheel.Y = (short)HIWORD(msg.dwButtonState);
break;
}
if (OldWheelX != mMouseState->ScrollWheel.X || OldWheelY != mMouseState->ScrollWheel.Y)
mMouseState->StateChanged = true;
OldWheelX = mMouseState->ScrollWheel.X;
OldWheelY = mMouseState->ScrollWheel.Y;
}
|
not all of the code is tested but what i want to look at is line 49 and 50, where i get the moue position. i am using the MOUSE_EVENT_RECORD but it returns a cursor position as in 8x12 blocks so
screen buffer = 80x32
0x1--------------------------------------- 0x79
|**************************|
|**************************|
|**************************|
|**************************|
|**************************|
|**************************|
0x31--------------------------------------- 31x79
but i need the pixel position. i hope this explains it a little more.