andykorth / opentk

The Open Toolkit is a low-level C# library that wraps OpenGL, OpenCL and OpenAL. This fork has been superseded by https://github.com/thefiddler/opentk Please direct your attention to that official repository.
71 stars 27 forks source link

Keyboard.GetState() dies a horrible death through access violation #13

Closed nattthebear closed 11 years ago

nattthebear commented 11 years ago

In KeyboardState.cs, internal void MergeBits():

Codes has type int[256]. This iteration is just plain wrong:

int* c2 = other.Codes;
fixed (int* c1 = Codes)
{
    for (int i = 0; i < short.MaxValue; i++)
        *(c1 + i) |= *(c2 + i);
}
andykorth commented 11 years ago

Yep, that looks pretty crazy to me.

andykorth commented 11 years ago

I've made a quick fix in f38e71760161a5ac9257f3e23f79d4100583de50.

Paging @artfunkel, in case he has any comments on this. (does that send automatic notifications?)

Artfunkel commented 11 years ago

Yes it does! Definitely a mistake on my part, I meant to use byte.MaxValue. Your fix is much better though.

andykorth commented 11 years ago

Okay, I'll call this one wrapped up!