--
| Robert Gatlin - Supercomputer Interconnect Components - Intel Corporation |
| gat...@scic.intel.com ...!any-MX-mailer-like-uunet!scic.intel.com!gatlin |
______ _ ________ _ __ _
/ _____\ / \ __ __| | | |\ | |
| / / _ \ | | | | | | \ | |
| | ____/ /_\ \ | | | | | |\ \| |
| | |__ | ___ \| | | | | ||\ \ |
| \____/ | / \ \ | | |___| || \ |
Sure. Open a "RAW:" window, and use Read() from dos.library.
BTW, I think there's a special escape sequence for turning a
normal "CON:"-window (e.g. the AmigaShell) into a "RAW:" window.
If you need more info, mail me.
>| Robert Gatlin - Supercomputer Interconnect Components - Intel Corporation |
>| gat...@scic.intel.com ...!any-MX-mailer-like-uunet!scic.intel.com!gatlin |
-- Juergen
o _ Juergen Weinelt, Germany
| (_) \/\/ UUCP: swb.de!imart!hcast!jow
' CBMNET: j...@hcast.adsp.sub.org
Check out RawIO on Fred Fish disk #85 (Yes, 85). It contains
source to a function to change the console window to raw mode
based on a Lattice C filehandle. This still works with Lattice
and SAS/C version 5.x. Under 6.0, functions are provided in the
library to do this.
--
*****
=*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 =
*|. o.| || 1200/2400/9600 Dual
| o |// For all you do, this bug's for you!
======
usenet: wal...@unx.sas.com bix: djwalker
Any opinions expressed are mine, not those of SAS Institute, Inc.
Here is a simple little routine that I use to get a 'hotkey' type of
response. Because of the use of the SetMode() function this routine is
effectively 2.x only.
----------------------------[ cut ]----------------------------------------
char GetHotKey()
{
BPTR FH;
char c;
FH=Input(); /* find stdin */
SetMode(FH, 1); /* switch stdin to RAW: mode (v36+) */
if(WaitForChar(FH, 0)) /* if there is a character available right away get */
{ /* it, otherwise don't wait. NOTE** there are problems */
/* with WaitForChar() with a timeout of 0 under 1.2/1.3 */
Read(FH, &c, 1); /* get waiting character */
}
else c=0;
return(c); /* return character if one was waiting, or 0 if none */
}
----------------------------[ cut ]----------------------------------------
I've found no problems with switching stdin to RAW: and not switching it
back, but you can switch it back to CON: before the return(c) if you like.
Also, there doesn't seem to be any problems with switching it to RAW:
every time, and since we _have_ to have it in RAW: for this to work, and
anything else can switch it to CON: then we have to switch it to make sure
we know its state.
Hope this proves helpful...
>--
>| Robert Gatlin - Supercomputer Interconnect Components - Intel Corporation |
>| gat...@scic.intel.com ...!any-MX-mailer-like-uunet!scic.intel.com!gatlin |
> ______ _ ________ _ __ _
> / _____\ / \ __ __| | | |\ | |
>| / / _ \ | | | | | | \ | |
>| | ____/ /_\ \ | | | | | |\ \| |
>| | |__ | ___ \| | | | | ||\ \ |
>| \____/ | / \ \ | | |___| || \ |
--
+-------------------------------------+
/ Rick Morrow - r...@delfax.ocunix.on.ca \
<----------------------------------------->
\ North Bay - Ontario - Canada /
+-------------------------------------+
[30-Sep-92: Weinelt/All]
>> I am writting a program in C (Lattice) and need to read a single
>> character from the keyboard without having to wait for the user to hit
>> <CR>. I have tried to use the ansii getc() function, but obviously
>> waits for a <CR>. The I*M version of Turbo C has a non-ansii standard
>> function getch() which does what I want. Is a similar function or
>> workaround available for Amiga C?
JW> Sure. Open a "RAW:" window, and use Read() from dos.library. BTW, I
JW> think there's a special escape sequence for turning a normal
JW> "CON:"-window (e.g. the AmigaShell) into a "RAW:" window.
I'm new to this echo, so excuse me if I'm off-topic... But if you're running 2.
0+ the following code might do the trick:
#define CON 0L
#define RAW 1L
long
getch(void)
{
long c;
BPTR fh = Input();
SetMode(fh,RAW);
c = FGetC(fh);
SetMode(fh,CON);
return(c);
}
This has been tested and it works. If somebody out there wants a 1.3-version,
please contact me by E-Mail. :-)
Bliss!
/\ : *** Magnetic Ink *** . FidoNet 2:230/119
/ Klaus Seistrup @ : Ahornsgade 8A, 1.TH. -*- Tel: +45 35-372-171
/____\ : DK-2200 Copenhagen N | AmigaNet 39:141/110
* "Walking back through the hills of dry grass - coming upriver" *
---