mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 12:26:39 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
	
		
			738 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
	
		
			738 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#include <iostream>
 | 
						|
#include "../driver.hpp"
 | 
						|
#include <unistd.h>
 | 
						|
using namespace std;
 | 
						|
using namespace Mangle::Input;
 | 
						|
 | 
						|
Driver *input;
 | 
						|
 | 
						|
struct MyCB : Event
 | 
						|
{
 | 
						|
  void event(Event::Type type, int i, const void *p)
 | 
						|
  {
 | 
						|
    cout << "got event: type=" << type << " index=" << i << endl;
 | 
						|
  }
 | 
						|
};
 | 
						|
 | 
						|
void mainLoop(int argc, int quitKey)
 | 
						|
{
 | 
						|
  cout << "Hold the Q key to quit:\n";
 | 
						|
  input->setEvent(EventPtr(new MyCB));
 | 
						|
  while(!input->isDown(quitKey))
 | 
						|
    {
 | 
						|
      input->capture();
 | 
						|
      usleep(20000);
 | 
						|
 | 
						|
      if(argc == 1)
 | 
						|
        {
 | 
						|
          cout << "You are running in script mode, aborting. Run this test with a parameter (any at all) to test the input loop properly\n";
 | 
						|
          break;
 | 
						|
        }
 | 
						|
    }
 | 
						|
 | 
						|
  delete input;
 | 
						|
  cout << "\nBye bye!\n";
 | 
						|
}
 |