mirror of https://github.com/PCSX2/pcsx2.git
More gtk removals and Onepad dialog tweaks (#3525)
* Improve secondary dialogs in Onepad. I'll do gtk stuff in this branch, too, I promise... * More fiddling with onepad's secondary dialogs. * Rework config.inl to use wx, getting the rest of the null plugins. * Remove some unnecessary includes, and convert SysMessage to wx in onepad. * Add in tellowkrinkle's Mac OS fixes.
This commit is contained in:
parent
b00c603e0b
commit
e42b9ce110
|
@ -1,142 +0,0 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
|
||||||
* Copyright (C) 2002-2010 PCSX2 Dev Team
|
|
||||||
*
|
|
||||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* PCSX2 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 PCSX2.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// gtkGuiTools.h
|
|
||||||
//
|
|
||||||
// This file is meant to contain utility classes for users of GTK, for purposes
|
|
||||||
// of GTK 2/3 compatibility, and other helpful routines to help avoid repeatedly
|
|
||||||
// implementing the same code.
|
|
||||||
//
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
// They've gotten rid of the GtkHBox and GtkVBox in GTK3 in favor of using the
|
|
||||||
// more general GtkBox and supplying an orientation. While this is probably a
|
|
||||||
// move in the right direction, for compatability, it's easier to define our
|
|
||||||
// own hbox and vbox routines that invoke the old or the new version, depending
|
|
||||||
// on what it's built for.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static GtkWidget *ps_gtk_hbox_new(int padding = 5)
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_hbox_new(false, padding);
|
|
||||||
#else
|
|
||||||
return gtk_box_new(GTK_ORIENTATION_HORIZONTAL, padding);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *ps_gtk_vbox_new(int padding = 5)
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_vbox_new(false, padding);
|
|
||||||
#else
|
|
||||||
return gtk_box_new(GTK_ORIENTATION_VERTICAL, padding);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Similarly, GtkHScale and GtkVScale make way for GtkScale.
|
|
||||||
static GtkWidget *ps_gtk_hscale_new_with_range(double g_min, double g_max, int g_step = 5)
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_hscale_new_with_range(g_min, g_max, g_step);
|
|
||||||
#else
|
|
||||||
return gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, g_min, g_max, g_step);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *ps_gtk_vscale_new_with_range(double g_min, double g_max, int g_step = 5)
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_vscale_new_with_range(g_min, g_max, g_step);
|
|
||||||
#else
|
|
||||||
return gtk_scale_new_with_range(GTK_ORIENTATION_VERTICAL, g_min, g_max, g_step);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// And so on and so forth...
|
|
||||||
static GtkWidget *ps_gtk_hseparator_new()
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_hseparator_new();
|
|
||||||
#else
|
|
||||||
return gtk_separator_new(GTK_ORIENTATION_HORIZONTAL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget *ps_gtk_vseparator_new()
|
|
||||||
{
|
|
||||||
#if GTK_MAJOR_VERSION < 3
|
|
||||||
return gtk_vseparator_new();
|
|
||||||
#else
|
|
||||||
return gtk_separator_new(GTK_ORIENTATION_VERTICAL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// These two routines have been rewritten over and over. May as well include a copy.
|
|
||||||
// Renaming so as not to interfere with existing versions.
|
|
||||||
static void pcsx2_message(const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
char msg[512];
|
|
||||||
|
|
||||||
va_start(list, fmt);
|
|
||||||
vsprintf(msg, fmt, list);
|
|
||||||
va_end(list);
|
|
||||||
|
|
||||||
if (msg[strlen(msg) - 1] == '\n')
|
|
||||||
msg[strlen(msg) - 1] = 0;
|
|
||||||
|
|
||||||
GtkWidget *dialog;
|
|
||||||
dialog = gtk_message_dialog_new(NULL,
|
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_INFO,
|
|
||||||
GTK_BUTTONS_OK,
|
|
||||||
"%s", msg);
|
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pcsx2_message(const wchar_t *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list list;
|
|
||||||
va_start(list, fmt);
|
|
||||||
wxString msg;
|
|
||||||
msg.PrintfV(fmt, list);
|
|
||||||
va_end(list);
|
|
||||||
|
|
||||||
GtkWidget *dialog;
|
|
||||||
dialog = gtk_message_dialog_new(NULL,
|
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_INFO,
|
|
||||||
GTK_BUTTONS_OK,
|
|
||||||
"%s", msg.ToUTF8().data());
|
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic pop
|
|
||||||
#endif
|
|
|
@ -17,8 +17,8 @@
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__) || defined(__APPLE__)
|
||||||
#include <gtk/gtk.h>
|
#include <wx/wx.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -65,33 +65,33 @@ void ConfigureLogging()
|
||||||
DialogBox(s_hinstance, MAKEINTRESOURCE(IDD_DIALOG), GetActiveWindow(), ConfigureDialogProc);
|
DialogBox(s_hinstance, MAKEINTRESOURCE(IDD_DIALOG), GetActiveWindow(), ConfigureDialogProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__) || defined(__APPLE__)
|
||||||
|
|
||||||
void ConfigureLogging()
|
void ConfigureLogging()
|
||||||
{
|
{
|
||||||
GtkDialogFlags flags = static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT);
|
auto *dialog = new wxDialog;
|
||||||
GtkWidget *dialog = gtk_dialog_new_with_buttons("Config", nullptr, flags,
|
dialog->Create(nullptr, wxID_ANY, "Config", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX);
|
||||||
"Cancel", GTK_RESPONSE_REJECT,
|
|
||||||
"Ok", GTK_RESPONSE_ACCEPT,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
GtkWidget *console_checkbox = gtk_check_button_new_with_label("Log to console");
|
auto *main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
GtkWidget *file_checkbox = gtk_check_button_new_with_label("Log to file");
|
auto *sizer = dialog->CreateButtonSizer(wxOK | wxCANCEL);
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(console_checkbox), g_plugin_log.WriteToConsole);
|
|
||||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(file_checkbox), g_plugin_log.WriteToFile);
|
|
||||||
|
|
||||||
GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
|
auto *log_check = new wxCheckBox(dialog, wxID_ANY, "Log to Console");
|
||||||
gtk_container_add(GTK_CONTAINER(content_area), console_checkbox);
|
auto *file_check = new wxCheckBox(dialog, wxID_ANY, "Log to File");
|
||||||
gtk_container_add(GTK_CONTAINER(content_area), file_checkbox);
|
log_check->SetValue(g_plugin_log.WriteToConsole);
|
||||||
|
file_check->SetValue(g_plugin_log.WriteToFile);
|
||||||
|
|
||||||
gtk_widget_show_all(dialog);
|
main_sizer->Add(log_check);
|
||||||
|
main_sizer->Add(file_check);
|
||||||
|
main_sizer->Add(sizer);
|
||||||
|
|
||||||
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
|
dialog->SetSizerAndFit(main_sizer);
|
||||||
g_plugin_log.WriteToConsole = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(console_checkbox)) == TRUE;
|
|
||||||
g_plugin_log.WriteToFile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(file_checkbox)) == TRUE;
|
if ( dialog->ShowModal() == wxID_OK )
|
||||||
|
{
|
||||||
|
g_plugin_log.WriteToConsole = log_check->GetValue();
|
||||||
|
g_plugin_log.WriteToFile = file_check->GetValue();
|
||||||
}
|
}
|
||||||
|
wxDELETE(dialog);
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -56,7 +56,6 @@ set(UtilitiesHeaders
|
||||||
../../include/Utilities/EventSource.h
|
../../include/Utilities/EventSource.h
|
||||||
../../include/Utilities/Exceptions.h
|
../../include/Utilities/Exceptions.h
|
||||||
../../include/Utilities/FixedPointTypes.h
|
../../include/Utilities/FixedPointTypes.h
|
||||||
../../include/Utilities/gtkGuiTools.h
|
|
||||||
../../include/Utilities/General.h
|
../../include/Utilities/General.h
|
||||||
../../include/Utilities/MakeUnique.h
|
../../include/Utilities/MakeUnique.h
|
||||||
../../include/Utilities/MemcpyFast.h
|
../../include/Utilities/MemcpyFast.h
|
||||||
|
|
|
@ -48,7 +48,7 @@ set(FWnullFinalSources
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FWnullFinalLibs
|
set(FWnullFinalLibs
|
||||||
${GTK2_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILTIN_FW)
|
if(BUILTIN_FW)
|
||||||
|
|
|
@ -45,9 +45,6 @@ static HRESULT s_hr = E_FAIL;
|
||||||
#include "Window/GSWndOGL.h"
|
#include "Window/GSWndOGL.h"
|
||||||
#include "Window/GSWndEGL.h"
|
#include "Window/GSWndEGL.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include <gdk/gdkx.h>
|
|
||||||
|
|
||||||
extern bool RunLinuxDialog();
|
extern bool RunLinuxDialog();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,6 +49,7 @@ set(USBnullFinalSources
|
||||||
|
|
||||||
set(USBnullFinalLibs
|
set(USBnullFinalLibs
|
||||||
${GTK2_LIBRARIES}
|
${GTK2_LIBRARIES}
|
||||||
|
${wxWidgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILTIN_USB)
|
if(BUILTIN_USB)
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
|
|
||||||
#define __inline inline
|
#define __inline inline
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,7 +47,7 @@ set(dev9nullFinalSources
|
||||||
)
|
)
|
||||||
|
|
||||||
set(dev9nullFinalLibs
|
set(dev9nullFinalLibs
|
||||||
${GTK2_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILTIN_DEV9)
|
if(BUILTIN_DEV9)
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
extern const unsigned char version;
|
extern const unsigned char version;
|
||||||
extern const unsigned char revision;
|
extern const unsigned char revision;
|
||||||
extern const unsigned char build;
|
extern const unsigned char build;
|
||||||
extern const unsigned int minor;
|
|
||||||
|
|
||||||
extern void (*DEV9irq)(int);
|
extern void (*DEV9irq)(int);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
#include "state_management.h"
|
#include "state_management.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "wx_dialog/dialog.h"
|
#include "wx_dialog/dialog.h"
|
||||||
|
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
|
@ -33,7 +32,7 @@ Display *GSdsp;
|
||||||
Window GSwin;
|
Window GSwin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SysMessage(const char *fmt, ...)
|
static void SysMessage(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -45,14 +44,8 @@ void SysMessage(const char *fmt, ...)
|
||||||
if (msg[strlen(msg) - 1] == '\n')
|
if (msg[strlen(msg) - 1] == '\n')
|
||||||
msg[strlen(msg) - 1] = 0;
|
msg[strlen(msg) - 1] = 0;
|
||||||
|
|
||||||
GtkWidget *dialog;
|
wxMessageDialog dialog(nullptr, msg, "Info", wxOK);
|
||||||
dialog = gtk_message_dialog_new(NULL,
|
dialog.ShowModal();
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_INFO,
|
|
||||||
GTK_BUTTONS_OK,
|
|
||||||
"%s", msg);
|
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_C_(void)
|
EXPORT_C_(void)
|
||||||
|
|
|
@ -19,100 +19,49 @@
|
||||||
|
|
||||||
#include "GamepadConfiguration.h"
|
#include "GamepadConfiguration.h"
|
||||||
|
|
||||||
// Construtor of GamepadConfiguration
|
|
||||||
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
|
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent)
|
||||||
: wxDialog(
|
: wxDialog(parent, wxID_ANY, _T("Gamepad"), wxDefaultPosition, wxDefaultSize,
|
||||||
parent, // Parent
|
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("Gamepad configuration"), // Title
|
|
||||||
wxDefaultPosition, // Position
|
|
||||||
wxSize(400, 270), // Width + Length
|
|
||||||
// Style
|
|
||||||
wxSYSTEM_MENU |
|
|
||||||
wxCAPTION |
|
|
||||||
wxCLOSE_BOX |
|
|
||||||
wxCLIP_CHILDREN)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
m_pan_gamepad_config = new wxPanel(
|
|
||||||
this, // Parent
|
wxBoxSizer *gamepad_box = new wxBoxSizer(wxVERTICAL);
|
||||||
wxID_ANY, // ID
|
|
||||||
wxDefaultPosition, // Position
|
|
||||||
wxSize(300, 230) // Size
|
|
||||||
);
|
|
||||||
m_cb_rumble = new wxCheckBox(
|
|
||||||
m_pan_gamepad_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("&Enable rumble"), // Label
|
|
||||||
wxPoint(20, 20) // Position
|
|
||||||
);
|
|
||||||
|
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
for (const auto &j : s_vgamePad) {
|
for (const auto &j : s_vgamePad) {
|
||||||
choices.Add(j->GetName());
|
choices.Add(j->GetName());
|
||||||
}
|
}
|
||||||
m_joy_map = new wxChoice(
|
|
||||||
m_pan_gamepad_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
wxPoint(20, 50), // Position
|
|
||||||
wxDefaultSize, // Size
|
|
||||||
choices);
|
|
||||||
|
|
||||||
wxString txt_rumble = wxT("Rumble intensity");
|
m_joy_map = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
|
||||||
m_lbl_rumble_intensity = new wxStaticText(
|
m_cb_rumble = new wxCheckBox(this, enable_rumble_id, _T("&Enable rumble"));
|
||||||
m_pan_gamepad_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
txt_rumble, // Text which must be displayed
|
|
||||||
wxPoint(20, 90), // Position
|
|
||||||
wxDefaultSize // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
m_sl_rumble_intensity = new wxSlider(
|
wxStaticBoxSizer *rumble_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Rumble intensity"));
|
||||||
m_pan_gamepad_config, // Parent
|
m_sl_rumble_intensity = new wxSlider(this, rumble_slider_id, 0, 0, 0x7FFF, wxDefaultPosition, wxDefaultSize,
|
||||||
wxID_ANY, // ID
|
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
||||||
0, // value
|
|
||||||
0, // min value 0x0000
|
|
||||||
0x7FFF, // max value 0x7FFF
|
|
||||||
wxPoint(150, 83), // Position
|
|
||||||
wxSize(200, 50), // Size
|
|
||||||
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM
|
|
||||||
);
|
|
||||||
|
|
||||||
wxString txt_joystick = wxT("Joystick sensibility");
|
wxStaticBoxSizer *joy_box = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Joystick sensibility"));
|
||||||
m_lbl_rumble_intensity = new wxStaticText(
|
m_sl_joystick_sensibility = new wxSlider(this, joy_slider_id, 0, 0, 200, wxDefaultPosition, wxDefaultSize,
|
||||||
m_pan_gamepad_config, // Parent
|
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM);
|
||||||
wxID_ANY, // ID
|
|
||||||
txt_joystick, // Text which must be displayed
|
|
||||||
wxPoint(20, 150), // Position
|
|
||||||
wxDefaultSize // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
m_sl_joystick_sensibility = new wxSlider(
|
gamepad_box->Add(m_joy_map, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||||
m_pan_gamepad_config, // Parent
|
gamepad_box->Add(m_cb_rumble, wxSizerFlags().Expand());
|
||||||
wxID_ANY, // ID
|
|
||||||
0, // value
|
|
||||||
0, // min value
|
|
||||||
200, // max value
|
|
||||||
wxPoint(150, 143), // Position
|
|
||||||
wxSize(200, 50), // Size
|
|
||||||
wxSL_HORIZONTAL | wxSL_LABELS | wxSL_BOTTOM
|
|
||||||
);
|
|
||||||
|
|
||||||
m_bt_ok = new wxButton(
|
rumble_box->Add(m_sl_rumble_intensity, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||||
m_pan_gamepad_config, // Parent
|
joy_box->Add(m_sl_joystick_sensibility, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("&OK"), // Label
|
|
||||||
wxPoint(320, 210), // Position
|
|
||||||
wxSize(60, 25) // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnButtonClicked, this);
|
gamepad_box->Add(rumble_box, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||||
|
gamepad_box->Add(joy_box, wxSizerFlags().Expand().Border(wxALL, 5));
|
||||||
|
|
||||||
|
gamepad_box->Add(CreateSeparatedButtonSizer(wxOK), wxSizerFlags().Right().Border(wxALL, 5));
|
||||||
|
|
||||||
|
Bind(wxEVT_BUTTON, &GamepadConfiguration::OnOk, this, wxID_OK);
|
||||||
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
|
Bind(wxEVT_SCROLL_THUMBRELEASE, &GamepadConfiguration::OnSliderReleased, this);
|
||||||
Bind(wxEVT_CHECKBOX, &GamepadConfiguration::OnCheckboxChange, this);
|
Bind(wxEVT_CHECKBOX, &GamepadConfiguration::OnCheckboxChange, this);
|
||||||
Bind(wxEVT_CHOICE, &GamepadConfiguration::OnChoiceChange, this);
|
Bind(wxEVT_CHOICE, &GamepadConfiguration::OnChoiceChange, this);
|
||||||
|
|
||||||
repopulate();
|
repopulate();
|
||||||
|
|
||||||
|
SetSizerAndFit(gamepad_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,7 +75,7 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
/*
|
/*
|
||||||
* Check if there exist at least one pad available
|
* Check if there exist at least one pad available
|
||||||
* if the pad id is 0, you need at least 1 gamepad connected,
|
* if the pad id is 0, you need at least 1 gamepad connected,
|
||||||
* if the pad id is 1, you need at least 2 gamepad connected,
|
* if the pad id is 1, you need at least 2 gamepads connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if (s_vgamePad.size() >= m_pad_id + 1) {
|
if (s_vgamePad.size() >= m_pad_id + 1) {
|
||||||
|
@ -150,21 +99,9 @@ void GamepadConfiguration::InitGamepadConfiguration()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
void GamepadConfiguration::OnOk(wxCommandEvent &event)
|
||||||
/*********** Events functions ***********/
|
|
||||||
/****************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button event, called when a button is clicked
|
|
||||||
*/
|
|
||||||
void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
Destroy();
|
||||||
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
|
||||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
|
||||||
if (bt_id == m_bt_ok->GetId()) { // If the button ID is equals to the Ok button ID
|
|
||||||
Close(); // Close the window
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,28 +111,20 @@ void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||||
*/
|
*/
|
||||||
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxSlider *sl_tmp = (wxSlider *)event.GetEventObject(); // get the slider object
|
wxSlider *sl_tmp = (wxSlider *)event.GetEventObject();
|
||||||
int sl_id = sl_tmp->GetId(); // slider id
|
int sl_id = sl_tmp->GetId();
|
||||||
if (sl_id == m_sl_rumble_intensity->GetId()) { // if this is the rumble intensity slider
|
|
||||||
u32 intensity = m_sl_rumble_intensity->GetValue(); // get the new value
|
if (sl_id == rumble_slider_id)
|
||||||
g_conf.set_ff_intensity(intensity); // and set the force feedback intensity value with it
|
{
|
||||||
// get the rumble intensity
|
g_conf.set_ff_intensity(m_sl_rumble_intensity->GetValue());
|
||||||
float strength = m_sl_rumble_intensity->GetValue();
|
|
||||||
/*
|
// convert in a float value between 0 and 1, and run rumble feedback.
|
||||||
* convert in a float value between 0 and 1, and run rumble feedback
|
// 0 to 1 scales to 0x0 to 0x7FFF
|
||||||
* 1 -> 0x7FFF
|
s_vgamePad[m_pad_id]->TestForce(m_sl_rumble_intensity->GetValue() / 0x7FFF);
|
||||||
* 0 -> 0x0000
|
}
|
||||||
* x -> ?
|
else if (sl_id == joy_slider_id)
|
||||||
*
|
{
|
||||||
* formula : strength = x*1/0x7FFF
|
g_conf.set_sensibility(m_sl_joystick_sensibility->GetValue());
|
||||||
* x : intensity variable
|
|
||||||
* 0x7FFF : maximum intensity
|
|
||||||
* 1 : maximum value of the intensity for the sdl rumble test
|
|
||||||
*/
|
|
||||||
s_vgamePad[m_pad_id]->TestForce(strength / 0x7FFF);
|
|
||||||
} else if (sl_id == m_sl_joystick_sensibility->GetId()) {
|
|
||||||
u32 sensibility = m_sl_joystick_sensibility->GetValue(); // get the new value
|
|
||||||
g_conf.set_sensibility(sensibility); // and set the joystick sensibility
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,12 +135,17 @@ void GamepadConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
if (cb_id == m_cb_rumble->GetId()) {
|
|
||||||
|
if (cb_id == enable_rumble_id)
|
||||||
|
{
|
||||||
g_conf.pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue()) ? (u32)1 : (u32)0;
|
g_conf.pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue()) ? (u32)1 : (u32)0;
|
||||||
if (m_cb_rumble->GetValue()) {
|
if (m_cb_rumble->GetValue())
|
||||||
|
{
|
||||||
s_vgamePad[m_pad_id]->TestForce();
|
s_vgamePad[m_pad_id]->TestForce();
|
||||||
m_sl_rumble_intensity->Enable();
|
m_sl_rumble_intensity->Enable();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_sl_rumble_intensity->Disable();
|
m_sl_rumble_intensity->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,9 +158,9 @@ void GamepadConfiguration::OnChoiceChange(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxChoice *choice_tmp = (wxChoice *)event.GetEventObject();
|
wxChoice *choice_tmp = (wxChoice *)event.GetEventObject();
|
||||||
int id = choice_tmp->GetSelection();
|
int id = choice_tmp->GetSelection();
|
||||||
if (id != wxNOT_FOUND) {
|
if (id != wxNOT_FOUND)
|
||||||
size_t uid = GamePad::index_to_uid(id);
|
{
|
||||||
g_conf.set_joy_uid(m_pad_id, uid);
|
g_conf.set_joy_uid(m_pad_id, GamePad::index_to_uid(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,22 +171,15 @@ void GamepadConfiguration::OnChoiceChange(wxCommandEvent &event)
|
||||||
// Set button values
|
// Set button values
|
||||||
void GamepadConfiguration::repopulate()
|
void GamepadConfiguration::repopulate()
|
||||||
{
|
{
|
||||||
bool val = g_conf.pad_options[m_pad_id].forcefeedback;
|
m_cb_rumble->SetValue(g_conf.pad_options[m_pad_id].forcefeedback);
|
||||||
m_cb_rumble->SetValue(val);
|
|
||||||
|
|
||||||
int tmp = g_conf.get_ff_intensity();
|
m_sl_rumble_intensity->SetValue(g_conf.get_ff_intensity());
|
||||||
m_sl_rumble_intensity->SetValue(tmp);
|
m_sl_joystick_sensibility->SetValue(g_conf.get_sensibility());
|
||||||
|
|
||||||
tmp = g_conf.get_sensibility();
|
|
||||||
m_sl_joystick_sensibility->SetValue(tmp);
|
|
||||||
|
|
||||||
u32 joyid = GamePad::uid_to_index(m_pad_id);
|
u32 joyid = GamePad::uid_to_index(m_pad_id);
|
||||||
if (joyid < m_joy_map->GetCount() && !m_joy_map->IsEmpty())
|
if (joyid < m_joy_map->GetCount() && !m_joy_map->IsEmpty())
|
||||||
m_joy_map->SetSelection(joyid);
|
m_joy_map->SetSelection(joyid);
|
||||||
|
|
||||||
// enable rumble intensity slider if the checkbox is checked
|
// enable rumble intensity slider if the checkbox is checked
|
||||||
if (m_cb_rumble->GetValue())
|
m_sl_rumble_intensity->Enable(m_cb_rumble->GetValue());
|
||||||
m_sl_rumble_intensity->Enable();
|
|
||||||
else // disable otherwise
|
|
||||||
m_sl_rumble_intensity->Disable();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,31 +23,28 @@
|
||||||
#define __GAMEPADCONFIGURATION_H__
|
#define __GAMEPADCONFIGURATION_H__
|
||||||
|
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include <wx/frame.h>
|
|
||||||
#include <wx/window.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/checkbox.h>
|
|
||||||
#include <wx/slider.h>
|
|
||||||
|
|
||||||
#include "../GamePad.h"
|
#include "../GamePad.h"
|
||||||
#include "../keyboard.h"
|
#include "../keyboard.h"
|
||||||
#include "../onepad.h"
|
#include "../onepad.h"
|
||||||
|
|
||||||
|
static const s32 rumble_slider_id = wxID_HIGHEST + 200 + 1;
|
||||||
|
static const s32 joy_slider_id = wxID_HIGHEST + 200 + 2;
|
||||||
|
static const s32 enable_rumble_id = wxID_HIGHEST + 200 + 3;
|
||||||
|
|
||||||
class GamepadConfiguration : public wxDialog
|
class GamepadConfiguration : public wxDialog
|
||||||
{
|
{
|
||||||
wxPanel *m_pan_gamepad_config;
|
|
||||||
wxCheckBox *m_cb_rumble;
|
wxCheckBox *m_cb_rumble;
|
||||||
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
|
||||||
wxButton *m_bt_ok;
|
|
||||||
wxStaticText *m_lbl_rumble_intensity;
|
|
||||||
wxChoice *m_joy_map;
|
wxChoice *m_joy_map;
|
||||||
|
|
||||||
u32 m_pad_id;
|
u32 m_pad_id;
|
||||||
|
|
||||||
// methods
|
// Methods
|
||||||
void repopulate();
|
void repopulate();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent &);
|
void OnOk(wxCommandEvent &);
|
||||||
void OnSliderReleased(wxCommandEvent &);
|
void OnSliderReleased(wxCommandEvent &);
|
||||||
void OnCheckboxChange(wxCommandEvent &);
|
void OnCheckboxChange(wxCommandEvent &);
|
||||||
void OnChoiceChange(wxCommandEvent &);
|
void OnChoiceChange(wxCommandEvent &);
|
||||||
|
|
|
@ -19,106 +19,53 @@
|
||||||
|
|
||||||
#include "JoystickConfiguration.h"
|
#include "JoystickConfiguration.h"
|
||||||
|
|
||||||
// Construtor of JoystickConfiguration
|
// Constructor of JoystickConfiguration
|
||||||
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent)
|
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent)
|
||||||
: wxDialog(
|
: wxDialog(parent, wxID_ANY, _T("Joystick configuration"), wxDefaultPosition, wxDefaultSize,
|
||||||
parent, // Parent
|
wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("Gamepad configuration"), // Title
|
|
||||||
wxDefaultPosition, // Position
|
|
||||||
wxSize(400, 200), // Width + Lenght
|
|
||||||
// Style
|
|
||||||
wxSYSTEM_MENU |
|
|
||||||
wxCAPTION |
|
|
||||||
wxCLOSE_BOX |
|
|
||||||
wxCLIP_CHILDREN)
|
|
||||||
{
|
{
|
||||||
m_init_reverse_Lx = false;
|
m_init_reverse_Lx = m_init_reverse_Ly =
|
||||||
m_init_reverse_Ly = false;
|
m_init_reverse_Rx = m_init_reverse_Ry =
|
||||||
m_init_reverse_Rx = false;
|
m_init_mouse_Ljoy = m_init_mouse_Rjoy = false;
|
||||||
m_init_reverse_Ry = false;
|
|
||||||
m_init_mouse_Ljoy = false;
|
|
||||||
m_init_mouse_Rjoy = false;
|
|
||||||
|
|
||||||
m_pad_id = pad;
|
m_pad_id = pad;
|
||||||
m_isForLeftJoystick = left;
|
m_isForLeftJoystick = left;
|
||||||
m_pan_joystick_config = new wxPanel(
|
|
||||||
this, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
wxDefaultPosition, // Prosition
|
|
||||||
wxSize(300, 200) // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
if (m_isForLeftJoystick) {
|
wxBoxSizer *joy_conf_box = new wxBoxSizer(wxVERTICAL);
|
||||||
m_cb_reverse_Lx = new wxCheckBox(
|
|
||||||
m_pan_joystick_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("Reverse Lx"), // Label
|
|
||||||
wxPoint(20, 20) // Position
|
|
||||||
);
|
|
||||||
|
|
||||||
m_cb_reverse_Ly = new wxCheckBox(
|
if (m_isForLeftJoystick)
|
||||||
m_pan_joystick_config, // Parent
|
{
|
||||||
wxID_ANY, // ID
|
m_cb_reverse_Lx = new wxCheckBox(this, Lx_check_id, _T("Reverse Lx"));
|
||||||
_T("Reverse Ly"), // Label
|
m_cb_reverse_Ly = new wxCheckBox(this, Ly_check_id, _T("Reverse Ly"));
|
||||||
wxPoint(20, 40) // Position
|
m_cb_mouse_Ljoy = new wxCheckBox(this, Ljoy_check_id, _T("Use mouse for left analog joystick"));
|
||||||
);
|
|
||||||
|
|
||||||
m_cb_mouse_Ljoy = new wxCheckBox(
|
joy_conf_box->Add(m_cb_reverse_Lx, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
m_pan_joystick_config, // Parent
|
joy_conf_box->Add(m_cb_reverse_Ly, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
wxID_ANY, // ID
|
joy_conf_box->Add(m_cb_mouse_Ljoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
_T("Use mouse for left analog joystick"), // Label
|
|
||||||
wxPoint(20, 60) // Position
|
|
||||||
);
|
|
||||||
|
|
||||||
m_cb_reverse_Rx = nullptr;
|
m_cb_reverse_Rx = m_cb_reverse_Ry = m_cb_mouse_Rjoy = nullptr;
|
||||||
m_cb_reverse_Ry = nullptr;
|
|
||||||
m_cb_mouse_Rjoy = nullptr;
|
|
||||||
} else {
|
|
||||||
m_cb_reverse_Rx = new wxCheckBox(
|
|
||||||
m_pan_joystick_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("Reverse Rx"), // Label
|
|
||||||
wxPoint(20, 20) // Position
|
|
||||||
);
|
|
||||||
|
|
||||||
m_cb_reverse_Ry = new wxCheckBox(
|
}
|
||||||
m_pan_joystick_config, // Parent
|
else
|
||||||
wxID_ANY, // ID
|
{
|
||||||
_T("Reverse Ry"), // Label
|
m_cb_reverse_Rx = new wxCheckBox(this, Rx_check_id, _T("Reverse Rx"));
|
||||||
wxPoint(20, 40) // Position
|
m_cb_reverse_Ry = new wxCheckBox(this, Ry_check_id, _T("Reverse Ry"));
|
||||||
);
|
m_cb_mouse_Rjoy = new wxCheckBox(this, Rjoy_check_id, _T("Use mouse for right analog joystick"));
|
||||||
|
|
||||||
m_cb_mouse_Rjoy = new wxCheckBox(
|
joy_conf_box->Add(m_cb_reverse_Rx, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
m_pan_joystick_config, // Parent
|
joy_conf_box->Add(m_cb_reverse_Ry, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
wxID_ANY, // ID
|
joy_conf_box->Add(m_cb_mouse_Rjoy, wxSizerFlags().Expand().Border(wxLEFT | wxRIGHT, 5));
|
||||||
_T("Use mouse for right analog joystick"), // Label
|
|
||||||
wxPoint(20, 60) // Position
|
|
||||||
);
|
|
||||||
|
|
||||||
m_cb_reverse_Lx = nullptr;
|
m_cb_reverse_Lx = m_cb_reverse_Ly = m_cb_mouse_Ljoy = nullptr;
|
||||||
m_cb_reverse_Ly = nullptr;
|
|
||||||
m_cb_mouse_Ljoy = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bt_ok = new wxButton(
|
joy_conf_box->Add(CreateSeparatedButtonSizer(wxOK | wxCANCEL), wxSizerFlags().Border(wxALL, 5).Right());
|
||||||
m_pan_joystick_config, // Parent
|
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("&OK"), // Label
|
|
||||||
wxPoint(250, 130), // Position
|
|
||||||
wxSize(60, 25) // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
m_bt_cancel = new wxButton(
|
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnOk, this, wxID_OK);
|
||||||
m_pan_joystick_config, // Parent
|
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnCancel, this, wxID_CANCEL);
|
||||||
wxID_ANY, // ID
|
|
||||||
_T("&Cancel"), // Label
|
|
||||||
wxPoint(320, 130), // Position
|
|
||||||
wxSize(60, 25) // Size
|
|
||||||
);
|
|
||||||
|
|
||||||
Bind(wxEVT_BUTTON, &JoystickConfiguration::OnButtonClicked, this);
|
|
||||||
Bind(wxEVT_CHECKBOX, &JoystickConfiguration::OnCheckboxChange, this);
|
Bind(wxEVT_CHECKBOX, &JoystickConfiguration::OnCheckboxChange, this);
|
||||||
|
|
||||||
|
SetSizerAndFit(joy_conf_box);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,7 +78,7 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
/*
|
/*
|
||||||
* Check if there exist at least one pad available
|
* Check if there exist at least one pad available
|
||||||
* if the pad id is 0, you need at least 1 gamepad connected,
|
* if the pad id is 0, you need at least 1 gamepad connected,
|
||||||
* if the pad id is 1, you need at least 2 gamepad connected,
|
* if the pad id is 1, you need at least 2 gamepads connected,
|
||||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||||
*/
|
*/
|
||||||
if (s_vgamePad.size() < m_pad_id + 1) {
|
if (s_vgamePad.size() < m_pad_id + 1) {
|
||||||
|
@ -140,35 +87,29 @@ void JoystickConfiguration::InitJoystickConfiguration()
|
||||||
else
|
else
|
||||||
wxMessageBox(L"No second gamepad detected.");
|
wxMessageBox(L"No second gamepad detected.");
|
||||||
|
|
||||||
// disable all checkbox
|
// disable all checkboxes
|
||||||
if (m_isForLeftJoystick) {
|
if (m_isForLeftJoystick)
|
||||||
|
{
|
||||||
m_cb_reverse_Lx->Disable();
|
m_cb_reverse_Lx->Disable();
|
||||||
m_cb_reverse_Ly->Disable();
|
m_cb_reverse_Ly->Disable();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_cb_reverse_Rx->Disable();
|
m_cb_reverse_Rx->Disable();
|
||||||
m_cb_reverse_Ry->Disable();
|
m_cb_reverse_Ry->Disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************/
|
void JoystickConfiguration::OnOk(wxCommandEvent &event)
|
||||||
/*********** Events functions ***********/
|
|
||||||
/****************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button event, called when a button is clicked
|
|
||||||
*/
|
|
||||||
void JoystickConfiguration::OnButtonClicked(wxCommandEvent &event)
|
|
||||||
{
|
{
|
||||||
// Affichage d'un message à chaque clic sur le bouton
|
Destroy();
|
||||||
wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
|
}
|
||||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
|
||||||
if (bt_id == m_bt_ok->GetId()) { // If the button ID is equals to the Ok button ID
|
void JoystickConfiguration::OnCancel(wxCommandEvent &event)
|
||||||
Close(); // Close the window
|
{
|
||||||
} else if (bt_id == m_bt_cancel->GetId()) { // If the button ID is equals to the cancel button ID
|
reset();
|
||||||
reset(); // reinitialize the value of each parameters
|
Destroy();
|
||||||
Close(); // Close the window
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,28 +119,45 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
wxCheckBox *cb_tmp = (wxCheckBox *)event.GetEventObject(); // get the slider object
|
||||||
int cb_id = cb_tmp->GetId();
|
int cb_id = cb_tmp->GetId();
|
||||||
bool val;
|
|
||||||
if (m_isForLeftJoystick) {
|
if (m_isForLeftJoystick)
|
||||||
if (cb_id == m_cb_reverse_Ly->GetId()) {
|
{
|
||||||
val = m_cb_reverse_Ly->GetValue();
|
switch (cb_id)
|
||||||
g_conf.pad_options[m_pad_id].reverse_ly = val;
|
{
|
||||||
} else if (cb_id == m_cb_reverse_Lx->GetId()) {
|
case Lx_check_id:
|
||||||
val = m_cb_reverse_Lx->GetValue();
|
g_conf.pad_options[m_pad_id].reverse_lx = m_cb_reverse_Lx->GetValue();
|
||||||
g_conf.pad_options[m_pad_id].reverse_lx = val;
|
break;
|
||||||
} else if (cb_id == m_cb_mouse_Ljoy->GetId()) {
|
|
||||||
val = m_cb_mouse_Ljoy->GetValue();
|
case Ly_check_id:
|
||||||
g_conf.pad_options[m_pad_id].mouse_l = val;
|
g_conf.pad_options[m_pad_id].reverse_ly = m_cb_reverse_Ly->GetValue();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Ljoy_check_id:
|
||||||
|
g_conf.pad_options[m_pad_id].mouse_l = m_cb_mouse_Ljoy->GetValue();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (cb_id == m_cb_reverse_Ry->GetId()) {
|
else
|
||||||
val = m_cb_reverse_Ry->GetValue();
|
{
|
||||||
g_conf.pad_options[m_pad_id].reverse_ry = val;
|
switch (cb_id)
|
||||||
} else if (cb_id == m_cb_reverse_Rx->GetId()) {
|
{
|
||||||
val = m_cb_reverse_Rx->GetValue();
|
case Rx_check_id:
|
||||||
g_conf.pad_options[m_pad_id].reverse_rx = val;
|
g_conf.pad_options[m_pad_id].reverse_rx = m_cb_reverse_Rx->GetValue();
|
||||||
} else if (cb_id == m_cb_mouse_Rjoy->GetId()) {
|
break;
|
||||||
val = m_cb_mouse_Rjoy->GetValue();
|
|
||||||
g_conf.pad_options[m_pad_id].mouse_r = val;
|
case Ry_check_id:
|
||||||
|
g_conf.pad_options[m_pad_id].reverse_ry = m_cb_reverse_Ry->GetValue();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Rjoy_check_id:
|
||||||
|
g_conf.pad_options[m_pad_id].mouse_r = m_cb_mouse_Rjoy->GetValue();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,11 +169,14 @@ void JoystickConfiguration::OnCheckboxChange(wxCommandEvent &event)
|
||||||
// Reset checkbox and slider values
|
// Reset checkbox and slider values
|
||||||
void JoystickConfiguration::reset()
|
void JoystickConfiguration::reset()
|
||||||
{
|
{
|
||||||
if (m_isForLeftJoystick) {
|
if (m_isForLeftJoystick)
|
||||||
|
{
|
||||||
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
||||||
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
||||||
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
||||||
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
||||||
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
||||||
|
@ -225,30 +186,26 @@ void JoystickConfiguration::reset()
|
||||||
// Set button values
|
// Set button values
|
||||||
void JoystickConfiguration::repopulate()
|
void JoystickConfiguration::repopulate()
|
||||||
{
|
{
|
||||||
bool val;
|
if (m_isForLeftJoystick)
|
||||||
if (m_isForLeftJoystick) {
|
{
|
||||||
val = g_conf.pad_options[m_pad_id].reverse_lx;
|
m_init_reverse_Lx = g_conf.pad_options[m_pad_id].reverse_lx;
|
||||||
m_init_reverse_Lx = val;
|
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
|
||||||
m_cb_reverse_Lx->SetValue(val);
|
|
||||||
|
|
||||||
val = g_conf.pad_options[m_pad_id].reverse_ly;
|
m_init_reverse_Ly = g_conf.pad_options[m_pad_id].reverse_ly;
|
||||||
m_init_reverse_Ly = val;
|
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
|
||||||
m_cb_reverse_Ly->SetValue(val);
|
|
||||||
|
|
||||||
val = g_conf.pad_options[m_pad_id].mouse_l;
|
m_init_mouse_Ljoy = g_conf.pad_options[m_pad_id].mouse_l;
|
||||||
m_init_mouse_Ljoy = val;
|
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
|
||||||
m_cb_mouse_Ljoy->SetValue(val);
|
}
|
||||||
} else {
|
else
|
||||||
val = g_conf.pad_options[m_pad_id].reverse_rx;
|
{
|
||||||
m_init_reverse_Rx = val;
|
m_init_reverse_Rx = g_conf.pad_options[m_pad_id].reverse_rx;
|
||||||
m_cb_reverse_Rx->SetValue(val);
|
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
|
||||||
|
|
||||||
val = g_conf.pad_options[m_pad_id].reverse_ry;
|
m_init_reverse_Ry = g_conf.pad_options[m_pad_id].reverse_ry;
|
||||||
m_init_reverse_Ry = val;
|
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
|
||||||
m_cb_reverse_Ry->SetValue(val);
|
|
||||||
|
|
||||||
val = g_conf.pad_options[m_pad_id].mouse_r;
|
m_init_mouse_Rjoy = g_conf.pad_options[m_pad_id].mouse_r;
|
||||||
m_init_mouse_Rjoy = val;
|
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
|
||||||
m_cb_mouse_Rjoy->SetValue(val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,19 +23,21 @@
|
||||||
#define __JOYSTICKCONFIGURATION_H__
|
#define __JOYSTICKCONFIGURATION_H__
|
||||||
|
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
#include <wx/frame.h>
|
|
||||||
#include <wx/window.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/checkbox.h>
|
|
||||||
#include <wx/slider.h>
|
|
||||||
|
|
||||||
#include "../GamePad.h"
|
#include "../GamePad.h"
|
||||||
#include "../keyboard.h"
|
#include "../keyboard.h"
|
||||||
#include "../onepad.h"
|
#include "../onepad.h"
|
||||||
|
|
||||||
|
static const s32 Lx_check_id = wxID_HIGHEST + 100 + 1;
|
||||||
|
static const s32 Ly_check_id = wxID_HIGHEST + 100 + 2;
|
||||||
|
static const s32 Ljoy_check_id = wxID_HIGHEST + 100 + 3;
|
||||||
|
|
||||||
|
static const s32 Rx_check_id = wxID_HIGHEST + 100 + 4;
|
||||||
|
static const s32 Ry_check_id = wxID_HIGHEST + 100 + 5;
|
||||||
|
static const s32 Rjoy_check_id = wxID_HIGHEST + 100 + 6;
|
||||||
|
|
||||||
class JoystickConfiguration : public wxDialog
|
class JoystickConfiguration : public wxDialog
|
||||||
{
|
{
|
||||||
wxPanel *m_pan_joystick_config;
|
|
||||||
wxCheckBox *m_cb_reverse_Lx, *m_cb_reverse_Ly, *m_cb_reverse_Rx, *m_cb_reverse_Ry,
|
wxCheckBox *m_cb_reverse_Lx, *m_cb_reverse_Ly, *m_cb_reverse_Rx, *m_cb_reverse_Ry,
|
||||||
*m_cb_mouse_Ljoy, // Use mouse for left joystick
|
*m_cb_mouse_Ljoy, // Use mouse for left joystick
|
||||||
*m_cb_mouse_Rjoy; // Use mouse for right joystick
|
*m_cb_mouse_Rjoy; // Use mouse for right joystick
|
||||||
|
@ -46,12 +48,14 @@ class JoystickConfiguration : public wxDialog
|
||||||
bool m_init_reverse_Lx, m_init_reverse_Ly, m_init_reverse_Rx, m_init_reverse_Ry,
|
bool m_init_reverse_Lx, m_init_reverse_Ly, m_init_reverse_Rx, m_init_reverse_Ry,
|
||||||
m_init_mouse_Ljoy, m_init_mouse_Rjoy, m_isForLeftJoystick;
|
m_init_mouse_Ljoy, m_init_mouse_Rjoy, m_isForLeftJoystick;
|
||||||
|
|
||||||
// methods
|
// Methods
|
||||||
void repopulate();
|
void repopulate();
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
// Events
|
// Events
|
||||||
void OnButtonClicked(wxCommandEvent &);
|
|
||||||
void OnCheckboxChange(wxCommandEvent &);
|
void OnCheckboxChange(wxCommandEvent &);
|
||||||
|
void OnOk(wxCommandEvent &);
|
||||||
|
void OnCancel(wxCommandEvent &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JoystickConfiguration(int, bool, wxWindow *);
|
JoystickConfiguration(int, bool, wxWindow *);
|
||||||
|
|
|
@ -25,13 +25,13 @@
|
||||||
#include "state_management.h"
|
#include "state_management.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "linux.h"
|
#include "linux.h"
|
||||||
|
#include <wx/wx.h>
|
||||||
|
|
||||||
Display *GSdsp;
|
Display *GSdsp;
|
||||||
Window GSwin;
|
Window GSwin;
|
||||||
|
|
||||||
void SysMessage(const char *fmt, ...)
|
static void SysMessage(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list list;
|
va_list list;
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
@ -43,16 +43,11 @@ void SysMessage(const char *fmt, ...)
|
||||||
if (msg[strlen(msg) - 1] == '\n')
|
if (msg[strlen(msg) - 1] == '\n')
|
||||||
msg[strlen(msg) - 1] = 0;
|
msg[strlen(msg) - 1] = 0;
|
||||||
|
|
||||||
GtkWidget *dialog;
|
wxMessageDialog dialog(nullptr, msg, "Info", wxOK);
|
||||||
dialog = gtk_message_dialog_new(NULL,
|
dialog.ShowModal();
|
||||||
GTK_DIALOG_DESTROY_WITH_PARENT,
|
|
||||||
GTK_MESSAGE_INFO,
|
|
||||||
GTK_BUTTONS_OK,
|
|
||||||
"%s", msg);
|
|
||||||
gtk_dialog_run(GTK_DIALOG(dialog));
|
|
||||||
gtk_widget_destroy(dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EXPORT_C_(void) PADabout()
|
EXPORT_C_(void) PADabout()
|
||||||
{
|
{
|
||||||
SysMessage("OnePad is a rewrite of Zerofrog's ZeroPad, done by arcum42.");
|
SysMessage("OnePad is a rewrite of Zerofrog's ZeroPad, done by arcum42.");
|
||||||
|
|
Loading…
Reference in New Issue