Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
4.6 KiB

  1. /****************************************************************************
  2. * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  3. * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  4. * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  5. * PURPOSE.
  6. *
  7. * Copyright (c) 1993-1999 Microsoft Corporation
  8. *
  9. * File: joy.h
  10. * Content: joystick include file
  11. *
  12. *@@BEGIN_MSWINAPI
  13. *
  14. * History:
  15. * Date By Reason
  16. * ==== == ======
  17. * 05-oct-94 craige re-write
  18. * 25-Nov-97 qzheng convert to use DINPUT in NT instead of old driver
  19. *@@END_MSWINAPI
  20. *
  21. ***************************************************************************/
  22. #ifndef JOY_H
  23. #define JOY_H
  24. #include <windows.h>
  25. #include <mmsystem.h>
  26. #include <mmreg.h>
  27. #include <devioctl.h>
  28. #include <ntddjoy.h>
  29. #include <mmddk.h>
  30. #define DIRECTINPUT_VERSION 0x50A
  31. #include <dinput.h>
  32. #include <dinputd.h>
  33. #include <mmsystem.h>
  34. #include <hidusage.h>
  35. /*****************************************************************************
  36. *
  37. * Registered window messages
  38. *
  39. *****************************************************************************/
  40. #define MSGSTR_JOYCHANGED TEXT("MSJSTICK_VJOYD_MSGSTR")
  41. /****DEFINES****/
  42. #define cJoyMax ( 16 )
  43. #define cJoyPosAxisMax ( 6 )
  44. #define cJoyPosButtonMax (32 )
  45. #define cJoyMaxInWinmm (2)
  46. #define cMsecTimer (20000)
  47. #define INUSE ( 0 )
  48. #define DEATHROW ( 1 )
  49. #define EXECUTE ( 2 )
  50. #define INVALID (-1 )
  51. #define DEADZONE_PERCENT ( 5 )
  52. #undef MIN_PERIOD
  53. #define MIN_PERIOD 10
  54. #define MAX_PERIOD 1000
  55. typedef struct tagJOYDEVICE
  56. {
  57. LPDIRECTINPUTDEVICE2W pdid; // Device Interface
  58. DWORD dwButtons; // Number of Buttons
  59. DWORD dwFlags; // Cached dwFlags field for last JoyGetPosEx
  60. HWND hwnd; // the windows owns the focus of the joystick
  61. UINT uPeriod; // poll period
  62. UINT uThreshold;
  63. UINT_PTR uIDEvent; // timer ID
  64. BOOL fChanged; //
  65. UINT uIDJoy; // index of the currently caputured joystick
  66. UINT uState;
  67. JOYCAPSW jcw; // the caps of the joystick
  68. } JOYDEVICE, *LPJOYDEVICE;
  69. /*
  70. * fEqualMask - checks that all masked bits are equal
  71. */
  72. BOOL static __inline fEqualMaskFlFl(DWORD flMask, DWORD fl1, DWORD fl2)
  73. {
  74. return ((fl1 ^ fl2) & flMask) == 0;
  75. }
  76. /*
  77. * SetMaskFl - Set mask bits in fl
  78. */
  79. void static __inline SetMaskpFl( DWORD flMask, PDWORD pfl )
  80. {
  81. *pfl |= flMask;
  82. }
  83. /*
  84. * ClrMaskFl - Clear mask bits in fl
  85. */
  86. void static __inline ClrMaskpFl( DWORD flMask, PDWORD pfl )
  87. {
  88. *pfl &= (! flMask) ;
  89. }
  90. /***************************************************************************
  91. *
  92. * Debugging macros needed by inline functions
  93. *
  94. ***************************************************************************/
  95. #if defined(DBG) || defined(RDEBUG)
  96. #define XDBG
  97. #endif
  98. int WINAPI AssertPtszPtszLn(LPCTSTR ptszExpr, LPCTSTR ptszFile, int iLine);
  99. #ifdef DBG
  100. #define AssertFPtsz(c, ptsz) ((c) ? 0 : AssertPtszPtszLn(ptsz, TEXT(__FILE__), __LINE__))
  101. #else /* !DBG */
  102. #define AssertFPtsz(c, ptsz)
  103. #endif
  104. #define AssertF(c) AssertFPtsz(c, TEXT(#c))
  105. /*****************************************************************************
  106. *
  107. * @doc INLINE
  108. *
  109. * @method BOOL | IsWriteSam |
  110. *
  111. * Nonzero if the registry security access mask will
  112. * obtain (or attempt to obtain) write access.
  113. *
  114. * @parm REGSAM | regsam |
  115. *
  116. * Registry security access mask.
  117. *
  118. *****************************************************************************/
  119. BOOL IsWriteSam(REGSAM sam)
  120. {
  121. return sam & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | MAXIMUM_ALLOWED);
  122. }
  123. #define hresLe(le) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, (USHORT)(le))
  124. #ifdef DBG
  125. void joyDbgOut(LPSTR lpszFormat, ...);
  126. #define JOY_ERR 0x00000001
  127. #define JOY_WARN 0x00000002
  128. #define JOY_BABBLE 0x00000004
  129. #define JOY_DEFAULT_DBGLEVEL 0x00000000
  130. #endif
  131. #ifdef DBG
  132. extern DWORD g_dwDbgLevel;
  133. #define JOY_DBGPRINT( _debugMask_, _x_ ) \
  134. if( (((_debugMask_) & g_dwDbgLevel)) ){ \
  135. joyDbgOut _x_; \
  136. }
  137. #else
  138. #define JOY_DBGPRINT( _debugMask_, _x_ )
  139. #endif
  140. #endif // JOY_H