Results 1 to 7 of 7

Thread: Emulating Joystick Input in Linux ( C++ )

  1. #1
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Emulating Joystick Input in Linux ( C++ )

    Hi everybody, I've been looking everywhere to find help but there seems to be no one trying to do what I want to do. Or maybe it's just too simple and I'm the clueless one
    Here is my problem:

    I have a joystick(actually a steering wheel) which I want to put on my Windows PC. I take the data from the wheel, send it through a socket to Linux and then want to use the data within a programm on Linux -Suse- (i don't have any code of this programm. so no interface )

    There was no problem implementing the windows-part. I read out the data (like thousends of game developers before me). I send it over to my server and I can simply "cout" the numbers for checking. Untill that point everything is fine.
    The problem is I'm a total newbie to Linux. I know instead of drivers there are somehow modules on the kernel but I have no idea how I could send my data to the programm. I guess I have to emulate the joystick to Linux, so that Linux takes care of giving the data to the programm, but I have no idea how.

    BTW I know the programm runs with the joystick. I can just plugin the joystick into linux and everything runs fine. But in the future I want to control it from the windows pc.

    HELP ! Any ideas ?? Doesn't have to be code at first, maybe just the way I have to go to emulate the joystick in linux !!?? Would I have to send the data to the appropriate module (usbhid or joydev or ?) ? If so, maybe someone could give me some links that explain how those modules work.
    Or is there no way all of that could work ? Is there some kind of interface like "DirectX/Direct Input" on Windows ?

    I'd appreciate any help I could get. Thx in advance.

  2. #2
    Join Date
    Mar 2009
    Posts
    72
    Thanks
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Emulating Joystick Input in Linux ( C++ )

    I'm developing a simple cross-platform (Windows, Linux, MacOSX) C library for joysticks and joypads.

    You can find it here:

    http://code.google.com/p/libjstar/

    Currently it's only a prototype, but it works

  3. #3
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Emulating Joystick Input in Linux ( C++ )

    Thanks for replying !

    "This is a cross-platform library (Unix, Windows & MacOSX) for use in reading input from connected joysticks & joypads. "
    The reading is not my problem! And my joystick is not connected since it's connected to the Windows PC.
    I have a few "solutions"/ ideas/ flickers of hope now. I think that the input devices are connected to nodes lying in /dev/input... well I'll propably have to make my own node (hopefully not write a full device). I will then send my data from my server to this node or character device and hopefully the usbhid module will do the rest...

    Problem is those character devices are binary. I read them out, but since I have no idea what form they are in, I can't write the correct input to them. I use a - filestream (ifstream f) - a - char buffer[8] - and - f.read(buffer,8); - cause I found out that the numbers repeat themselves after 8 bits/bytes/chars (you see I have no clue) when I don't move the wheel.
    I'm wondering what is in the character device, which data gets in and which numbers in which order ?!

    PLEASE HELP!

  4. #4
    Join Date
    Mar 2009
    Posts
    72
    Thanks
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Emulating Joystick Input in Linux ( C++ )

    Err, I'm sorry....You're right: you need to write, not to read. I misunderstood your first post.

  5. #5
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question Re: Emulating Joystick Input in Linux ( C++ )

    Don't worry... no problem ...Thanks anyway, @zuck !

    I'm still looking: Read alot about character devices, drivers, mayor and minor numbers and kernel in the past days.
    Maybe someone could tell me if I'm thinking correct right now:
    On the kernel I got usbhid which is the modul that controls the device driver and this device driver communicates with the char device file over the node I can create with mknod.
    And when putting on the actual device. Which part of all this talks to the physical device ? Is there another modul on the kernel checking the usb for changes ? And is the same thing writing to my node ? or where to ?
    Cause I guess I have to take over its role and write to my node !? I still have no clue in which way to send the data to the node, but if I'd know about the device that takes this task when an actual device is present I might find something.

    So... still hoping someone comes around and saves me !

  6. #6
    Join Date
    Jan 2010
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Exclamation Re: Emulating Joystick Input in Linux ( C++ )

    So nobody saved me but myself...
    and i can't imagine being the only one needing this, so if anyone else is ever gonna come looking for something like this, I at least want to give a solution:
    I implemented a module in Linux , a Device Driver, that writes through a device file the information that the joystick would usually give out... in form of js_event... if you wonder how to write the device driver... here are to very good explained examples.. well actually its the same example twice, but the second adds writing and ioctl into the first...
    here you go: http://www.linuxhq.com/guides/LKMPG/node14.html
    and http://tldp.org/LDP/lkmpg/2.4/html/c854.htm

    hope that helps...

  7. The following 2 users say thank you to invisible_uli for this useful post:

    pitonyak (1st March 2010), TheIndependentAquarius (5th January 2012)

  8. #7
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: Emulating Joystick Input in Linux ( C++ )

    Just in case ...
    Quote Originally Posted by invisible_uli View Post
    I implemented a module in Linux , a Device Driver, that writes through a device file the information that the joystick would usually give out... in form of js_event...
    Can you present some hints or code on how did you achieve that?

Similar Threads

  1. Emulating Enter key with left mouse click
    By wconstan in forum Newbie
    Replies: 6
    Last Post: 30th December 2009, 16:16
  2. input audio
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 10th September 2009, 11:12
  3. Emulating Unix on Windows
    By eichner in forum Qt Programming
    Replies: 5
    Last Post: 14th February 2008, 18:13
  4. QIntValidator input
    By chaos_theory in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2007, 10:28
  5. regarding input widget
    By jagadish in forum Qt Tools
    Replies: 1
    Last Post: 28th June 2007, 12:07

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.