Hi Julian,

analog->getNumChannels() returns the size of the last actual received packet of
Analog data, not the potential channel capacity of an Analog device; see
osgVRPN/Analog.h.

The example below queries getNumChannels() immediately after device creation but
before any packet handing; after data has been received from the device, the
numchannels will be non-zero.

hth
-- mew



Julian Looser wrote:
> Hi Amin,
> 
> Thanks for your reply. It seems our posts have crossed over and you've
> replied to my initial message. What you've described is exactly what
> I've done so far. I began with an AnalogFly entry in the vrpn.cfg file,
> but I removed it because I just want the raw values from the joystick at
> the moment, I don't need them mapped onto a tracker.
> 
> I get correct results with the vrpn_print_devices program. Could you
> tell me whether these analog values were correctly working for you with
> osgVRPN? This is where I am currently stuck: VRPN can see the analog
> values but I don't get them through osgVRPN's Analog class.
> 
> Thanks again,
> Julian.
> 
> 
> Amin Ghadersohi wrote:
> 
>> Quoted from http://www.cs.unc.edu/Research/vrpn/DirectInput.html:
>> "Before using a DirectInput joystick, you need to download the
>> DirectInput
>> SDK from www.microsoft.com/directx. Install it in the recommended
>> directory
>> (C:\DXSDK).
>>
>> Once the SDK is installed, edit the vrpn_Configure.h. file and
>> uncomment the
>> definition for using direct input. Then rebuild the vrpn_server
>> application.
>> Now you can instantiate the joystick. Note that you can use the
>> joystick as
>> a tracker by adding an AnalogFly that listens to its values."
>>
>> I have done this and analog channels work just fine.
>>
>> Here is my vrpn.cfg file. A good way to test it, after you place the new
>> vrpn_server application that you compiled, is to run the
>> RUN_vrpn_server.bat
>> file and then modify RUN_vrpn_print_devices.bat to
>> vrpn_print_devices [EMAIL PROTECTED] 
>> And run it.
>> Here is what the output of vrpn_server should be:
>>
>>  
>>
>>> vrpn_server -millisleep 1 -f vrpn.cfg
>>>     
>>
>> Reading from config file vrpn.cfg
>> Opening vrpn_DirectXFFJoystick: Joystick0, read rate 60, force rate 0
>> Opening vrpn_Tracker_AnalogFly: Tracker0 with update rate 60
>>
>>
>> And here is what the output of the vrpn_print_devices should be:
>>
>>  
[snip]

>> Hope this helps
>> Amin
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Mike Weiblen
>> Sent: Tuesday, October 03, 2006 11:47 PM
>> To: osg users
>> Subject: Re: [osg-users] osgVRPN with a joystick
>>
>> Hi Julian,
>>
>> I have not used the DirectXFFJoystick device, does it publish Analog
>> or Dial
>> channels?  The osgVRPN prebuilt libs use VRPN 06.06 (I think), is that
>> device supported in that version?
>>
>> Have you tried snooping the device traffic with the
>> vrpn_print_devices.exe
>> included w/ osgVRPN?
>>
>> I have successfully used Analog channels with a Spaceball, so they do
>> work
>> on the client side.
>>
>> Cheers
>> -- mew
>>
>>
>>
>>
>> Julian Looser wrote:
>>  
>>
>>> Hi,
>>>
>>> I am trying to get values from a joystick into my OSG application
>>> using VRPN via osgVRPN. I have set my joystick inside the vrpn.cfg file
>>>     
>>
>> like so:
>>  
>>
>>> vrpn_DirectXFFJoystick    Joystick0    60    0
>>>
>>> In my application I use osgVRPN::Button and osgVRPN::Analog to access
>>> the buttons and axes of the joystick. Button state information is
>>> coming through fine, but the analog object says there are no analog
>>> channels when there should be seven.
>>>
>>> Has anyone successfully used these classes with a joystick under
>>> windows before? I had a look at the VRPN internals where it uses
>>> DirectX to enumerate the joystick buttons and axes and it should be
>>> picking them up. All buttons and axes are working in the Windows control
>>>     
>>
>> panel.
>>  
>>
>>> Any thoughts?
>>> Thanks in advance,
>>> Julian.
>>>
>>>
>>> Here is the code for the incredibly simple test application:
>>>
>>> int main( int argc, char *argv[] )
>>> {
>>>
>>>    osgProducer::Viewer viewer;
>>>    viewer.setUpViewer( osgProducer::Viewer::STANDARD_SETTINGS );
>>>
>>>    const char* deviceName( "[EMAIL PROTECTED]" );
>>>
>>>    osgVRPN::Button* button = new osgVRPN::Button(deviceName);
>>>    osgVRPN::Analog* analog = new osgVRPN::Analog(deviceName);
>>>
>>>    std::cout << "Analogs: " << analog->getNumChannels();  // always 0!
>>>
>>>    osg::Group* root = new osg::Group();
>>>    viewer.setSceneData( root);
>>>    viewer.realize();
>>>
>>>    while( !viewer.done() )
>>>    {
>>>        viewer.sync();
>>>        viewer.update();
>>>
>>>        button->update();
>>>        std::cout << button->getButtonState(0) << " ";
>>>        std::cout << button->getButtonState(1) << " ";
>>>        std::cout << button->getButtonState(2) << " ";
>>>        std::cout << std::endl;
>>>              viewer.frame();
>>>    }
>>>    viewer.sync();
>>>    return 0;
>>> }

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to