-
Notifications
You must be signed in to change notification settings - Fork 0
/
SingleWiimoteForm.cs
57 lines (48 loc) · 1.49 KB
/
SingleWiimoteForm.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
//////////////////////////////////////////////////////////////////////////////////
// SingleWiimoteForm.cs
// Managed Wiimote Library Tester
// Written by Brian Peek (http://www.brianpeek.com/)
// for MSDN's Coding4Fun (http://msdn.microsoft.com/coding4fun/)
// Visit http://blogs.msdn.com/coding4fun/archive/2007/03/14/1879033.aspx
// and http://www.codeplex.com/WiimoteLib
// for more information
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Windows.Forms;
using WiimoteLib;
namespace WiimoteTest
{
public partial class SingleWiimoteForm : Form
{
Wiimote wm = new Wiimote();
public SingleWiimoteForm()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
wiimoteInfo1.Wiimote = wm;
wm.WiimoteChanged += wm_WiimoteChanged;
wm.WiimoteExtensionChanged += wm_WiimoteExtensionChanged;
wm.Connect();
wm.SetReportType(InputReport.IRAccel, true);
wm.SetLEDs(false, true, true, false);
}
private void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args)
{
wiimoteInfo1.UpdateState(args);
}
private void wm_WiimoteExtensionChanged(object sender, WiimoteExtensionChangedEventArgs args)
{
wiimoteInfo1.UpdateExtension(args);
if(args.Inserted)
wm.SetReportType(InputReport.IRExtensionAccel, true);
else
wm.SetReportType(InputReport.IRAccel, true);
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
wm.Disconnect();
}
}
}