keyboard.pp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Florian Klaempfl
  4. member of the Free Pascal development team
  5. Keyboard unit for go32v2
  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. unit Keyboard;
  13. interface
  14. {$i keybrdh.inc}
  15. implementation
  16. uses
  17. go32;
  18. {$i keyboard.inc}
  19. function SysGetKeyEvent: TKeyEvent;
  20. var
  21. regs : trealregs;
  22. begin
  23. regs.ah:=$10;
  24. realintr($16,regs);
  25. if (regs.al=$e0) and (regs.ah<>0) then
  26. regs.al:=0;
  27. SysGetKeyEvent:=(kbPhys shl 24) or regs.ax or ((mem[$40:$17] and $f) shl 16);
  28. end;
  29. function SysPollKeyEvent: TKeyEvent;
  30. var
  31. regs : trealregs;
  32. begin
  33. regs.ah:=$11;
  34. realintr($16,regs);
  35. if (regs.realflags and zeroflag<>0) then
  36. exit(0);
  37. if (regs.al=$e0) and (regs.ah<>0) then
  38. regs.al:=0;
  39. SysPollKeyEvent:=(kbPhys shl 24) or regs.ax or ((mem[$40:$17] and $f) shl 16);
  40. end;
  41. function SysGetShiftState: Byte;
  42. begin
  43. SysGetShiftState:=(mem[$40:$17] and $f);
  44. end;
  45. Const
  46. SysKeyboardDriver : TKeyboardDriver = (
  47. InitDriver : Nil;
  48. DoneDriver : Nil;
  49. GetKeyevent : @SysGetKeyEvent;
  50. PollKeyEvent : @SysPollKeyEvent;
  51. GetShiftState : @SysGetShiftState;
  52. TranslateKeyEvent : Nil;
  53. TranslateKeyEventUnicode : Nil;
  54. );
  55. begin
  56. SetKeyBoardDriver(SysKeyBoardDriver);
  57. end.