From 8eb779558ca3ba6587c46741a76b5ed7d96531b8 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Mon, 15 Oct 2007 11:02:14 +0000 Subject: [PATCH] Disabled support for multiple devices to minimize memory and CPU usage. --- Source/OpenTK/Platform/Windows/WinRawKeyboard.cs | 14 +++++++++----- Source/OpenTK/Platform/Windows/WinRawMouse.cs | 12 +++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs index 09d18742..bf4c607d 100644 --- a/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs +++ b/Source/OpenTK/Platform/Windows/WinRawKeyboard.cs @@ -284,11 +284,15 @@ namespace OpenTK.Platform.Windows // came not from a physical keyboard device but from a code-generated input message - in // that case, the event goes to the default (first) keyboard. // TODO: Send the event to all keyboards instead of the default one. - int index = keyboards.FindIndex(delegate(KeyboardDevice kb) - { - return kb.DeviceID == rin.Header.Device; - }); - if (index == -1) index = 0; + // TODO: Optimize this! The predicate allocates way to much memory. + //int index = keyboards.FindIndex(delegate(KeyboardDevice kb) + //{ + // return kb.DeviceID == rin.Header.Device; + //}); + //if (index == -1) index = 0; + int index; + if (keyboards.Count > 0) index = 0; + else return false; // Generic control, shift, alt keys may be sent instead of left/right. // It seems you have to explicitly register left/right events. diff --git a/Source/OpenTK/Platform/Windows/WinRawMouse.cs b/Source/OpenTK/Platform/Windows/WinRawMouse.cs index 1d65b68c..9e4f40a5 100644 --- a/Source/OpenTK/Platform/Windows/WinRawMouse.cs +++ b/Source/OpenTK/Platform/Windows/WinRawMouse.cs @@ -167,11 +167,13 @@ namespace OpenTK.Platform.Windows /// internal bool ProcessEvent(RawInput rin) { - MouseDevice mouse = mice.Find(delegate(MouseDevice m) - { - return m.DeviceID == rin.Header.Device; - }); - if (mouse == null && mice.Count > 0) mouse = mice[0]; + //MouseDevice mouse = mice.Find(delegate(MouseDevice m) + //{ + // return m.DeviceID == rin.Header.Device; + //}); + MouseDevice mouse; + if (mice.Count > 0) mouse = mice[0]; + else return false; switch (rin.Header.Type) {