mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Moved WiimoteNew into Dolphin and eliminated the old wiimote plugin. Removed wiimote plugin support. Moved input dialog related InputUICommon stuff into DolphinWX. Removed now unused InputCommon files. UDPWiimote stuff is temporarily disabled until it is reorganized so Core won't depend on wx. Real wiimotes are now initialized on first need(wiimote diag open or game start) and left initialized until Dolphin exit.(maybe this will work better for Linux/OS X) (scons probably needs some fixes)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6270 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,253 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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 <iostream> // System
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
#include "Common.h" // Common
|
||||
|
||||
#if defined HAVE_WX && HAVE_WX
|
||||
#include <wx/wx.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
namespace InputCommon
|
||||
{
|
||||
|
||||
// Degree to radian and back
|
||||
float Deg2Rad(float Deg)
|
||||
{
|
||||
return Deg * (float)M_PI / 180.0f;
|
||||
}
|
||||
float Rad2Deg(float Rad)
|
||||
{
|
||||
return Rad * 180.0f / (float)M_PI;
|
||||
}
|
||||
|
||||
// Check if the pad is within the dead zone, we assume the range is 0x8000
|
||||
float CoordinatesToRadius(int x, int y)
|
||||
{
|
||||
return sqrt(pow((float)x, 2) + pow((float)y, 2));
|
||||
}
|
||||
|
||||
bool IsDeadZone(float DeadZone, int x, int y)
|
||||
{
|
||||
// Get the distance from the center
|
||||
float Distance = CoordinatesToRadius(x, y) / 32767.0f;
|
||||
|
||||
//Console::Print("%f\n", Distance);
|
||||
|
||||
// Check if it's within the dead zone
|
||||
if (Distance <= DeadZone)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
// Scale down stick values from 0x8000 to 0x80
|
||||
/*
|
||||
The value returned by SDL_JoystickGetAxis is a signed integer s16 (-32768 to
|
||||
32767). The value used for the gamecube controller is an unsigned char u8 (0
|
||||
to 255) with neutral at 0x80 (128), so that it's equivalent to a signed -128
|
||||
to 127. */
|
||||
//
|
||||
int Pad_Convert(int _val)
|
||||
{
|
||||
|
||||
/* If the limits on PadState[].axis[] actually is a u16 then we don't need
|
||||
this but if it's not actually limited to that we need to apply these
|
||||
limits */
|
||||
if(_val > 32767) _val = 32767; // upper limit
|
||||
if(_val < -32768) _val = -32768; // lower limit
|
||||
|
||||
// Convert the range (-0x8000 to 0x7fff) to (0 to 0xffff)
|
||||
_val = 0x8000 +_val;
|
||||
|
||||
// Convert the range (0 to 0xffff) to (0 to 0xff)
|
||||
_val = _val >> 8;
|
||||
|
||||
//Console::Print("0x%04x %06i\n\n", _val, _val);
|
||||
|
||||
return _val;
|
||||
}
|
||||
|
||||
// Adjust the radius
|
||||
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius)
|
||||
{
|
||||
// Get the radius setting
|
||||
float RadiusSetting = (float)_Radius / 100.0f;
|
||||
float x = (float)_x * RadiusSetting;
|
||||
float y = (float)_y * RadiusSetting;
|
||||
// Update values
|
||||
_x = (s8)x;
|
||||
_y = (s8)y;
|
||||
}
|
||||
|
||||
/* Convert the stick raidus from a square or rounded box to a circular
|
||||
radius. I don't know what input values the actual GC controller produce for
|
||||
the GC, it may be a square, a circle or something in between. But one thing
|
||||
that is certain is that PC pads differ in their output (as shown in the list
|
||||
below), so it may be beneficiary to convert whatever radius they produce to
|
||||
the radius the GC games expect. This is the first implementation of this
|
||||
that convert a square radius to a circual radius. Use the advanced settings
|
||||
to enable and calibrate it.
|
||||
|
||||
Observed diagonals:
|
||||
Perfect circle: 71% = sin(45)
|
||||
Logitech Dual Action: 100%
|
||||
PS2 Dual Shock 2 (Original) with Super Dual Box Pro: 90%
|
||||
XBox 360 Wireless: 85%
|
||||
GameCube Controller (Third Party) with EMS Trio Linker Plus II: 60%
|
||||
*/
|
||||
|
||||
/* Calculate the distance from the outer edges of the box to the outer edges of
|
||||
the circle inside the box at any angle from 0 to 360. The returned value is
|
||||
1 + Distance, for example at most sqrt(2) in the corners and at least 1.0 at
|
||||
the horizontal and vertical angles. */
|
||||
float Square2CircleDistance(float deg)
|
||||
{
|
||||
// See if we have to adjust the angle
|
||||
deg = fabsf(deg);
|
||||
if( (deg > 45 && deg < 135) ) deg = deg - 90;
|
||||
|
||||
// Calculate distance from center
|
||||
float val = fabsf(cos(Deg2Rad(deg)));
|
||||
float Distance = 1 / val;
|
||||
|
||||
//m_frame->m_pStatusBar2->SetLabel(wxString::Format("Deg:%f Val:%f Dist:%f", deg, val, dist));
|
||||
|
||||
return Distance;
|
||||
}
|
||||
|
||||
// Produce a perfect circle from an original square or rounded box
|
||||
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square)
|
||||
{
|
||||
// Do we need to do this check?
|
||||
if(_x > 32767) _x = 32767; if(_y > 32767) _y = 32767; // upper limit
|
||||
if(_x < -32768) _x = -32768; if(_y < -32768) _y = -32768; // lower limit
|
||||
|
||||
// Convert to circle
|
||||
// Get the manually configured diagonal distance
|
||||
float Diagonal = (float)_Diagonal / 100.0f;
|
||||
|
||||
// First make a perfect square in case we don't have one already
|
||||
float OrigDist = sqrt( pow((float)_y, 2) + pow((float)_x, 2) ); // Get current distance
|
||||
float deg = Rad2Deg(atan2((float)_y, (float)_x)); // Get current angle
|
||||
|
||||
/* Calculate the actual distance between the maxium diagonal values, and
|
||||
the outer edges of the square. A diagonal of 85% means a maximum
|
||||
distance of 0.85 * sqrt(2) ~1.2 in the diagonals. */
|
||||
float corner_circle_dist = ( Diagonal / sin(Deg2Rad(45.0f)) );
|
||||
float SquareDist = Square2CircleDistance(deg);
|
||||
// The original-to-square distance adjustment
|
||||
float adj_ratio1;
|
||||
// The circle-to-square distance adjustment
|
||||
float adj_ratio2 = SquareDist;
|
||||
// The resulting distance
|
||||
float result_dist;
|
||||
|
||||
// Calculate the corner-to-square adjustment ratio
|
||||
if(corner_circle_dist < SquareDist) adj_ratio1 = SquareDist / corner_circle_dist;
|
||||
else adj_ratio1 = 1;
|
||||
|
||||
// Calculate the resulting distance
|
||||
if(Circle2Square)
|
||||
result_dist = OrigDist * adj_ratio1;
|
||||
else
|
||||
result_dist = OrigDist * adj_ratio1 / adj_ratio2;
|
||||
|
||||
// Calculate x and y and return it
|
||||
float x = result_dist * cos(Deg2Rad(deg));
|
||||
float y = result_dist * sin(Deg2Rad(deg));
|
||||
// Update coordinates
|
||||
_x = (int)floor(x);
|
||||
_y = (int)floor(y);
|
||||
// Boundaries
|
||||
if (_x < -32768) _x = -32768; if (_x > 32767) _x = 32767;
|
||||
if (_y < -32768) _y = -32768; if (_y > 32767) _y = 32767;
|
||||
|
||||
// Debugging
|
||||
//Console::Print("%f %f %i", corner_circle_dist, Diagonal, Tmp));
|
||||
}
|
||||
|
||||
// Windows Virtual Key Codes Names
|
||||
#ifdef _WIN32
|
||||
std::string VKToString(int keycode)
|
||||
{
|
||||
// Default value
|
||||
char KeyStr[64] = {0};
|
||||
std::string KeyString;
|
||||
|
||||
switch(keycode)
|
||||
{
|
||||
// Give it some help with a few keys
|
||||
case VK_END: return "END";
|
||||
case VK_INSERT: return "INS";
|
||||
case VK_DELETE: return "DEL";
|
||||
case VK_HOME: return "HOME";
|
||||
case VK_PRIOR: return "PGUP";
|
||||
case VK_NEXT: return "PGDN";
|
||||
|
||||
case VK_UP: return "UP";
|
||||
case VK_DOWN: return "DOWN";
|
||||
case VK_LEFT: return "LEFT";
|
||||
case VK_RIGHT: return "RIGHT";
|
||||
|
||||
case VK_LSHIFT: return "Left Shift";
|
||||
case VK_RSHIFT: return "Right Shift";
|
||||
case VK_LCONTROL: return "Left Ctrl";
|
||||
case VK_RCONTROL: return "Right Ctrl";
|
||||
case VK_LMENU: return "Left Alt";
|
||||
case VK_RMENU: return "Right Alt";
|
||||
|
||||
case VK_NUMLOCK: return "Num Lock";
|
||||
case VK_MULTIPLY: return "Num *";
|
||||
case VK_ADD: return "Num +";
|
||||
case VK_SEPARATOR: case 0xC2: return "Num Separator";
|
||||
case VK_SUBTRACT: return "Num -";
|
||||
case VK_DECIMAL: return "Num Decimal";
|
||||
case VK_DIVIDE: return "Num /";
|
||||
|
||||
case VK_OEM_PLUS: return "=";
|
||||
case VK_OEM_MINUS: return "-";
|
||||
case VK_OEM_COMMA: return ",";
|
||||
case VK_OEM_PERIOD: return ".";
|
||||
|
||||
case VK_BROWSER_BACK: return "Nav Bwd";
|
||||
case VK_BROWSER_FORWARD: return "Nav Fwd";
|
||||
|
||||
//default: return KeyString = KeyStr;
|
||||
}
|
||||
|
||||
// TODO: Switch to unicode GetKeyNameText?
|
||||
if (keycode < 256) // Keyboard
|
||||
GetKeyNameTextA(MapVirtualKey(keycode, MAPVK_VK_TO_VSC) << 16, KeyStr, 64);
|
||||
else // Pad
|
||||
sprintf(KeyStr, "PAD: %d", keycode - 0x1000);
|
||||
|
||||
return KeyString = KeyStr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
@ -298,9 +298,8 @@ ControllerEmu::Tilt::Tilt( const char* const _name )
|
||||
settings.push_back( new Setting("Circle Stick", 0 ) );
|
||||
}
|
||||
|
||||
ControllerEmu::Cursor::Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize )
|
||||
: ControlGroup( _name, GROUP_TYPE_CURSOR )
|
||||
, wiimote_initialize(_wiimote_initialize)
|
||||
ControllerEmu::Cursor::Cursor(const char* const _name)
|
||||
: ControlGroup(_name, GROUP_TYPE_CURSOR)
|
||||
, m_z(0)
|
||||
{
|
||||
for ( unsigned int i = 0; i < 4; ++i )
|
||||
|
@ -27,7 +27,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "GCPadStatus.h"
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include "ControllerInterface/ControllerInterface.h"
|
||||
#include "IniFile.h"
|
||||
@ -374,7 +373,7 @@ public:
|
||||
class Cursor : public ControlGroup
|
||||
{
|
||||
public:
|
||||
Cursor( const char* const _name, const SWiimoteInitialize* const _wiimote_initialize );
|
||||
Cursor(const char* const _name);
|
||||
|
||||
template <typename C>
|
||||
void GetState( C* const x, C* const y, C* const z, const bool adjusted = false )
|
||||
@ -412,9 +411,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
const SWiimoteInitialize* const wiimote_initialize;
|
||||
|
||||
float m_z;
|
||||
};
|
||||
|
||||
|
@ -20,14 +20,16 @@
|
||||
|
||||
#define INPUT_DETECT_THRESHOLD 0.85
|
||||
|
||||
ControllerInterface g_controller_interface;
|
||||
|
||||
//
|
||||
// Init
|
||||
//
|
||||
// detect devices and inputs outputs / will make refresh function later
|
||||
//
|
||||
void ControllerInterface::Init()
|
||||
void ControllerInterface::Initialize()
|
||||
{
|
||||
if ( m_is_init )
|
||||
if (m_is_init)
|
||||
return;
|
||||
|
||||
#ifdef CIFACE_USE_DINPUT
|
||||
@ -54,9 +56,9 @@ void ControllerInterface::Init()
|
||||
//
|
||||
// remove all devices/ call library cleanup functions
|
||||
//
|
||||
void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
|
||||
void ControllerInterface::Shutdown()
|
||||
{
|
||||
if ( false == m_is_init )
|
||||
if (false == m_is_init)
|
||||
return;
|
||||
|
||||
std::vector<Device*>::const_iterator
|
||||
@ -73,12 +75,6 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
|
||||
// update output
|
||||
(*d)->UpdateOutput();
|
||||
|
||||
// TODO: remove this
|
||||
// major hacks/memleaks to prevent gcpad/wiimote new from crashing eachother
|
||||
if (hacks_no_sdl_quit)
|
||||
if ((*d)->GetSource() == "SDL")
|
||||
continue;
|
||||
|
||||
//delete device
|
||||
delete *d;
|
||||
}
|
||||
@ -99,8 +95,7 @@ void ControllerInterface::DeInit(const bool hacks_no_sdl_quit)
|
||||
#endif
|
||||
#ifdef CIFACE_USE_SDL
|
||||
// TODO: there seems to be some sort of memory leak with SDL, quit isn't freeing everything up
|
||||
if (false == hacks_no_sdl_quit)
|
||||
SDL_Quit();
|
||||
SDL_Quit();
|
||||
#endif
|
||||
|
||||
m_is_init = false;
|
||||
|
@ -210,9 +210,9 @@ public:
|
||||
ControllerInterface() : m_is_init(false), m_hwnd(NULL) {}
|
||||
|
||||
void SetHwnd(void* const hwnd);
|
||||
void Init();
|
||||
void Initialize();
|
||||
// TODO: remove this hack param
|
||||
void DeInit(const bool hacks_no_sdl_quit = false);
|
||||
void Shutdown();
|
||||
bool IsInit() const { return m_is_init; }
|
||||
|
||||
void UpdateReference(ControlReference* control, const DeviceQualifier& default_device) const;
|
||||
@ -230,4 +230,6 @@ private:
|
||||
void* m_hwnd;
|
||||
};
|
||||
|
||||
extern ControllerInterface g_controller_interface;
|
||||
|
||||
#endif
|
||||
|
@ -1,229 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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
|
||||
// -------------------
|
||||
#include "DirectInputBase.h"
|
||||
|
||||
|
||||
|
||||
DInput::DInput()
|
||||
: g_pDI(NULL),
|
||||
g_pKeyboard(NULL)
|
||||
{}
|
||||
|
||||
|
||||
DInput::~DInput()
|
||||
{
|
||||
Free();
|
||||
}
|
||||
|
||||
void DInput::DIKToString(unsigned int keycode, char *keyStr)
|
||||
{
|
||||
switch(keycode) {
|
||||
case DIK_RETURN:
|
||||
sprintf(keyStr, "Enter");
|
||||
break;
|
||||
case DIK_LCONTROL:
|
||||
sprintf(keyStr, "Left Ctrl");
|
||||
break;
|
||||
case DIK_RCONTROL:
|
||||
strcpy(keyStr, "Right Ctrl");
|
||||
break;
|
||||
case DIK_LSHIFT:
|
||||
sprintf(keyStr, "Left Shift");
|
||||
break;
|
||||
case DIK_RSHIFT:
|
||||
sprintf(keyStr, "Right Shift");
|
||||
break;
|
||||
case DIK_LMENU:
|
||||
sprintf(keyStr, "Left Alt");
|
||||
break;
|
||||
case DIK_RMENU:
|
||||
strcpy(keyStr, "Right Alt");
|
||||
break;
|
||||
case DIK_UP:
|
||||
sprintf(keyStr, "Up");
|
||||
break;
|
||||
case DIK_DOWN:
|
||||
sprintf(keyStr, "Down");
|
||||
break;
|
||||
case DIK_LEFT:
|
||||
sprintf(keyStr, "Left");
|
||||
break;
|
||||
case DIK_RIGHT:
|
||||
sprintf(keyStr, "Right");
|
||||
break;
|
||||
case DIK_HOME:
|
||||
strcpy(keyStr, "Home");
|
||||
break;
|
||||
case DIK_END:
|
||||
strcpy(keyStr, "End");
|
||||
break;
|
||||
case DIK_INSERT:
|
||||
strcpy(keyStr, "Ins");
|
||||
break;
|
||||
case DIK_DELETE:
|
||||
strcpy(keyStr, "Del");
|
||||
break;
|
||||
case DIK_PGUP:
|
||||
strcpy(keyStr, "PgUp");
|
||||
break;
|
||||
case DIK_PGDN:
|
||||
strcpy(keyStr, "PgDn");
|
||||
break;
|
||||
case DIK_NUMLOCK:
|
||||
strcpy(keyStr, "Num Lock");
|
||||
break;
|
||||
case DIK_NUMPAD0:
|
||||
strcpy(keyStr, "Num 0");
|
||||
break;
|
||||
case DIK_NUMPAD1:
|
||||
strcpy(keyStr, "Num 1");
|
||||
break;
|
||||
case DIK_NUMPAD2:
|
||||
strcpy(keyStr, "Num 2");
|
||||
break;
|
||||
case DIK_NUMPAD3:
|
||||
strcpy(keyStr, "Num 3");
|
||||
break;
|
||||
case DIK_NUMPAD4:
|
||||
strcpy(keyStr, "Num 4");
|
||||
break;
|
||||
case DIK_NUMPAD5:
|
||||
strcpy(keyStr, "Num 5");
|
||||
break;
|
||||
case DIK_NUMPAD6:
|
||||
strcpy(keyStr, "Num 6");
|
||||
break;
|
||||
case DIK_NUMPAD7:
|
||||
strcpy(keyStr, "Num 7");
|
||||
break;
|
||||
case DIK_NUMPAD8:
|
||||
strcpy(keyStr, "Num 8");
|
||||
break;
|
||||
case DIK_NUMPAD9:
|
||||
strcpy(keyStr, "Num 9");
|
||||
break;
|
||||
case DIK_DIVIDE:
|
||||
strcpy(keyStr, "Num /");
|
||||
break;
|
||||
case DIK_NUMPADENTER:
|
||||
strcpy(keyStr, "Num Enter");
|
||||
break;
|
||||
case DIK_DECIMAL:
|
||||
strcpy(keyStr, "Num Decimal");
|
||||
break;
|
||||
case DIK_NUMPADCOMMA:
|
||||
case DIK_ABNT_C2:
|
||||
strcpy(keyStr, "Num Separator");
|
||||
break;
|
||||
case DIK_NUMPADEQUALS:
|
||||
strcpy(keyStr, "Num =");
|
||||
break;
|
||||
default:
|
||||
// TODO: Switch to unicode GetKeyNameText?
|
||||
GetKeyNameTextA(keycode << 16, keyStr, 64);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT DInput::Init(HWND hWnd)
|
||||
{
|
||||
HRESULT hr;
|
||||
DWORD dwCoopFlags;
|
||||
dwCoopFlags = DISCL_FOREGROUND | DISCL_NOWINKEY;
|
||||
|
||||
// Create a DInput object
|
||||
if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8, (VOID* *)&g_pDI, NULL)))
|
||||
{
|
||||
MessageBox(0, L"Direct Input Create Failed", 0, MB_ICONERROR);
|
||||
return(hr);
|
||||
}
|
||||
|
||||
if (FAILED(hr = g_pDI->CreateDevice(GUID_SysKeyboard, &g_pKeyboard, NULL)))
|
||||
{
|
||||
MessageBox(0, L"Couldn't access keyboard", 0, MB_ICONERROR);
|
||||
Free();
|
||||
return(hr);
|
||||
}
|
||||
|
||||
g_pKeyboard->SetDataFormat(&c_dfDIKeyboard);
|
||||
g_pKeyboard->SetCooperativeLevel(hWnd, dwCoopFlags);
|
||||
g_pKeyboard->Acquire();
|
||||
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
void DInput::Free()
|
||||
{
|
||||
if (g_pKeyboard)
|
||||
{
|
||||
g_pKeyboard->Unacquire();
|
||||
g_pKeyboard->Release();
|
||||
g_pKeyboard = 0;
|
||||
}
|
||||
|
||||
if (g_pDI)
|
||||
{
|
||||
g_pDI->Release();
|
||||
g_pDI = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Desc: Read the input device's state when in immediate mode and display it.
|
||||
HRESULT DInput::Read()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if (NULL == g_pKeyboard)
|
||||
{
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
// Get the input's device state, and put the state in dims
|
||||
ZeroMemory(diks, sizeof(diks));
|
||||
hr = g_pKeyboard->GetDeviceState(sizeof(diks), diks);
|
||||
|
||||
//for (int i=0; i<256; i++)
|
||||
// if (diks[i]) MessageBox(0,"DSFJDKSF|",0,0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
// DirectInput may be telling us that the input stream has been
|
||||
// interrupted. We aren't tracking any state between polls, so
|
||||
// we don't have any special reset that needs to be done.
|
||||
// We just re-acquire and try again.
|
||||
|
||||
// If input is lost then acquire and keep trying
|
||||
hr = g_pKeyboard->Acquire();
|
||||
|
||||
while (hr == DIERR_INPUTLOST)
|
||||
{
|
||||
hr = g_pKeyboard->Acquire();
|
||||
}
|
||||
|
||||
// hr may be DIERR_OTHERAPPHASPRIO or other errors. This
|
||||
// may occur when the app is minimized or in the process of
|
||||
// switching, so just try again later
|
||||
return(S_OK);
|
||||
}
|
||||
|
||||
return(S_OK);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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 _DIRECTINPUTBASE_H
|
||||
#define _DIRECTINPUTBASE_H
|
||||
|
||||
|
||||
#include <windows.h> // System
|
||||
#include <stdio.h>
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x0800 // DirectInput
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
|
||||
class DInput
|
||||
{
|
||||
public:
|
||||
|
||||
DInput();
|
||||
~DInput();
|
||||
|
||||
static void DInput::DIKToString(unsigned int keycode, char *keyStr);
|
||||
|
||||
HRESULT Init(HWND hWnd);
|
||||
void Free();
|
||||
HRESULT Read();
|
||||
|
||||
|
||||
BYTE diks[256]; // DirectInput keyboard state buffer
|
||||
|
||||
private:
|
||||
|
||||
LPDIRECTINPUT8 g_pDI; // The DirectInput object
|
||||
LPDIRECTINPUTDEVICE8 g_pKeyboard; // The keyboard device
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,23 +0,0 @@
|
||||
namespace InputCommon
|
||||
{
|
||||
enum EButtonType
|
||||
{
|
||||
CTL_AXIS = 0,
|
||||
CTL_HAT,
|
||||
CTL_BUTTON,
|
||||
CTL_KEY,
|
||||
};
|
||||
|
||||
enum ETriggerType
|
||||
{
|
||||
CTL_TRIGGER_SDL = 0,
|
||||
CTL_TRIGGER_XINPUT,
|
||||
};
|
||||
|
||||
enum EXInputTrigger
|
||||
{
|
||||
XI_TRIGGER_L = 0,
|
||||
XI_TRIGGER_R,
|
||||
};
|
||||
|
||||
}
|
@ -17,19 +17,6 @@
|
||||
|
||||
#include "InputConfig.h"
|
||||
|
||||
InputPlugin::InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name )
|
||||
: ini_name(_ini_name)
|
||||
, gui_name(_gui_name)
|
||||
, profile_name(_profile_name)
|
||||
{
|
||||
// GCPads
|
||||
//for ( unsigned int i = 0; i<4; ++i )
|
||||
//controllers.push_back( new GCPad( i ) );
|
||||
// Wiimotes / disabled, cause it only the GUI half is done
|
||||
//for ( unsigned int i = 0; i<4; ++i )
|
||||
// controllers.push_back( new Wiimote( i ) );
|
||||
};
|
||||
|
||||
InputPlugin::~InputPlugin()
|
||||
{
|
||||
// delete pads
|
||||
@ -52,14 +39,14 @@ bool InputPlugin::LoadConfig()
|
||||
// load settings from ini
|
||||
(*i)->LoadConfig(inifile.GetOrCreateSection((*i)->GetName().c_str()));
|
||||
// update refs
|
||||
(*i)->UpdateReferences(controller_interface);
|
||||
(*i)->UpdateReferences(g_controller_interface);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
controllers[0]->LoadDefaults(controller_interface);
|
||||
controllers[0]->UpdateReferences(controller_interface);
|
||||
controllers[0]->LoadDefaults(g_controller_interface);
|
||||
controllers[0]->UpdateReferences(g_controller_interface);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -30,13 +30,16 @@
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
|
||||
// InputPlugin isn't a very good name anymore since it's also used for GCPad which
|
||||
// will soon not even be a plugin anymore.
|
||||
// InputPlugin isn't a very good name anymore since it's used by GCPad/Wiimote
|
||||
// which are not even plugins anymore.
|
||||
class InputPlugin
|
||||
{
|
||||
public:
|
||||
|
||||
InputPlugin( const char* const _ini_name, const char* const _gui_name, const char* const _profile_name );
|
||||
InputPlugin(const char* const _ini_name, const char* const _gui_name,
|
||||
const char* const _profile_name)
|
||||
: ini_name(_ini_name), gui_name(_gui_name), profile_name(_profile_name) {}
|
||||
|
||||
~InputPlugin();
|
||||
|
||||
bool LoadConfig();
|
||||
@ -44,8 +47,7 @@ public:
|
||||
|
||||
std::vector< ControllerEmu* > controllers;
|
||||
|
||||
Common::CriticalSection controls_crit; // critical section for changing any control references
|
||||
ControllerInterface controller_interface;
|
||||
Common::CriticalSection controls_crit; // critical section for changing any control references
|
||||
|
||||
const char * const ini_name;
|
||||
const char * const gui_name;
|
||||
|
@ -3,13 +3,11 @@ import sys
|
||||
Import('env')
|
||||
|
||||
files = [
|
||||
'Configuration.cpp',
|
||||
'ControllerEmu.cpp',
|
||||
'InputConfig.cpp',
|
||||
'ControllerInterface/ControllerInterface.cpp',
|
||||
'UDPWiimote.cpp',
|
||||
'UDPWrapper.cpp',
|
||||
'SDL_Util.cpp', # XXX needed by old Wiimote plugin
|
||||
]
|
||||
|
||||
if sys.platform == 'win32':
|
||||
@ -30,7 +28,6 @@ elif env['HAVE_X11']:
|
||||
files += [
|
||||
'ControllerInterface/SDL/SDL.cpp',
|
||||
'ControllerInterface/Xlib/Xlib.cpp',
|
||||
'X11InputBase.cpp'
|
||||
]
|
||||
|
||||
env.StaticLibrary(env['local_libs'] + "inputcommon", files)
|
||||
|
@ -1,222 +0,0 @@
|
||||
|
||||
// Project description
|
||||
// -------------------
|
||||
// Name: SDL Input
|
||||
// Description: Common SDL Input Functions
|
||||
//
|
||||
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
|
||||
// Copyright (C) 2003 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/
|
||||
//
|
||||
|
||||
|
||||
#define _SDL_MAIN_ // Avoid certain declarations in SDL.h
|
||||
#include "InputCommon.h"
|
||||
#include "SDL_Util.h" // Local
|
||||
#ifdef _WIN32
|
||||
#include "XInput_Util.h"
|
||||
#endif
|
||||
|
||||
namespace InputCommon
|
||||
{
|
||||
|
||||
|
||||
// Search attached devices. Populate joyinfo for all attached physical devices.
|
||||
// -----------------------
|
||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||
{
|
||||
if (!SDL_WasInit(0))
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0)
|
||||
#else
|
||||
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
|
||||
#endif
|
||||
{
|
||||
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
// We have now read the values we need so we close the device
|
||||
// if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
|
||||
}
|
||||
|
||||
_NumPads = (int)_joyinfo.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Avoid extreme axis values
|
||||
// ---------------------
|
||||
/* Function: We have to avoid very big values because some triggers are -0x8000 in the
|
||||
unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
|
||||
bool AvoidValues(int value, bool NoTriggerFilter)
|
||||
{
|
||||
// Avoid detecting very small or very big (for triggers) values
|
||||
if((value > -0x1000 && value < 0x1000) // Small values
|
||||
|| ((value < -0x7000 || value > 0x7000) && !NoTriggerFilter)) // Big values
|
||||
return true; // Avoid
|
||||
else
|
||||
return false; // Keep
|
||||
}
|
||||
|
||||
|
||||
// Detect a pressed button
|
||||
// ---------------------
|
||||
void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int hats,
|
||||
int &KeyboardKey, int &value, int &type, int &pressed, bool &Succeed, bool &Stop,
|
||||
bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat, bool NoTriggerFilter)
|
||||
{
|
||||
// It needs the wxWidgets excape keycode
|
||||
static const int WXK_ESCAPE = 27;
|
||||
|
||||
// Update the internal status
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
// For the triggers we accept both a digital or an analog button
|
||||
if(Axis)
|
||||
{
|
||||
for(int i = 0; i < axes; i++)
|
||||
{
|
||||
value = SDL_JoystickGetAxis(joy, i);
|
||||
|
||||
if(AvoidValues(value, NoTriggerFilter)) continue; // Avoid values
|
||||
|
||||
pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
|
||||
type = InputCommon::CTL_AXIS;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a hat
|
||||
if(Hat)
|
||||
{
|
||||
for(int i = 0; i < hats; i++)
|
||||
{
|
||||
value = SDL_JoystickGetHat(joy, i);
|
||||
if(value)
|
||||
{
|
||||
pressed = i;
|
||||
type = InputCommon::CTL_HAT;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a button
|
||||
if(Button)
|
||||
{
|
||||
for(int i = 0; i < buttons; i++)
|
||||
{
|
||||
// Some kind of bug in SDL 1.3 would give button 9 and 10 (nonexistent) the value 48 on the 360 pad
|
||||
if (SDL_JoystickGetButton(joy, i) > 1) continue;
|
||||
|
||||
if(SDL_JoystickGetButton(joy, i))
|
||||
{
|
||||
pressed = i;
|
||||
type = InputCommon::CTL_BUTTON;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a XInput trigger
|
||||
#ifdef _WIN32
|
||||
if(XInput && LeftRight)
|
||||
{
|
||||
for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++)
|
||||
{
|
||||
if(XInput::GetXI(ControllerID, i))
|
||||
{
|
||||
pressed = i + 1000;
|
||||
type = InputCommon::CTL_AXIS;
|
||||
Succeed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Check for keyboard action
|
||||
if (KeyboardKey)
|
||||
{
|
||||
if(Button)
|
||||
{
|
||||
// Todo: Add a separate keyboard vector to remove this restriction
|
||||
if(KeyboardKey >= buttons)
|
||||
{
|
||||
pressed = KeyboardKey;
|
||||
type = InputCommon::CTL_BUTTON;
|
||||
Succeed = true;
|
||||
KeyboardKey = 0;
|
||||
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the escape key
|
||||
}
|
||||
// Else show the error message
|
||||
else
|
||||
{
|
||||
pressed = KeyboardKey;
|
||||
KeyboardKey = -1;
|
||||
Stop = true;
|
||||
}
|
||||
}
|
||||
// Only accept the escape key
|
||||
else if (KeyboardKey == WXK_ESCAPE)
|
||||
{
|
||||
Succeed = true;
|
||||
KeyboardKey = 0;
|
||||
pressed = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // InputCommon
|
||||
|
@ -1,76 +0,0 @@
|
||||
// Copyright (C) 2003 Dolphin Project.
|
||||
|
||||
// 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 <iostream> // System
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <SDL.h> // Externals
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
#include <SDL_haptic.h>
|
||||
#endif
|
||||
#else
|
||||
#include <SDL/SDL.h>
|
||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||
#include <SDL/SDL_haptic.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "Common.h" // Common
|
||||
|
||||
|
||||
namespace InputCommon
|
||||
{
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
// General functions
|
||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &NumPads, int &NumGoodPads);
|
||||
void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool,bool);
|
||||
|
||||
// Value conversion
|
||||
float Deg2Rad(float Deg);
|
||||
float Rad2Deg(float Rad);
|
||||
int Pad_Convert(int _val);
|
||||
float SquareDistance(float deg);
|
||||
bool IsDeadZone(float DeadZone, int x, int y);
|
||||
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square = false);
|
||||
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius);
|
||||
// Input configuration
|
||||
std::string VKToString(int keycode);
|
||||
|
||||
|
||||
} // InputCommon
|
||||
|
||||
|
||||
#endif // _SDL_h
|
@ -1,5 +1,8 @@
|
||||
|
||||
#include "UDPWiimote.h"
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <winsock2.h>
|
||||
@ -418,3 +421,5 @@ void UDPWiimote::changeName(const char * name)
|
||||
displayName=name;
|
||||
d->nameMutex.Leave();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,7 @@
|
||||
#ifndef UDPWIIMOTE_H
|
||||
|
||||
//#define USE_UDP_WIIMOTE
|
||||
|
||||
#if (!defined(UDPWIIMOTE_H) && defined(USE_UDP_WIIMOTE))
|
||||
#define UDPWIIMOTE_H
|
||||
|
||||
#include "Common.h"
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
#include "UDPWrapper.h"
|
||||
|
||||
#ifdef USE_UDP_WIIMOTE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -197,3 +201,5 @@ void UDPWrapper::Configure(wxWindow * parent)
|
||||
diag->Destroy();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,7 @@
|
||||
#ifndef UDPWRAPPER_H
|
||||
|
||||
#include "UDPWiimote.h"
|
||||
|
||||
#if (defined(USE_UDP_WIIMOTE) && !defined(UDPWRAPPER_H))
|
||||
#define UDPWRAPPER_H
|
||||
|
||||
#include "Common.h"
|
||||
@ -19,8 +22,6 @@
|
||||
#include <wx/spinctrl.h>
|
||||
#endif
|
||||
|
||||
#include "UDPWiimote.h"
|
||||
|
||||
class UDPWrapper : public ControllerEmu::ControlGroup
|
||||
{
|
||||
public:
|
||||
|
@ -1,123 +0,0 @@
|
||||
|
||||
//
|
||||
// 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/
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
// File description
|
||||
/* -------------------
|
||||
Function: This file will get the status of the analog triggers of any connected XInput device.
|
||||
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
|
||||
Samples.
|
||||
|
||||
///////////////////////////////////////////////////// */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
||||
// Includes
|
||||
// -------------------
|
||||
#include <windows.h>
|
||||
#include <XInput.h> // XInput API
|
||||
#include "InputCommon.h"
|
||||
|
||||
namespace XInput
|
||||
{
|
||||
|
||||
// Declarations
|
||||
// -------------------
|
||||
|
||||
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
|
||||
|
||||
struct CONTROLER_STATE
|
||||
{
|
||||
XINPUT_STATE state;
|
||||
bool bConnected;
|
||||
};
|
||||
|
||||
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
|
||||
|
||||
|
||||
// Init
|
||||
// -------------------
|
||||
/* Function: Calculate the number of connected XInput devices
|
||||
Todo: Implement this to figure out if there are multiple XInput controllers connected,
|
||||
we currently only try to connect to XInput device 0 */
|
||||
void Init()
|
||||
{
|
||||
// Init state
|
||||
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
|
||||
|
||||
// Declaration
|
||||
DWORD dwResult;
|
||||
|
||||
// Calculate the number of connected XInput devices
|
||||
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
|
||||
{
|
||||
// Simply get the state of the controller from XInput.
|
||||
dwResult = XInputGetState( i, &g_Controllers[i].state );
|
||||
|
||||
if( dwResult == ERROR_SUCCESS )
|
||||
g_Controllers[i].bConnected = true;
|
||||
else
|
||||
g_Controllers[i].bConnected = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get the trigger status
|
||||
// -------------------
|
||||
int GetXI(int Controller, int Button)
|
||||
{
|
||||
// Update the internal status
|
||||
DWORD dwResult;
|
||||
dwResult = XInputGetState(Controller, &g_Controllers[Controller].state);
|
||||
|
||||
if (dwResult != ERROR_SUCCESS) return -1;
|
||||
|
||||
switch (Button)
|
||||
{
|
||||
case InputCommon::XI_TRIGGER_L:
|
||||
return g_Controllers[Controller].state.Gamepad.bLeftTrigger;
|
||||
|
||||
case InputCommon::XI_TRIGGER_R:
|
||||
return g_Controllers[Controller].state.Gamepad.bRightTrigger;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a certain controller is connected
|
||||
// -------------------
|
||||
bool IsConnected(int Controller)
|
||||
{
|
||||
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
|
||||
|
||||
// Update the connected status
|
||||
if( dwResult == ERROR_SUCCESS )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
} // XInput
|
||||
|
||||
#endif
|
@ -1,42 +0,0 @@
|
||||
|
||||
//
|
||||
// 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/
|
||||
//
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
|
||||
// Includes
|
||||
// ----------
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace XInput
|
||||
{
|
||||
|
||||
// Declarations
|
||||
// ----------
|
||||
void Init();
|
||||
int GetXI(int Controller, int Button);
|
||||
bool IsConnected(int Controller);
|
||||
|
||||
} // XInput
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user