
extern "C" 
{

//------------------------------------------------------------------------------------
// irr::IrrlichtDevice wrappers (done)
//------------------------------------------------------------------------------------

	bool Irr_IrrlichtDevice_drop(IrrlichtDevice* unk)
	{
		if (unk)
			return unk->drop();
		else return 0;
	}
	
	const c8* Irr_IrrlichtDevice_getDebugName(IrrlichtDevice* unk)
	{
		if (unk)
			return unk->getDebugName();
		else return "";
	}
	
	void Irr_IrrlichtDevice_grab(IrrlichtDevice* unk)
	{
		if (unk)
			unk->grab();
	}	

	void Irr_IrrlichtDevice_setResizable(IrrlichtDevice* device,bool resize) 
	{
		if (device>0)
			device->setResizable(resize);
	}
	
	BMXEventReceiver* Irr_IrrlichtDevice_getEventReceiver(IrrlichtDevice* device)
	{
		if (device>0)
			return (BMXEventReceiver*)device->getEventReceiver();
		else
			return 0;
	}
	
	void Irr_IrrlichtDevice_setEventReceiver(IrrlichtDevice* device, BMXEventReceiver* receiver)
	{
		if (device>0)
			return device->setEventReceiver((IEventReceiver*)receiver);
	}
	
	bool Irr_IrrlichtDevice_isWindowActive(IrrlichtDevice* device)
	{
		if (device>0)
			return device->isWindowActive();
		else
			return false;
	}
	
	IVideoModeList* Irr_IrrlichtDevice_getVideoModeList(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getVideoModeList();
		else
			return 0;
	}
	
	const char* Irr_IrrlichtDevice_getVersion(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getVersion();
		else
			return "";
	}
	
	ITimer* Irr_IrrlichtDevice_getTimer(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getTimer();
		else
			return 0;
	}
	
	IOSOperator* Irr_IrrlichtDevice_getOSOperator(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getOSOperator();
		else
			return 0;
	}
	
	ILogger* Irr_IrrlichtDevice_getLogger(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getLogger();
		else
			return 0;
	}
	
	IFileSystem* Irr_IrrlichtDevice_getFileSystem(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getFileSystem();
		else
			return 0;
	}
	
	void Irr_IrrlichtDevice_closeDevice(IrrlichtDevice* device)
	{
		if (device>0)
			device->closeDevice();
	}
	
	ICursorControl* Irr_IrrlichtDevice_getCursorControl(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getCursorControl();
		else
			return 0;
	}
	
	
	void Irr_IrrlichtDevice_setWindowCaption(IrrlichtDevice* device,const c8* text)
	{
		core::stringw w_text = text;
	
		if (device>0)
			device->setWindowCaption(w_text.c_str());
	}

	void Irr_IrrlichtDevice_setWindowCaptionW(IrrlichtDevice* device,const wchar_t* text)
	{
		if (device>0)
			device->setWindowCaption(text);
	}
	
	bool Irr_IrrlichtDevice_run(IrrlichtDevice* device)
	{
		if (device>0)
			return device->run();
		else
			return false;
	}
	
	IVideoDriver* Irr_IrrlichtDevice_getVideoDriver(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getVideoDriver();
		else
			return 0;
	}
	
	ISceneManager* Irr_IrrlichtDevice_getSceneManager(IrrlichtDevice* device)
	{
		if (device>0)
			return device->getSceneManager();
		else
			return 0;
	}
	
	IGUIEnvironment* Irr_IrrlichtDevice_getGUIEnvironment(IrrlichtDevice* device)  
	{
		if (device>0)
			return device->getGUIEnvironment();
		else
			return 0;
	}
		
	bool Irr_IrrlichtDevice_postEventFromUser(IrrlichtDevice* device,SEvent* event)
	{
		if (device)
			return device->postEventFromUser(*event);
		else return false;
	}

	void Irr_IrrlichtDevice_yield(IrrlichtDevice* device)
	{
		if (device)
			device->yield();
	} 
	
	void Irr_IrrlichtDevice_sleep(IrrlichtDevice* device,u32 timeMs, bool pauseTimer=false)
	{
		if (device)
			device->sleep(timeMs,pauseTimer);
	}
	
	void Irr_IrrlichtDevice_setInputReceivingSceneManager(IrrlichtDevice* device,ISceneManager* sceneManager)
	{
		if (device)
			device->setInputReceivingSceneManager(sceneManager);
	}
	
	bool Irr_IrrlichtDevice_isWindowFocused(IrrlichtDevice* device)	
	{
		if (device)
			return device->isWindowFocused();
		else return false;
	}
	
	bool Irr_IrrlichtDevice_isWindowMinimized(IrrlichtDevice* device)
	{
		if (device)
			return device->isWindowMinimized();
		else return false;
	}
	
	bool Irr_IrrlichtDevice_isFullscreen(IrrlichtDevice* device)
	{
		if (device)
			return device->isFullscreen();
		else return false;
	}

	s32 Irr_IrrlichtDevice_getColorFormat(IrrlichtDevice* device) // returns ECOLOR_FORMAT
	{
		if (device)
			return device->getColorFormat();
		else return -1;
	}
	
	bool Irr_IrrlichtDevice_activateJoysticks(IrrlichtDevice* device, SJoystickInfo** joystickInfoArray, u32 joystickInfoArraySize)
	{
		if (device) {

			array<SJoystickInfo> joystickInfo(joystickInfoArraySize);
			for (int i=0; i<joystickInfoArraySize; i++) {	
				joystickInfo[i]=*joystickInfoArray[i];
			}

			return device->activateJoysticks(joystickInfo);
		} else return false;
	}
	
	bool Irr_IrrlichtDevice_isDriverSupported(IrrlichtDevice* device, E_DRIVER_TYPE driver) {
		if (device) {
			return device->isDriverSupported(driver);
		} else return false;
	}
	
	void Irr_IrrlichtDevice_minimizeWindow(IrrlichtDevice* device) 
	{
		if (device)
			device->minimizeWindow();
	}

	void Irr_IrrlichtDevice_maximizeWindow(IrrlichtDevice* device)
	{
		if (device)
			device->maximizeWindow();
	}

	void Irr_IrrlichtDevice_restoreWindow(IrrlichtDevice* device)
	{
		if (device)
			device->restoreWindow();
	}

	bool Irr_IrrlichtDevice_setGammaRamp(IrrlichtDevice* device, f32 red, f32 green, f32 blue, f32 relativebrightness, f32 relativecontrast)
	{
		if (device)
			return device->setGammaRamp(red, green, blue, relativebrightness, relativecontrast);
		else return false;
	}

	bool Irr_IrrlichtDevice_getGammaRamp(IrrlichtDevice* device, f32 &red, f32 &green, f32 &blue,	f32 &brightness, f32 &contrast)
	{
		if (device)
			return device->getGammaRamp(red, green, blue, brightness, contrast);
		else return false;
	}

	s32 Irr_IrrlichtDevice_getType(IrrlichtDevice* device) 
	{
		if (device)
			return device->getType();
		else return -1;
	}
	
	void Irr_IrrlichtDevice_clearSystemMessages(IrrlichtDevice* device)
	{
		if (device)
			device->clearSystemMessages();
	}
}
//------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
