]> O.S.I.I.S - jp/crow.git/commitdiff
base changed done, need mouse state to be updated
authorjpbruyere <jp.bruyere@hotmail.com>
Sat, 13 Feb 2016 17:10:23 +0000 (18:10 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 1 Mar 2016 04:01:44 +0000 (05:01 +0100)
42 files changed:
Crow.csproj
Tests/GOLIBTest_0.cs
Tests/GOLIBTest_4.cs
Tests/GOLIBTest_5.cs
Tests/GOLIBTest_DirViewer.cs
Tests/GOLIBTest_Listbox.cs
Tests/GOLIBTest_TypeViewer.cs
Tests/GOLIBTests.cs
Tests/Tests.csproj
src/BubblingMouseButtonEventArgs.cs
src/GraphicObjects/Button.cs
src/GraphicObjects/CheckBox.cs
src/GraphicObjects/Container.cs
src/GraphicObjects/Expandable.cs
src/GraphicObjects/FileDialog.cs
src/GraphicObjects/GraphicObject.cs
src/GraphicObjects/Image.cs
src/GraphicObjects/Label.cs
src/GraphicObjects/ListBox.cs
src/GraphicObjects/PrivateContainer.cs
src/GraphicObjects/RadioButton.cs
src/GraphicObjects/Scroller.cs
src/GraphicObjects/Slider.cs
src/GraphicObjects/Spinner.cs
src/GraphicObjects/Splitter.cs
src/GraphicObjects/TabItem.cs
src/GraphicObjects/TabView.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TextBox.cs
src/GraphicObjects/TextRun.cs
src/GraphicObjects/Window.cs
src/Input/ButtonState.cs [new file with mode: 0644]
src/Input/Buttons.cs [new file with mode: 0644]
src/Input/Key.cs [new file with mode: 0644]
src/Input/KeyModifiers.cs [new file with mode: 0644]
src/Input/KeyboardKeyEventArgs.cs [new file with mode: 0644]
src/Input/KeyboardState.cs [new file with mode: 0644]
src/Input/MouseButton.cs [new file with mode: 0644]
src/Input/MouseEventArgs.cs [new file with mode: 0644]
src/Input/MouseScroll.cs [new file with mode: 0644]
src/Input/MouseState.cs [new file with mode: 0644]
src/OpenTKGameWindow.cs

index 689751699f85db233598490735cbdc1ef96d1631..2c519d58d4a544112055e42394af4395d334258e 100644 (file)
     <Compile Include="src\GraphicObjects\TabView.cs" />
     <Compile Include="src\GraphicObjects\TabItem.cs" />
     <Compile Include="src\GraphicObjects\DummyTemplate.cs" />
+    <Compile Include="src\Input\KeyboardKeyEventArgs.cs" />
+    <Compile Include="src\Input\Buttons.cs" />
+    <Compile Include="src\Input\ButtonState.cs" />
+    <Compile Include="src\Input\Key.cs" />
+    <Compile Include="src\Input\KeyboardState.cs" />
+    <Compile Include="src\Input\KeyModifiers.cs" />
+    <Compile Include="src\Input\MouseButton.cs" />
+    <Compile Include="src\Input\MouseEventArgs.cs" />
+    <Compile Include="src\Input\MouseScroll.cs" />
+    <Compile Include="src\Input\MouseState.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
     <Folder Include="src\OpenGL\" />
     <Folder Include="src\Fill\" />
     <Folder Include="Styles\" />
+    <Folder Include="src\Input\" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Include="Images\Icons\updown.svg" />
index 32067ae2ae9c2106970b9115897e6c08d6cea2b5..a82c7d6d2db24ca0cba218d42ad619a32837c277 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
@@ -61,25 +60,25 @@ namespace test6
                        l.Text = tmp.ToString ();
                }
 
-               protected override void OnKeyDown (KeyboardKeyEventArgs e)
-               {
-                       switch (e.Key) {
-                       case Key.Left:
-                               g.Left++;
-                               break;
-                       case Key.Right:
-                               g.Left--;
-                               break;
-                       case Key.Up:
-                               g.Top--;
-                               break;
-                       case Key.Down:
-                               g.Top++;
-                               break;
-                       default:
-                               break;
-                       }
-               }
+//             protected override void OnKeyDown (KeyboardKeyEventArgs e)
+//             {
+//                     switch (e.Key) {
+//                     case Key.Left:
+//                             g.Left++;
+//                             break;
+//                     case Key.Right:
+//                             g.Left--;
+//                             break;
+//                     case Key.Up:
+//                             g.Top--;
+//                             break;
+//                     case Key.Down:
+//                             g.Top++;
+//                             break;
+//                     default:
+//                             break;
+//                     }
+//             }
                protected override void OnUpdateFrame (FrameEventArgs e)
                {
                        base.OnUpdateFrame (e);
index 9c8fe3858bce5160e35911b777bb311eae2b0668..37596eeb8d5bcf9dbf8c9972ebe8d871369b8ebe 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
index 664483be0401b628eeda4b665b86f840177717ee..349549ec67c39f87a7bfdec0d1eb4330afd8d600 100644 (file)
@@ -2,7 +2,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
index a1d20c4b6556851136e801ac2c53f1bf48f4e5f4..04e46aa49063416d7e6991a74529c12f3f6fc32d 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
index 1dd1f555bb7fe96ca1bb90698389c78540263a42..766310207b430429b93f91afecc5c07d8cfac08a 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
@@ -97,23 +96,23 @@ namespace test
                        TestList = Directory.GetFileSystemEntries("/home/jp/tmp/mtgdata/a", "*.txt",SearchOption.AllDirectories).ToList();
                        ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));
                }
-               protected override void OnMouseMove (MouseMoveEventArgs e)
-               {                       
-                       base.OnMouseMove (e);
-                       ValueChanged.Raise (this, new ValueChangeEventArgs ("Hover", Hover));
-                       ValueChanged.Raise (this, new ValueChangeEventArgs ("MousePos", e.Position.ToString()));
-               }
+//             protected override void OnMouseMove (MouseMoveEventArgs e)
+//             {
+//                     base.OnMouseMove (e);
+//                     ValueChanged.Raise (this, new ValueChangeEventArgs ("Hover", Hover));
+//                     ValueChanged.Raise (this, new ValueChangeEventArgs ("MousePos", e.Position.ToString()));
+//             }
 
                protected override void OnUpdateFrame (FrameEventArgs e)
                {
                        base.OnUpdateFrame (e);
                }
-               protected override void OnKeyDown (KeyboardKeyEventArgs e)
-               {
-                       TestList = Directory.GetFileSystemEntries("/home/jp/tmp/mtgdata/a", "*.txt",SearchOption.AllDirectories).ToList();
-                       //TestList.Add ("newly added list item");
-                       ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));
-               }
+//             protected override void OnKeyDown (KeyboardKeyEventArgs e)
+//             {
+//                     TestList = Directory.GetFileSystemEntries("/home/jp/tmp/mtgdata/a", "*.txt",SearchOption.AllDirectories).ToList();
+//                     //TestList.Add ("newly added list item");
+//                     ValueChanged.Raise(this, new ValueChangeEventArgs ("TestList", TestList));
+//             }
 
                [STAThread]
                static void Main ()
index 8864d1da01ff0438d92edc28866d3c7fd299beae..39e5a527b1253479c1fbda8a5519cb130433a9f4 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
index b70a25423888a6510bdaebe6b300f108aaadb0ce..a0c8a84c47ae40a575bf41963017fef7e450cc14 100644 (file)
@@ -5,7 +5,6 @@ using System;
 using System.Runtime.InteropServices;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 using System.Diagnostics;
 
@@ -189,41 +188,22 @@ namespace test
                {
                        base.OnLoad (e);
                        //this.AddWidget(new test4());
+                       KeyboardKeyDown += GOLIBTests_KeyboardKeyDown1;;
 
                        GraphicObject obj = LoadInterface("Interfaces/" + testFiles[idx]);
                        obj.DataSource = this;
-       }
-               protected override void OnUpdateFrame (FrameEventArgs e)
-               {
-                       //if (frameCpt % 8 == 0)
-                               base.OnUpdateFrame (e);
-                       
-                       fps = (int)RenderFrequency;
-
-
-                       if (frameCpt > 50) {
-                               resetFps ();
-                               frameCpt = 0;
-                               GC.Collect();
-                               GC.WaitForPendingFinalizers();
-                               NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
-                       }
-                       frameCpt++;
                }
-               protected override void OnKeyDown (KeyboardKeyEventArgs e)
+
+               void GOLIBTests_KeyboardKeyDown1 (object sender, OpenTK.Input.KeyboardKeyEventArgs e)
                {
-                       if (FocusedWidget is TextBox) {
-                               base.OnKeyDown (e);
-                               return;
-                       }
-                       if (e.Key == Key.Escape) {
+                       if (e.Key == OpenTK.Input.Key.Escape) {
                                this.Quit ();
                                return;
-                       } else if (e.Key == Key.L) {
+                       } else if (e.Key == OpenTK.Input.Key.L) {
                                TestList.Add ("new string");
                                NotifyValueChanged ("TestList", TestList);
                                return;
-                       } else if (e.Key == Key.W) {
+                       } else if (e.Key == OpenTK.Input.Key.W) {
                                GraphicObject w = LoadInterface("Interfaces/testWindow.goml");
                                w.DataSource = this;
                                return;
@@ -235,7 +215,24 @@ namespace test
                        this.Title = testFiles [idx];
                        GraphicObject obj = LoadInterface("Interfaces/" + testFiles[idx]);
                        obj.DataSource = this;
+               }
+
+               protected override void OnUpdateFrame (FrameEventArgs e)
+               {
+                       //if (frameCpt % 8 == 0)
+                               base.OnUpdateFrame (e);
+
+                       fps = (int)RenderFrequency;
 
+
+                       if (frameCpt > 50) {
+                               resetFps ();
+                               frameCpt = 0;
+                               GC.Collect();
+                               GC.WaitForPendingFinalizers();
+                               NotifyValueChanged("memory", GC.GetTotalMemory (false).ToString());
+                       }
+                       frameCpt++;
                }
                void onButClick(object send, MouseButtonEventArgs e)
                {
@@ -265,4 +262,4 @@ namespace test
                        Debug.WriteLine ("cancel");
                }
        }
-}
\ No newline at end of file
+}
index a01a92af4bc38be4e4b775bcfc40fcaa9aa39f1f..b7c32c0132a1b6a2aa098716226fa1d7140b2fd2 100644 (file)
@@ -47,7 +47,6 @@
     <Reference Include="Mono.Cairo" />
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="GOLIBTest_4.cs" />
     <Compile Include="GOLIBTest_Listbox.cs" />
     <Compile Include="GOLIBTest_0.cs" />
     <Compile Include="GOLIBTest_TypeViewer.cs" />
