InputCommon and nJoy: Moved functions to InputCommon, to be shared with the Wiimote plugin
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2147 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
44370518a3
commit
c6b4f5c819
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Version="9,00"
|
||||
Name="InputCommon"
|
||||
ProjectGUID="{C7E5D50A-2916-464B-86A7-E10B3CC88ADA}"
|
||||
RootNamespace="VideoCommon"
|
||||
|
@ -175,7 +175,7 @@
|
|||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc"
|
||||
AdditionalIncludeDirectories="..\..\..\Externals\SDL\include;../../Core/Common/Src;../../PluginSpecs;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\wxWidgets\lib\vc_lib\msw;..\..\..\Externals\wxWidgets\include\msvc"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_SECURE_SCL=0;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
|
@ -411,6 +411,14 @@
|
|||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\Src\Configuration.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Configuration.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Event.hpp"
|
||||
>
|
||||
|
@ -435,6 +443,22 @@
|
|||
RelativePath=".\Src\SConscript"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\SDL.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\SDL.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XInput.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XInput.h"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Project description
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Name: SDL Input
|
||||
// Description: Common SDL Input Functions
|
||||
//
|
||||
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Licensetype: GNU General Public License (GPL)
|
||||
//
|
||||
// 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, version 2.0.
|
||||
//
|
||||
// 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 2.0 for more details.
|
||||
//
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#define _SDL_MAIN_ // Avoid certain declarations in SDL.h
|
||||
#include "SDL.h" // Local
|
||||
#include "XInput.h"
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
namespace InputCommon
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Definitions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Search attached devices. Populate joyinfo for all attached physical devices.
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
// Load config
|
||||
#ifdef _DEBUG
|
||||
DEBUG_INIT();
|
||||
#endif
|
||||
|
||||
/* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need
|
||||
the SDL_INIT_VIDEO flag to */
|
||||
if (!SDL_WasInit(0))
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
|
||||
{
|
||||
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
fprintf(pFile, "Scanning for devices\n");
|
||||
fprintf(pFile, "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n");
|
||||
#endif
|
||||
|
||||
// Get device status
|
||||
int numjoy = SDL_NumJoysticks();
|
||||
for (int i = 0; i < numjoy; i++ )
|
||||
{
|
||||
CONTROLLER_INFO Tmp;
|
||||
|
||||
Tmp.joy = SDL_JoystickOpen(i);
|
||||
Tmp.ID = i;
|
||||
Tmp.NumAxes = SDL_JoystickNumAxes(Tmp.joy);
|
||||
Tmp.NumButtons = SDL_JoystickNumButtons(Tmp.joy);
|
||||
Tmp.NumBalls = SDL_JoystickNumBalls(Tmp.joy);
|
||||
Tmp.NumHats = SDL_JoystickNumHats(Tmp.joy);
|
||||
Tmp.Name = SDL_JoystickName(i);
|
||||
|
||||
// Check if the device is okay
|
||||
if ( Tmp.NumAxes == 0
|
||||
&& Tmp.NumBalls == 0
|
||||
&& Tmp.NumButtons == 0
|
||||
&& Tmp.NumHats == 0
|
||||
)
|
||||
{
|
||||
Tmp.Good = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_NumGoodPads++;
|
||||
Tmp.Good = true;
|
||||
}
|
||||
|
||||
_joyinfo.push_back(Tmp);
|
||||
|
||||
#ifdef _DEBUG
|
||||
fprintf(pFile, "ID: %d\n", i);
|
||||
fprintf(pFile, "Name: %s\n", joyinfo[i].Name);
|
||||
fprintf(pFile, "Buttons: %d\n", joyinfo[i].NumButtons);
|
||||
fprintf(pFile, "Axes: %d\n", joyinfo[i].NumAxes);
|
||||
fprintf(pFile, "Hats: %d\n", joyinfo[i].NumHats);
|
||||
fprintf(pFile, "Balls: %d\n\n", joyinfo[i].NumBalls);
|
||||
#endif
|
||||
|
||||
// We have now read the values we need so we close the device
|
||||
if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
|
||||
}
|
||||
|
||||
_NumPads = _joyinfo.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
////////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Supporting functions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Read current joystick status
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
The value PadMapping[].buttons[] is the number of the assigned joypad button,
|
||||
PadState[].buttons[] is the status of the button, it becomes 0 (no pressed) or 1 (pressed) */
|
||||
|
||||
|
||||
// Read buttons status. Called from GetJoyState().
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ReadButton(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int button, int NumButtons)
|
||||
{
|
||||
int ctl_button = _PadMapping.buttons[button];
|
||||
if (ctl_button < NumButtons)
|
||||
{
|
||||
_PadState.buttons[button] = SDL_JoystickGetButton(_PadState.joy, ctl_button);
|
||||
}
|
||||
}
|
||||
|
||||
// Request joystick state.
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Called from: PAD_GetStatus()
|
||||
Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input value "controller" is
|
||||
for a virtual controller 0 to 3. */
|
||||
void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int controller, int NumButtons)
|
||||
{
|
||||
// Update the gamepad status
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
// Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here.
|
||||
_PadState.axis[CTL_MAIN_X] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.axis[CTL_MAIN_X]);
|
||||
_PadState.axis[CTL_MAIN_Y] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.axis[CTL_MAIN_Y]);
|
||||
_PadState.axis[CTL_SUB_X] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.axis[CTL_SUB_X]);
|
||||
_PadState.axis[CTL_SUB_Y] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.axis[CTL_SUB_Y]);
|
||||
|
||||
// Update the analog trigger axis values
|
||||
#ifdef _WIN32
|
||||
if (_PadMapping.triggertype == CTL_TRIGGER_SDL)
|
||||
{
|
||||
#endif
|
||||
// If we are using SDL analog triggers the buttons have to be mapped as 1000 or up, otherwise they are not used
|
||||
if(_PadMapping.buttons[CTL_L_SHOULDER] >= 1000) _PadState.axis[CTL_L_SHOULDER] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.buttons[CTL_L_SHOULDER] - 1000); else _PadState.axis[CTL_L_SHOULDER] = 0;
|
||||
if(_PadMapping.buttons[CTL_R_SHOULDER] >= 1000) _PadState.axis[CTL_R_SHOULDER] = SDL_JoystickGetAxis(_PadState.joy, _PadMapping.buttons[CTL_R_SHOULDER] - 1000); else _PadState.axis[CTL_R_SHOULDER] = 0;
|
||||
#ifdef _WIN32
|
||||
}
|
||||
else
|
||||
{
|
||||
_PadState.axis[CTL_L_SHOULDER] = XInput::GetXI(0, _PadMapping.buttons[CTL_L_SHOULDER] - 1000);
|
||||
_PadState.axis[CTL_R_SHOULDER] = XInput::GetXI(0, _PadMapping.buttons[CTL_R_SHOULDER] - 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update button states to on or off
|
||||
ReadButton(_PadState, _PadMapping, CTL_L_SHOULDER, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_R_SHOULDER, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_A_BUTTON, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_B_BUTTON, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_X_BUTTON, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_Y_BUTTON, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_Z_TRIGGER, NumButtons);
|
||||
ReadButton(_PadState, _PadMapping, CTL_START, NumButtons);
|
||||
|
||||
//
|
||||
if (_PadMapping.halfpress < NumButtons)
|
||||
_PadState.halfpress = SDL_JoystickGetButton(_PadState.joy, _PadMapping.halfpress);
|
||||
|
||||
// Check if we have an analog or digital joypad
|
||||
if (_PadMapping.controllertype == CTL_DPAD_HAT)
|
||||
{
|
||||
_PadState.dpad = SDL_JoystickGetHat(_PadState.joy, _PadMapping.dpad);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Only do this if the assigned button is in range (to allow for the current way of saving keyboard
|
||||
keys in the same array) */
|
||||
if(_PadMapping.dpad2[CTL_D_PAD_UP] <= NumButtons)
|
||||
_PadState.dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_UP]);
|
||||
if(_PadMapping.dpad2[CTL_D_PAD_DOWN] <= NumButtons)
|
||||
_PadState.dpad2[CTL_D_PAD_DOWN] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_DOWN]);
|
||||
if(_PadMapping.dpad2[CTL_D_PAD_LEFT] <= NumButtons)
|
||||
_PadState.dpad2[CTL_D_PAD_LEFT] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_LEFT]);
|
||||
if(_PadMapping.dpad2[CTL_D_PAD_RIGHT] <= NumButtons)
|
||||
_PadState.dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(_PadState.joy, _PadMapping.dpad2[CTL_D_PAD_RIGHT]);
|
||||
}
|
||||
|
||||
/* Debugging
|
||||
Console::ClearScreen();
|
||||
Console::Print(
|
||||
"Controller and handle: %i %i\n"
|
||||
|
||||
"Triggers:%i %i %i %i %i | HalfPress: %i Mapping: %i\n",
|
||||
|
||||
controller, (int)_PadState.joy,
|
||||
|
||||
_PadMapping.triggertype,
|
||||
_PadMapping.buttons[CTL_L_SHOULDER], _PadMapping.buttons[CTL_R_SHOULDER],
|
||||
_PadState.axis[CTL_L_SHOULDER], _PadState.axis[CTL_R_SHOULDER],
|
||||
|
||||
_PadState.halfpress, _PadMapping.halfpress
|
||||
); */
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
} // InputCommon
|
|
@ -0,0 +1,168 @@
|
|||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Project description
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
// Name: SDL Input
|
||||
// Description: Common SDL Input Functions
|
||||
//
|
||||
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
|
||||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Licensetype: GNU General Public License (GPL)
|
||||
//
|
||||
// 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, version 2.0.
|
||||
//
|
||||
// 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 2.0 for more details.
|
||||
//
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
//
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _SDL_h
|
||||
#define _SDL_h
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
#include <iostream> // System
|
||||
#include <vector>
|
||||
|
||||
#include <SDL.h> // Externals
|
||||
|
||||
#include "Common.h" // Common
|
||||
////////////////////////////
|
||||
|
||||
|
||||
namespace InputCommon
|
||||
{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Structures
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
CONTROLLER_STATE buttons (PadState) = 0 or 1
|
||||
CONTROLLER_MAPPING buttons (joystick) = 0 or 1, 2, 3, 4, a certain joypad button
|
||||
|
||||
Please remember: The axis limit is hardcoded here, if you allow more axises (for
|
||||
example for analog A and B buttons) you must first incrase the size of the axis array
|
||||
size here
|
||||
*/
|
||||
struct CONTROLLER_STATE // GC PAD INFO/STATE
|
||||
{
|
||||
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
int dpad; // Automatic SDL D-Pad (8 directions + neutral)
|
||||
int dpad2[4]; // D-pad using buttons
|
||||
int axis[6]; // 2 x 2 Axes (Main & Sub)
|
||||
int halfpress; // Halfpress... you know, like not fully pressed ;)...
|
||||
SDL_Joystick *joy; // SDL joystick device
|
||||
};
|
||||
|
||||
struct CONTROLLER_MAPPING // GC PAD MAPPING
|
||||
{
|
||||
int buttons[8]; // (See above)
|
||||
int dpad; // (See above)
|
||||
int dpad2[4]; // (See above)
|
||||
int axis[6]; // (See above)
|
||||
int halfpress; // (See above)
|
||||
int enabled; // Pad attached?
|
||||
int deadzone; // Deadzone... what else?
|
||||
int ID; // SDL joystick device ID
|
||||
int controllertype; // Hat: Hat or custom buttons
|
||||
int triggertype; // Triggers range
|
||||
std::string SDiagonal;
|
||||
bool bSquareToCircle;
|
||||
int eventnum; // Linux Event Number, Can't be found dynamically yet
|
||||
};
|
||||
|
||||
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
|
||||
{
|
||||
int NumAxes; // Amount of Axes
|
||||
int NumButtons; // Amount of Buttons
|
||||
int NumBalls; // Amount of Balls
|
||||
int NumHats; // Amount of Hats (POV)
|
||||
std::string Name; // Joypad/stickname
|
||||
int ID; // SDL joystick device ID
|
||||
bool Good; // Pad is good (it has at least one button or axis)
|
||||
SDL_Joystick *joy; // SDL joystick device
|
||||
};
|
||||
enum
|
||||
{
|
||||
// CTL_L_SHOULDER and CTL_R_SHOULDER = 0 and 1
|
||||
CTL_MAIN_X = 2,
|
||||
CTL_MAIN_Y,
|
||||
CTL_SUB_X,
|
||||
CTL_SUB_Y
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CTL_L_SHOULDER = 0,
|
||||
CTL_R_SHOULDER,
|
||||
CTL_A_BUTTON,
|
||||
CTL_B_BUTTON,
|
||||
CTL_X_BUTTON,
|
||||
CTL_Y_BUTTON,
|
||||
CTL_Z_TRIGGER,
|
||||
CTL_START
|
||||
};
|
||||
// DPad Type
|
||||
enum
|
||||
{
|
||||
CTL_DPAD_HAT = 0, // Automatically use the first hat that SDL finds
|
||||
CTL_DPAD_CUSTOM // Custom directional pad settings
|
||||
};
|
||||
// Trigger Type
|
||||
enum
|
||||
{
|
||||
CTL_TRIGGER_SDL = 0, //
|
||||
CTL_TRIGGER_XINPUT // The XBox 360 pad
|
||||
};
|
||||
enum
|
||||
{
|
||||
CTL_D_PAD_UP = 0,
|
||||
CTL_D_PAD_DOWN,
|
||||
CTL_D_PAD_LEFT,
|
||||
CTL_D_PAD_RIGHT
|
||||
};
|
||||
// Button type for the configuration
|
||||
enum
|
||||
{
|
||||
CTL_AXIS = 0,
|
||||
CTL_HAT,
|
||||
CTL_BUTTON,
|
||||
CTL_KEY
|
||||
};
|
||||
// XInput buttons
|
||||
enum
|
||||
{
|
||||
XI_TRIGGER_L = 0,
|
||||
XI_TRIGGER_R
|
||||
};
|
||||
////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &NumPads, int &NumGoodPads);
|
||||
void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int controller, int NumButtons);
|
||||
|
||||
#ifndef _SDL_MAIN_
|
||||
|
||||
#endif
|
||||
////////////////////////////
|
||||
|
||||
|
||||
} // InputCommon
|
||||
|
||||
|
||||
#endif // _SDL_h
|
|
@ -37,7 +37,7 @@
|
|||
#include <windows.h>
|
||||
#include <XInput.h> // XInput API
|
||||
|
||||
#include "nJoy.h" // Local
|
||||
#include "SDL.h" // Local
|
||||
///////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -103,10 +103,10 @@ int GetXI(int Controller, int Button)
|
|||
|
||||
switch(Button)
|
||||
{
|
||||
case XI_TRIGGER_L:
|
||||
case InputCommon::XI_TRIGGER_L:
|
||||
return g_Controllers[0].state.Gamepad.bLeftTrigger;
|
||||
|
||||
case XI_TRIGGER_R:
|
||||
case InputCommon::XI_TRIGGER_R:
|
||||
return g_Controllers[0].state.Gamepad.bRightTrigger;
|
||||
|
||||
default:
|
|
@ -119,6 +119,7 @@ EndProject
|
|||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_nJoy_SDL", "Plugins\Plugin_nJoy_SDL\Plugin_nJoy_SDL.vcproj", "{521498BE-6089-4780-8223-E67C22F4E068}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
|
||||
{C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}
|
||||
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
|
||||
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
|
||||
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
|
||||
|
|
|
@ -522,14 +522,6 @@
|
|||
RelativePath=".\Src\Rumble.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XInput.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\XInput.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="GUI"
|
||||
|
|
|
@ -141,23 +141,23 @@ void Config::Save(int Slot)
|
|||
SectionName = joyinfo[PadMapping[i].ID].Name;
|
||||
}
|
||||
|
||||
file.Set(SectionName.c_str(), "l_shoulder", PadMapping[i].buttons[CTL_L_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "r_shoulder", PadMapping[i].buttons[CTL_R_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "a_button", PadMapping[i].buttons[CTL_A_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "b_button", PadMapping[i].buttons[CTL_B_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "x_button", PadMapping[i].buttons[CTL_X_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "y_button", PadMapping[i].buttons[CTL_Y_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "z_trigger", PadMapping[i].buttons[CTL_Z_TRIGGER]);
|
||||
file.Set(SectionName.c_str(), "start_button", PadMapping[i].buttons[CTL_START]);
|
||||
file.Set(SectionName.c_str(), "l_shoulder", PadMapping[i].buttons[InputCommon::CTL_L_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "r_shoulder", PadMapping[i].buttons[InputCommon::CTL_R_SHOULDER]);
|
||||
file.Set(SectionName.c_str(), "a_button", PadMapping[i].buttons[InputCommon::CTL_A_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "b_button", PadMapping[i].buttons[InputCommon::CTL_B_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "x_button", PadMapping[i].buttons[InputCommon::CTL_X_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "y_button", PadMapping[i].buttons[InputCommon::CTL_Y_BUTTON]);
|
||||
file.Set(SectionName.c_str(), "z_trigger", PadMapping[i].buttons[InputCommon::CTL_Z_TRIGGER]);
|
||||
file.Set(SectionName.c_str(), "start_button", PadMapping[i].buttons[InputCommon::CTL_START]);
|
||||
file.Set(SectionName.c_str(), "dpad", PadMapping[i].dpad);
|
||||
file.Set(SectionName.c_str(), "dpad_up", PadMapping[i].dpad2[CTL_D_PAD_UP]);
|
||||
file.Set(SectionName.c_str(), "dpad_down", PadMapping[i].dpad2[CTL_D_PAD_DOWN]);
|
||||
file.Set(SectionName.c_str(), "dpad_left", PadMapping[i].dpad2[CTL_D_PAD_LEFT]);
|
||||
file.Set(SectionName.c_str(), "dpad_right", PadMapping[i].dpad2[CTL_D_PAD_RIGHT]);
|
||||
file.Set(SectionName.c_str(), "main_x", PadMapping[i].axis[CTL_MAIN_X]);
|
||||
file.Set(SectionName.c_str(), "main_y", PadMapping[i].axis[CTL_MAIN_Y]);
|
||||
file.Set(SectionName.c_str(), "sub_x", PadMapping[i].axis[CTL_SUB_X]);
|
||||
file.Set(SectionName.c_str(), "sub_y", PadMapping[i].axis[CTL_SUB_Y]);
|
||||
file.Set(SectionName.c_str(), "dpad_up", PadMapping[i].dpad2[InputCommon::CTL_D_PAD_UP]);
|
||||
file.Set(SectionName.c_str(), "dpad_down", PadMapping[i].dpad2[InputCommon::CTL_D_PAD_DOWN]);
|
||||
file.Set(SectionName.c_str(), "dpad_left", PadMapping[i].dpad2[InputCommon::CTL_D_PAD_LEFT]);
|
||||
file.Set(SectionName.c_str(), "dpad_right", PadMapping[i].dpad2[InputCommon::CTL_D_PAD_RIGHT]);
|
||||
file.Set(SectionName.c_str(), "main_x", PadMapping[i].axis[InputCommon::CTL_MAIN_X]);
|
||||
file.Set(SectionName.c_str(), "main_y", PadMapping[i].axis[InputCommon::CTL_MAIN_Y]);
|
||||
file.Set(SectionName.c_str(), "sub_x", PadMapping[i].axis[InputCommon::CTL_SUB_X]);
|
||||
file.Set(SectionName.c_str(), "sub_y", PadMapping[i].axis[InputCommon::CTL_SUB_Y]);
|
||||
|
||||
file.Set(SectionName.c_str(), "deadzone", PadMapping[i].deadzone);
|
||||
file.Set(SectionName.c_str(), "halfpress", PadMapping[i].halfpress);
|
||||
|
@ -228,23 +228,23 @@ void Config::Load(bool ChangePad, bool ChangeSaveByID)
|
|||
SectionName = joyinfo[PadMapping[i].ID].Name;
|
||||
}
|
||||
|
||||
file.Get(SectionName.c_str(), "l_shoulder", &PadMapping[i].buttons[CTL_L_SHOULDER], 4);
|
||||
file.Get(SectionName.c_str(), "r_shoulder", &PadMapping[i].buttons[CTL_R_SHOULDER], 5);
|
||||
file.Get(SectionName.c_str(), "a_button", &PadMapping[i].buttons[CTL_A_BUTTON], 0);
|
||||
file.Get(SectionName.c_str(), "b_button", &PadMapping[i].buttons[CTL_B_BUTTON], 1);
|
||||
file.Get(SectionName.c_str(), "x_button", &PadMapping[i].buttons[CTL_X_BUTTON], 3);
|
||||
file.Get(SectionName.c_str(), "y_button", &PadMapping[i].buttons[CTL_Y_BUTTON], 2);
|
||||
file.Get(SectionName.c_str(), "z_trigger", &PadMapping[i].buttons[CTL_Z_TRIGGER], 7);
|
||||
file.Get(SectionName.c_str(), "start_button", &PadMapping[i].buttons[CTL_START], 9);
|
||||
file.Get(SectionName.c_str(), "l_shoulder", &PadMapping[i].buttons[InputCommon::CTL_L_SHOULDER], 4);
|
||||
file.Get(SectionName.c_str(), "r_shoulder", &PadMapping[i].buttons[InputCommon::CTL_R_SHOULDER], 5);
|
||||
file.Get(SectionName.c_str(), "a_button", &PadMapping[i].buttons[InputCommon::CTL_A_BUTTON], 0);
|
||||
file.Get(SectionName.c_str(), "b_button", &PadMapping[i].buttons[InputCommon::CTL_B_BUTTON], 1);
|
||||
file.Get(SectionName.c_str(), "x_button", &PadMapping[i].buttons[InputCommon::CTL_X_BUTTON], 3);
|
||||
file.Get(SectionName.c_str(), "y_button", &PadMapping[i].buttons[InputCommon::CTL_Y_BUTTON], 2);
|
||||
file.Get(SectionName.c_str(), "z_trigger", &PadMapping[i].buttons[InputCommon::CTL_Z_TRIGGER], 7);
|
||||
file.Get(SectionName.c_str(), "start_button", &PadMapping[i].buttons[InputCommon::CTL_START], 9);
|
||||
file.Get(SectionName.c_str(), "dpad", &PadMapping[i].dpad, 0);
|
||||
file.Get(SectionName.c_str(), "dpad_up", &PadMapping[i].dpad2[CTL_D_PAD_UP], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_down", &PadMapping[i].dpad2[CTL_D_PAD_DOWN], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_left", &PadMapping[i].dpad2[CTL_D_PAD_LEFT], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_right", &PadMapping[i].dpad2[CTL_D_PAD_RIGHT], 0);
|
||||
file.Get(SectionName.c_str(), "main_x", &PadMapping[i].axis[CTL_MAIN_X], 0);
|
||||
file.Get(SectionName.c_str(), "main_y", &PadMapping[i].axis[CTL_MAIN_Y], 1);
|
||||
file.Get(SectionName.c_str(), "sub_x", &PadMapping[i].axis[CTL_SUB_X], 2);
|
||||
file.Get(SectionName.c_str(), "sub_y", &PadMapping[i].axis[CTL_SUB_Y], 3);
|
||||
file.Get(SectionName.c_str(), "dpad_up", &PadMapping[i].dpad2[InputCommon::CTL_D_PAD_UP], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_down", &PadMapping[i].dpad2[InputCommon::CTL_D_PAD_DOWN], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_left", &PadMapping[i].dpad2[InputCommon::CTL_D_PAD_LEFT], 0);
|
||||
file.Get(SectionName.c_str(), "dpad_right", &PadMapping[i].dpad2[InputCommon::CTL_D_PAD_RIGHT], 0);
|
||||
file.Get(SectionName.c_str(), "main_x", &PadMapping[i].axis[InputCommon::CTL_MAIN_X], 0);
|
||||
file.Get(SectionName.c_str(), "main_y", &PadMapping[i].axis[InputCommon::CTL_MAIN_Y], 1);
|
||||
file.Get(SectionName.c_str(), "sub_x", &PadMapping[i].axis[InputCommon::CTL_SUB_X], 2);
|
||||
file.Get(SectionName.c_str(), "sub_y", &PadMapping[i].axis[InputCommon::CTL_SUB_Y], 3);
|
||||
|
||||
file.Get(SectionName.c_str(), "deadzone", &PadMapping[i].deadzone, 9);
|
||||
file.Get(SectionName.c_str(), "halfpress", &PadMapping[i].halfpress, -1);
|
||||
|
|
|
@ -70,8 +70,10 @@ void ConfigBox::PadGetStatus()
|
|||
int PhysicalDevice = PadMapping[notebookpage].ID;
|
||||
int TriggerType = PadMapping[notebookpage].triggertype;
|
||||
|
||||
// Get pad status
|
||||
GetJoyState(notebookpage);
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
if (!g_Config.bCheckFocus && IsFocus())
|
||||
InputCommon::GetJoyState(PadState[notebookpage], PadMapping[notebookpage], notebookpage, joyinfo[PadMapping[notebookpage].ID].NumButtons);
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
// Analog stick
|
||||
|
@ -81,8 +83,8 @@ void ConfigBox::PadGetStatus()
|
|||
//int deadzone2 = (int)(((float)(-128.00/100.00)) * (float)(PadMapping[_numPAD].deadzone+1));
|
||||
|
||||
// Get original values
|
||||
int main_x = PadState[notebookpage].axis[CTL_MAIN_X];
|
||||
int main_y = PadState[notebookpage].axis[CTL_MAIN_Y];
|
||||
int main_x = PadState[notebookpage].axis[InputCommon::CTL_MAIN_X];
|
||||
int main_y = PadState[notebookpage].axis[InputCommon::CTL_MAIN_Y];
|
||||
//int sub_x = (PadState[_numPAD].axis[CTL_SUB_X];
|
||||
//int sub_y = -(PadState[_numPAD].axis[CTL_SUB_Y];
|
||||
|
||||
|
@ -138,11 +140,11 @@ void ConfigBox::PadGetStatus()
|
|||
m_JoyShoulderR[notebookpage]->GetValue().ToLong(&Right);
|
||||
|
||||
// Get the trigger values
|
||||
int TriggerLeft = PadState[notebookpage].axis[CTL_L_SHOULDER];
|
||||
int TriggerRight = PadState[notebookpage].axis[CTL_R_SHOULDER];
|
||||
int TriggerLeft = PadState[notebookpage].axis[InputCommon::CTL_L_SHOULDER];
|
||||
int TriggerRight = PadState[notebookpage].axis[InputCommon::CTL_R_SHOULDER];
|
||||
|
||||
// Convert the triggers values
|
||||
if (PadMapping[notebookpage].triggertype == CTL_TRIGGER_SDL)
|
||||
if (PadMapping[notebookpage].triggertype == InputCommon::CTL_TRIGGER_SDL)
|
||||
{
|
||||
TriggerLeft = Pad_Convert(TriggerLeft);
|
||||
TriggerRight = Pad_Convert(TriggerRight);
|
||||
|
@ -153,8 +155,8 @@ void ConfigBox::PadGetStatus()
|
|||
if(Right < 1000) TriggerRight = 0;
|
||||
|
||||
// Get the digital values
|
||||
if(Left < 1000 && PadState[notebookpage].buttons[CTL_L_SHOULDER]) TriggerLeft = TriggerValue;
|
||||
if(Right < 1000 && PadState[notebookpage].buttons[CTL_R_SHOULDER]) TriggerRight = TriggerValue;
|
||||
if(Left < 1000 && PadState[notebookpage].buttons[InputCommon::CTL_L_SHOULDER]) TriggerLeft = TriggerValue;
|
||||
if(Right < 1000 && PadState[notebookpage].buttons[InputCommon::CTL_R_SHOULDER]) TriggerRight = TriggerValue;
|
||||
|
||||
m_TStatusTriggers[notebookpage]->SetLabel(wxString::Format(
|
||||
wxT("Left:%03i Right:%03i"),
|
||||
|
@ -233,7 +235,7 @@ std::string ShowStatus(int VirtualController)
|
|||
//PadState[PadMapping[0].ID].joy, PadState[PadMapping[1].ID].joy, PadState[PadMapping[2].ID].joy, PadState[PadMapping[3].ID].joy,
|
||||
|
||||
#ifdef _WIN32
|
||||
XInput::IsConnected(0), XInput::GetXI(0, XI_TRIGGER_L), XInput::GetXI(0, XI_TRIGGER_R),
|
||||
XInput::IsConnected(0), XInput::GetXI(0, InputCommon::XI_TRIGGER_L), XInput::GetXI(0, InputCommon::XI_TRIGGER_R),
|
||||
#endif
|
||||
StrAxes.c_str(), StrHats.c_str(), StrBut.c_str(),
|
||||
Axes, Balls, Hats, Buttons
|
||||
|
|
|
@ -475,7 +475,7 @@ void ConfigBox::UpdateGUI(int _notebookpage)
|
|||
UpdateGUIKeys(_notebookpage);
|
||||
|
||||
// Collect status
|
||||
bool Hat = (PadMapping[_notebookpage].controllertype == CTL_DPAD_HAT);
|
||||
bool Hat = (PadMapping[_notebookpage].controllertype == InputCommon::CTL_DPAD_HAT);
|
||||
long Left, Right;
|
||||
m_JoyShoulderL[_notebookpage]->GetValue().ToLong(&Left);
|
||||
m_JoyShoulderR[_notebookpage]->GetValue().ToLong(&Right);
|
||||
|
@ -619,12 +619,12 @@ void ConfigBox::CreateGUIControls()
|
|||
// Populate the DPad type and Trigger type list
|
||||
// -----------------------------
|
||||
wxArrayString wxAS_DPadType;
|
||||
wxAS_DPadType.Add(wxString::FromAscii(DPadType[CTL_DPAD_HAT]));
|
||||
wxAS_DPadType.Add(wxString::FromAscii(DPadType[CTL_DPAD_CUSTOM]));
|
||||
wxAS_DPadType.Add(wxString::FromAscii(DPadType[InputCommon::CTL_DPAD_HAT]));
|
||||
wxAS_DPadType.Add(wxString::FromAscii(DPadType[InputCommon::CTL_DPAD_CUSTOM]));
|
||||
|
||||
wxArrayString wxAS_TriggerType;
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_SDL]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[CTL_TRIGGER_XINPUT]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[InputCommon::CTL_TRIGGER_SDL]));
|
||||
wxAS_TriggerType.Add(wxString::FromAscii(TriggerType[InputCommon::CTL_TRIGGER_XINPUT]));
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Populate the deadzone list
|
||||
|
|
|
@ -56,22 +56,22 @@ void ConfigBox::UpdateGUIKeys(int controller)
|
|||
// Update the enabled checkbox
|
||||
m_Joyattach[controller]->SetValue(PadMapping[controller].enabled == 1 ? true : false);
|
||||
|
||||
tmp << PadMapping[controller].buttons[CTL_L_SHOULDER]; m_JoyShoulderL[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[CTL_R_SHOULDER]; m_JoyShoulderR[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_L_SHOULDER]; m_JoyShoulderL[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_R_SHOULDER]; m_JoyShoulderR[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
tmp << PadMapping[controller].buttons[CTL_A_BUTTON]; m_JoyButtonA[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[CTL_B_BUTTON]; m_JoyButtonB[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[CTL_X_BUTTON]; m_JoyButtonX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[CTL_Y_BUTTON]; m_JoyButtonY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[CTL_Z_TRIGGER]; m_JoyButtonZ[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_A_BUTTON]; m_JoyButtonA[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_B_BUTTON]; m_JoyButtonB[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_X_BUTTON]; m_JoyButtonX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_Y_BUTTON]; m_JoyButtonY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_Z_TRIGGER]; m_JoyButtonZ[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
tmp << PadMapping[controller].buttons[CTL_START]; m_JoyButtonStart[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].buttons[InputCommon::CTL_START]; m_JoyButtonStart[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].halfpress; m_JoyButtonHalfpress[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
tmp << PadMapping[controller].axis[CTL_MAIN_X]; m_JoyAnalogMainX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[CTL_MAIN_Y]; m_JoyAnalogMainY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[CTL_SUB_X]; m_JoyAnalogSubX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[CTL_SUB_Y]; m_JoyAnalogSubY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[InputCommon::CTL_MAIN_X]; m_JoyAnalogMainX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[InputCommon::CTL_MAIN_Y]; m_JoyAnalogMainY[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[InputCommon::CTL_SUB_X]; m_JoyAnalogSubX[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].axis[InputCommon::CTL_SUB_Y]; m_JoyAnalogSubY[controller]->SetValue(tmp); tmp.clear();
|
||||
|
||||
// Update the deadzone and controller type controls
|
||||
m_ControlType[controller]->SetSelection(PadMapping[controller].controllertype);
|
||||
|
@ -83,16 +83,16 @@ void ConfigBox::UpdateGUIKeys(int controller)
|
|||
//LogMsg("m_TriggerType[%i] = %i\n", controller, PadMapping[controller].triggertype);
|
||||
|
||||
// Update D-Pad
|
||||
if(PadMapping[controller].controllertype == CTL_DPAD_HAT)
|
||||
if(PadMapping[controller].controllertype == InputCommon::CTL_DPAD_HAT)
|
||||
{
|
||||
tmp << PadMapping[controller].dpad; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp << PadMapping[controller].dpad2[CTL_D_PAD_UP]; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[CTL_D_PAD_DOWN]; m_JoyDpadDown[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[CTL_D_PAD_LEFT]; m_JoyDpadLeft[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[CTL_D_PAD_RIGHT]; m_JoyDpadRight[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_UP]; m_JoyDpadUp[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_DOWN]; m_JoyDpadDown[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_LEFT]; m_JoyDpadLeft[controller]->SetValue(tmp); tmp.clear();
|
||||
tmp << PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_RIGHT]; m_JoyDpadRight[controller]->SetValue(tmp); tmp.clear();
|
||||
}
|
||||
|
||||
// Replace "-1" with "" in the GUI controls
|
||||
|
@ -124,22 +124,22 @@ void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId, int FromSlo
|
|||
PadMapping[controller].bSquareToCircle = m_CBS_to_C[FromSlot]->IsChecked();
|
||||
|
||||
// The analog buttons
|
||||
m_JoyAnalogMainX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_MAIN_X] = value; tmp.clear();
|
||||
m_JoyAnalogMainY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_MAIN_Y] = value; tmp.clear();
|
||||
m_JoyAnalogSubX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_SUB_X] = value; tmp.clear();
|
||||
m_JoyAnalogSubY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[CTL_SUB_Y] = value; tmp.clear();
|
||||
m_JoyAnalogMainX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[InputCommon::CTL_MAIN_X] = value; tmp.clear();
|
||||
m_JoyAnalogMainY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[InputCommon::CTL_MAIN_Y] = value; tmp.clear();
|
||||
m_JoyAnalogSubX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[InputCommon::CTL_SUB_X] = value; tmp.clear();
|
||||
m_JoyAnalogSubY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].axis[InputCommon::CTL_SUB_Y] = value; tmp.clear();
|
||||
|
||||
// The shoulder buttons
|
||||
m_JoyShoulderL[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_L_SHOULDER] = value;
|
||||
m_JoyShoulderR[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_R_SHOULDER] = value;
|
||||
m_JoyShoulderL[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_L_SHOULDER] = value;
|
||||
m_JoyShoulderR[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_R_SHOULDER] = value;
|
||||
|
||||
// The digital buttons
|
||||
m_JoyButtonA[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_A_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonB[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_B_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_X_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_Y_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonZ[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_Z_TRIGGER] = value; tmp.clear();
|
||||
m_JoyButtonStart[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[CTL_START] = value; tmp.clear();
|
||||
m_JoyButtonA[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_A_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonB[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_B_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonX[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_X_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonY[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_Y_BUTTON] = value; tmp.clear();
|
||||
m_JoyButtonZ[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_Z_TRIGGER] = value; tmp.clear();
|
||||
m_JoyButtonStart[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].buttons[InputCommon::CTL_START] = value; tmp.clear();
|
||||
|
||||
//LogMsg("PadMapping[%i].triggertype = %i, m_TriggerType[%i]->GetSelection() = %i\n",
|
||||
// controller, PadMapping[controller].triggertype, FromSlot, m_TriggerType[FromSlot]->GetSelection());
|
||||
|
@ -148,16 +148,16 @@ void ConfigBox::SaveButtonMapping(int controller, bool DontChangeId, int FromSlo
|
|||
m_JoyButtonHalfpress[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].halfpress = value; tmp.clear();
|
||||
|
||||
// The digital pad
|
||||
if(PadMapping[controller].controllertype == CTL_DPAD_HAT)
|
||||
if(PadMapping[controller].controllertype == InputCommon::CTL_DPAD_HAT)
|
||||
{
|
||||
m_JoyDpadUp[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad = value; tmp.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_JoyDpadUp[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_UP] = value; tmp.clear();
|
||||
m_JoyDpadDown[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_DOWN] = value; tmp.clear();
|
||||
m_JoyDpadLeft[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_LEFT] = value; tmp.clear();
|
||||
m_JoyDpadRight[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[CTL_D_PAD_RIGHT] = value; tmp.clear();
|
||||
m_JoyDpadUp[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_UP] = value; tmp.clear();
|
||||
m_JoyDpadDown[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_DOWN] = value; tmp.clear();
|
||||
m_JoyDpadLeft[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_LEFT] = value; tmp.clear();
|
||||
m_JoyDpadRight[FromSlot]->GetValue().ToLong(&value); PadMapping[controller].dpad2[InputCommon::CTL_D_PAD_RIGHT] = value; tmp.clear();
|
||||
}
|
||||
|
||||
// Replace "-1" with ""
|
||||
|
@ -288,16 +288,16 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R);
|
||||
|
||||
bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R)
|
||||
&& !(TriggerType == CTL_TRIGGER_XINPUT && (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R) ); // Don't allow SDL here
|
||||
&& !(TriggerType == InputCommon::CTL_TRIGGER_XINPUT && (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R) ); // Don't allow SDL here
|
||||
|
||||
bool XInput = (TriggerType == CTL_TRIGGER_XINPUT);
|
||||
bool XInput = (TriggerType == InputCommon::CTL_TRIGGER_XINPUT);
|
||||
|
||||
bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONHALFPRESS) // All digital buttons
|
||||
|| (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R) // both shoulder buttons
|
||||
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && ControllerType == CTL_DPAD_CUSTOM); // Or the custom hat mode
|
||||
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && ControllerType == InputCommon::CTL_DPAD_CUSTOM); // Or the custom hat mode
|
||||
|
||||
bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT) // All DPads
|
||||
&& (PadMapping[Controller].controllertype == CTL_DPAD_HAT); // Not with the hat option defined
|
||||
&& (PadMapping[Controller].controllertype == InputCommon::CTL_DPAD_HAT); // Not with the hat option defined
|
||||
|
||||
/* Open a new joystick. Joysticks[controller].GetId is the system GetId of the physical joystick
|
||||
that is mapped to controller, for example 0, 1, 2, 3 for the first four PadMapping */
|
||||
|
@ -370,7 +370,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
if(AvoidValues(value)) continue; // Avoid values
|
||||
|
||||
pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
|
||||
type = CTL_AXIS;
|
||||
type = InputCommon::CTL_AXIS;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
if(SDL_JoystickGetHat(joy, i))
|
||||
{
|
||||
pressed = i;
|
||||
type = CTL_HAT;
|
||||
type = InputCommon::CTL_HAT;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
if(SDL_JoystickGetButton(joy, i))
|
||||
{
|
||||
pressed = i;
|
||||
type = CTL_BUTTON;
|
||||
type = InputCommon::CTL_BUTTON;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
|
@ -410,12 +410,12 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
#ifdef _WIN32
|
||||
if(XInput)
|
||||
{
|
||||
for(int i = 0; i <= XI_TRIGGER_R; i++)
|
||||
for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++)
|
||||
{
|
||||
if(XInput::GetXI(0, i))
|
||||
{
|
||||
pressed = i + 1000;
|
||||
type = CTL_AXIS;
|
||||
type = InputCommon::CTL_AXIS;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
|||
if(g_Pressed >= buttons)
|
||||
{
|
||||
pressed = g_Pressed;
|
||||
type = CTL_BUTTON;
|
||||
type = InputCommon::CTL_BUTTON;
|
||||
Succeed = true;
|
||||
g_Pressed = 0;
|
||||
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the exape key
|
||||
|
|
|
@ -81,12 +81,12 @@
|
|||
// ¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Rumble in windows
|
||||
#define _CONTROLLER_STATE_H // Avoid certain declarations in nJoy.h
|
||||
#define _EXCLUDE_MAIN_ // Avoid certain declarations in nJoy.h
|
||||
FILE *pFile;
|
||||
HINSTANCE nJoy_hInst = NULL;
|
||||
std::vector<CONTROLLER_INFO> joyinfo;
|
||||
CONTROLLER_STATE PadState[4];
|
||||
CONTROLLER_MAPPING PadMapping[4];
|
||||
std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
|
||||
InputCommon::CONTROLLER_STATE PadState[4];
|
||||
InputCommon::CONTROLLER_MAPPING PadMapping[4];
|
||||
bool emulator_running = false;
|
||||
int NumPads = 0, NumGoodPads = 0;
|
||||
HWND m_hWnd; // Handle to window
|
||||
|
@ -193,7 +193,7 @@ void DllConfig(HWND _hParent)
|
|||
// Start the pads so we can use them in the configuration and advanced controls
|
||||
if(!emulator_running)
|
||||
{
|
||||
NumPads = Search_Devices(); // Populate joyinfo for all attached devices
|
||||
Search_Devices(joyinfo, NumPads, NumGoodPads); // Populate joyinfo for all attached devices
|
||||
}
|
||||
|
||||
m_frame = new ConfigBox(NULL);
|
||||
|
@ -251,7 +251,7 @@ void Initialize(void *init)
|
|||
m_hWnd = (HWND)g_PADInitialize->hWnd;
|
||||
#endif
|
||||
|
||||
NumPads = Search_Devices(); // Populate joyinfo for all attached devices
|
||||
Search_Devices(joyinfo, NumPads, NumGoodPads); // Populate joyinfo for all attached devices
|
||||
|
||||
/* Check if any of the pads failed to open. In Windows there is a strange "IDirectInputDevice2::
|
||||
SetDataFormat() DirectX error -2147024809" after a few Open and Close */
|
||||
|
@ -265,79 +265,15 @@ void Initialize(void *init)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Search attached devices. Populate joyinfo for all attached physical devices.
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
int Search_Devices()
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
// Load config
|
||||
#ifdef _DEBUG
|
||||
DEBUG_INIT();
|
||||
#endif
|
||||
|
||||
/* SDL 1.3 use DirectInput instead of the old Microsoft Multimeda API, and with this we need
|
||||
the SDL_INIT_VIDEO flag to */
|
||||
if (!SDL_WasInit(0))
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
|
||||
{
|
||||
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
fprintf(pFile, "Scanning for devices\n");
|
||||
fprintf(pFile, "¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n");
|
||||
#endif
|
||||
|
||||
// Get device status
|
||||
int numjoy = SDL_NumJoysticks();
|
||||
for (int i = 0; i < numjoy; i++ )
|
||||
{
|
||||
CONTROLLER_INFO Tmp;
|
||||
|
||||
Tmp.joy = SDL_JoystickOpen(i);
|
||||
Tmp.ID = i;
|
||||
Tmp.NumAxes = SDL_JoystickNumAxes(Tmp.joy);
|
||||
Tmp.NumButtons = SDL_JoystickNumButtons(Tmp.joy);
|
||||
Tmp.NumBalls = SDL_JoystickNumBalls(Tmp.joy);
|
||||
Tmp.NumHats = SDL_JoystickNumHats(Tmp.joy);
|
||||
Tmp.Name = SDL_JoystickName(i);
|
||||
|
||||
// Check if the device is okay
|
||||
if ( Tmp.NumAxes == 0
|
||||
&& Tmp.NumBalls == 0
|
||||
&& Tmp.NumButtons == 0
|
||||
&& Tmp.NumHats == 0
|
||||
)
|
||||
{
|
||||
Tmp.Good = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
NumGoodPads++;
|
||||
Tmp.Good = true;
|
||||
}
|
||||
|
||||
joyinfo.push_back(Tmp);
|
||||
|
||||
#ifdef _DEBUG
|
||||
fprintf(pFile, "ID: %d\n", i);
|
||||
fprintf(pFile, "Name: %s\n", joyinfo[i].Name);
|
||||
fprintf(pFile, "Buttons: %d\n", joyinfo[i].NumButtons);
|
||||
fprintf(pFile, "Axes: %d\n", joyinfo[i].NumAxes);
|
||||
fprintf(pFile, "Hats: %d\n", joyinfo[i].NumHats);
|
||||
fprintf(pFile, "Balls: %d\n\n", joyinfo[i].NumBalls);
|
||||
#endif
|
||||
|
||||
// We have now read the values we need so we close the device
|
||||
if (SDL_JoystickOpened(i)) SDL_JoystickClose(joyinfo[i].joy);
|
||||
}
|
||||
bool Success = InputCommon::SearchDevices(_joyinfo, _NumPads, _NumGoodPads);
|
||||
|
||||
// Warn the user if no gamepads are detected
|
||||
if (NumGoodPads == 0 && emulator_running)
|
||||
if (_NumGoodPads == 0 && emulator_running)
|
||||
{
|
||||
PanicAlert("nJoy: No Gamepad Detected");
|
||||
return joyinfo.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load PadMapping[] etc
|
||||
|
@ -351,7 +287,7 @@ int Search_Devices()
|
|||
PadState[i].joy = SDL_JoystickOpen(PadMapping[i].ID);
|
||||
}
|
||||
|
||||
return joyinfo.size();
|
||||
return Success;
|
||||
}
|
||||
|
||||
// Shutdown PAD (stop emulation)
|
||||
|
@ -405,13 +341,13 @@ void PAD_Input(u16 _Key, u8 _UpDown)
|
|||
// Check if the keys are interesting, and then update it
|
||||
for(int i = 0; i < 4; i++)
|
||||
{
|
||||
for(int j = CTL_L_SHOULDER; j <= CTL_START; j++)
|
||||
for(int j = InputCommon::CTL_L_SHOULDER; j <= InputCommon::CTL_START; j++)
|
||||
{
|
||||
if (PadMapping[i].buttons[j] == _Key)
|
||||
{ PadState[i].buttons[j] = _UpDown; break; }
|
||||
}
|
||||
|
||||
for(int j = CTL_D_PAD_UP; j <= CTL_D_PAD_RIGHT; j++)
|
||||
for(int j = InputCommon::CTL_D_PAD_UP; j <= InputCommon::CTL_D_PAD_RIGHT; j++)
|
||||
{
|
||||
if (PadMapping[i].dpad2[j] == _Key)
|
||||
{ PadState[i].dpad2[j] = _UpDown; break; }
|
||||
|
@ -461,8 +397,9 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
// Clear pad status
|
||||
memset(_pPADStatus, 0, sizeof(SPADStatus));
|
||||
|
||||
// Update the pad status
|
||||
GetJoyState(_numPAD);
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
if (!g_Config.bCheckFocus && IsFocus())
|
||||
GetJoyState(PadState[_numPAD], PadMapping[_numPAD], _numPAD, joyinfo[PadMapping[_numPAD].ID].NumButtons);
|
||||
|
||||
// Get type
|
||||
int TriggerType = PadMapping[_numPAD].triggertype;
|
||||
|
@ -472,12 +409,12 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
// -----------
|
||||
|
||||
// Read axis values
|
||||
int i_main_stick_x = PadState[_numPAD].axis[CTL_MAIN_X];
|
||||
int i_main_stick_y = -PadState[_numPAD].axis[CTL_MAIN_Y];
|
||||
int i_sub_stick_x = PadState[_numPAD].axis[CTL_SUB_X];
|
||||
int i_sub_stick_y = -PadState[_numPAD].axis[CTL_SUB_Y];
|
||||
int TriggerLeft = PadState[_numPAD].axis[CTL_L_SHOULDER];
|
||||
int TriggerRight = PadState[_numPAD].axis[CTL_R_SHOULDER];
|
||||
int i_main_stick_x = PadState[_numPAD].axis[InputCommon::CTL_MAIN_X];
|
||||
int i_main_stick_y = -PadState[_numPAD].axis[InputCommon::CTL_MAIN_Y];
|
||||
int i_sub_stick_x = PadState[_numPAD].axis[InputCommon::CTL_SUB_X];
|
||||
int i_sub_stick_y = -PadState[_numPAD].axis[InputCommon::CTL_SUB_Y];
|
||||
int TriggerLeft = PadState[_numPAD].axis[InputCommon::CTL_L_SHOULDER];
|
||||
int TriggerRight = PadState[_numPAD].axis[InputCommon::CTL_R_SHOULDER];
|
||||
|
||||
// Check if we should make adjustments
|
||||
if(PadMapping[_numPAD].bSquareToCircle)
|
||||
|
@ -494,10 +431,10 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
u8 sub_stick_y = Pad_Convert(i_sub_stick_y);
|
||||
|
||||
// Convert the triggers values, if we are using analog triggers at all
|
||||
if(PadMapping[_numPAD].triggertype == CTL_TRIGGER_SDL)
|
||||
if(PadMapping[_numPAD].triggertype == InputCommon::CTL_TRIGGER_SDL)
|
||||
{
|
||||
if(PadMapping[_numPAD].buttons[CTL_L_SHOULDER] >= 1000) TriggerLeft = Pad_Convert(TriggerLeft);
|
||||
if(PadMapping[_numPAD].buttons[CTL_R_SHOULDER] >= 1000) TriggerRight = Pad_Convert(TriggerRight);
|
||||
if(PadMapping[_numPAD].buttons[InputCommon::CTL_L_SHOULDER] >= 1000) TriggerLeft = Pad_Convert(TriggerLeft);
|
||||
if(PadMapping[_numPAD].buttons[InputCommon::CTL_R_SHOULDER] >= 1000) TriggerRight = Pad_Convert(TriggerRight);
|
||||
}
|
||||
|
||||
// Set Deadzones (perhaps out of function?)
|
||||
|
@ -520,7 +457,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
_pPADStatus->button |= PAD_USE_ORIGIN; // Neutral value, no button pressed
|
||||
|
||||
// Check if the digital L button is pressed
|
||||
if (PadState[_numPAD].buttons[CTL_L_SHOULDER])
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_L_SHOULDER])
|
||||
{
|
||||
_pPADStatus->button |= PAD_TRIGGER_L;
|
||||
_pPADStatus->triggerLeft = TriggerValue;
|
||||
|
@ -529,7 +466,7 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
_pPADStatus->triggerLeft = TriggerLeft;
|
||||
|
||||
// Check if the digital R button is pressed
|
||||
if (PadState[_numPAD].buttons[CTL_R_SHOULDER])
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_R_SHOULDER])
|
||||
{
|
||||
_pPADStatus->button |= PAD_TRIGGER_R;
|
||||
_pPADStatus->triggerRight = TriggerValue;
|
||||
|
@ -545,26 +482,26 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
///////////////////////////////////////////////////
|
||||
// The digital buttons
|
||||
// -----------
|
||||
if (PadState[_numPAD].buttons[CTL_A_BUTTON])
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_A_BUTTON])
|
||||
{
|
||||
_pPADStatus->button |= PAD_BUTTON_A;
|
||||
_pPADStatus->analogA = 255; // Perhaps support pressure?
|
||||
}
|
||||
if (PadState[_numPAD].buttons[CTL_B_BUTTON])
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_B_BUTTON])
|
||||
{
|
||||
_pPADStatus->button |= PAD_BUTTON_B;
|
||||
_pPADStatus->analogB = 255; // Perhaps support pressure?
|
||||
}
|
||||
if (PadState[_numPAD].buttons[CTL_X_BUTTON]) _pPADStatus->button|=PAD_BUTTON_X;
|
||||
if (PadState[_numPAD].buttons[CTL_Y_BUTTON]) _pPADStatus->button|=PAD_BUTTON_Y;
|
||||
if (PadState[_numPAD].buttons[CTL_Z_TRIGGER]) _pPADStatus->button|=PAD_TRIGGER_Z;
|
||||
if (PadState[_numPAD].buttons[CTL_START]) _pPADStatus->button|=PAD_BUTTON_START;
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_X_BUTTON]) _pPADStatus->button|=PAD_BUTTON_X;
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_Y_BUTTON]) _pPADStatus->button|=PAD_BUTTON_Y;
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_Z_TRIGGER]) _pPADStatus->button|=PAD_TRIGGER_Z;
|
||||
if (PadState[_numPAD].buttons[InputCommon::CTL_START]) _pPADStatus->button|=PAD_BUTTON_START;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
// The D-pad
|
||||
// -----------
|
||||
if (PadMapping[_numPAD].controllertype == CTL_DPAD_HAT)
|
||||
if (PadMapping[_numPAD].controllertype == InputCommon::CTL_DPAD_HAT)
|
||||
{
|
||||
if (PadState[_numPAD].dpad == SDL_HAT_LEFTUP || PadState[_numPAD].dpad == SDL_HAT_UP || PadState[_numPAD].dpad == SDL_HAT_RIGHTUP ) _pPADStatus->button|=PAD_BUTTON_UP;
|
||||
if (PadState[_numPAD].dpad == SDL_HAT_LEFTUP || PadState[_numPAD].dpad == SDL_HAT_LEFT || PadState[_numPAD].dpad == SDL_HAT_LEFTDOWN ) _pPADStatus->button|=PAD_BUTTON_LEFT;
|
||||
|
@ -573,13 +510,13 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (PadState[_numPAD].dpad2[CTL_D_PAD_UP])
|
||||
if (PadState[_numPAD].dpad2[InputCommon::CTL_D_PAD_UP])
|
||||
_pPADStatus->button |= PAD_BUTTON_UP;
|
||||
if (PadState[_numPAD].dpad2[CTL_D_PAD_DOWN])
|
||||
if (PadState[_numPAD].dpad2[InputCommon::CTL_D_PAD_DOWN])
|
||||
_pPADStatus->button |= PAD_BUTTON_DOWN;
|
||||
if (PadState[_numPAD].dpad2[CTL_D_PAD_LEFT])
|
||||
if (PadState[_numPAD].dpad2[InputCommon::CTL_D_PAD_LEFT])
|
||||
_pPADStatus->button |= PAD_BUTTON_LEFT;
|
||||
if (PadState[_numPAD].dpad2[CTL_D_PAD_RIGHT])
|
||||
if (PadState[_numPAD].dpad2[InputCommon::CTL_D_PAD_RIGHT])
|
||||
_pPADStatus->button |= PAD_BUTTON_RIGHT;
|
||||
}
|
||||
|
||||
|
@ -757,114 +694,3 @@ std::vector<int> Pad_Square_to_Circle(int _x, int _y, int _pad)
|
|||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Supporting functions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Read current joystick status
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
The value PadMapping[].buttons[] is the number of the assigned joypad button,
|
||||
PadState[].buttons[] is the status of the button, it becomes 0 (no pressed) or 1 (pressed) */
|
||||
|
||||
|
||||
// Read buttons status. Called from GetJoyState().
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ReadButton(int controller, int button)
|
||||
{
|
||||
int ctl_button = PadMapping[controller].buttons[button];
|
||||
if (ctl_button < joyinfo[PadMapping[controller].ID].NumButtons)
|
||||
{
|
||||
PadState[controller].buttons[button] = SDL_JoystickGetButton(PadState[controller].joy, ctl_button);
|
||||
}
|
||||
}
|
||||
|
||||
// Request joystick state.
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
/* Called from: PAD_GetStatus()
|
||||
Input: The virtual device 0, 1, 2 or 3
|
||||
Function: Updates the PadState struct with the current pad status. The input value "controller" is
|
||||
for a virtual controller 0 to 3. */
|
||||
void GetJoyState(int controller)
|
||||
{
|
||||
// Check that Dolphin is in focus, otherwise don't update the pad status
|
||||
if (!g_Config.bCheckFocus && !IsFocus()) return;
|
||||
|
||||
// Update the gamepad status
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
// Save the number of buttons
|
||||
int Buttons = joyinfo[PadMapping[controller].ID].NumButtons;
|
||||
|
||||
// Update axis states. It doesn't hurt much if we happen to ask for nonexisting axises here.
|
||||
PadState[controller].axis[CTL_MAIN_X] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].axis[CTL_MAIN_X]);
|
||||
PadState[controller].axis[CTL_MAIN_Y] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].axis[CTL_MAIN_Y]);
|
||||
PadState[controller].axis[CTL_SUB_X] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].axis[CTL_SUB_X]);
|
||||
PadState[controller].axis[CTL_SUB_Y] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].axis[CTL_SUB_Y]);
|
||||
|
||||
// Update the analog trigger axis values
|
||||
#ifdef _WIN32
|
||||
if (PadMapping[controller].triggertype == CTL_TRIGGER_SDL)
|
||||
{
|
||||
#endif
|
||||
// If we are using SDL analog triggers the buttons have to be mapped as 1000 or up, otherwise they are not used
|
||||
if(PadMapping[controller].buttons[CTL_L_SHOULDER] >= 1000) PadState[controller].axis[CTL_L_SHOULDER] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].buttons[CTL_L_SHOULDER] - 1000); else PadState[controller].axis[CTL_L_SHOULDER] = 0;
|
||||
if(PadMapping[controller].buttons[CTL_R_SHOULDER] >= 1000) PadState[controller].axis[CTL_R_SHOULDER] = SDL_JoystickGetAxis(PadState[controller].joy, PadMapping[controller].buttons[CTL_R_SHOULDER] - 1000); else PadState[controller].axis[CTL_R_SHOULDER] = 0;
|
||||
#ifdef _WIN32
|
||||
}
|
||||
else
|
||||
{
|
||||
PadState[controller].axis[CTL_L_SHOULDER] = XInput::GetXI(0, PadMapping[controller].buttons[CTL_L_SHOULDER] - 1000);
|
||||
PadState[controller].axis[CTL_R_SHOULDER] = XInput::GetXI(0, PadMapping[controller].buttons[CTL_R_SHOULDER] - 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Update button states to on or off
|
||||
ReadButton(controller, CTL_L_SHOULDER);
|
||||
ReadButton(controller, CTL_R_SHOULDER);
|
||||
ReadButton(controller, CTL_A_BUTTON);
|
||||
ReadButton(controller, CTL_B_BUTTON);
|
||||
ReadButton(controller, CTL_X_BUTTON);
|
||||
ReadButton(controller, CTL_Y_BUTTON);
|
||||
ReadButton(controller, CTL_Z_TRIGGER);
|
||||
ReadButton(controller, CTL_START);
|
||||
|
||||
//
|
||||
if (PadMapping[controller].halfpress < joyinfo[controller].NumButtons)
|
||||
PadState[controller].halfpress = SDL_JoystickGetButton(PadState[controller].joy, PadMapping[controller].halfpress);
|
||||
|
||||
// Check if we have an analog or digital joypad
|
||||
if (PadMapping[controller].controllertype == CTL_DPAD_HAT)
|
||||
{
|
||||
PadState[controller].dpad = SDL_JoystickGetHat(PadState[controller].joy, PadMapping[controller].dpad);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Only do this if the assigned button is in range (to allow for the current way of saving keyboard
|
||||
keys in the same array) */
|
||||
if(PadMapping[controller].dpad2[CTL_D_PAD_UP] <= Buttons)
|
||||
PadState[controller].dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(PadState[controller].joy, PadMapping[controller].dpad2[CTL_D_PAD_UP]);
|
||||
if(PadMapping[controller].dpad2[CTL_D_PAD_DOWN] <= Buttons)
|
||||
PadState[controller].dpad2[CTL_D_PAD_DOWN] = SDL_JoystickGetButton(PadState[controller].joy, PadMapping[controller].dpad2[CTL_D_PAD_DOWN]);
|
||||
if(PadMapping[controller].dpad2[CTL_D_PAD_LEFT] <= Buttons)
|
||||
PadState[controller].dpad2[CTL_D_PAD_LEFT] = SDL_JoystickGetButton(PadState[controller].joy, PadMapping[controller].dpad2[CTL_D_PAD_LEFT]);
|
||||
if(PadMapping[controller].dpad2[CTL_D_PAD_RIGHT] <= Buttons)
|
||||
PadState[controller].dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(PadState[controller].joy, PadMapping[controller].dpad2[CTL_D_PAD_RIGHT]);
|
||||
}
|
||||
|
||||
/* Debugging
|
||||
Console::ClearScreen();
|
||||
Console::Print(
|
||||
"Controller and handle: %i %i\n"
|
||||
|
||||
"Triggers:%i %i %i %i %i | HalfPress: %i Mapping: %i\n",
|
||||
|
||||
controller, (int)PadState[controller].joy,
|
||||
|
||||
PadMapping[controller].triggertype,
|
||||
PadMapping[controller].buttons[CTL_L_SHOULDER], PadMapping[controller].buttons[CTL_R_SHOULDER],
|
||||
PadState[controller].axis[CTL_L_SHOULDER], PadState[controller].axis[CTL_R_SHOULDER],
|
||||
|
||||
PadState[controller].halfpress, PadMapping[controller].halfpress
|
||||
); */
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -45,7 +45,9 @@
|
|||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
#include <SDL.h>
|
||||
|
||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "pluginspecs_pad.h"
|
||||
|
@ -54,7 +56,6 @@
|
|||
//#include "Timer.h"
|
||||
|
||||
#include "Config.h" // Local
|
||||
#include "XInput.h"
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "GUI/AboutBox.h"
|
||||
|
@ -102,115 +103,6 @@
|
|||
#define THANKYOU "`plot`, Absolute0, Aprentice, Bositman, Brice, ChaosCode, CKemu, CoDeX, Dave2001, dn, drk||Raziel, Florin, Gent, Gigaherz, Hacktarux, JegHegy, Linker, Linuzappz, Martin64, Muad, Knuckles, Raziel, Refraction, Rudy_x, Shadowprince, Snake785, Saqib, vEX, yaz0r, Zilmar, Zenogais and ZeZu."
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Structures
|
||||
/* ¯¯¯¯¯¯¯¯¯¯
|
||||
CONTROLLER_STATE buttons (PadState) = 0 or 1
|
||||
CONTROLLER_MAPPING buttons (joystick) = 0 or 1, 2, 3, 4, a certain joypad button
|
||||
|
||||
Please remember: The axis limit is hardcoded here, if you allow more axises (for
|
||||
example for analog A and B buttons) you must first incrase the size of the axis array
|
||||
size here
|
||||
*/
|
||||
struct CONTROLLER_STATE // GC PAD INFO/STATE
|
||||
{
|
||||
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
|
||||
int dpad; // Automatic SDL D-Pad (8 directions + neutral)
|
||||
int dpad2[4]; // D-pad using buttons
|
||||
int axis[6]; // 2 x 2 Axes (Main & Sub)
|
||||
int halfpress; // Halfpress... you know, like not fully pressed ;)...
|
||||
SDL_Joystick *joy; // SDL joystick device
|
||||
};
|
||||
|
||||
struct CONTROLLER_MAPPING // GC PAD MAPPING
|
||||
{
|
||||
int buttons[8]; // (See above)
|
||||
int dpad; // (See above)
|
||||
int dpad2[4]; // (See above)
|
||||
int axis[6]; // (See above)
|
||||
int halfpress; // (See above)
|
||||
int enabled; // Pad attached?
|
||||
int deadzone; // Deadzone... what else?
|
||||
int ID; // SDL joystick device ID
|
||||
int controllertype; // Hat: Hat or custom buttons
|
||||
int triggertype; // Triggers range
|
||||
std::string SDiagonal;
|
||||
bool bSquareToCircle;
|
||||
int eventnum; // Linux Event Number, Can't be found dynamically yet
|
||||
};
|
||||
|
||||
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
|
||||
{
|
||||
int NumAxes; // Amount of Axes
|
||||
int NumButtons; // Amount of Buttons
|
||||
int NumBalls; // Amount of Balls
|
||||
int NumHats; // Amount of Hats (POV)
|
||||
std::string Name; // Joypad/stickname
|
||||
int ID; // SDL joystick device ID
|
||||
bool Good;
|
||||
SDL_Joystick *joy; // SDL joystick device
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
// CTL_L_SHOULDER and CTL_R_SHOULDER = 0 and 1
|
||||
CTL_MAIN_X = 2,
|
||||
CTL_MAIN_Y,
|
||||
CTL_SUB_X,
|
||||
CTL_SUB_Y
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CTL_L_SHOULDER = 0,
|
||||
CTL_R_SHOULDER,
|
||||
CTL_A_BUTTON,
|
||||
CTL_B_BUTTON,
|
||||
CTL_X_BUTTON,
|
||||
CTL_Y_BUTTON,
|
||||
CTL_Z_TRIGGER,
|
||||
CTL_START
|
||||
};
|
||||
|
||||
// DPad Type
|
||||
enum
|
||||
{
|
||||
CTL_DPAD_HAT = 0, // Automatically use the first hat that SDL finds
|
||||
CTL_DPAD_CUSTOM // Custom directional pad settings
|
||||
};
|
||||
|
||||
// Trigger Type
|
||||
enum
|
||||
{
|
||||
CTL_TRIGGER_SDL = 0, //
|
||||
CTL_TRIGGER_XINPUT // The XBox 360 pad
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CTL_D_PAD_UP = 0,
|
||||
CTL_D_PAD_DOWN,
|
||||
CTL_D_PAD_LEFT,
|
||||
CTL_D_PAD_RIGHT
|
||||
};
|
||||
|
||||
// Button type for the configuration
|
||||
enum
|
||||
{
|
||||
CTL_AXIS = 0,
|
||||
CTL_HAT,
|
||||
CTL_BUTTON,
|
||||
CTL_KEY
|
||||
};
|
||||
|
||||
// XInput buttons
|
||||
enum
|
||||
{
|
||||
XI_TRIGGER_L = 0,
|
||||
XI_TRIGGER_R
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Input vector. Todo: Save the configured keys here instead of in joystick
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
|
@ -225,11 +117,11 @@ extern std::vector<u8> Keys;
|
|||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Variables
|
||||
// ¯¯¯¯¯¯¯¯¯
|
||||
#ifndef _CONTROLLER_STATE_H
|
||||
#ifndef _EXCLUDE_MAIN_
|
||||
extern FILE *pFile;
|
||||
extern std::vector<CONTROLLER_INFO> joyinfo;
|
||||
extern CONTROLLER_STATE PadState[4];
|
||||
extern CONTROLLER_MAPPING PadMapping[4];
|
||||
extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
|
||||
extern InputCommon::CONTROLLER_STATE PadState[4];
|
||||
extern InputCommon::CONTROLLER_MAPPING PadMapping[4];
|
||||
extern HWND m_hWnd; // Handle to window
|
||||
extern int NumPads, NumGoodPads; // Number of goods pads
|
||||
#endif
|
||||
|
@ -238,9 +130,7 @@ extern std::vector<u8> Keys;
|
|||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Custom Functions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
void GetJoyState(int controller);
|
||||
int Search_Devices();
|
||||
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads);
|
||||
void DEBUG_INIT();
|
||||
void DEBUG_QUIT();
|
||||
bool IsFocus();
|
||||
|
|
Loading…
Reference in New Issue