Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("\n\n*** OIS Console Demo App is starting up... ***");
            try
            {
                DoStartup();
                Console.WriteLine("\nStartup done... Hit 'q' or ESC to exit (or joy button 1)\n");

                while (appRunning)
                {
                    System.Threading.Thread.Sleep(30);
                    System.Windows.Forms.Application.DoEvents();

                    if (g_kb != null)
                    {
                        g_kb.Capture();
                        if (!g_kb.Buffered())
                        {
                            handleNonBufferedKeys();
                        }
                    }

                    if (g_m != null)
                    {
                        g_m.Capture();
                        if (!g_m.Buffered())
                        {
                            handleNonBufferedMouse();
                        }
                    }

                    for (int i = 0; i < g_joys.Length; ++i)
                    {
                        if (g_joys[i] != null)
                        {
                            g_joys[i].Capture();
                            if (!g_joys[i].Buffered())
                            {
                                handleNonBufferedJoy(g_joys[i]);
                            }
                        }
                    }
                }
            }
            catch (System.Runtime.InteropServices.SEHException)
            {
                if (MOIS.OISException.LastException != null)
                {
                    System.Windows.Forms.MessageBox.Show(MOIS.OISException.LastException.eText, "An exception has occured!", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                }
                else
                {
                    throw;
                }
            }

            if (g_InputManager != null)
            {
                g_InputManager.DestroyInputObject(g_kb);
                g_InputManager.DestroyInputObject(g_m);

                for (int i = 0; i < g_joys.Length; ++i)
                {
                    g_InputManager.DestroyInputObject(g_joys[i]);
                }

                InputManager.DestroyInputSystem(g_InputManager);
            }

            Console.WriteLine("\n\nGoodbye\n");
        }