本文整理汇总了C#中MouseState.GetMouseButtons方法的典型用法代码示例。如果您正苦于以下问题:C# MouseState.GetMouseButtons方法的具体用法?C# MouseState.GetMouseButtons怎么用?C# MouseState.GetMouseButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MouseState
的用法示例。
在下文中一共展示了MouseState.GetMouseButtons方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FrameMoveMouse
private void FrameMoveMouse()
{
_mouseState = _mouse.CurrentMouseState;
byte[] buttons = _mouseState.GetMouseButtons();
}
示例2: Poll
public void Poll()
{
LockMouse = false;
try
{
CurrentMouseState = Device.CurrentMouseState;
ButtonState = CurrentMouseState.GetMouseButtons();
for (int i = 0; i < ButtonState.Length; i++)
{
if (ButtonsHeld[i])
ButtonsPressed[i] = false;
else
ButtonsPressed[i] = (ButtonState[i] & 128) > 0;
ButtonsHeld[i] = (ButtonState[i] & 128) > 0;
}
}
catch (NotAcquiredException)
{
try { _Device.Acquire(); }
catch (Exception) { }
}
catch (InputException) { }
catch (NullReferenceException) { }
}
示例3: Update
internal void Update(MouseState state)
{
m_x += state.X;
m_y += state.Y;
m_b = 0;
byte[] buttonState = state.GetMouseButtons();
if ((buttonState[0] & 0x80) != 0) m_b |= 1;
if ((buttonState[1] & 0x80) != 0) m_b |= 2;
if ((buttonState[2] & 0x80) != 0) m_b |= 4;
if ((buttonState[3] & 0x80) != 0) m_b |= 8;
if ((buttonState[4] & 0x80) != 0) m_b |= 16;
if ((buttonState[5] & 0x80) != 0) m_b |= 32;
}
示例4: CaptureImmediateMouse
/// <summary>
/// Takes a snapshot of the mouse state for immediate input checking.
/// </summary>
private void CaptureImmediateMouse()
{
// throw away the collection of buffered data
if (useMouseEvents)
mouseDevice.GetBufferedData();
// capture the current mouse state
mouseState = mouseDevice.CurrentMouseState;
// store the updated absolute values
mouseAbsX += mouseState.X;
mouseAbsY += mouseState.Y;
mouseAbsZ += mouseState.Z;
// calc relative deviance from center
mouseRelX = mouseState.X;
mouseRelY = mouseState.Y;
mouseRelZ = mouseState.Z;
byte[] buttons = mouseState.GetMouseButtons();
// clear the flags
mouseButtons = 0;
for(int i = 0; i < buttons.Length; i++) {
if((buttons[i] & 0x80) != 0) {
mouseButtons |= (1 << i);
}
}
}
示例5: Update
public void Update()
{
do
{
// Try to get the current state
try
{
state = mouse.CurrentMouseState;
// if fetching the state is successful -> exit loop
break;
}
catch (InputException)
{
// let the application handle Windows messages
Application.DoEvents();
// Try to get reacquire the keyboard
// and don't care about exceptions
try
{
mouse.Acquire();
}
catch (InputLostException)
{
continue;
}
catch(OtherApplicationHasPriorityException)
{
continue;
}
}
}
while(true); // Do this until it's successful
if(m_bWindowed)
{
m_XPos = Cursor.Position.X - m_Owner.Left;
m_YPos = Cursor.Position.Y - (m_Owner.Top + 23);
}
else
{
m_XPos += XDelta;
m_YPos += YDelta;
}
byte[] btns = state.GetMouseButtons();
for(int i = 0; i < btns.Length; i++)
{
if(btns[i] != 0)
{
buttons[i] = true;
}
else
{
buttons[i] = false;
}
}
m_ObjectSpace = Vector3.Unproject(
new Vector3(m_XPos, m_YPos, 0f),
d3ddevice.Viewport, d3ddevice.Transform.Projection,
d3ddevice.Transform.View, d3ddevice.Transform.World);
m_ObjectSpace2 = Vector3.Unproject(
new Vector3(m_XPos, m_YPos, 1f),
d3ddevice.Viewport, d3ddevice.Transform.Projection,
d3ddevice.Transform.View, d3ddevice.Transform.World);
}