mirror of https://github.com/PCSX2/pcsx2.git
OnePad : New GUI based on gwWidget
Buttons done, configuration initialization done. Still need to add Gamepad and Joysticks configuration frames. Require png file for the moment (the embedded picture will be fixed after). New Onepad GUI based on wxWidget (Main frame almost finish) Background picture is now embedded Button binding works Loading and saving works Need to add feedback and gamepad, joysticks configuration frame Modification of the onepad CMakeList.txt Automatic generation of images headers using perl script Modification of the test feedback function
This commit is contained in:
parent
5b287deca2
commit
823a37aed7
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "MSWstuff.h"
|
||||
|
||||
#include "Resources/EmbeddedImage.h"
|
||||
#include "Utilities/EmbeddedImage.h"
|
||||
#include "Resources/BackgroundLogo.h"
|
||||
#include "Resources/ButtonIcon_Camera.h"
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "Dialogs/ModalPopups.h"
|
||||
|
||||
#include "Resources/EmbeddedImage.h"
|
||||
#include "Utilities/EmbeddedImage.h"
|
||||
#include "Resources/Logo.h"
|
||||
|
||||
#include <wx/mstream.h>
|
||||
|
|
|
@ -5,9 +5,36 @@ if(NOT TOP_CMAKE_WAS_SOURCED)
|
|||
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
|
||||
endif()
|
||||
|
||||
set(compiled_images "${CMAKE_BINARY_DIR}/plugins/onepad/ImgHeader")
|
||||
set(image_sources "${CMAKE_SOURCE_DIR}/plugins/onepad/Img")
|
||||
set(linux_sources "Linux")
|
||||
set(linux_headers "Linux")
|
||||
|
||||
|
||||
set(onepadGuiResources
|
||||
${compiled_images}/analog.h
|
||||
${compiled_images}/circle.h
|
||||
${compiled_images}/cross.h
|
||||
${compiled_images}/dp_bottom.h
|
||||
${compiled_images}/dp_left.h
|
||||
${compiled_images}/dp_right.h
|
||||
${compiled_images}/dp_up.h
|
||||
${compiled_images}/dualshock2.h
|
||||
${compiled_images}/joystick_cursor.h
|
||||
${compiled_images}/l1.h
|
||||
${compiled_images}/r1.h
|
||||
${compiled_images}/l2.h
|
||||
${compiled_images}/r2.h
|
||||
${compiled_images}/l3.h
|
||||
${compiled_images}/r3.h
|
||||
${compiled_images}/select.h
|
||||
${compiled_images}/square.h
|
||||
${compiled_images}/start.h
|
||||
${compiled_images}/triangle.h
|
||||
)
|
||||
|
||||
# plugin name
|
||||
set(Output onepad-1.1.0)
|
||||
set(Output onepad-1.2.0)
|
||||
set(onepadFinalFlags "")
|
||||
|
||||
# onepad sources
|
||||
|
@ -31,13 +58,19 @@ set(onepadHeaders
|
|||
|
||||
# onepad Linux sources
|
||||
set(onepadLinuxSources
|
||||
Linux/ini.cpp
|
||||
Linux/dialog.cpp
|
||||
Linux/linux.cpp)
|
||||
${linux_sources}/ini.cpp
|
||||
${linux_sources}/dialog.cpp
|
||||
${linux_sources}/linux.cpp
|
||||
${linux_sources}/opPanel.cpp
|
||||
${linux_sources}/GamepadConfiguration.cpp
|
||||
${linux_headers}/JoystickConfiguration.cpp)
|
||||
|
||||
# onepad Linux headers
|
||||
set(onepadLinuxHeaders
|
||||
Linux/linux.h)
|
||||
${linux_headers}/linux.h
|
||||
${linux_headers}/opPanel.h
|
||||
${linux_headers}/GamepadConfiguration.h
|
||||
${linux_headers}/JoystickConfiguration.h)
|
||||
|
||||
# onepad Windows sources
|
||||
set(onepadWindowsSources
|
||||
|
@ -70,6 +103,22 @@ set(onepadFinalSources
|
|||
${onepadHeaders}
|
||||
${onepadLinuxSources}
|
||||
${onepadLinuxHeaders}
|
||||
${onepadGuiResources}
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}/plugins/onepad/
|
||||
)
|
||||
|
||||
### Generate the resources files
|
||||
file(MAKE_DIRECTORY ${compiled_images})
|
||||
|
||||
foreach(result_file IN ITEMS
|
||||
analog circle cross dp_bottom dp_left dp_right dp_up dualshock2
|
||||
joystick_cursor l1 r1 l2 r2 l3 r3 select square start triangle)
|
||||
add_custom_command(
|
||||
OUTPUT "${compiled_images}/${result_file}.h"
|
||||
COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/hex2h.pl "${image_sources}/${result_file}.png" "${compiled_images}/${result_file}" )
|
||||
endforeach()
|
||||
|
||||
add_pcsx2_plugin(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}")
|
||||
|
|
|
@ -38,7 +38,7 @@ class GamePad
|
|||
**/
|
||||
static void UpdateGamePadState();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Causes devices to rumble
|
||||
* Rumble will differ according to type which is either 0(small motor) or 1(big motor)
|
||||
**/
|
||||
|
@ -53,7 +53,7 @@ class GamePad
|
|||
/**
|
||||
* Used for GUI checkbox to give feedback to the user
|
||||
**/
|
||||
virtual void TestForce(){return;}
|
||||
virtual bool TestForce(float strength = 0.6){return false;}
|
||||
|
||||
virtual bool PollButtons(u32 &pkey){return false;}
|
||||
virtual bool PollAxes(u32 &pkey){return false;}
|
||||
|
|
|
@ -0,0 +1,284 @@
|
|||
/* OnePAD
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "GamepadConfiguration.h"
|
||||
|
||||
// Construtor of GamepadConfiguration
|
||||
GamepadConfiguration::GamepadConfiguration(int pad, wxWindow *parent) : wxFrame(
|
||||
parent, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Gamepad configuration"), // Title
|
||||
wxDefaultPosition, // Position
|
||||
wxSize(400, 200), // Width + Lenght
|
||||
// Style
|
||||
wxSYSTEM_MENU |
|
||||
wxCAPTION |
|
||||
wxCLOSE_BOX |
|
||||
wxCLIP_CHILDREN
|
||||
)
|
||||
{
|
||||
|
||||
this->pad_id = pad;
|
||||
this->pan_gamepad_config = new wxPanel(
|
||||
this, // Parent
|
||||
wxID_ANY, // ID
|
||||
wxDefaultPosition, // Prosition
|
||||
wxSize(300, 200) // Size
|
||||
);
|
||||
this->cb_rumble = new wxCheckBox(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&Enable rumble"), // Label
|
||||
wxPoint(20, 20) // Position
|
||||
);
|
||||
|
||||
this->cb_hack_sixaxis = new wxCheckBox(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&Hack Sixaxis/DS3 plugged in USB"), // Label
|
||||
wxPoint(20, 40) // Position
|
||||
);
|
||||
|
||||
wxString txt_rumble = wxT("Rumble intensity");
|
||||
this->lbl_rumble_intensity = new wxStaticText(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
txt_rumble, // Text which must be displayed
|
||||
wxPoint(20, 70), // Position
|
||||
wxDefaultSize // Size
|
||||
);
|
||||
|
||||
this->sl_rumble_intensity = new wxSlider(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
0, // value
|
||||
0, // min value 0x0000
|
||||
0x7FFF, // max value 0x7FFF
|
||||
wxPoint(150, 63), // Position
|
||||
wxSize(200, 30) // Size
|
||||
);
|
||||
|
||||
wxString txt_joystick = wxT("Joystick sensibility");
|
||||
this->lbl_rumble_intensity = new wxStaticText(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
txt_joystick, // Text which must be displayed
|
||||
wxPoint(20, 100), // Position
|
||||
wxDefaultSize // Size
|
||||
);
|
||||
|
||||
this->sl_joystick_sensibility = new wxSlider(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
0, // value
|
||||
0, // min value
|
||||
100, // max value
|
||||
wxPoint(150, 93), // Position
|
||||
wxSize(200, 30) // Size
|
||||
);
|
||||
|
||||
this->bt_ok = new wxButton(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&OK"), // Label
|
||||
wxPoint(250, 130), // Position
|
||||
wxSize(60,25) // Size
|
||||
);
|
||||
|
||||
this->bt_cancel = new wxButton(
|
||||
this->pan_gamepad_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&Cancel"), // Label
|
||||
wxPoint(320, 130), // Position
|
||||
wxSize(60,25) // Size
|
||||
);
|
||||
|
||||
// Connect the buttons to the OnButtonClicked Event
|
||||
this->Connect(
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler(GamepadConfiguration::OnButtonClicked)
|
||||
);
|
||||
// Connect the sliders to the OnSliderReleased Event
|
||||
this->Connect(
|
||||
wxEVT_SCROLL_THUMBRELEASE,
|
||||
wxCommandEventHandler(GamepadConfiguration::OnSliderReleased)
|
||||
);
|
||||
// Connect the checkboxes to the OnCheckboxClicked Event
|
||||
this->Connect(
|
||||
wxEVT_CHECKBOX,
|
||||
wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize the frame
|
||||
Check if a gamepad is detected
|
||||
Check if the gamepad support rumbles
|
||||
*/
|
||||
void GamepadConfiguration::InitGamepadConfiguration()
|
||||
{
|
||||
this->repopulate(); // Set label and fit simulated key array
|
||||
/*
|
||||
* 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 1, you need at least 2 gamepad connected,
|
||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||
*/
|
||||
if(s_vgamePad.size() >= this->pad_id+1)
|
||||
{
|
||||
/*
|
||||
* Determine if the device can use rumble
|
||||
* Use TestForce with a very low strength (can't be felt)
|
||||
* May be better to create a new function in order to check only that
|
||||
*/
|
||||
|
||||
if(!s_vgamePad[this->pad_id]->TestForce(0.001f))
|
||||
{
|
||||
wxMessageBox("Rumble is not available for your device.");
|
||||
this->cb_rumble->Disable(); // disable the rumble checkbox
|
||||
this->sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxMessageBox("No gamepad detected.");
|
||||
this->sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
|
||||
this->cb_rumble->Disable(); // disable the rumble checkbox
|
||||
this->sl_rumble_intensity->Disable(); // disable the rumble intensity slider
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/*********** Events functions ***********/
|
||||
/****************************************/
|
||||
|
||||
/**
|
||||
* Button event, called when a button is clicked
|
||||
*/
|
||||
void GamepadConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||
{
|
||||
// Affichage d'un message à chaque clic sur le bouton
|
||||
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
||||
if(bt_id == this->bt_ok->GetId()) // If the button ID is equals to the Ok button ID
|
||||
{
|
||||
this->Close(); // Close the window
|
||||
}
|
||||
else if(bt_id == this->bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
|
||||
{
|
||||
this->reset(); // reinitialize the value of each parameters
|
||||
this->Close(); // Close the window
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Slider event, called when the use release the slider button
|
||||
* @FIXME The current solution can't change the joystick sensibility and the rumble intensity
|
||||
* for a specific gamepad. The same value is used for both
|
||||
*/
|
||||
void GamepadConfiguration::OnSliderReleased(wxCommandEvent &event)
|
||||
{
|
||||
wxSlider* sl_tmp = (wxSlider*)event.GetEventObject(); // get the slider object
|
||||
int sl_id = sl_tmp->GetId(); // slider id
|
||||
if(sl_id == this->sl_rumble_intensity->GetId()) // if this is the rumble intensity slider
|
||||
{
|
||||
u32 intensity = this->sl_rumble_intensity->GetValue(); // get the new value
|
||||
conf->set_ff_intensity(intensity); // and set the force feedback intensity value with it
|
||||
// get the rumble intensity
|
||||
float strength = this->sl_rumble_intensity->GetValue();
|
||||
/*
|
||||
* convert in a float value between 0 and 1, and run rumble feedback
|
||||
* 1 -> 0x7FFF
|
||||
* 0 -> 0x0000
|
||||
* x -> ?
|
||||
*
|
||||
* formula : strength = x*1/0x7FFF
|
||||
* x : intensity variable
|
||||
* 0x7FFF : maximum intensity
|
||||
* 1 : maximum value of the intensity for the sdl rumble test
|
||||
*/
|
||||
s_vgamePad[this->pad_id]->TestForce(strength/0x7FFF);
|
||||
}
|
||||
else if(sl_id == this->sl_joystick_sensibility->GetId())
|
||||
{
|
||||
u32 sensibility = this->sl_joystick_sensibility->GetValue(); // get the new value
|
||||
conf->set_sensibility(sensibility); // and set the joystick sensibility
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkbox event, called when the value of the checkbox change
|
||||
*/
|
||||
void GamepadConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
||||
{
|
||||
wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object
|
||||
int cb_id = cb_tmp->GetId();
|
||||
if(cb_id == this->cb_rumble->GetId())
|
||||
{
|
||||
conf->pad_options[this->pad_id].forcefeedback = (this->cb_rumble->GetValue())?(u32)1:(u32)0;
|
||||
if(this->cb_rumble->GetValue())
|
||||
{
|
||||
s_vgamePad[this->pad_id]->TestForce();
|
||||
this->sl_rumble_intensity->Enable();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->sl_rumble_intensity->Disable();
|
||||
}
|
||||
}
|
||||
else if(cb_id == this->cb_hack_sixaxis->GetId())
|
||||
{
|
||||
conf->pad_options[this->pad_id].sixaxis_usb = (this->cb_hack_sixaxis->GetValue())?(u32)1:(u32)0;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/*********** Methods functions **********/
|
||||
/****************************************/
|
||||
|
||||
// Reset checkbox and slider values
|
||||
void GamepadConfiguration::reset()
|
||||
{
|
||||
this->cb_rumble->SetValue(this->init_rumble);
|
||||
this->cb_hack_sixaxis->SetValue(this->init_hack_sixaxis);
|
||||
this->sl_rumble_intensity->SetValue(this->init_rumble_intensity);
|
||||
this->sl_joystick_sensibility->SetValue(this->init_joystick_sensibility);
|
||||
}
|
||||
|
||||
// Set button values
|
||||
void GamepadConfiguration::repopulate()
|
||||
{
|
||||
bool val = conf->pad_options[this->pad_id].forcefeedback;
|
||||
this->init_rumble = val;
|
||||
this->cb_rumble->SetValue(val);
|
||||
val = conf->pad_options[this->pad_id].sixaxis_usb;
|
||||
this->init_hack_sixaxis = val;
|
||||
this->cb_hack_sixaxis->SetValue(val);
|
||||
int tmp = conf->get_ff_intensity();
|
||||
this->sl_rumble_intensity->SetValue(tmp);
|
||||
this->init_rumble_intensity = tmp;
|
||||
tmp = conf->get_sensibility();
|
||||
this->sl_joystick_sensibility->SetValue(tmp);
|
||||
this->init_joystick_sensibility = tmp;
|
||||
|
||||
// enable rumble intensity slider if the checkbox is checked
|
||||
if(this->cb_rumble->GetValue())
|
||||
this->sl_rumble_intensity->Enable();
|
||||
else // disable otherwise
|
||||
this->sl_rumble_intensity->Disable();
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* onepad.h
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __GAMEPADCONFIGURATION_H__
|
||||
#define __GAMEPADCONFIGURATION_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 "keyboard.h"
|
||||
#include "onepad.h"
|
||||
|
||||
class GamepadConfiguration : public wxFrame
|
||||
{
|
||||
wxPanel* pan_gamepad_config;
|
||||
wxCheckBox *cb_rumble, *cb_hack_sixaxis;
|
||||
wxSlider *sl_rumble_intensity, *sl_joystick_sensibility;
|
||||
wxButton *bt_ok, *bt_cancel;
|
||||
wxStaticText *lbl_rumble_intensity, *lbl_joystick_sensibility;
|
||||
|
||||
int pad_id;
|
||||
u32 init_rumble_intensity, init_joystick_sensibility;
|
||||
bool init_rumble, init_hack_sixaxis;
|
||||
|
||||
// methods
|
||||
void repopulate();
|
||||
void reset();
|
||||
// Events
|
||||
void OnButtonClicked(wxCommandEvent&);
|
||||
void OnSliderReleased(wxCommandEvent&);
|
||||
void OnCheckboxChange(wxCommandEvent&);
|
||||
|
||||
public:
|
||||
GamepadConfiguration(int, wxWindow*);
|
||||
void InitGamepadConfiguration();
|
||||
};
|
||||
|
||||
#endif // __GAMEPADCONFIGURATION_H__
|
|
@ -0,0 +1,273 @@
|
|||
/* OnePAD
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "JoystickConfiguration.h"
|
||||
|
||||
// Construtor of JoystickConfiguration
|
||||
JoystickConfiguration::JoystickConfiguration(int pad, bool left, wxWindow *parent) : wxFrame(
|
||||
parent, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Gamepad configuration"), // Title
|
||||
wxDefaultPosition, // Position
|
||||
wxSize(400, 200), // Width + Lenght
|
||||
// Style
|
||||
wxSYSTEM_MENU |
|
||||
wxCAPTION |
|
||||
wxCLOSE_BOX |
|
||||
wxCLIP_CHILDREN
|
||||
)
|
||||
{
|
||||
|
||||
this->pad_id = pad;
|
||||
this->isForLeftJoystick = left;
|
||||
this->pan_joystick_config = new wxPanel(
|
||||
this, // Parent
|
||||
wxID_ANY, // ID
|
||||
wxDefaultPosition, // Prosition
|
||||
wxSize(300, 200) // Size
|
||||
);
|
||||
|
||||
if(this->isForLeftJoystick)
|
||||
{
|
||||
this->cb_reverse_Lx = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Reverse Lx"), // Label
|
||||
wxPoint(20, 20) // Position
|
||||
);
|
||||
|
||||
this->cb_reverse_Ly = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Reverse Ly"), // Label
|
||||
wxPoint(20, 40) // Position
|
||||
);
|
||||
|
||||
this->cb_mouse_Ljoy = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Use mouse for left analog joystick"), // Label
|
||||
wxPoint(20, 60) // Position
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cb_reverse_Rx = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Reverse Rx"), // Label
|
||||
wxPoint(20, 20) // Position
|
||||
);
|
||||
|
||||
this->cb_reverse_Ry = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Reverse Ry"), // Label
|
||||
wxPoint(20, 40) // Position
|
||||
);
|
||||
|
||||
this->cb_mouse_Rjoy = new wxCheckBox(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("Use mouse for right analog joystick"), // Label
|
||||
wxPoint(20, 60) // Position
|
||||
);
|
||||
}
|
||||
|
||||
this->bt_ok = new wxButton(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&OK"), // Label
|
||||
wxPoint(250, 130), // Position
|
||||
wxSize(60,25) // Size
|
||||
);
|
||||
|
||||
this->bt_cancel = new wxButton(
|
||||
this->pan_joystick_config, // Parent
|
||||
wxID_ANY, // ID
|
||||
_T("&Cancel"), // Label
|
||||
wxPoint(320, 130), // Position
|
||||
wxSize(60,25) // Size
|
||||
);
|
||||
|
||||
// Connect the buttons to the OnButtonClicked Event
|
||||
this->Connect(
|
||||
wxEVT_COMMAND_BUTTON_CLICKED,
|
||||
wxCommandEventHandler(JoystickConfiguration::OnButtonClicked)
|
||||
);
|
||||
|
||||
// Connect the checkboxes to the OnCheckboxClicked Event
|
||||
this->Connect(
|
||||
wxEVT_CHECKBOX,
|
||||
wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Initialize the frame
|
||||
Check if a gamepad is detected
|
||||
*/
|
||||
void JoystickConfiguration::InitJoystickConfiguration()
|
||||
{
|
||||
this->repopulate(); // Set label and fit simulated key array
|
||||
/*
|
||||
* 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 1, you need at least 2 gamepad connected,
|
||||
* Prevent to use a none initialized value on s_vgamePad (core dump)
|
||||
*/
|
||||
if(s_vgamePad.size() < this->pad_id+1)
|
||||
{
|
||||
wxMessageBox("No gamepad detected.");
|
||||
// disable all checkbox
|
||||
if(this->isForLeftJoystick)
|
||||
{
|
||||
this->cb_reverse_Lx->Disable();
|
||||
this->cb_reverse_Ly->Disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cb_reverse_Rx->Disable();
|
||||
this->cb_reverse_Ry->Disable();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/*********** Events functions ***********/
|
||||
/****************************************/
|
||||
|
||||
/**
|
||||
* Button event, called when a button is clicked
|
||||
*/
|
||||
void JoystickConfiguration::OnButtonClicked(wxCommandEvent &event)
|
||||
{
|
||||
// Affichage d'un message à chaque clic sur le bouton
|
||||
wxButton* bt_tmp = (wxButton*)event.GetEventObject(); // get the button object
|
||||
int bt_id = bt_tmp->GetId(); // get the real ID
|
||||
if(bt_id == this->bt_ok->GetId()) // If the button ID is equals to the Ok button ID
|
||||
{
|
||||
this->Close(); // Close the window
|
||||
}
|
||||
else if(bt_id == this->bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
|
||||
{
|
||||
this->reset(); // reinitialize the value of each parameters
|
||||
this->Close(); // Close the window
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkbox event, called when the value of the checkbox change
|
||||
*/
|
||||
void JoystickConfiguration::OnCheckboxChange(wxCommandEvent& event)
|
||||
{
|
||||
wxCheckBox* cb_tmp = (wxCheckBox*) event.GetEventObject(); // get the slider object
|
||||
int cb_id = cb_tmp->GetId();
|
||||
bool val;
|
||||
if(this->isForLeftJoystick)
|
||||
{
|
||||
if(cb_id == this->cb_reverse_Ly->GetId())
|
||||
{
|
||||
val = this->cb_reverse_Ly->GetValue();
|
||||
conf->pad_options[this->pad_id].reverse_ly = val;
|
||||
}
|
||||
else if(cb_id == this->cb_reverse_Lx->GetId())
|
||||
{
|
||||
val = this->cb_reverse_Lx->GetValue();
|
||||
conf->pad_options[this->pad_id].reverse_lx = val;
|
||||
}
|
||||
else if(cb_id == this->cb_mouse_Ljoy->GetId())
|
||||
{
|
||||
val = this->cb_mouse_Ljoy->GetValue();
|
||||
conf->pad_options[this->pad_id].mouse_l = val;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cb_id == this->cb_reverse_Ry->GetId())
|
||||
{
|
||||
val = this->cb_reverse_Ry->GetValue();
|
||||
conf->pad_options[this->pad_id].reverse_ry = val;
|
||||
}
|
||||
else if(cb_id == this->cb_reverse_Rx->GetId())
|
||||
{
|
||||
val = this->cb_reverse_Rx->GetValue();
|
||||
conf->pad_options[this->pad_id].reverse_rx = val;
|
||||
}
|
||||
else if(cb_id == this->cb_mouse_Rjoy->GetId())
|
||||
{
|
||||
val = this->cb_mouse_Rjoy->GetValue();
|
||||
conf->pad_options[this->pad_id].mouse_r = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************/
|
||||
/*********** Methods functions **********/
|
||||
/****************************************/
|
||||
|
||||
// Reset checkbox and slider values
|
||||
void JoystickConfiguration::reset()
|
||||
{
|
||||
if(this->isForLeftJoystick)
|
||||
{
|
||||
this->cb_reverse_Lx->SetValue(this->init_reverse_Lx);
|
||||
this->cb_reverse_Ly->SetValue(this->init_reverse_Ly);
|
||||
this->cb_mouse_Ljoy->SetValue(this->init_mouse_Ljoy);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->cb_reverse_Rx->SetValue(this->init_reverse_Rx);
|
||||
this->cb_reverse_Ry->SetValue(this->init_reverse_Ry);
|
||||
this->cb_mouse_Rjoy->SetValue(this->init_mouse_Rjoy);
|
||||
}
|
||||
}
|
||||
|
||||
// Set button values
|
||||
void JoystickConfiguration::repopulate()
|
||||
{
|
||||
bool val;
|
||||
if(this->isForLeftJoystick)
|
||||
{
|
||||
val = conf->pad_options[this->pad_id].reverse_lx;
|
||||
this->init_reverse_Lx = val;
|
||||
this->cb_reverse_Lx->SetValue(val);
|
||||
|
||||
val = conf->pad_options[this->pad_id].reverse_ly;
|
||||
this->init_reverse_Ly = val;
|
||||
this->cb_reverse_Ly->SetValue(val);
|
||||
|
||||
val = conf->pad_options[this->pad_id].mouse_l;
|
||||
this->init_mouse_Ljoy = val;
|
||||
this->cb_mouse_Ljoy->SetValue(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = conf->pad_options[this->pad_id].reverse_rx;
|
||||
this->init_reverse_Rx = val;
|
||||
this->cb_reverse_Rx->SetValue(val);
|
||||
|
||||
val = conf->pad_options[this->pad_id].reverse_ry;
|
||||
this->init_reverse_Ry = val;
|
||||
this->cb_reverse_Ry->SetValue(val);
|
||||
|
||||
val = conf->pad_options[this->pad_id].mouse_r;
|
||||
this->init_mouse_Rjoy = val;
|
||||
this->cb_mouse_Rjoy->SetValue(val);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* onepad.h
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __JOYSTICKCONFIGURATION_H__
|
||||
#define __JOYSTICKCONFIGURATION_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 "keyboard.h"
|
||||
#include "onepad.h"
|
||||
|
||||
class JoystickConfiguration : public wxFrame
|
||||
{
|
||||
wxPanel* pan_joystick_config;
|
||||
wxCheckBox *cb_reverse_Lx, *cb_reverse_Ly, *cb_reverse_Rx, *cb_reverse_Ry,
|
||||
*cb_mouse_Ljoy, // Use mouse for left joystick
|
||||
*cb_mouse_Rjoy; // Use mouse for right joystick
|
||||
wxButton *bt_ok, *bt_cancel;
|
||||
|
||||
int pad_id;
|
||||
// isForLeftJoystick -> true is for Left Joystick, false is for Right Joystick
|
||||
bool init_reverse_Lx, init_reverse_Ly, init_reverse_Rx, init_reverse_Ry,
|
||||
init_mouse_Ljoy, init_mouse_Rjoy, isForLeftJoystick;
|
||||
|
||||
// methods
|
||||
void repopulate();
|
||||
void reset();
|
||||
// Events
|
||||
void OnButtonClicked(wxCommandEvent&);
|
||||
void OnCheckboxChange(wxCommandEvent&);
|
||||
|
||||
public:
|
||||
JoystickConfiguration(int, bool, wxWindow*);
|
||||
void InitJoystickConfiguration();
|
||||
};
|
||||
|
||||
#endif // __JOYSTICKCONFIGURATION_H__
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,102 @@
|
|||
/* onepad.h
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __DIALOG_H__
|
||||
#define __DIALOG_H__
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/frame.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/effects.h>
|
||||
#include <wx/rawbmp.h>
|
||||
#include <wx/graphics.h>
|
||||
#include <wx/timer.h>
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "GamePad.h"
|
||||
#include "keyboard.h"
|
||||
#include "onepad.h"
|
||||
#include "opPanel.h"
|
||||
|
||||
#include "GamepadConfiguration.h"
|
||||
#include "JoystickConfiguration.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
// Allow to found quickly button id
|
||||
// e.g L2 → 0, triangle → 4, ...
|
||||
// see onepad.h for more details about gamepad button id
|
||||
|
||||
enum gui_buttons {
|
||||
Analog = PAD_R_LEFT+1, // Analog button (not yet supported ?)
|
||||
JoyL_config, // Left Joystick Configuration
|
||||
JoyR_config, // Right Joystick Configuration
|
||||
Gamepad_config, // Gamepad Configuration
|
||||
Apply, // Apply modifications without exit
|
||||
Ok, // Apply modifications and exit
|
||||
Cancel // Exit without apply modificatons
|
||||
};
|
||||
|
||||
#define BUTTONS_LENGHT 31 // numbers of buttons on the gamepad
|
||||
#define GAMEPAD_NUMBER 2 // numbers of gamepad
|
||||
#define UPDATE_TIME 5
|
||||
|
||||
class Dialog : public wxFrame
|
||||
{
|
||||
// Panels
|
||||
opPanel* pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
|
||||
// Notebooks
|
||||
wxNotebook* tab_gamepad; // Joysticks Tabs
|
||||
// Buttons
|
||||
wxButton* bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
|
||||
// Contain all simulated key
|
||||
u32 simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
|
||||
// Timer
|
||||
wxTimer time_update_gui;
|
||||
// Check if the gui must display feddback image
|
||||
bool pressed[GAMEPAD_NUMBER][NB_IMG];
|
||||
// Map the key pressed with the feedback image id
|
||||
std::map<u32,int> map_images[GAMEPAD_NUMBER];
|
||||
|
||||
// Frame
|
||||
GamepadConfiguration* frm_gamepad_config; // Gamepad Configuration frame
|
||||
JoystickConfiguration* frm_joystick_config; // Joystick Configuration frame
|
||||
|
||||
// methods
|
||||
void config_key(int, int);
|
||||
void clear_key(int, int);
|
||||
void repopulate();
|
||||
|
||||
// Events
|
||||
void OnButtonClicked(wxCommandEvent&);
|
||||
void JoystickEvent(wxCommandEvent&);
|
||||
|
||||
public:
|
||||
Dialog();
|
||||
void InitDialog();
|
||||
void show();
|
||||
};
|
||||
|
||||
extern void DisplayDialog(); // Main function
|
||||
|
||||
#endif // __DIALOG_H__
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "GamePad.h"
|
||||
#include "keyboard.h"
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
/* opPanel.cpp
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "opPanel.h"
|
||||
#include "ImgHeader/dualshock2.h"
|
||||
#include "ImgHeader/cross.h"
|
||||
#include "ImgHeader/circle.h"
|
||||
#include "ImgHeader/square.h"
|
||||
#include "ImgHeader/triangle.h"
|
||||
#include "ImgHeader/dp_left.h"
|
||||
#include "ImgHeader/dp_right.h"
|
||||
#include "ImgHeader/dp_up.h"
|
||||
#include "ImgHeader/dp_bottom.h"
|
||||
#include "ImgHeader/l1.h"
|
||||
#include "ImgHeader/r1.h"
|
||||
#include "ImgHeader/l2.h"
|
||||
#include "ImgHeader/l3.h"
|
||||
#include "ImgHeader/r2.h"
|
||||
#include "ImgHeader/r3.h"
|
||||
#include "ImgHeader/start.h"
|
||||
#include "ImgHeader/select.h"
|
||||
#include "ImgHeader/analog.h"
|
||||
#include "ImgHeader/joystick_cursor.h"
|
||||
|
||||
opPanel::opPanel(wxWindow *parent,
|
||||
wxWindowID id=wxID_ANY,
|
||||
const wxPoint &pos=wxDefaultPosition,
|
||||
const wxSize &size=wxDefaultSize
|
||||
): wxPanel( parent, id, pos, size)
|
||||
{
|
||||
this->picture[img_background] = EmbeddedImage<res_dualshock2>().GetIcon();
|
||||
|
||||
this->picture[img_start] = EmbeddedImage<res_start>().GetIcon();
|
||||
this->picture[img_select] = EmbeddedImage<res_select>().GetIcon();
|
||||
this->picture[img_analog] = EmbeddedImage<res_analog>().GetIcon();
|
||||
|
||||
this->picture[img_dp_left] = EmbeddedImage<res_dp_left>().GetIcon();
|
||||
this->picture[img_dp_right] = EmbeddedImage<res_dp_right>().GetIcon();
|
||||
this->picture[img_dp_up] = EmbeddedImage<res_dp_up>().GetIcon();
|
||||
this->picture[img_dp_bottom] = EmbeddedImage<res_dp_bottom>().GetIcon();
|
||||
|
||||
this->picture[img_square] = EmbeddedImage<res_square>().GetIcon();
|
||||
this->picture[img_circle] = EmbeddedImage<res_circle>().GetIcon();
|
||||
this->picture[img_cross] = EmbeddedImage<res_cross>().GetIcon();
|
||||
this->picture[img_triangle] = EmbeddedImage<res_triangle>().GetIcon();
|
||||
|
||||
this->picture[img_l1] = EmbeddedImage<res_l1>().GetIcon();
|
||||
this->picture[img_l3] = EmbeddedImage<res_l3>().GetIcon();
|
||||
this->picture[img_l2] = EmbeddedImage<res_l2>().GetIcon();
|
||||
|
||||
this->picture[img_r1] = EmbeddedImage<res_r1>().GetIcon();
|
||||
this->picture[img_r3] = EmbeddedImage<res_r3>().GetIcon();
|
||||
this->picture[img_r2] = EmbeddedImage<res_r2>().GetIcon();
|
||||
|
||||
this->picture[img_left_cursor] = EmbeddedImage<res_joystick_cursor>().GetIcon();
|
||||
this->picture[img_right_cursor] = EmbeddedImage<res_joystick_cursor>().GetIcon();
|
||||
|
||||
for(int i=0; i<NB_IMG; ++i)
|
||||
{
|
||||
this->show_image[i] = false;
|
||||
this->SaveSize(i);
|
||||
this->HideImg(i);
|
||||
}
|
||||
this->ShowImg(img_background);
|
||||
this->show_image[img_background] = true;
|
||||
|
||||
this->left_cursor_x = 0;
|
||||
this->left_cursor_y = 0;
|
||||
this->right_cursor_x = 0;
|
||||
this->right_cursor_y = 0;
|
||||
}
|
||||
|
||||
void opPanel::SaveSize(int id)
|
||||
{
|
||||
this->img_size[id][0] = this->picture[id].GetWidth();
|
||||
this->img_size[id][1] = this->picture[id].GetHeight();
|
||||
}
|
||||
|
||||
void opPanel::HideImg(int id)
|
||||
{
|
||||
this->show_image[id] = false;
|
||||
this->Refresh();
|
||||
}
|
||||
|
||||
void opPanel::ShowImg(int id)
|
||||
{
|
||||
this->show_image[id] = true;
|
||||
this->Refresh();
|
||||
}
|
||||
|
||||
void opPanel::MoveJoystick(int axe,int value)
|
||||
{
|
||||
if(axe == 0)
|
||||
{
|
||||
this->left_cursor_x = value*30/40000;
|
||||
}
|
||||
else if(axe == 1)
|
||||
{
|
||||
this->left_cursor_y = value*30/40000;
|
||||
}
|
||||
else if( axe == 2)
|
||||
{
|
||||
this->right_cursor_x = value*30/40000;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->right_cursor_y = value*30/40000;
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(opPanel, wxPanel)
|
||||
EVT_PAINT(opPanel::OnPaint)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void opPanel::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
wxSize sz = GetClientSize();
|
||||
|
||||
wxMemoryDC temp_background, temp_start, temp_select, temp_analog, temp_dp_left,
|
||||
temp_dp_right, temp_dp_up, temp_dp_bottom, temp_l1, temp_r1, temp_L3, temp_l2_2,
|
||||
temp_R3, temp_r2_2, temp_square, temp_circle, temp_cross, temp_triangle,
|
||||
temp_left_cursor, temp_right_cursor;
|
||||
|
||||
temp_background.SelectObject(this->picture[img_background]);
|
||||
temp_start.SelectObject(this->picture[img_start]);
|
||||
temp_select.SelectObject(this->picture[img_select]);
|
||||
temp_analog.SelectObject(this->picture[img_analog]);
|
||||
temp_dp_left.SelectObject(this->picture[img_dp_left]);
|
||||
|
||||
temp_dp_right.SelectObject(this->picture[img_dp_right]);
|
||||
temp_dp_up.SelectObject(this->picture[img_dp_up]);
|
||||
temp_dp_bottom.SelectObject(this->picture[img_dp_bottom]);
|
||||
temp_l1.SelectObject(this->picture[img_l1]);
|
||||
temp_r1.SelectObject(this->picture[img_r1]);
|
||||
temp_L3.SelectObject(this->picture[img_l3]);
|
||||
temp_l2_2.SelectObject(this->picture[img_l2]);
|
||||
|
||||
temp_R3.SelectObject(this->picture[img_r3]);
|
||||
temp_r2_2.SelectObject(this->picture[img_r2]);
|
||||
temp_square.SelectObject(this->picture[img_square]);
|
||||
temp_circle.SelectObject(this->picture[img_circle]);
|
||||
temp_cross.SelectObject(this->picture[img_cross]);
|
||||
temp_triangle.SelectObject(this->picture[img_triangle]);
|
||||
|
||||
temp_left_cursor.SelectObject(this->picture[img_left_cursor]);
|
||||
temp_right_cursor.SelectObject(this->picture[img_right_cursor]);
|
||||
|
||||
if(this->show_image[img_background])
|
||||
dc.Blit(wxPoint(0, 0), temp_background.GetSize(), &temp_background, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_start])
|
||||
dc.Blit(wxPoint(526, 296), temp_start.GetSize(), &temp_start, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_select])
|
||||
dc.Blit(wxPoint(450, 297), temp_select.GetSize(), &temp_select, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_analog])
|
||||
dc.Blit(wxPoint(489, 358), temp_analog.GetSize(), &temp_analog, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_dp_left])
|
||||
dc.Blit(wxPoint(335, 292), temp_dp_left.GetSize(), &temp_dp_left, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_dp_right])
|
||||
dc.Blit(wxPoint(378, 292), temp_dp_right.GetSize(), &temp_dp_right, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_dp_up])
|
||||
dc.Blit(wxPoint(358, 269), temp_dp_up.GetSize(), &temp_dp_up, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_dp_bottom])
|
||||
dc.Blit(wxPoint(358, 312), temp_dp_bottom.GetSize(), &temp_dp_bottom, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_l1])
|
||||
dc.Blit(wxPoint(343, 186), temp_l1.GetSize(), &temp_l1, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_r1])
|
||||
dc.Blit(wxPoint(594, 186), temp_r1.GetSize(), &temp_r1, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_l3])
|
||||
dc.Blit(wxPoint(409, 344), temp_L3.GetSize(), &temp_L3, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_l2])
|
||||
dc.Blit(wxPoint(347, 158), temp_l2_2.GetSize(), &temp_l2_2, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_r3])
|
||||
dc.Blit(wxPoint(525, 344), temp_R3.GetSize(), &temp_R3, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_r2])
|
||||
dc.Blit(wxPoint(581, 158), temp_r2_2.GetSize(), &temp_r2_2, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_square])
|
||||
dc.Blit(wxPoint(573, 287), temp_square.GetSize(), &temp_square, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_circle])
|
||||
dc.Blit(wxPoint(647, 287), temp_circle.GetSize(), &temp_circle, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_cross])
|
||||
dc.Blit(wxPoint(610, 324), temp_cross.GetSize(), &temp_cross, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_triangle])
|
||||
dc.Blit(wxPoint(610, 250), temp_triangle.GetSize(), &temp_triangle, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_left_cursor])
|
||||
dc.Blit(wxPoint(439+this->left_cursor_x, 374+this->left_cursor_y), temp_left_cursor.GetSize(), &temp_left_cursor, wxPoint(0, 0), wxCOPY, true);
|
||||
if(this->show_image[img_right_cursor])
|
||||
dc.Blit(wxPoint(555+this->right_cursor_x, 374+this->right_cursor_y), temp_right_cursor.GetSize(), &temp_right_cursor, wxPoint(0, 0), wxCOPY, true);
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/* opPanel.h
|
||||
* Copyright (C) 2015
|
||||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __OPPANEL_H__
|
||||
#define __OPPANEL_H__
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include "EmbeddedImage.h"
|
||||
|
||||
enum gui_img {
|
||||
img_l2,
|
||||
img_r2,
|
||||
img_l1,
|
||||
img_r1,
|
||||
img_triangle,
|
||||
img_circle,
|
||||
img_cross,
|
||||
img_square,
|
||||
img_select,
|
||||
img_l3,
|
||||
img_r3,
|
||||
img_start,
|
||||
img_dp_up,
|
||||
img_dp_right,
|
||||
img_dp_bottom,
|
||||
img_dp_left,
|
||||
img_left_cursor,
|
||||
img_right_cursor,
|
||||
img_analog,
|
||||
img_background // background pic
|
||||
};
|
||||
|
||||
#define NB_IMG 20
|
||||
|
||||
class opPanel : public wxPanel
|
||||
{
|
||||
wxBitmap picture[NB_IMG];
|
||||
int img_size[NB_IMG][2];
|
||||
bool show_image[NB_IMG];
|
||||
int left_cursor_x, left_cursor_y, right_cursor_x, right_cursor_y;
|
||||
void SaveSize(int);
|
||||
DECLARE_EVENT_TABLE()
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
|
||||
public:
|
||||
opPanel(wxWindow*, wxWindowID, const wxPoint&, const wxSize&);
|
||||
void HideImg(int);
|
||||
void ShowImg(int);
|
||||
void MoveJoystick(int, int);
|
||||
};
|
||||
|
||||
#endif // __OPPANEL_H__
|
|
@ -130,7 +130,7 @@ void JoystickInfo::Rumble(int type, int pad)
|
|||
{
|
||||
fprintf(stderr,"ERROR: Effect is not uploaded! %s, id is %d\n",SDL_GetError(),effects_id[0]);
|
||||
}
|
||||
|
||||
|
||||
/** Effect for big motor **/
|
||||
effects[1].type = SDL_HAPTIC_TRIANGLE;
|
||||
effects_id[1] = SDL_HapticNewEffect(haptic, &effects[1]);
|
||||
|
@ -236,18 +236,23 @@ void JoystickInfo::SaveState()
|
|||
SetHatState(i, SDL_JoystickGetHat(joy, i));
|
||||
}
|
||||
|
||||
void JoystickInfo::TestForce()
|
||||
bool JoystickInfo::TestForce(float strength=0.60)
|
||||
{
|
||||
#if SDL_MAJOR_VERSION >= 2
|
||||
// This code just use standard rumble to check that SDL handles the pad correctly! --3kinox
|
||||
if(haptic == NULL) return; // Otherwise, core dump!
|
||||
if(haptic == NULL)
|
||||
return false; // Otherwise, core dump!
|
||||
SDL_HapticRumbleInit( haptic );
|
||||
// Make the haptic pad rumble 60% strength for half a second, shoudld be enough for user to see if it works or not
|
||||
if( SDL_HapticRumblePlay( haptic, 0.60, 400 ) != 0)
|
||||
if( SDL_HapticRumblePlay( haptic, strength, 400 ) != 0)
|
||||
{
|
||||
fprintf(stderr,"ERROR: Rumble is not working! %s\n",SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JoystickInfo::PollButtons(u32 &pkey)
|
||||
|
|
|
@ -52,7 +52,7 @@ class JoystickInfo : GamePad
|
|||
|
||||
JoystickInfo(const JoystickInfo&); // copy constructor
|
||||
JoystickInfo& operator=(const JoystickInfo&); // assignment
|
||||
|
||||
|
||||
void Destroy();
|
||||
// opens handles to all possible joysticks
|
||||
static void EnumerateJoysticks(vector<GamePad*>& vjoysticks);
|
||||
|
@ -61,7 +61,7 @@ class JoystickInfo : GamePad
|
|||
|
||||
bool Init(int id); // opens a handle and gets information
|
||||
|
||||
void TestForce();
|
||||
bool TestForce(float);
|
||||
|
||||
bool PollButtons(u32 &pkey);
|
||||
bool PollAxes(u32 &pkey);
|
||||
|
|
|
@ -101,7 +101,7 @@ class PADconf
|
|||
int shift = 8 * pad;
|
||||
return ((joyid_map >> shift) & 0xFF);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return (a copy of) private memner ff_instensity
|
||||
**/
|
||||
|
@ -116,7 +116,7 @@ class PADconf
|
|||
**/
|
||||
void set_ff_intensity(u32 new_intensity)
|
||||
{
|
||||
if(new_intensity < 0x7FFF && new_intensity >= 0)
|
||||
if(new_intensity <= 0x7FFF && new_intensity >= 0)
|
||||
{
|
||||
ff_intensity = new_intensity;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ bool toggleAutoRepeat = false;
|
|||
|
||||
const u32 version = PS2E_PAD_VERSION;
|
||||
const u32 revision = 1;
|
||||
const u32 build = 1; // increase that with each version
|
||||
const u32 build = 2; // increase that with each version
|
||||
|
||||
int PadEnum[2][2] = {{0, 2}, {1, 3}};
|
||||
|
||||
|
|
|
@ -97,30 +97,30 @@ enum PadCommands
|
|||
|
||||
enum gamePadValues
|
||||
{
|
||||
PAD_L2 = 0,
|
||||
PAD_R2,
|
||||
PAD_L1,
|
||||
PAD_R1,
|
||||
PAD_TRIANGLE,
|
||||
PAD_CIRCLE,
|
||||
PAD_CROSS,
|
||||
PAD_SQUARE,
|
||||
PAD_SELECT,
|
||||
PAD_L3,
|
||||
PAD_R3,
|
||||
PAD_START,
|
||||
PAD_UP,
|
||||
PAD_RIGHT,
|
||||
PAD_DOWN,
|
||||
PAD_LEFT,
|
||||
PAD_L_UP,
|
||||
PAD_L_RIGHT,
|
||||
PAD_L_DOWN,
|
||||
PAD_L_LEFT,
|
||||
PAD_R_UP,
|
||||
PAD_R_RIGHT,
|
||||
PAD_R_DOWN,
|
||||
PAD_R_LEFT
|
||||
PAD_L2 = 0, // L2 button
|
||||
PAD_R2, // R2 button
|
||||
PAD_L1, // L1 button
|
||||
PAD_R1, // R1 button
|
||||
PAD_TRIANGLE, // Triangle button ▲
|
||||
PAD_CIRCLE, // Circle button ●
|
||||
PAD_CROSS, // Cross button ✖
|
||||
PAD_SQUARE, // Square button ■
|
||||
PAD_SELECT, // Select button
|
||||
PAD_L3, // Left joystick button (L3)
|
||||
PAD_R3, // Right joystick button (R3)
|
||||
PAD_START, // Start button
|
||||
PAD_UP, // Directional pad ↑
|
||||
PAD_RIGHT, // Directional pad →
|
||||
PAD_DOWN, // Directional pad ↓
|
||||
PAD_LEFT, // Directional pad ←
|
||||
PAD_L_UP, // Left joystick (Up) ↑
|
||||
PAD_L_RIGHT, // Left joystick (Right) →
|
||||
PAD_L_DOWN, // Left joystick (Down) ↓
|
||||
PAD_L_LEFT, // Left joystick (Left) ←
|
||||
PAD_R_UP, // Right joystick (Up) ↑
|
||||
PAD_R_RIGHT, // Right joystick (Right) →
|
||||
PAD_R_DOWN, // Right joystick (Down) ↓
|
||||
PAD_R_LEFT // Right joystick (Left) ←
|
||||
};
|
||||
|
||||
extern keyEvent event;
|
||||
|
|
Loading…
Reference in New Issue