Merge pull request #924 from kust2708/onepad-gui

Onepad GUI for Linux - New wxWidget interface
This commit is contained in:
Gregory Hainaut 2016-03-15 20:23:44 +01:00
commit 0ef8ddb2a2
47 changed files with 1904 additions and 619 deletions

View File

@ -24,7 +24,7 @@
#include "MSWstuff.h" #include "MSWstuff.h"
#include "Resources/EmbeddedImage.h" #include "Utilities/EmbeddedImage.h"
#include "Resources/BackgroundLogo.h" #include "Resources/BackgroundLogo.h"
#include "Resources/ButtonIcon_Camera.h" #include "Resources/ButtonIcon_Camera.h"

View File

@ -19,7 +19,7 @@
#include "Dialogs/ModalPopups.h" #include "Dialogs/ModalPopups.h"
#include "Resources/EmbeddedImage.h" #include "Utilities/EmbeddedImage.h"
#include "Resources/Logo.h" #include "Resources/Logo.h"
#include <wx/mstream.h> #include <wx/mstream.h>

View File

@ -5,9 +5,40 @@ if(NOT TOP_CMAKE_WAS_SOURCED)
It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt") It is advice to delete all wrongly generated cmake stuff => CMakeFiles & CMakeCache.txt")
endif() 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
${compiled_images}/arrow_up.h
${compiled_images}/arrow_bottom.h
${compiled_images}/arrow_left.h
${compiled_images}/arrow_right.h
)
# plugin name # plugin name
set(Output onepad-1.1.0) set(Output onepad-1.2.0)
set(onepadFinalFlags "") set(onepadFinalFlags "")
# onepad sources # onepad sources
@ -31,13 +62,19 @@ set(onepadHeaders
# onepad Linux sources # onepad Linux sources
set(onepadLinuxSources set(onepadLinuxSources
Linux/ini.cpp ${linux_sources}/ini.cpp
Linux/dialog.cpp ${linux_sources}/dialog.cpp
Linux/linux.cpp) ${linux_sources}/linux.cpp
${linux_sources}/opPanel.cpp
${linux_sources}/GamepadConfiguration.cpp
${linux_headers}/JoystickConfiguration.cpp)
# onepad Linux headers # onepad Linux headers
set(onepadLinuxHeaders set(onepadLinuxHeaders
Linux/linux.h) ${linux_headers}/linux.h
${linux_headers}/opPanel.h
${linux_headers}/GamepadConfiguration.h
${linux_headers}/JoystickConfiguration.h)
# onepad Windows sources # onepad Windows sources
set(onepadWindowsSources set(onepadWindowsSources
@ -70,6 +107,23 @@ set(onepadFinalSources
${onepadHeaders} ${onepadHeaders}
${onepadLinuxSources} ${onepadLinuxSources}
${onepadLinuxHeaders} ${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 arrow_up
arrow_bottom arrow_left arrow_right)
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}") add_pcsx2_plugin(${Output} "${onepadFinalSources}" "${onepadFinalLibs}" "${onepadFinalFlags}")

View File

@ -38,7 +38,7 @@ class GamePad
**/ **/
static void UpdateGamePadState(); static void UpdateGamePadState();
/** /**
* Causes devices to rumble * Causes devices to rumble
* Rumble will differ according to type which is either 0(small motor) or 1(big motor) * 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 * 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 PollButtons(u32 &pkey){return false;}
virtual bool PollAxes(u32 &pkey){return false;} virtual bool PollAxes(u32 &pkey){return false;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
plugins/onepad/Img/l1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 947 B

BIN
plugins/onepad/Img/l2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
plugins/onepad/Img/l3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

BIN
plugins/onepad/Img/r1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 949 B

BIN
plugins/onepad/Img/r2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
plugins/onepad/Img/r3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 906 B

View File

@ -23,7 +23,7 @@
void KeyStatus::Init() void KeyStatus::Init()
{ {
for (int pad = 0; pad < 2; pad++) { for (int pad = 0; pad < GAMEPAD_NUMBER; pad++) {
m_button[pad] = 0xFFFF; m_button[pad] = 0xFFFF;
m_internal_button_kbd[pad] = 0xFFFF; m_internal_button_kbd[pad] = 0xFFFF;
m_internal_button_joy[pad] = 0xFFFF; m_internal_button_joy[pad] = 0xFFFF;

View File

@ -35,18 +35,18 @@ typedef struct
class KeyStatus class KeyStatus
{ {
private: private:
u16 m_button[2]; u16 m_button[GAMEPAD_NUMBER];
u16 m_internal_button_kbd[2]; u16 m_internal_button_kbd[GAMEPAD_NUMBER];
u16 m_internal_button_joy[2]; u16 m_internal_button_joy[GAMEPAD_NUMBER];
u8 m_button_pressure[2][MAX_KEYS]; u8 m_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
u8 m_internal_button_pressure[2][MAX_KEYS]; u8 m_internal_button_pressure[GAMEPAD_NUMBER][MAX_KEYS];
bool m_state_acces[2]; bool m_state_acces[GAMEPAD_NUMBER];
PADAnalog m_analog[2]; PADAnalog m_analog[GAMEPAD_NUMBER];
PADAnalog m_internal_analog_kbd[2]; PADAnalog m_internal_analog_kbd[GAMEPAD_NUMBER];
PADAnalog m_internal_analog_joy[2]; PADAnalog m_internal_analog_joy[GAMEPAD_NUMBER];
void analog_set(u32 pad, u32 index, u8 value); void analog_set(u32 pad, u32 index, u8 value);
bool analog_is_reversed(u32 pad, u32 index); bool analog_is_reversed(u32 pad, u32 index);

View File

@ -0,0 +1,308 @@
/* GamepadConfiguration.cpp
* PCSX2 Dev Team
* 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, 230), // Width + Lenght
// Style
wxSYSTEM_MENU |
wxCAPTION |
wxCLOSE_BOX |
wxCLIP_CHILDREN
)
{
m_pad_id = pad;
m_pan_gamepad_config = new wxPanel(
this, // Parent
wxID_ANY, // ID
wxDefaultPosition, // Prosition
wxSize(300, 200) // Size
);
m_cb_rumble = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Enable rumble"), // Label
wxPoint(20, 20) // Position
);
m_cb_hack_sixaxis_usb = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Hack: Sixaxis/DS3 plugged in USB"), // Label
wxPoint(20, 40) // Position
);
m_cb_hack_sixaxis_pressure = new wxCheckBox(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Hack: Sixaxis/DS3 pressure"), // Label
wxPoint(20, 60) // Position
);
wxString txt_rumble = wxT("Rumble intensity");
m_lbl_rumble_intensity = new wxStaticText(
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(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
0, // value
0, // min value 0x0000
0x7FFF, // max value 0x7FFF
wxPoint(150, 83), // Position
wxSize(200, 30) // Size
);
wxString txt_joystick = wxT("Joystick sensibility");
m_lbl_rumble_intensity = new wxStaticText(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
txt_joystick, // Text which must be displayed
wxPoint(20, 120), // Position
wxDefaultSize // Size
);
m_sl_joystick_sensibility = new wxSlider(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
0, // value
0, // min value
100, // max value
wxPoint(150, 113), // Position
wxSize(200, 30) // Size
);
m_bt_ok = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&OK"), // Label
wxPoint(250, 160), // Position
wxSize(60,25) // Size
);
m_bt_cancel = new wxButton(
m_pan_gamepad_config, // Parent
wxID_ANY, // ID
_T("&Cancel"), // Label
wxPoint(320, 160), // Position
wxSize(60,25) // Size
);
// Connect the buttons to the OnButtonClicked Event
Connect(
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(GamepadConfiguration::OnButtonClicked)
);
// Connect the sliders to the OnSliderReleased Event
Connect(
wxEVT_SCROLL_THUMBRELEASE,
wxCommandEventHandler(GamepadConfiguration::OnSliderReleased)
);
// Connect the checkboxes to the OnCheckboxClicked Event
#if wxMAJOR_VERSION >= 3
Connect(
wxEVT_CHECKBOX,
wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange)
);
#else
Connect(
wxEVT_COMMAND_CHECKBOX_CLICKED,
wxCommandEventHandler(GamepadConfiguration::OnCheckboxChange)
);
#endif
}
/**
Initialize the frame
Check if a gamepad is detected
Check if the gamepad support rumbles
*/
void GamepadConfiguration::InitGamepadConfiguration()
{
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() >= m_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[m_pad_id]->TestForce(0.001f))
{
wxMessageBox(L"Rumble is not available for your device.");
m_cb_rumble->Disable(); // disable the rumble checkbox
m_sl_rumble_intensity->Disable(); // disable the rumble intensity slider
}
}
else
{
wxMessageBox(L"No gamepad detected.");
m_sl_joystick_sensibility->Disable(); // disable the joystick sensibility slider
m_cb_rumble->Disable(); // disable the rumble checkbox
m_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 == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID
{
Close(); // Close the window
}
else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
{
reset(); // reinitialize the value of each parameters
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 == m_sl_rumble_intensity->GetId()) // if this is the rumble intensity slider
{
u32 intensity = m_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 = m_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[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
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 == m_cb_rumble->GetId())
{
conf->pad_options[m_pad_id].forcefeedback = (m_cb_rumble->GetValue())?(u32)1:(u32)0;
if(m_cb_rumble->GetValue())
{
s_vgamePad[m_pad_id]->TestForce();
m_sl_rumble_intensity->Enable();
}
else
{
m_sl_rumble_intensity->Disable();
}
}
else if(cb_id == m_cb_hack_sixaxis_usb->GetId())
{
conf->pad_options[m_pad_id].sixaxis_usb = (m_cb_hack_sixaxis_usb->GetValue())?(u32)1:(u32)0;
}
else if(cb_id == m_cb_hack_sixaxis_pressure->GetId())
{
conf->pad_options[m_pad_id].sixaxis_pressure = (m_cb_hack_sixaxis_pressure->GetValue())?(u32)1:(u32)0;
}
}
/****************************************/
/*********** Methods functions **********/
/****************************************/
// Reset checkbox and slider values
void GamepadConfiguration::reset()
{
m_cb_rumble->SetValue(m_init_rumble);
m_cb_hack_sixaxis_usb->SetValue(m_init_hack_sixaxis);
m_cb_hack_sixaxis_pressure->SetValue(m_init_hack_sixaxis_pressure);
m_sl_rumble_intensity->SetValue(m_init_rumble_intensity);
m_sl_joystick_sensibility->SetValue(m_init_joystick_sensibility);
}
// Set button values
void GamepadConfiguration::repopulate()
{
bool val = conf->pad_options[m_pad_id].forcefeedback;
m_init_rumble = val;
m_cb_rumble->SetValue(val);
val = conf->pad_options[m_pad_id].sixaxis_usb;
m_init_hack_sixaxis = val;
m_cb_hack_sixaxis_usb->SetValue(val);
val = conf->pad_options[m_pad_id].sixaxis_pressure;
m_init_hack_sixaxis_pressure = val;
m_cb_hack_sixaxis_pressure->SetValue(val);
int tmp = conf->get_ff_intensity();
m_sl_rumble_intensity->SetValue(tmp);
m_init_rumble_intensity = tmp;
tmp = conf->get_sensibility();
m_sl_joystick_sensibility->SetValue(tmp);
m_init_joystick_sensibility = tmp;
// enable rumble intensity slider if the checkbox is checked
if(m_cb_rumble->GetValue())
m_sl_rumble_intensity->Enable();
else // disable otherwise
m_sl_rumble_intensity->Disable();
}

View File

@ -0,0 +1,60 @@
/* GamepadConfiguration.h
* PCSX2 Dev Team
* 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* m_pan_gamepad_config;
wxCheckBox *m_cb_rumble, *m_cb_hack_sixaxis_usb, *m_cb_hack_sixaxis_pressure;
wxSlider *m_sl_rumble_intensity, *m_sl_joystick_sensibility;
wxButton *m_bt_ok, *m_bt_cancel;
wxStaticText *m_lbl_rumble_intensity, *m_lbl_joystick_sensibility;
int m_pad_id;
u32 m_init_rumble_intensity, m_init_joystick_sensibility;
bool m_init_rumble, m_init_hack_sixaxis, m_init_hack_sixaxis_pressure;
// methods
void repopulate();
void reset();
// Events
void OnButtonClicked(wxCommandEvent&);
void OnSliderReleased(wxCommandEvent&);
void OnCheckboxChange(wxCommandEvent&);
public:
GamepadConfiguration(int, wxWindow*);
void InitGamepadConfiguration();
};
#endif // __GAMEPADCONFIGURATION_H__

View File

@ -0,0 +1,281 @@
/* JoystickConfiguration.cpp
* PCSX2 Dev Team
* 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
)
{
m_pad_id = pad;
m_isForLeftJoystick = left;
m_pan_joystick_config = new wxPanel(
this, // Parent
wxID_ANY, // ID
wxDefaultPosition, // Prosition
wxSize(300, 200) // Size
);
if(m_isForLeftJoystick)
{
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(
m_pan_joystick_config, // Parent
wxID_ANY, // ID
_T("Reverse Ly"), // Label
wxPoint(20, 40) // Position
);
m_cb_mouse_Ljoy = new wxCheckBox(
m_pan_joystick_config, // Parent
wxID_ANY, // ID
_T("Use mouse for left analog joystick"), // Label
wxPoint(20, 60) // Position
);
}
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
wxID_ANY, // ID
_T("Reverse Ry"), // Label
wxPoint(20, 40) // Position
);
m_cb_mouse_Rjoy = new wxCheckBox(
m_pan_joystick_config, // Parent
wxID_ANY, // ID
_T("Use mouse for right analog joystick"), // Label
wxPoint(20, 60) // Position
);
}
m_bt_ok = new wxButton(
m_pan_joystick_config, // Parent
wxID_ANY, // ID
_T("&OK"), // Label
wxPoint(250, 130), // Position
wxSize(60,25) // Size
);
m_bt_cancel = new wxButton(
m_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
Connect(
wxEVT_COMMAND_BUTTON_CLICKED,
wxCommandEventHandler(JoystickConfiguration::OnButtonClicked)
);
// Connect the checkboxes to the OnCheckboxClicked Event
#if wxMAJOR_VERSION >= 3
Connect(
wxEVT_CHECKBOX,
wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange)
);
#else
Connect(
wxEVT_COMMAND_CHECKBOX_CLICKED,
wxCommandEventHandler(JoystickConfiguration::OnCheckboxChange)
);
#endif
}
/**
Initialize the frame
Check if a gamepad is detected
*/
void JoystickConfiguration::InitJoystickConfiguration()
{
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() < m_pad_id+1)
{
wxMessageBox(L"No gamepad detected.");
// disable all checkbox
if(m_isForLeftJoystick)
{
m_cb_reverse_Lx->Disable();
m_cb_reverse_Ly->Disable();
}
else
{
m_cb_reverse_Rx->Disable();
m_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 == m_bt_ok->GetId()) // If the button ID is equals to the Ok button ID
{
Close(); // Close the window
}
else if(bt_id == m_bt_cancel->GetId()) // If the button ID is equals to the cancel button ID
{
reset(); // reinitialize the value of each parameters
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(m_isForLeftJoystick)
{
if(cb_id == m_cb_reverse_Ly->GetId())
{
val = m_cb_reverse_Ly->GetValue();
conf->pad_options[m_pad_id].reverse_ly = val;
}
else if(cb_id == m_cb_reverse_Lx->GetId())
{
val = m_cb_reverse_Lx->GetValue();
conf->pad_options[m_pad_id].reverse_lx = val;
}
else if(cb_id == m_cb_mouse_Ljoy->GetId())
{
val = m_cb_mouse_Ljoy->GetValue();
conf->pad_options[m_pad_id].mouse_l = val;
}
}
else
{
if(cb_id == m_cb_reverse_Ry->GetId())
{
val = m_cb_reverse_Ry->GetValue();
conf->pad_options[m_pad_id].reverse_ry = val;
}
else if(cb_id == m_cb_reverse_Rx->GetId())
{
val = m_cb_reverse_Rx->GetValue();
conf->pad_options[m_pad_id].reverse_rx = val;
}
else if(cb_id == m_cb_mouse_Rjoy->GetId())
{
val = m_cb_mouse_Rjoy->GetValue();
conf->pad_options[m_pad_id].mouse_r = val;
}
}
}
/****************************************/
/*********** Methods functions **********/
/****************************************/
// Reset checkbox and slider values
void JoystickConfiguration::reset()
{
if(m_isForLeftJoystick)
{
m_cb_reverse_Lx->SetValue(m_init_reverse_Lx);
m_cb_reverse_Ly->SetValue(m_init_reverse_Ly);
m_cb_mouse_Ljoy->SetValue(m_init_mouse_Ljoy);
}
else
{
m_cb_reverse_Rx->SetValue(m_init_reverse_Rx);
m_cb_reverse_Ry->SetValue(m_init_reverse_Ry);
m_cb_mouse_Rjoy->SetValue(m_init_mouse_Rjoy);
}
}
// Set button values
void JoystickConfiguration::repopulate()
{
bool val;
if(m_isForLeftJoystick)
{
val = conf->pad_options[m_pad_id].reverse_lx;
m_init_reverse_Lx = val;
m_cb_reverse_Lx->SetValue(val);
val = conf->pad_options[m_pad_id].reverse_ly;
m_init_reverse_Ly = val;
m_cb_reverse_Ly->SetValue(val);
val = conf->pad_options[m_pad_id].mouse_l;
m_init_mouse_Ljoy = val;
m_cb_mouse_Ljoy->SetValue(val);
}
else
{
val = conf->pad_options[m_pad_id].reverse_rx;
m_init_reverse_Rx = val;
m_cb_reverse_Rx->SetValue(val);
val = conf->pad_options[m_pad_id].reverse_ry;
m_init_reverse_Ry = val;
m_cb_reverse_Ry->SetValue(val);
val = conf->pad_options[m_pad_id].mouse_r;
m_init_mouse_Rjoy = val;
m_cb_mouse_Rjoy->SetValue(val);
}
}

View File

@ -0,0 +1,60 @@
/* JoystickConfiguration.h
* PCSX2 Dev Team
* 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* m_pan_joystick_config;
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_Rjoy; // Use mouse for right joystick
wxButton *m_bt_ok, *m_bt_cancel;
int m_pad_id;
// isForLeftJoystick -> true is for Left Joystick, false is for Right Joystick
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;
// 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

View File

@ -0,0 +1,104 @@
/* dialog.h
* PCSX2 Dev Team
* 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"
// 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
Set_all, // Set all buttons
Apply, // Apply modifications without exit
Ok, // Apply modifications and exit
Cancel // Exit without apply modificatons
};
#define BUTTONS_LENGHT 32 // numbers of buttons on the gamepad
#define UPDATE_TIME 5
#define DEFAULT_WIDTH 1000
#define DEFAULT_HEIGHT 740
class Dialog : public wxFrame
{
// Panels
opPanel* m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box
// Notebooks
wxNotebook* m_tab_gamepad; // Joysticks Tabs
// Buttons
wxButton* m_bt_gamepad[GAMEPAD_NUMBER][BUTTONS_LENGHT]; // Joystick button use to modify the button mapping
// Contain all simulated key
u32 m_simulatedKeys[GAMEPAD_NUMBER][MAX_KEYS];
// Timer
wxTimer m_time_update_gui;
// Check if the gui must display feddback image
bool m_pressed[GAMEPAD_NUMBER][NB_IMG];
// Map the key pressed with the feedback image id
std::map<u32,int> m_map_images[GAMEPAD_NUMBER];
// Frame
GamepadConfiguration* m_frm_gamepad_config; // Gamepad Configuration frame
JoystickConfiguration* m_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__

View File

@ -20,7 +20,6 @@
*/ */
#include <string.h> #include <string.h>
#include <gtk/gtk.h>
#include "GamePad.h" #include "GamePad.h"
#include "keyboard.h" #include "keyboard.h"
@ -134,7 +133,7 @@ void SaveConfig()
fprintf(f, "joy_pad_map = %d\n", conf->joyid_map); fprintf(f, "joy_pad_map = %d\n", conf->joyid_map);
fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity()); fprintf(f, "ff_intensity = %d\n", conf->get_ff_intensity());
for (int pad = 0; pad < 2; pad++) for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
{ {
for (int key = 0; key < MAX_KEYS; key++) for (int key = 0; key < MAX_KEYS; key++)
{ {
@ -143,7 +142,7 @@ void SaveConfig()
} }
map<u32,u32>::iterator it; map<u32,u32>::iterator it;
for (int pad = 0; pad < 2 ; pad++) for (int pad = 0; pad < GAMEPAD_NUMBER ; pad++)
for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it) for (it = conf->keysym_map[pad].begin(); it != conf->keysym_map[pad].end(); ++it)
fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second); fprintf(f, "PAD %d:KEYSYM 0x%x = %d\n", pad, it->first, it->second);
@ -182,7 +181,7 @@ void LoadConfig()
if (fscanf(f, "ff_intensity = %d\n", &value) == 0) goto error; if (fscanf(f, "ff_intensity = %d\n", &value) == 0) goto error;
conf->set_ff_intensity(value); conf->set_ff_intensity(value);
for (int pad = 0; pad < 2; pad++) for (int pad = 0; pad < GAMEPAD_NUMBER; pad++)
{ {
for (int key = 0; key < MAX_KEYS; key++) for (int key = 0; key < MAX_KEYS; key++)
{ {

View File

@ -172,7 +172,7 @@ EXPORT_C_(void) PADupdate(int pad)
// Actually PADupdate is always call with pad == 0. So you need to update both // Actually PADupdate is always call with pad == 0. So you need to update both
// pads -- Gregory // pads -- Gregory
for (int cpad = 0; cpad < 2; cpad++) { for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
// Poll keyboard/mouse event // Poll keyboard/mouse event
key_status->keyboard_state_acces(cpad); key_status->keyboard_state_acces(cpad);
PollForX11KeyboardInput(cpad); PollForX11KeyboardInput(cpad);

View File

@ -0,0 +1,247 @@
/* opPanel.cpp
* PCSX2 Dev Team
* 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"
#include "ImgHeader/arrow_up.h"
#include "ImgHeader/arrow_right.h"
#include "ImgHeader/arrow_bottom.h"
#include "ImgHeader/arrow_left.h"
opPanel::opPanel(wxWindow *parent,
wxWindowID id=wxID_ANY,
const wxPoint &pos=wxDefaultPosition,
const wxSize &size=wxDefaultSize
): wxPanel( parent, id, pos, size)
{
m_picture[img_background] = EmbeddedImage<res_dualshock2>().Get();
m_picture[img_start] = EmbeddedImage<res_start>().Get();
m_picture[img_select] = EmbeddedImage<res_select>().Get();
m_picture[img_analog] = EmbeddedImage<res_analog>().Get();
m_picture[img_dp_left] = EmbeddedImage<res_dp_left>().Get();
m_picture[img_dp_right] = EmbeddedImage<res_dp_right>().Get();
m_picture[img_dp_up] = EmbeddedImage<res_dp_up>().Get();
m_picture[img_dp_bottom] = EmbeddedImage<res_dp_bottom>().Get();
m_picture[img_square] = EmbeddedImage<res_square>().Get();
m_picture[img_circle] = EmbeddedImage<res_circle>().Get();
m_picture[img_cross] = EmbeddedImage<res_cross>().Get();
m_picture[img_triangle] = EmbeddedImage<res_triangle>().Get();
m_picture[img_l1] = EmbeddedImage<res_l1>().Get();
m_picture[img_l3] = EmbeddedImage<res_l3>().Get();
m_picture[img_l2] = EmbeddedImage<res_l2>().Get();
m_picture[img_r1] = EmbeddedImage<res_r1>().Get();
m_picture[img_r3] = EmbeddedImage<res_r3>().Get();
m_picture[img_r2] = EmbeddedImage<res_r2>().Get();
m_picture[img_left_cursor] = EmbeddedImage<res_joystick_cursor>().Get();
m_picture[img_right_cursor] = EmbeddedImage<res_joystick_cursor>().Get();
m_picture[img_l_arrow_up] = EmbeddedImage<res_arrow_up>().Get();
m_picture[img_l_arrow_right] = EmbeddedImage<res_arrow_right>().Get();
m_picture[img_l_arrow_bottom] = EmbeddedImage<res_arrow_bottom>().Get();
m_picture[img_l_arrow_left] = EmbeddedImage<res_arrow_left>().Get();
m_picture[img_r_arrow_up] = EmbeddedImage<res_arrow_up>().Get();
m_picture[img_r_arrow_right] = EmbeddedImage<res_arrow_right>().Get();
m_picture[img_r_arrow_bottom] = EmbeddedImage<res_arrow_bottom>().Get();
m_picture[img_r_arrow_left] = EmbeddedImage<res_arrow_left>().Get();
for(int i=0; i<NB_IMG; ++i)
{
m_show_image[i] = false;
HideImg(i);
}
ShowImg(img_background);
m_show_image[img_background] = true;
m_left_cursor_x = 0;
m_left_cursor_y = 0;
m_right_cursor_x = 0;
m_right_cursor_y = 0;
}
void opPanel::HideImg(int id)
{
if(id < NB_IMG)
{
m_show_image[id] = false;
Refresh();
}
}
void opPanel::ShowImg(int id)
{
if(id < NB_IMG)
{
m_show_image[id] = true;
Refresh();
}
}
void opPanel::MoveJoystick(int axe,int value)
{
if(axe == 0)
{
m_left_cursor_x = value*30/40000;
}
else if(axe == 1)
{
m_left_cursor_y = value*30/40000;
}
else if( axe == 2)
{
m_right_cursor_x = value*30/40000;
}
else
{
m_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);
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_l_arrow_up, temp_l_arrow_right,
temp_l_arrow_bottom, temp_l_arrow_left, temp_r_arrow_up, temp_r_arrow_right,
temp_r_arrow_bottom, temp_r_arrow_left;
temp_background.SelectObject(m_picture[img_background]);
temp_start.SelectObject(m_picture[img_start]);
temp_select.SelectObject(m_picture[img_select]);
temp_analog.SelectObject(m_picture[img_analog]);
temp_dp_left.SelectObject(m_picture[img_dp_left]);
temp_dp_right.SelectObject(m_picture[img_dp_right]);
temp_dp_up.SelectObject(m_picture[img_dp_up]);
temp_dp_bottom.SelectObject(m_picture[img_dp_bottom]);
temp_l1.SelectObject(m_picture[img_l1]);
temp_r1.SelectObject(m_picture[img_r1]);
temp_L3.SelectObject(m_picture[img_l3]);
temp_l2_2.SelectObject(m_picture[img_l2]);
temp_R3.SelectObject(m_picture[img_r3]);
temp_r2_2.SelectObject(m_picture[img_r2]);
temp_square.SelectObject(m_picture[img_square]);
temp_circle.SelectObject(m_picture[img_circle]);
temp_cross.SelectObject(m_picture[img_cross]);
temp_triangle.SelectObject(m_picture[img_triangle]);
temp_left_cursor.SelectObject(m_picture[img_left_cursor]);
temp_right_cursor.SelectObject(m_picture[img_right_cursor]);
temp_l_arrow_up.SelectObject(m_picture[img_l_arrow_up]);
temp_l_arrow_right.SelectObject(m_picture[img_l_arrow_right]);
temp_l_arrow_bottom.SelectObject(m_picture[img_l_arrow_bottom]);
temp_l_arrow_left.SelectObject(m_picture[img_l_arrow_left]);
temp_r_arrow_up.SelectObject(m_picture[img_r_arrow_up]);
temp_r_arrow_right.SelectObject(m_picture[img_r_arrow_right]);
temp_r_arrow_bottom.SelectObject(m_picture[img_r_arrow_bottom]);
temp_r_arrow_left.SelectObject(m_picture[img_r_arrow_left]);
if(m_show_image[img_background])
dc.Blit(wxPoint(0, 0), temp_background.GetSize(), &temp_background, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_start])
dc.Blit(wxPoint(526, 296), temp_start.GetSize(), &temp_start, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_select])
dc.Blit(wxPoint(450, 297), temp_select.GetSize(), &temp_select, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_analog])
dc.Blit(wxPoint(489, 358), temp_analog.GetSize(), &temp_analog, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_dp_left])
dc.Blit(wxPoint(334, 292), temp_dp_left.GetSize(), &temp_dp_left, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_dp_right])
dc.Blit(wxPoint(378, 292), temp_dp_right.GetSize(), &temp_dp_right, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_dp_up])
dc.Blit(wxPoint(358, 269), temp_dp_up.GetSize(), &temp_dp_up, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_dp_bottom])
dc.Blit(wxPoint(358, 312), temp_dp_bottom.GetSize(), &temp_dp_bottom, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l1])
dc.Blit(wxPoint(343, 186), temp_l1.GetSize(), &temp_l1, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r1])
dc.Blit(wxPoint(593, 186), temp_r1.GetSize(), &temp_r1, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l3])
dc.Blit(wxPoint(409, 344), temp_L3.GetSize(), &temp_L3, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l2])
dc.Blit(wxPoint(346, 158), temp_l2_2.GetSize(), &temp_l2_2, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r3])
dc.Blit(wxPoint(525, 344), temp_R3.GetSize(), &temp_R3, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r2])
dc.Blit(wxPoint(582, 158), temp_r2_2.GetSize(), &temp_r2_2, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_square])
dc.Blit(wxPoint(573, 287), temp_square.GetSize(), &temp_square, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_circle])
dc.Blit(wxPoint(647, 287), temp_circle.GetSize(), &temp_circle, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_cross])
dc.Blit(wxPoint(610, 324), temp_cross.GetSize(), &temp_cross, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_triangle])
dc.Blit(wxPoint(610, 250), temp_triangle.GetSize(), &temp_triangle, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_left_cursor])
dc.Blit(wxPoint(439+m_left_cursor_x, 374+m_left_cursor_y), temp_left_cursor.GetSize(), &temp_left_cursor, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_right_cursor])
dc.Blit(wxPoint(555+m_right_cursor_x, 374+m_right_cursor_y), temp_right_cursor.GetSize(), &temp_right_cursor, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l_arrow_up])
dc.Blit(wxPoint(433, 357), temp_l_arrow_up.GetSize(), &temp_l_arrow_up, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l_arrow_right])
dc.Blit(wxPoint(423, 368), temp_l_arrow_right.GetSize(), &temp_l_arrow_right, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l_arrow_bottom])
dc.Blit(wxPoint(433, 357), temp_l_arrow_bottom.GetSize(), &temp_l_arrow_bottom, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_l_arrow_left])
dc.Blit(wxPoint(423, 368), temp_l_arrow_left.GetSize(), &temp_l_arrow_left, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r_arrow_up])
dc.Blit(wxPoint(548, 357), temp_r_arrow_up.GetSize(), &temp_r_arrow_up, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r_arrow_right])
dc.Blit(wxPoint(539, 368), temp_r_arrow_right.GetSize(), &temp_r_arrow_right, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r_arrow_bottom])
dc.Blit(wxPoint(548, 357), temp_r_arrow_bottom.GetSize(), &temp_r_arrow_bottom, wxPoint(0, 0), wxCOPY, true);
if(m_show_image[img_r_arrow_left])
dc.Blit(wxPoint(539, 368), temp_r_arrow_left.GetSize(), &temp_r_arrow_left, wxPoint(0, 0), wxCOPY, true);
}

View File

@ -0,0 +1,77 @@
/* opPanel.h
* PCSX2 Dev Team
* 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
img_l_arrow_up,
img_l_arrow_right,
img_l_arrow_bottom,
img_l_arrow_left,
img_r_arrow_up,
img_r_arrow_right,
img_r_arrow_bottom,
img_r_arrow_left
};
#define NB_IMG 28
class opPanel : public wxPanel
{
wxBitmap m_picture[NB_IMG];
bool m_show_image[NB_IMG];
int m_left_cursor_x, m_left_cursor_y, m_right_cursor_x, m_right_cursor_y;
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__

View File

@ -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]); fprintf(stderr,"ERROR: Effect is not uploaded! %s, id is %d\n",SDL_GetError(),effects_id[0]);
} }
/** Effect for big motor **/ /** Effect for big motor **/
effects[1].type = SDL_HAPTIC_TRIANGLE; effects[1].type = SDL_HAPTIC_TRIANGLE;
effects_id[1] = SDL_HapticNewEffect(haptic, &effects[1]); effects_id[1] = SDL_HapticNewEffect(haptic, &effects[1]);
@ -236,18 +236,23 @@ void JoystickInfo::SaveState()
SetHatState(i, SDL_JoystickGetHat(joy, i)); SetHatState(i, SDL_JoystickGetHat(joy, i));
} }
void JoystickInfo::TestForce() bool JoystickInfo::TestForce(float strength=0.60)
{ {
#if SDL_MAJOR_VERSION >= 2 #if SDL_MAJOR_VERSION >= 2
// This code just use standard rumble to check that SDL handles the pad correctly! --3kinox // 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 ); 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 // 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()); fprintf(stderr,"ERROR: Rumble is not working! %s\n",SDL_GetError());
return false;
} }
#endif #endif
return true;
} }
bool JoystickInfo::PollButtons(u32 &pkey) bool JoystickInfo::PollButtons(u32 &pkey)

View File

@ -52,7 +52,7 @@ class JoystickInfo : GamePad
JoystickInfo(const JoystickInfo&); // copy constructor JoystickInfo(const JoystickInfo&); // copy constructor
JoystickInfo& operator=(const JoystickInfo&); // assignment JoystickInfo& operator=(const JoystickInfo&); // assignment
void Destroy(); void Destroy();
// opens handles to all possible joysticks // opens handles to all possible joysticks
static void EnumerateJoysticks(vector<GamePad*>& vjoysticks); static void EnumerateJoysticks(vector<GamePad*>& vjoysticks);
@ -61,7 +61,7 @@ class JoystickInfo : GamePad
bool Init(int id); // opens a handle and gets information bool Init(int id); // opens a handle and gets information
void TestForce(); bool TestForce(float);
bool PollButtons(u32 &pkey); bool PollButtons(u32 &pkey);
bool PollAxes(u32 &pkey); bool PollAxes(u32 &pkey);

View File

@ -52,7 +52,7 @@ extern int button_to_key(int button_id);
extern int axis_to_key(int full_axis, int sign, int axis_id); extern int axis_to_key(int full_axis, int sign, int axis_id);
extern int hat_to_key(int dir, int axis_id); extern int hat_to_key(int dir, int axis_id);
extern int PadEnum[2][2]; //extern int PadEnum[2][2]; // never used
class PADconf class PADconf
{ {
@ -71,14 +71,14 @@ class PADconf
u16 sixaxis_usb :1; u16 sixaxis_usb :1;
u16 sixaxis_pressure :1; u16 sixaxis_pressure :1;
u16 _free : 7; // The 8 remaining bits are unused, do what you wish with them ;) u16 _free : 7; // The 8 remaining bits are unused, do what you wish with them ;)
} pad_options[2]; // One for each pads } pad_options[GAMEPAD_NUMBER]; // One for each pads
u32 packed_options; // Only first 8 bits of each 16 bits series are really used, rest is padding u32 packed_options; // Only first 8 bits of each 16 bits series are really used, rest is padding
}; };
u32 keys[2][MAX_KEYS]; u32 keys[GAMEPAD_NUMBER][MAX_KEYS];
u32 log; u32 log;
u32 joyid_map; u32 joyid_map;
map<u32,u32> keysym_map[2]; map<u32,u32> keysym_map[GAMEPAD_NUMBER];
PADconf() { init(); } PADconf() { init(); }
@ -87,8 +87,11 @@ class PADconf
log = packed_options = joyid_map = 0; log = packed_options = joyid_map = 0;
ff_intensity = 0x7FFF; // set it at max value by default ff_intensity = 0x7FFF; // set it at max value by default
sensibility = 500; sensibility = 500;
for (int pad = 0; pad < 2 ; pad++) for (int pad = 0; pad < GAMEPAD_NUMBER ; pad++)
{
keysym_map[pad].clear(); keysym_map[pad].clear();
set_joyid((u32)pad, (u32)pad); // define id mapping for each gamepad
}
} }
void set_joyid(u32 pad, u32 joy_id) { void set_joyid(u32 pad, u32 joy_id) {
@ -101,7 +104,7 @@ class PADconf
int shift = 8 * pad; int shift = 8 * pad;
return ((joyid_map >> shift) & 0xFF); return ((joyid_map >> shift) & 0xFF);
} }
/** /**
* Return (a copy of) private memner ff_instensity * Return (a copy of) private memner ff_instensity
**/ **/
@ -116,7 +119,7 @@ class PADconf
**/ **/
void set_ff_intensity(u32 new_intensity) 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; ff_intensity = new_intensity;
} }

