Wednesday, July 16, 2008

Intel Laptop Gaming TDK API Implementation on your game

Well after browsing for mods @ GG site, I found this interesting engine modification about adding this Intel Laptop Gaming TDK API. With this API we can get the current status of the hardware running our game, is it running on a PC or Laptop. and we also can extract the battery and wireless signal strength of our laptop/PC.

Of course we can use this API on other game engines or maybe our self made game engine. This API is available for free from Intel, you can donwload it here http://softwarecommunity.intel.com/articles/eng/1017.htm and install it on your PC. You can see the methods you can call from this API in the IntelLaptopGamingTDK.h

This is a sample source code I've made just to try the features.




#include "StdAfx.h"
#include "Testing.h"
#include "IntelGamingTDKAPI.h"

#define _CRTDBG_MAP_ALLOC
#include
#include

#include
#include

using namespace std;

#ifdef _DEBUG
#define SET_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag((a) _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#define CLEAR_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#else
#define SET_CRT_DEBUG_FIELD(a) ((void) 0)
#define CLEAR_CRT_DEBUG_FIELD(a) ((void) 0)
#endif

Testing::Testing(void)
{
Feature();
}

void Testing::Feature()
{
IntelLaptopGamingTDKInterface *IGT = IntelLaptopGamingTDKInterface::GetTDKInterface();

if(!IGT)
return;

/**
* Is this a laptop ??
*/
cout << "\nIS LAPTOP ? " <<>IsLaptop();

/**
* Get number of core on per physical processor
*/
cout << "\nCPU CORE ? " <<>GetNumCoresPerProcessor();

/**
* Get total number of processors as seen by OS
*/
cout << "\nCPU COUNT ? " <GetNumProcessors();

// and just try the other methods..

// Memory leaks checking
// 6 mem leaks because pointers on heap aren't deleted till function
// exits. We call this function before the pointers go out of scope.
_CrtDumpMemoryLeaks();
}

Testing::~Testing(void)
{
}


I use VC 2005 for the compiler.

Following are the steps to compile your code using this API.

  1. Go to project properties
  2. In the configuration properties > C++ @ the additional include directory, point to your directory where u put the headers and IntelLaptopGaming.lib
  3. In the configuration properties > Linker @ the additional include directory, point to your directory where u put the headers and IntelLaptopGaming.lib
  4. In the configuration properties > Linker > Input @ the additional dependency type IntelLaptopGaming.lib
  5. Copy your IntelLaptopGaming.dll to your exe output directory (the dll depends on your OS if u use vista copy dll for vista, if u use xp copy dll for xp)
  6. Compile, build, and RUN.

Have fun and cheers.

No comments: