Commit 3570a106 authored by deuce's avatar deuce
Browse files

More old mouse stuff... fix variable bug.

parent 80dc165d
......@@ -143,7 +143,6 @@ void add_outevent(int event, int x, int y)
void ciolib_mouse_thread(void *data)
{
struct timespec timeout;
struct in_mouse_event *old_in_event;
int timedout;
int timeout_button=0;
......
......@@ -25,11 +25,9 @@ const struct vid_mode vid_modes[VID_MODES]={
,{C80X50,80,50,1}
};
static struct cio_mouse_event cio_last_button_press;
static struct cio_mouse_event last_mouse_click;
static int lastch=0;
static int domouse=0;
static DWORD last_state=0;
static int xpos=1;
static int ypos=1;
......@@ -84,7 +82,6 @@ unsigned char WintoDOSAttr(WORD newattr)
int win32_kbhit(void)
{
static DWORD last_state=0;
INPUT_RECORD input;
DWORD num=0;
......@@ -99,27 +96,27 @@ int win32_kbhit(void)
if(domouse) {
if(input.EventType==MOUSE_EVENT) {
if(input.Event.MouseEvent.dwEventFlags==MOUSE_MOVED) {
ciomouse_gotevent(CIOLIB_MOUSE_MOVE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_MOUSE_MOVE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
}
if(!input.Event.MouseEvent.dwEventFlags) {
switch(input.Event.MouseEvent.dwButtonState ^ last_state) {
case FROM_LEFT_1ST_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_1_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_1_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_1_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_1_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
case FROM_LEFT_2ND_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_2_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_2_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_2_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_2_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
case RIGHTMOST_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_3_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_3_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_3_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_3_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
}
last_state=input.Event.MouseEvent.dwButtonState;
......@@ -149,7 +146,7 @@ int win32_getch(void)
lastch>>=8;
return(ch);
}
if(mousepending())
if(mouse_pending())
lastch=CIO_KEY_MOUSE;
if(!ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &input, 1, &num)
|| !num || (input.EventType!=KEY_EVENT && input.EventType!=MOUSE_EVENT))
......@@ -183,27 +180,27 @@ int win32_getch(void)
if(domouse) {
if(input.EventType==MOUSE_EVENT) {
if(input.Event.MouseEvent.dwEventFlags==MOUSE_MOVED) {
ciomouse_gotevent(CIOLIB_MOUSE_MOVE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_MOUSE_MOVE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
}
if(!input.Event.MouseEvent.dwEventFlags) {
switch(input.Event.MouseEvent.dwButtonState ^ last_state) {
case FROM_LEFT_1ST_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_1_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_1_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_1_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_1_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
case FROM_LEFT_2ND_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_2_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_2_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_2_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_2_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
case RIGHTMOST_BUTTON_PRESSED:
if(input.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED)
ciomouse_gotevent(CIOLIB_BUTTON_3_PRESS,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_3_PRESS,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
else
ciomouse_gotevent(CIOLIB_BUTTON_3_RELEASE,dwMousePosition.X+1,dwMousePosition.Y+1);
ciomouse_gotevent(CIOLIB_BUTTON_3_RELEASE,input.Event.MouseEvent.dwMousePosition.X+1,input.Event.MouseEvent.dwMousePosition.Y+1);
break;
}
last_state=input.Event.MouseEvent.dwButtonState;
......@@ -212,8 +209,6 @@ int win32_getch(void)
}
}
}
return(0);
}
int win32_getche(void)
......@@ -240,17 +235,9 @@ int win32_initciolib(long inmode)
if(!SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), conmode))
return(0);
cio_api.mouse=1;
memset(&cio_last_button_press,0,sizeof(cio_last_button_press));
memset(&last_mouse_click,0,sizeof(last_mouse_click));
return(1);
}
int win32_getmouse(struct cio_mouse_event *mevent)
{
memcpy(mevent,&last_mouse_click,sizeof(last_mouse_click));
return(0);
}
int win32_hidemouse(void)
{
domouse=0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment