none
how to send mouse cursor move or reposition and left mouse click event in input report using this descriptor

    Question

  • I have a report descriptor and wish to send the mouse cursor move or reposition to where i want and left click a mouse in my input report if necessary or a way to after creating my emulated devices using the generichid script from dsf to change position of mouse and simulate a left mouse click. Also, i would accept an alternative way of sending input to dsf created drivers using windows apis if you have a link to sample code or list it below as i would need to see that your on the right track. I think if i just simulate a hardware left button being pressed down and  then released the only other thing would be to reposition the mouse to the position i tell it to go to.

    The main topic is sending input (stated above) to multiple emulated mouse devices in dsf(device simulation framework) wheter with windows apis or through input reports whichever will work but if windows apis i require a code sample and not just theory because its impossible to see where your going.

    BTW, in dsf the input reports are the same as a real input report on a device driver except its not real hardware so key codes are the same i just need a sample for multiple mice.

    I heard mame+ got rawinput to work with mutiple mice in some emulators but rawinput confuses me more then the other windows apis.




    Edit sorry heres the mouse descriptor from the vbscript file:

     ReportDescriptorsMouse(0) = CByte(&H5)   ' Usage Page
    ReportDescriptorsMouse(1) = CByte(&1)    '   Generic Controls
    ReportDescriptorsMouse(2) = CByte(&H9)   ' Usage
    ReportDescriptorsMouse(3) = CByte(&H2)   '   Mouse
    ReportDescriptorsMouse(4) = CByte(&HA1)  ' Collection
    ReportDescriptorsMouse(5) = CByte(&H1)   '   Application
    ReportDescriptorsMouse(6) = CByte(&H9)   ' Usage
    ReportDescriptorsMouse(7) = CByte(&H1)   '   Pointer
    ReportDescriptorsMouse(8) = CByte(&HA1)  ' Collection
    ReportDescriptorsMouse(9) = CByte(&H0)   '   Physical

    ReportDescriptorsMouse(10) = CByte(&H5)  ' Usage Page
    ReportDescriptorsMouse(11) = CByte(&H9)  '   Buttons
    ReportDescriptorsMouse(12) = CByte(&H19) ' Usage Minimum
    ReportDescriptorsMouse(13) = CByte(&H1)  ' 1
    ReportDescriptorsMouse(14) = CByte(&H29) ' Usage Maximum
    ReportDescriptorsMouse(15) = CByte(&H5)  ' 5
    ReportDescriptorsMouse(16) = CByte(&H15) ' Logical Minimum
    ReportDescriptorsMouse(17) = CByte(&H0)  ' 0
    ReportDescriptorsMouse(18) = CByte(&H25) ' Logical Maximum
    ReportDescriptorsMouse(19) = CByte(&H1)  ' 1
    ReportDescriptorsMouse(20) = CByte(&H95) ' Report Count
    ReportDescriptorsMouse(21) = CByte(&H5)  ' 5
    ReportDescriptorsMouse(22) = CByte(&H75) ' Report Size
    ReportDescriptorsMouse(23) = CByte(&H1)  ' 1
    ReportDescriptorsMouse(24) = CByte(&H81) ' Input
    ReportDescriptorsMouse(25) = CByte(&2)   ' Data Variable Absolute
    ReportDescriptorsMouse(26) = CByte(&H95) ' Report Count
    ReportDescriptorsMouse(27) = CByte(&1)   ' 1
    ReportDescriptorsMouse(28) = CByte(&H75) ' Report Size
    ReportDescriptorsMouse(29) = CByte(&3)   ' 3 padding
    ReportDescriptorsMouse(30) = CByte(&H81) ' Input
    ReportDescriptorsMouse(31) = CByte(&1)   ' Constant

    ReportDescriptorsMouse(32) = CByte(&H5)  ' Usage Page
    ReportDescriptorsMouse(33) = CByte(&H1)  ' Generic Desktop
    ReportDescriptorsMouse(34) = CByte(&H9)  ' Usage
    ReportDescriptorsMouse(35) = CByte(&H30) ' X
    ReportDescriptorsMouse(36) = CByte(&H9)  ' Usage
    ReportDescriptorsMouse(37) = CByte(&H31) ' Y
    ReportDescriptorsMouse(38) = CByte(&H9)  ' Usage
    ReportDescriptorsMouse(39) = CByte(&H38) ' Wheel
    ReportDescriptorsMouse(40) = CByte(&H15) ' Logical Minimum
    ReportDescriptorsMouse(41) = CByte(&H81) ' -127
    ReportDescriptorsMouse(42) = CByte(&H25) ' Logical Maximum
    ReportDescriptorsMouse(43) = CByte(&H7F) ' 127
    ReportDescriptorsMouse(44) = CByte(&H75) ' Report Size
    ReportDescriptorsMouse(45) = CByte(&H8)  ' 8
    ReportDescriptorsMouse(46) = CByte(&H95) ' Report Count
    ReportDescriptorsMouse(47) = CByte(&H3)  ' 3
    ReportDescriptorsMouse(48) = CByte(&H81) ' Input
    ReportDescriptorsMouse(49) = CByte(&H6)  ' Data variable relative

    ReportDescriptorsMouse(50) = CByte(&H5)  ' Usage Page
    ReportDescriptorsMouse(51) = CByte(&HC)  ' Consumer Devices
    ReportDescriptorsMouse(52) = CByte(&H15) ' Logical Minimum
    ReportDescriptorsMouse(53) = CByte(&H81) ' -127
    ReportDescriptorsMouse(54) = CByte(&H25) ' Logical Maximum
    ReportDescriptorsMouse(55) = CByte(&H7F) ' 127
    ReportDescriptorsMouse(56) = CByte(&H75) ' Report Size
    ReportDescriptorsMouse(57) = CByte(&H8)  ' 8
    ReportDescriptorsMouse(58) = CByte(&H95) ' Report Count
    ReportDescriptorsMouse(59) = CByte(&H1)  ' 1
    ReportDescriptorsMouse(60) = CByte(&HA)  ' Usage
    ReportDescriptorsMouse(61) = CByte(&H38) ' AC Pan
    ReportDescriptorsMouse(62) = CByte(&H2)  ' Horizontal Wheel scroll
    ReportDescriptorsMouse(63) = CByte(&H81) ' Input
    ReportDescriptorsMouse(64) = CByte(&H6)  ' Data variable relative

    ReportDescriptorsMouse(65) = CByte(&HC0) ' End collection
    ReportDescriptorsMouse(66) = CByte(&HC0) ' End collection



    • Edited by The Thinker Thursday, October 06, 2011 4:07 PM
    Thursday, October 06, 2011 3:51 PM

Answers

  • The Thinker wrote:
    >
    >The first question is: is their a default value for the wheel or can i put
    >zero for it always as i dont plan on using it at all?
     
    The wheel value is also relative, so if you keep sending 0, the wheel won't
    move.  However, if you don't want to worry about the wheel at all, just
    remove the vertical wheel and horizontal pan parts of your report
    descriptor.  Then you only have to send 3 bytes instead of 5.
     
    >The second question is:  So i can put my value of how far i move as a
    >value in hex or just plain write it out and it works?
     
    I'm sorry, I don't understand.  You can put any value from -128 to +127,
    which is about half an inch of physical motion.  If you write that in hex,
    it's &H80 to &H7F.
     
    >I think as long as i get the mouse moving that it might do bounds checking
    >within the mousemischief and multipoint i just need to move the mouse for
    >now
     
    You can keep reporting motion forever; the system will stop the pointer at
    the mouse edge.  This is just like your physical mouse.  You can keep
    moving your mouse farther and farther to the left, but the pointer stops at
    the desktop edge.
     
    >;) i get that way sometimes when im confused or frustrated or haven't had
    >my caffeine so you have to excuse me when i become a pain in the neck
    >sometimes.
     
    ;)
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by The Thinker Tuesday, October 18, 2011 12:04 PM
    Saturday, October 15, 2011 3:24 AM
  • The Thinker wrote:
    >
    >I have a report descriptor and wish to send the mouse cursor move or
    >reposition to where i want and left click a mouse in my input report
    >if necessary or a way to after creating my emulated devices using the
    >generichid script from dsf to change position of mouse and simulate
    >a left mouse click.
     
    Did you read the HID spec to see what your descriptor means?  The
    descriptor declares a report with three different parts.  The first part is
    buttons, consisting of 1 byte of data, with 5 bits for buttons and 3 pad
    bits.  The bit numbering is LSB first, so the 5 button bits would be:
        x x x 4 3 2 1 0
    The left button is first (bit 0).
     
    The second part is mouse position and vertical wheel scrolling.  This
    consists of three bytes: X, Y, Wheel.  Each is one byte, a signed 8 bit
    value, representing relative movement of -128 to +127 mickeys.
     
    The third part is the horizontal wheel motion ("pan"), with one byte, again
    with a relative value of -128 to +127.
     
    So, your reports will consist of 5 bytes:
     
       BUTTON  X  Y  WHEEL PAN
     
    Clicking the left button will send two reports:
     
        01 00 00 00 00   Left mouse down, no motion
        00 00 00 00 00   Left mouse up, no motion.
     
    It's just that easy.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by The Thinker Tuesday, October 18, 2011 12:05 PM
    Saturday, October 08, 2011 11:23 PM

