Category : Files from Magazines
Archive   : CUJ9208.ZIP
Filename : 1008098A

 
Output of file : 1008098A contained in archive : CUJ9208.ZIP
/*-------------------- ShowTch.c -------------------*
* *
* Module: ShowTch.c *
* Purpose: To provide a demonstration about how *
* to use function GetTouch(). *
* Author: W. Harvey Gray *
* Compiler: Microsoft 5.0 *
* *
* Functions: (extern) *
* main *
* *
* Variables: There are no external variables used *
* or defined by this module. *
* *
* Copyright 1992, W. Harvey Gray. May be used *
* freely, if authorship and publication are *
* acknowledged. *
* *
*--------------------------------------------------*/

#include
#include
#include
#include
#include

#include "dvrfunc.h"
#include "GetTouch.h"

/*--------------------------------------------------*
* static prototypes *
*--------------------------------------------------*/

static void print_touch( void );
static void touch_loop( void );

/*--------------------------------------------------*
* extern function main() *
*--------------------------------------------------*/

int main( int argc, char **argv ) {

/*--------------------------------------------------*
* Purpose: *
* *
* Demonstrates a simple routine that reads a *
* complete touchscreen touch and prints its *
* statistics. *
* *
*--------------------------------------------------*/

struct infodata *pinfo;

puts( "ShowTch V1.0" );
puts( " A test program for function GetTouch." );

if ( ! finddriver() ) { /* Check for ELODEV. */

puts( "\nELODEV not installed." );
exit( 1 );
}
/*----------------------------------------------*
* Check for correct device driver version. *
*----------------------------------------------*/

pinfo = malloc( sizeof( struct infodata ) );
driverinfo( pinfo );

if ( ( pinfo->driverversionmajor * 10 +
pinfo->driverversionminor ) < 14 ) {

puts( "\nELODEV not >= version 1.4" );
exit( 2 );
}
free( pinfo );

/*----------------------------------------------*
* Startup the touchscreen device driver. *
*----------------------------------------------*/

setmode( BUFFERED | UNTOUCH | STREAM );
opentouch();
enabletouch();
initdelay();

/*----------------------------------------------*
* Set the button radius to be 4% of the *
* diagonal dimension of the touchscreen. *
*----------------------------------------------*/

InitializeTouch();
SetButtonRadius( 4096/25 );

/*----------------------------------------------*
* Continue reading touches until the key- *
* board is hit. *
*----------------------------------------------*/

while ( ! _bios_keybrd( _KEYBRD_READY ) )
touch_loop();
/* Flush keyboard buffer. */

while ( _bios_keybrd( _KEYBRD_READY ) )
getch();

closetouch();
exit( 0 );
}

/*--------------------------------------------------*
* static function print_touch() *
*--------------------------------------------------*/

static void print_touch( void ) {

/*--------------------------------------------------*
* Purpose: *
* *
* Print the touch statistics. *
* *
*--------------------------------------------------*/

struct touchit *pti;

pti = TouchInfo();
printf( "\nTouch pts = %d;", pti->n );
printf( "\n (X,Y)cen = (" );
printf( "%5d,", pti->xcen );
printf( "%5d);", pti->ycen );
printf( "\n Push button = %s.",
( (pti->button) ? "True" : "False" ) );

return;
}

/*--------------------------------------------------*
* static function touch_loop() *
*--------------------------------------------------*/

static void touch_loop( void ) {

/*--------------------------------------------------*
* Purpose: *
* *
* Read an entire touch and print its statistics *
* when an untouch point is received. *
* *
*--------------------------------------------------*/

boolean button;
boolean touched;

struct touchxy *ptouch;

/*----------------------------------------------*
* Service one complete touch. *
*----------------------------------------------*/

touched = FALSE;
do {

if (( ptouch = GetTouch( &button )) !=
(struct touchxy *) NULL ) {

touched = TRUE; /* Touch point recv'd */

if ( ptouch->ut ) { /* Is a untouch? */

print_touch();
printf(" (Press any key to stop.)" );
break; /* Finished with touch. */
}
}
}
while ( touched );

return;
} /* End of file. */


  3 Responses to “Category : Files from Magazines
Archive   : CUJ9208.ZIP
Filename : 1008098A

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/