I am doveloping a game brain champ. This is its version 3. In this version I want to use mouse in addition with keyboard for input. I have successfully tested its standalone keyboard version as well as mouse version. I have used int86() function for mouse with 0x33 interrupt number. Also I have used getch() function for keyboard input. But my main problem is I m not able to use mouse and keyboard simultaneously. As when I do so getch() holds the program and thus I can't get mouse input simultaneously. Please help me out. I am working on turbo c++ 3.0. I am an experienced programmer. Please give me sample code so that I can use it accordingly. Thanks in advance.

Before calling getch() find out if anything is in the keyboard buffer kbhit() from conio.h will tell you that. If nothing there then you can check for mouse input.

Thanks for your reply ancient dragon. I understand the whole concept but there is a small problem if I hit keyboard more than one time then getch() just take one input at one time. So buffer has input still after the call to getch(). How can I clear this buffer() after single call to getch(). Fflush(stdin) isn't working.

fflush is not supposed to work with stdin -- it's only for output streams like stdout. You can write your own fflush like this

void flushKeyboard()
{
   while( kbhit() )
       getch();
}

U r such a beautiful dragon. Thank you so much. :-).
But as u knw problems never end for a programmer. There is another minor problem. Whenever I use clearviewport() to clear the screen the portion of screen beneath the mouse cursor remains there uncleared. What should I do to clear that portion.

I have no idea -- have not used Turbo C in 30 years.

Ok thanks. I will make out that thing on my own, thank you so much.

helo sanyam.mishra this is header file *.h include most func you need with turbo C++
you must manipulate registry value with ("reg., init86().....") included from <dos.h>
If you need any help

E- mail: 51284191@orange.tn
#include <dos.h>
#include <stddef.h>


   typedef enum Boolean {false,true}boolean;
   union REGS reg;
   int etat();
   int X();
   int Y();
   void MouseInit();
   void MouseOn();
   void MouseOff();
   int Left();
   int Right();
   int MouseIn();
   void curseur(int x,int y);
   void MouseInit()
   {
      reg.x.ax=0x00;
      int86(0x33,®,®);
   }
   void MouseOn()
   {
     reg.x.ax=0x01;
     int86(0x33,®,®);
   }
   void MouseOff()
   {
      reg.x.ax=0x02;
      int86(0x33,®,®);
   }
   int X()
   {
      reg.x.ax=0x03;
      int86(0x33,®,®);
      return(reg.x.cx);
   }
   int Y()
   {
     reg.x.ax=0x03;
     int86(0x33,®,®);
     return(reg.x.dx);
   }
   int Left()
   {
      reg.x.ax=0x03;
      int86(0x33,®,®);
      return((reg.x.bx==1));
   }
   int Right()
   {
      reg.x.ax=03;
      int86(0x33,®,®);
      return((reg.x.bx==2));
   }
   int MouseIn(int x1,int x2,int y1,int y2)
   {
      reg.x.ax=0x03;
      int86(0x33,®,®);
      reg.x.bx=2;
      return ((X()>=x1)&(X()<=x2)&(Y()<=y2)&(Y()>=y1));
   }
   int etat(void)
   {
     reg.x.ax=0x03;
     int86(0x33,®,®);
     return(reg.x.bx);
   }
   ------
   void cursor_pointer(int x,int y)
{
while(!kbhit())
{
setcolor(0);
outtextxy(x,y,"_");
delay(150);
setcolor(9);
outtextxy(x,y,"_");
delay(150);
}
}

-------------//good luck//

Thanks paul but I had already figured this put. But anyway I will save this for my future reference. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.