Results 1 to 6 of 6

Thread: Raw Input in QT4

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Raw Input in QT4

    Does QT4 support raw input? Is there a way to use it?

  2. #2
    Join Date
    Dec 2007
    Posts
    27
    Thanks
    1
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Raw Input in QT4

    What do you mean with "raw input". Any context?

  3. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Raw Input in QT4

    Yes, Raw Input as in input from a game controller.
    http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx
    But I want to be able to connect various USB mouse to a pc and then get each of their input separately.

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Raw Input in QT4

    No, I don't think this capability is in Qt.

    You can of course use the functions suggested by MSDN.
    But it won't be multiplatform.

    On unix systems you can just get the input from a device like this:
    Qt Code:
    1. cat /dev/input/mouse0
    2. (þ(þ(û(ü(û(ü(ú(û(ý(þ(þ(ÿ(ÿ(þ(þ(þ(ý(ý(ý(ý(ÿ(ý(ý(ý(ý(ý(ÿ(ý(ý(þ(ý(ý(þ(þ(þ(ý(ÿ(þ(ÿ(ÿ(ÿ(ÿ(þ(ý(þ(þ(ÿ(þ(ÿ(ÿ(ÿ(ÿ(ÿ(ý(þ(þ(ý(ÿ(þ(ÿ(ÿ(þ(ÿ(ÿ(ÿ(ÿ((ÿ(þ(ÿ(ÿ(ÿ^C
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Raw Input in QT4

    Ok, I found a app that uses Win32 to get raw input.


    raw_mouse.h:
    Qt Code:
    1. //=================================================================
    2. //
    3. // raw_mouse.h - Windows XP implementation of multi-mouse input
    4. //
    5. //=================================================================
    6.  
    7. #ifndef __RAW_MOUSE_H
    8. #define __RAW_MOUSE_H
    9.  
    10. #include <windows.h>
    11. #include <stdio.h>
    12.  
    13. //============================================================
    14. // PROTOTYPES
    15. //============================================================
    16. // init raw mouse by creating the array of raw mice (include sysmouse, include rawmouse, include individual mice)
    17. BOOL init_raw_mouse(BOOL, BOOL, BOOL);
    18.  
    19. // Number of mice stored in pRawMice array
    20. // NOTE: init_raw_mouse must be called before this can return the actual number of mice
    21. int raw_mouse_count();
    22.  
    23.  
    24.  
    25. // Free up the memory allocated for the raw mouse array
    26. void destroy_raw_mouse(void);
    27.  
    28. // Every time the WM_INPUT message is received, the lparam must be passed to this function to keep a running tally of
    29. // every mouse move to maintain accurate results for get_raw_mouse_x_delta() & get_raw_mouse_y_delta().
    30. BOOL add_to_raw_mouse_x_and_y(HANDLE); // device handle, x val, y val
    31.  
    32. // Fetch the relative position of the mouse since the last time get_raw_mouse_x_delta() or get_raw_mouse_y_delta
    33. // was called
    34. ULONG get_raw_mouse_x_delta(int);
    35. ULONG get_raw_mouse_y_delta(int);
    36. ULONG get_raw_mouse_z_delta(int);
    37.  
    38. // pass the mousenumber, button number, returns 0 if the button is up, 1 if the button is down
    39. BOOL is_raw_mouse_button_pressed(int, int);
    40. char *get_raw_mouse_button_name(int, int);
    41.  
    42. // Used to determine if the HID is using absolute mode or relative mode
    43. // The Act Labs PC USB Light Gun is absolute mode (returns screen coordinates)
    44. // and mice are relative mode (returns delta)
    45. // NOTE: this value isn't updated until the device registers a WM_INPUT message
    46. BOOL is_raw_mouse_absolute(int);
    47.  
    48. // This indicates if the coordinates are coming from a multi-monitor setup
    49. // NOTE: this value isn't updated until the device registers a WM_INPUT message
    50. BOOL is_raw_mouse_virtual_desktop(int);
    51.  
    52. #endif /* ifndef __RAW_MOUSE_H */
    To copy to clipboard, switch view to plain text mode 

    So I include the C file:
    Qt Code:
    1. extern "C"{
    2. #include "raw_mouse.h"
    3. }
    To copy to clipboard, switch view to plain text mode 
    And call the initialization function, then check for amount of raw mouse inputs:
    Qt Code:
    1. init_raw_mouse(1,0,1);
    2. qDebug() << raw_mouse_count();
    To copy to clipboard, switch view to plain text mode 
    But that outputs 0. When it should show 5.That's what the original Win32 app displays.
    Attached Files Attached Files
    Last edited by been_1990; 13th September 2010 at 04:51. Reason: Upload file

  6. #6
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Raw Input in QT4

    With some help I've got that figured out. Subclassed QApplication and here's the result:
    Qt Code:
    1. extern "C"{
    2. #include "raw_mouse.h"
    3. }
    4. #include "qapp.h"
    5. #include <QDebug>
    6. #define WM_INPUT 0x00FF
    7.  
    8. QApp::QApp(int & argc, char ** argv) :
    9. QApplication(argc,argv)
    10. {
    11. init_raw_mouse(1, 0, 1);
    12. qDebug() << raw_mouse_count();
    13. }
    14.  
    15. bool QApp::winEventFilter(MSG *message, long *result)
    16. {
    17. qDebug() << message->message;
    18. switch(message->message){
    19. case WM_INPUT:
    20. {
    21. add_to_raw_mouse_x_and_y((HANDLE)message->lParam);
    22. qDebug() << "raw input here";
    23. }
    24. return true;
    25. }
    26. return false;
    27. }
    To copy to clipboard, switch view to plain text mode 

    The problem is that "raw input here" never traces, so I never get the raw input. Also raw_mouse_count() prints 0 when it should print out at least 5.

Similar Threads

  1. QLineEdit and input mask
    By tpf80 in forum Qt Programming
    Replies: 7
    Last Post: 9th May 2014, 20:47
  2. input audio
    By addu in forum Qt Programming
    Replies: 9
    Last Post: 10th September 2009, 12:12
  3. [SOLVED] QLineEdit Input
    By QbelcorT in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2008, 05:37
  4. QIntValidator input
    By chaos_theory in forum Qt Programming
    Replies: 4
    Last Post: 19th August 2007, 11:28
  5. regarding input widget
    By jagadish in forum Qt Tools
    Replies: 1
    Last Post: 28th June 2007, 13:07

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.