[koogler@bedford.progress.com (David Koogler) writes:]
>I'm trying to find a way to read the console keyboard directly, without having
>to wait and without having to hit return. It should be simple, but I can not
>find a straight forward example.
Well, if you don't mind building a VSTa request directly...
#include <sys/types.h>
#include <sys/fs.h>
main()
{
port_t port;
struct msg m;
uchar buf[128];
int x, y;
/*
* Open port to console server, screen #0
*/
port = path_open("tty/cons:0");
/*
* Or use port attached to standard input
*
port = __fd_port(0);
*/
/*
* Here's your chance to do some typeahead
*/
printf("Type some stuff\n"); sleep(1);
/*
* Send read request, "everything you have" (m_arg == 0)
*/
m.m_op = FS_READ | M_READ;
m.m_arg = 0;
m.m_nseg = 1;
m.m_buf = buf;
m.m_buflen = sizeof(buf);
x = msg_send(port, &m);
/*
* Dump it
*/
printf("Got back %d\n", x);
for (y = 0; y < x; ++y) {
printf(" %02x", buf[y]);
}
printf("\n");
return(0);
}
Received on Mon Mar 6 14:42:22 1995
This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:17 PDT