void MessageProcessor::send(const ControllerMessage& msg_in, const ControllerMessageDescriptor& msg_desc, int msec_delta) { if (m_config && !m_config->empty()) { ControllerMessage msg = msg_in; #if 0 if (m_rumble_test) { log_debug("rumble: " << msg.get_abs(XBOX_AXIS_LT) << " " << msg.get_abs(XBOX_AXIS_RT)); set_rumble(static_cast<uint8_t>(msg.get_abs(XBOX_AXIS_LT)), static_cast<uint8_t>(msg.get_abs(XBOX_AXIS_RT))); } #endif // handling switching of configurations if (m_config_toggle_button != -1) { bool last = m_oldmsg.get_key(m_config_toggle_button); bool cur = msg.get_key(m_config_toggle_button); if (cur && cur != last) { // reset old mapping to zero to not get stuck keys/axis m_config->get_config()->get_emitter().reset_all_outputs(); // switch to the next input mapping m_config->next_config(); log_info("switched to config: " << m_config->get_current_config()); } } // run the controller message through all modifier for(std::vector<ModifierPtr>::iterator i = m_config->get_config()->get_modifier().begin(); i != m_config->get_config()->get_modifier().end(); ++i) { (*i)->update(msec_delta, msg, m_desc); } m_config->get_config()->get_emitter().update(msec_delta); // send current Xbox state to uinput if (msg != m_oldmsg) { // Only send a new event out if something has changed, // this is useful since some controllers send events // even if nothing has changed, deadzone can cause this // too m_oldmsg = msg; m_config->get_config()->get_emitter().send(msg); } } }
void UInputMessageProcessor::send(const XboxGenericMsg& msg_in, int msec_delta) { if (!m_config->empty()) { XboxGenericMsg msg = msg_in; if (m_rumble_test) { log_debug("rumble: " << get_axis(msg, XBOX_AXIS_LT) << " " << get_axis(msg, XBOX_AXIS_RT)); set_rumble(get_axis(msg, XBOX_AXIS_LT), get_axis(msg, XBOX_AXIS_RT)); } // handling switching of configurations if (m_config_toggle_button != XBOX_BTN_UNKNOWN) { bool last = get_button(m_oldmsg, m_config_toggle_button); bool cur = get_button(msg, m_config_toggle_button); if (cur && cur != last) { // reset old mapping to zero to not get stuck keys/axis m_config->get_config()->get_uinput().reset_all_outputs(); // switch to the next input mapping m_config->next_config(); log_info("switched to config: " << m_config->get_current_config()); } } // run the controller message through all modifier for(std::vector<ModifierPtr>::iterator i = m_config->get_config()->get_modifier().begin(); i != m_config->get_config()->get_modifier().end(); ++i) { (*i)->update(msec_delta, msg); } m_config->get_config()->get_uinput().update(msec_delta); // send current Xbox state to uinput if (memcmp(&msg, &m_oldmsg, sizeof(XboxGenericMsg)) != 0) { // Only send a new event out if something has changed, // this is useful since some controllers send events // even if nothing has changed, deadzone can cause this // too m_oldmsg = msg; m_config->get_config()->get_uinput().send(msg); } } }