Exemplo n.º 1
0
Arquivo: SLIDR.C Projeto: LesInk/Test
T_void SliderUpdateAllSliders (T_void)
{
	T_word16 i;

	DebugRoutine ("SliderUpdateAllSliders");
	for (i=0;i<MAX_SLIDERS;i++)
	{
		if (G_sliderArray[i]!=NULL) SliderUpdate (G_sliderArray[i]);
	}
	DebugEnd();
}
Exemplo n.º 2
0
Arquivo: SLIDR.C Projeto: LesInk/Test
T_void SliderMouseControl (E_mouseEvent event,
								   T_word16 x,
								   T_word16 y,
								   T_buttonClick button)
{
   T_word16 i;
   T_word16 mvalue,dx,dx2;
   T_graphicStruct *p_graphic=NULL;
   T_sliderStruct *p_slider=NULL;
   static T_sliderID selected=NULL;

   DebugRoutine ("SliderMouseControl");

   switch (event)
   {
      case MOUSE_EVENT_START:
      selected=NULL;

      for (i=0;i<MAX_SLIDERS;i++)
      {
         if (G_sliderArray[i]!=NULL)
         {
            /* found a slider, check to see if the mouse is on it */
            if (SliderIsAt (G_sliderArray[i],x,y))
            {
               /* assign this slider as selected */
               selected=G_sliderArray[i];
               break;
            }
         }
      }
      break;

      case MOUSE_EVENT_DRAG:
      case MOUSE_EVENT_HELD:
      if (selected!=NULL)
      {
         p_slider=(T_sliderStruct *)selected;
         p_graphic=(T_graphicStruct *)p_slider->knobgraphic;
         /* drag slider knob */
         p_slider->sliderx=x-4;
         /* check bounds */
         if (p_slider->sliderx>p_slider->lx2-p_graphic->width+1)
            p_slider->sliderx=p_slider->lx2-p_graphic->width+1;
         else if (p_slider->sliderx < p_slider->lx1)
            p_slider->sliderx=p_slider->lx1;
         /* calculate the new slider value */
            dx=((p_slider->lx2-p_graphic->width+1)-p_slider->lx1);
            dx2=(p_slider->sliderx-p_slider->lx1);
            mvalue=0-1;
            mvalue/=dx;
            mvalue*=dx2;
            p_slider->curval=mvalue;
         /* redraw this slider */
//       p_graphic->locx=p_slider->sliderx;
         SliderUpdate (selected);
      }
      break;

      default:
      selected=NULL;
      break;
   }

   DebugEnd();
}
Exemplo n.º 3
0
INT_PTR CALLBACK DialogProc2(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static s32 port;

	switch(uMsg)
	{
	case WM_INITDIALOG:
		{
			port = TabCtrl_GetCurSel(GetDlgItem(GetParent(hwndDlg), IDC_TAB1));

			for(s32 control = IDC_COMBO_LX; control <= IDC_COMBO_RY; control++)
			{
				SendMessage(GetDlgItem(hwndDlg, control), CB_ADDSTRING, 0, (LPARAM)L"Axis LX");
				SendMessage(GetDlgItem(hwndDlg, control), CB_ADDSTRING, 0, (LPARAM)L"Axis LY");
				SendMessage(GetDlgItem(hwndDlg, control), CB_ADDSTRING, 0, (LPARAM)L"Axis RX");
				SendMessage(GetDlgItem(hwndDlg, control), CB_ADDSTRING, 0, (LPARAM)L"Axis RY");
			}

			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_RUMBLE), TBM_SETRANGE, TRUE, MAKELONG(0, 200));
			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_DEADZONE), TBM_SETRANGE, TRUE, MAKELONG(0, 100));
			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_ANTIDEADZONE), TBM_SETRANGE, TRUE, MAKELONG(0, 90));
			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_LINEARITY), TBM_SETRANGE, TRUE, MAKELONG(-30, 30));

			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_DEADZONE2), TBM_SETRANGE, TRUE, MAKELONG(0, 100));
			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_ANTIDEADZONE2), TBM_SETRANGE, TRUE, MAKELONG(0, 90));
			SendMessage(GetDlgItem(hwndDlg, IDC_SLIDER_LINEARITY2), TBM_SETRANGE, TRUE, MAKELONG(-30, 30));

			UpdateControls(hwndDlg, port);

			ShowWindow(hwndDlg, SW_SHOW);
		} break;

	case WM_HSCROLL:
		{
			if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_RUMBLE))
			{
				settings[port].rumble = (f32)SliderUpdate(hwndDlg, IDC_SLIDER_RUMBLE, IDC_TEXT_RUMBLE);
			}
			else  if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_DEADZONE))
			{
				settings[port].stickL.deadzone =  (f32)SliderUpdate(hwndDlg, IDC_SLIDER_DEADZONE, IDC_TEXT_DEADZONE);
				if(settings[port].sticksLocked) SliderSet(hwndDlg, IDC_SLIDER_DEADZONE2, settings[port].stickL.deadzone);
			}
			else if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_ANTIDEADZONE))
			{
				settings[port].stickL.antiDeadzone =   (f32)SliderUpdate(hwndDlg, IDC_SLIDER_ANTIDEADZONE, IDC_TEXT_ANTIDEADZONE);
				if(settings[port].sticksLocked) SliderSet(hwndDlg, IDC_SLIDER_ANTIDEADZONE2, settings[port].stickL.antiDeadzone);
			}
			else if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_LINEARITY))
			{
				settings[port].stickL.linearity =  SliderUpdate(hwndDlg, IDC_SLIDER_LINEARITY, IDC_TEXT_LINEARITY, true);
				if(settings[port].sticksLocked) SliderSet(hwndDlg, IDC_SLIDER_LINEARITY2, settings[port].stickL.linearity, true);
			}
			else if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_DEADZONE2))
			{
				settings[port].stickR.deadzone =  (f32)SliderUpdate(hwndDlg, IDC_SLIDER_DEADZONE2, IDC_TEXT_DEADZONE2);
			}
			else if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_ANTIDEADZONE2))
			{
				settings[port].stickR.antiDeadzone =   (f32)SliderUpdate(hwndDlg, IDC_SLIDER_ANTIDEADZONE2, IDC_TEXT_ANTIDEADZONE2);
			}
			else if((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_LINEARITY2))
			{
				settings[port].stickR.linearity =  SliderUpdate(hwndDlg, IDC_SLIDER_LINEARITY2, IDC_TEXT_LINEARITY2, true);
			}

		} break;

	case WM_COMMAND:
		{
			s16 command = LOWORD(wParam);

			switch(command)
			{
			case IDC_XINPUT1: settings[port].xinputPort = 0; break;
			case IDC_XINPUT2: settings[port].xinputPort = 1; break;
			case IDC_XINPUT3: settings[port].xinputPort = 2; break;
			case IDC_XINPUT4: settings[port].xinputPort = 3; break;

			case IDC_MODE_DIGITAL: settings[port].defaultAnalog = false; break;
			case IDC_MODE_ANALOG: settings[port].defaultAnalog = true; break;

			case IDC_COMBO_LX: if(HIWORD(wParam) == CBN_SELCHANGE)
					settings[port].axisRemap[GP_AXIS_LX] = (u8)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_LX), CB_GETCURSEL, 0, 0);
				break;
			case IDC_COMBO_LY: if(HIWORD(wParam) == CBN_SELCHANGE)
					settings[port].axisRemap[GP_AXIS_LY] = (u8)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_LY), CB_GETCURSEL, 0, 0);
				break;
			case IDC_COMBO_RX: if(HIWORD(wParam) == CBN_SELCHANGE)
					settings[port].axisRemap[GP_AXIS_RX] = (u8)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_RX), CB_GETCURSEL, 0, 0);
				break;
			case IDC_COMBO_RY: if(HIWORD(wParam) == CBN_SELCHANGE)
					settings[port].axisRemap[GP_AXIS_RY] = (u8)SendMessage(GetDlgItem(hwndDlg, IDC_COMBO_RY), CB_GETCURSEL, 0, 0);
				break;

			case IDC_INVERT_LX:
				settings[port].axisInverted[GP_AXIS_LX] = IsDlgButtonChecked(hwndDlg, IDC_INVERT_LX) == BST_CHECKED;
				break;
			case IDC_INVERT_LY:
				settings[port].axisInverted[GP_AXIS_LY] = IsDlgButtonChecked(hwndDlg, IDC_INVERT_LY) == BST_CHECKED;
				break;
			case IDC_INVERT_RX:
				settings[port].axisInverted[GP_AXIS_RX] = IsDlgButtonChecked(hwndDlg, IDC_INVERT_RX) == BST_CHECKED;
				break;
			case IDC_INVERT_RY:
				settings[port].axisInverted[GP_AXIS_RY] = IsDlgButtonChecked(hwndDlg, IDC_INVERT_RY) == BST_CHECKED;
				break;

			case IDC_GUITAR:
				settings[port].isGuitar = IsDlgButtonChecked(hwndDlg, IDC_GUITAR) == BST_CHECKED;
				break;

			case IDC_DISABLED:
				settings[port].disabled = IsDlgButtonChecked(hwndDlg, IDC_DISABLED) == BST_CHECKED;
				break;

			case IDC_ANALOG_GREEN:
				settings[port].greenAnalog = IsDlgButtonChecked(hwndDlg, IDC_ANALOG_GREEN) == BST_CHECKED;
				break;

			case IDC_LOCKSLIDERS:
				settings[port].sticksLocked = IsDlgButtonChecked(hwndDlg, IDC_LOCKSLIDERS) == BST_CHECKED;

				EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_DEADZONE2), !settings[port].sticksLocked);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_ANTIDEADZONE2), !settings[port].sticksLocked);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SLIDER_LINEARITY2), !settings[port].sticksLocked);
				break;

			case IDC_4WAYSTICK:
				//settings[port].b4wayStick = IsDlgButtonChecked(hwndDlg, IDC_4WAYSTICK) == BST_CHECKED;
				break;

			case IDC_SWAPSTICKS:
				settings[port].SwapSticksEnabled = IsDlgButtonChecked(hwndDlg, IDC_SWAPSTICKS) == BST_CHECKED;
				break;

			case IDC_SWAPXO:
				settings[port].SwapXO = IsDlgButtonChecked(hwndDlg, IDC_SWAPXO) == BST_CHECKED;
				break;
			}

		} break;

	case WM_USER: if(wParam == 0xDEADBEEF)
		{
			port = lParam;
			UpdateControls(hChild, port);
		}
		break;

	default: return FALSE;
	}

	return TRUE;
}