home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ Games Programming
/
CPPGAMES.ISO
/
thx
/
include
/
keyfold.h
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-08
|
1KB
|
50 lines
// --------- keyfold.h
#ifndef KEYFOLD_H
#define KEYFOLD_H
#include "hand.h"
#include "handler.h"
#include "folder.h"
#include "debug.h"
const int NUMKEYS = 175;
const int AUX_OFFSET = 71;
// 0-126 are used by ascii values, tilde is the highest (126)
// 130-213 are used by AUX values, DEL being the highest (83)
class KeystrokeFolder : public Folder {
int adjust_key(int);
EventHandler key[NUMKEYS];
friend class KeystrokeServer;
public:
KeystrokeFolder() : Folder(key, NUMKEYS) { }
void register_key(Hand*,int key,callback);
void unregister_key(Hand*,int key,callback);
void reset();
void dispatch(int, int, int);
};
inline int KeystrokeFolder::adjust_key(int k)
{
if ((k&0xff00) != 0)
k = ((k>>8)&0xff)+AUX_OFFSET;
Assert(k >= 0 && k < NUMKEYS);
return k;
}
inline void KeystrokeFolder::register_key(Hand* hand,
int k,callback cb)
{
key[adjust_key(k)].add(hand,cb);
}
inline void KeystrokeFolder::unregister_key(Hand* hand,
int k,callback cb)
{
key[adjust_key(k)].del(hand,cb);
}
#endif