2015-10-27 19:07:41 +00:00
|
|
|
/* dialog.cpp
|
|
|
|
* PCSX2 Dev Team
|
2015-10-17 16:57:28 +00:00
|
|
|
* Copyright (C) 2015
|
2010-06-05 05:35:36 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2010-06-05 05:35:36 +00:00
|
|
|
*/
|
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
#include "dialog.h"
|
|
|
|
|
|
|
|
// Construtor of Dialog
|
2016-09-04 12:10:02 +00:00
|
|
|
Dialog::Dialog()
|
2016-10-16 19:39:56 +00:00
|
|
|
: wxDialog(NULL, // Parent
|
|
|
|
wxID_ANY, // ID
|
|
|
|
_T("OnePad configuration"), // Title
|
|
|
|
wxDefaultPosition, // Position
|
|
|
|
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT), // Width + Lenght
|
2016-09-04 12:10:02 +00:00
|
|
|
// Style
|
|
|
|
wxSYSTEM_MENU |
|
|
|
|
wxCAPTION |
|
|
|
|
wxCLOSE_BOX |
|
|
|
|
wxCLIP_CHILDREN)
|
2010-06-05 08:22:14 +00:00
|
|
|
{
|
2011-06-12 14:48:36 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
/*
|
|
|
|
* Define the size and the position of each button :
|
|
|
|
* padding[ButtonID][0] : Width
|
|
|
|
* padding[ButtonID][1] : Height
|
|
|
|
* padding[ButtonID][2] : x position
|
|
|
|
* padding[ButtonID][3] : y position
|
|
|
|
*/
|
|
|
|
int padding[BUTTONS_LENGHT][4];
|
|
|
|
|
|
|
|
// L1
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L1][0] = 218; // Width
|
|
|
|
padding[PAD_L1][1] = 28; // Height
|
|
|
|
padding[PAD_L1][2] = 50; // X
|
|
|
|
padding[PAD_L1][3] = 175; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// L2
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L2][0] = 218; // Width
|
|
|
|
padding[PAD_L2][1] = 28; // Height
|
|
|
|
padding[PAD_L2][2] = 50; // X
|
|
|
|
padding[PAD_L2][3] = 104; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// R1
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R1][0] = 218; // Width
|
|
|
|
padding[PAD_R1][1] = 28; // Height
|
|
|
|
padding[PAD_R1][2] = 726; // X
|
|
|
|
padding[PAD_R1][3] = 175; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// R2
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R2][0] = 218; // Width
|
|
|
|
padding[PAD_R2][1] = 28; // Height
|
|
|
|
padding[PAD_R2][2] = 726; // X
|
|
|
|
padding[PAD_R2][3] = 104; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Triangle
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_TRIANGLE][0] = 218; // Width
|
|
|
|
padding[PAD_TRIANGLE][1] = 28; // Height
|
|
|
|
padding[PAD_TRIANGLE][2] = 726; // X
|
|
|
|
padding[PAD_TRIANGLE][3] = 246; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Circle
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_CIRCLE][0] = 218; // Width
|
|
|
|
padding[PAD_CIRCLE][1] = 28; // Height
|
|
|
|
padding[PAD_CIRCLE][2] = 726; // X
|
|
|
|
padding[PAD_CIRCLE][3] = 319; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Cross
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_CROSS][0] = 218; // Width
|
|
|
|
padding[PAD_CROSS][1] = 28; // Height
|
|
|
|
padding[PAD_CROSS][2] = 726; // X
|
|
|
|
padding[PAD_CROSS][3] = 391; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Square
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_SQUARE][0] = 218; // Width
|
|
|
|
padding[PAD_SQUARE][1] = 28; // Height
|
|
|
|
padding[PAD_SQUARE][2] = 726; // X
|
|
|
|
padding[PAD_SQUARE][3] = 463; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Directional pad up
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_UP][0] = 100; // Width
|
|
|
|
padding[PAD_UP][1] = 25; // Height
|
|
|
|
padding[PAD_UP][2] = 108; // X
|
|
|
|
padding[PAD_UP][3] = 290; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Directional pad down
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_DOWN][0] = 100; // Width
|
|
|
|
padding[PAD_DOWN][1] = 25; // Height
|
|
|
|
padding[PAD_DOWN][2] = 108; // X
|
|
|
|
padding[PAD_DOWN][3] = 340; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Directional pad right
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_RIGHT][0] = 109; // Width
|
|
|
|
padding[PAD_RIGHT][1] = 25; // Height
|
|
|
|
padding[PAD_RIGHT][2] = 159; // X
|
|
|
|
padding[PAD_RIGHT][3] = 315; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Directional pad left
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_LEFT][0] = 109; // Width
|
|
|
|
padding[PAD_LEFT][1] = 25; // Height
|
|
|
|
padding[PAD_LEFT][2] = 50; // X
|
|
|
|
padding[PAD_LEFT][3] = 315; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Left Joystick up
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L_UP][0] = 100; // Width
|
|
|
|
padding[PAD_L_UP][1] = 25; // Height
|
|
|
|
padding[PAD_L_UP][2] = 325; // X
|
|
|
|
padding[PAD_L_UP][3] = 527; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Left Joystick down
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L_DOWN][0] = 100; // Width
|
|
|
|
padding[PAD_L_DOWN][1] = 25; // Height
|
|
|
|
padding[PAD_L_DOWN][2] = 325; // X
|
|
|
|
padding[PAD_L_DOWN][3] = 577; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Left Joystick right
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L_RIGHT][0] = 109; // Width
|
|
|
|
padding[PAD_L_RIGHT][1] = 25; // Height
|
|
|
|
padding[PAD_L_RIGHT][2] = 377; // X
|
|
|
|
padding[PAD_L_RIGHT][3] = 552; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Left Joystick left
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L_LEFT][0] = 109; // Width
|
|
|
|
padding[PAD_L_LEFT][1] = 25; // Height
|
|
|
|
padding[PAD_L_LEFT][2] = 268; // X
|
|
|
|
padding[PAD_L_LEFT][3] = 552; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// L3
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_L3][0] = 218; // Width
|
|
|
|
padding[PAD_L3][1] = 28; // Height
|
|
|
|
padding[PAD_L3][2] = 268; // X
|
|
|
|
padding[PAD_L3][3] = 641; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Right Joystick up
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R_UP][0] = 100; // Width
|
|
|
|
padding[PAD_R_UP][1] = 25; // Height
|
|
|
|
padding[PAD_R_UP][2] = 555; // X
|
|
|
|
padding[PAD_R_UP][3] = 527; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Right Joystick down
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R_DOWN][0] = 100; // Width
|
|
|
|
padding[PAD_R_DOWN][1] = 25; // Height
|
|
|
|
padding[PAD_R_DOWN][2] = 555; // X
|
|
|
|
padding[PAD_R_DOWN][3] = 577; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Right Joystick right
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R_RIGHT][0] = 109; // Width
|
|
|
|
padding[PAD_R_RIGHT][1] = 25; // Height
|
|
|
|
padding[PAD_R_RIGHT][2] = 607; // X
|
|
|
|
padding[PAD_R_RIGHT][3] = 552; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Right Joystick left
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R_LEFT][0] = 109; // Width
|
|
|
|
padding[PAD_R_LEFT][1] = 25; // Height
|
|
|
|
padding[PAD_R_LEFT][2] = 498; // X
|
|
|
|
padding[PAD_R_LEFT][3] = 552; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// R3
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_R3][0] = 218; // Width
|
|
|
|
padding[PAD_R3][1] = 28; // Height
|
|
|
|
padding[PAD_R3][2] = 498; // X
|
|
|
|
padding[PAD_R3][3] = 641; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Start
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_START][0] = 218; // Width
|
|
|
|
padding[PAD_START][1] = 28; // Height
|
|
|
|
padding[PAD_START][2] = 503; // X
|
|
|
|
padding[PAD_START][3] = 34; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Select
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[PAD_SELECT][0] = 218; // Width
|
|
|
|
padding[PAD_SELECT][1] = 28; // Height
|
|
|
|
padding[PAD_SELECT][2] = 273; // X
|
|
|
|
padding[PAD_SELECT][3] = 34; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Analog
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Analog][0] = 218; // Width
|
|
|
|
padding[Analog][1] = 28; // Height
|
|
|
|
padding[Analog][2] = 50; // X
|
|
|
|
padding[Analog][3] = 452; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Left Joystick Configuration
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[JoyL_config][0] = 180; // Width
|
|
|
|
padding[JoyL_config][1] = 28; // Height
|
|
|
|
padding[JoyL_config][2] = 50; // X
|
|
|
|
padding[JoyL_config][3] = 550; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Right Joystick Configuration
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[JoyR_config][0] = 180; // Width
|
|
|
|
padding[JoyR_config][1] = 28; // Height
|
|
|
|
padding[JoyR_config][2] = 764; // X
|
|
|
|
padding[JoyR_config][3] = 550; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Gamepad Configuration
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Gamepad_config][0] = 180; // Width
|
|
|
|
padding[Gamepad_config][1] = 28; // Height
|
|
|
|
padding[Gamepad_config][2] = 50; // X
|
|
|
|
padding[Gamepad_config][3] = 585; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
2015-10-27 19:07:41 +00:00
|
|
|
// Set All Buttons
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Set_all][0] = 180; // Width
|
|
|
|
padding[Set_all][1] = 28; // Height
|
|
|
|
padding[Set_all][2] = 764; // X
|
|
|
|
padding[Set_all][3] = 585; // Y
|
2015-10-27 19:07:41 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
// Apply modifications without exit
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Apply][0] = 70; // Width
|
|
|
|
padding[Apply][1] = 28; // Height
|
|
|
|
padding[Apply][2] = 833; // X
|
|
|
|
padding[Apply][3] = 642; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Ok button
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Ok][0] = 70; // Width
|
|
|
|
padding[Ok][1] = 28; // Height
|
|
|
|
padding[Ok][2] = 913; // X
|
|
|
|
padding[Ok][3] = 642; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Cancel button
|
2016-10-16 19:39:56 +00:00
|
|
|
padding[Cancel][0] = 70; // Width
|
|
|
|
padding[Cancel][1] = 28; // Height
|
|
|
|
padding[Cancel][2] = 753; // X
|
|
|
|
padding[Cancel][3] = 642; // Y
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// create a new Notebook
|
2015-11-29 14:42:42 +00:00
|
|
|
m_tab_gamepad = new wxNotebook(this, wxID_ANY);
|
2016-09-04 12:10:02 +00:00
|
|
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
2015-10-17 16:57:28 +00:00
|
|
|
// Tabs panels
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[i] = new opPanel(
|
2016-02-27 19:04:06 +00:00
|
|
|
m_tab_gamepad,
|
|
|
|
wxID_ANY,
|
|
|
|
wxDefaultPosition,
|
2016-09-04 12:10:02 +00:00
|
|
|
wxSize(DEFAULT_WIDTH, DEFAULT_HEIGHT));
|
2015-10-17 16:57:28 +00:00
|
|
|
// Add new page
|
|
|
|
// Define label
|
|
|
|
std::stringstream sstm;
|
|
|
|
std::string label = "Gamepad ";
|
|
|
|
sstm << label << i;
|
|
|
|
// New page creation
|
2015-11-29 14:42:42 +00:00
|
|
|
m_tab_gamepad->AddPage(
|
2016-10-16 19:39:56 +00:00
|
|
|
m_pan_tabs[i], // Parent
|
|
|
|
wxString(sstm.str().c_str(), wxConvUTF8) // Title
|
2016-09-04 12:10:02 +00:00
|
|
|
);
|
2015-10-17 16:57:28 +00:00
|
|
|
|
2016-09-04 12:10:02 +00:00
|
|
|
for (int j = 0; j < BUTTONS_LENGHT; ++j) {
|
2016-02-27 19:04:06 +00:00
|
|
|
// Gamepad buttons
|
|
|
|
m_bt_gamepad[i][j] = new wxButton(
|
2016-10-16 19:39:56 +00:00
|
|
|
m_pan_tabs[i], // Parent
|
|
|
|
wxID_HIGHEST + j + 1, // ID
|
|
|
|
_T("Undefined"), // Label
|
|
|
|
wxPoint(padding[j][2], padding[j][3]), // Position
|
|
|
|
wxSize(padding[j][0], padding[j][1]) // Size
|
2016-09-04 12:10:02 +00:00
|
|
|
);
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
|
|
|
// Redefine others gui buttons label
|
2015-11-29 14:42:42 +00:00
|
|
|
m_bt_gamepad[i][JoyL_config]->SetLabel(_T("&Left Joystick Config"));
|
|
|
|
m_bt_gamepad[i][JoyR_config]->SetLabel(_T("&Right Joystick Config"));
|
|
|
|
m_bt_gamepad[i][Gamepad_config]->SetLabel(_T("&Gamepad Configuration"));
|
|
|
|
m_bt_gamepad[i][Set_all]->SetLabel(_T("&Set All Buttons"));
|
|
|
|
m_bt_gamepad[i][Cancel]->SetLabel(_T("&Cancel"));
|
|
|
|
m_bt_gamepad[i][Apply]->SetLabel(_T("&Apply"));
|
|
|
|
m_bt_gamepad[i][Ok]->SetLabel(_T("&Ok"));
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// Disable analog button (not yet supported)
|
2015-11-29 14:42:42 +00:00
|
|
|
m_bt_gamepad[i][Analog]->Disable();
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
|
|
|
|
2016-04-27 07:47:03 +00:00
|
|
|
Bind(wxEVT_BUTTON, &Dialog::OnButtonClicked, this);
|
2015-10-17 16:57:28 +00:00
|
|
|
|
2016-09-04 12:10:02 +00:00
|
|
|
for (int i = 0; i < GAMEPAD_NUMBER; ++i) {
|
|
|
|
for (int j = 0; j < NB_IMG; ++j) {
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pressed[i][j] = false;
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-12 14:48:36 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
void Dialog::InitDialog()
|
2011-06-12 14:48:36 +00:00
|
|
|
{
|
2016-10-16 19:39:56 +00:00
|
|
|
GamePad::EnumerateGamePads(s_vgamePad); // activate gamepads
|
|
|
|
LoadConfig(); // Load configuration from the ini file
|
|
|
|
repopulate(); // Set label and fit simulated key array
|
2010-06-05 05:35:36 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
/****************************************/
|
|
|
|
/*********** Events functions ***********/
|
|
|
|
/****************************************/
|
2011-06-12 14:48:36 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
void Dialog::OnButtonClicked(wxCommandEvent &event)
|
|
|
|
{
|
|
|
|
// Affichage d'un message à chaque clic sur le bouton
|
2016-10-16 19:39:56 +00:00
|
|
|
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
|
|
|
int bt_id = bt_tmp->GetId() - wxID_HIGHEST - 1; // get the real ID
|
|
|
|
int gamepad_id = m_tab_gamepad->GetSelection(); // get the tab ID (equivalent to the gamepad id)
|
|
|
|
if (bt_id >= 0 && bt_id <= PAD_R_LEFT) { // if the button ID is a gamepad button
|
|
|
|
bt_tmp->Disable(); // switch the button state to "Disable"
|
2015-11-29 14:42:42 +00:00
|
|
|
config_key(gamepad_id, bt_id);
|
2016-10-16 19:39:56 +00:00
|
|
|
bt_tmp->Enable(); // switch the button state to "Enable"
|
|
|
|
} else if (bt_id == Gamepad_config) { // If the button ID is equals to the Gamepad_config button ID
|
2016-07-20 08:06:29 +00:00
|
|
|
GamepadConfiguration gamepad_config(gamepad_id, this);
|
|
|
|
|
|
|
|
gamepad_config.InitGamepadConfiguration();
|
|
|
|
gamepad_config.ShowModal();
|
2016-10-16 19:39:56 +00:00
|
|
|
} else if (bt_id == JoyL_config) { // If the button ID is equals to the JoyL_config button ID
|
2016-07-20 08:06:29 +00:00
|
|
|
JoystickConfiguration joystick_config(gamepad_id, true, this);
|
|
|
|
|
|
|
|
joystick_config.InitJoystickConfiguration();
|
|
|
|
joystick_config.ShowModal();
|
2016-10-16 19:39:56 +00:00
|
|
|
} else if (bt_id == JoyR_config) { // If the button ID is equals to the JoyR_config button ID
|
2016-07-20 08:06:29 +00:00
|
|
|
JoystickConfiguration joystick_config(gamepad_id, false, this);
|
|
|
|
|
|
|
|
joystick_config.InitJoystickConfiguration();
|
|
|
|
joystick_config.ShowModal();
|
2016-10-16 19:39:56 +00:00
|
|
|
} else if (bt_id == Set_all) { // If the button ID is equals to the Set_all button ID
|
2016-09-04 12:10:02 +00:00
|
|
|
for (int i = 0; i < MAX_KEYS; ++i) {
|
2015-11-29 14:42:42 +00:00
|
|
|
bt_tmp = m_bt_gamepad[gamepad_id][i];
|
2016-09-04 12:10:02 +00:00
|
|
|
switch (i) {
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_UP: // Left joystick (Up) ↑
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_RIGHT: // Left joystick (Right) →
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_DOWN: // Left joystick (Down) ↓
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_LEFT: // Left joystick (Left) ←
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_UP: // Right joystick (Up) ↑
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_RIGHT: // Right joystick (Right) →
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_DOWN: // Right joystick (Down) ↓
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_LEFT: // Right joystick (Left) ←
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->ShowImg(i);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->Refresh();
|
|
|
|
m_pan_tabs[gamepad_id]->Update();
|
|
|
|
config_key(gamepad_id, i);
|
2016-09-04 12:10:02 +00:00
|
|
|
switch (i) {
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_UP: // Left joystick (Up) ↑
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_RIGHT: // Left joystick (Right) →
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_right);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_DOWN: // Left joystick (Down) ↓
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_L_LEFT: // Left joystick (Left) ←
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_left);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_UP: // Right joystick (Up) ↑
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_up);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_RIGHT: // Right joystick (Right) →
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_right);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_DOWN: // Right joystick (Down) ↓
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
2016-10-16 19:39:56 +00:00
|
|
|
case PAD_R_LEFT: // Right joystick (Left) ←
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_left);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->HideImg(i);
|
2015-10-27 19:07:41 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-11-29 14:42:42 +00:00
|
|
|
m_pan_tabs[gamepad_id]->Refresh();
|
|
|
|
m_pan_tabs[gamepad_id]->Update();
|
2016-10-16 19:39:56 +00:00
|
|
|
usleep(500000); // give enough time to the user to release the button
|
2015-10-27 19:07:41 +00:00
|
|
|
}
|
2016-10-16 19:39:56 +00:00
|
|
|
} else if (bt_id == Ok) { // If the button ID is equals to the Ok button ID
|
|
|
|
SaveConfig(); // Save the configuration
|
|
|
|
Close(); // Close the window
|
|
|
|
} else if (bt_id == Apply) { // If the button ID is equals to the Apply button ID
|
|
|
|
SaveConfig(); // Save the configuration
|
|
|
|
} else if (bt_id == Cancel) { // If the button ID is equals to the cancel button ID
|
|
|
|
Close(); // Close the window
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-05 05:35:36 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
/****************************************/
|
|
|
|
/*********** Methods functions **********/
|
|
|
|
/****************************************/
|
2011-06-12 14:48:36 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
void Dialog::config_key(int pad, int key)
|
2010-06-05 05:35:36 +00:00
|
|
|
{
|
2016-09-04 12:10:02 +00:00
|
|
|
bool captured = false;
|
|
|
|
u32 key_pressed = 0;
|
|
|
|
|
|
|
|
while (!captured) {
|
|
|
|
if (PollX11KeyboardMouseEvent(key_pressed)) {
|
|
|
|
// special case for keyboard/mouse to handle multiple keys
|
|
|
|
// Note: key_pressed == 0 when ESC is hit to abort the capture
|
|
|
|
if (key_pressed > 0) {
|
2015-11-29 14:42:42 +00:00
|
|
|
clear_key(pad, key);
|
2016-09-04 12:10:02 +00:00
|
|
|
set_keyboad_key(pad, key_pressed, key);
|
2015-11-29 14:42:42 +00:00
|
|
|
m_simulatedKeys[pad][key] = key_pressed;
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
2016-09-04 12:10:02 +00:00
|
|
|
captured = true;
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
2016-09-04 12:10:02 +00:00
|
|
|
}
|
2016-04-27 07:35:46 +00:00
|
|
|
m_bt_gamepad[pad][key]->SetLabel(
|
2016-09-04 12:10:02 +00:00
|
|
|
KeyName(pad, key, m_simulatedKeys[pad][key]).c_str());
|
2010-06-05 08:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
void Dialog::clear_key(int pad, int key)
|
2010-06-05 08:22:14 +00:00
|
|
|
{
|
2015-10-17 16:57:28 +00:00
|
|
|
// Erase the keyboard binded key
|
2015-11-29 14:42:42 +00:00
|
|
|
u32 keysim = m_simulatedKeys[pad][key];
|
|
|
|
m_simulatedKeys[pad][key] = 0;
|
2015-10-17 16:57:28 +00:00
|
|
|
|
|
|
|
// erase gamepad entry (keysim map)
|
2017-04-16 11:58:22 +00:00
|
|
|
conf->keysym_map[pad].erase(keysim);
|
2010-06-05 08:22:14 +00:00
|
|
|
}
|
|
|
|
|
2010-06-05 05:35:36 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
// Set button values
|
|
|
|
void Dialog::repopulate()
|
2011-06-12 14:48:36 +00:00
|
|
|
{
|
2016-09-04 12:10:02 +00:00
|
|
|
for (int gamepad_id = 0; gamepad_id < GAMEPAD_NUMBER; ++gamepad_id) {
|
2015-10-17 16:57:28 +00:00
|
|
|
// keyboard/mouse key
|
2017-04-14 20:10:08 +00:00
|
|
|
for (const auto &it : conf->keysym_map[gamepad_id]) {
|
|
|
|
int keysym = it.first;
|
|
|
|
int key = it.second;
|
2016-04-27 07:35:46 +00:00
|
|
|
|
|
|
|
m_bt_gamepad[gamepad_id][key]->SetLabel(
|
2016-09-04 12:10:02 +00:00
|
|
|
KeyName(gamepad_id, key, keysym).c_str());
|
2016-04-27 07:35:46 +00:00
|
|
|
|
2015-11-29 14:42:42 +00:00
|
|
|
m_simulatedKeys[gamepad_id][key] = keysym;
|
2015-10-17 16:57:28 +00:00
|
|
|
}
|
|
|
|
}
|
2011-06-12 14:48:36 +00:00
|
|
|
}
|
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
// Main
|
2011-06-12 14:48:36 +00:00
|
|
|
void DisplayDialog()
|
|
|
|
{
|
2016-07-20 08:06:29 +00:00
|
|
|
Dialog dialog;
|
|
|
|
|
|
|
|
dialog.InitDialog();
|
|
|
|
dialog.ShowModal();
|
2010-06-05 05:35:36 +00:00
|
|
|
}
|