944,080 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 5701
  • C++ RSS
Mar 27th, 2005
0

Accessing a mouse button

Expand Post »
Hi, I am making some software for microchips. I am currently developing some algorithms or the PC, and was wondering if there is a way to access a mouse button in very simple C, not c++, in the form of a variable, either on or off. Also, switch bounce is not an issue, as I would like to accommadate for this in the programming

Thanks in advance,

Dave
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave2point0 is offline Offline
6 posts
since Mar 2005
Mar 27th, 2005
0

Re: Accessing a mouse button

Not knowing what operating system you are using, here is some old and ugly Turbo C code. You could leave out the x,y info. It contains the one big hint, that you might as well use assembler ...
C++ Syntax (Toggle Plain Text)
  1. /************************** m_releas.cf ******************************
  2. **
  3. ** Returns pointers to the coordinate values x, y of the mouse cursor
  4. ** position at which the button was clicked (x, y values jump in steps
  5. ** of 8 in text mode). Also returns a pointer to the number of times
  6. ** the button was released. This value will reset to 0 after the call.
  7. ** This function is preferred over the m_button_press() function.
  8. ** call m_button_release(0, &x, &y, &rnum)
  9. **
  10. ** Written in TURBO C V.2.0 by vegaseat 2/13/89
  11. **
  12. ************************************************************************/
  13.  
  14. void m_button_release(int button, int *x, int *y, int *rel)
  15. /* mouse function #6, find out how many times a button has been released */
  16. /* which button left = 0, right = 1 Returns position x (0-639),y (0-199) */
  17. /* at which the click occured and number of releases, call resets to 0 */
  18. { /* needs DOS.H and union REGS inreg, outreg */
  19. inreg.x.ax = 6;
  20. inreg.x.bx = button;
  21. int86(0x33,&inreg,&outreg);
  22. *x = outreg.x.cx;
  23. *y = outreg.x.dx;
  24. *rel = outreg.x.bx;
  25. }
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Mar 28th, 2005
0

Re: Accessing a mouse button

Quote originally posted by vegaseat ...
Not knowing what operating system you are using,
I'm using windows XP

Ummmmm.... Sorry, I'm not very good at C, do you know how I could translate this info into a variable (i.e. 1 of button down & 0 for button up), because I only need to access the state of the mouse button, not the X, Y. Well, thanks loads anyway
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave2point0 is offline Offline
6 posts
since Mar 2005
Mar 28th, 2005
0

Re: Accessing a mouse button

Also, I get all these errors:
Sorry if this is something obvious - not one of my bios program has even nearly done what it was supposed to

Warning W8065 C:\c\button.c 9: Call to function 'm_button_release' with no prototype in function main
Error E2356 C:\c\button.c 19: Type mismatch in redeclaration of 'm_button_release'
Error E2451 C:\c\button.c 20: Undefined symbol 'inreg' in function m_button_release
Error E2451 C:\c\button.c 22: Undefined symbol 'outreg' in function m_button_release
Warning W8065 C:\c\button.c 22: Call to function 'int86' with no prototype in function m_button_release
Warning W8057 C:\c\button.c 26: Parameter 'button' is never used in function m_button_release
Warning W8057 C:\c\button.c 26: Parameter 'x' is never used in function m_button_release
Warning W8057 C:\c\button.c 26: Parameter 'y' is never used in function m_button_release
Warning W8057 C:\c\button.c 26: Parameter 'rel' is never used in function m_button_release
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dave2point0 is offline Offline
6 posts
since Mar 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Recursion: when do you use it?
Next Thread in C++ Forum Timeline: Is there an array[x][y][z] in C++ (i.e TRIPLE ARRAY)???





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC