Exemplo n.º 1
0
int ConGetEvent(TEventMask EventMask, TEvent *Event, int WaitTime, int Delete) {
  KBDINFO ki;

  if (EventBuf.What != evNone) {
    *Event = EventBuf;

    if (Delete) EventBuf.What = evNone;
    return 0;
  }

  if (MouseEv.What != evNone) {
    *Event = MouseEv;

    if (Delete) MouseEv.What = evNone;
    return 0;
  }
  EventBuf.What = evNone;
  Event->What   = evNone;

  ki         = SaveKbdState;
  ki.fsMask &= ~(KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE);
  ki.fsMask |= (KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE);
  APIRET16 s = KbdSetStatus(&ki, 0);
  assert(s == 0);

  while ((WaitTime == -1) || (WaitTime >= 0)) {
    if ((ReadKbdEvent(Event, WaitTime) == 1) && (EventMask & evKeyboard)) break;
    else if (MousePresent &&
             (ReadMouseEvent(Event,
                             EventMask) == 1) && (EventMask & evMouse)) break;
    else if (GetPipeEvent(Event) == 1) break;

    if (WaitTime == 0) return -1;

    DosSleep(5);

    if (WaitTime > 0) {
      WaitTime -= 5;

      if (WaitTime <= 0) return -1;
    }
  }

  if (Event->What != evNone) {
    if (Event->What == evMouseMove) {
      while (ReadMouseEvent(&MouseEv, EventMask) == 1) {
        if (MouseEv.What == evMouseMove) {
          *Event       = MouseEv;
          MouseEv.What = evNone;
        } else break;
      }
    }
    EventBuf = *Event;

    if (Delete) EventBuf.What = evNone;
    return 0;
  }
  return -1;
}
Exemplo n.º 2
0
/* Turn on keyboard echo.  Does not check error returns. */
static void
EchoOn( void )
{
  KBDINFO KbdInfo;
  
  KbdGetStatus (&KbdInfo, 0);
  KbdInfo.fsMask = (KbdInfo.fsMask & ~KEYBOARD_ECHO_OFF) | KEYBOARD_ECHO_ON;
  KbdSetStatus (&KbdInfo, 0);
}
Exemplo n.º 3
0
static void set_kbd(void)
{
  KBDINFO kbdInfo;

  kbdInfo = initialKbdInfo;
  kbdInfo.fsMask &= ~0x0001;		/* not echo on		*/
  kbdInfo.fsMask |= 0x0002;		/* echo off		*/
  kbdInfo.fsMask &= ~0x0008;		/* cooked mode off	*/
  kbdInfo.fsMask |= 0x0004;		/* raw mode		*/
  kbdInfo.fsMask &= ~0x0100;		/* shift report	off	*/
  KbdSetStatus(&kbdInfo, 0);
}
Exemplo n.º 4
0
void SLang_reset_tty (void)
{
   if (0 == SLos2_threadID) return;
   atEnd = 1;                      /* set flag and wait until thread ends */
   while (atEnd) {DosSleep (0);}

   CloseSem();

   /* close the keyboard */
   KbdSetStatus(&initialKbdInfo, 0); /* restore original state	*/
   SLos2_threadID = 0;
}
Exemplo n.º 5
0
void TEventQueue::suspend()
{
#ifdef __OS2__
  {
    KBDINFO ki;
    ki.cb = sizeof(ki);
    assert(!KbdGetStatus(&ki,0));
    ki.fsMask |= KEYBOARD_ASCII_MODE;
    ki.fsMask &= ~KEYBOARD_BINARY_MODE;
    assert(!KbdSetStatus(&ki,0));
  }
#endif
    mouse.suspend();
}
Exemplo n.º 6
0
KBDINFO setkbmode(void)
{
    USHORT rc;
    KBDINFO kb_state;

    kb_state.cb = sizeof(kb_state);
    KbdGetStatus(&kb_state, 0);
    kb_state.fsMask &= ~KEYBOARD_ASCII_MODE;
    kb_state.fsMask |= KEYBOARD_BINARY_MODE;
    rc = KbdSetStatus(&kb_state, 0);

    /*  if(rc) printf("KbdSetStatus rc = %04x\n", rc);  */

    return kb_state;
}
Exemplo n.º 7
0
/*
 * EMX initialization
 */
