Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputManager::createInputObject(OIS::Mouse, false) crashes when mouse is not plugged in. #60

Open
HeeMyung opened this issue Dec 16, 2019 · 2 comments

Comments

@HeeMyung
Copy link

Describe the bug
When an application is launched without a valid 'MOUSE' device. the program crashes when calling InputManager::createInputObject(OIS::Mouse, false) (raising an exception)

To Reproduce
Just run an application without proper 'MOUSE' device.

Expected behavior
Do not crash.

Platform (please complete the following information):

  • OS: Windows (OGRE)
  • Backend: DirectInput
  • Version 1.4

Additional context
You could think silly about launching without any valid mouse, but some people using my apps only with a trackball device, not with a mouse.
Funny thing is that if I run the program with plugged in a mouse and unplugging out after initialize, the program runs well and actually can control the mouse cursor with trackball device!

@Ybalrid
Copy link
Member

Ybalrid commented Mar 25, 2020

Interesting... I need to try to repro that. @HeeMyung sorry for the delay, you have some code to share or a project to repro that in?

@HeeMyung
Copy link
Author

HeeMyung commented Mar 26, 2020

There are some systems that have a device that could actually generate mouse events (like surface pro) that can't pass up the initialization process. I can't reproduce the problem cause I was just received some crash dumps over the user report and googling the situation.
The only thing I can reproduce was that the program raise an exception when I don't have any mouse device which is normal I think.
A funny thing here is that I have a 'used' mouse device that is not plugged in (was the mouse I used before). And if I don't stop using that device, I don't have any problem with initializing the program even though I actually pull off all of my real mouse devices.
And I can continue without any problem after plugging in a mouse after initialization.
So my guess is that the creation of a mouse object on OIS does not need the actual mouse device but just something I don't know.

Here's the code fragment which the exception raised.
The program crashes on the last line because my program is not handling the exception.

sorry for poor English

OIS::ParamList pl;
std::ostringstream wHndStr;
wHndStr << m_windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), wHndStr.str()));

// OIS - Mouse Cursor
if (m_isNonExclusiveMouseInput)
{
	pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
	pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
}

pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));

m_inputManager = OIS::InputManager::createInputSystem(pl);

m_keyboard = static_cast<OIS::Keyboard*>(m_inputManager->createInputObject(OIS::OISKeyboard, true));
m_mouse = static_cast<OIS::Mouse*>(m_inputManager->createInputObject(OIS::OISMouse, true));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants