• Hello everyone,

    We're happy to announce that our forum is back online! We needed to take some time off to discuss and decide on how to handle sensitive topics in our community.

    The team has posted an in-depth comment regarding a recent incident and our stance on politics and sexuality in our forum. We also added a dedicated paragraph about this in the forum guidelines. This is part of our commitment to maintain a welcoming and inclusive environment for all our users. Your understanding and continued support in building a creative and respectful community are highly appreciated.

    Thank you, the CX Dev-Team

Implemented SetMouse() ?

Paul59

Active member
CX Code Contributor
Joined
Dec 13, 2018
Messages
384
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.
 
No there isn't right now ;)
 
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
 
Before you posted that, i had this already put into my local dev version. It will be called SetMousePos.
 
Its on Github now.
 
Back
Top Bottom