From 914d91da2ceece59799af7099e3fe82d114f995b Mon Sep 17 00:00:00 2001 From: riccardom Date: Mon, 5 Apr 2010 16:11:29 +0000 Subject: [PATCH] Cleanup the code a bit wrt, unused functions and functions that can be declared static. --- desmume/src/wx/InputCommon/Configuration.cpp | 4 ++-- desmume/src/wx/InputCommon/InputCommon.cpp | 1 + desmume/src/wx/InputCommon/SDL.cpp | 4 ++-- desmume/src/wx/PadSimple/PadSimple.cpp | 16 ++++++++++------ desmume/src/wx/wxMain.cpp | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/desmume/src/wx/InputCommon/Configuration.cpp b/desmume/src/wx/InputCommon/Configuration.cpp index b3bfa2fba..1e9aefa4d 100644 --- a/desmume/src/wx/InputCommon/Configuration.cpp +++ b/desmume/src/wx/InputCommon/Configuration.cpp @@ -64,7 +64,7 @@ float Rad2Deg(float Rad) // Check if the pad is within the dead zone, we assume the range is 0x8000 // ---------------- -float CoordinatesToRadius(int x, int y) +static float CoordinatesToRadius(int x, int y) { return sqrt(pow((float)x, 2) + pow((float)y, 2)); } @@ -159,7 +159,7 @@ void RadiusAdjustment(int &_x, int &_y, int _pad, std::string SRadius) /* 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) +static float Square2CircleDistance(float deg) { // See if we have to adjust the angle deg = abs(deg); diff --git a/desmume/src/wx/InputCommon/InputCommon.cpp b/desmume/src/wx/InputCommon/InputCommon.cpp index 8ec366a9c..f7b22738d 100644 --- a/desmume/src/wx/InputCommon/InputCommon.cpp +++ b/desmume/src/wx/InputCommon/InputCommon.cpp @@ -1,4 +1,5 @@ #include "EventHandler.h" +#include "InputCommon.h" //EventHandler *eventHandler = NULL; diff --git a/desmume/src/wx/InputCommon/SDL.cpp b/desmume/src/wx/InputCommon/SDL.cpp index ec503a43e..a9ebe96c2 100644 --- a/desmume/src/wx/InputCommon/SDL.cpp +++ b/desmume/src/wx/InputCommon/SDL.cpp @@ -125,7 +125,7 @@ bool SearchDevices(std::vector &_joyinfo, int &_NumPads, int &_ // Read buttons status. Called from GetJoyState(). // ---------------------- -void ReadButton(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int button, int NumButtons) +static void ReadButton(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, int button, int NumButtons) { int ctl_button = _PadMapping.buttons[button]; if (ctl_button < NumButtons) @@ -250,7 +250,7 @@ void GetJoyState(CONTROLLER_STATE &_PadState, CONTROLLER_MAPPING _PadMapping, in // --------------------- /* Function: We have to avoid very big values to becuse 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) +static bool AvoidValues(int value, bool NoTriggerFilter) { // Avoid detecting very small or very big (for triggers) values if( (value > -0x2000 && value < 0x2000) // Small values diff --git a/desmume/src/wx/PadSimple/PadSimple.cpp b/desmume/src/wx/PadSimple/PadSimple.cpp index 2b37396a4..d155655fe 100644 --- a/desmume/src/wx/PadSimple/PadSimple.cpp +++ b/desmume/src/wx/PadSimple/PadSimple.cpp @@ -113,6 +113,7 @@ BOOL APIENTRY aMain(HINSTANCE hinstDLL, // DLL module handle } #endif +#if 0 #if defined(HAVE_WX) wxWindow* GetParentedWxWindow(HWND Parent) { @@ -127,7 +128,7 @@ wxWindow* GetParentedWxWindow(HWND Parent) return win; } #endif - +#endif // Input Recording @@ -227,12 +228,13 @@ bool IsFocus() #endif } +#ifdef _WIN32 // Implement circular deadzone -const float kDeadZone = 0.1f; void ScaleStickValues(unsigned char* outx, unsigned char* outy, short inx, short iny) { + const float kDeadZone = 0.1f; float x = ((float)inx + 0.5f) / 32767.5f; float y = ((float)iny + 0.5f) / 32767.5f; @@ -258,12 +260,13 @@ void ScaleStickValues(unsigned char* outx, *outx = 0x80 + ix; *outy = 0x80 + iy; } +#endif // for same displacement should be sqrt(2)/2 (in theory) // 3/4 = 0.75 is a little faster than sqrt(2)/2 = 0.7071... // In SMS, 17/20 = 0.85 is perfect; in WW, 7/10 = 0.70 is closer. #define DIAGONAL_SCALE 0.70710678 -void EmulateAnalogStick(unsigned char *stickX, unsigned char *stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude) { +static void EmulateAnalogStick(unsigned char *stickX, unsigned char *stickY, bool buttonUp, bool buttonDown, bool buttonLeft, bool buttonRight, int magnitude) { int mainY = 0; int mainX = 0; if (buttonUp) @@ -434,7 +437,7 @@ bool XInput_Read(int XPadPlayer, SPADStatus* _pPADStatus) #if (defined(HAVE_X11) && HAVE_X11) || (defined(HAVE_COCOA) && HAVE_COCOA) #if defined(HAVE_X11) && HAVE_X11 // The graphics plugin in the PCSX2 design leaves a lot of the window processing to the pad plugin, weirdly enough. -void X11_Read(int _numPAD, SPADStatus* _pPADStatus) +static void X11_Read(int _numPAD, SPADStatus* _pPADStatus) { // Do all the stuff we need to do once per frame here if (_numPAD != 0) @@ -684,6 +687,7 @@ void Initialize(void *init) #endif } +#if 0 void DoState(unsigned char **ptr, int mode) { #ifdef RERECORDING @@ -704,7 +708,7 @@ void DoState(unsigned char **ptr, int mode) #endif } -void Shutdown() +static void Shutdown() { // Save the recording and reset the counter #ifdef RERECORDING @@ -729,7 +733,7 @@ void Shutdown() #endif SaveConfig(); } - +#endif // Set buttons status from wxWidgets in the main application void PAD_Input(u16 _Key, u8 _UpDown) {} diff --git a/desmume/src/wx/wxMain.cpp b/desmume/src/wx/wxMain.cpp index 9d0a3e459..10cc12da8 100644 --- a/desmume/src/wx/wxMain.cpp +++ b/desmume/src/wx/wxMain.cpp @@ -628,9 +628,9 @@ bool Desmume::OnInit() PADInitialize.padNumber = 1; -extern void Initialize(void *init); - #ifndef WIN32 + extern void Initialize(void *init); + Initialize(&PADInitialize); #endif