Yes, sorry, just looked up the names in Kore.
-
hiding the mouse
@robert when I look at the definition:
/**-
Hides the system cursor (without locking)
*/
public function hideSystemCursor(): Void {}
/**
-
Show the system cursor
*/
public function showSystemCursor(): Void {}
they are empty? this is also true of Mouse.get().lock() and Mouse.get().unlock().
-
-
hiding the mouse
@robert Well the commands work if I compile as linux native but not with HTML5 target or krom. Is that the way it is supposed to be?
-
hiding the mouse
I don't think lock/unlock by themselves are supposed to hide the cursor. There's a separate function for that after all. --debug should create debug symbols but I'm not sure I already implemented that for Linux. But if you omit the --compile switch you can just open the Code::Blocks project or the Clion project or the makefile created in the build dir.
-
hiding the mouse
@robert um... yeah, you are correct if I use both like this:
if (hasMouse == false)
{
var mouse = Mouse.get();
mouse.lock();
mouse.hideSystemCursor();
hasMouse = true;
}
else if (hasMouse == true)
{
var mouse = Mouse.get();
mouse.unlock();
mouse.showSystemCursor();
hasMouse = false;
}
compiling for linux mouse re-centring works. For Krom neither does the mouse hide nor the re-centring. HTML5 the mouse hiding works but not the re-centring. This is using the master branch of Kha, which perhaps I shouldn't be using. also perhaps I am missing some sub repositories? not sure...| last edited by vivichrist Reputation: 0 | Posts: 30 -
hiding the mouse
Debug the html5 build. Linux build was fine I thought? For Krom you should wait for the next version anyway because that is changing a lot these days.
Just in general though - Kha is explicitly not about fleeing from "horrible languages", it's about very much the opposite: easy introspection and learning how things work. -
hiding the mouse
So I go through and get to the show(bool) function
void Mouse::show(bool truth) { #ifdef KORE_OPENGL ::Display* dpy = XOpenDisplay(0); ::Window win = (XID)Window::get(0)->_data.handle; if (truth) { XUndefineCursor(dpy, win); } else { XColor col; char data[1] = {0}; Pixmap blank = XCreateBitmapFromData(dpy, win, data, 1, 1); Cursor cursor = XCreatePixmapCursor(dpy, blank, blank, &col, &col, 0, 0); XFreePixmap(dpy, blank); XDefineCursor(dpy, win, cursor); } #endif }
which takes the else branch for false.
-
hiding the mouse
Stepping through the code with the debugger there are no exceptions or errors thrown or reported. It looks ok, it follows logically, that is, its just creating a blank cursor to replace the system defined one, though nothing in the docs says anything about the dimensions of the cursor. I looked at the docs for X11 and this would be the way to do it. I need to learn more about how to compile haxe/Kha. But the reason I am hating on C++ so much is that I did a third year paper where we (the students) were expected to learn C++ and OpenGL/GLSL then create a rendering pipeline. that was a lot of work to get... Parallax Occlusion Mapping, Ambient Occlusion, Bloom and Depth of Field all happening between us (a group of three). Most of the others were sticking with OpenGL 2.0 where as I decided to go with 3.3 (which, at the time Intel had just updated their drivers on linux). My experience of C++ is one of flakey brittle code that is very hard to think or reason about, so many corner cases, exceptions and weird limits etc. (same with C in my opinion) I like Kha for it's concise simplicity and nicely defined abstraction that still appeals to my understanding of OpenGL and shaders but without all the crazy house keeping and menial tasks. The design of the API is just what I was looking for in a graphics engine. I much more like to just program shaders. Also I would be quite interested in developing a shader language of my own.
But having said all this I will try to make a small program that tests the above code snippet as a kind of unit test. -
hiding the mouse
Kha is nice to keep away from C++ and OpenGL most of the time but being able to debug things is super helpful because as much as I'd like it to - Kha is not yet perfect. Getting closer every day though. Also sometimes I just can't reproduce things and are dependent on a little help - on Linux in particular where every system is a little different and drivers are sometimes horrible.
So, back to the problem at hand - the code seems to be alright but it does not hide the cursor? Or it sometimes hides the cursor? I'm completely confused by now about what works in what circumstances on your vaguely defined Linux system. -
hiding the mouse
Doesn't hide the mouse cursor when compiling to native code i.e the "Kha: Build for Linux". I am currently trying to work with this code and see if it can work. Also debugging this will be a bit easier than having to deal with all of the generated HaXe C++.
#include <iostream> #include <X11/X.h> #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/Xutil.h> #include <X11/Xos.h> #include <string> #include <iostream> Window window; void show(); int main() { Display *display; XEvent e; std::string msg = "Hello, World!"; int screen; display = XOpenDisplay(nullptr); if (display == nullptr) { std::cerr << "Cannot open display\n"; throw; } screen = XDefaultScreen(display); window = XCreateSimpleWindow(display, RootWindow(display, screen), 10, 10, 500, 500, 1, BlackPixel(display, screen), WhitePixel(display, screen)); XStoreName(display, window, "Silly Window"); XSelectInput(display, window, ExposureMask | KeyPressMask ); XMapWindow(display, window); while (true) { XNextEvent(display, &e); if (e.type == Expose) { std::cout << "Window Exposed!\n"; XExposeEvent ev = e.xexpose; if (ev.window != window) continue; XFillRectangle(display, window, DefaultGC(display, screen), 50, 50, 400, 50); XDrawString(display, window, DefaultGC(display, screen), 220, 220, msg.c_str(), msg.length()); XFillRectangle(display, window, DefaultGC(display, screen), 50, 400, 400, 50); } else if (e.type == KeyPress) { char buf[128] = {0}; KeySym keysym; int len = XLookupString(&e.xkey, buf, sizeof buf, &keysym, NULL); if (keysym == XK_Escape) { break; } else if (keysym == XK_space) { show(); XAllowEvents(display, SyncBoth, CurrentTime); } } } XDestroyWindow(display, window); XCloseDisplay(display); return 0; } bool toggle = false; void show() { Display* dpy = XOpenDisplay(0); if (toggle) { std::cout << "toggle On\n"; XUndefineCursor(dpy, window); } else { std::cout << "toggle Off\n"; XColor col; char data[1] = {0X00}; Pixmap blank = XCreateBitmapFromData(dpy, window, data, 1, 1); Cursor cursor = XCreatePixmapCursor(dpy, blank, blank, &col, &col, 0, 0); XDefineCursor(dpy, window, cursor); XSetWindowAttributes wa; XChangeWindowAttributes(dpy, window, CWCursor, &wa); wa.cursor = cursor; XFreePixmap(dpy, blank); } toggle = !toggle; }
Note: Updated code
| last edited by vivichrist Reputation: 0 | Posts: 30 -
hiding the mouse
I tried a few different things but mouse cursor under Gnome is flakey as. I remember there was a space of about a couple of years where changing you mouse cursor in Debian based distros was not possible without writing it to /user/share/...something (required admin privileges). X11 is a mess of bung.