AmigaActive (149/1728)

From:David Bateman
Date:4 Jun 2001 at 11:50:35
Subject:Header Files (StormC v3)

Hi,

I am trying to use a function called getch() in StormC v3, the header files
i got from http://www.themoebius.org.uk/pm/doc/include/ have been no use.

when i use getch() all i get is a linker error: Symbol "_getch" not defined.

any ideas how i can get a character from the keyboard without pressing
return ?

i have tried c-prog on yahoo groups, but no working solutions as yet.

Cya l8r



Team AMIGA
ICQ:22288065
http://www.robotheaven.freeserve.co.uk
http://www.hvymetal.u-net.com

EZTower/Amiga A1200
OS3.9/MorphOS/Linux(2.2.10 kernel)/MUIPPC
64Mb/PPC 603e(200/040)
2.1Gb HD/8x CD-ROM/PortJnr/USR 56k/250MB ZIP
17" SVGA/BVisionPPC/CGX v4.2(pre 8)

In matters of style, swim with the current; In matters of principle, stand
like a rock.
-- Thomas Jefferson

----------

#ifndef __CONIO_H
#define __CONIO_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <types.h>

void WriteChar(char ch);
void WriteConsole(const char* str);
void WriteNumber(DWORD dw, int nWidth, int nBase, BOOL bPad);
void WriteHex(DWORD dw, int nWidth);
void WriteDecimal(DWORD dw, int nWidth);
void WriteItem(const char* str, DWORD val);

/* "bucky bits"
0x0100 is reserved for non-ASCII keys, so start with 0x200 */
#define KBD_BUCKY_ALT 0x0200 /* Alt is pressed */
#define KBD_BUCKY_CTRL 0x0400 /* Ctrl is pressed */
#define KBD_BUCKY_SHIFT 0x0800 /* Shift is pressed */
#define KBD_BUCKY_CAPS 0x1000 /* CapsLock is on */
#define KBD_BUCKY_NUM 0x2000 /* NumLock is on */
#define KBD_BUCKY_SCRL 0x4000 /* ScrollLock is on */
#define KBD_BUCKY_ALTGR 0x8000 /* AltGr is pressed */
#define KBD_BUCKY_ANY (KBD_BUCKY_ALT | KBD_BUCKY_CTRL | KBD_BUCKY_SHIFT | KBD_BUCKY_ALTGR)

/* "raw" set 3 scancodes from PC keyboard
xxx - finish this listing later */
#define RAW_LEFT_CTRL 0x11
#define RAW_LEFT_SHIFT 0x12
#define RAW_CAPS_LOCK 0x14
#define RAW_LEFT_ALT 0x19
#define RAW_RIGHT_ALT 0x39
#define RAW_RIGHT_CTRL 0x58
#define RAW_RIGHT_SHIFT 0x59
#define RAW_SCROLL_LOCK 0x5F
#define RAW_NUM_LOCK 0x76
#define RAW_END_1 0x69 /* End/1 on numeric keypad */
#define RAW_BREAK_CODE 0xF0

/* "ASCII" values for non-ASCII keys. All of these are user-defined.
function keys: */
#define KEY_F1 0x100
#define KEY_F2 (KEY_F1 + 1)
#define KEY_F3 (KEY_F2 + 1)
#define KEY_F4 (KEY_F3 + 1)
#define KEY_F5 (KEY_F4 + 1)
#define KEY_F6 (KEY_F5 + 1)
#define KEY_F7 (KEY_F6 + 1)
#define KEY_F8 (KEY_F7 + 1)
#define KEY_F9 (KEY_F8 + 1)
#define KEY_F10 (KEY_F9 + 1)
#define KEY_F11 (KEY_F10 + 1)
#define KEY_F12 (KEY_F11 + 1) /* 0x10B */
/* cursor keys */
#define KEY_INS (KEY_F12 + 1) /* 0x10C */
#define KEY_DEL (KEY_INS + 1)
#define KEY_HOME (KEY_DEL + 1)
#define KEY_END (KEY_HOME + 1)
#define KEY_PGUP (KEY_END + 1)
#define KEY_PGDN (KEY_PGUP + 1)
#define KEY_LFT (KEY_PGDN + 1)
#define KEY_UP (KEY_LFT + 1)
#define KEY_DN (KEY_UP + 1)
#define KEY_RT (KEY_DN + 1) /* 0x115 */
/* print screen/sys rq and pause/break */
#define KEY_PRNT (KEY_RT + 1) /* 0x116 */
#define KEY_PAUSE (KEY_PRNT + 1) /* 0x117 */
/* these return a value but they could also act as additional bucky keys */
#define KEY_LWIN (KEY_PAUSE + 1) /* 0x118 */
#define KEY_RWIN (KEY_LWIN + 1)
#define KEY_MENU (KEY_RWIN + 1) /* 0x11A */

char getch();
BOOL kbhit();
WORD ReadKey();

#ifdef __cplusplus
}
#endif

#endif

----------

#ifndef __TYPES_H
#define __TYPES_H

#ifndef NULL
#define NULL 0
#endif

typedef unsigned long size_t;

typedef unsigned char BYTE; // 8-bit byte
typedef unsigned short WORD; // 16-bit word
typedef unsigned int DWORD; // 32-bit dword
typedef unsigned int ADDR; // address that should not be deref'd
typedef DWORD ULONG;

typedef unsigned char UINT8; // 8-bit unsigned integer
typedef signed char INT8; // 8-bit signed integer
typedef unsigned short UINT16; // 16-bit unsigned integer
typedef signed short INT16; // 16-bit signed integer
typedef unsigned long UINT32; // 32-bit unsigned integer
typedef signed long INT32; // 32-bit signed integer

typedef unsigned char NCHAR; // ISO 8859-1 character

#if defined(__cplusplus)
typedef __wchar_t WCHAR; // Unicode character
#else
typedef short int WCHAR;
#endif

typedef WCHAR CHAR; // General (Unicode) character

typedef DWORD BOOL; // boolean value
#define TRUE 1
#define FALSE 0

#define HIBYTE(x) ((BYTE)((x) >> 8))
#define LOBYTE(x) ((BYTE)((x) & 0xff))
#define ABS(x) ((x) < 0 ? -(x) : (x)) // NB: multiple evaluations!

#define S_OK 0x00000000
#define S_FALSE 0x00000001
#define S_EOF 0x00000002

#define E_FAIL 0x80000000
#define E_OUTOFMEMORY 0x80000001
#define E_INVALIDARGS 0x80000002
#define E_INVALIDFORMAT 0x80000003
#define E_NOTFOUND 0x80000004
#define E_ACCESSDENIED 0x80000005
#define E_INVALIDBUFFER 0x80000006
#define E_NOTIMPLEMENTED 0x80000007

#define FAILED(hr) (((hr) & 0x80000000) == 0x80000000)
#define SUCCEEDED(hr) (((hr) & 0x80000000) != 0x80000000)
#define HRESULT_FALSE(hr) (((hr) & 0x00000001) == 0x00000001)
#define HRESULT_TRUE(hr) (((hr) & 0x00000001) != 0x00000001)

typedef struct _GUID
{
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;

typedef DWORD HRESULT;
typedef GUID IID;
typedef GUID CLSID;

#define STRUCT(name) typedef struct _##name name; struct _##name

#endif // __TYPES_H

[Non-text portions of this message have been removed]

Quote carefully and read all ADMIN:README mails

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/