Example #1
0
	void XInputDevice::PollForUpdates()
	{
		m_lastState = m_state;

		SetIsConnected(XInputGetState(m_controllerId, &m_state) == ERROR_SUCCESS);

		m_leftState = float3(m_state.Gamepad.sThumbLX, m_state.Gamepad.sThumbLY, m_state.Gamepad.bLeftTrigger);
		m_rightState = float3(m_state.Gamepad.sThumbRX, m_state.Gamepad.sThumbRY, m_state.Gamepad.bRightTrigger);

		FilterAnalog(m_leftState.x, m_leftState.y, XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE, 32767);
		FilterAnalog(m_rightState.x, m_rightState.y, XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE, 32767);
		FilterAnalog(m_leftState.z, XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);
		FilterAnalog(m_rightState.z, XINPUT_GAMEPAD_TRIGGER_THRESHOLD, 255);

		if (m_state.Gamepad.wButtons != m_lastState.Gamepad.wButtons)
		{
			for (auto& i : xinputToInputDeviceMap)
			{
				bool oldState = (m_lastState.Gamepad.wButtons & i.xinput) == i.xinput;
				bool newState = (m_state.Gamepad.wButtons & i.xinput) == i.xinput;
				
				if (oldState == newState)
					continue;

				if (oldState)
					OnReleased(i.button);
				else
					OnPressed(i.button);
			}
		}
	}
 void EventProcessor::ProcessEvent(NodeInfo *nodeInfo, uint8 event) {
   if (nodeInfo->m_nodeId == masterSwitchId) {
     if (event == 0) {
       OffPressed();
     } else {
       OnPressed();
     }
   }
 }
	void OnInput(VariantList *pVList)
	{
		uint32 fingerID = 0;
		if (pVList->Get(2).GetType() == Variant::TYPE_UINT32)
		{
			fingerID = pVList->Get(2).GetUINT32();
		}

		if (eMessageType(int(pVList->Get(0).GetFloat())) == MESSAGE_TYPE_GUI_CLICK_START)
		{
			OnPressed(fingerID);
		}
	}
Example #4
0
bool MouseArea::OnMsg(uint32 msg_id, uint32 param1, uint32 param2)
{
	switch (msg_id)
	{
	case WM_LBUTTONDOWN:
		OnPressed(msg_id, param1, param2);
		break;
	case WM_LBUTTONUP:
		OnReleased(msg_id, param1, param2);
		break;
	default:
		break;
	}
	return true; 
}
Example #5
0
eAppCallResult cROTAR::DoEachCycle(Time_t now, uint8_t *statusBuffer, size_t *statusBufferLength) {
	(void)(statusBuffer);
	bool isPressed=false;
	BSP::GetDigitalInput(this->inputPush, &isPressed);
	isPressed=!isPressed;
	if (this->pushState == ePushState::RELEASED
			&& isPressed) {
		OnPressed(now);

		cMaster::PublishApplicationEventFiltered(now, Id, eEventType::PRESSED, localEvents, localEventsLength, busEvents, busEventsLength, 0,0);
		this->pushState = ePushState::PRESSED;
		this->lastChange = now;
		this->lastPressOrRelease=now;

	} else if (this->pushState == ePushState::PRESSED
			&& !isPressed) {
		if (now - this->lastChange < SHORT_PRESS) {
			OnReleasedShort(now);
			cMaster::PublishApplicationEventFiltered(now, Id, eEventType::RELEASED_SHORT, localEvents, localEventsLength, busEvents, busEventsLength, 0,0);
		} else {
			OnReleasedLong(now);
			cMaster::PublishApplicationEventFiltered(now, Id, eEventType::RELEASED_LONG, localEvents, localEventsLength, busEvents, busEventsLength, 0,0);
		}

		cMaster::PublishApplicationEventFiltered(now, Id, eEventType::RELEASED, localEvents, localEventsLength, busEvents, busEventsLength, 0,0);
		this->pushState = ePushState::RELEASED;
		this->lastChange = now;
		this->lastPressOrRelease=now;
	}
	uint16_t currentRotaryState = BSP::GetRotaryEncoderValue(this->inputRotary);
	if(currentRotaryState!=this->rotaryState)
	{
		int16_t change =  currentRotaryState-this->rotaryState;
		this->lastChange=now;
		if(now-this->lastPressOrRelease>DEAD_TIME_FOR_TURN_AFTER_PRESS_OR_RELEASE)
		{
			OnTurned(now, change);
			cMaster::PublishApplicationEventFiltered(now, Id, eEventType::TURNED, localEvents, localEventsLength, busEvents, busEventsLength, (uint8_t*)&change ,2);
		}
	}
	this->rotaryState=currentRotaryState;
	*statusBufferLength=0;
	return eAppCallResult::OK;
}
Example #6
0
		void Button::OnMouseButtonPressed(const sf::Event::MouseButtonEvent &pEvent){
			mPressed = true;
			OnPressed();
		}