Moved global variables out into a separate file.

master
Pacman Ghost 8 years ago
parent 577a7e0af8
commit 9735b7d047
  1. 2
      MouseDll/actions.cpp
  2. 2
      MouseDll/api.cpp
  3. 1
      MouseDll/appProfile.hpp
  4. 64
      MouseDll/core.cpp
  5. 1
      MouseDll/device.cpp
  6. 1
      MouseDll/event.cpp
  7. 42
      MouseDll/globals.cpp
  8. 45
      MouseDll/globals.hpp
  9. 8
      MouseDll/mouse.vcproj
  10. 2
      MouseDll/utils.cpp

@ -1,6 +1,6 @@
#include "actions.hpp"
#include "api.hpp"
#include "utils.hpp"
#include "globals.hpp"
using namespace std ;

@ -1,6 +1,6 @@
#include <stdexcept>
#include <windows.h>
#include "api.hpp"
#include "globals.hpp"
#include "utils.hpp"
using namespace std ;

@ -2,7 +2,6 @@
#define APPPROFILE_HPP
#include "event.hpp"
#include "utils.hpp"
struct ApiAppProfile ;

@ -1,55 +1,9 @@
#include <windows.h>
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <map>
#include <set>
#include "api.hpp"
#include "device.hpp"
#include "deviceConfig.hpp"
#include "globals.hpp"
#include "utils.hpp"
using namespace std ;
typedef set<string> StringSet ;
// --- LOCAL DATA ------------------------------------------------------
static HMODULE ghInterceptionDll = NULL ;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
typedef IntPtrMap<Device> DeviceTable ;
static DeviceTable gDeviceTable ;
typedef IntPtrMap<DeviceConfig> DeviceConfigTable ;
static DeviceConfigTable gDeviceConfigTable ;
// --- LOCAL DATA ------------------------------------------------------
static bool gEnableConsole = false ;
static wstring gLogFilename ;
static ofstream gLogFile ;
static StringSet gLogging ;
static bool isLoggingEnabled( const string& s ) { return gLogging.find(s) != gLogging.end() ; }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#define LOG_MSG( msg ) \
{ \
if ( gEnableConsole || gLogFile.is_open() ) \
{ \
string _buf_ = MAKE_STRING( msg ) ; \
if ( gEnableConsole ) \
cout << _buf_ << endl ; \
if ( gLogFile.is_open() ) \
gLogFile << _buf_ << endl ; \
} \
}
// ---------------------------------------------------------------------
void
@ -166,21 +120,7 @@ reloadConfig(
gLogFilename = pLogFilename ;
}
}
// initialize logging
gLogging.clear() ;
const wchar_t* p = pDebugConfig->mpLogging ;
for ( ; ; )
{
const wchar_t* q = wcschr( p , L'|' ) ;
if ( q == NULL )
{
gLogging.insert( toUtf8(p) ) ;
break ;
}
gLogging.insert( toUtf8(p,q-p) ) ;
p = q + 1 ;
}
initLogging( pDebugConfig->mpLogging ) ;
// load the Device's
gDeviceTable.deleteAll() ;

@ -1,6 +1,5 @@
#include "device.hpp"
#include "api.hpp"
#include "utils.hpp"
using namespace std ;

@ -1,6 +1,5 @@
#include "event.hpp"
#include "api.hpp"
#include "utils.hpp"
using namespace std ;

@ -0,0 +1,42 @@
#include <set>
#include "globals.hpp"
using namespace std ;
// ---------------------------------------------------------------------
HMODULE ghInterceptionDll = NULL ;
DeviceTable gDeviceTable ;
DeviceConfigTable gDeviceConfigTable ;
bool gEnableConsole = false ;
wstring gLogFilename ;
ofstream gLogFile ;
// ---------------------------------------------------------------------
typedef set<string> StringSet ;
static StringSet gLogging ;
void initLogging( const wchar_t* pLogging )
{
// initialize logging
gLogging.clear() ;
if ( pLogging == NULL )
return ;
for ( const wchar_t* p=pLogging ; ; )
{
const wchar_t* q = wcschr( p , L'|' ) ;
if ( q == NULL )
{
gLogging.insert( toUtf8(p) ) ;
break ;
}
gLogging.insert( toUtf8(p,q-p) ) ;
p = q + 1 ;
}
}
bool isLoggingEnabled( const string& s ) { return gLogging.find(s) != gLogging.end() ; }

@ -0,0 +1,45 @@
#ifndef GLOBALS_HPP
#define GLOBALS_HPP
#include <windows.h>
#include <iostream>
#include <fstream>
#include "device.hpp"
#include "deviceConfig.hpp"
#include "utils.hpp"
// ---------------------------------------------------------------------
extern HMODULE ghInterceptionDll ;
typedef IntPtrMap<Device> DeviceTable ;
extern DeviceTable gDeviceTable ;
typedef IntPtrMap<DeviceConfig> DeviceConfigTable ;
extern DeviceConfigTable gDeviceConfigTable ;
// ---------------------------------------------------------------------
#define LOG_MSG( msg ) \
{ \
if ( gEnableConsole || gLogFile.is_open() ) \
{ \
string _buf_ = MAKE_STRING( msg ) ; \
if ( gEnableConsole ) \
cout << _buf_ << endl ; \
if ( gLogFile.is_open() ) \
gLogFile << _buf_ << endl ; \
} \
}
extern void initLogging( const wchar_t* ) ;
extern bool isLoggingEnabled( const std::string& ) ;
extern bool gEnableConsole ;
extern std::wstring gLogFilename ;
extern std::ofstream gLogFile ;
// ---------------------------------------------------------------------
#endif // GLOBALS_HPP

@ -208,6 +208,10 @@
RelativePath=".\event.cpp"
>
</File>
<File
RelativePath=".\globals.cpp"
>
</File>
<File
RelativePath=".\utils.cpp"
>
@ -242,6 +246,10 @@
RelativePath=".\event.hpp"
>
</File>
<File
RelativePath=".\globals.hpp"
>
</File>
<File
RelativePath=".\utils.hpp"
>

@ -1,5 +1,5 @@
#include <windows.h>
#include "utils.hpp"
#include "globals.hpp"
using namespace std ;

Loading…
Cancel
Save