本文整理汇总了C#中InputManager.GetNumberOfDevices方法的典型用法代码示例。如果您正苦于以下问题:C# InputManager.GetNumberOfDevices方法的具体用法?C# InputManager.GetNumberOfDevices怎么用?C# InputManager.GetNumberOfDevices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputManager
的用法示例。
在下文中一共展示了InputManager.GetNumberOfDevices方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStartup
static void DoStartup()
{
ParamList pl = new ParamList();
Form1 form = new Form1();
form.Show();
pl.Insert("WINDOW", form.Handle.ToString());
//Default mode is foreground exclusive..but, we want to show mouse - so nonexclusive
pl.Insert("w32_mouse", "DISCL_FOREGROUND");
pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
//This never returns null.. it will raise an exception on errors
g_InputManager = InputManager.CreateInputSystem(pl);
uint v = InputManager.VersionNumber;
Console.WriteLine("OIS Version: " + (v >> 16) + "." + ((v >> 8) & 0x000000FF) + "." + (v & 0x000000FF)
+ "\n\tRelease Name: " //+ InputManager.VersionName
+ "\n\tPlatform: " + g_InputManager.InputSystemName()
+ "\n\tNumber of Mice: " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISMouse)
+ "\n\tNumber of Keyboards: " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISKeyboard)
+ "\n\tNumber of Joys/Pads = " + g_InputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick));
//List all devices
DeviceList list = g_InputManager.ListFreeDevices();
foreach (KeyValuePair<MOIS.Type, string> pair in list)
Console.WriteLine("\n\tDevice: " + g_DeviceType[(int)pair.Key] + " Vendor: " + pair.Value);
g_kb = (Keyboard)g_InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
g_kb.KeyPressed += new KeyListener.KeyPressedHandler(KeyPressed);
g_kb.KeyReleased += new KeyListener.KeyReleasedHandler(KeyReleased);
g_m = (Mouse)g_InputManager.CreateInputObject(MOIS.Type.OISMouse, true);
g_m.MouseMoved += new MouseListener.MouseMovedHandler(MouseMoved);
g_m.MousePressed += new MouseListener.MousePressedHandler(MousePressed);
g_m.MouseReleased += new MouseListener.MouseReleasedHandler(MouseReleased);
MouseState_NativePtr ms = g_m.MouseState;
ms.width = form.Width;
ms.height = form.Height;
//This demo only uses at max 4 joys
int numSticks = g_InputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick);
if (numSticks > 4) numSticks = 4;
g_joys = new JoyStick[numSticks];
for (int i = 0; i < numSticks; ++i)
{
g_joys[i] = (JoyStick)g_InputManager.CreateInputObject(MOIS.Type.OISJoyStick, true);
g_joys[i].AxisMoved += new JoyStickListener.AxisMovedHandler(AxisMoved);
g_joys[i].ButtonPressed += new JoyStickListener.ButtonPressedHandler(JoyButtonPressed);
g_joys[i].ButtonReleased += new JoyStickListener.ButtonReleasedHandler(JoyButtonReleased);
g_joys[i].PovMoved += new JoyStickListener.PovMovedHandler(PovMoved);
g_joys[i].Vector3Moved += new JoyStickListener.Vector3MovedHandler(Vector3Moved);
}
}