1
\$\begingroup\$

How to use Input in OpenTK 1.0? There is not much info around, some classes are unfinished.

What I want to achieve, is to be able to use input not only in OnUpdate function, but also in other classes created by myself.

\$\endgroup\$
  • 2
    \$\begingroup\$ This might not answer your specific question but take a look at MonoGame monogame.codeplex.com an open source project that uses OpenTK under the hood. You can probably look at the source code as a reference. \$\endgroup\$ – craftworkgames Nov 23 '12 at 4:21
2
\$\begingroup\$

Check out OpenTK.Input.

From there you can get access to OpenTK.Input.Mouse and

Some examples from the page include:

To check whether a button is pressed:

using OpenTK.Input;

var mouse = Mouse.GetState();
if (mouse[MouseButton.Left])
{
    // Left mouse button is pressed
}

To check whether a mouse button is not pressed:

using OpenTK.Input;`

var mouse = Mouse.GetState();
if (!mouse[MouseButton.Left])
{
    // Left mouse button is not pressed
}
\$\endgroup\$
  • 1
    \$\begingroup\$ Note that the above is for 1.1, which is available through the SVN repository. As far as I know, OpenTK 1.0 doesn't have support for this. \$\endgroup\$ – MichaelHouse Sep 20 '13 at 22:14
  • \$\begingroup\$ As a side note, mouse does not work with 1.1 build on windows 7/8. There is patched version on github, which is currently the main repo for OpenTK: github.com/thefiddler/opentk More info about the issue: opentk.com/node/3198 \$\endgroup\$ – Lasse Oct 20 '13 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.