Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: No rendering with joystick attached on Linux  (Read 5081 times)

0 Members and 1 Guest are viewing this topic.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
No rendering with joystick attached on Linux
« on: December 12, 2009, 01:17:37 pm »
Hey,

I've got a problem with SFML when I've attached my Saitek X52 Pro controller. When launching programs, nothings gets rendered -- or sometimes just the first frame.

When I disconnect the joystick, everything's just fine.

There're no error messages or crashes. The applications just doesn't respond anymore.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No rendering with joystick attached on Linux
« Reply #1 on: December 12, 2009, 01:39:52 pm »
Hi

Which version of SFML do you use? Can you use the debugger to know where the program is stuck?
Laurent Gomila - SFML developer

Mr. Wonko

  • Newbie
  • *
  • Posts: 10
    • View Profile
No rendering with joystick attached on Linux
« Reply #2 on: December 13, 2009, 12:25:41 am »
hey I was about to post the same thing!

I use SFML 1.5, .deb package downloaded with Synaptic on Ubuntu 9.10.

I've got an XBox 360 (wired) Gamepad connected and no window would show up. It turned out that it never left the GetEvent-loop.

So I added debug output for every Event. Well, it turned out that...
Quote
Event: JoyMoved: 0 - 4.43434
Event: JoyMoved: 0 - -0.601215
Event: JoyMoved: 0 - -100
Event: JoyMoved: 0 - 14.2369
Event: JoyMoved: 0 - -100
Event: JoyMoved: 0 - 100
Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0.1
Event: JoyButtonPressed: 0 - 34
Event: JoyButtonPressed: 0 - 35
Event: JoyButtonPressed: 0 - 37
Event: JoyButtonPressed: 0 - 38
Event: JoyButtonPressed: 0 - 39
Event: JoyMoved: 0 - 4.43434
Event: JoyMoved: 0 - -0.601215
Event: JoyMoved: 0 - -100
Event: JoyMoved: 0 - 14.2369
Event: JoyMoved: 0 - -100
Event: JoyMoved: 0 - 100
Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0.1
Event: JoyButtonPressed: 0 - 34
Event: JoyButtonPressed: 0 - 35
Event: JoyButtonPressed: 0 - 37
Event: JoyButtonPressed: 0 - 38
Event: JoyButtonPressed: 0 - 39
...
you get the idea

And apparently that happens faster than it can be popped from the stack.

I tried removing the gamepad (didn't restart though), resulting in a slightly different output:
Quote

Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0.1
Event: JoyButtonReleased: 0 - 32
Event: JoyButtonReleased: 0 - 33
Event: JoyButtonReleased: 0 - 36
Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0
Event: JoyMoved: 0 - 0.1
Event: JoyButtonReleased: 0 - 32
Event: JoyButtonReleased: 0 - 33
Event: JoyButtonReleased: 0 - 36

(Btw there's no output for the Joy::Axis because I was too lazy to look that up - it's not in the doc.)

Well, as a workaround I counted the events received and stopped on 1000 per frame - that way it ran smoothly.
So I started wondering just how many Events there could possibly be... I tried this (I really love the simplicity of SFML - nice work!):
Code: [Select]
       sf::Clock WatchDogTimer;
        while(App.GetEvent(Event))
        {
            ++count;
            if(WatchDogTimer.GetElapsedTime() > 1.0)
            {
                std::cout<<"Event-Overflow: more than 1 second of events per frame. ("<<count<<" events received)"<<std::endl;
                break;
            }

Well, it turned out I got 3 million Events per second! (SFML sure is fast :D )

I don't know if this is a Ubuntu- or an SFML-related problem but it sure is annoying.


P.S.: AM/PM time style is funny - 11:25PM is after 12:39PM

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No rendering with joystick attached on Linux
« Reply #3 on: December 13, 2009, 12:30:11 am »
If I remember correctly, there is a program to test joysticks on Linux.
Try this:
Code: [Select]
jstest /dev/input/js0
(or js1 if it's your secondary joystick)

And see if you still get 3 millions events per second ;)

By the way, I have a similar problem on my Debian, but I don't think that it is the same one: the OS thinks that my Microsoft keyboard is a joystick that triggers events continuously. This has the same effect: the event loop gets stuck, and the whole application is frozen.
Laurent Gomila - SFML developer

Mr. Wonko

  • Newbie
  • *
  • Posts: 10
    • View Profile
No rendering with joystick attached on Linux
« Reply #4 on: December 13, 2009, 10:25:42 am »
Quote from: "Laurent"
By the way, I have a similar problem on my Debian, but I don't think that it is the same one: the OS thinks that my Microsoft keyboard is a joystick that triggers events continuously. This has the same effect: the event loop gets stuck, and the whole application is frozen.

Hey, I just found out that my problem is the same: My mouse (Sharkoon Fireglider), besides working as a mouse, also creates a /dev/input/js0. It has 6 Buttons (i.e. 1 more than most mouse interfaces support), thus you might think that the other buttons work as a joystick but that's not the case - I tested it using
jstest [--normal or --event] /dev/input/js0
and neither did anything change when I pressed a button nor did I get thousands of events.

Anyway if I disconnect it while running the program everythings works - no thousands of events. So the problem seems to have something to do with either SFML or the Input Library it uses. Good thing is: Your keyboard causes the same problem so it should be easier to figure out what the problem is.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No rendering with joystick attached on Linux
« Reply #5 on: December 13, 2009, 11:47:45 am »
I know what the problem is on my PC: the system maps the keyboard to /dev/input/js0 and produces random values in it. Nothing to do with SFML.
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
No rendering with joystick attached on Linux
« Reply #6 on: December 14, 2009, 09:16:10 am »
GetEvent() fetches JoyButtonReleased events all the time which freezes the application on my side. However, jstest doesn't report continious events.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
No rendering with joystick attached on Linux
« Reply #7 on: December 14, 2009, 09:19:50 am »
Quote from: "Tank"
GetEvent() fetches JoyButtonReleased events all the time which freezes the application on my side. However, jstest doesn't report continious events.

Yeah, I don't think it is the same issue for you, as everything works fine when you unplug your joystick.
Laurent Gomila - SFML developer

 

anything