attempt to fix the main window closing from r5056. i'm not sure how this affects window deletion tho.

apply eol-style native to GCPad, pretty annoying to break patches and stuff

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5059 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
j4ck.fr0st
2010-02-14 16:33:53 +00:00
parent dc7029e7f4
commit cd321feb83
13 changed files with 3460 additions and 3456 deletions
@@ -193,6 +193,7 @@ void DllConfig(HWND _hParent)
m_ConfigFrame->ShowModal();
delete m_ConfigFrame;
frame->SetHWND(NULL);
delete frame;
m_ConfigFrame = 0;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+49 -49
View File
@@ -1,49 +1,49 @@
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 _PLUGIN_GCPAD_CONFIG_H
#define _PLUGIN_GCPAD_CONFIG_H
struct Config
{
Config();
void Load();
void Save();
// General
bool bNoTriggerFilter;
#ifdef RERECORDING
bool bRecording;
bool bPlayback;
#endif
};
extern Config g_Config;
#endif // _PLUGIN_GCPAD_CONFIG_H
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 _PLUGIN_GCPAD_CONFIG_H
#define _PLUGIN_GCPAD_CONFIG_H
struct Config
{
Config();
void Load();
void Save();
// General
bool bNoTriggerFilter;
#ifdef RERECORDING
bool bRecording;
bool bPlayback;
#endif
};
extern Config g_Config;
#endif // _PLUGIN_GCPAD_CONFIG_H
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+168 -168
View File
@@ -1,168 +1,168 @@
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 _PLUGIN_GCPAD_H
#define _PLUGIN_GCPAD_H
#include <vector> // System
#include <cstdio>
#include "../../../Core/InputCommon/Src/InputCommon.h" // Core
#include "../../../Core/InputCommon/Src/SDL_Util.h"
#ifdef _WIN32
#include "../../../Core/InputCommon/Src/XInput_Util.h"
#elif defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
//no need for Cocoa yet, but I guess ayuanx isn't done yet.
//#elif defined(HAVE_COCOA) && HAVE_COCOA
// #include <Cocoa/Cocoa.h>
#endif
#include "pluginspecs_pad.h"
#define DEF_BUTTON_FULL 255
#define DEF_STICK_FULL 100
#define DEF_STICK_HALF 50
#define DEF_TRIGGER_FULL 255
#define DEF_TRIGGER_HALF 128
#define DEF_TRIGGER_THRESHOLD 230
// GC Pad Buttons
enum EGCPad
{
EGC_A = 0,
EGC_B,
EGC_X,
EGC_Y,
EGC_Z,
EGC_START,
EGC_DPAD_UP,
EGC_DPAD_DOWN,
EGC_DPAD_LEFT,
EGC_DPAD_RIGHT,
EGC_STICK_UP,
EGC_STICK_DOWN,
EGC_STICK_LEFT,
EGC_STICK_RIGHT,
EGC_STICK_SEMI,
EGC_CSTICK_UP,
EGC_CSTICK_DOWN,
EGC_CSTICK_LEFT,
EGC_CSTICK_RIGHT,
EGC_CSTICK_SEMI,
EGC_TGR_L,
EGC_TGR_R,
EGC_TGR_SEMI_L,
EGC_TGR_SEMI_R,
LAST_CONSTANT,
};
enum EInputType
{
FROM_KEYBOARD,
FROM_ANALOG1,
FROM_ANALOG2,
FROM_TRIGGER,
};
union UAxis
{
int Code[6];
struct
{
int Lx;
int Ly;
int Rx;
int Ry;
int Tl; // Trigger
int Tr; // Trigger
};
};
struct SStickMapping
{
int Main;
int Sub;
int Shoulder; //Trigger
};
struct CONTROLLER_MAPPING_GC // PAD MAPPING GC
{
int ID; // SDL joystick device ID
SDL_Joystick *joy; // SDL joystick device
UAxis AxisState;
UAxis AxisMapping; // 6 Axes (Main, Sub, Triggers)
int TriggerType; // SDL or XInput trigger
bool Rumble;
int RumbleStrength;
int DeadZoneL; // Analog 1 Deadzone
int DeadZoneR; // Analog 2 Deadzone
bool bSquare2Circle;
int Diagonal;
SStickMapping Stick;
SStickMapping Pressure;
int Button[LAST_CONSTANT];
};
extern CONTROLLER_MAPPING_GC GCMapping[4];
extern int NumPads, NumGoodPads, g_ID;
extern SPADInitialize *g_PADInitialize;
extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
#ifdef _WIN32
extern HWND m_hWnd; // Handle to window
#endif
#if defined(HAVE_X11) && HAVE_X11
extern Display* WMdisplay;
#endif
// Custom Functions
// ----------------
void EmulateAnalogStick(unsigned char &stickX, unsigned char &stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude);
void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR);
void Close_Devices();
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads);
void GetAxisState(CONTROLLER_MAPPING_GC &_GCMapping);
void UpdatePadState(CONTROLLER_MAPPING_GC &_GCMapping);
bool IsKey(int Key);
bool IsFocus();
bool ReloadDLL();
void PAD_RumbleClose();
#endif // _PLUGIN_GCPAD_H
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 _PLUGIN_GCPAD_H
#define _PLUGIN_GCPAD_H
#include <vector> // System
#include <cstdio>
#include "../../../Core/InputCommon/Src/InputCommon.h" // Core
#include "../../../Core/InputCommon/Src/SDL_Util.h"
#ifdef _WIN32
#include "../../../Core/InputCommon/Src/XInput_Util.h"
#elif defined(HAVE_X11) && HAVE_X11
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
//no need for Cocoa yet, but I guess ayuanx isn't done yet.
//#elif defined(HAVE_COCOA) && HAVE_COCOA
// #include <Cocoa/Cocoa.h>
#endif
#include "pluginspecs_pad.h"
#define DEF_BUTTON_FULL 255
#define DEF_STICK_FULL 100
#define DEF_STICK_HALF 50
#define DEF_TRIGGER_FULL 255
#define DEF_TRIGGER_HALF 128
#define DEF_TRIGGER_THRESHOLD 230
// GC Pad Buttons
enum EGCPad
{
EGC_A = 0,
EGC_B,
EGC_X,
EGC_Y,
EGC_Z,
EGC_START,
EGC_DPAD_UP,
EGC_DPAD_DOWN,
EGC_DPAD_LEFT,
EGC_DPAD_RIGHT,
EGC_STICK_UP,
EGC_STICK_DOWN,
EGC_STICK_LEFT,
EGC_STICK_RIGHT,
EGC_STICK_SEMI,
EGC_CSTICK_UP,
EGC_CSTICK_DOWN,
EGC_CSTICK_LEFT,
EGC_CSTICK_RIGHT,
EGC_CSTICK_SEMI,
EGC_TGR_L,
EGC_TGR_R,
EGC_TGR_SEMI_L,
EGC_TGR_SEMI_R,
LAST_CONSTANT,
};
enum EInputType
{
FROM_KEYBOARD,
FROM_ANALOG1,
FROM_ANALOG2,
FROM_TRIGGER,
};
union UAxis
{
int Code[6];
struct
{
int Lx;
int Ly;
int Rx;
int Ry;
int Tl; // Trigger
int Tr; // Trigger
};
};
struct SStickMapping
{
int Main;
int Sub;
int Shoulder; //Trigger
};
struct CONTROLLER_MAPPING_GC // PAD MAPPING GC
{
int ID; // SDL joystick device ID
SDL_Joystick *joy; // SDL joystick device
UAxis AxisState;
UAxis AxisMapping; // 6 Axes (Main, Sub, Triggers)
int TriggerType; // SDL or XInput trigger
bool Rumble;
int RumbleStrength;
int DeadZoneL; // Analog 1 Deadzone
int DeadZoneR; // Analog 2 Deadzone
bool bSquare2Circle;
int Diagonal;
SStickMapping Stick;
SStickMapping Pressure;
int Button[LAST_CONSTANT];
};
extern CONTROLLER_MAPPING_GC GCMapping[4];
extern int NumPads, NumGoodPads, g_ID;
extern SPADInitialize *g_PADInitialize;
extern std::vector<InputCommon::CONTROLLER_INFO> joyinfo;
#ifdef _WIN32
extern HWND m_hWnd; // Handle to window
#endif
#if defined(HAVE_X11) && HAVE_X11
extern Display* WMdisplay;
#endif
// Custom Functions
// ----------------
void EmulateAnalogStick(unsigned char &stickX, unsigned char &stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude);
void EmulateAnalogTrigger(unsigned char &trL, unsigned char &trR);
void Close_Devices();
bool Search_Devices(std::vector<InputCommon::CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads);
void GetAxisState(CONTROLLER_MAPPING_GC &_GCMapping);
void UpdatePadState(CONTROLLER_MAPPING_GC &_GCMapping);
bool IsKey(int Key);
bool IsFocus();
bool ReloadDLL();
void PAD_RumbleClose();
#endif // _PLUGIN_GCPAD_H
+180 -180
View File
@@ -1,181 +1,181 @@
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 "GCPad.h"
#include "FileUtil.h"
#include "ChunkFile.h"
// TODO :
// This is pretty much useless now with the TAS features right ?
#ifdef RERECORDING
namespace Recording
{
// Definitions
// -------------
// Pre defined maxium storage limit
#define RECORD_SIZE (1024 * 128)
SPADStatus RecordBuffer[RECORD_SIZE];
int count = 0;
// Recording functions
// -------------
void RecordInput(const SPADStatus& _rPADStatus)
{
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) Save();
}
const SPADStatus& Play()
{
// 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 Load()
{
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 Save()
{
// 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("NJoy: Could not save pad-record.bin");
}
//PanicAlert("SaveRecord()");
//Console::Print("SaveRecord()");
}
void Initialize()
{
// -------------------------------------------
// Rerecording
// ----------------------
#ifdef RERECORDING
/* Check if we are starting the pad to record the input, and an old file exists. In that case ask
if we really want to start the recording and eventually overwrite the file */
if (g_Config.bRecording && File::Exists("pad-record.bin"))
{
if (!AskYesNo("An old version of '%s' aleady exists in your Dolphin directory. You can"
" now make a copy of it before you start a new recording and overwrite the file."
" Select Yes to continue and overwrite the file. Select No to turn off the input"
" recording and continue without recording anything.",
"pad-record.bin"))
{
// Turn off recording and continue
g_Config.bRecording = false;
}
}
// Load recorded input if we are to play it back, otherwise begin with a blank recording
if (g_Config.bPlayback) Recording::Load();
#endif
// ----------------------
}
void ShutDown()
{
// Save recording
if (g_Config.bRecording) Recording::Save();
// Reset the counter
count = 0;
}
void DoState(unsigned char **ptr, int mode)
{
// Load or save the counter
PointerWrap p(ptr, mode);
p.Do(count);
//Console::Print("count: %i\n", count);
// Update the frame counter for the sake of the status bar
if (mode == PointerWrap::MODE_READ)
{
#ifdef _WIN32
// This only works when rendering to the main window, I think
PostMessage(GetParent(g_PADInitialize->hWnd), WM_USER, INPUT_FRAME_COUNTER, count);
#endif
}
}
} // Recording
// Project description
// -------------------
// Name: nJoy
// Description: A Dolphin Compatible Input Plugin
//
// Author: Falcon4ever (nJoy@falcon4ever.com)
// Site: www.multigesture.net
// Copyright (C) 2003 Dolphin Project.
//
// 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 "GCPad.h"
#include "FileUtil.h"
#include "ChunkFile.h"
// TODO :
// This is pretty much useless now with the TAS features right ?
#ifdef RERECORDING
namespace Recording
{
// Definitions
// -------------
// Pre defined maxium storage limit
#define RECORD_SIZE (1024 * 128)
SPADStatus RecordBuffer[RECORD_SIZE];
int count = 0;
// Recording functions
// -------------
void RecordInput(const SPADStatus& _rPADStatus)
{
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) Save();
}
const SPADStatus& Play()
{
// 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 Load()
{
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 Save()
{
// 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("NJoy: Could not save pad-record.bin");
}
//PanicAlert("SaveRecord()");
//Console::Print("SaveRecord()");
}
void Initialize()
{
// -------------------------------------------
// Rerecording
// ----------------------
#ifdef RERECORDING
/* Check if we are starting the pad to record the input, and an old file exists. In that case ask
if we really want to start the recording and eventually overwrite the file */
if (g_Config.bRecording && File::Exists("pad-record.bin"))
{
if (!AskYesNo("An old version of '%s' aleady exists in your Dolphin directory. You can"
" now make a copy of it before you start a new recording and overwrite the file."
" Select Yes to continue and overwrite the file. Select No to turn off the input"
" recording and continue without recording anything.",
"pad-record.bin"))
{
// Turn off recording and continue
g_Config.bRecording = false;
}
}
// Load recorded input if we are to play it back, otherwise begin with a blank recording
if (g_Config.bPlayback) Recording::Load();
#endif
// ----------------------
}
void ShutDown()
{
// Save recording
if (g_Config.bRecording) Recording::Save();
// Reset the counter
count = 0;
}
void DoState(unsigned char **ptr, int mode)
{
// Load or save the counter
PointerWrap p(ptr, mode);
p.Do(count);
//Console::Print("count: %i\n", count);
// Update the frame counter for the sake of the status bar
if (mode == PointerWrap::MODE_READ)
{
#ifdef _WIN32
// This only works when rendering to the main window, I think
PostMessage(GetParent(g_PADInitialize->hWnd), WM_USER, INPUT_FRAME_COUNTER, count);
#endif
}
}
} // Recording
#endif // RERECORDING
File diff suppressed because it is too large Load Diff
+28 -28
View File
@@ -1,28 +1,28 @@
# -*- python -*-
Import('env')
import sys
name = "Plugin_GCPad"
padenv = env.Clone()
if not env['HAVE_SDL']:
print name + " must have SDL to be build"
Return()
files = [
'Config.cpp',
'GCPad.cpp',
'Rumble.cpp',
]
if padenv['HAVE_WX']:
files += [
'ConfigJoypad.cpp',
'ConfigBox.cpp',
]
padenv.Append(
LIBS = [ 'inputcommon', 'common', ],
)
padenv.SharedLibrary(env['plugin_dir']+name, files)
# -*- python -*-
Import('env')
import sys
name = "Plugin_GCPad"
padenv = env.Clone()
if not env['HAVE_SDL']:
print name + " must have SDL to be build"
Return()
files = [
'Config.cpp',
'GCPad.cpp',
'Rumble.cpp',
]
if padenv['HAVE_WX']:
files += [
'ConfigJoypad.cpp',
'ConfigBox.cpp',
]
padenv.Append(
LIBS = [ 'inputcommon', 'common', ],
)
padenv.SharedLibrary(env['plugin_dir']+name, files)
@@ -315,6 +315,7 @@ void DllConfig(HWND _hParent)
allowConfigShow = m_ConfigFrame->ShowModal() == 1 ? true : false;
delete m_ConfigFrame;
frame->SetHWND(NULL);
delete frame;
m_ConfigFrame = 0;
}
@@ -188,6 +188,7 @@ void DllConfig(HWND _hParent)
m_BasicConfigFrame->ShowModal();
m_BasicConfigFrame->Destroy();
m_BasicConfigFrame = NULL;
frame->SetHWND(NULL);
delete frame;
}
#endif