Results 1 to 3 of 3

Thread: [ClanLib 3.0](Maybe also 2.3...) Joystick fix

  1. #1

    Default [ClanLib 3.0](Maybe also 2.3...) Joystick fix

    Hi, here it's a really "strange" fix. It's relate to ioctl behavior (on archlinux, kernel 3.2.9, and I do not tested with a joystick due to lack of hardward).

    Here is the documentation I found :
    https://www.kernel.org/doc/Documenta...ystick-api.txt

    Clanlib's X11's input_device_provider_linuxjoystick.cpp follow the documentation and use the following call :
    Code:
    	char name_cstr[256];
    	if (ioctl(fd, JSIOCGNAME(sizeof(name_cstr)), name_cstr) < 0)
    		strncpy(name_cstr, "Unknown", sizeof(name_cstr));
    But, in some conditions (do not ask me why and when...), the "name_cstr" field isn't writen by ioctl, althought the function didn't return a negative value. So a fix is :
    Code:
    	char name_cstr[256] = {'\0'}; //Initialize the string as an empty C string.
    	if (ioctl(fd, JSIOCGNAME(sizeof(name_cstr)), name_cstr) < 0)
    		strncpy(name_cstr, "Unknown", sizeof(name_cstr));
    At the same time, I saw some old C in the call of x11 window cpp file, so I wasn't able to keep myself from rewriting it. I saw that string_format is used in the mouse code, so I just used it. Check the patch file.
    Attached Files Attached Files

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    humm, interesting. iirc, valgrind complained about that function many many years ago (ClanLib 0.9 time)
    I wonder if it's connected...

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Patch applied, many thanks

Similar Threads

  1. Joystick bug
    By Nightwind0 in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 10-11-2010, 04:12 PM
  2. Replies: 7
    Last Post: 08-26-2008, 09:57 PM
  3. Installing ClanLib 0.8 and ClanLib 0.9 on linux
    By rombust in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-15-2008, 09:51 AM
  4. NovaShell in Linux won't start (joystick error)
    By ArmiMaan in forum Novashell Game Creation System
    Replies: 2
    Last Post: 02-18-2008, 12:34 PM
  5. FreeBSD joystick patch for clanlib 0.8
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 10-14-2007, 04:19 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •