Source code of Windows XP (NT5)
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.

121 lines
3.3 KiB

  1. //===========================================================================
  2. // FF.CPP
  3. //
  4. // Functions:
  5. // ForceFeedback_DlgProc()
  6. //
  7. //===========================================================================
  8. #include "cplsvr1.h"
  9. #include "dicputil.h"
  10. //===========================================================================
  11. // (C) Copyright 1997 Microsoft Corp. All rights reserved.
  12. //
  13. // You have a royalty-free right to use, modify, reproduce and
  14. // distribute the Sample Files (and/or any modified version) in
  15. // any way you find useful, provided that you agree that
  16. // Microsoft has no warranty obligations or liability for any
  17. // Sample Application Files which are modified.
  18. //===========================================================================
  19. #define ID_SLIDERTIMER 2800
  20. #define TIMER_FREQ 850
  21. //===========================================================================
  22. // ForceFeedback_DlgProc
  23. //
  24. // Parameters:
  25. // HWND hWnd - handle to dialog window
  26. // UINT uMsg - dialog message
  27. // WPARAM wParam - message specific data
  28. // LPARAM lParam - message specific data
  29. //
  30. // Returns: BOOL
  31. //
  32. //===========================================================================
  33. BOOL CALLBACK ForceFeedback_DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  34. {
  35. CDIGameCntrlPropSheet_X *pdiCpl; // = (CDIGameCntrlPropSheet_X*)GetWindowLong(hWnd, DWL_USER);
  36. static LPDIRECTINPUTDEVICE2 pdiDevice2 = NULL;
  37. static CSliderCtrl CReturnSlider, CForceSlider;
  38. switch(uMsg)
  39. {
  40. // OnInit
  41. case WM_INITDIALOG:
  42. {
  43. // get ptr to our object
  44. pdiCpl = (CDIGameCntrlPropSheet_X*)((LPPROPSHEETPAGE)lParam)->lParam;
  45. // Save our pointer so we can access it later
  46. SetWindowLong(hWnd, DWL_USER, (LPARAM)pdiCpl);
  47. // initialize DirectInput
  48. if(FAILED(InitDInput(GetParent(hWnd), pdiCpl)))
  49. {
  50. OutputDebugString(TEXT("TEST.CPP: WM_INIT: InitDInput FAILED!\n"));
  51. }
  52. // Get the device2 interface pointer
  53. pdiCpl->GetDevice(&pdiDevice2);
  54. // Setup the Sliders
  55. HWND hCtrl = GetDlgItem(hWnd, IDC_SLIDER1);
  56. ASSERT (hCtrl);
  57. CReturnSlider.Attach(hCtrl);
  58. hCtrl = GetDlgItem(hWnd, IDC_SLIDER2);
  59. ASSERT (hCtrl);
  60. CForceSlider.Attach(hCtrl);
  61. // BLJ: TODO!!!
  62. // Setup the granularity of the sliders based on the device!
  63. // Set up timer to monitor button presses on the device!!!
  64. // SetTimer(hWnd, ID_SLIDERTIMER, TIMER_FREQ, 0);
  65. }
  66. break; // end of WM_INITDIALOG
  67. // OnTimer
  68. case WM_TIMER:
  69. break;
  70. // OnDestroy
  71. case WM_DESTROY:
  72. // KillTimer(hWnd, ID_SLIDERTIMER);
  73. CForceSlider.Detach();
  74. CReturnSlider.Detach();
  75. // Get the device2 interface pointer
  76. pdiDevice2->Unacquire();
  77. break; // end of WM_DESTROY
  78. // OnNotify
  79. case WM_NOTIFY:
  80. switch(((NMHDR *)lParam)->code)
  81. {
  82. case PSN_SETACTIVE:
  83. // Do that Acquire thing...
  84. if(FAILED(pdiDevice2->Acquire()))
  85. {
  86. OutputDebugString(TEXT("FF.CPP: PSN_SETACTIVE: Acquire() FAILED!\n"));
  87. }
  88. break;
  89. case PSN_KILLACTIVE:
  90. // Do that Unacquire thing...
  91. pdiDevice2->Unacquire();
  92. break;
  93. }
  94. break; // end of WM_NOTIFY
  95. }
  96. return FALSE;
  97. } //*** end Test_DlgProc()