<commit_before>#include "Joysticks.h"

#if defined WIN32
#include "win_common.h"
#include "Win\WinMessageWindow.h"
#endif

using namespace OIS;

const char *g_DeviceType[6] = {
  "OISUnknown", "OISKeyboard", "OISMouse",
  "OISJoyStick", "OISTablet", "OISOther"
};

JoysticksHandler::JoysticksHandler() {
  status = "uninitialized";
}

JoysticksHandler::~JoysticksHandler() {
  if( m_InputManager ) {
    InputManager::destroyInputSystem(m_InputManager);
  }
}

bool JoysticksHandler::buttonPressed( const JoyStickEvent &arg, int button ) {
  return true;
}

bool JoysticksHandler::buttonReleased( const JoyStickEvent &arg, int button ) {
  return true;
}

bool JoysticksHandler::axisMoved( const JoyStickEvent &arg, int axis ) {
  return true;
}

bool JoysticksHandler::povMoved( const JoyStickEvent &arg, int pov ) {
  return true;
}

bool JoysticksHandler::vector3Moved( const JoyStickEvent &arg, int index) {
  return true;
}

void JoysticksHandler::capture() {
#if defined WIN32
  MSG  msg;
  while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) {
    TranslateMessage( &msg );
    DispatchMessage( &msg );
  }
#endif

  for( int i = 0; i < MAX_JOYSTICKS ; ++i ) {
    if( m_joys[i] ) {
      m_joys[i]->capture();
    }
  }
}

std::vector<JoyStickState> JoysticksHandler::joyStickStates() {
  std::vector<JoyStickState> result;

  for( int i = 0; i < MAX_JOYSTICKS ; ++i ) {
    if( m_joys[i] ) {
      result.push_back(m_joys[i]->getJoyStickState());
    }
  }

  return result;
}

void JoysticksHandler::initialize() {
  try {
    OIS::ParamList pl;

#if defined WIN32
	FB::WinMessageWindow messageWindow;
	HWND hwnd = messageWindow.getHWND();

	std::ostringstream wnd;
	wnd << (size_t)hwnd;

	pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));

#endif

    m_InputManager = InputManager::createInputSystem(pl);
    m_InputManager->enableAddOnFactory(InputManager::AddOn_All);

    status = "input manager created";

    try {
      status = "before initializing joysticks";

      //This demo uses at most 8 joysticks - use old way to create (i.e. disregard vendor)
      int numSticks = min(m_InputManager->getNumberOfDevices(OISJoyStick), MAX_JOYSTICKS);
      for( int i = 0; i < numSticks; ++i ) {
        m_joys[i] = (JoyStick*)m_InputManager->createInputObject( OISJoyStick, true );
        m_joys[i]->setEventCallback( this );
      }

      status = (boost::format("Initialized %d joysticks") % numSticks).str();
    } catch(OIS::Exception &ex) {
      status = ex.eText;
    }
  } catch( const Exception &ex ) {
    status = ex.eText;
  } catch(std::exception &ex) {
    status = ex.what();
  }
}<commit_msg>No longer using min macro<commit_after>#include "Joysticks.h"

#if defined WIN32
#include "win_common.h"
#include "Win\WinMessageWindow.h"
#endif

using namespace OIS;

const char *g_DeviceType[6] = {
  "OISUnknown", "OISKeyboard", "OISMouse",
  "OISJoyStick", "OISTablet", "OISOther"
};

JoysticksHandler::JoysticksHandler() {
  status = "uninitialized";
}

JoysticksHandler::~JoysticksHandler() {
  if( m_InputManager ) {
    InputManager::destroyInputSystem(m_InputManager);
  }
}

bool JoysticksHandler::buttonPressed( const JoyStickEvent &arg, int button ) {
  return true;
}

bool JoysticksHandler::buttonReleased( const JoyStickEvent &arg, int button ) {
  return true;
}

bool JoysticksHandler::axisMoved( const JoyStickEvent &arg, int axis ) {
  return true;
}

bool JoysticksHandler::povMoved( const JoyStickEvent &arg, int pov ) {
  return true;
}

bool JoysticksHandler::vector3Moved( const JoyStickEvent &arg, int index) {
  return true;
}

void JoysticksHandler::capture() {
#if defined WIN32
  MSG  msg;
  while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) {
    TranslateMessage( &msg );
    DispatchMessage( &msg );
  }
#endif

  for( int i = 0; i < MAX_JOYSTICKS ; ++i ) {
    if( m_joys[i] ) {
      m_joys[i]->capture();
    }
  }
}

std::vector<JoyStickState> JoysticksHandler::joyStickStates() {
  std::vector<JoyStickState> result;

  for( int i = 0; i < MAX_JOYSTICKS ; ++i ) {
    if( m_joys[i] ) {
      result.push_back(m_joys[i]->getJoyStickState());
    }
  }

  return result;
}

void JoysticksHandler::initialize() {
  try {
    OIS::ParamList pl;

#if defined WIN32
	FB::WinMessageWindow messageWindow;
	HWND hwnd = messageWindow.getHWND();

	std::ostringstream wnd;
	wnd << (size_t)hwnd;

	pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));

#endif

    m_InputManager = InputManager::createInputSystem(pl);
    m_InputManager->enableAddOnFactory(InputManager::AddOn_All);

    status = "input manager created";

    try {
      status = "before initializing joysticks";

      //This demo uses at most 8 joysticks - use old way to create (i.e. disregard vendor)
      int numSticks = m_InputManager->getNumberOfDevices(OISJoyStick);
      if (numSticks > MAX_JOYSTICKS) {
        numSticks = MAX_JOYSTICKS;
      }

      for( int i = 0; i < numSticks; ++i ) {
        m_joys[i] = (JoyStick*)m_InputManager->createInputObject( OISJoyStick, true );
        m_joys[i]->setEventCallback( this );
      }

      status = (boost::format("Initialized %d joysticks") % numSticks).str();
    } catch(OIS::Exception &ex) {
      status = ex.eText;
    }
  } catch( const Exception &ex ) {
    status = ex.eText;
  } catch(std::exception &ex) {
    status = ex.what();
  }
}
{'fraction_non_alphanumeric': 0.13791814614090825, 'fraction_numerical': 0.005232666791253972, 'mean_word_length': 3.9555555555555557, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7408956', 'n_tokens_mistral': 1998, 'n_tokens_neox': 1949, 'n_words': 414}