-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.cs
64 lines (49 loc) · 1.5 KB
/
Input.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.DirectX.DirectInput;
using System.Windows.Forms;
namespace GalaxySmash
{
public class Input
{
private Device _keyboard;
private Device _mouse;
private MouseState _mouseState;
private KeyboardState _keyboardState;
public void Init(Control parent)
{
_keyboard = new Microsoft.DirectX.DirectInput.Device(SystemGuid.Keyboard);
_keyboard.SetCooperativeLevel(parent, CooperativeLevelFlags.Background | CooperativeLevelFlags.NonExclusive);
_keyboard.Acquire();
_mouse = new Device(SystemGuid.Mouse);
_mouse.SetCooperativeLevel(parent,
CooperativeLevelFlags.NonExclusive |
CooperativeLevelFlags.Background);
_mouse.Acquire();
}
public void FrameMove()
{
FrameMoveMouse();
FrameMoveKeyboard();
}
public MouseState Mouse
{
get { return _mouseState; }
}
public KeyboardState Keyboard
{
get { return _keyboardState; }
}
private void FrameMoveMouse()
{
_mouseState = _mouse.CurrentMouseState;
byte[] buttons = _mouseState.GetMouseButtons();
}
private void FrameMoveKeyboard()
{
_keyboardState = _keyboard.GetCurrentKeyboardState();
}
}
}