Win32Mouse.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: Win32Mouse.h /////////////////////////////////////////////////////////
  24. //-----------------------------------------------------------------------------
  25. //
  26. // Westwood Studios Pacific.
  27. //
  28. // Confidential Information
  29. // Copyright (C) 2001 - All Rights Reserved
  30. //
  31. //-----------------------------------------------------------------------------
  32. //
  33. // Project: RTS3
  34. //
  35. // File name: Win32Mouse.h
  36. //
  37. // Created: Colin Day, July 2001
  38. //
  39. // Desc: Interface for the mouse using only the Win32 messages
  40. //
  41. //-----------------------------------------------------------------------------
  42. ///////////////////////////////////////////////////////////////////////////////
  43. #pragma once
  44. #ifndef __WIN32MOUSE_H_
  45. #define __WIN32MOUSE_H_
  46. // SYSTEM INCLUDES ////////////////////////////////////////////////////////////
  47. // USER INCLUDES //////////////////////////////////////////////////////////////
  48. #include "GameClient/Mouse.h"
  49. // FORWARD REFERENCES /////////////////////////////////////////////////////////
  50. // TYPE DEFINES ///////////////////////////////////////////////////////////////
  51. enum { NO_TIME_FROM_WINDOWS = 0 };
  52. // Win32Mouse -----------------------------------------------------------------
  53. /** Mouse interface for when using only the Win32 messages */
  54. //-----------------------------------------------------------------------------
  55. class Win32Mouse : public Mouse
  56. {
  57. public:
  58. Win32Mouse( void );
  59. virtual ~Win32Mouse( void );
  60. virtual void init( void ); ///< init mouse, extend this functionality, do not replace
  61. virtual void reset( void ); ///< reset the system
  62. virtual void update( void ); ///< update
  63. virtual void initCursorResources(void); ///< load windows resources needed for 2d cursors.
  64. virtual void setCursor( MouseCursor cursor ); ///< set mouse cursor
  65. virtual void capture( void ); ///< capture the mouse
  66. virtual void releaseCapture( void ); ///< release mouse capture
  67. virtual void setVisibility(Bool visible);
  68. /// add an event from a win32 window procedure
  69. void addWin32Event( UINT msg, WPARAM wParam, LPARAM lParam, DWORD time );
  70. void lostFocus (Bool state) { m_lostFocus = state;}
  71. protected:
  72. /// get the next event available in the buffer
  73. virtual UnsignedByte getMouseEvent( MouseIO *result, Bool flush );
  74. /// translate a win32 mouse event to our own info
  75. void translateEvent( UnsignedInt eventIndex, MouseIO *result );
  76. struct Win32MouseEvent
  77. {
  78. UINT msg; ///< WM_* message
  79. WPARAM wParam; ///< WPARAM from the WM_* message
  80. LPARAM lParam; ///< LPARAM from the WM_* message
  81. DWORD time; ///< TIME from the WM_* message
  82. };
  83. /// this is our buffer of events that we receive via a WndProc message
  84. Win32MouseEvent m_eventBuffer[ Mouse::NUM_MOUSE_EVENTS ];
  85. UnsignedInt m_nextFreeIndex; ///< insert new events at this index
  86. UnsignedInt m_nextGetIndex; /** events retrieved through getMouseEvent
  87. will come from this index, then it will be
  88. incremented to the next index */
  89. MouseCursor m_currentWin32Cursor; ///< keep track of last cursor image sent to D3D.
  90. Int m_directionFrame; ///< current frame of directional cursor (frome 0 points up).
  91. Bool m_lostFocus; ///< flag if window has lost focues and mouse should stop being updated.
  92. }; // end Win32Mouse
  93. // INLINING ///////////////////////////////////////////////////////////////////
  94. // EXTERNALS //////////////////////////////////////////////////////////////////
  95. #endif // __WIN32MOUSE_H_