Null and Void

Members
  • Content count

    6733
  • Joined

  • Last visited

Community Reputation

1088 Excellent

About Null and Void

  • Rank
    Contributor
  1. glfw "undefined reference to glfwInit"

    "Undefined reference to" is an error from the linker. How are you compiling or linking the program? If you're doing it by hand on the command line or in your own Makefile, do you have "-lglfw" (dash, lower case "L", "glfw") somewhere in there?
  2. Booting Custom Linux Distro

    You're trying to create your own Linux "live CD". While I can't offer a whole lot of hands-on tutelage, there are many scripts and tutorials to help you do this. Through [url="http://www.google.com/search?q=linux+live+cd+creator"]Google[/url] I come up with a couple dozen useful links.
  3. FMV playback

    Perhaps ffmpeg's [url="http://www.inb.uni-luebeck.de/%7Eboehme/using_libavcodec.html"]libavformat and libavcodec[/url] would work?
  4. Handle Multiple Keypress Events With Xwindows

    If you just care about which keys are currently pressed and released, an auto-repeat release will be immediately followed by a press. So, we'll just store which keys are pressed and released: [code] #include <stdio.h> #include <X11/Xlib.h> #include <X11/keysym.h> int keysym_to_arrow_key(KeySym keysym) { switch(keysym) { case XK_Up: return 0; case XK_Down: return 1; case XK_Left: return 2; case XK_Right: return 3; } return -1; } int main(void) { Display *display; Window window; int arrow_keys[4] = { 0, 0, 0, 0 }; display = XOpenDisplay(NULL); window = XCreateSimpleWindow(display, RootWindow(display, 0), 100, 100, 100, 100, 0, BlackPixel(display, 0), BlackPixel(display, 0)); XSelectInput(display, window, KeyPressMask | KeyReleaseMask); XMapWindow(display, window); XFlush(display); for(; { /* Event loop */ while(XPending(display) > 0) { XEvent event; XNextEvent(display, &event); switch(event.type) { case KeyPress: { KeySym keysym = XLookupKeysym(&event.xkey, 0); int arrow_key = keysym_to_arrow_key(keysym); /* Is this a key we care about? All we're caring about now are the arrow keys. */ if(arrow_key != -1) arrow_keys[arrow_key] = 1; } break; case KeyRelease: { KeySym keysym = XLookupKeysym(&event.xkey, 0); int arrow_key = keysym_to_arrow_key(keysym); /* Is this a key we care about? All we're caring about now are the arrow keys. */ if(arrow_key != -1) arrow_keys[arrow_key] = 0; } break; } } /* Do stuff */ printf("%d%d%d%d\n", arrow_keys[0], arrow_keys[1], arrow_keys[2], arrow_keys[3]); } return 0; } [/code] If you do need auto-repeating keys, it gets a little more complicated: [code] #include <stdio.h> #include <time.h> #include <X11/Xlib.h> #include <X11/keysym.h> unsigned long get_time_milliseconds(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec*1000 + ts.tv_nsec/1000000; } int keysym_to_arrow_key(KeySym keysym) { switch(keysym) { case XK_Up: return 0; case XK_Down: return 1; case XK_Left: return 2; case XK_Right: return 3; } return -1; } int main(void) { unsigned int a; Display *display; Window window; struct { int pressed; int pressed_count; unsigned long press_time; unsigned long repeat_interval; } arrow_keys[4] = { { 0, 0, 0, 0 }, }; display = XOpenDisplay(NULL); window = XCreateSimpleWindow(display, RootWindow(display, 0), 100, 100, 100, 100, 0, BlackPixel(display, 0), BlackPixel(display, 0)); XSelectInput(display, window, KeyPressMask | KeyReleaseMask); XMapWindow(display, window); XFlush(display); /* Setup an automatic repeat interval */ arrow_keys[0].repeat_interval = arrow_keys[1].repeat_interval = arrow_keys[2].repeat_interval = arrow_keys[3].repeat_interval = 250; /* milliseconds */ for(; { unsigned long currenttime = get_time_milliseconds(); /* Event loop */ while(XPending(display) > 0) { XEvent event; XNextEvent(display, &event); switch(event.type) { case KeyPress: { KeySym keysym = XLookupKeysym(&event.xkey, 0); int arrow_key = keysym_to_arrow_key(keysym); /* Is this a key we care about? All we're caring about now are the arrow keys. */ if(arrow_key != -1) { arrow_keys[arrow_key].pressed = 1; arrow_keys[arrow_key].pressed_count += 1; arrow_keys[arrow_key].press_time = currenttime; } } break; case KeyRelease: { KeySym keysym = XLookupKeysym(&event.xkey, 0); int arrow_key = keysym_to_arrow_key(keysym); /* Is this a key we care about? All we're caring about now are the arrow keys. */ if(arrow_key != -1) { XEvent next_event; /* Check if this is an auto-repeat by seeing if the next event is a KeyPress at the exact same time. */ if(XPending(display) > 0 && XPeekEvent(display, &next_event) && next_event.type == KeyPress && next_event.xkey.time == event.xkey.time && next_event.xkey.keycode == event.xkey.keycode) { /* It's an auto-repeat, eat the event */ XNextEvent(display, &next_event); } else if(arrow_keys[arrow_key].pressed) { /* Okay, it's not auto-repeat. */ unsigned int presses = (currenttime - arrow_keys[arrow_key].press_time)/arrow_keys[arrow_key].repeat_interval; arrow_keys[arrow_key].pressed = 0; arrow_keys[arrow_key].pressed_count += presses; } } } break; } } /* Manual event loop checking for auto-repeat */ { for(a = 0; a < sizeof(arrow_keys)/sizeof(arrow_keys[0]); ++a) { if(arrow_keys[a].pressed) { unsigned int presses = (currenttime - arrow_keys[a].press_time)/arrow_keys[a].repeat_interval; arrow_keys[a].pressed_count += presses; arrow_keys[a].press_time += presses * arrow_keys[a].repeat_interval; } } } /* Do stuff */ { const char *state[] = { "pressed", "released" }; const char *names[] = { "up", "down", "left", "right" }; /* Report and deregister key presses */ for(a = 0; a < sizeof(arrow_keys)/sizeof(arrow_keys[0]); ++a) { while(arrow_keys[a].pressed_count > 0) { printf("%s pressed.\n", names[a]); arrow_keys[a].pressed_count -= 1; } } /* Disabled due to flood of text without any sort of delay */ if(0) { /* Report key state */ for(a = 0; a < sizeof(arrow_keys)/sizeof(arrow_keys[0]); ++a) printf("%5s is %8s. ", names[a], state[!arrow_keys[a].pressed]); putc('\n', stdout); } } } return 0; } [/code] I'm hardly Mr. Xlib-expert, so there may be easier ways to accomplish this. At least it will keep you from having to disable auto-repeat for the entire display.
  5. Handle Multiple Keypress Events With Xwindows

    Are you relying on the key to auto-repeat their press and release events? You may want to disable auto-repeat on at least the arrow keys, store their pressed/released state on your own, and generate your own repeat behavior based on your stored state. By the way, if you're curious to see what events are being generated quickly and easily, run a program named "xev". It's a window that reports the events it's receiving into the terminal.
  6. Runtime TLS initialization when using clone()

    If I'm not mistaken, to have __thread work properly with clone you must use the flag CLONE_SETTLS and setup a thread local storage descriptor to pass as the sixth argument to clone. As far as I am aware this will be kernel/architecture specific. That all said, I've never done this myself. This is all done for you if you use pthreads.
  7. checking Mouse Click in the Linux without events

    Something like this in Xlib (although, avoiding events is hardly the proper "X" way): Display *display; Window window; bool Mouse::isKeyDown(int key) const { const unsigned int masks[5] = { Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask }; Window root, child; int root_x, root_y, child_x, child_y; unsigned int mask; if(key < 0 || key >= sizeof(masks)/sizeof(masks[0])) return false; XQueryPointer(display, window, &root, &child, &root_x, &root_y, &child_x, &child_y, &mask); return ((mask & masks[key]) > 0); }
  8. how to use dynamic link so file in cygwin

    Quote:-rdynamic: Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, not only used ones, to the dynamic symbol table. This option is needed for some uses of "dlopen" or to allow obtaining backtraces from within a program. Windows and Cygwin target PE/COFF rather than ELF. An ELF shared object ("so") would be instead a dynamic-link library (DLL). Here's some documentation on DLLs in Cywgin: Building and Using DLLs.
  9. compiling .cpp as .mm

    Try adding the option -x objective-c++.
  10. CentOs remote desktop help

    Quote:Original post by Kaze I figured out how to install x on cygwin, now: 1: how do I use gnome instead of the default x GNOME must be installed on the server, start it with gnome-session. Quote:Original post by Kaze 2: how do I connect to a remote computer Using SSH? ssh -X your_server's_hostname_or_ip_address Perhaps I'm misunderstanding the question. Quote:Original post by Kaze 3: what port will it use or can I use ssh The SSH daemon will by default listen to port 22. Usually, SSH defaults to disallowing root logins but allowing other accounts access with a password. As far as I remember, the X communication is tunneled through the SSH connection.
  11. CentOs remote desktop help

    Quote:Original post by Kaze When I tried startx I got Fatal server error: PAM authentication failed, cannot start X server. Perhaps you do not have console ownership? How do I fix it and why do I need authentication when I'm already using ssh Did you enter that on your server? (I'm guessing so, since I don't think PAM is usually available in Cygwin.) If so, it is trying to start a new X server on your server, rather than connect to the X server on your desktop. Since the X server is already running (on your desktop of course), try an X application or desktop environment (xterm, gnome-session).
  12. CentOs remote desktop help

    The way I've done it in the past (the hard way, probably ;)): Your server needs to have an X application or desktop manager installed and SSH up and running and accessible, as you've already done. You will need a X server running on your Windows desktop. So, install X in Cygwin, open a terminal and start up a X server on your desktop (xinit). Make sure DISPLAY is set properly; echo $DISPLAY should show something like :0.0. In the terminal, we'll forward X to the server via SSH, just like you'd normally log on with ssh, but with a -X added: e.g., ssh -X 123.456.789.0. In the SSH session, execute a X application (gnome-session, gdm, anything) and it should show up in your desktop's X server.
  13. Installing Python 2.6.4 on CentOS 5.4

    I couldn't say if doing this manually is the proper way, but in setup.py you can add modules to the disabled_module_list to skip them. # Replace: disabled_module_list = [] # With: disabled_module_list = ['bsddb185', 'dl', 'imageop', 'sunaudiodev']
  14. Where to store system wide settings?

    Not impossible, but nontraditional. I suppose you could make a sub-directory in your program's /etc, say /etc/myprogram/userconfig. Make that directory world readable/writable/executable and set the sticky bit so that it's like /tmp, to keep users from messing with each others files. Personally (not knowing more about what you're trying to achieve), I'd probably just leave the per-user configuration in the users' home directories. Most users have world readable/executable home directories, so scanning these directories from your program executed by any user shouldn't be too hard.
  15. The most common hack is to move the mouse pointer to the center of the screen after each motion event. Someone was working on a true relative motion extension, but I haven't heard anything about it in a while.