示例#1
0
void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
{
	SetStickValue(&m_main_stick.x_cont.set_by_keyboard, &m_main_stick.x_cont.value, m_main_stick.x_cont.text, PadStatus->stickX);
	SetStickValue(&m_main_stick.y_cont.set_by_keyboard, &m_main_stick.y_cont.value, m_main_stick.y_cont.text, PadStatus->stickY);

	SetStickValue(&m_c_stick.x_cont.set_by_keyboard, &m_c_stick.x_cont.value, m_c_stick.x_cont.text, PadStatus->substickX);
	SetStickValue(&m_c_stick.y_cont.set_by_keyboard, &m_c_stick.y_cont.value, m_c_stick.y_cont.text, PadStatus->substickY);
	SetSliderValue(&m_l_cont, PadStatus->triggerLeft);
	SetSliderValue(&m_r_cont, PadStatus->triggerRight);

	for (unsigned int i = 0; i < ArraySize(m_buttons); ++i)
	{
		if (m_buttons[i] != nullptr)
			SetButtonValue(m_buttons[i], ((PadStatus->button & m_gc_pad_buttons_bitmask[i]) != 0));
	}
	SetButtonValue(&m_l, ((PadStatus->triggerLeft) == 255) || ((PadStatus->button & PAD_TRIGGER_L) != 0));
	SetButtonValue(&m_r, ((PadStatus->triggerRight) == 255) || ((PadStatus->button & PAD_TRIGGER_R) != 0));
}
示例#2
0
void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key)
{
	u8* const coreData = rptf.core ? (data + rptf.core) : nullptr;
	u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
	//u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
	u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr;

	if (coreData)
	{
		for (unsigned int i = 0; i < 10; ++i)
		{
			if (m_buttons[i] != nullptr)
				SetButtonValue(m_buttons[i], (((wm_buttons*)coreData)->hex & m_wii_buttons_bitmask[i]) != 0);
		}
	}
	if (accelData)
	{
		wm_accel* dt = (wm_accel*)accelData;

		SetSliderValue(&m_x_cont, dt->x << 2 | ((wm_buttons*)coreData)->acc_x_lsb, m_x_cont.default_value);
		SetSliderValue(&m_y_cont, dt->y << 2 | ((wm_buttons*)coreData)->acc_y_lsb << 1, m_y_cont.default_value);
		SetSliderValue(&m_z_cont, dt->z << 2 | ((wm_buttons*)coreData)->acc_z_lsb << 1, m_z_cont.default_value);
	}

	// I don't think this can be made to work in a sane manner.
	//if (irData)
	//{
	//	u16 x = 1023 - (irData[0] | ((irData[2] >> 4 & 0x3) << 8));
	//	u16 y = irData[1] | ((irData[2] >> 6 & 0x3) << 8);

	//	SetStickValue(&m_main_stick.x_cont.set_by_keyboard, &m_main_stick.x_cont.value, m_main_stick.x_cont.text, x, 561);
	//	SetStickValue(&m_main_stick.y_cont.set_by_keyboard, &m_main_stick.y_cont.value, m_main_stick.y_cont.text, y, 486);
	//}

	if (extData && ext == 1)
	{
		wm_nc& nunchuk = *(wm_nc*)extData;
		WiimoteDecrypt(&key, (u8*)&nunchuk, 0, sizeof(wm_nc));
		nunchuk.bt.hex = nunchuk.bt.hex ^ 0x3;
		SetButtonValue(m_buttons[11], nunchuk.bt.c != 0);
		SetButtonValue(m_buttons[12], nunchuk.bt.z != 0);
	}
}
示例#3
0
// NOTE: Host / CPU Thread
void TASInputDlg::GetKeyBoardInput(GCPadStatus* PadStatus)
{
  SetStickValue(&m_main_stick.x_cont, PadStatus->stickX);
  SetStickValue(&m_main_stick.y_cont, PadStatus->stickY);

  SetStickValue(&m_c_stick.x_cont, PadStatus->substickX);
  SetStickValue(&m_c_stick.y_cont, PadStatus->substickY);
  SetSliderValue(&m_l_cont, PadStatus->triggerLeft);
  SetSliderValue(&m_r_cont, PadStatus->triggerRight);

  for (size_t i = 0; i < m_buttons.size(); ++i)
  {
    if (m_buttons[i] != nullptr)
      SetButtonValue(m_buttons[i], ((PadStatus->button & s_gc_pad_buttons_bitmask[i]) != 0));
  }
  SetButtonValue(&m_l,
                 ((PadStatus->triggerLeft) == 255) || ((PadStatus->button & PAD_TRIGGER_L) != 0));
  SetButtonValue(&m_r,
                 ((PadStatus->triggerRight) == 255) || ((PadStatus->button & PAD_TRIGGER_R) != 0));
}
示例#4
0
void TASInputDlg::GetKeyBoardInput(u8* data, WiimoteEmu::ReportFeatures rptf, int ext, const wiimote_key key)
{
	u8* const coreData = rptf.core ? (data + rptf.core) : nullptr;
	u8* const accelData = rptf.accel ? (data + rptf.accel) : nullptr;
	//u8* const irData = rptf.ir ? (data + rptf.ir) : nullptr;
	u8* const extData = rptf.ext ? (data + rptf.ext) : nullptr;

	if (coreData)
	{
		for (unsigned int i = 0; i < 11; ++i)
		{
			if (m_buttons[i] != nullptr)
				SetButtonValue(m_buttons[i], (((wm_buttons*)coreData)->hex & m_wii_buttons_bitmask[i]) != 0);
		}
	}
	if (accelData)
	{
		wm_accel* dt = (wm_accel*)accelData;

		SetSliderValue(&m_x_cont, dt->x << 2 | ((wm_buttons*)coreData)->acc_x_lsb);
		SetSliderValue(&m_y_cont, dt->y << 2 | ((wm_buttons*)coreData)->acc_y_lsb << 1);
		SetSliderValue(&m_z_cont, dt->z << 2 | ((wm_buttons*)coreData)->acc_z_lsb << 1);
	}

	// I don't think this can be made to work in a sane manner.
	//if (irData)
	//{
	//	u16 x = 1023 - (irData[0] | ((irData[2] >> 4 & 0x3) << 8));
	//	u16 y = irData[1] | ((irData[2] >> 6 & 0x3) << 8);

	//	SetStickValue(&m_main_stick.x_cont.set_by_keyboard, &m_main_stick.x_cont.value, m_main_stick.x_cont.text, x, 561);
	//	SetStickValue(&m_main_stick.y_cont.set_by_keyboard, &m_main_stick.y_cont.value, m_main_stick.y_cont.text, y, 486);
	//}

	if (extData && ext == 1)
	{
		wm_nc& nunchuk = *(wm_nc*)extData;
		WiimoteDecrypt(&key, (u8*)&nunchuk, 0, sizeof(wm_nc));
		nunchuk.bt.hex = nunchuk.bt.hex ^ 0x3;
		SetButtonValue(m_buttons[11], nunchuk.bt.c != 0);
		SetButtonValue(m_buttons[12], nunchuk.bt.z != 0);
	}

	if (extData && ext == 2)
	{
		wm_classic_extension& cc = *(wm_classic_extension*)extData;
		WiimoteDecrypt(&key, (u8*)&cc, 0, sizeof(wm_classic_extension));
		cc.bt.hex = cc.bt.hex ^ 0xFFFF;
		for (unsigned int i = 0; i < 15; ++i)
		{
			SetButtonValue(&m_cc_buttons[i], ((cc.bt.hex & m_cc_buttons_bitmask[i]) != 0));
		}

		if (m_cc_l.value == 31)
			m_cc_buttons[10].checkbox->SetValue(true);
		if (m_cc_r.value == 31)
			m_cc_buttons[11].checkbox->SetValue(true);

		SetSliderValue(&m_cc_l_stick.x_cont, cc.regular_data.lx);
		SetSliderValue(&m_cc_l_stick.y_cont, cc.regular_data.ly);

		SetSliderValue(&m_cc_r_stick.x_cont, cc.rx1 | (cc.rx2 << 1) | (cc.rx3 << 3));
		SetSliderValue(&m_cc_r_stick.y_cont, cc.ry);
	}
}
示例#5
0
文件: main.c 项目: herrsergio/libjsw
/*
 *	Updates the information in jsd, returns JSGotEvent if there
 *	was some change or JSNoEvent if there was no change.
 *
 *	jsd needs to be previously initialized by a call to
 *	JSInit().
 */
