コード例 #1
0
ファイル: InputDriver.cs プロジェクト: prepare/HTML-Renderer
        public InputDriver(GameWindow parent)
        {
            if (parent == null)
                throw new ArgumentException("A valid window (IWindowInfo) must be specified to construct an InputDriver");
            switch (Environment.OSVersion.Platform)
            {
                case PlatformID.Win32Windows:
                case PlatformID.Win32NT:
                case PlatformID.Win32S:
                case PlatformID.WinCE:
                    if (Environment.OSVersion.Version.Major > 5 ||
                        (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
                    {
                        inputDriver = new OpenTK.Platform.Windows.WinRawInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
                    }
                    else
                    {
                        // Legacy or unknown windows version:
                        inputDriver = new OpenTK.Platform.Windows.WMInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
                    }
                    break;
                case PlatformID.Unix:
                    // TODO: Input is currently handled asychronously by the driver in X11GLNative.
                    //inputDriver = new OpenTK.Platform.X11.X11Input(parent.WindowInfo);

                    break;
                default:
                    throw new PlatformNotSupportedException(
    "Input handling is not supported on the current platform. Please report the problem to http://opentk.sourceforge.net");
            }
        }
コード例 #2
0
        public InputDriver(GameWindow parent)
        {
            if (parent == null)
            {
                throw new ArgumentException("A valid window (IWindowInfo) must be specified to construct an InputDriver");
            }
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Win32Windows:
            case PlatformID.Win32NT:
            case PlatformID.Win32S:
            case PlatformID.WinCE:
                if (Environment.OSVersion.Version.Major > 5 ||
                    (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1))
                {
                    inputDriver = new OpenTK.Platform.Windows.WinRawInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
                }
                else
                {
                    // Legacy or unknown windows version:
                    inputDriver = new OpenTK.Platform.Windows.WMInput((OpenTK.Platform.Windows.WinWindowInfo)parent.WindowInfo);
                }
                break;

            case PlatformID.Unix:
                // TODO: Input is currently handled asychronously by the driver in X11GLNative.
                //inputDriver = new OpenTK.Platform.X11.X11Input(parent.WindowInfo);

                break;

            default:
                throw new PlatformNotSupportedException(
                          "Input handling is not supported on the current platform. Please report the problem to http://opentk.sourceforge.net");
            }
        }
コード例 #3
0
ファイル: Sdl2NativeWindow.cs プロジェクト: raphaelts3/opentk
        public Sdl2NativeWindow(int x, int y, int width, int height,
            string title, GameWindowFlags options, DisplayDevice device,
            IInputDriver input_driver)
        {
            lock (sync)
            {
                this.input_driver = input_driver;

                var bounds = device.Bounds;
                var flags = TranslateFlags(options);
                flags |= WindowFlags.OPENGL;
                flags |= WindowFlags.RESIZABLE;
                flags |= WindowFlags.HIDDEN;
                if (Toolkit.Options.EnableHighResolution)
                {
                    flags |= WindowFlags.ALLOW_HIGHDPI;
                }

                if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 ||
                    (flags & WindowFlags.FULLSCREEN) != 0)
                    window_state = WindowState.Fullscreen;

                IntPtr handle;
                lock (SDL.Sync)
                {
                    handle = SDL.CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags);
                    exists = true;
                }
                ProcessEvents();
                window = new Sdl2WindowInfo(handle, null);
                window_id = SDL.GetWindowID(handle);
                windows.Add(window_id, this);
                window_title = title;
            }
        }
コード例 #4
0
ファイル: MappedReader.cs プロジェクト: palotasb/cornelius
        public static IEnumerable <T> Read <T>(string path, Map map, IInputDriver driver)
            where T : new()
        {
            var reader = driver.GetReader(path, null);
            List <Assignment> assignments = new List <Assignment>();

            FieldInfo[] fields = typeof(T).GetFields();

            foreach (FieldInfo field in fields)
            {
                MapAttribute attribute = (MapAttribute)field.GetCustomAttributes(typeof(MapAttribute), false).FirstOrDefault();
                if (attribute != null)
                {
                    Assignment assignment = null;
                    var        entries    = map.Columns.Where(e => e.Value == field.Name);
                    foreach (var entry in entries)
                    {
                        int index = reader.FirstRow.IndexOf(entry.Key);
                        if (index >= 0)
                        {
                            assignment = new Assignment(index, field);
                            break;
                        }
                    }

                    if (assignment == null && attribute.Required)
                    {
                        throw new Exception("A \"" + field.Name + "\" mező nem található a térképben vagy a fájlban.");
                    }
                    else if (assignment != null)
                    {
                        Translation translation = null;
                        if (map.Enums.ContainsKey(field.Name))
                        {
                            translation = map.Enums[field.Name];
                        }
                        assignment.Cast = Transform.ToType(field.FieldType, translation);
                        assignments.Add(assignment);
                    }
                }
            }

            foreach (var record in reader.Skip(1))
            {
                T obj = new T();
                foreach (var assignment in assignments)
                {
                    assignment.Field.SetValue(obj, assignment.Cast(record[assignment.Index]));
                }
                yield return(obj);
            }

            reader.Dispose();
        }
コード例 #5
0
ファイル: TableReader.cs プロジェクト: palotasb/cornelius
        public static IEnumerable <T> Read <T>(string path, IInputDriver driver)
            where T : new()
        {
            var table  = (TableAttribute)typeof(T).GetCustomAttributes(typeof(TableAttribute), false).First();
            var fields = typeof(T).GetFields().Where(field => field.GetCustomAttributes(typeof(ColumnAttribute), true).Length > 0).OrderBy(field => ((ColumnAttribute)field.GetCustomAttributes(typeof(ColumnAttribute), true).First()).Number).ToArray();
            var reader = driver.GetReader(path, table.Name);

            foreach (var row in reader.Skip(1))
            {
                T item = new T();
                for (int i = 0; i < fields.Length; ++i)
                {
                    fields[i].SetValue(item, Transform.ToType(fields[i].FieldType)(row[i]));
                }
                yield return(item);
            }

            reader.Dispose();
        }
コード例 #6
0
ファイル: Sdl2NativeWindow.cs プロジェクト: noggs/opentk
        public Sdl2NativeWindow(int x, int y, int width, int height,
                                string title, GameWindowFlags options, DisplayDevice device,
                                IInputDriver input_driver)
        {
            lock (sync)
            {
                this.input_driver = input_driver;

                var bounds = device.Bounds;
                var flags  = TranslateFlags(options);
                flags |= WindowFlags.OPENGL;
                flags |= WindowFlags.RESIZABLE;
                flags |= WindowFlags.HIDDEN;
                if (Toolkit.Options.EnableHighResolution)
                {
                    flags |= WindowFlags.ALLOW_HIGHDPI;
                }

                if ((flags & WindowFlags.FULLSCREEN_DESKTOP) != 0 ||
                    (flags & WindowFlags.FULLSCREEN) != 0)
                {
                    window_state = WindowState.Fullscreen;
                }

                IntPtr handle;
                lock (SDL.Sync)
                {
                    EventFilterDelegate = Marshal.GetFunctionPointerForDelegate(EventFilterDelegate_GCUnsafe);
                    handle = SDL.CreateWindow(title, bounds.Left + x, bounds.Top + y, width, height, flags);
                    SDL.AddEventWatch(EventFilterDelegate, handle);
                    SDL.PumpEvents();
                }
                window    = new Sdl2WindowInfo(handle, null);
                window_id = SDL.GetWindowID(handle);
                windows.Add(window_id, this);
                window_title = title;

                exists = true;
            }
        }
コード例 #7
0
ファイル: DummyGame.cs プロジェクト: minato7/CodeWar5
 public DummyGame(IDisplayDriver display, IInputDriver input)
 {
     myDisplayDriver              = display;
     myInputDriver                = input;
     myInputDriver.InputReceived += OnInputReceived;
 }
コード例 #8
0
 static IL()
 {
     Driver = DriverManager.LoadDriver <IInputDriver>(GameConfig.InputDriver, ExpectedDriverVersion);
     Driver.Initialize();
 }
コード例 #9
0
        public void OnCreate(EventArgs e)
        {
            this.window.Handle = this.Handle;
            this.window.Parent = null;
            //this.window = new WindowInfo(this);

            //driver = new WinRawInput(this.window);    // Disabled until the mouse issues are resolved.
            driver = new WMInput(this.window);

            Debug.Print("Window created: {0}", window);

            if (this.Create != null)
                this.Create(this, e);
        }