Scroll Wheel support?

Monkey Forums/Monkey Beginners/Scroll Wheel support?

Jello Fox(Posted March) [#1]
Where is the code concerning scroll wheels? How do I make use of them?

Soap(Posted March) [#2]

Goodlookinguy(Posted March) [#3]
Look at this:
My current code is this:

I haven't updated for GLFW 3 because it uses callbacks and I have to change a handful of things to make it play nice.

Based on this:
typedef void(* GLFWscrollfun)(GLFWwindow *, double, double)

I'd have to do something like this or something. (By the way, I think it was supposed to be GLFW scroll func, but someone forgot the c)

class MojoHacks
    static GLFWscrollfun ScrollCallback(GLFWwindow *window, double xOffset, double yOffset)
            // or something

    static GLFWscrollfun s_scrollCallback;

GLFWscrollfun MojoHacks::s_scrollCallback = MojoHacks::ScrollCallback;

Edit: Or if I bothered to click that "glfwSetScrollCallback" link, I'd discover this...
GLFWscrollfun glfwSetScrollCallback( GLFWwindow *window, GLFWscrollfun cbfun )

I'd need to know where in the native Mojo code to get the GLFWwindow from, then do something like this...
class MojoHacks
    static void BeginMouseWheelUpdate()
        glfwSetScrollCallback(windowFromBBSomething, MojoHacks::ScrollCallback);
    static GLFWscrollfun ScrollCallback(GLFWwindow *window, double xOffset, double yOffset)
            // do stuff

Nobuyuki(Posted March) [#4]
My code doesn't work on GLFW3 either, sorry. Anyone willing to deal with the event callback stuff and proper externs feel free to do so.

Shinkiro1(Posted March) [#5]
This is my code for glfw3. Unfortunately it's non trivial:

GLFWwindow* getWindow() {
  return BBGlfwGame::GlfwGame()->GetGLFWwindow();

class MouseWheelInfo {
  Float x;
  Float y;
  MouseWheelInfo() : x(0.0), y(0.0) {}
MouseWheelInfo* wheelInfo;

void scrollwheelCallback(GLFWwindow* window, double xoffset, double yoffset) {
  wheelInfo->x = Float(xoffset);
  wheelInfo->y = Float(yoffset);

void NativeInit() {
  GLFWwindow* window = getWindow();
  glfwSetScrollCallback(window, &scrollwheelCallback);
  wheelInfo = new MouseWheelInfo();

Float MouseZUnsafe() {
  if (wheelInfo != 0) {
    float z = wheelInfo->y;
    wheelInfo->y = 0.0;
    return z;
  return 0.0;

#If TARGET = "glfw"
	Import "native.cpp"

	Function NativeInit:Void() = "NativeInit"
	Function MouseZUnsafe:Float() = "MouseZUnsafe"


Then in your monkey code import native.monkey and set MouseZUnsafe to a variable each frame!
You then use this variable for your game code.
Calling MouseZUnsafe more than once per frame will mess it up.