Recent Posts
HTML | 14 sec ago
Bash | 30 sec ago
None | 53 sec ago
None | 55 sec ago
PHP | 1 min ago
None | 1 min ago
None | 1 min ago
None | 1 min ago
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Domain Reports
Please check out our new and improved Firefox Add-on. hide message
By houbysoftxfcz on the 25th of Oct 2008 08:56:14 PM Download | Raw | Embed | Report
  1. void mouse_handler(struct regs *r)
  2. {
  3.   static unsigned char cycle = 0;
  4.   static char mouse_bytes[3];
  5.   mouse_bytes[cycle++] = inportb(0x60);
  6.  
  7.   if (cycle == 3) { // if we have all the 3 bytes...
  8.     cycle = 0; // reset the counter
  9.     // do what you wish with the bytes, this is just a sample
  10.     if ((mouse_bytes[0] & 0x80) || (mouse_bytes[0] & 0x40))
  11.       return; // the mouse only sends information about overflowing, do not care about it and return
  12.     if (!(mouse_bytes[0] & 0x20))
  13.       y |= 0xFFFFFF00; //delta-y is a negative value
  14.     if (!(mouse_bytes[0] & 0x10))
  15.       x |= 0xFFFFFF00; //delta-x is a negative value
  16.     if (mouse_bytes[0] & 0x4)
  17.       puts("Middle button is pressed!n");
  18.     if (mouse_bytes[0] & 0x2)
  19.       puts("Right button is pressed!n");
  20.     if (mouse_bytes[0] & 0x1)
  21.       puts("Left button is pressed!n");
  22.     // do what you want here, just replace the puts's to execute an action for each button
  23.     // to use the coordinate data, use mouse_bytes[1] for delta-x, and mouse_bytes[2] for delta-y
  24.   }
  25. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: