Counter Strike : Global Offensive Source Code
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.

176 lines
4.0 KiB

  1. /****************************/
  2. /* Set extended button maps */
  3. /****************************/
  4. #include <stdio.h>
  5. #include <windows.h>
  6. #include "wintab.h"
  7. #include "mgrtest.h"
  8. #include "resource.h"
  9. typedef struct {
  10. UINT wCsr;
  11. BYTE sysBtns[256];
  12. BYTE logBtns[256];
  13. } xBtn_info;
  14. static const unsigned nbitboxes = 32;
  15. static const int bitbox_id[] = {
  16. IDC_SYS_1, IDC_SYS_2, IDC_SYS_3, IDC_SYS_4, IDC_SYS_5, IDC_SYS_6, IDC_SYS_7, IDC_SYS_8, IDC_SYS_9, IDC_SYS_10, IDC_SYS_11, IDC_SYS_12, IDC_SYS_13, IDC_SYS_14, IDC_SYS_15, IDC_SYS_16,
  17. IDC_LOG_1, IDC_LOG_2, IDC_LOG_3, IDC_LOG_4, IDC_LOG_5, IDC_LOG_6, IDC_LOG_7, IDC_LOG_8, IDC_LOG_9, IDC_LOG_10, IDC_LOG_11, IDC_LOG_12, IDC_LOG_13, IDC_LOG_14, IDC_LOG_15, IDC_LOG_16
  18. };
  19. extern HANDLE hInst;
  20. void
  21. display_xButton_info( HWND hDlg, const xBtn_info * btn )
  22. {
  23. unsigned i;
  24. for( i = 0; i < nbitboxes; i++ ) {
  25. unsigned j;
  26. char buf[100] = "";
  27. for( j = 0; j < 16; j++ ) {
  28. char tmp[5];
  29. sprintf( tmp, "%2x ", (int)*(btn->sysBtns + i*16 + j) );
  30. strcat( buf, tmp );
  31. }
  32. SetWindowText(GetDlgItem(hDlg, bitbox_id[i]), buf);
  33. }
  34. }
  35. BOOL
  36. CALLBACK valueProc( HWND hDlg, UINT Msg, WPARAM wParam, LONG lParam )
  37. {
  38. BOOL fResult;
  39. int retval;
  40. switch( Msg ) {
  41. case WM_COMMAND:
  42. switch( wParam ) {
  43. case IDOK:
  44. retval = GetDlgItemInt( hDlg, IDC_EDIT, 0, TRUE );
  45. EndDialog(hDlg, retval);
  46. fResult = TRUE;
  47. break;
  48. case IDCANCEL:
  49. EndDialog(hDlg, -1);
  50. fResult = TRUE;
  51. break;
  52. default:
  53. fResult = FALSE;
  54. }
  55. break;
  56. default:
  57. fResult = FALSE;
  58. }
  59. return fResult;
  60. }
  61. BOOL
  62. CALLBACK xButtonDlgProc( HWND hDlg, UINT Msg, WPARAM wParam, LONG lParam )
  63. {
  64. static xBtn_info * btn;
  65. int i;
  66. BOOL fResult;
  67. switch( Msg ) {
  68. case WM_INITDIALOG:
  69. btn = (xBtn_info *)lParam;
  70. display_xButton_info( hDlg, btn );
  71. fResult = TRUE;
  72. break;
  73. case WM_LBUTTONDOWN: /* Change the xBtn map */
  74. i = test_bitboxes( hDlg, lParam, 16, nbitboxes, bitbox_id );
  75. if( i > -1 ) {
  76. FARPROC lpProcDlg;
  77. int val;
  78. /* Open 'Enter Value' dialog */
  79. lpProcDlg = MakeProcInstance( valueProc, hInst );
  80. val = DialogBox( hInst, MAKEINTRESOURCE(IDD_VALUE), hDlg, lpProcDlg );
  81. FreeProcInstance( lpProcDlg );
  82. if( val >= 0 && val <= 0xff ) {
  83. *(btn->sysBtns + i) = val;
  84. display_xButton_info( hDlg, btn );
  85. } else
  86. if( val != -1 )
  87. MessageBox( hDlg, "Invalid value.", "MgrTest", MB_OK | MB_ICONHAND );
  88. }
  89. fResult = TRUE;
  90. break;
  91. case WM_COMMAND:
  92. if (wParam == IDOK || wParam == IDCANCEL) {
  93. EndDialog(hDlg, wParam);
  94. fResult = TRUE;
  95. } else
  96. fResult = FALSE;
  97. break;
  98. default:
  99. fResult = FALSE;
  100. }
  101. return fResult;
  102. }
  103. void
  104. set_xBtnMap( HWND hWnd, HMGR hMgr )
  105. {
  106. FARPROC lpProcDlg;
  107. xBtn_info info;
  108. unsigned i;
  109. int tag;
  110. /* Open a dialog to choose which cursor to use. */
  111. lpProcDlg = MakeProcInstance( CursInfoDlgProc, hInst );
  112. info.wCsr = DialogBoxParam( hInst, MAKEINTRESOURCE(IDD_INFOLIST),
  113. hWnd, lpProcDlg, WTI_CURSORS );
  114. FreeProcInstance( lpProcDlg );
  115. if( info.wCsr != 0xffffffff ) {
  116. /* Find xBtnMask info */
  117. i = 0;
  118. while( WTInfo( WTI_EXTENSIONS + i, EXT_TAG, &tag ) && tag != WTX_XBTNMASK )
  119. i++;
  120. if( tag != WTX_XBTNMASK )
  121. MessageBox( hWnd, "XBTNMASK extension not supported.", "MgrTest", MB_ICONHAND | MB_OK );
  122. /* Read the xBtn map info */
  123. if( !WTInfo( WTI_EXTENSIONS + i, EXT_CURSORS + info.wCsr, info.sysBtns ) )
  124. MessageBox( hWnd, "This cursor does not support XBTNMASK.", "MgrTest", MB_ICONHAND | MB_OK );
  125. else {
  126. int id;
  127. /* Start the XBUTTONS dialog */
  128. lpProcDlg = MakeProcInstance( xButtonDlgProc, hInst );
  129. id = DialogBoxParam( hInst, MAKEINTRESOURCE(IDD_XBUTTONS),
  130. hWnd, lpProcDlg, (long)&info );
  131. FreeProcInstance( lpProcDlg );
  132. if( id == IDOK )
  133. if( !WTMgrCsrExt( hMgr, info.wCsr, WTX_XBTNMASK, info.sysBtns ) )
  134. MessageBox( hWnd, "WTMgrCsrExt failed.", "MgrTest", MB_ICONHAND | MB_OK );
  135. }
  136. }
  137. }