View File

@ -260,7 +260,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN: case WM_KEYDOWN:
if (lParam & 0x40000000) return TRUE; if (lParam & 0x40000000) return TRUE;
for (int pad = 0; pad < 2; ++pad) for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
{ {
for (int i = 0; i < MAX_KEYS; i++) for (int i = 0; i < MAX_KEYS; i++)
{ {
@ -277,7 +277,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break; break;
case WM_KEYUP: case WM_KEYUP:
for (int pad = 0; pad < 2; ++pad) for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
{ {
for (int i = 0; i < MAX_KEYS; i++) for (int i = 0; i < MAX_KEYS; i++)
{ {
@ -304,7 +304,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return GSwndProc(hWnd, msg, wParam, lParam); return GSwndProc(hWnd, msg, wParam, lParam);
} }
for (int pad = 0; pad < 2; ++pad) for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
key_status->commit_status(pad); key_status->commit_status(pad);
return TRUE; return TRUE;

View File

@ -47,9 +47,10 @@ bool toggleAutoRepeat = false;
const u32 version = PS2E_PAD_VERSION; const u32 version = PS2E_PAD_VERSION;
const u32 revision = 1; 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}}; // Useless variable ...
//int PadEnum[2][2] = {{0, 2}, {1, 3}};
u8 stdpar[2][20] = { u8 stdpar[2][20] = {
{0xff, 0x5a, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, {0xff, 0x5a, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80,

View File

@ -22,6 +22,8 @@
#ifndef __PAD_H__ #ifndef __PAD_H__
#define __PAD_H__ #define __PAD_H__
#define GAMEPAD_NUMBER 2 // numbers of gamepad
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <queue> #include <queue>
@ -97,30 +99,30 @@ enum PadCommands
enum gamePadValues enum gamePadValues
{ {
PAD_L2 = 0, PAD_L2 = 0, // L2 button
PAD_R2, PAD_R2, // R2 button
PAD_L1, PAD_L1, // L1 button
PAD_R1, PAD_R1, // R1 button
PAD_TRIANGLE, PAD_TRIANGLE, // Triangle button ▲
PAD_CIRCLE, PAD_CIRCLE, // Circle button ●
PAD_CROSS, PAD_CROSS, // Cross button ✖
PAD_SQUARE, PAD_SQUARE, // Square button ■
PAD_SELECT, PAD_SELECT, // Select button
PAD_L3, PAD_L3, // Left joystick button (L3)
PAD_R3, PAD_R3, // Right joystick button (R3)
PAD_START, PAD_START, // Start button
PAD_UP, PAD_UP, // Directional pad ↑
PAD_RIGHT, PAD_RIGHT, // Directional pad →
PAD_DOWN, PAD_DOWN, // Directional pad ↓
PAD_LEFT, PAD_LEFT, // Directional pad ←
PAD_L_UP, PAD_L_UP, // Left joystick (Up) ↑
PAD_L_RIGHT, PAD_L_RIGHT, // Left joystick (Right) →
PAD_L_DOWN, PAD_L_DOWN, // Left joystick (Down) ↓
PAD_L_LEFT, PAD_L_LEFT, // Left joystick (Left) ←
PAD_R_UP, PAD_R_UP, // Right joystick (Up) ↑
PAD_R_RIGHT, PAD_R_RIGHT, // Right joystick (Right) →
PAD_R_DOWN, PAD_R_DOWN, // Right joystick (Down) ↓
PAD_R_LEFT PAD_R_LEFT // Right joystick (Left) ←
}; };
extern keyEvent event; extern keyEvent event;