private void updateMouser(PSMoveSharpState state) { UInt16 just_pressed; UInt16 just_released; { UInt16 changed_buttons = Convert.ToUInt16(state.gemStates[0].pad.digitalbuttons ^ last_buttons); just_pressed = Convert.ToUInt16(changed_buttons & state.gemStates[0].pad.digitalbuttons); just_released = Convert.ToUInt16(changed_buttons & ~state.gemStates[0].pad.digitalbuttons); last_buttons = state.gemStates[0].pad.digitalbuttons; } checkBoxCalibrated.Checked = (state.positionPointerStates[0].valid == 1); checkBoxEnabled.Checked = fake_mouse_events; labelMovePosValX.Text = (state.positionPointerStates[0].valid == 1) ? state.positionPointerStates[0].normalized_x.ToString("N3") : "N/A"; labelMovePosValY.Text = (state.positionPointerStates[0].valid == 1) ? state.positionPointerStates[0].normalized_y.ToString("N3") : "N/A"; buttonEnable.Text = fake_mouse_events ? "Disable" : "Enable"; if (state.positionPointerStates[0].valid == 1) { if ((just_pressed & PSMoveSharpConstants.ctrlSelect) == PSMoveSharpConstants.ctrlSelect) { MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerDisable, 0); Console.WriteLine("Disabling pointer"); calibration_step = 0; } if (fake_mouse_events) { if ((just_pressed & PSMoveSharpConstants.ctrlCross) == PSMoveSharpConstants.ctrlCross) { MouserRecenter(state.positionPointerStates[0].normalized_x, state.positionPointerStates[0].normalized_y); } else { MouserMove(state.positionPointerStates[0].normalized_x, state.positionPointerStates[0].normalized_y); } if (((just_pressed & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick)) { SimulateMouseClickEvent(MOUSEEVENTF_LEFTDOWN); } else if (((just_released & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick)) { SimulateMouseClickEvent(MOUSEEVENTF_LEFTUP); } if (((just_pressed & PSMoveSharpConstants.ctrlCircle) == PSMoveSharpConstants.ctrlCircle)) { SimulateMouseClickEvent(MOUSEEVENTF_RIGHTDOWN); } else if (((just_released & PSMoveSharpConstants.ctrlCircle) == PSMoveSharpConstants.ctrlCircle)) { SimulateMouseClickEvent(MOUSEEVENTF_RIGHTUP); } } } else if (((just_pressed & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick) && ((last_buttons & PSMoveSharpConstants.ctrlTrigger) == PSMoveSharpConstants.ctrlTrigger)) { switch (calibration_step) { case ClientCalibrationStep.Left: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetLeft, 0); break; case ClientCalibrationStep.Right: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetRight, 0); break; case ClientCalibrationStep.Bottom: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetBottom, 0); break; case ClientCalibrationStep.Top: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetTop, 0); break; } Console.WriteLine("Calibration tick"); calibration_step++; if (calibration_step == ClientCalibrationStep.Done) { MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerEnable, 0); Console.WriteLine("Enabling pointer"); } } }
private void updateMouser(PSMoveSharpState state) { UInt16 just_pressed; UInt16 just_released; { UInt16 changed_buttons = Convert.ToUInt16(state.gemStates[0].pad.digitalbuttons ^ last_buttons); just_pressed = Convert.ToUInt16(changed_buttons & state.gemStates[0].pad.digitalbuttons); just_released = Convert.ToUInt16(changed_buttons & ~state.gemStates[0].pad.digitalbuttons); last_buttons = state.gemStates[0].pad.digitalbuttons; } checkBoxCalibrated.Checked = (state.positionPointerStates[0].valid == 1); checkBoxEnabled.Checked = fake_mouse_events; labelMovePosValX.Text = (state.positionPointerStates[0].valid == 1) ? state.positionPointerStates[0].normalized_x.ToString("N3") : "N/A"; labelMovePosValY.Text = (state.positionPointerStates[0].valid == 1) ? state.positionPointerStates[0].normalized_y.ToString("N3") : "N/A"; buttonEnable.Text = fake_mouse_events ? "Disable" : "Enable"; if (state.positionPointerStates[0].valid == 1) { if ((just_pressed & PSMoveSharpConstants.ctrlSelect) == PSMoveSharpConstants.ctrlSelect) { MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerDisable, 0); Console.WriteLine("Disabling pointer"); calibration_step = 0; } if (fake_mouse_events) { if ((just_pressed & PSMoveSharpConstants.ctrlCross) == PSMoveSharpConstants.ctrlCross) { MouserRecenter(state.positionPointerStates[0].normalized_x, state.positionPointerStates[0].normalized_y); } else { MouserMove(state.positionPointerStates[0].normalized_x, state.positionPointerStates[0].normalized_y); } if (((just_pressed & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick)) { SimulateMouseClickEvent(MOUSEEVENTF_LEFTDOWN); } else if (((just_released & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick)) { SimulateMouseClickEvent(MOUSEEVENTF_LEFTUP); } if (((just_pressed & PSMoveSharpConstants.ctrlCircle) == PSMoveSharpConstants.ctrlCircle)) { SimulateMouseClickEvent(MOUSEEVENTF_RIGHTDOWN); } else if (((just_released & PSMoveSharpConstants.ctrlCircle) == PSMoveSharpConstants.ctrlCircle)) { SimulateMouseClickEvent(MOUSEEVENTF_RIGHTUP); } } } else if (((just_pressed & PSMoveSharpConstants.ctrlTick) == PSMoveSharpConstants.ctrlTick) && ((last_buttons & PSMoveSharpConstants.ctrlTrigger) == PSMoveSharpConstants.ctrlTrigger)) { switch (calibration_step) { case ClientCalibrationStep.Left: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetLeft, 0); break; case ClientCalibrationStep.Right: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetRight, 0); break; case ClientCalibrationStep.Bottom: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetBottom, 0); break; case ClientCalibrationStep.Top: MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerSetTop, 0); break; } Console.WriteLine("Calibration tick"); calibration_step++; if (calibration_step == ClientCalibrationStep.Done) { MouserProgram.moveClient.SendRequestPacket(PSMoveClient.ClientRequest.PSMoveClientRequestPositionPointerEnable, 0); Console.WriteLine("Enabling pointer"); } } }