Ejemplo n.º 1
0
// Ввод скан-кода клавиши с ожиданием нажатия
// Необработанные эвенты передаются функции HandleEvent
short ReadScan()
{
short res;
SDL_Event event;
DrawScreen();
for(;;)
  {
  SDL_WaitEvent(&event);
  if (event.type==SDL_KEYDOWN && !(event.key.keysym.mod & KMOD_ALT))
    {
    res=(event.key.keysym.scancode&0x7f); // в драйвере directx бит 7 установлен?
    res=TranslateScanCode(res)<<8;
//    if (event.key.keysym.sym<128)
//      res|=event.key.keysym.sym;
    if (event.key.keysym.unicode<128)
      res|=event.key.keysym.unicode;
    return res;
    }
  HandleEvent(&event);
  }
}
Ejemplo n.º 2
0
UCHAR
FwInputScanCode (
    VOID
    )

/*++

Routine Description:

    This routine reads a byte from the keyboard.  If no data is available,
    it blocks until a key is typed.

Arguments:

    None.

Return Value:

    Returns the character read from the keyboard.

--*/

{

#ifndef ALPHA

    UCHAR ScanCode;

    while (KbdBuffer.ReadIndex == KbdBuffer.WriteIndex) {
    }
    KbdBuffer.ReadIndex = (KbdBuffer.ReadIndex+1) % KBD_BUFFER_SIZE;
    ScanCode = KbdBuffer.Buffer[KbdBuffer.ReadIndex];

    return ScanCode;

#else

    //
    // Alpha.  If there are remaining characters in the 
    // circular buffer, return the next one.  Otherwise,
    // hang until another character is typed and then call
    // TranslateScanCode.  Then return a character.
    //

    while (TRUE) {

	if (KbdBuffer.ReadIndex != KbdBuffer.WriteIndex) {

	    //
	    // A character is in the buffer.  Return it.
	    //

	    KbdBuffer.ReadIndex = (KbdBuffer.ReadIndex+1) % KBD_BUFFER_SIZE;
	    return (KbdBuffer.Buffer[KbdBuffer.ReadIndex]);
	}

    
	//
	// Wait until a character is typed, then scan it, and loop back.
	// The TranslateScanCode() calls will eventually bump the KbdBuffer
	// WriteIndex.
	//

	while ((READ_PORT_UCHAR((PUCHAR)&KEYBOARD_READ->Status) &
		KBD_OBF_MASK) == 0) {
	}

	TranslateScanCode(READ_PORT_UCHAR((PUCHAR)&KEYBOARD_READ->Data));
	FwStallExecution(10);	            // Don't pound on the controller.
    }

#endif

}
Ejemplo n.º 3
0
ARC_STATUS
KeyboardGetReadStatus (
    IN ULONG FileId
    )
/*++

Routine Description:

    This routine checks to see if a character is available from the keyboard.

Arguments:

    FileId - Supplies a file identifier.

Return Value:

    Returns ESUCCESS is a byte is available, otherwise EAGAIN is returned.

--*/
{

#ifndef ALPHA

    if (KbdBuffer.ReadIndex == KbdBuffer.WriteIndex) {
        return EAGAIN;
    } else {
        return ESUCCESS;
    }

#else

    //
    // Alpha  does polling.
    //

    if (KbdBuffer.ReadIndex != KbdBuffer.WriteIndex) {

	// A character is available
	return ESUCCESS;

    } else if (READ_PORT_UCHAR((PUCHAR)&KEYBOARD_READ->Status) & KBD_OBF_MASK) {

	// A character is available at the keyboard, but it may be a
	// character that is not returned to the calling program (e.g., a
        // break code).  Screen it here.

	TranslateScanCode(READ_PORT_UCHAR((PUCHAR)&KEYBOARD_READ->Data));
	if (KbdBuffer.ReadIndex != KbdBuffer.WriteIndex) {
	    // A character is now available
	    return ESUCCESS;
	} else {
	    // A character is not available, let the user drain any other
	    // characters or non-characters by calling this again.
	    return EAGAIN;
	}

    } else {

	// A character is not available
	return EAGAIN;

    }

#endif

}