index 863d265e1e5523a9f9dafb256fce2463b373c26e..515a7e070a165b5a0629e205845e49b32a3f99e4 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using System;
-using OpenTK.Input;
 
 namespace Crow
 {
index 92d19af60c63f1a78555106c8582b5fef3dad0eb..0b37118c3c2f82efd8033b326bf8618da03790c2 100644 (file)
@@ -8,7 +8,6 @@ using System.Diagnostics;
 
 using System.Xml.Serialization;
 using Cairo;
-using OpenTK.Input;
 using System.ComponentModel;
 
 namespace Crow
index edf6650b106fe55c8dab465301257a0ade07c511..71e686f911adc56cd2c95611c4c29ea171f0c209 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using System;
-using OpenTK.Input;
 using System.ComponentModel;
 using System.Xml.Serialization;
 
index 360eee5161f490e9338a478d6340de81279356b6..cb6145a84c1dcf7b1cf4215220bc3c5352daf60d 100644 (file)
@@ -1,7 +1,6 @@
 using System;
 using System.Xml.Serialization;
 using System.Reflection;
-using OpenTK.Input;
 using System.ComponentModel;
 using System.Linq;
 
index 16b3e9749e86cf3b98bab2ac9d74eb4f8ac0884f..af8b5640ee91a5143fe43282822c0317992dcba5 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using System;
-using OpenTK.Input;
 using System.ComponentModel;
 using System.Xml.Serialization;
 
index bed42a05ec45a0b531e6e9d5f0abf305c9fa244d..b1c93119a646e3fc13313cac6f3701043c8b2eae 100644 (file)
@@ -24,7 +24,6 @@ using System.ComponentModel;
 using System.IO;
 using System.Collections.Generic;
 using System.Diagnostics;
-using OpenTK.Input;
 using System.Linq;
 using System.Text.RegularExpressions;
 
index 2ddceccac82dd903734445f9bf016d52d5d6d79f..9f1bf81136658171514a8d87011ac58c5613688e 100644 (file)
@@ -1,15 +1,13 @@
 ï»¿using System;
 using System.Collections.Generic;
 using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
+using System.Xml.Serialization;
 using System.Reflection;
 using System.Reflection.Emit;
 using System.Runtime.CompilerServices;
-using System.Xml.Serialization;
 using Cairo;
-using OpenTK.Input;
-using System.IO;
+using System.Linq;
+using System.Diagnostics;
 
 namespace Crow
 {
index 46d081eb13809384d418df3e77ac4441e4183462..8f02a19e3360b05b62ba4c542a045950f4136035 100644 (file)
@@ -1,14 +1,10 @@
 ï»¿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using Cairo;
-using System.IO;
-using System.Runtime.InteropServices;
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
 
+
 namespace Crow
 {
        public class Image : GraphicObject
index 6782e259a24ef3498189695de7f6b42f9e646e42..fa2d582803fedc745850730812a61dd2ac022f6a 100644 (file)
@@ -7,7 +7,6 @@ using Cairo;
 using System.Text.RegularExpressions;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using OpenTK.Input;
 
 namespace Crow
 {
index 69e717845b0e3c6fe22fdd81e8975b8dd0dc4b8f..31555306544723b1c3ec49e352bfdf29e949627f 100644 (file)
@@ -1,4 +1,4 @@
-//
+                                            //
 //  ListBox.cs
 //
 //  Author:
index 640e8d0bbbcf5f89349933d2c3a13b265e190999..3a3d90671c22a504bd5668c5d07ccd2e80211d9f 100644 (file)
@@ -21,7 +21,6 @@
 using System;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using OpenTK.Input;
 using Cairo;
 
 namespace Crow
index 4370d1572e28a7ac1462b1eb49e5253270b1d4b8..a62487069c05a8b0e667a4a6771c3cf1d50a6a39 100644 (file)
@@ -1,5 +1,4 @@
 ï»¿using System;
-using OpenTK.Input;
 using System.ComponentModel;
 using System.Xml.Serialization;
 
index 459205fecbdb0599f8141e7215080df43b86fd4b..58a0f245a26af5f05c3cd0e09358eaecc4c7046b 100644 (file)
@@ -24,7 +24,6 @@ using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
 using Cairo;
-using OpenTK.Input;
 
 namespace Crow
 {
@@ -166,10 +165,6 @@ namespace Crow
                internal Point savedMousePos;
                public override bool MouseIsIn (Point m)
                {                       
-//                     Debug.WriteLine ("Mouse in scroller: {0} scr coord:{1} mouse:{2}",
-//                             base.ScreenCoordinates (Slot).ContainsOrIsEqual (m),
-//                             base.ScreenCoordinates (Slot), m);
-
                        return Visible ? base.ScreenCoordinates(Slot).ContainsOrIsEqual (m) : false; 
                }
                public override void checkHoverWidget (MouseMoveEventArgs e)
@@ -180,10 +175,6 @@ namespace Crow
                }
                public override void onMouseWheel (object sender, MouseWheelEventArgs e)
                {
-                       //base.onMouseWheel (sender, e); base event buble to the top
-//                     if (MouseWheelChanged!=null)
-//                             MouseWheelChanged (this, e);
-
                        if (Child == null)
                                return;
                        
@@ -218,7 +209,7 @@ namespace Crow
 
                        gr.Save ();
                        //clip to scrolled client zone
-                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);//+ new Point((int)ScrollX,(int)ScrollY)
+                       CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius);
                        gr.Clip ();
 
                        gr.Translate (-ScrollX, -ScrollY);
index faaacd784833b8c7538877092d3f2271d9136025..a96f2a401bdffbdf85ecaa60c1d57efb2ff4a2be 100644 (file)
@@ -172,7 +172,7 @@ namespace Crow
         }
         
                #region mouse handling
-               public override void onMouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+               public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseDown (sender, e);
 
@@ -191,13 +191,13 @@ namespace Crow
                                        Value += LargeIncrement;
                        }
                }
-               public override void onMouseUp (object sender, OpenTK.Input.MouseButtonEventArgs e)
+               public override void onMouseUp (object sender,MouseButtonEventArgs e)
                {
                        base.onMouseUp (sender, e);
 
                        holdCursor = false;
                }
-               public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        if (holdCursor) {
                                if (_orientation == Orientation.Horizontal)
index ffc9472be0427e848defaa7e533a6d65f522f5a8..9447f205d2a6355e8fa5a68074b408d075e98d4b 100644 (file)
@@ -19,7 +19,6 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 using System;
-using OpenTK.Input;
 
 namespace Crow
 {
index 97cce52cd0b2b198a73ea67c3154b38f65833902..dbda87af71461d459b0edd7d2b40dede63543824 100644 (file)
@@ -58,7 +58,7 @@ namespace Crow
                                base.Parent = value;
                        }
                }
-               public override void onMouseEnter (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               public override void onMouseEnter (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseEnter (sender, e);
                        if ((Parent as GenericStack).Orientation == Orientation.Horizontal)
@@ -66,12 +66,12 @@ namespace Crow
                        else
                                this.HostContainer.MouseCursor = XCursor.V;
                }
-               public override void onMouseLeave (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               public override void onMouseLeave (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseLeave (sender, e);
                        this.HostContainer.MouseCursor = XCursor.Default;
                }
-               public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseMove (sender, e);
 
index b0e733fb182c4374c7fbf56b373e40e530aa00d0..c2d863af18e1053da53ea38c29f978ae5b64649c 100644 (file)
@@ -158,18 +158,18 @@ namespace Crow
                                || mouseIsInTitle;
                }
                bool holdCursor = false;
-               public override void onMouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+               public override void onMouseDown (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseDown (sender, e);
                        holdCursor = true;
                }
-               public override void onMouseUp (object sender, OpenTK.Input.MouseButtonEventArgs e)
+               public override void onMouseUp (object sender, MouseButtonEventArgs e)
                {
                        base.onMouseUp (sender, e);
                        holdCursor = false;
                        (Parent as TabView).UpdateLayout (LayoutingType.ArrangeChildren);
                }
-               public override void onMouseMove (object sender, OpenTK.Input.MouseMoveEventArgs e)
+               public override void onMouseMove (object sender, MouseMoveEventArgs e)
                {
                        base.onMouseMove (sender, e);
 
@@ -206,7 +206,7 @@ namespace Crow
                                TabOffset = tmp;
                        }
                }
-               public void butCloseTabClick (object sender, OpenTK.Input.MouseButtonEventArgs e){
+               public void butCloseTabClick (object sender, MouseButtonEventArgs e){
                        (Parent as TabView).RemoveChild(this);
                }
                #endregion
index a480ae09eb38931c01bdfd0a1cfd956619ba2fe4..7bf827d666b6770c6e67f021ddef1798a359a76c 100644 (file)
@@ -23,7 +23,6 @@ using System.Xml.Serialization;
 using System.ComponentModel;
 using Cairo;
 using System.Diagnostics;
-using OpenTK.Input;
 
 namespace Crow
 {
@@ -207,7 +206,8 @@ namespace Crow
                        }
                }
                #endregion
-               void Ti_MouseDown (object sender, OpenTK.Input.MouseButtonEventArgs e)
+
+               void Ti_MouseDown (object sender, MouseButtonEventArgs e)
                {
                        SelectedTab = Children.IndexOf (sender as GraphicObject);
                }
index bb2fbd28d6502d55be1f1869d7fe72187c5b4d90..c8ec2d9e87b05ca4485285b6bb5dffe33caff317 100644 (file)
@@ -23,8 +23,8 @@ using System.Xml.Serialization;
 using System.ComponentModel;
 using System.IO;
 using System.Xml;
-using System.Linq;
 using System.Diagnostics;
+using System.Linq;
 
 namespace Crow
 {
index 911225239833aa7280dddc677395f0e8134025e0..7907eb422238c87c89db207ed5c6bb15a1a2d26b 100644 (file)
@@ -2,7 +2,6 @@
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
-using OpenTK.Input;
 using Cairo;
 using System.Diagnostics;
 using System.Xml.Serialization;
index bb308eb6451a855438e8db644fa54f872e2008e5..0fa463af14fead0ffcc05c10c923ee9c01b9f1dc 100644 (file)
@@ -7,7 +7,6 @@ using Cairo;
 using System.Text.RegularExpressions;
 using System.Xml.Serialization;
 using System.ComponentModel;
-using OpenTK.Input;
 
 namespace Crow
 {
index 5e1bd681a165c39c0f7d073171b56b0ecea45bde..757ee080e59e67505e0e27593cac7579e280eb8e 100644 (file)
@@ -2,7 +2,6 @@
 using System.Xml.Serialization;
 using System.ComponentModel;
 using System.Diagnostics;
-using OpenTK.Input;
 
 namespace Crow
 {
diff --git a/src/Input/ButtonState.cs b/src/Input/ButtonState.cs
new file mode 100644 (file)
index 0000000..17849ca
--- /dev/null
@@ -0,0 +1,45 @@
+ #region License
+ //
+ // The Open Toolkit Library License
+ //
+ // Copyright (c) 2006 - 2010 the Open Toolkit library.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights to
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ // the Software, and to permit persons to whom the Software is furnished to do
+ // so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in all
+ // copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ // OTHER DEALINGS IN THE SOFTWARE.
+ //
+ #endregion
+
+namespace Crow
+{
+    /// <summary>
+    /// Enumerates possible mouse button states.
+    /// </summary>
+    public enum ButtonState
+    {
+       /// <summary>
+       /// Indicates that a mouse button is released.
+       /// </summary>
+       Released = 0,
+
+       /// <summary>
+       /// Indicates that a mouse button is pressed.
+       /// </summary>
+       Pressed = 1
+    }
+}
diff --git a/src/Input/Buttons.cs b/src/Input/Buttons.cs
new file mode 100644 (file)
index 0000000..a80f504
--- /dev/null
@@ -0,0 +1,166 @@
+//
+// GamePadButton.cs
+//
+// Author:
+//       robert <${AuthorEmail}>
+//
+// Copyright (c) 2012 robert
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+
+namespace OpenTK.Input
+{
+    /// <summary>
+    /// Enumerates available buttons for a <c>GamePad</c> device.
+    /// </summary>
+    [Flags]
+    public enum Buttons
+    {
+       /// <summary>
+       /// DPad up direction button
+       /// </summary>
+       DPadUp = 1 << 0,
+
+       /// <summary>
+       /// DPad down direction button
+       /// </summary>
+       DPadDown = 1 << 1,
+
+       /// <summary>
+       /// DPad left direction button
+       /// </summary>
+       DPadLeft = 1 << 2,
+
+       /// <summary>
+       /// DPad right direction button
+       /// </summary>
+       DPadRight = 1 << 3,
+
+       /// <summary>
+       /// Start button
+       /// </summary>
+       Start = 1 << 4,
+
+       /// <summary>
+       /// Back button
+       /// </summary>
+       Back = 1 << 5,
+
+       /// <summary>
+       /// Left stick button
+       /// </summary>
+       LeftStick = 1 << 6,
+
+       /// <summary>
+       /// Right stick button
+       /// </summary>
+       RightStick = 1 << 7,
+
+       /// <summary>
+       /// Left shoulder button
+       /// </summary>
+       LeftShoulder = 1 << 8,
+
+       /// <summary>
+       /// Right shoulder button
+       /// </summary>
+       RightShoulder = 1 << 9,
+
+       /// <summary>
+       /// Home button
+       /// </summary>
+       Home = 1 << 11,
+
+       /// <summary>
+       /// Home button
+       /// </summary>
+       BigButton = Home,
+
+       /// <summary>
+       /// A button
+       /// </summary>
+       A = 1 << 12,
+
+       /// <summary>
+       /// B button
+       /// </summary>
+       B = 1 << 13,
+
+       /// <summary>
+       /// X button
+       /// </summary>
+       X = 1 << 14,
+
+       /// <summary>
+       /// Y button
+       /// </summary>
+       Y = 1 << 15,
+
+       /// <summary>
+       /// Left thumbstick left direction button
+       /// </summary>
+       LeftThumbstickLeft = 1 << 21,
+
+       /// <summary>
+       /// Right trigger button
+       /// </summary>
+       RightTrigger = 1 << 22,
+
+       /// <summary>
+       /// Left trigger button
+       /// </summary>
+       LeftTrigger = 1 << 23,
+
+       /// <summary>
+       /// Right thumbstick up direction button
+       /// </summary>
+       RightThumbstickUp = 1 << 24,
+
+       /// <summary>
+       /// Right thumbstick down direction button
+       /// </summary>
+       RightThumbstickDown = 1 << 25,
+
+       /// <summary>
+       /// Right stick right direction button
+       /// </summary>
+       RightThumbstickRight = 1 << 26,
+
+       /// <summary>
+       /// Right stick left direction button
+       /// </summary>
+       RightThumbstickLeft = 1 << 27,
+
+       /// <summary>
+       /// Left stick up direction button
+       /// </summary>
+       LeftThumbstickUp = 1 << 28,
+
+       /// <summary>
+       /// Left stick down direction button
+       /// </summary>
+       LeftThumbstickDown = 1 << 29,
+
+       /// <summary>
+       /// Left stick right direction button
+       /// </summary>
+       LeftThumbstickRight = 1 << 30,
+    }
+}
diff --git a/src/Input/Key.cs b/src/Input/Key.cs
new file mode 100644 (file)
index 0000000..71f9d85
--- /dev/null
@@ -0,0 +1,380 @@
+ #region License
+ //
+ // The Open Toolkit Library License
+ //
+ // Copyright (c) 2006 - 2009 the Open Toolkit library.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights to
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ // the Software, and to permit persons to whom the Software is furnished to do
+ // so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in all
+ // copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ // OTHER DEALINGS IN THE SOFTWARE.
+ //
+ #endregion
+
+namespace Crow
+{
+    /// <summary>
+    /// The available keyboard keys.
+    /// </summary>
+    public enum Key : int
+    {
+       /// <summary>A key outside the known keys.</summary>
+       Unknown = 0,
+
+       // Modifiers
+       /// <summary>The left shift key.</summary>
+       ShiftLeft,
+       /// <summary>The left shift key (equivalent to ShiftLeft).</summary>
+       LShift = ShiftLeft,
+       /// <summary>The right shift key.</summary>
+       ShiftRight,
+       /// <summary>The right shift key (equivalent to ShiftRight).</summary>
+       RShift = ShiftRight,
+       /// <summary>The left control key.</summary>
+       ControlLeft,
+       /// <summary>The left control key (equivalent to ControlLeft).</summary>
+       LControl = ControlLeft,
+       /// <summary>The right control key.</summary>
+       ControlRight,
+       /// <summary>The right control key (equivalent to ControlRight).</summary>
+       RControl = ControlRight,
+       /// <summary>The left alt key.</summary>
+       AltLeft,
+       /// <summary>The left alt key (equivalent to AltLeft.</summary>
+       LAlt = AltLeft,
+       /// <summary>The right alt key.</summary>
+       AltRight,
+       /// <summary>The right alt key (equivalent to AltRight).</summary>
+       RAlt = AltRight,
+       /// <summary>The left win key.</summary>
+       WinLeft,
+       /// <summary>The left win key (equivalent to WinLeft).</summary>
+       LWin = WinLeft,
+       /// <summary>The right win key.</summary>
+       WinRight,
+       /// <summary>The right win key (equivalent to WinRight).</summary>
+       RWin = WinRight,
+       /// <summary>The menu key.</summary>
+       Menu,
+
+       // Function keys (hopefully enough for most keyboards - mine has 26)
+       // <keysymdef.h> on X11 reports up to 35 function keys.
+       /// <summary>The F1 key.</summary>
+       F1,
+       /// <summary>The F2 key.</summary>
+       F2,
+       /// <summary>The F3 key.</summary>
+       F3,
+       /// <summary>The F4 key.</summary>
+       F4,
+       /// <summary>The F5 key.</summary>
+       F5,
+       /// <summary>The F6 key.</summary>
+       F6,
+       /// <summary>The F7 key.</summary>
+       F7,
+       /// <summary>The F8 key.</summary>
+       F8,
+       /// <summary>The F9 key.</summary>
+       F9,
+       /// <summary>The F10 key.</summary>
+       F10,
+       /// <summary>The F11 key.</summary>
+       F11,
+       /// <summary>The F12 key.</summary>
+       F12,
+       /// <summary>The F13 key.</summary>
+       F13,
+       /// <summary>The F14 key.</summary>
+       F14,
+       /// <summary>The F15 key.</summary>
+       F15,
+       /// <summary>The F16 key.</summary>
+       F16,
+       /// <summary>The F17 key.</summary>
+       F17,
+       /// <summary>The F18 key.</summary>
+       F18,
+       /// <summary>The F19 key.</summary>
+       F19,
+       /// <summary>The F20 key.</summary>
+       F20,
+       /// <summary>The F21 key.</summary>
+       F21,
+       /// <summary>The F22 key.</summary>
+       F22,
+       /// <summary>The F23 key.</summary>
+       F23,
+       /// <summary>The F24 key.</summary>
+       F24,
+       /// <summary>The F25 key.</summary>
+       F25,
+       /// <summary>The F26 key.</summary>
+       F26,
+       /// <summary>The F27 key.</summary>
+       F27,
+       /// <summary>The F28 key.</summary>
+       F28,
+       /// <summary>The F29 key.</summary>
+       F29,
+       /// <summary>The F30 key.</summary>
+       F30,
+       /// <summary>The F31 key.</summary>
+       F31,
+       /// <summary>The F32 key.</summary>
+       F32,
+       /// <summary>The F33 key.</summary>
+       F33,
+       /// <summary>The F34 key.</summary>
+       F34,
+       /// <summary>The F35 key.</summary>
+       F35,
+
+       // Direction arrows
+       /// <summary>The up arrow key.</summary>
+       Up,
+       /// <summary>The down arrow key.</summary>
+       Down,
+       /// <summary>The left arrow key.</summary>
+       Left,
+       /// <summary>The right arrow key.</summary>
+       Right,
+
+       /// <summary>The enter key.</summary>
+       Enter,
+       /// <summary>The escape key.</summary>
+       Escape,
+       /// <summary>The space key.</summary>
+       Space,
+       /// <summary>The tab key.</summary>
+       Tab,
+       /// <summary>The backspace key.</summary>
+       BackSpace,
+       /// <summary>The backspace key (equivalent to BackSpace).</summary>
+       Back = BackSpace,
+       /// <summary>The insert key.</summary>
+       Insert,
+       /// <summary>The delete key.</summary>
+       Delete,
+       /// <summary>The page up key.</summary>
+       PageUp,
+       /// <summary>The page down key.</summary>
+       PageDown,
+       /// <summary>The home key.</summary>
+       Home,
+       /// <summary>The end key.</summary>
+       End,
+       /// <summary>The caps lock key.</summary>
+       CapsLock,
+       /// <summary>The scroll lock key.</summary>
+       ScrollLock,
+       /// <summary>The print screen key.</summary>
+       PrintScreen,
+       /// <summary>The pause key.</summary>
+       Pause,
+       /// <summary>The num lock key.</summary>
+       NumLock,
+
+       // Special keys
+       /// <summary>The clear key (Keypad5 with NumLock disabled, on typical keyboards).</summary>
+       Clear,
+       /// <summary>The sleep key.</summary>
+       Sleep,
+       /*LogOff,
+       Help,
+       Undo,
+       Redo,
+       New,
+       Open,
+       Close,
+       Reply,
+       Forward,
+       Send,
+       Spell,
+       Save,
+       Calculator,
+
+       // Folders and applications
+       Documents,
+       Pictures,
+       Music,
+       MediaPlayer,
+       Mail,
+       Browser,
+       Messenger,
+
+       // Multimedia keys
+       Mute,
+       PlayPause,
+       Stop,
+       VolumeUp,
+       VolumeDown,
+       TrackPrevious,
+       TrackNext,*/
+
+       // Keypad keys
+       /// <summary>The keypad 0 key.</summary>
+       Keypad0,
+       /// <summary>The keypad 1 key.</summary>
+       Keypad1,
+       /// <summary>The keypad 2 key.</summary>
+       Keypad2,
+       /// <summary>The keypad 3 key.</summary>
+       Keypad3,
+       /// <summary>The keypad 4 key.</summary>
+       Keypad4,
+       /// <summary>The keypad 5 key.</summary>
+       Keypad5,
+       /// <summary>The keypad 6 key.</summary>
+       Keypad6,
+       /// <summary>The keypad 7 key.</summary>
+       Keypad7,
+       /// <summary>The keypad 8 key.</summary>
+       Keypad8,
+       /// <summary>The keypad 9 key.</summary>
+       Keypad9,
+       /// <summary>The keypad divide key.</summary>
+       KeypadDivide,
+       /// <summary>The keypad multiply key.</summary>
+       KeypadMultiply,
+       /// <summary>The keypad subtract key.</summary>
+       KeypadSubtract,
+       /// <summary>The keypad minus key (equivalent to KeypadSubtract).</summary>
+       KeypadMinus = KeypadSubtract,
+       /// <summary>The keypad add key.</summary>
+       KeypadAdd,
+       /// <summary>The keypad plus key (equivalent to KeypadAdd).</summary>
+       KeypadPlus = KeypadAdd,
+       /// <summary>The keypad decimal key.</summary>
+       KeypadDecimal,
+       /// <summary>The keypad period key (equivalent to KeypadDecimal).</summary>
+       KeypadPeriod = KeypadDecimal,
+       /// <summary>The keypad enter key.</summary>
+       KeypadEnter,
+
+       // Letters
+       /// <summary>The A key.</summary>
+       A,
+       /// <summary>The B key.</summary>
+       B,
+       /// <summary>The C key.</summary>
+       C,
+       /// <summary>The D key.</summary>
+       D,
+       /// <summary>The E key.</summary>
+       E,
+       /// <summary>The F key.</summary>
+       F,
+       /// <summary>The G key.</summary>
+       G,
+       /// <summary>The H key.</summary>
+       H,
+       /// <summary>The I key.</summary>
+       I,
+       /// <summary>The J key.</summary>
+       J,
+       /// <summary>The K key.</summary>
+       K,
+       /// <summary>The L key.</summary>
+       L,
+       /// <summary>The M key.</summary>
+       M,
+       /// <summary>The N key.</summary>
+       N,
+       /// <summary>The O key.</summary>
+       O,
+       /// <summary>The P key.</summary>
+       P,
+       /// <summary>The Q key.</summary>
+       Q,
+       /// <summary>The R key.</summary>
+       R,
+       /// <summary>The S key.</summary>
+       S,
+       /// <summary>The T key.</summary>
+       T,
+       /// <summary>The U key.</summary>
+       U,
+       /// <summary>The V key.</summary>
+       V,
+       /// <summary>The W key.</summary>
+       W,
+       /// <summary>The X key.</summary>
+       X,
+       /// <summary>The Y key.</summary>
+       Y,
+       /// <summary>The Z key.</summary>
+       Z,
+
+       // Numbers
+       /// <summary>The number 0 key.</summary>
+       Number0,
+       /// <summary>The number 1 key.</summary>
+       Number1,
+       /// <summary>The number 2 key.</summary>
+       Number2,
+       /// <summary>The number 3 key.</summary>
+       Number3,
+       /// <summary>The number 4 key.</summary>
+       Number4,
+       /// <summary>The number 5 key.</summary>
+       Number5,
+       /// <summary>The number 6 key.</summary>
+       Number6,
+       /// <summary>The number 7 key.</summary>
+       Number7,
+       /// <summary>The number 8 key.</summary>
+       Number8,
+       /// <summary>The number 9 key.</summary>
+       Number9,
+
+       // Symbols
+       /// <summary>The tilde key.</summary>
+       Tilde,
+       /// <summary>The grave key (equivaent to Tilde).</summary>
+       Grave = Tilde,
+       /// <summary>The minus key.</summary>
+       Minus,
+       //Equal,
+       /// <summary>The plus key.</summary>
+       Plus,
+       /// <summary>The left bracket key.</summary>
+       BracketLeft,
+       /// <summary>The left bracket key (equivalent to BracketLeft).</summary>
+       LBracket = BracketLeft,
+       /// <summary>The right bracket key.</summary>
+       BracketRight,
+       /// <summary>The right bracket key (equivalent to BracketRight).</summary>
+       RBracket = BracketRight,
+       /// <summary>The semicolon key.</summary>
+       Semicolon,
+       /// <summary>The quote key.</summary>
+       Quote,
+       /// <summary>The comma key.</summary>
+       Comma,
+       /// <summary>The period key.</summary>
+       Period,
+       /// <summary>The slash key.</summary>
+       Slash,
+       /// <summary>The backslash key.</summary>
+       BackSlash,
+       /// <summary>The secondary backslash key.</summary>
+       NonUSBackSlash,
+       /// <summary>Indicates the last available keyboard key.</summary>
+       LastKey
+    }
+}
\ No newline at end of file
diff --git a/src/Input/KeyModifiers.cs b/src/Input/KeyModifiers.cs
new file mode 100644 (file)
index 0000000..1314e73
--- /dev/null
@@ -0,0 +1,57 @@
+#region License
+//
+// HatPosition.cs
+//
+// Author:
+//       Stefanos A. <stapostol@gmail.com>
+//
+// Copyright (c) 2006-2014 Stefanos Apostolopoulos
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Crow
+{
+    /// <summary>
+    /// Enumerates modifier keys.
+    /// </summary>
+    [Flags]
+    public enum KeyModifiers : byte
+    {
+       /// <summary>
+       /// The alt key modifier (option on Mac).
+       /// </summary>
+       Alt = 1 << 0,
+
+       /// <summary>
+       /// The control key modifier.
+       /// </summary>
+       Control = 1 << 1,
+
+       /// <summary>
+       /// The shift key modifier.
+       /// </summary>
+       Shift = 1 << 2
+    }
+}
diff --git a/src/Input/KeyboardKeyEventArgs.cs b/src/Input/KeyboardKeyEventArgs.cs
new file mode 100644 (file)
index 0000000..bfe0deb
--- /dev/null
@@ -0,0 +1,168 @@
+#region License
+//
+// The Open Toolkit Library License
+//
+// Copyright (c) 2006 - 2009 the Open Toolkit library.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights to
+// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+// the Software, and to permit persons to whom the Software is furnished to do
+// so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Crow
+{
+    /// <summary>
+    /// Defines the event data for <see cref="KeyboardDevice"/> events.
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// Do not cache instances of this type outside their event handler.
+    /// If necessary, you can clone a KeyboardEventArgs instance using the
+    /// <see cref="KeyboardKeyEventArgs(KeyboardKeyEventArgs)"/> constructor.
+    /// </para>
+    /// </remarks>
+    public class KeyboardKeyEventArgs : EventArgs
+    {
+       #region Fields
+
+       Key key;
+       bool repeat;
+       KeyboardState state;
+
+       #endregion
+
+       #region Constructors
+
+       /// <summary>
+       /// Constructs a new KeyboardEventArgs instance.
+       /// </summary>
+               public KeyboardKeyEventArgs(Key _key, bool _repeat, KeyboardState _state)
+               {
+                       key = _key;
+                       repeat = _repeat;
+                       state = _state;
+               }
+
+       /// <summary>
+       /// Constructs a new KeyboardEventArgs instance.
+       /// </summary>
+       /// <param name="args">An existing KeyboardEventArgs instance to clone.</param>
+       public KeyboardKeyEventArgs(KeyboardKeyEventArgs args)
+       {
+           Key = args.Key;
+       }
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets the <see cref="Key"/> that generated this event.
+       /// </summary>
+       public Key Key
+       {
+           get { return key; }
+           internal set { key = value; }
+       }
+
+       /// <summary>
+       /// Gets the scancode which generated this event.
+       /// </summary>
+       [CLSCompliant(false)]
+       public uint ScanCode
+       {
+           get { return (uint)Key; }
+       }
+
+       /// <summary>
+       /// Gets a value indicating whether <see cref="OpenTK.Input.KeyModifiers.Alt"/> is pressed.
+       /// </summary>
+       /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
+       public bool Alt
+       {
+           get { return state[Key.AltLeft] || state[Key.AltRight]; }
+       }
+
+       /// <summary>
+       /// Gets a value indicating whether <see cref="OpenTK.Input.KeyModifiers.Control"/> is pressed.
+       /// </summary>
+       /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
+       public bool Control
+       {
+           get { return state[Key.ControlLeft] || state[Key.ControlRight]; }
+       }
+
+       /// <summary>
+       /// Gets a value indicating whether <see cref="OpenTK.Input.KeyModifiers.Shift"/> is pressed.
+       /// </summary>
+       /// <value><c>true</c> if pressed; otherwise, <c>false</c>.</value>
+       public bool Shift
+       {
+           get { return state[Key.ShiftLeft] || state[Key.ShiftRight]; }
+       }
+
+       /// <summary>
+       /// Gets a bitwise combination representing the <see cref="OpenTK.Input.KeyModifiers"/>
+       /// that are currently pressed.
+       /// </summary>
+       /// <value>The modifiers.</value>
+       public KeyModifiers Modifiers
+       {
+           get
+           {
+               KeyModifiers mods = 0;
+               mods |= Alt ? KeyModifiers.Alt : 0;
+               mods |= Control ? KeyModifiers.Control : 0;
+               mods |= Shift ? KeyModifiers.Shift : 0;
+               return mods;
+           }
+       }
+
+       /// <summary>
+       /// Gets the current <see cref="OpenTK.Input.KeyboardState"/>.
+       /// </summary>
+       /// <value>The keyboard.</value>
+       public KeyboardState Keyboard
+       {
+           get { return state; }
+           internal set { state = value; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether
+       /// this key event is a repeat.
+       /// </summary>
+       /// <value>
+       /// true, if this event was caused by the user holding down
+       /// a key; false, if this was caused by the user pressing a
+       /// key for the first time.
+       /// </value>
+       public bool IsRepeat
+       {
+           get { return repeat; }
+           internal set { repeat = value; }
+       }
+
+       #endregion
+    }
+}
diff --git a/src/Input/KeyboardState.cs b/src/Input/KeyboardState.cs
new file mode 100644 (file)
index 0000000..ba392ca
--- /dev/null
@@ -0,0 +1,316 @@
+ #region License
+ //
+ // The Open Toolkit Library License
+ //
+ // Copyright (c) 2006 - 2009 the Open Toolkit library.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights to
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ // the Software, and to permit persons to whom the Software is furnished to do
+ // so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in all
+ // copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ // OTHER DEALINGS IN THE SOFTWARE.
+ //
+ #endregion
+
+using System;
+using System.Collections.Specialized;
+using System.Text;
+
+namespace Crow
+{
+    /// <summary>
+    /// Encapsulates the state of a Keyboard device.
+    /// </summary>
+    public struct KeyboardState : IEquatable<KeyboardState>
+    {
+       #region Fields
+
+       // Allocate enough ints to store all keyboard keys
+       const int IntSize = sizeof(int);
+       const int NumInts = ((int)Key.LastKey + IntSize - 1) / IntSize;
+       // The following line triggers bogus CS0214 in gmcs 2.0.1, sigh...
+       unsafe fixed int Keys[NumInts];
+       bool is_connected;
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the specified
+       /// <see cref="OpenTK.Input.Key"/> is pressed.
+       /// </summary>
+       /// <param name="key">The <see cref="OpenTK.Input.Key"/> to check.</param>
+       /// <returns>True if key is pressed; false otherwise.</returns>
+       public bool this[Key key]
+       {
+           get { return IsKeyDown(key); }
+           internal set { SetKeyState(key, value); }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the specified
+       /// <see cref="OpenTK.Input.Key"/> is pressed.
+       /// </summary>
+       /// <param name="code">The scancode to check.</param>
+       /// <returns>True if code is pressed; false otherwise.</returns>
+       public bool this[short code]
+       {
+           get { return IsKeyDown((Key)code); }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this key is down.
+       /// </summary>
+       /// <param name="key">The <see cref="OpenTK.Input.Key"/> to check.</param>
+       public bool IsKeyDown(Key key)
+       {
+           return ReadBit((int)key);
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this scan code is down.
+       /// </summary>
+       /// <param name="code">The scan code to check.</param>
+       public bool IsKeyDown(short code)
+       {
+           return code >= 0 && code < (short)Key.LastKey && ReadBit(code);
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this key is up.
+       /// </summary>
+       /// <param name="key">The <see cref="OpenTK.Input.Key"/> to check.</param>
+       public bool IsKeyUp(Key key)
+       {
+           return !ReadBit((int)key);
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this scan code is down.
+       /// </summary>
+       /// <param name="code">The scan code to check.</param>
+       public bool IsKeyUp(short code)
+       {
+           return !IsKeyDown(code);
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this keyboard
+       /// is connected.
+       /// </summary>
+       public bool IsConnected
+       {
+           get { return is_connected; }
+           internal set { is_connected = value; }
+       }
+
+#if false
+       // Disabled until the correct cross-platform API can be determined.
+       public bool IsLedOn(KeyboardLeds led)
+       {
+           return false;
+       }
+
+       public bool IsLedOff(KeyboardLeds led)
+       {
+           return false;
+       }
+#endif
+
+       /// <summary>
+       /// Checks whether two <see cref="KeyboardState" /> instances are equal.
+       /// </summary>
+       /// <param name="left">
+       /// A <see cref="KeyboardState"/> instance.
+       /// </param>
+       /// <param name="right">
+       /// A <see cref="KeyboardState"/> instance.
+       /// </param>
+       /// <returns>
+       /// True if both left is equal to right; false otherwise.
+       /// </returns>
+       public static bool operator ==(KeyboardState left, KeyboardState right)
+       {
+           return left.Equals(right);
+       }
+
+       /// <summary>
+       /// Checks whether two <see cref="KeyboardState" /> instances are not equal.
+       /// </summary>
+       /// <param name="left">
+       /// A <see cref="KeyboardState"/> instance.
+       /// </param>
+       /// <param name="right">
+       /// A <see cref="KeyboardState"/> instance.
+       /// </param>
+       /// <returns>
+       /// True if both left is not equal to right; false otherwise.
+       /// </returns>
+       public static bool operator !=(KeyboardState left, KeyboardState right)
+       {
+           return !left.Equals(right);
+       }
+
+       /// <summary>
+       /// Compares to an object instance for equality.
+       /// </summary>
+       /// <param name="obj">
+       /// The <see cref="System.Object"/> to compare to.
+       /// </param>
+       /// <returns>
+       /// True if this instance is equal to obj; false otherwise.
+       /// </returns>
+       public override bool Equals(object obj)
+       {
+           if (obj is KeyboardState)
+           {
+               return this == (KeyboardState)obj;
+           }
+           else
+           {
+               return false;
+           }
+       }
+
+       /// <summary>
+       /// Generates a hashcode for the current instance.
+       /// </summary>
+       /// <returns>
+       /// A <see cref="System.Int32"/> represting the hashcode for this instance.
+       /// </returns>
+       public override int GetHashCode()
+       {
+           unsafe
+           {
+               fixed (int* k = Keys)
+               {
+                   int hashcode = 0;
+                   for (int i = 0; i < NumInts; i++)
+                       hashcode ^= (k + i)->GetHashCode();
+                   return hashcode;
+               }
+           }
+       }
+
+       #endregion
+
+       #region Internal Members
+
+       internal void SetKeyState(Key key, bool down)
+       {
+           if (down)
+           {
+               EnableBit((int)key);
+           }
+           else
+           {
+               DisableBit((int)key);
+           }
+       }
+
+       internal bool ReadBit(int offset)
+       {
+           ValidateOffset(offset);
+
+           int int_offset = offset / 32;
+           int bit_offset = offset % 32;
+           unsafe
+           {
+               fixed (int* k = Keys) { return (*(k + int_offset) & (1 << bit_offset)) != 0u; }
+           }
+       }
+
+       internal void EnableBit(int offset)
+       {
+           ValidateOffset(offset);
+
+           int int_offset = offset / 32;
+           int bit_offset = offset % 32;
+           unsafe
+           {
+               fixed (int* k = Keys) { *(k + int_offset) |= 1 << bit_offset; }
+           }
+       }
+
+       internal void DisableBit(int offset)
+       {
+           ValidateOffset(offset);
+
+           int int_offset = offset / 32;
+           int bit_offset = offset % 32;
+           unsafe
+           {
+               fixed (int* k = Keys) { *(k + int_offset) &= ~(1 << bit_offset); }
+           }
+       }
+
+       internal void MergeBits(KeyboardState other)
+       {
+           unsafe
+           {
+               int* k2 = other.Keys;
+               fixed (int* k1 = Keys)
+               {
+                   for (int i = 0; i < NumInts; i++)
+                       *(k1 + i) |= *(k2 + i);
+               }
+           }
+           IsConnected |= other.IsConnected;
+       }
+
+       internal void SetIsConnected(bool value)
+       {
+           IsConnected = value;
+       }
+
+       #endregion
+
+       #region Private Members
+
+       static void ValidateOffset(int offset)
+       {
+           if (offset < 0 || offset >= NumInts * IntSize)
+               throw new ArgumentOutOfRangeException();
+       }
+
+       #endregion
+
+       #region IEquatable<KeyboardState> Members
+
+       /// <summary>
+       /// Compares two KeyboardState instances.
+       /// </summary>
+       /// <param name="other">The instance to compare two.</param>
+       /// <returns>True, if both instances are equal; false otherwise.</returns>
+       public bool Equals(KeyboardState other)
+       {
+           bool equal = true;
+           unsafe
+           {
+               int* k2 = other.Keys;
+               fixed (int* k1 = Keys)
+               {
+                   for (int i = 0; equal && i < NumInts; i++)
+                       equal &= *(k1 + i) == *(k2 + i);
+               }
+           }
+           return equal;
+       }
+
+       #endregion
+    }
+}
diff --git a/src/Input/MouseButton.cs b/src/Input/MouseButton.cs
new file mode 100644 (file)
index 0000000..92be477
--- /dev/null
@@ -0,0 +1,92 @@
+ #region License
+ //
+ // The Open Toolkit Library License
+ //
+ // Copyright (c) 2006 - 2009 the Open Toolkit library.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights to
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ // the Software, and to permit persons to whom the Software is furnished to do
+ // so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in all
+ // copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ // OTHER DEALINGS IN THE SOFTWARE.
+ //
+ #endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Crow
+{
+    /// <summary>
+    /// Enumerates all possible mouse buttons.
+    /// </summary>
+    public enum MouseButton
+    {
+       /// <summary>
+       /// The left mouse button.
+       /// </summary>
+       Left = 0,
+       /// <summary>
+       /// The middle mouse button.
+       /// </summary>
+       Middle,
+       /// <summary>
+       /// The right mouse button.
+       /// </summary>
+       Right,
+       /// <summary>
+       /// The first extra mouse button.
+       /// </summary>
+       Button1,
+       /// <summary>
+       /// The second extra mouse button.
+       /// </summary>
+       Button2,
+       /// <summary>
+       /// The third extra mouse button.
+       /// </summary>
+       Button3,
+       /// <summary>
+       /// The fourth extra mouse button.
+       /// </summary>
+       Button4,
+       /// <summary>
+       /// The fifth extra mouse button.
+       /// </summary>
+       Button5,
+       /// <summary>
+       /// The sixth extra mouse button.
+       /// </summary>
+       Button6,
+       /// <summary>
+       /// The seventh extra mouse button.
+       /// </summary>
+       Button7,
+       /// <summary>
+       /// The eigth extra mouse button.
+       /// </summary>
+       Button8,
+       /// <summary>
+       /// The ninth extra mouse button.
+       /// </summary>
+       Button9,
+       /// <summary>
+       /// Indicates the last available mouse button.
+       /// </summary>
+       LastButton
+    }
+}
diff --git a/src/Input/MouseEventArgs.cs b/src/Input/MouseEventArgs.cs
new file mode 100644 (file)
index 0000000..758a5a6
--- /dev/null
@@ -0,0 +1,369 @@
+#region License
+//
+// MouseEventArgs.cs
+//
+// Author:
+//       Stefanos A. <stapostol@gmail.com>
+//
+// Copyright (c) 2006-2014 Stefanos Apostolopoulos
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+#endregion
+
+using System;
+#if !MINIMAL
+using System.Drawing;
+#endif
+
+namespace Crow
+{
+    /// <summary>
+    /// Defines the event data for <see cref="MouseDevice"/> events.
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// Do not cache instances of this type outside their event handler.
+    /// If necessary, you can clone an instance using the
+    /// <see cref="MouseEventArgs(MouseEventArgs)"/> constructor.
+    /// </para>
+    /// </remarks>
+    public class MouseEventArgs : EventArgs
+    {
+       #region Fields
+
+       MouseState state;
+
+       #endregion
+
+       #region Constructors
+
+       /// <summary>
+       /// Constructs a new instance.
+       /// </summary>
+       public MouseEventArgs()
+       {
+           state.SetIsConnected(true);
+       }
+
+       /// <summary>
+       /// Constructs a new instance.
+       /// </summary>
+       /// <param name="x">The X position.</param>
+       /// <param name="y">The Y position.</param>
+       public MouseEventArgs(int x, int y)
+           : this()
+       {
+           state.X = x;
+           state.Y = y;
+       }
+
+       /// <summary>
+       /// Constructs a new instance.
+       /// </summary>
+       /// <param name="args">The <see cref="MouseEventArgs"/> instance to clone.</param>
+       public MouseEventArgs(MouseEventArgs args)
+           : this(args.X, args.Y)
+       {
+       }
+
+       #endregion
+
+       #region Protected Members
+
+       internal void SetButton(MouseButton button, ButtonState state)
+       {
+           if (button < 0 || button > MouseButton.LastButton)
+               throw new ArgumentOutOfRangeException();
+
+           switch (state)
+           {
+               case ButtonState.Pressed:
+                   this.state.EnableBit((int)button);
+                   break;
+
+               case ButtonState.Released:
+                   this.state.DisableBit((int)button);
+                   break;
+           }
+       }
+
+       internal ButtonState GetButton(MouseButton button)
+       {
+           if (button < 0 || button > MouseButton.LastButton)
+               throw new ArgumentOutOfRangeException();
+
+           return
+               state.ReadBit((int)button) ?
+               ButtonState.Pressed : ButtonState.Released;
+       }
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets the X position of the mouse for the event.
+       /// </summary>
+       public int X { get { return state.X; } internal set { state.X = value; } }
+
+       /// <summary>
+       /// Gets the Y position of the mouse for the event.
+       /// </summary>
+       public int Y { get { return state.Y; } internal set { state.Y = value; } }
+
+       /// <summary>
+       /// Gets a <see cref="System.Drawing.Point"/> representing the location of the mouse for the event.
+       /// </summary>
+       public Point Position
+       {
+           get { return new Point(state.X, state.Y); }
+           set
+           {
+               X = value.X;
+               Y = value.Y;
+           }
+       }
+
+       /// <summary>
+       /// Gets the current <see cref="OpenTK.Input.MouseState"/>.
+       /// </summary>
+       public MouseState Mouse
+       {
+           get { return state; }
+           internal set { state = value; }
+       }
+
+       #endregion
+    }
+
+    /// <summary>
+    /// Defines the event data for <see cref="MouseDevice.Move"/> events.
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// Do not cache instances of this type outside their event handler.
+    /// If necessary, you can clone an instance using the
+    /// <see cref="MouseMoveEventArgs(MouseMoveEventArgs)"/> constructor.
+    /// </para>
+    /// </remarks>
+    public class MouseMoveEventArgs : MouseEventArgs
+    {
+       #region Fields
+
+       int x_delta, y_delta;
+
+       #endregion
+
+       #region Constructors
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseMoveEventArgs"/> instance.
+       /// </summary>
+       public MouseMoveEventArgs() { }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseMoveEventArgs"/> instance.
+       /// </summary>
+       /// <param name="x">The X position.</param>
+       /// <param name="y">The Y position.</param>
+       /// <param name="xDelta">The change in X position produced by this event.</param>
+       /// <param name="yDelta">The change in Y position produced by this event.</param>
+       public MouseMoveEventArgs(int x, int y, int xDelta, int yDelta)
+           : base(x, y)
+       {
+           XDelta = xDelta;
+           YDelta = yDelta;
+       }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseMoveEventArgs"/> instance.
+       /// </summary>
+       /// <param name="args">The <see cref="MouseMoveEventArgs"/> instance to clone.</param>
+       public MouseMoveEventArgs(MouseMoveEventArgs args)
+           : this(args.X, args.Y, args.XDelta, args.YDelta)
+       {
+       }
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets the change in X position produced by this event.
+       /// </summary>
+       public int XDelta { get { return x_delta; } internal set { x_delta = value; } }
+
+       /// <summary>
+       /// Gets the change in Y position produced by this event.
+       /// </summary>
+       public int YDelta { get { return y_delta; } internal set { y_delta = value; } }
+
+       #endregion
+    }
+
+    /// <summary>
+    /// Defines the event data for <see cref="MouseDevice.ButtonDown"/> and <see cref="MouseDevice.ButtonUp"/> events.
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// Do not cache instances of this type outside their event handler.
+    /// If necessary, you can clone an instance using the
+    /// <see cref="MouseButtonEventArgs(MouseButtonEventArgs)"/> constructor.
+    /// </para>
+    /// </remarks>
+    public class MouseButtonEventArgs : MouseEventArgs
+    {
+       #region Fields
+
+       MouseButton button;
+
+       #endregion
+
+       #region Constructors
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseButtonEventArgs"/> instance.
+       /// </summary>
+       public MouseButtonEventArgs() { }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseButtonEventArgs"/> instance.
+       /// </summary>
+       /// <param name="x">The X position.</param>
+       /// <param name="y">The Y position.</param>
+       /// <param name="button">The mouse button for the event.</param>
+       /// <param name="pressed">The current state of the button.</param>
+       public MouseButtonEventArgs(int x, int y, MouseButton button, bool pressed)
+           : base(x, y)
+       {
+           this.button = button;
+           this.IsPressed = pressed;
+       }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseButtonEventArgs"/> instance.
+       /// </summary>
+       /// <param name="args">The <see cref="MouseButtonEventArgs"/> instance to clone.</param>
+       public MouseButtonEventArgs(MouseButtonEventArgs args)
+           : this(args.X, args.Y, args.Button, args.IsPressed)
+       {
+       }
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets the <see cref="MouseButton"/> that triggered this event.
+       /// </summary>
+       public MouseButton Button { get { return button; } internal set { button = value; } }
+
+       /// <summary>
+       /// Gets a System.Boolean representing the state of the mouse button for the event.
+       /// </summary>
+       public bool IsPressed
+       {
+           get { return GetButton(Button) == ButtonState.Pressed; }
+           internal set { SetButton(Button, value ? ButtonState.Pressed : ButtonState.Released); }
+       }
+
+       #endregion
+    }
+
+    /// <summary>
+    /// Defines the event data for <see cref="MouseDevice.WheelChanged"/> events.
+    /// </summary>
+    /// <remarks>
+    /// <para>
+    /// Do not cache instances of this type outside their event handler.
+    /// If necessary, you can clone an instance using the
+    /// <see cref="MouseWheelEventArgs(MouseWheelEventArgs)"/> constructor.
+    /// </para>
+    /// </remarks>
+    public class MouseWheelEventArgs : MouseEventArgs
+    {
+       #region Fields
+
+       float delta;
+
+       #endregion
+
+       #region Constructors
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseWheelEventArgs"/> instance.
+       /// </summary>
+       public MouseWheelEventArgs() { }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseWheelEventArgs"/> instance.
+       /// </summary>
+       /// <param name="x">The X position.</param>
+       /// <param name="y">The Y position.</param>
+       /// <param name="value">The value of the wheel.</param>
+       /// <param name="delta">The change in value of the wheel for this event.</param>
+       public MouseWheelEventArgs(int x, int y, int value, int delta)
+           : base(x, y)
+       {
+           Mouse.SetScrollAbsolute(Mouse.Scroll.X, value);
+           this.delta = delta;
+       }
+
+       /// <summary>
+       /// Constructs a new <see cref="MouseWheelEventArgs"/> instance.
+       /// </summary>
+       /// <param name="args">The <see cref="MouseWheelEventArgs"/> instance to clone.</param>
+       public MouseWheelEventArgs(MouseWheelEventArgs args)
+           : this(args.X, args.Y, args.Value, args.Delta)
+       {
+       }
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets the value of the wheel in integer units.
+       /// To support high-precision mice, it is recommended to use <see cref="ValuePrecise"/> instead.
+       /// </summary>
+       public int Value { get { return (int)Math.Round(Mouse.Scroll.Y, MidpointRounding.AwayFromZero); } }
+
+       /// <summary>
+       /// Gets the change in value of the wheel for this event in integer units.
+       /// To support high-precision mice, it is recommended to use <see cref="DeltaPrecise"/> instead.
+       /// </summary>
+       public int Delta { get { return (int)Math.Round(delta, MidpointRounding.AwayFromZero); } }
+
+       /// <summary>
+       /// Gets the precise value of the wheel in floating-point units.
+       /// </summary>
+       public float ValuePrecise
+       {
+           get { return Mouse.Scroll.Y; }
+       }
+
+       /// <summary>
+       /// Gets the precise change in value of the wheel for this event in floating-point units.
+       /// </summary>
+       public float DeltaPrecise { get { return delta; } internal set { delta = value; } }
+
+       #endregion
+    }
+}
diff --git a/src/Input/MouseScroll.cs b/src/Input/MouseScroll.cs
new file mode 100644 (file)
index 0000000..a04e9d6
--- /dev/null
@@ -0,0 +1,118 @@
+#region License
+//
+// MouseWheel.cs
+//
+// Author:
+//       Stefanos A. <stapostol@gmail.com>
+//
+// Copyright (c) 2006-2014 Stefanos Apostolopoulos
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+#endregion
+
+using System;
+
+namespace Crow
+{
+    /// <summary>
+    /// Represents the state of a mouse wheel.
+    /// </summary>
+    public struct MouseScroll : IEquatable<MouseScroll>
+    {
+       #region Public Members
+
+       /// <summary>
+       /// Gets the absolute horizontal offset of the wheel,
+       /// or 0 if no horizontal scroll wheel exists.
+       /// </summary>
+       /// <value>The x.</value>
+       public float X { get; internal set; }
+
+       /// <summary>
+       /// Gets the absolute vertical offset of the wheel,
+       /// or 0 if no vertical scroll wheel exists.
+       /// </summary>
+       /// <value>The y.</value>
+       public float Y { get; internal set; }
+
+       /// <param name="left">A <see cref="MouseScroll"/> instance to test for equality.</param>
+       /// <param name="right">A <see cref="MouseScroll"/> instance to test for equality.</param>
+       public static bool operator ==(MouseScroll left, MouseScroll right)
+       {
+           return left.Equals(right);
+       }
+
+       /// <param name="left">A <see cref="MouseScroll"/> instance to test for inequality.</param>
+       /// <param name="right">A <see cref="MouseScroll"/> instance to test for inequality.</param>
+       public static bool operator !=(MouseScroll left, MouseScroll right)
+       {
+           return !left.Equals(right);
+       }
+
+       /// <summary>
+       /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseScroll"/>.
+       /// </summary>
+       /// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseScroll"/>.</returns>
+       public override string ToString()
+       {
+           return string.Format("[X={0:0.00}, Y={1:0.00}]", X, Y);
+       }
+
+       /// <summary>
+       /// Serves as a hash function for a <see cref="OpenTK.Input.MouseScroll"/> object.
+       /// </summary>
+       /// <returns>A hash code for this instance that is suitable for use in hashing algorithms and data structures such as a
+       /// hash table.</returns>
+       public override int GetHashCode()
+       {
+           return X.GetHashCode() ^ Y.GetHashCode();
+       }
+
+       /// <summary>
+       /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="OpenTK.Input.MouseScroll"/>.
+       /// </summary>
+       /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="OpenTK.Input.MouseScroll"/>.</param>
+       /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
+       /// <see cref="OpenTK.Input.MouseScroll"/>; otherwise, <c>false</c>.</returns>
+       public override bool Equals(object obj)
+       {
+           return
+               obj is MouseScroll &&
+               Equals((MouseScroll)obj);
+       }
+
+       #endregion
+
+       #region IEquatable Members
+
+       /// <summary>
+       /// Determines whether the specified <see cref="OpenTK.Input.MouseScroll"/> is equal to the current <see cref="OpenTK.Input.MouseScroll"/>.
+       /// </summary>
+       /// <param name="other">The <see cref="OpenTK.Input.MouseScroll"/> to compare with the current <see cref="OpenTK.Input.MouseScroll"/>.</param>
+       /// <returns><c>true</c> if the specified <see cref="OpenTK.Input.MouseScroll"/> is equal to the current
+       /// <see cref="OpenTK.Input.MouseScroll"/>; otherwise, <c>false</c>.</returns>
+       public bool Equals(MouseScroll other)
+       {
+           return X == other.X && Y == other.Y;
+       }
+
+       #endregion
+    }
+}
diff --git a/src/Input/MouseState.cs b/src/Input/MouseState.cs
new file mode 100644 (file)
index 0000000..c645062
--- /dev/null
@@ -0,0 +1,360 @@
+ #region License
+ //
+ // The Open Toolkit Library License
+ //
+ // Copyright (c) 2006 - 2009 the Open Toolkit library.
+ //
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
+ // of this software and associated documentation files (the "Software"), to deal
+ // in the Software without restriction, including without limitation the rights to
+ // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ // the Software, and to permit persons to whom the Software is furnished to do
+ // so, subject to the following conditions:
+ //
+ // The above copyright notice and this permission notice shall be included in all
+ // copies or substantial portions of the Software.
+ //
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ // OTHER DEALINGS IN THE SOFTWARE.
+ //
+ #endregion
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Crow
+{
+    /// <summary>
+    /// Encapsulates the state of a mouse device.
+    /// </summary>
+    public struct MouseState : IEquatable<MouseState>
+    {
+       #region Fields
+
+       internal const int MaxButtons = 16; // we are storing in an ushort
+       Point position;
+       MouseScroll scroll;
+       ushort buttons;
+       bool is_connected;
+
+       #endregion
+
+       #region Public Members
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the specified
+       /// <see cref="OpenTK.Input.MouseButton"/> is pressed.
+       /// </summary>
+       /// <param name="button">The <see cref="OpenTK.Input.MouseButton"/> to check.</param>
+       /// <returns>True if key is pressed; false otherwise.</returns>
+       public bool this[MouseButton button]
+       {
+           get { return IsButtonDown(button); }
+           internal set
+           {
+               if (value)
+                   EnableBit((int)button);
+               else
+                   DisableBit((int)button);
+           }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this button is down.
+       /// </summary>
+       /// <param name="button">The <see cref="OpenTK.Input.MouseButton"/> to check.</param>
+       public bool IsButtonDown(MouseButton button)
+       {
+           return ReadBit((int)button);
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether this button is up.
+       /// </summary>
+       /// <param name="button">The <see cref="OpenTK.Input.MouseButton"/> to check.</param>
+       public bool IsButtonUp(MouseButton button)
+       {
+           return !ReadBit((int)button);
+       }
+
+       /// <summary>
+       /// Gets the absolute wheel position in integer units.
+       /// To support high-precision mice, it is recommended to use <see cref="WheelPrecise"/> instead.
+       /// </summary>
+       public int Wheel
+       {
+           get { return (int)Math.Round(scroll.Y, MidpointRounding.AwayFromZero); }
+       }
+
+       /// <summary>
+       /// Gets the absolute wheel position in floating-point units.
+       /// </summary>
+       public float WheelPrecise
+       {
+           get { return scroll.Y; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="OpenTK.Input.MouseScroll"/> instance,
+       /// representing the current state of the mouse scroll wheel.
+       /// </summary>
+       public MouseScroll Scroll
+       {
+           get { return scroll; }
+       }
+
+       /// <summary>
+       /// Gets an integer representing the absolute x position of the pointer, in window pixel coordinates.
+       /// </summary>
+       public int X
+       {
+                       get { return position.X; }
+           internal set { position.X = value; }
+       }
+
+       /// <summary>
+       /// Gets an integer representing the absolute y position of the pointer, in window pixel coordinates.
+       /// </summary>
+       public int Y
+       {
+                       get { return position.Y; }
+           internal set { position.Y = value; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the left mouse button is pressed.
+       /// This property is intended for XNA compatibility.
+       /// </summary>
+       public ButtonState LeftButton
+       {
+           get { return IsButtonDown(MouseButton.Left) ? ButtonState.Pressed : ButtonState.Released; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the middle mouse button is pressed.
+       /// This property is intended for XNA compatibility.
+       /// </summary>
+       public ButtonState MiddleButton
+       {
+           get { return IsButtonDown(MouseButton.Middle) ? ButtonState.Pressed : ButtonState.Released; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the right mouse button is pressed.
+       /// This property is intended for XNA compatibility.
+       /// </summary>
+       public ButtonState RightButton
+       {
+           get { return IsButtonDown(MouseButton.Right) ? ButtonState.Pressed : ButtonState.Released; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the first extra mouse button is pressed.
+       /// This property is intended for XNA compatibility.
+       /// </summary>
+       public ButtonState XButton1
+       {
+           get { return IsButtonDown(MouseButton.Button1) ? ButtonState.Pressed : ButtonState.Released; }
+       }
+
+       /// <summary>
+       /// Gets a <see cref="System.Boolean"/> indicating whether the second extra mouse button is pressed.
+       /// This property is intended for XNA compatibility.
+       /// </summary>
+       public ButtonState XButton2
+       {
+           get { return IsButtonDown(MouseButton.Button2) ? ButtonState.Pressed : ButtonState.Released; }
+       }
+
+       /// <summary>
+       /// Gets the absolute wheel position in integer units. This property is intended for XNA compatibility.
+       /// To support high-precision mice, it is recommended to use <see cref="WheelPrecise"/> instead.
+       /// </summary>
+       public int ScrollWheelValue
+       {
+           get { return Wheel; }
+       }
+
+       /// <summary>
+       /// Gets a value indicating whether this instance is connected.
+       /// </summary>
+       /// <value><c>true</c> if this instance is connected; otherwise, <c>false</c>.</value>
+       public bool IsConnected
+       {
+           get { return is_connected; }
+           internal set { is_connected = value; }
+       }
+
+       /// <summary>
+       /// Checks whether two <see cref="MouseState" /> instances are equal.
+       /// </summary>
+       /// <param name="left">
+       /// A <see cref="MouseState"/> instance.
+       /// </param>
+       /// <param name="right">
+       /// A <see cref="MouseState"/> instance.
+       /// </param>
+       /// <returns>
+       /// True if both left is equal to right; false otherwise.
+       /// </returns>
+       public static bool operator ==(MouseState left, MouseState right)
+       {
+           return left.Equals(right);
+       }
+
+       /// <summary>
+       /// Checks whether two <see cref="MouseState" /> instances are not equal.
+       /// </summary>
+       /// <param name="left">
+       /// A <see cref="MouseState"/> instance.
+       /// </param>
+       /// <param name="right">
+       /// A <see cref="MouseState"/> instance.
+       /// </param>
+       /// <returns>
+       /// True if both left is not equal to right; false otherwise.
+       /// </returns>
+       public static bool operator !=(MouseState left, MouseState right)
+       {
+           return !left.Equals(right);
+       }
+
+       /// <summary>
+       /// Compares to an object instance for equality.
+       /// </summary>
+       /// <param name="obj">
+       /// The <see cref="System.Object"/> to compare to.
+       /// </param>
+       /// <returns>
+       /// True if this instance is equal to obj; false otherwise.
+       /// </returns>
+       public override bool Equals(object obj)
+       {
+           if (obj is MouseState)
+           {
+               return this == (MouseState)obj;
+           }
+           else
+           {
+               return false;
+           }
+       }
+
+       /// <summary>
+       /// Generates a hashcode for the current instance.
+       /// </summary>
+       /// <returns>
+       /// A <see cref="System.Int32"/> represting the hashcode for this instance.
+       /// </returns>
+       public override int GetHashCode()
+       {
+           return buttons.GetHashCode() ^ X.GetHashCode() ^ Y.GetHashCode() ^ scroll.GetHashCode();
+       }
+
+       /// <summary>
+       /// Returns a <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseState"/>.
+       /// </summary>
+       /// <returns>A <see cref="System.String"/> that represents the current <see cref="OpenTK.Input.MouseState"/>.</returns>
+       public override string ToString()
+       {
+           string b = Convert.ToString(buttons, 2).PadLeft(10, '0');
+           return String.Format("[X={0}, Y={1}, Scroll={2}, Buttons={3}, IsConnected={4}]",
+               X, Y, Scroll, b, IsConnected);
+       }
+
+       #endregion
+
+       #region Internal Members
+
+       internal Point Position
+       {
+           get { return position; }
+           set { position = value; }
+       }
+
+       internal bool ReadBit(int offset)
+       {
+           ValidateOffset(offset);
+           return (buttons & (1 << offset)) != 0;
+       }
+
+       internal void EnableBit(int offset)
+       {
+           ValidateOffset(offset);
+           buttons |= unchecked((ushort)(1 << offset));
+       }
+
+       internal void DisableBit(int offset)
+       {
+           ValidateOffset(offset);
+           buttons &= unchecked((ushort)(~(1 << offset)));
+       }
+
+       internal void MergeBits(MouseState other)
+       {
+           buttons |= other.buttons;
+           SetScrollRelative(other.scroll.X, other.scroll.Y);
+           X += other.X;
+           Y += other.Y;
+           IsConnected |= other.IsConnected;
+       }
+
+       internal void SetIsConnected(bool value)
+       {
+           IsConnected = value;
+       }
+
+       #region Internal Members
+
+       internal void SetScrollAbsolute(float x, float y)
+       {
+           scroll.X = x;
+           scroll.Y = y;
+       }
+
+       internal void SetScrollRelative(float x, float y)
+       {
+           scroll.X += x;
+           scroll.Y += y;
+       }
+
+       #endregion
+
+       #endregion
+
+       #region Private Members
+
+       static void ValidateOffset(int offset)
+       {
+           if (offset < 0 || offset >= 16)
+               throw new ArgumentOutOfRangeException("offset");
+       }
+
+       #endregion
+
+       #region IEquatable<MouseState> Members
+
+       /// <summary>
+       /// Compares two MouseState instances.
+       /// </summary>
+       /// <param name="other">The instance to compare two.</param>
+       /// <returns>True, if both instances are equal; false otherwise.</returns>
+       public bool Equals(MouseState other)
+       {
+           return
+               buttons == other.buttons &&
+               X == other.X &&
+               Y == other.Y &&
+               Scroll == other.Scroll;
+       }
+
+       #endregion
+    }
+}
index 17d9581f918938251a26af9bd15dc0903662ab65..c6f95ba360e5601e58fd615cfb02ba6aaf51f7f2 100644 (file)
@@ -28,7 +28,6 @@ using System.Xml;
 using Cairo;
 using OpenTK;
 using OpenTK.Graphics.OpenGL;
-using OpenTK.Input;
 
 namespace Crow
 {
@@ -179,11 +178,12 @@ namespace Crow
                }
                #region Events
                //those events are raised only if mouse isn't in a graphic object
-               public event EventHandler<MouseWheelEventArgs> MouseWheelChanged;
-               public event EventHandler<MouseButtonEventArgs> MouseButtonUp;
-               public event EventHandler<MouseButtonEventArgs> MouseButtonDown;
-               public event EventHandler<MouseButtonEventArgs> MouseClick;
-               public event EventHandler<MouseMoveEventArgs> MouseMove;
+               public event EventHandler<OpenTK.Input.MouseWheelEventArgs> MouseWheelChanged;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonUp;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseButtonDown;
+               public event EventHandler<OpenTK.Input.MouseButtonEventArgs> MouseClick;
+               public event EventHandler<OpenTK.Input.MouseMoveEventArgs> MouseMove;
+               public event EventHandler<OpenTK.Input.KeyboardKeyEventArgs> KeyboardKeyDown;
                #endregion
 
                #region graphic contexte
@@ -430,11 +430,11 @@ namespace Crow
         {
             base.OnLoad(e);
 
-                       Keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(Keyboard_KeyDown);
-                       Mouse.WheelChanged += new EventHandler<MouseWheelEventArgs>(Mouse_WheelChanged);
-                       Mouse.ButtonDown += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonDown);
-                       Mouse.ButtonUp += new EventHandler<MouseButtonEventArgs>(Mouse_ButtonUp);
-                       Mouse.Move += new EventHandler<MouseMoveEventArgs>(Mouse_Move);
+                       Keyboard.KeyDown += new EventHandler<OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyDown);
+                       Mouse.WheelChanged += new EventHandler<OpenTK.Input.MouseWheelEventArgs>(Mouse_WheelChanged);
+                       Mouse.ButtonDown += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonDown);
+                       Mouse.ButtonUp += new EventHandler<OpenTK.Input.MouseButtonEventArgs>(Mouse_ButtonUp);
+                       Mouse.Move += new EventHandler<OpenTK.Input.MouseMoveEventArgs>(Mouse_Move);
 
                        GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
 
@@ -457,8 +457,11 @@ namespace Crow
                #endregion
 
         #region Mouse Handling
-        void Mouse_Move(object sender, MouseMoveEventArgs e)
+
+               void Mouse_Move(object sender, OpenTK.Input.MouseMoveEventArgs otk_e)
         {
+                       MouseMoveEventArgs e = new MouseMoveEventArgs (otk_e.X, otk_e.Y, otk_e.XDelta, otk_e.YDelta);
+
                        if (_activeWidget != null) {
                                //first, ensure object is still in the graphic tree
                                if (_activeWidget.HostContainer == null) {
@@ -525,12 +528,14 @@ namespace Crow
                                }
                        }
                        hoverWidget = null;
-                       MouseMove.Raise (this, e);
+                       MouseMove.Raise (this, otk_e);
         }
-        void Mouse_ButtonUp(object sender, MouseButtonEventArgs e)
+               void Mouse_ButtonUp(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
         {
+                       MouseButtonEventArgs e = new MouseButtonEventArgs (otk_e.X, otk_e.Y, (Crow.MouseButton)otk_e.Button, otk_e.IsPressed);
+
                        if (_activeWidget == null) {
-                               MouseButtonUp.Raise (this, e);
+                               MouseButtonUp.Raise (this, otk_e);
                                return;
                        }
                                
@@ -543,10 +548,12 @@ namespace Crow
                        _activeWidget.onMouseUp (this, e);
                        activeWidget = null;
         }
-        void Mouse_ButtonDown(object sender, MouseButtonEventArgs e)
-        {
+               void Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs otk_e)
+               {
+                       MouseButtonEventArgs e = new MouseButtonEventArgs (otk_e.X, otk_e.Y, (Crow.MouseButton)otk_e.Button, otk_e.IsPressed);
+
                        if (hoverWidget == null) {
-                               MouseButtonDown.Raise (this, e);
+                               MouseButtonDown.Raise (this, otk_e);
                                return;
                        }
 
@@ -559,10 +566,12 @@ namespace Crow
                        mouseRepeatThread = new Thread (mouseRepeatThreadFunc);
                        mouseRepeatThread.Start ();
         }
-        void Mouse_WheelChanged(object sender, MouseWheelEventArgs e)
+               void Mouse_WheelChanged(object sender, OpenTK.Input.MouseWheelEventArgs otk_e)
         {
+                       MouseWheelEventArgs e = new MouseWheelEventArgs (otk_e.X, otk_e.Y, otk_e.Value, otk_e.Delta);
+
                        if (hoverWidget == null) {
-                               MouseWheelChanged.Raise (this, e);
+                               MouseWheelChanged.Raise (this, otk_e);
                                return;
                        }
                        hoverWidget.onMouseWheel (this, e);
@@ -584,10 +593,15 @@ namespace Crow
                #endregion
 
         #region keyboard Handling
-        void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e)
-        {                      
-                       if (_focusedWidget == null)
-                               return;
+               KeyboardState Keyboad = new KeyboardState ();
+               void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs otk_e)
+       {
+//                     if (_focusedWidget == null) {
+                               KeyboardKeyDown.Raise (this, otk_e);
+//                             return;
+//                     }
+                       Keyboad.SetKeyState ((Crow.Key)otk_e.Key, true);
+                       KeyboardKeyEventArgs e = new KeyboardKeyEventArgs((Crow.Key)otk_e.Key, otk_e.IsRepeat,Keyboad);
                        _focusedWidget.onKeyDown (sender, e);
         }
         #endregion