本文整理汇总了C#中InputManager.CreateInputObject方法的典型用法代码示例。如果您正苦于以下问题:C# InputManager.CreateInputObject方法的具体用法?C# InputManager.CreateInputObject怎么用?C# InputManager.CreateInputObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputManager
的用法示例。
在下文中一共展示了InputManager.CreateInputObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: CreateInput
public void CreateInput()
{
MOIS.ParamList pl = new ParamList();
IntPtr windHnd;
this.mRenderWindow.GetCustomAttribute("WINDOW", out windHnd);
pl.Insert("WINDOW", windHnd.ToString());
//Non-exclusive input, show OS cursor
//If you want to see the mouse cursor and be able to move it outside your OGRE window and use the keyboard outside the running application
pl.Insert("w32_mouse", "DISCL_FOREGROUND");
pl.Insert("w32_mouse", "DISCL_NONEXCLUSIVE");
pl.Insert("w32_keyboard", "DISCL_FOREGROUND");
pl.Insert("w32_keyboard", "DISCL_NONEXCLUSIVE");
inputManager = MOIS.InputManager.CreateInputSystem(pl);
//Create all devices (except joystick, as most people have Keyboard/Mouse) using buffered input.
inputKeyboard = (Keyboard)inputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
inputMouse = (Mouse)inputManager.CreateInputObject(MOIS.Type.OISMouse, true);
MOIS.MouseState_NativePtr mouseState = inputMouse.MouseState;
mouseState.width = this.mViewport.ActualWidth;//update after resize window
mouseState.height = this.mViewport.ActualHeight;
CreateEventHandler();
}
示例3: SetupInput
void SetupInput()
{
ParamList pl = new ParamList();
IntPtr windowHnd;
window.GetCustomAttribute("WINDOW", out windowHnd); // window is your RenderWindow!
pl.Insert("WINDOW", windowHnd.ToString());
InputManager = InputManager.CreateInputSystem(pl);
InputKeyboard = (Keyboard) InputManager.CreateInputObject(MOIS.Type.OISKeyboard, true);
InputKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(InputKeyboard_KeyPressed);
}