Results 1 to 11 of 11

Thread: How to simultaneously read and transfer all joystick values to a usb port

  1. #1
    Join Date
    Mar 2011
    Location
    INDIA
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Joystick Reader

    Hi, i am emulating joystick, so far i am able to read joystick values and display them on screen, but i want to send them to another computer using tcp socket. I am able to create a socket but can any one tell me how can i gather all the values and send them to tcp socket

    Joystick reader

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4.  
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. QTimer* timer = new QTimer(this);
    12. joystick = new Joystick();
    13. connect(timer, SIGNAL(timeout()), this, SLOT(updateForm()));
    14. connect(ui->btnConnect,SIGNAL(clicked()),this, SLOT(joyConnect()));
    15. }
    16.  
    17. MainWindow::~MainWindow()
    18. {
    19. delete ui;
    20. }
    21.  
    22. void MainWindow::joyConnect()
    23. {
    24. if(joystick->init(joyAccess->text().toAscii()) > -1)
    25. {
    26. ui->btnConnect->setText("Connected");
    27. timer->start();
    28. }
    29.  
    30. }
    31. void MainWindow::updateForm()
    32. {
    33. ui->lcd1->display(joystick->getAxis(0));
    34. ui->lcd2->display(joystick->getAxis(1));
    35. ui->lcd3->display(joystick->getAxis(2));
    36. ui->lcd4->display(joystick->getAxis(3));
    37.  
    38.  
    39. if(joystick->getButton(0) > 0)
    40. ui->label_1->setText("UP");
    41. else
    42. ui->label_1->setText(" Axis1");
    43.  
    44. if(joystick->getButton(1) > 0)
    45. ui->label_2->setText("Down");
    46. else
    47. ui->label_2->setText(" Axis2");
    48.  
    49.  
    50. if(joystick->getButton(2) > 0)
    51. ui->label_3->setText("UP");
    52. else
    53. ui->label_3->setText(" Axis3");
    54.  
    55.  
    56. if(joystick->getButton(3) > 0)
    57. ui->label_4->setText("UP");
    58. else
    59. ui->label_4->setText(" Axis4");
    60.  
    61. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2011
    Location
    INDIA
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default How to simultaneously read and transfer all joystick values to a usb port

    Hi everybody
    i am new to Qt.I am trying to emulate joystick so far i am able to read joystik value and display it.i want to simulataneous gather all(4) the values and send ot to a port.

    I am reading joystick values using getAxis().
    I will appreciate any help from ur side.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    There is similar thread already : link. Aren't you the same person ?
    If not, then well, Qt does not offer any usb-port access methods, you'll need to implement it on your own. On windows, maybe you could use libusb ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Joystick Reader

    If you are able to read all the values then what's exactly the problem?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    Aren't you the same person ?
    Or perhaps two people in the same class at school with the same homework assignment.

  6. #6
    Join Date
    Mar 2011
    Location
    INDIA
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Joystick Reader

    Well I want to send all the values simultaneously to tcp socket, and I am not able to figure out how??.

  7. #7
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Joystick Reader

    You call socket.write(). See the documentation.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    And the same IP? Doubtful. Users merged, merging threads.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Mar 2011
    Location
    INDIA
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    Well, may be I wasn't clear last time, the problem is how to gather all the values together .

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    What do you mean "together"?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to simultaneously read and transfer all joystick values to a usb port

    Well, may be I wasn't clear last time, the problem is how to gather all the values together .
    The clarity hasn't changed much.

    You can store joystick values in a QVector, QList, some user-defined structure with appropriate streaming operators if needed, or just send them one at a time. There is no QBundleOfJoystickValues class to rely on, and there is no universal right way to bundle data. If the receiver imposes a certain format then you should send your data in that format.

Similar Threads

  1. Replies: 6
    Last Post: 12th October 2015, 08:59
  2. Replies: 5
    Last Post: 11th January 2011, 10:52
  3. how QT read com port with lowlevel I/O on CE
    By baby911 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 3rd August 2009, 03:40
  4. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2008, 00:29
  5. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2008, 08:41

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.