TASInputDlg.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Copyright 2011 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <wx/bitmap.h>
  6. #include <wx/dcmemory.h>
  7. #include <wx/dialog.h>
  8. #include <wx/sizer.h>
  9. #include "Common/CommonTypes.h"
  10. #include "Core/HW/WiimoteEmu/WiimoteEmu.h"
  11. #include "InputCommon/GCPadStatus.h"
  12. class wxCheckBox;
  13. class wxSlider;
  14. class wxStaticBitmap;
  15. class wxTextCtrl;
  16. class TASInputDlg : public wxDialog
  17. {
  18. public:
  19. TASInputDlg(wxWindow* parent,
  20. wxWindowID id = wxID_ANY,
  21. const wxString& title = _("TAS Input"),
  22. const wxPoint& pos = wxDefaultPosition,
  23. const wxSize& size = wxDefaultSize,
  24. long style = wxDEFAULT_DIALOG_STYLE | wxSTAY_ON_TOP);
  25. void OnCloseWindow(wxCloseEvent& event);
  26. void UpdateFromSliders(wxCommandEvent& event);
  27. void UpdateFromText(wxCommandEvent& event);
  28. void OnMouseDownL(wxMouseEvent& event);
  29. void OnMouseUpR(wxMouseEvent& event);
  30. void OnRightClickSlider(wxMouseEvent& event);
  31. void ResetValues();
  32. void GetValues(GCPadStatus* PadStatus);
  33. void GetValues(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key);
  34. void SetTurbo(wxMouseEvent& event);
  35. void SetTurboFalse(wxMouseEvent& event);
  36. void SetTurboState(wxCheckBox* CheckBox, bool* turbo_on);
  37. void ButtonTurbo();
  38. void GetKeyBoardInput(GCPadStatus* PadStatus);
  39. void GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key);
  40. bool TextBoxHasFocus();
  41. void SetLandRTriggers();
  42. bool TASHasFocus();
  43. void CreateGCLayout();
  44. void CreateWiiLayout(int num);
  45. wxBitmap CreateStickBitmap(int x, int y);
  46. void SetWiiButtons(u16* butt);
  47. void GetIRData(u8* const data, u8 mode, bool use_accel);
  48. void HandleExtensionChange();
  49. private:
  50. const int ID_C_STICK = 1001;
  51. const int ID_MAIN_STICK = 1002;
  52. const int ID_CC_L_STICK = 1003;
  53. const int ID_CC_R_STICK = 1004;
  54. int m_eleID = 1005;
  55. struct Control
  56. {
  57. wxTextCtrl* text;
  58. wxSlider* slider;
  59. int value = -1;
  60. int text_id;
  61. int slider_id;
  62. u32 range;
  63. u32 default_value = 128;
  64. bool set_by_keyboard = false;
  65. bool reverse = false;
  66. };
  67. struct Button
  68. {
  69. wxCheckBox* checkbox;
  70. bool value = false;
  71. bool set_by_keyboard = false;
  72. bool turbo_on = false;
  73. int id;
  74. };
  75. struct Stick
  76. {
  77. wxStaticBitmap* bitmap;
  78. Control x_cont;
  79. Control y_cont;
  80. };
  81. wxBoxSizer* CreateCCLayout();
  82. void FinishLayout();
  83. void SetStickValue(Control* stick, int CurrentValue, int center = 128);
  84. void SetButtonValue(Button* button, bool CurrentState);
  85. void SetSliderValue(Control* control, int CurrentValue);
  86. void CreateBaseLayout();
  87. void UpdateStickBitmap(Stick stick);
  88. void InvalidateButton(Button* button);
  89. void InvalidateControl(Control* button);
  90. void UpdateFromInvalidatedButton(wxCommandEvent& event);
  91. void UpdateFromInvalidatedControl(wxCommandEvent& event);
  92. Stick* FindStickByID(int id);
  93. Stick CreateStick(int id_stick, int xRange, int yRange, u32 defaultX, u32 defaultY, bool reverseX, bool reverseY);
  94. wxStaticBoxSizer* CreateStickLayout(Stick* tempStick, const wxString& title);
  95. wxStaticBoxSizer* CreateAccelLayout(Control* x, Control* y, Control* z, const wxString& title);
  96. Button CreateButton(const std::string& name);
  97. Control CreateControl(long style, int width, int height, bool reverse = false, u32 range = 255, u32 default_value = 128);
  98. enum
  99. {
  100. CC_L_STICK_X,
  101. CC_L_STICK_Y,
  102. CC_R_STICK_X,
  103. CC_R_STICK_Y,
  104. CC_L_TRIGGER,
  105. CC_R_TRIGGER,
  106. };
  107. Control m_l_cont, m_r_cont, m_x_cont, m_y_cont, m_z_cont, m_nx_cont, m_ny_cont, m_nz_cont, m_cc_l, m_cc_r;
  108. Button m_a, m_b, m_x, m_y, m_z, m_l, m_r, m_c;
  109. Button m_start, m_plus, m_minus, m_one, m_two, m_home;
  110. Button m_dpad_up, m_dpad_down, m_dpad_left, m_dpad_right;
  111. Stick m_main_stick, m_c_stick;
  112. Stick m_cc_l_stick, m_cc_r_stick;
  113. Button* m_buttons[13];
  114. Button m_cc_buttons[15];
  115. Control* m_controls[10];
  116. Control* m_cc_controls[6];
  117. static const int m_gc_pad_buttons_bitmask[12];
  118. static const int m_wii_buttons_bitmask[11];
  119. static const int m_cc_buttons_bitmask[15];
  120. static const std::string m_cc_button_names[15];
  121. u8 m_ext = 0;
  122. wxBoxSizer* m_main_szr;
  123. wxBoxSizer* m_wiimote_szr;
  124. wxBoxSizer* m_ext_szr;
  125. wxBoxSizer* m_cc_szr;
  126. wxStaticBoxSizer* m_main_stick_szr;
  127. wxStaticBoxSizer* m_c_stick_szr;
  128. wxStaticBoxSizer* m_cc_l_stick_szr;
  129. wxStaticBoxSizer* m_cc_r_stick_szr;
  130. bool m_has_layout = false;
  131. wxGridSizer* m_buttons_dpad;
  132. };