Allows you to drag the input for the analogs.

This commit is contained in:
Braden
2012-11-04 01:56:41 -05:00
parent 2976e89944
commit 793e547e15
2 changed files with 22 additions and 10 deletions

View File

@ -54,7 +54,8 @@ TASInputDlg::TASInputDlg(wxWindow *parent, wxWindowID id, const wxString &title,
wxBoxSizer* const main_stick_box = new wxBoxSizer(wxVERTICAL);
static_bitmap_main = new wxStaticBitmap(this, ID_MAIN_STICK, TASInputDlg::CreateStickBitmap(128,128), wxDefaultPosition, wxDefaultSize);
static_bitmap_main->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(TASInputDlg::OnMouseUpL), NULL, this);
static_bitmap_main->Connect(wxEVT_MOTION, wxMouseEventHandler(TASInputDlg::OnMouseDownL), NULL, this);
static_bitmap_main->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(TASInputDlg::OnMouseDownL), NULL, this);
static_bitmap_main->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(TASInputDlg::OnMouseUpR), NULL, this);
wx_mainX_s = new wxSlider(this, ID_MAIN_X_SLIDER, 128, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
wx_mainX_s->SetMinSize(wxSize(120,-1));
@ -80,7 +81,8 @@ TASInputDlg::TASInputDlg(wxWindow *parent, wxWindowID id, const wxString &title,
wxBoxSizer* const c_stick_box = new wxBoxSizer(wxVERTICAL);
static_bitmap_c = new wxStaticBitmap(this, ID_C_STICK, TASInputDlg::CreateStickBitmap(128,128), wxDefaultPosition, wxDefaultSize);
static_bitmap_c->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(TASInputDlg::OnMouseUpL), NULL, this);
static_bitmap_c->Connect(wxEVT_MOTION, wxMouseEventHandler(TASInputDlg::OnMouseDownL), NULL, this);
static_bitmap_c->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(TASInputDlg::OnMouseDownL), NULL, this);
static_bitmap_c->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(TASInputDlg::OnMouseUpR), NULL, this);
wx_cX_s = new wxSlider(this, ID_C_X_SLIDER, 128, 0, 255, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL);
wx_cX_s->SetMinSize(wxSize(120,-1));
@ -766,8 +768,11 @@ void TASInputDlg::OnMouseUpR(wxMouseEvent& event)
}
void TASInputDlg::OnMouseUpL(wxMouseEvent& event)
void TASInputDlg::OnMouseDownL(wxMouseEvent& event)
{
if(!event.LeftIsDown())
return;
wxSlider *sliderX,*sliderY;
wxStaticBitmap *sbitmap;
wxTextCtrl *textX, *textY;
@ -799,6 +804,7 @@ void TASInputDlg::OnMouseUpL(wxMouseEvent& event)
return;
}
wxPoint ptM(event.GetPosition());
*x = ptM.x *2;
*y = ptM.y * 2;
@ -806,9 +812,15 @@ void TASInputDlg::OnMouseUpL(wxMouseEvent& event)
if(*x > 255)
*x = 255;
if(*x < 0)
*x =0;
if(*y > 255)
*y = 255;
if(*y <0)
*y = 0;
sbitmap->SetBitmap(TASInputDlg::CreateStickBitmap(*x,*y));
textX->SetValue(wxString::Format(wxT("%i"), *x));

View File

@ -37,7 +37,7 @@ class TASInputDlg : public wxDialog
void OnCloseWindow(wxCloseEvent& event);
void UpdateFromSliders(wxCommandEvent& event);
void UpdateFromText(wxCommandEvent& event);
void OnMouseUpL(wxMouseEvent& event);
void OnMouseDownL(wxMouseEvent& event);
void OnMouseUpR(wxMouseEvent& event);
void ResetValues();
void GetValues(SPADStatus *PadStatus, int controllerID);