/*
|
/*
|
*/
|
*/
|
|
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <errno.h>
|
#include <errno.h>
|
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
#include <fcntl.h>
|
#include <fcntl.h>
|
|
|
#include <rtems/mw_uid.h>
|
#include <rtems/mw_uid.h>
|
#include <rtems/kd.h>
|
#include <rtems/kd.h>
|
|
|
static const char *Q_NAME = "MWQ";
|
static const char *Q_NAME = "MWQ";
|
#define Q_MAX_MSGS 128
|
#define Q_MAX_MSGS 128
|
|
|
|
|
/*
|
/*
|
* "Select() routine called by the MicroWindows framework to receive events
|
* "Select() routine called by the MicroWindows framework to receive events
|
* from the input devices.
|
* from the input devices.
|
*/
|
*/
|
void GsSelect(void)
|
void GsSelect(void)
|
{
|
{
|
struct MW_UID_MESSAGE m;
|
struct MW_UID_MESSAGE m;
|
int rc;
|
int rc;
|
|
|
/* let's make sure that the type is invalid */
|
/* let's make sure that the type is invalid */
|
m.type = MV_UID_INVALID;
|
m.type = MV_UID_INVALID;
|
|
|
/* wait up to 100 milisecons for events */
|
/* wait up to 100 milisecons for events */
|
rc = uid_read_message( &m, 100 );
|
rc = uid_read_message( &m, 100 );
|
|
|
/* return if timed-out or something went wrong */
|
/* return if timed-out or something went wrong */
|
if( rc < 0 )
|
if( rc < 0 )
|
{
|
{
|
if( errno != ETIMEDOUT )
|
if( errno != ETIMEDOUT )
|
printf( " rc= %d, errno=%d\n", rc, errno );
|
printf( " rc= %d, errno=%d\n", rc, errno );
|
return;
|
return;
|
}
|
}
|
/* let's pass the event up to microwindows */
|
/* let's pass the event up to microwindows */
|
switch( m.type )
|
switch( m.type )
|
{
|
{
|
/* Mouse or Touch Screen event */
|
/* Mouse or Touch Screen event */
|
case MV_UID_REL_POS:
|
case MV_UID_REL_POS:
|
case MV_UID_ABS_POS:
|
case MV_UID_ABS_POS:
|
printf( "Mouse: btns=%X, dx=%d, dy=%d, dz=%d\n",
|
printf( "Mouse: btns=%X, dx=%d, dy=%d, dz=%d\n",
|
m.m.pos.btns, m.m.pos.x, m.m.pos.y, m.m.pos.z );
|
m.m.pos.btns, m.m.pos.x, m.m.pos.y, m.m.pos.z );
|
break;
|
break;
|
|
|
|
|
/* KBD event */
|
/* KBD event */
|
case MV_UID_KBD:
|
case MV_UID_KBD:
|
printf( "Kbd: code=%X, modifiers=%X, mode=%d\n",
|
printf( "Kbd: code=%X, modifiers=%X, mode=%d\n",
|
(unsigned char )m.m.kbd.code, m.m.kbd.modifiers, m.m.kbd.mode );
|
(unsigned char )m.m.kbd.code, m.m.kbd.modifiers, m.m.kbd.mode );
|
break;
|
break;
|
|
|
/* micro-windows does nothing with those.. */
|
/* micro-windows does nothing with those.. */
|
case MV_UID_TIMER:
|
case MV_UID_TIMER:
|
case MV_UID_INVALID:
|
case MV_UID_INVALID:
|
default:
|
default:
|
;
|
;
|
}
|
}
|
}
|
}
|
|
|
extern "C" int close( int );
|
extern "C" int close( int );
|
extern "C" int rtems_main(int argc, char **argv)
|
extern "C" int rtems_main(int argc, char **argv)
|
{
|
{
|
int status;
|
int status;
|
printf( "Starting untar file.\n" );
|
printf( "Starting untar file.\n" );
|
struct MW_UID_MESSAGE m;
|
struct MW_UID_MESSAGE m;
|
|
|
int rc;
|
int rc;
|
/* if this is the first time around, create the message queue */
|
/* if this is the first time around, create the message queue */
|
rc = uid_open_queue( Q_NAME, O_CREAT | O_RDWR, Q_MAX_MSGS );
|
rc = uid_open_queue( Q_NAME, O_CREAT | O_RDWR, Q_MAX_MSGS );
|
|
|
printf( "Open QUEUE=%X\n", rc );
|
printf( "Open QUEUE=%X\n", rc );
|
|
|
int mouse_fd = open( "/dev/mouse", O_NONBLOCK );
|
int mouse_fd = open( "/dev/mouse", O_NONBLOCK );
|
uid_register_device( mouse_fd, Q_NAME );
|
uid_register_device( mouse_fd, Q_NAME );
|
|
|
/* kbd it is already opened */
|
/* kbd it is already opened */
|
int kbd_fd = fileno( stdin );
|
int kbd_fd = fileno( stdin );
|
uid_register_device( kbd_fd, Q_NAME );
|
uid_register_device( kbd_fd, Q_NAME );
|
|
|
int old_mode = 0;
|
int old_mode = 0;
|
/* set keyboard to scanmode */
|
/* set keyboard to scanmode */
|
rc = uid_set_kbd_mode( kbd_fd, MV_KEY_MODE_SCANCODE, &old_mode );
|
rc = uid_set_kbd_mode( kbd_fd, MV_KEY_MODE_SCANCODE, &old_mode );
|
printf( "Kbd OldMode=%X, rc=%d\n", old_mode, rc );
|
printf( "Kbd OldMode=%X, rc=%d\n", old_mode, rc );
|
while( TRUE )
|
while( TRUE )
|
{
|
{
|
GsSelect();
|
GsSelect();
|
}
|
}
|
uid_unregister_device( kbd_fd );
|
uid_unregister_device( kbd_fd );
|
uid_unregister_device( mouse_fd );
|
uid_unregister_device( mouse_fd );
|
rc = uid_close_queue();
|
rc = uid_close_queue();
|
printf( "Close QUEUE=%X\n", rc );
|
printf( "Close QUEUE=%X\n", rc );
|
|
|
close( mouse_fd );
|
close( mouse_fd );
|
|
|
fprintf(stdout, "About to leave main()\n" );
|
fprintf(stdout, "About to leave main()\n" );
|
return 0;
|
return 0;
|
}
|
}
|
|
|