Esempio n. 1
0
CKeystrokeEngine::CKeystrokeEngine(const char* sKeys) :
	m_bCtrlPressed (false), m_bAltPressed (false), m_bShiftPressed (false),
    m_bPause (false), m_bSendToWnd (false), m_bExact (false), m_bCaseSensitive (false),
	m_bReactivate (false), m_nPause (0), m_nReActivate (0), 
	m_lpszWndTitle (NULL), m_lpszWndClass (NULL)
{
	m_sKeys = sKeys;
	ParseKeys ();
}
Esempio n. 2
0
/*
============
sdDeclRadialMenu::ParseItem
============
*/
bool sdDeclRadialMenu::ParseItem( idParser& src ) {
	idToken token;
	if( !src.ReadToken( &token )) {
		src.Error( "sdDeclRadialMenu::ParseItem: Unexpected end of file while parsing itemName" );
		return false;
	}
	item_t& item = items.Alloc();
	item.title = declHolder.FindLocStr( token.c_str() );

	bool success = ParseKeys( src, item.keys );

	gameLocal.CacheDictionaryMedia( item.keys );

	return success;
}
Esempio n. 3
0
/*
================
sdDeclKeyBinding::Parse
================
*/
bool sdDeclKeyBinding::Parse( const char *text, const int textLength ) {
	idToken token;
	idParser src;

	src.SetFlags( DECL_LEXER_FLAGS );
	//src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
	sdDeclParseHelper declHelper( this, text, textLength, src );

	src.SkipUntilString( "{", &token );

	while( true ) {
		if( !src.ReadToken( &token )) {
			src.Error( "sdDeclKeyBinding::Parse: unexpected end of file." );
			break;
		}
		if( !token.Cmp( "}" )) {
			break;
		}

		if( !token.Icmp( "keys" )) {
			if( !ParseKeys( src )) {
				src.Error( "sdDeclKeyBinding::Parse: failed to parse keys" );
				break;
			}
			continue;
		}

		if( !token.Icmp( "title" )) {
			if( !src.ReadToken( &token )) {
				src.Error( "sdDeclKeyBinding::Parse: failed to title" );
				break;
			}
			title = declHolder.declLocStrType.LocalFind( token );
			continue;
		}
	}
	
	return true;
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
	CNV11* NV11 = new CNV11(); // Create instance of validator class
	// Start the polling thread, this will not send any polls until
	// the IsPolling variable is true
	HANDLE nv11Thread = StartPollThread(NV11); 
	// Set output to std::cout
	NV11->SetOutputStream(&cout);
	WriteString("Example C++ NV11 SDK\n\nSearching for ports...\n");

	// Find out about the validator and create a connection struct to pass
	// to the validator class
	SSP_COMMAND commandStructure;
	commandStructure.BaudRate = 9600;
	commandStructure.Timeout = 1000;
	commandStructure.RetryLevel = 3;
	commandStructure.IgnoreError = 1;

	char* end;
	// Get port number
	std::vector<string> ports = GetComPorts();
	for (unsigned int i = 0; i < ports.size(); ++i)
		cout << ports[i] << endl;
	string in = "";
	unsigned int portIndex = 0;
	do
	{
		in = GetInputString("Select a port: ");
		portIndex = strtol(in.c_str(), &end, 0);
	} while (portIndex <= 0 || portIndex > ports.size());
	commandStructure.PortNumber = FormatComPort(ports[portIndex-1]); 
		
	// Get ssp address
	int ssp = 0;
	do
	{
		in = GetInputString("SSP Address (Default = 0): ");
		ssp = strtol(in.c_str(), &end, 0);
	} while (ssp < 0 || ssp > 32 || end == in.c_str());
	commandStructure.SSPAddress = (unsigned char)ssp;

	// Get protocol version to use
	int p = 0;
	do
	{
		in = GetInputString("Protocol version: ");
		p = strtol(in.c_str(), &end, 0);
	} while (p <= 0 || p > MAX_PROTOCOL_VERSION);

	// Now connect to validator
	if (NV11->ConnectToValidator(commandStructure, p, 5))
	{
		WriteString("Connected to validator successfully");
		DisplayCommands();
		while  (true)
		{
			// Parse the keys, if this returns false then the user has selected
			// to exit the program
			if (!ParseKeys(NV11))
			{
				IsPolling = false; // Stop polling before exit
				break;
			}

			// If PollFailed is set by the polling thread, attempt to reconnect to the unit
			if (PollFailed)
			{
				// Make 5 attempts to reconnect, if none successful break out
				if (NV11->ConnectToValidator(commandStructure, p, 5)) 
				{
					// If successful reconnect, restart the polling thread and continue
					PollFailed = false;
					TerminateThread(nv11Thread, 0);
					CloseHandle(nv11Thread);
					nv11Thread = StartPollThread(NV11);
				}
				else
					break;
			}
		}
		WriteString("Poll loop stopped");
	}
	TerminateThread(nv11Thread, 0);
	CloseHandle(nv11Thread);
	delete NV11;
	WriteString("Press any key to exit...");
	_getch();
}
Esempio n. 5
0
/*
================
sdDeclRadialMenu::Parse
================
*/
bool sdDeclRadialMenu::Parse( const char *text, const int textLength ) {
	idToken token;
	idParser src;

	src.SetFlags( DECL_LEXER_FLAGS );
//	src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
//	src.AddIncludes( GetFileLevelIncludeDependencies() );
	//sdDeclParseHelper declHelper( this, text, textLength, src );
	sdDeclParseHelper declHelper( this, text, textLength, src );

	src.SkipUntilString( "{", &token );

	bool hadError = false;

	while( true ) {
		if( !src.ReadToken( &token )) {
			src.Error( "sdDeclRadialMenu::Parse: unexpected end of file." );
			hadError = true;
			break;
		}
		if( !token.Cmp( "}" )) {
			break;
		}

		if( !token.Icmp( "keys" )) {
			if( !ParseKeys( src, keys )) {
				src.Error( "sdDeclRadialMenu::Parse: failed to parse keys" );
				hadError = true;
				break;
			}
			continue;
		}

		if( !token.Icmp( "title" )) {
			if( !src.ReadToken( &token )) {
				src.Error( "sdDeclRadialMenu::Parse: failed to title" );
				hadError = true;
				break;
			}
			title = declHolder.FindLocStr( token.c_str() );
			continue;
		}

		if( !token.Icmp( "page" )) {
			if( !ParsePage( src )) {
				src.Error( "sdDeclRadialMenu::Parse: failed to parse page" );
				hadError = true;
				break;
			}
			continue;
		}
		if( !token.Icmp( "item" )) {
			if( !ParseItem( src )) {
				src.Error( "sdDeclRadialMenu::Parse: failed to parse item" );
				hadError = true;
				break;
			}
			continue;
		}
	}
	
	return !hadError;
}