static void Term_init_emx(term *t)
{
	struct _KBDINFO kbdinfo;	/* see structure description ?somewhere? */

	v_init();
	v_getctype(&curs_start, &curs_end);
	/* hide cursor (?) XXX XXX XXX */
	v_clear();

	/* the documentation I (SWD) have implies, in passing, that setting */
	/* "binary mode" on the keyboard device will prevent the O/S from */
	/* acting on keys such as ^S (pause) and ^P (printer echo). */

	/* note also that "KbdSetStatus is ignored for a Vio-windowed application." */
	/* so there may well be problems with running this in a window.  Damnit. */

	/* this is kind of a nasty structure, as you can't just flip a bit */
	/* to change binary/ASCII mode, or echo on/off mode... nor can you */
	/* clear the whole thing -- certain bits need to be preserved. */

	KbdGetStatus(&kbdinfo, (HKBD)0);
	kbdinfo.fsMask &= ~ (KEYBOARD_ECHO_ON|	/* clear lowest four bits */
		KEYBOARD_ECHO_OFF|KEYBOARD_BINARY_MODE|KEYBOARD_ASCII_MODE);
	kbdinfo.fsMask |= (KEYBOARD_BINARY_MODE);	/* set bit two */
	KbdSetStatus(&kbdinfo, (HKBD)0);

#if 1 /* turn off for debug */
	signal(SIGHUP, SIG_IGN);
	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);
	/*  signal(SIGILL,SIG_IGN);  */
	/*  signal(SIGTRAP,SIG_IGN); */
	/*  signal(SIGABRT,SIG_IGN); */
	/*  signal(SIGEMT,SIG_IGN);  */
	/*  signal(SIGFPE,SIG_IGN);  */
	/*  signal(SIGBUS,SIG_IGN);  */
	/*  signal(SIGSEGV,SIG_IGN); */
	/*  signal(SIGSYS,SIG_IGN);  */
	signal(SIGPIPE, SIG_IGN);
	signal(SIGALRM, SIG_IGN);
	/*  signal(SIGTERM,SIG_IGN); */
	signal(SIGUSR1, SIG_IGN);
	signal(SIGUSR2, SIG_IGN);
	signal(SIGCHLD, SIG_IGN);
	signal(SIGBREAK, SIG_IGN);
#endif

}
Exemplo n.º 8
0
/*
 * TurnOffCapsLock - switch off caps lock
 */
void TurnOffCapsLock( void )
{
    KBDINFO     ki;

    ki.cb = sizeof( KBDINFO );
    KbdGetStatus( &ki, 0 );
    if( ki.fsState & KEY_CAPS_LOCK ) {
        hadCapsLock = TRUE;
        ki.fsMask |= 0x10;
        ki.fsState &= ~KEY_CAPS_LOCK;
        KbdSetStatus( &ki, 0 );  /* OS/2 2.0 F***S UP IF YOU DO THIS */
    } else {
        hadCapsLock = FALSE;
    }

} /* TurnOffCapsLock */
Exemplo n.º 9
0
int ConContinue() {
  VIOINTENSITY   vi;
  static KBDINFO ki;

  signal(SIGBREAK, SIG_IGN);
  signal(SIGINT,   SIG_IGN);

  ki         = SaveKbdState;
  ki.fsMask &= ~(KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE);
  ki.fsMask |= (KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE);
  APIRET16 s = KbdSetStatus(&ki, 0);
  assert(s == 0);

  vi.cb   = 6;
  vi.type = 2;
  vi.fs   = 1;
  VioSetState(&vi, 0);
  ConShowMouse();
  return 0;
}
Exemplo n.º 10
0
int ConSuspend() {
  VIOINTENSITY   vi;
  static KBDINFO ki;

  vi.cb   = 6;
  vi.type = 2;
  vi.fs   = 0;
  VioSetState(&vi, 0);

  ki         = SaveKbdState;
  ki.fsMask &= ~(KEYBOARD_ECHO_OFF | KEYBOARD_BINARY_MODE);
  ki.fsMask |= (KEYBOARD_ECHO_ON | KEYBOARD_ASCII_MODE);
  APIRET16 s = KbdSetStatus(&ki, 0);
  assert(0 == s);

  ConHideMouse();

  signal(SIGBREAK, SIG_DFL);
  signal(SIGINT,   SIG_DFL);

  return 0;
}
Exemplo n.º 11
0
void TEventQueue::resume()
{
#ifdef __OS2__
  {
    KBDINFO ki;
    ki.cb = sizeof(ki);
    assert(!KbdGetStatus(&ki,0));
    ki.fsMask &= ~KEYBOARD_ASCII_MODE;
    ki.fsMask |= KEYBOARD_BINARY_MODE;
    assert(!KbdSetStatus(&ki,0));
  }
#endif
    if( mouse.present() == False )
        mouse.resume();
    if( mouse.present() == False )
        return;
    mouse.getEvent( curMouse );
    lastMouse = curMouse;
    mouse.registerHandler( 0xFFFF, (void (*)(void))mouseInt );
    mouseEvents = True;
    mouse.show();
    TMouse::setRange( TScreen::screenWidth-1, TScreen::screenHeight-1 );
}
Exemplo n.º 12
0
void restkbmode(KBDINFO kb_state)    /* restore keyboard mode */
{
    USHORT rc;

    rc = KbdSetStatus(&kb_state, 0);
}
Exemplo n.º 13
0
USHORT __pascal KBDSETSTATUS(const PKBDINFO pkbdinfo, const HKBD hkbd)
{
  return KbdSetStatus(pkbdinfo, hkbd);
}