Suppress JInput output or redirect to a file

hi

Is it possible to suppress the JInput output (to stdout) or catch it (and parse it) and/or redirect to a file?

Qudus

Hi

I had an awful number of problems reported that with no output were impossible to diagnose, so by default, all the output is there. There is also the plugins system that outputs a bunch of debug. For now, the output is on.

Endolf

Galun just told me how to redirect stdout and stderr:

    OutputStream osc1 = new OutputStreamXYZ();
    PrintStream newStdout = new PrintStream(osc1);
    OutputStream osc2 = new OutputStreamXYZ();
    PrintStream newStderr = new PrintStream(osc2);
    System.setOut(newStdout);
    System.setErr(newStderr);

This is great. So I can stop the annoying xith output waisting my own logging. Or I can just filter the output byte wise.

But jinput doesn’t seem to use the jeva stdout or stderr. So I cannot force it to give its output to me instead of stdout or stderr. Is this correct or is there an output channel I don’t know of in java?

Qudus

Edit: I watched it a little closer. The following output comes just after the program terminated:


Initing event interface
Device name for device file /dev/input/event0 is AT Translated Set 2 keyboard
Device name for device file /dev/input/event1 is Logitech USB-PS/2 Optical Mouse
Copied temp event device 0 to event device 0
Copied temp event device 1 to event device 1
Initing joystick interface
Getting the number of event devices
Getting 2 event devices
Getting the number of joystick devices
Getting 0 joystick devices
Gettign device name for jinput device 0.
jinput device 0 is 136319456
EventDevice::getName()
Gettign device name for jinput device 0, (AT Translated Set 2 keyboard)
EventDevice::getName()
Gettign number of absolute axes for jinput device 0 (0)
Gettign number of relative axes for jinput device 0 (0)
Gettign number of buttons for jinput device 0 (146)
Getting bus type for device 0
Getting supported buttons for jinput device 0
Getting suported relative axes for jinput device 0
Getting suported absolute axes for jinput device 0
Getting supported buttons for jinput device 0
Gettign device name for jinput device 1.
jinput device 1 is 136321968
EventDevice::getName()
Gettign device name for jinput device 1, (Logitech USB-PS/2 Optical Mouse)
EventDevice::getName()
Gettign number of absolute axes for jinput device 1 (0)
Gettign number of relative axes for jinput device 1 (3)
Gettign number of buttons for jinput device 1 (4)
Getting bus type for device 1
Getting supported buttons for jinput device 1
Getting suported relative axes for jinput device 1
Getting suported absolute axes for jinput device 1
Getting supported buttons for jinput device 1

I think it might be an unflushed stream or so. Can you recontruct this? And do you want it to be like this? I think such an information should show up when the devices are gathered.

Qudus

Hi

Thanks comming from the native .so library. If you can compile the linux plugin, there is a -DDEBUG or similar in the ant build file in the linux plugin directory, if you remove that, then you should get no output, but you’ll also get nothing to tell you what went wrong if it does, which it shouldn’t :slight_smile:

Endolf

That’s not what I want. I just want runtime control over the output. As I said in my last post, this output is coming up after I called System.exit(0). I don’t think this is the goal of this output. Shouldn’t this output show up when thedevices are searched for and (hopefully) found? I think this is a bug, isn’t it?

If the output came up during runtime of my program, I could easily redirect it to a local methode and bock it, if I like and pass it through, if I think it’s necessary at that time.

Don’t you agree?

Qudus

For providence: Sometimes my phrases come down the way I didn’t mean them to. If it did, be assured, this should all just be contructive.

In the past the delay has never been a big deal. We generally dont exmaine the outpuit unless something goers wrong anyway :slight_smile:

My suspicion is that the reason it coems at the end has something to do with the way Java and the native C code interract in using stdout so I doubt its fixable.

I just started my program without eclipse and there the output come when it was meant to. But I still can’t redirect it by redirecting System.out and System.err. Any Idea?

Because its not Java.

Changing the Java doesnt do anything to the natvie code generating that.

As Endolf says, you need to rebuild the native lib with debug turned off.

OK. I don’t want to modify and rebuild a library. But how about passing a method to the java lib to switch this on and off? Maybe You could pass an Instance of a Stream Class to redirect it.

I agree with you, that this output can be necessary. But all the other time it’s just ugly waste in my stdout.

What do you think about it?

What would C code do with an instacne of Stream?

Actually, it WOULD be possible, through JNI, to call back into a Java object to send output. It woudl hwoever be needlessly slow.

You dont have to modify the library to eliminate the output. The switches are already there. You DO have to set a flag and run the build again.

As for modifying it. You say you don’t want to do any modification. That means it likely will not be modified as noone else is having an issue with this. You have a unique problem, you get to fix it.

Welcome to the wonders of Open Source.

When I originally wrote the linux plugin, at the native level, I had the choice of just dumping to stdout, w compile time controlled logger, or a runtime controlled logger. I figured that there would be several stages to development, and that at some point in the future when enough testing had been done, the only output needed would be in error cases. One stage would be the early adoption of the library, which is where I would say we still are, then there would be a reasonably stable period. Whilst we are in the adoption phase, there are have been a number of queries that withought the debug, we would not have been able to fix. I’m in the process of sticking force feedback into the linux plugin (well, rumblers at least) and again the debug is needed.

I have used numerous loggers in java before and they all the discussions have the same comments about needing to check if the levels are enabled first etc, which was way beyond what I wanted, I just wanted an ‘on/off’ system, and a simple macro in the C code sorted it. It’s not to everyones tastes, but it’s damn quick when it’s disabled, ie, there is no code there by the time the compiler gets it, so it’s fast to run.

The messages comming out at funny points seems to be when you have some java process wrapping stdout, like eclipse, or ant, if I run the tests from an ant script I also get the delays.

I can pass you a .so that doesn’t have the debug in it if you want?

Endolf

The point is that it doesn’t make any sense for me forking the code. If I make a modification found senseless by the library developer, and so will never be implemented ni releases, I’ll always have to remake this modification. That would be no usable solution for me.

But I think, if I have some time in the next days, I’ll go through the sourcecode of JInput and try to understand it better. If I find a thing worthy beeing changed, I’ll change it and give you my modified version, so you can check if you like it.

I think I’ll get along with the debugging output for some time. So you don’t need to send me such a .so, endolf. Thanks anyway.

Qudus

Hi

There is no issue at all in others modifying the code, if you find issues you can either post them on the jinput forum, if you have a fix, then you can either post it here, or get developer access to the source and change it yourself. Obviously, if it’s something major, we like to check with the other devs and users if it’s ok, so everyone knows and a consecus is reached before anything goes in anyway.

If you have any more questions don’t hesitate, questions and comments are what drives the api forwards.

Endolf