NewI\O mouse_test
mouse_test.nio is a small app that demonstrates mouse function. Press mouse button #3 to exit.
Here is the sourcecode:
Updated: 01/25/06 ccn
/******************************************************************************
*
* mouse_test.c
*
* Copyright (C) 2005 Chris Nystrom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty whatsoever.
*
* For more license information see:
*
* http://www.gnu.org/copyleft/gpl.html
*
* Contact Author at:
*
* Chris Nystrom
* 11013 Prairie Dove Circle
* Austin, Texas 78758
*
* E-Mail: cnystrom@gmail.com
* Blog: http://conversazione.blogspot.com
* AIM: nystromchris
*
* Soli Deo Gloria
*
*/
#include "nio_lib.h"
int main(int argc, char *argv[])
{
color black;
color white;
int font;
nio_app_init("mouse_test", "0.1");
nio_set_write_wait(1000);
black = nio_get_color("black");
white = nio_get_color("white");
nio_set_screen(640, 480, black);
font = nio_load_sys_font(NIO_DEFAULT_FONT,
NIO_DEFAULT_PTSIZE,
NIO_STYLE_NORMAL, white, black);
nio_term_init(font, black, 10, 10, 24, 80);
while (1) {
mouse_state ms;
ms = nio_mouse_state();
nio_clear_screen(black, FALSE);
nio_print_at(2, 2, "\nNIO Mouse Test (version 0.01)\n",
FALSE);
if (ms.b1 == PRESSED) {
nio_print_at(6, 2, "MOUSE BUTTON 1 PRESSED",
FALSE);
}
if (ms.b2 == PRESSED) {
nio_print_at(8, 2, "MOUSE BUTTON 2 PRESSED",
FALSE);
}
if (ms.b3 == PRESSED) {
break;
}
nio_printf_at(10, 2, FALSE, "MOUSE X = %d", ms.x);
nio_printf_at(12, 2, FALSE, "MOUSE Y = %d", ms.y);
nio_paint();
}
nio_free_font(font);
nio_exit();
exit(0);
}
