Warp back to 1983!!! (rev 1983, that is, not the year :P)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1997 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-01-23 21:28:55 +00:00
parent 7ecf884f9a
commit 70bc8167f8
29 changed files with 294 additions and 504 deletions

View File

@ -185,6 +185,8 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void DllConfig(HWND _hParent)
{
#ifdef _WIN32
// Start the pads so we can use them in the configuration and advanced controls
if(!emulator_running)
{
@ -195,10 +197,31 @@ void DllConfig(HWND _hParent)
emulator_running = false; // Set it back to false
}
g_Config.Load(); // Load settings
// We don't need a parent for this wxDialog
//wxWindow win;
//win.SetHWND(_hParent);
//ConfigBox frame(&win);
//win.SetHWND(0);
m_frame = new ConfigBox(NULL);
m_frame->ShowModal();
#else
if (SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
return;
}
g_Config.Load(); // load settings
#if defined(HAVE_WX) && HAVE_WX
g_Config.Load(); // Load settings
m_frame = new ConfigBox(NULL);
m_frame->ShowModal();
ConfigBox frame(NULL);
frame.ShowModal();
#endif
#endif
}
@ -217,33 +240,29 @@ void Initialize(void *init)
{
// Debugging
//Console::Open();
SPADInitialize *_PADInitialize = (SPADInitialize*)init;
#ifndef INPUTCOMMON
Console::Print("Initialize: %i, %i\n", _PADInitialize->padNumber, SDL_WasInit(0));
#endif
//Console::Print("Initialize: %i\n", SDL_WasInit(0));
SPADInitialize _PADInitialize = *(SPADInitialize*)init;
emulator_running = true;
#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_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) < 0)
{
#ifdef _WIN32
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
#else
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
#endif
return;
}
#ifdef _WIN32
m_hWnd = (HWND)_PADInitialize->hWnd;
#endif
#ifndef INPUTCOMMON
/* 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)
{
#ifdef _WIN32
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
#else
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
#endif
return;
}
m_hWnd = (HWND)_PADInitialize.hWnd;
#endif
Search_Devices(); // Populate joyinfo for all attached devices
@ -256,18 +275,6 @@ void Initialize(void *init)
joystate[2].joy = SDL_JoystickOpen(PadMapping[2].ID);
if (PadMapping[3].enabled)
joystate[3].joy = SDL_JoystickOpen(PadMapping[3].ID);
//_PADInitialize->padNumber = 55;
/* 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 */
if( (PadMapping[0].enabled && joystate[0].joy == NULL)
|| (PadMapping[1].enabled && joystate[1].joy == NULL)
|| (PadMapping[2].enabled && joystate[2].joy == NULL)
|| (PadMapping[3].enabled && joystate[3].joy == NULL))
{
_PADInitialize->padNumber = -1;
Console::Print("%s\n", SDL_GetError());
}
}
@ -295,7 +302,11 @@ int Search_Devices()
// Warn the user if no PadMapping are detected
if (numjoy == 0)
{
PanicAlert("No Joystick detected");
#ifdef _WIN32
//MessageBox(NULL, "No Joystick detected!", NULL, MB_ICONWARNING);
#else
printf("No Joystick detected!\n");
#endif
return 0;
}
@ -339,7 +350,7 @@ int Search_Devices()
Called from: The Dolphin Core, ConfigBox::OnClose() */
void Shutdown()
{
Console::Print("Shutdown: %i\n", SDL_WasInit(0));
//Console::Print("Shutdown: %i\n", SDL_WasInit(0));
if (PadMapping[0].enabled && SDL_JoystickOpened(PadMapping[0].ID))
SDL_JoystickClose(joystate[0].joy);
@ -348,11 +359,9 @@ void Shutdown()
if (PadMapping[2].enabled && SDL_JoystickOpened(PadMapping[2].ID))
SDL_JoystickClose(joystate[2].joy);
if (PadMapping[3].enabled && SDL_JoystickOpened(PadMapping[3].ID))
SDL_JoystickClose(joystate[3].joy);
SDL_JoystickClose(joystate[3].joy);
#ifndef INPUTCOMMON
SDL_Quit();
#endif
SDL_Quit();
#ifdef _DEBUG
DEBUG_QUIT();
@ -544,14 +553,11 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
Console::ClearScreen();
Console::Print(
"Trigger type: %s Left:%04x Right:%04x Value:%i\n"
"D-Pad type: %s L:%i R:%i U:%i D:%i"
"Main stick x, y: %i %i",
"D-Pad type: %s L:%i R:%i U:%i D:%i",
(PadMapping[_numPAD].triggertype ? "CTL_TRIGGER_XINPUT" : "CTL_TRIGGER_SDL"),
TriggerLeft, TriggerRight, TriggerValue,
(PadMapping[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"),
0, 0, 0, 0,
main_stick_x, main_stick_y
0, 0, 0, 0
);*/
}
@ -766,7 +772,7 @@ void GetJoyState(int controller)
ReadButton(controller, CTL_START);
//
if (PadMapping[controller].halfpress < Buttons)
if (PadMapping[controller].halfpress < joyinfo[controller].NumButtons)
joystate[controller].halfpress = SDL_JoystickGetButton(joystate[controller].joy, PadMapping[controller].halfpress);
// Check if we have an analog or digital joypad

View File

@ -95,8 +95,6 @@
// Define
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//#define INPUTCOMMON
#define INPUT_VERSION "0.3"
#define INPUT_STATE "PUBLIC RELEASE"
#define RELDAY "21"

View File

@ -51,10 +51,7 @@ HWND m_hWnd;
#ifdef USE_RUMBLE_DINPUT_HACK
bool g_rumbleEnable = FALSE;
#endif
// Declare config window so that we can write debugging info to it from functions in this file
#if defined(HAVE_WX) && HAVE_WX
ConfigBox* m_frame;
#endif
// Rumble in windows
#ifdef _WIN32
HINSTANCE nJoy_hInst = NULL;
@ -167,22 +164,37 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) {
// Call config dialog
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void DllConfig(HWND _hParent)
{
// Start the pads so we can use them in the configuration and advanced controls
if(!emulator_running)
{
#ifdef _WIN32
if(SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
SPADInitialize _PADInitialize;
_PADInitialize.hWnd = NULL;
_PADInitialize.pLog = NULL;
Initialize((void*)&_PADInitialize);
emulator_running = false; // Set it back to false
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
return;
}
#if defined(HAVE_WX) && HAVE_WX
m_frame = new ConfigBox(NULL);
m_frame->ShowModal();
#endif
LoadConfig(); // load settings
#if defined(HAVE_WX) && HAVE_WX
wxWindow win;
win.SetHWND(_hParent);
ConfigBox frame(&win);
frame.ShowModal();
win.SetHWND(0);
#endif
#else
if(SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
return;
}
LoadConfig(); // load settings
#if defined(HAVE_WX) && HAVE_WX
ConfigBox frame(NULL);
frame.ShowModal();
#endif
#endif
}
void DllDebugger(HWND _hParent, bool Show) {
@ -198,6 +210,16 @@ void Initialize(void *init)
DEBUG_INIT();
#endif
if(SDL_Init(SDL_INIT_JOYSTICK ) < 0)
{
#ifdef _WIN32
MessageBox(NULL, SDL_GetError(), "Could not initialize SDL!", MB_ICONERROR);
#else
printf("Could not initialize SDL! (%s)\n", SDL_GetError());
#endif
return;
}
#ifdef _WIN32
m_hWnd = (HWND)_PADInitialize.hWnd;
#endif
@ -218,32 +240,32 @@ void Initialize(void *init)
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void Shutdown()
{
if(joysticks[0].enabled)
SDL_JoystickClose(joystate[0].joy);
if(joysticks[1].enabled)
SDL_JoystickClose(joystate[1].joy);
if(joysticks[2].enabled)
SDL_JoystickClose(joystate[2].joy);
if(joysticks[3].enabled)
SDL_JoystickClose(joystate[3].joy);
#ifdef _DEBUG
DEBUG_QUIT();
#endif
if (joyinfo) {
if(joysticks[0].enabled)
SDL_JoystickClose(joystate[0].joy);
if(joysticks[1].enabled)
SDL_JoystickClose(joystate[1].joy);
if(joysticks[2].enabled)
SDL_JoystickClose(joystate[2].joy);
if(joysticks[3].enabled)
SDL_JoystickClose(joystate[3].joy);
SDL_Quit();
#ifdef _DEBUG
DEBUG_QUIT();
#endif
delete [] joyinfo;
joyinfo = NULL;
}
emulator_running = FALSE;
#ifdef _WIN32
#ifdef USE_RUMBLE_DINPUT_HACK
FreeDirectInput();
#endif
#elif defined(__linux__)
close(fd);
#endif
emulator_running = FALSE;
#ifdef _WIN32
#ifdef USE_RUMBLE_DINPUT_HACK
FreeDirectInput();
#endif
#elif defined(__linux__)
close(fd);
#endif
}
void DoState(unsigned char **ptr, int mode) {
@ -678,9 +700,13 @@ int Search_Devices()
int numjoy = SDL_NumJoysticks();
if(numjoy == 0)
{
PanicAlert("No Joystick detected!\n");
return 0;
{
#ifdef _WIN32
MessageBox(NULL, "No Joystick detected!", NULL, MB_ICONWARNING);
#else
printf("No Joystick detected!\n");
#endif
return 0;
}
if(joyinfo)