From: Jay Link (jlink@interlink-bbs.com)
Date: Thu 16 Mar 2000 - 08:04:17 IST
> I recently decided to have a playw ith svgalib and for the life of me I cant
> work out why the attached bit of code doesnt work. It's so stupidly simple
> that it should work! The docs imply that mouse_waitforupdate will block
> until something happens, yet it refuses to block or return any x/y coords...
> could you guide me in the right direction so I can move on and actually do
> something productive with it?:)
Hello John,
Thanks for writing.
Mainly, the answer you're looking for is that vga_setmousesupport(1)
should come *before* vga_setmode(1).
However, some other things should be noted:
* You should #include <vgamouse.h>
* You don't need mouse_setdefaulteventhandler()
* mouse_close() is unnecessary if you initialize the mouse with
vga_setmousesupport()
* Since you aren't taking any command line arguments, you could suffice
with int main(void) { }. However, if you *were* to take command line
arguments, then it should be char *argv[] (with brackets), or else
maybe char **argv (I think that would work, too).
Hope that helps. Good luck!
Cheers,
-Jay Link
#include <stdio.h>
#include <vga.h>
#include <time.h>
// My shockingly excellent program that doesnt actually work.
int main(int argc, char* argv)
{
time_t initialTime, currentTime;
vga_init();
vga_setmode(1);
vga_setmousesupport(1);
mouse_setdefaulteventhandler();
// Do this for 100 seconds
initialTime = time(NULL);
do
{
currentTime = time(NULL);
mouse_waitforupdate();
printf("Mouse is at x=%d y=%d\n", mouse_getx(), mouse_gety());
} while (currentTime < initialTime + 100);
mouse_close();
exit(0);
}
This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:23 IST