mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
Fix crazy svn changing trunk on last commit
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2206 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -15,6 +15,10 @@
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Include
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
@ -22,43 +26,69 @@
|
||||
#include "pluginspecs_pad.h"
|
||||
#include "PadSimple.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
|
||||
#include "ConsoleWindow.h"
|
||||
#include "StringUtil.h"
|
||||
#include "ChunkFile.h"
|
||||
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include "GUI/ConfigDlg.h"
|
||||
#include "GUI/ConfigDlg.h"
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "XInput.h"
|
||||
#include "DirectInputBase.h"
|
||||
#include "XInput.h"
|
||||
#include "DirectInputBase.h"
|
||||
|
||||
DInput dinput;
|
||||
//#elif defined(USE_SDL) && USE_SDL
|
||||
//#include <SDL.h>
|
||||
DInput dinput;
|
||||
//#elif defined(USE_SDL) && USE_SDL
|
||||
//#include <SDL.h>
|
||||
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/XKBlib.h>
|
||||
|
||||
Display* GXdsp;
|
||||
bool KeyStatus[NUMCONTROLS];
|
||||
Display* GXdsp;
|
||||
bool KeyStatus[NUMCONTROLS];
|
||||
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
||||
#include <Cocoa/Cocoa.h>
|
||||
bool KeyStatus[NUMCONTROLS];
|
||||
#include <Cocoa/Cocoa.h>
|
||||
bool KeyStatus[NUMCONTROLS];
|
||||
#endif
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Declarations
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
SPads pad[4];
|
||||
|
||||
HINSTANCE g_hInstance;
|
||||
SPADInitialize g_PADInitialize;
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Input Recording
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// Enable these to record or play back
|
||||
//#define RECORD_REPLAY
|
||||
//#define RECORD_STORE
|
||||
|
||||
// Pre defined maxium storage limit
|
||||
#define RECORD_SIZE (1024 * 128)
|
||||
SPADStatus recordBuffer[RECORD_SIZE];
|
||||
int count = 0;
|
||||
bool g_EmulatorRunning = false;
|
||||
////////////////////////////////
|
||||
|
||||
|
||||
// TODO: fix this dirty hack to stop missing symbols
|
||||
void __Log(int log, const char *format, ...) {}
|
||||
void __Logv(int log, int v, const char *format, ...) {}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Supporting functions
|
||||
@ -66,46 +96,68 @@ int count = 0;
|
||||
|
||||
void RecordInput(const SPADStatus& _rPADStatus)
|
||||
{
|
||||
if (count >= RECORD_SIZE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (count >= RECORD_SIZE) return;
|
||||
recordBuffer[count++] = _rPADStatus;
|
||||
}
|
||||
|
||||
// Logging
|
||||
//u8 TmpData[sizeof(SPADStatus)];
|
||||
//memcpy(TmpData, &recordBuffer[count - 1], sizeof(SPADStatus));
|
||||
//Console::Print("RecordInput(%i): %s\n", count, ArrayToString(TmpData, sizeof(SPADStatus), 0, 30).c_str());
|
||||
|
||||
// Auto save every ten seconds
|
||||
if (count % (60 * 10) == 0) SaveRecord();
|
||||
}
|
||||
|
||||
const SPADStatus& PlayRecord()
|
||||
{
|
||||
if (count >= RECORD_SIZE){return(recordBuffer[0]);}
|
||||
// Logging
|
||||
//Console::Print("PlayRecord(%i)\n", count);
|
||||
|
||||
if (count >= RECORD_SIZE)
|
||||
{
|
||||
// Todo: Make the recording size unlimited?
|
||||
//PanicAlert("The recording reached its end");
|
||||
return(recordBuffer[0]);
|
||||
}
|
||||
return(recordBuffer[count++]);
|
||||
}
|
||||
|
||||
|
||||
void LoadRecord()
|
||||
{
|
||||
FILE* pStream = fopen("c:\\pad-record.bin", "rb");
|
||||
FILE* pStream = fopen("pad-record.bin", "rb");
|
||||
|
||||
if (pStream != NULL)
|
||||
{
|
||||
fread(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream);
|
||||
fclose(pStream);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("SimplePad: Could not open pad-record.bin");
|
||||
}
|
||||
|
||||
//Console::Print("LoadRecord()");
|
||||
}
|
||||
|
||||
void SaveRecord()
|
||||
{
|
||||
FILE* pStream = fopen("c:\\pad-record.bin", "wb");
|
||||
// Open the file in a way that clears all old data
|
||||
FILE* pStream = fopen("pad-record.bin", "wb");
|
||||
|
||||
if (pStream != NULL)
|
||||
{
|
||||
fwrite(recordBuffer, 1, RECORD_SIZE * sizeof(SPADStatus), pStream);
|
||||
fclose(pStream);
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("SimplePad: Could not save pad-record.bin");
|
||||
}
|
||||
//PanicAlert("SaveRecord()");
|
||||
//Console::Print("SaveRecord()");
|
||||
}
|
||||
|
||||
|
||||
// Check if Dolphin is in focus
|
||||
bool IsFocus()
|
||||
{
|
||||
@ -167,89 +219,6 @@ BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle
|
||||
#endif
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Plugin specification functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
||||
{
|
||||
_PluginInfo->Version = 0x0100;
|
||||
_PluginInfo->Type = PLUGIN_TYPE_PAD;
|
||||
|
||||
#ifdef DEBUGFAST
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (DebugFast)");
|
||||
#else
|
||||
#ifndef _DEBUG
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad");
|
||||
#else
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (Debug)");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
|
||||
}
|
||||
|
||||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
LoadConfig();
|
||||
#ifdef _WIN32
|
||||
wxWindow win;
|
||||
win.SetHWND(_hParent);
|
||||
ConfigDialog frame(&win);
|
||||
frame.ShowModal();
|
||||
win.SetHWND(0);
|
||||
#elif defined(HAVE_WX) && HAVE_WX
|
||||
ConfigDialog frame(NULL);
|
||||
frame.ShowModal();
|
||||
#endif
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
void DllDebugger(HWND _hParent, bool Show) {
|
||||
}
|
||||
|
||||
void Initialize(void *init)
|
||||
{
|
||||
#ifdef RECORD_REPLAY
|
||||
LoadRecord();
|
||||
#endif
|
||||
|
||||
g_PADInitialize = *(SPADInitialize*)init;
|
||||
#ifdef _WIN32
|
||||
dinput.Init((HWND)g_PADInitialize.hWnd);
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
GXdsp = (Display*)g_PADInitialize.hWnd;
|
||||
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
||||
#endif
|
||||
|
||||
LoadConfig();
|
||||
}
|
||||
|
||||
void DoState(unsigned char **ptr, int mode) {
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
#ifdef RECORD_STORE
|
||||
SaveRecord();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
dinput.Free();
|
||||
// Kill xpad rumble
|
||||
XINPUT_VIBRATION vib;
|
||||
vib.wLeftMotorSpeed = 0;
|
||||
vib.wRightMotorSpeed = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (pad[i].bRumble)
|
||||
XInputSetState(pad[i].XPadPlayer, &vib);
|
||||
#endif
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
|
||||
const float kDeadZone = 0.1f;
|
||||
|
||||
// Implement circular deadzone
|
||||
@ -283,6 +252,9 @@ void ScaleStickValues(unsigned char* outx,
|
||||
*outy = 0x80 + iy;
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
// Input
|
||||
//******************************************************************************
|
||||
|
||||
#ifdef _WIN32
|
||||
void DInput_Read(int _numPAD, SPADStatus* _pPADStatus)
|
||||
@ -334,6 +306,8 @@ void DInput_Read(int _numPAD, SPADStatus* _pPADStatus)
|
||||
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADLEFT]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_LEFT;}
|
||||
if (dinput.diks[pad[_numPAD].keyForControl[CTL_DPADRIGHT]]& 0xFF){_pPADStatus->button |= PAD_BUTTON_RIGHT;}
|
||||
if (dinput.diks[pad[_numPAD].keyForControl[CTL_START]] & 0xFF){_pPADStatus->button |= PAD_BUTTON_START;}
|
||||
|
||||
_pPADStatus->MicButton = (dinput.diks[pad[_numPAD].keyForControl[CTL_MIC]] & 0xFF) ? true : false;
|
||||
}
|
||||
|
||||
bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus)
|
||||
@ -381,6 +355,8 @@ bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus)
|
||||
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_UP) {_pPADStatus->button |= PAD_BUTTON_UP;}
|
||||
if (xpad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) {_pPADStatus->button |= PAD_BUTTON_DOWN;}
|
||||
|
||||
//_pPADStatus->MicButton = (xpad.wButtons & XINPUT_GAMEPAD_LEFT_SHOULDER) ? true : false;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -610,25 +586,124 @@ void cocoa_Read(int _numPAD, SPADStatus* _pPADStatus)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Plugin specification functions
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
|
||||
{
|
||||
_PluginInfo->Version = 0x0100;
|
||||
_PluginInfo->Type = PLUGIN_TYPE_PAD;
|
||||
|
||||
#ifdef DEBUGFAST
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (DebugFast)");
|
||||
#else
|
||||
#ifndef _DEBUG
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad");
|
||||
#else
|
||||
sprintf(_PluginInfo->Name, "Dolphin KB/X360pad (Debug)");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {}
|
||||
|
||||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
LoadConfig();
|
||||
#ifdef _WIN32
|
||||
wxWindow win;
|
||||
win.SetHWND(_hParent);
|
||||
ConfigDialog frame(&win);
|
||||
frame.ShowModal();
|
||||
win.SetHWND(0);
|
||||
#elif defined(HAVE_WX) && HAVE_WX
|
||||
ConfigDialog frame(NULL);
|
||||
frame.ShowModal();
|
||||
#endif
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
void DllDebugger(HWND _hParent, bool Show) {}
|
||||
|
||||
void Initialize(void *init)
|
||||
{
|
||||
//Console::Open(70, 5000);
|
||||
|
||||
// We are now running a game
|
||||
g_EmulatorRunning = true;
|
||||
|
||||
// Load configuration
|
||||
LoadConfig();
|
||||
|
||||
// Load recorded input if we are to play it back, otherwise begin with a blank recording
|
||||
if (pad[0].bPlayback) LoadRecord();
|
||||
|
||||
g_PADInitialize = *(SPADInitialize*)init;
|
||||
|
||||
#ifdef _WIN32
|
||||
dinput.Init((HWND)g_PADInitialize.hWnd);
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
GXdsp = (Display*)g_PADInitialize.hWnd;
|
||||
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void DoState(unsigned char **ptr, int mode)
|
||||
{
|
||||
// Load or save the counter
|
||||
PointerWrap p(ptr, mode);
|
||||
p.Do(count);
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
//Console::Print("ShutDown()\n");
|
||||
|
||||
// Save recording
|
||||
if (pad[0].bRecording) SaveRecord();
|
||||
// Reset the counter
|
||||
count = 0;
|
||||
// We have stopped the game
|
||||
g_EmulatorRunning = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
dinput.Free();
|
||||
// Kill xpad rumble
|
||||
XINPUT_VIBRATION vib;
|
||||
vib.wLeftMotorSpeed = 0;
|
||||
vib.wRightMotorSpeed = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (pad[i].bRumble)
|
||||
XInputSetState(pad[i].XPadPlayer, &vib);
|
||||
#endif
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
|
||||
// Set buttons status from wxWidgets in the main application
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
void PAD_Input(u16 _Key, u8 _UpDown) {
|
||||
}
|
||||
void PAD_Input(u16 _Key, u8 _UpDown) {}
|
||||
|
||||
|
||||
void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
{
|
||||
// Check if all is okay
|
||||
if ((_pPADStatus == NULL))
|
||||
if (_pPADStatus == NULL) return;
|
||||
|
||||
// Play back input instead of accepting any user input
|
||||
if (pad[0].bPlayback)
|
||||
{
|
||||
*_pPADStatus = PlayRecord();
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef RECORD_REPLAY
|
||||
*_pPADStatus = PlayRecord();
|
||||
return;
|
||||
#endif
|
||||
|
||||
const int base = 0x80;
|
||||
// Clear pad
|
||||
memset(_pPADStatus, 0, sizeof(SPADStatus));
|
||||
@ -639,15 +714,18 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
_pPADStatus->substickY = base;
|
||||
_pPADStatus->button |= PAD_USE_ORIGIN;
|
||||
#ifdef _WIN32
|
||||
// Just update pad on focus
|
||||
if (pad[_numPAD].bDisable)
|
||||
{
|
||||
if (!IsFocus()) return;
|
||||
}
|
||||
// Only update pad on focus, don't do this when recording
|
||||
if (pad[_numPAD].bDisable && !pad[0].bRecording && !IsFocus()) return;
|
||||
|
||||
// Dolphin doesn't really care about the pad error codes anyways...
|
||||
_pPADStatus->err = PAD_ERR_NONE;
|
||||
|
||||
// Read XInput
|
||||
if (pad[_numPAD].bEnableXPad) XInput_Read(pad[_numPAD].XPadPlayer, _pPADStatus);
|
||||
|
||||
// Read Direct Input
|
||||
DInput_Read(_numPAD, _pPADStatus);
|
||||
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
_pPADStatus->err = PAD_ERR_NONE;
|
||||
X11_Read(_numPAD, _pPADStatus);
|
||||
@ -656,9 +734,8 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
cocoa_Read(_numPAD, _pPADStatus);
|
||||
#endif
|
||||
|
||||
#ifdef RECORD_STORE
|
||||
RecordInput(*_pPADStatus);
|
||||
#endif
|
||||
// Record input
|
||||
if (pad[0].bRecording) RecordInput(*_pPADStatus);
|
||||
}
|
||||
|
||||
|
||||
@ -742,7 +819,8 @@ void LoadConfig()
|
||||
DIK_G,
|
||||
DIK_F,
|
||||
DIK_H,
|
||||
DIK_LSHIFT
|
||||
DIK_LSHIFT, //halfpress
|
||||
DIK_M //Mic
|
||||
};
|
||||
#elif defined(HAVE_X11) && HAVE_X11
|
||||
const int defaultKeyForControl[NUMCONTROLS] =
|
||||
@ -768,7 +846,7 @@ void LoadConfig()
|
||||
XK_f,
|
||||
XK_h,
|
||||
XK_Shift_L, //halfpress
|
||||
XK_p
|
||||
XK_p //Mic
|
||||
};
|
||||
#elif defined(HAVE_COCOA) && HAVE_COCOA
|
||||
const int defaultKeyForControl[NUMCONTROLS] =
|
||||
@ -794,7 +872,7 @@ void LoadConfig()
|
||||
3,
|
||||
4,
|
||||
56, //halfpress
|
||||
35
|
||||
35 //Mic
|
||||
};
|
||||
#endif
|
||||
IniFile file;
|
||||
@ -811,6 +889,9 @@ void LoadConfig()
|
||||
file.Get(SectionName, "Rumble", &pad[i].bRumble, true);
|
||||
file.Get(SectionName, "XPad#", &pad[i].XPadPlayer);
|
||||
|
||||
file.Get(SectionName, "Recording", &pad[i].bRecording, false);
|
||||
file.Get(SectionName, "Playback", &pad[i].bPlayback, false);
|
||||
|
||||
for (int x = 0; x < NUMCONTROLS; x++)
|
||||
{
|
||||
file.Get(SectionName, controlNames[x], &pad[i].keyForControl[x],
|
||||
@ -840,6 +921,9 @@ void SaveConfig()
|
||||
file.Set(SectionName, "DisableOnBackground", pad[i].bDisable);
|
||||
file.Set(SectionName, "Rumble", pad[i].bRumble);
|
||||
file.Set(SectionName, "XPad#", pad[i].XPadPlayer);
|
||||
// Recording
|
||||
file.Set(SectionName, "Recording", pad[i].bRecording);
|
||||
file.Set(SectionName, "Playback", pad[i].bPlayback);
|
||||
|
||||
for (int x = 0; x < NUMCONTROLS; x++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user