int JSUpdate(js_data_struct *jsd)
{
	int n;
	int status = JSNoEvent;
#if defined(__linux__)
	int keep_handling = 1;
	int bytes_read, cycles;
	struct js_event event;
#elif defined(__FreeBSD__)
	struct joystick js;
#endif
#if defined(__linux__) || defined(__FreeBSD__)
	js_axis_struct **axis;
	js_button_struct **button;
#endif  /* __linux__ || __FreeBSD__ */


	if(jsd == NULL)
	    return(status);

	if(jsd->fd < 0)
	    return(status);

#if defined(__linux__) || defined(__FreeBSD__)
	/* Reset all button state change value on all buttons */
	for(n = 0, button = jsd->button;
	    n < jsd->total_buttons;
	    n++, button++
	)
	{
	    if(*button != NULL)
		(*button)->changed_state = JSButtonChangedStateNone;
	}

	/* Reset current and previous axis values */
	for(n = 0, axis = jsd->axis;
	    n < jsd->total_axises;
	    n++, axis++
	)
	{
	    if(*axis != NULL)
		(*axis)->prev = (*axis)->cur;
	}
#endif /* __linux__ || __FreeBSD__ */


#if defined(__linux__)
	/* Linux joystick device fetching
	 *
	 * Handle up to 16 events from joystick driver
	 */
	cycles = 0;
	while(keep_handling &&
	      (cycles < 16)
	)
	{
	    /* Get event */
	    bytes_read = read(
	        jsd->fd,
	        &event,
	        sizeof(struct js_event)
	    );
	    /* No more events to be read? */
	    if(bytes_read != sizeof(struct js_event))
	        return(status);

	    /* Handle by event type */
	    switch(event.type & ~JS_EVENT_INIT)
	    {
	      /* Axis event */
	      case JS_EVENT_AXIS:
	        /* Get axis number */
		n = event.number;

		/* Does axis exist? */
		if(JSIsAxisAllocated(jsd, n))
		    SetAxisValue(
			jsd->axis[n],
			(int)event.value,
			(time_t)event.time
		    );
		jsd->events_received++;	/* Increment events recv count */
	        status = JSGotEvent;	/* Mark that we got event */
	        break;

	      /* Button event */
	      case JS_EVENT_BUTTON:
	        /* Get button number */
	        n = event.number;

	        /* Does button exist? */
		if(JSIsButtonAllocated(jsd, n))
		    SetButtonValue(
			jsd->button[n],
			(int)event.value, (time_t)event.time
		    );
		jsd->events_received++;	/* Increment events recv count */
	        status = JSGotEvent;	/* Mark that we got event */
	        break;

	      /* Other event */
	      default:
		keep_handling = 0;	/* Stop handling events */
		break;
	    }

	    cycles++;
	}
#elif defined(__FreeBSD__)
	/* FreeBSD joystick device fetching */
	if(read(jsd->fd, &js, sizeof(struct joystick)) == sizeof(struct joystick))
	{
	    status = JSGotEvent;
	    if(JSIsAxisAllocated(jsd, 0))
		SetAxisValue(jsd->axis[0], js.x, time(NULL));
	    if(JSIsAxisAllocated(jsd, 1))
		SetAxisValue(jsd->axis[1], js.y, time(NULL));
	    if(JSIsButtonAllocated(jsd, 0))
		SetButtonValue(jsd->button[0], js.b1, time(NULL));
	    if(JSIsButtonAllocated(jsd, 1))
		SetButtonValue(jsd->button[1], js.b2, time(NULL));
	}
#endif

	return(status);
}