All replies

  • Just focus in on the input report the above is a chunk taken from the generichid sample thats included with dsf
    • Edited by The Thinker Thursday, October 06, 2011 5:56 PM
    Thursday, October 06, 2011 5:56 PM
  • The Thinker wrote:
    >
    >I have a report descriptor and wish to send the mouse cursor move or
    >reposition to where i want and left click a mouse in my input report
    >if necessary or a way to after creating my emulated devices using the
    >generichid script from dsf to change position of mouse and simulate
    >a left mouse click.
     
    Did you read the HID spec to see what your descriptor means?  The
    descriptor declares a report with three different parts.  The first part is
    buttons, consisting of 1 byte of data, with 5 bits for buttons and 3 pad
    bits.  The bit numbering is LSB first, so the 5 button bits would be:
        x x x 4 3 2 1 0
    The left button is first (bit 0).
     
    The second part is mouse position and vertical wheel scrolling.  This
    consists of three bytes: X, Y, Wheel.  Each is one byte, a signed 8 bit
    value, representing relative movement of -128 to +127 mickeys.
     
    The third part is the horizontal wheel motion ("pan"), with one byte, again
    with a relative value of -128 to +127.
     
    So, your reports will consist of 5 bytes:
     
       BUTTON  X  Y  WHEEL PAN
     
    Clicking the left button will send two reports:
     
        01 00 00 00 00   Left mouse down, no motion
        00 00 00 00 00   Left mouse up, no motion.
     
    It's just that easy.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by The Thinker Tuesday, October 18, 2011 12:05 PM
    Saturday, October 08, 2011 11:23 PM
  • I've been in cisco and other classes with hex and binary. So can i use CByte to convert the hex equivilent of above into correct input report to send?

    How do i do mouse position though? Do i have to convert hex code into byte format for each position its moved like the mouse left button click?

    Okay so will something similar to this work? or Am I just messing around?:

    'left mouse click part which is the same as mouse up and down together.

    InputReport(0) = CByte(mouse click converted to hex here)

    InputReport(1) = CByte(x coordinates converted to hex here)
    InputReport(2) = CByte(y coordinates converted to hex here)

    InputReport(3) = CByte(what codes do i use for wheel?)

    InputReport(4) = CByte(code for pan here)

    If i need to do anything to change the above input report tell me. Once i test with sample values for cooridnates i will put in with kinect code.

    P.S. think my code modified from the generichis dsf sample on http://kinectmultipoint.codeplex.com project discussions would work with code above? I just put the mouse descriptors in keyboards place. 


    P.S. does the report descriptor have the hex code for each value? ( this is an important piece also)
    • Edited by The Thinker Tuesday, October 11, 2011 1:56 PM
    Tuesday, October 11, 2011 12:31 PM
  • Anyone know how to do this? BTW, thanks tim for helping because this project will also allow me to learn more about driver programming in case i need to do it in the future. Mostly concepts of driver programming though. I have learned about device descriptors and device input reports incase i need them in the future also.





    P.S. why does dsf(device simulation framework) have redistributable files for runtime if dsf doesnt have redistributable rights? (Sorry if im asking a more legal term but the answer to this question is optional.
    • Edited by The Thinker Tuesday, October 11, 2011 5:45 PM
    Tuesday, October 11, 2011 5:24 PM
  • Anyone know also how to when installing the generic device with dsf to skip windows update search unless its neccessary? Also, how do i use hclient to read the input report? (confused on that)

    Im confused because how do i modify the vbscript to put in your binary part tim? Do i have to convert to hex then send it like in the script? Also, first will my above code be the correct variable with the input report to send to the emulated device? 
    • Edited by The Thinker Tuesday, October 11, 2011 7:26 PM
    Tuesday, October 11, 2011 7:10 PM
  • > P.S. why does dsf(device simulation framework) have redistributable files for runtime if dsf doesnt have redistributable rights? (Sorry if im asking a more legal term but the answer to this question is optional

     

    because installing the wdk does not install DSF. it installs the DSF MSI so that you can install it on the machine under test. if you didn't have the MSI, there would be no way for you to install DSF without installing the WDK on all of your test machines. also, folks want the wdk to install without installing KM software on the dev box.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, October 12, 2011 6:39 AM
  • Doron, Tim, or anyone else that can answer the question above know to modify the script? I could probably could code mostly in vb.net myself because vbscript and vb.net are similar.


    • Edited by The Thinker Wednesday, October 12, 2011 7:09 PM
    Wednesday, October 12, 2011 12:02 PM
  • Anyone know wheter the values in the CByte statements in the input reports are hex values or constants? Also, for mouse position do i just insert it into the report?

    Would this be the correct way to arrange the bytes in the variable in my modified vbscript?

    'left mouse click part which is the same as mouse up and down together.

    InputReport(0) = CByte(mouse click converted to hex here)

    InputReport(1) = CByte(x coordinates converted to hex here)
    InputReport(2) = CByte(y coordinates converted to hex here)

    InputReport(3) = CByte(what codes do i use for wheel?)

    InputReport(4) = CByte(code for pan here)

    I just want for now to put it at a random chosen fixed location for each mouse and forget about anything else for now (for testing purposes). This will allow me to see the process and better help me if i actually go to write a driver in future and i need to have it soon because teachers might ask for my kinect project.

    I understand some of it now but wanted to make sure what i have about would work as the input report in the script?




    • Edited by The Thinker Wednesday, October 12, 2011 7:17 PM
    Wednesday, October 12, 2011 7:12 PM
  • The Thinker wrote:
    >
    >Anyone know wheter the values in the CByte statements in the input reports
    >are hex values or constants?
     
    I apologize in advance, because this message is going to expose my
    frustration.  I just don't think you know enough programming to be messing
    around at this level.  Seriously, you should be able to figure this kind of
    thing out on your own.  We've had literally dozens of messages in this
    thread, and I'm not convinced we are any closer to a result than when we
    started.
     
    The values are bytes.  Whether you write them as decimal or hex or
    constants or variables depends on convenience in your program.  In the
    machine's memory, they are just 5 bytes of binary data.
     
    Do you see my point?  The values 65 and &H41 and "A" are all exactly
    identical.  They have the same bit pattern when stored in a byte.
     
    >Also, for mouse position do i just insert it into the report?
     
    As opposed to what?  Where else would you put them?  You need to send a 5
    byte report, two bytes of which are mouse motion data.
     
    >Would this be the correct way to arrange the bytes in the variable in
    >my modified vbscript?
    >
    >'left mouse click part which is the same as mouse up and down together.
    >
    >InputReport(0) = CByte(mouse click converted to hex here)
     
    If you want the left mouse to be down, you'd store a 1.  Whether you write
    it as 1 or &H01 or CByte(1) is up to you.
     
    >InputReport(3) = CByte(what codes do i use for wheel?)
     
    "Notches".  It's kind of an arbitrary unit based on the motion of the
    wheel.  It takes 120 ticks before motion is noticed.
     
    >I just want for now to put it at a random chosen fixed location for each
    >mouse and forget about anything else for now (for testing purposes).
     
    Mice do not have fixed locations.  Mouse reports are RELATIVE.  The mouse
    knows how far it has traveled since its last report.  It has no concept of
    its physical location on your desk.  You report the number of mickeys that
    the mouse has moved since the last report, where a mickey is about 1/200".
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Thursday, October 13, 2011 3:40 AM
  • Okay that explains most things. I just have one maybe two more questions for the wheel and about mickeys before i mark answered and be on my way testing for awhile i doubt i will be back for awhile as i conquer code.

    The first question is: is their a default value for the wheel or can i put zero for it always as i dont plan on using it at all?

    The second question is:  So i can put my value of how far i move as a value in hex or just plain write it out and it works? I think as long as i get the mouse moving that it might do bounds checking within the mousemischief and multipoint i just need to move the mouse for now (i know multipoint does). BTW, im sorry about fixed location without bounds checking i cant really keep it within a fixed location or certain bounds in my program. I really meant  i want to keep it within certain bounds but this kind of programming has to be done in the main program so forget i asked that.

     

    Thank You tim and everyone that has helped sorry about my caffeine snd confused outbursts on my first few threads i made. ;) i get that way sometimes when im confused or frustrated or haven't had my caffeine so you have to excuse me when i become a pain in the neck sometimes.


    • Edited by The Thinker Thursday, October 13, 2011 12:27 PM
    Thursday, October 13, 2011 12:26 PM
  • The Thinker wrote:
    >
    >The first question is: is their a default value for the wheel or can i put
    >zero for it always as i dont plan on using it at all?
     
    The wheel value is also relative, so if you keep sending 0, the wheel won't
    move.  However, if you don't want to worry about the wheel at all, just
    remove the vertical wheel and horizontal pan parts of your report
    descriptor.  Then you only have to send 3 bytes instead of 5.
     
    >The second question is:  So i can put my value of how far i move as a
    >value in hex or just plain write it out and it works?
     
    I'm sorry, I don't understand.  You can put any value from -128 to +127,
    which is about half an inch of physical motion.  If you write that in hex,
    it's &H80 to &H7F.
     
    >I think as long as i get the mouse moving that it might do bounds checking
    >within the mousemischief and multipoint i just need to move the mouse for
    >now
     
    You can keep reporting motion forever; the system will stop the pointer at
    the mouse edge.  This is just like your physical mouse.  You can keep
    moving your mouse farther and farther to the left, but the pointer stops at
    the desktop edge.
     
    >;) i get that way sometimes when im confused or frustrated or haven't had
    >my caffeine so you have to excuse me when i become a pain in the neck
    >sometimes.
     
    ;)
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    • Marked as answer by The Thinker Tuesday, October 18, 2011 12:04 PM
    Saturday, October 15, 2011 3:24 AM
  • Thanks i understand now and i will try that and get back with you after some testing sessions. For testing the vbscript before i convert it i can loop the part with the mouse being created and just loop it as many times as i need.
    Tuesday, October 18, 2011 12:04 PM