keyboard.pp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2001 by the Free Pascal development team.
  5. Keyboard unit for netware
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { 2001/04/16 armin: first version for netware
  13. 2002/03/03 armin: changes for fpc 1.1 }
  14. unit Keyboard;
  15. interface
  16. {$i keybrdh.inc}
  17. implementation
  18. {$i keyboard.inc}
  19. {$i nwsys.inc}
  20. procedure SysInitKeyboard;
  21. begin
  22. PendingKeyEvent := 0;
  23. end;
  24. function SysGetKeyEvent: TKeyEvent;
  25. var T : TKeyEvent;
  26. begin
  27. if PendingKeyEvent<>0 then
  28. begin
  29. SysGetKeyEvent:=PendingKeyEvent;
  30. PendingKeyEvent:=0;
  31. exit;
  32. end;
  33. T := byte(_getch);
  34. if T = 0 then
  35. T := word(_getch) shl 8;
  36. SysGetKeyEvent := $03000000 OR T;
  37. end;
  38. function SysPollKeyEvent: TKeyEvent;
  39. begin
  40. if PendingKeyEvent<>0 then
  41. exit(PendingKeyEvent);
  42. if _kbhit <> 0 then
  43. begin
  44. PendingKeyEvent := byte(_getch);
  45. if PendingKeyEvent = 0 then
  46. PendingKeyEvent := word(_getch) shl 8;
  47. PendingKeyEvent := PendingKeyEvent OR $03000000;
  48. SysPollKeyEvent := PendingKeyEvent;
  49. end else
  50. SysPollKeyEvent := 0;
  51. end;
  52. function SysPollShiftStateEvent: TKeyEvent;
  53. begin
  54. SysPollShiftStateEvent:=0;
  55. end;
  56. function SysGetShiftState: Byte;
  57. begin
  58. SysGetShiftState:=0;
  59. end;
  60. Const
  61. SysKeyboardDriver : TKeyboardDriver = (
  62. InitDriver : Nil;
  63. DoneDriver : Nil;
  64. GetKeyevent : @SysGetKeyEvent;
  65. PollKeyEvent : @SysPollKeyEvent;
  66. GetShiftState : @SysGetShiftState;
  67. TranslateKeyEvent : Nil;
  68. TranslateKeyEventUnicode : Nil;
  69. );
  70. begin
  71. KeyboardInitialized := false;
  72. PendingKeyEvent := 0;
  73. SetKeyBoardDriver(SysKeyBoardDriver);
  74. end.
  75. {
  76. $Log$
  77. Revision 1.4 2002-09-07 16:01:20 peter
  78. * old logs removed and tabs fixed
  79. Revision 1.3 2002/03/08 19:02:59 armin
  80. Changes for new style (TKeyboardDriver record)
  81. }