home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MODEL
/
EVENT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-05
|
3KB
|
160 lines
/*
* イベント制御
*
* Copyright T.Kobayashi 1994.6.26
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#include "event.h"
#include "view.h"
#include "graph.h"
#include "input.h"
#include "ml.h"
extern int QuitFlag;
static int EventKeyIdent[0x80] ;
static int EventSpcKeyIdent[KEY_FUNC_END - KEY_FUNC_START] ;
static int EventInput ;
/* イベント初期化 */
void EventInit()
{
int i ;
EventInput = -1 ;
for( i = 0 ; i < 0x80 ; i++ )
EventKeyIdent[i] = -1 ;
for( i = 0 ; i < (KEY_FUNC_END - KEY_FUNC_START) ;i++ )
EventSpcKeyIdent[i] = -1 ;
}
/* マウス、キー入力待ち */
void WaitMouseOrKey()
{
#if 0
int col ;
static int selectcol ;
selectcol = ( selectcol + 1 ) & 0xFFFF ;
col = ( selectcol >> 3 ) & 511 ;
if ( col >= 256 )
col = 511 - col ;
graph_palet( SELECT_COLOR, 255, 255-col, col );
#endif
WaitInput();
}
/* イベント設定 */
void EventSetKey( ident, key )
int ident ;
char *key ;
{
int code ;
while( *key != '\0' )
{
if ( *key == 'F' )
{
code = 0 ;
key++ ;
while( isdigit( *key ) )
{
code = code * 10 + *key - '0';
key++ ;
}
if ( 0 <= code && code <= (KEY_FUNC_END - KEY_FUNC_START) )
EventSpcKeyIdent[code] = ident ;
}
else
{
code = *key & 0x7F ;
EventKeyIdent[code] = ident ;
key++ ;
}
}
}
/* 入力イベント設定 */
void EventSetInput( ident )
int ident ;
{
EventInput = ident ;
}
/* キーイベント呼び出し */
int CallKeyEvent()
{
int code, ident ;
DataStruct *mark ;
if ( KeyCode & 0x8000 )
{
assert( ( KeyCode & 0xff ) < (KEY_FUNC_END - KEY_FUNC_START) );
code = KeyCode ;
ident = EventSpcKeyIdent[code&0xFF] ;
}
else
{
code = KeyCode & 0x7F ;
ident = EventKeyIdent[code] ;
}
if ( ident >= 0 )
{
mark = StackTop();
StackPushInt( code );
StackPushInt( ShiftStat );
CallFunction( ident, 2, mark+1 );
StackRelease( mark );
return TRUE;
}
return FALSE;
}
/* 入力イベント呼び出し */
void CallInputEvent()
{
DataStruct *mark ;
if ( EventInput >= 0 )
{
mark = StackTop();
StackPushInt( ShiftStat );
CallFunction( EventInput, 1, mark+1 );
StackRelease( mark );
}
}
/* マウスボタンが離されるまで待つ */
void WaitMouseOff()
{
#if 0
do
{
WaitInput();
if (QuitFlag) {
return;
}
} while( MouseLeft || MouseRight );
#else
while( MouseLeft || MouseRight ) {
if (QuitFlag) {
return;
}
WaitInput();
}
#endif
}