Example #1
0
bool Wiimote::Read()
{
	Report rpt(MAX_PAYLOAD);
	auto const result = IORead(rpt.data());

	if (result > 0 && m_channel > 0)
	{
		if (SConfig::GetInstance().iBBDumpPort > 0 &&
		    m_index == WIIMOTE_BALANCE_BOARD)
		{
			static sf::UdpSocket Socket;
			Socket.send((char*)rpt.data(),
			            rpt.size(),
			            sf::IpAddress::LocalHost,
		                SConfig::GetInstance().iBBDumpPort);
		}

		// Add it to queue
		rpt.resize(result);
		m_read_reports.Push(std::move(rpt));
		return true;
	}
	else if (0 == result)
	{
		ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wiimote %d.", m_index + 1);
		DisconnectInternal();
	}

	return false;
}
Example #2
0
void Wiimote::ThreadFunc()
{
	Common::SetCurrentThreadName("Wiimote Device Thread");

	bool ok = ConnectInternal();

	SetReady();

	if (!ok)
	{
		return;
	}

	// main loop
	while (IsConnected() && m_run_thread)
	{
		if (m_need_prepare)
		{
			m_need_prepare = false;
			if (!PrepareOnThread())
			{
				ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed.  Disconnecting Wiimote %d.", index + 1);
				break;
			}
		}
		Write();
		Read();
	}

	DisconnectInternal();
}
Example #3
0
bool Wiimote::Read()
{
	Report rpt(MAX_PAYLOAD);
	auto const result = IORead(rpt.data());

	if (result > 0 && m_channel > 0)
	{
		if (Core::g_CoreStartupParameter.iBBDumpPort > 0 &&
		    index == WIIMOTE_BALANCE_BOARD)
		{
			static sf::SocketUDP Socket;
			Socket.Send((char*)rpt.data(),
			            rpt.size(),
			            sf::IPAddress::LocalHost,
		                Core::g_CoreStartupParameter.iBBDumpPort);
		}

		// Add it to queue
		rpt.resize(result);
		m_read_reports.Push(std::move(rpt));
		return true;
	}
	else if (0 == result)
	{
		ERROR_LOG(WIIMOTE, "Wiimote::IORead failed. Disconnecting Wiimote %d.", index + 1);
		DisconnectInternal();
	}

	return false;
}
Example #4
0
STDMETHODIMP
CBasePin::Disconnect()
{
	CComAutoLock cObjectLock(m_pLock);

	/* See if the filter is active */
	if (!IsStopped()) {
		return VFW_E_NOT_STOPPED;
	}

	return DisconnectInternal();
}
Example #5
0
void Wiimote::ControlChannel(const u16 channel, const void* const data, const u32 size)
{
  // Check for custom communication
  if (channel == 99)
  {
    if (m_really_disconnect)
      DisconnectInternal();
  }
  else
  {
    InterruptChannel(channel, data, size);
    const hid_packet* const hidp = (hid_packet*)data;
    if (hidp->type == HID_TYPE_SET_REPORT)
    {
      u8 handshake_ok = HID_HANDSHAKE_SUCCESS;
      Core::Callback_WiimoteInterruptChannel(m_index, channel, &handshake_ok, sizeof(handshake_ok));
    }
  }
}
Example #6
0
void Wiimote::ThreadFunc()
{
  Common::SetCurrentThreadName("Wiimote Device Thread");

  bool ok = ConnectInternal();

  if (!ok)
  {
    // try again, it might take a moment to settle
    Common::SleepCurrentThread(100);
    ok = ConnectInternal();
  }

  SetReady();

  if (!ok)
  {
    return;
  }

  // main loop
  while (IsConnected() && m_run_thread.load())
  {
    if (m_need_prepare.load())
    {
      m_need_prepare.store(false);
      if (!PrepareOnThread())
      {
        ERROR_LOG(WIIMOTE, "Wiimote::PrepareOnThread failed.  Disconnecting Wiimote %d.",
                  m_index + 1);
        break;
      }
    }
    Write();
    Read();
  }

  DisconnectInternal();
}