cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/21/11:57:01

From: jsc AT lds DOT co DOT uk
Newsgroups: comp.os.msdos.djgpp
Subject: new user - mouse problems
Date: Wed, 21 Oct 1998 15:43:11 GMT
Organization: Deja News - The Leader in Internet Discussion
Lines: 149
Message-ID: <70kvef$r9$1@nnrp1.dejanews.com>
NNTP-Posting-Host: 194.73.88.179
X-Article-Creation-Date: Wed Oct 21 15:43:11 1998 GMT
X-Http-User-Agent: Mozilla/2.0 (compatible; MSIE 3.0; Windows 95)
X-Http-Proxy: 1.0 x5.dejanews.com:80 (Squid/1.1.22) for client 194.73.88.179
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Sorry but nothing is working. All the other functions are fine but this one
just crashes every time. Anyway, here's the code, someone help please - I
can't go on without a mouse. Thanks, Chris jsc AT lds DOT co DOT uk


#include <dos.h>
#include <bios.h>
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include "mygraph.h"


#define far

#define MOUSE_LB    0x01    /* mouse left button */
#define MOUSE_RB    0x02    /* mouse right button */
#define MOUSE_CB    0x04    /* mouse center button */




int mouse_detect(void)
{
	union REGS regs;

	regs.x.ax = 0x0;
	int86(0x33, &regs, &regs);

	return regs.x.ax;
}

void mouse_show(void)
{
	union REGS regs;

	regs.x.ax = 0x01;
	int86(0x33, &regs, &regs);
}

void mouse_hide(void)
{
	union REGS regs;

	regs.x.ax = 0x02;
	int86(0x33, &regs, &regs);
}

unsigned char mouse_button(unsigned char button)
{
	union REGS regs;

	regs.x.ax = 0x3;
	int86(0x33, &regs, &regs);

	return (regs.x.bx & button);
}


void mouse_abs_pos(int *x, int *y)
{
	union REGS regs;

	regs.x.ax = 0x03;
	int86(0x33, &regs, &regs);
	*x = regs.x.cx;
	*y = regs.x.dx;

	return;
}




int mouse_rel_pos(int *x, int *y)
{
	union REGS regs;

	regs.x.ax = 0xb;
	int86(0x33, &regs, &regs);
	*x = regs.x.cx;
	*y = regs.x.dx;

	return (*x|*y);
}




int main(void)
{

int buttons,num_buttons;
int colour=1;
int x;
int y;
// put the computer into graphics mode

InitGraphics();

// initialize mouse

mouse_detect();

// show the mouse

mouse_show();

while(!kbhit())
     {



	mouse_abs_pos(&x,&y);

	//mouse_rel_pos(&x,&y);

	if(mouse_button(MOUSE_LB))
	{
	Plot_Pixel(&x, &y, colour);
	}

	if(mouse_button(MOUSE_RB))
	{
	if (++colour>15) colour=0;
	}

	}
ExitGraphics();
return(0);
} // end main
















-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019