| 65 | } |
| 66 | |
| 67 | void InitializeInput(HWND handle) |
| 68 | { |
| 69 | TENLog("Initializing input system...", LogLevel::Info); |
| 70 | |
| 71 | RumbleInfo = {}; |
| 72 | |
| 73 | // Initialize key map. |
| 74 | for (int i = 0; i < KEY_COUNT; i++) |
| 75 | KeyMap[i] = 0.0f; |
| 76 | |
| 77 | // Initialize action and action queue maps. |
| 78 | for (int i = 0; i < (int)ActionID::Count; i++) |
| 79 | { |
| 80 | auto actionID = (ActionID)i; |
| 81 | ActionMap[actionID] = Action(actionID); |
| 82 | ActionQueueMap[actionID] = ActionQueueState::None; |
| 83 | } |
| 84 | |
| 85 | // Initialize axis map. |
| 86 | for (int i = 0; i < (int)AxisID::Count; i++) |
| 87 | { |
| 88 | auto axisID = (AxisID)i; |
| 89 | AxisMap[axisID] = Vector2::Zero; |
| 90 | } |
| 91 | |
| 92 | try |
| 93 | { |
| 94 | // Use OIS::ParamList since default behaviour blocks WIN key and steals mouse. |
| 95 | auto paramList = OIS::ParamList{}; |
| 96 | auto wnd = std::ostringstream{}; |
| 97 | wnd << (size_t)handle; |
| 98 | paramList.insert(std::make_pair(std::string("WINDOW"), wnd.str())); |
| 99 | paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_BACKGROUND"))); |
| 100 | paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE"))); |
| 101 | paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_BACKGROUND"))); |
| 102 | paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE"))); |
| 103 | |
| 104 | OisInputManager = OIS::InputManager::createInputSystem(paramList); |
| 105 | OisInputManager->enableAddOnFactory(OIS::InputManager::AddOn_All); |
| 106 | |
| 107 | if (OisInputManager->getNumberOfDevices(OIS::OISKeyboard) == 0) |
| 108 | { |
| 109 | TENLog("Keyboard not found.", LogLevel::Warning); |
| 110 | } |
| 111 | else |
| 112 | { |
| 113 | OisKeyboard = (OIS::Keyboard*)OisInputManager->createInputObject(OIS::OISKeyboard, true); |
| 114 | } |
| 115 | |
| 116 | if (OisInputManager->getNumberOfDevices(OIS::OISMouse) == 0) |
| 117 | { |
| 118 | TENLog("Mouse not found.", LogLevel::Warning); |
| 119 | } |
| 120 | else |
| 121 | { |
| 122 | OisMouse = (OIS::Mouse*)OisInputManager->createInputObject(OIS::OISMouse, true); |
| 123 | } |
| 124 | } |
no test coverage detected