Implemented SetMouse() ?

Paul59

New member
CX Code Contributor
Joined
Dec 13, 2018
Messages
375
I seem to recall a SetMouse() function in Blitz Basic (or maybe B3d?) - if there's not such a function in CX (and I can't find it if there is!) it could be useful for the desktop target.
 

TheMrCerebro

Member
Tutorial Author
Joined
Apr 7, 2018
Messages
18
It would be very easy to add such a function, it is in glfw3.h.
JavaScript:
GLFWAPI void glfwSetCursorPos(GLFWwindow* window, double xpos, double ypos);

In "targets/glfw3/modules/native/glfwgame.cpp"
Add:
JavaScript:
in ...class BBGlfwGame : public BBGame{...

virtual void SetMousePosition( float xpos, float ypos );

...private:...
and this:

JavaScript:
...}...

void BBGlfwGame::SetMousePosition( float xpos, float ypos ){
        glfwSetCursorPos( _window, xpos, ypos);
}

...String BBGlfwGame::PathToFilePath( String path ){...

in "modules/mojo/app.cxs"
Add:
JavaScript:
..End...

Function SetMouse:Void(x:Float,y:float)
    _game.SetMousePosition(x,y)
End

...Function DeviceWidth:Int()...

in "modules/brl/native/gametarget.cpp"
Add:
JavaScript:
in ...class BBGame{...

virtual void SetMousePosition(float x,float y);

...};...
and this:
JavaScript:
...}...

void BBGame::SetMousePosition(float x,float y){
}

...//***** C++ Game *****...

In "modules/brl/gametarget.cxs"
Add:
JavaScript:
in ...Class BBGame Extends Null...

Method SetMousePosition:Void(x:Float,y:float)

...End...

Copy and paste only the functions, what is in "..." no.
I've tried it and it works, but as always something will be forgotten :p
 
Top Bottom