mouseh.inc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. const
  12. { We have an errorcode base of 1030 }
  13. errMouseBase = 1030;
  14. errMouseInitError = errMouseBase + 0;
  15. errMouseNotImplemented = errMouseBase + 1;
  16. type
  17. PMouseEvent=^TMouseEvent;
  18. TMouseEvent=packed record { 8 bytes }
  19. buttons : word;
  20. x,y : word;
  21. Action : word;
  22. end;
  23. const
  24. MouseActionDown = $0001; { Mouse down event }
  25. MouseActionUp = $0002; { Mouse up event }
  26. MouseActionMove = $0004; { Mouse move event }
  27. MouseLeftButton = $01; { Left mouse button }
  28. MouseRightButton = $02; { Right mouse button }
  29. MouseMiddleButton = $04; { Middle mouse button }
  30. var
  31. PendingMouseEvent : array[0..MouseEventBufSize-1] of TMouseEvent;
  32. PendingMouseHead,
  33. PendingMouseTail : PMouseEvent;
  34. PendingMouseEvents : byte;
  35. LastMouseEvent : TMouseEvent;
  36. MouseIntFlag : Byte; { Mouse in int flag }
  37. MouseButtons : Byte; { Mouse button state }
  38. MouseWhereX,
  39. MouseWhereY : Word; { Mouse position }
  40. procedure InitMouse;
  41. { Initialize the mouse interface }
  42. procedure DoneMouse;
  43. { Deinitialize the mouse interface }
  44. function DetectMouse:byte;
  45. { Detect if a mouse is present, returns the amount of buttons or 0
  46. if no mouse is found }
  47. procedure ShowMouse;
  48. { Show the mouse cursor }
  49. procedure HideMouse;
  50. { Hide the mouse cursor }
  51. function GetMouseX:word;
  52. { Return the current X position of the mouse }
  53. function GetMouseY:word;
  54. { Return the current Y position of the mouse }
  55. function GetMouseButtons:word;
  56. { Return the current button state of the mouse }
  57. procedure SetMouseXY(x,y:word);
  58. { Place the mouse cursor on x,y }
  59. procedure GetMouseEvent(var MouseEvent:TMouseEvent);
  60. { Returns the last Mouseevent, and waits for one if not available }
  61. procedure PutMouseEvent(const MouseEvent: TMouseEvent);
  62. { Adds the given MouseEvent to the input queue. Please note that depending on
  63. the implementation this can hold only one value (NO FIFOs etc) }
  64. function PollMouseEvent(var MouseEvent: TMouseEvent):boolean;
  65. { Checks if a Mouseevent is available, and returns it if one is found. If no
  66. event is pending, it returns 0 }
  67. {
  68. $Log$
  69. Revision 1.1 2001-01-13 11:13:12 peter
  70. * API 2 RTL
  71. }