This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to program Left cilk mouse to PageDown?


If I want to use Keil uVision to write a program to make the mouse to left click to have page_down function. How can I do?
<Use Nordic nRf24LU1 two feature boards and the wireless mouse demo.>

Parents
  • I don't have the board, and Nordic doesn't open the source to the web.
    As this brochure shows, I suppose the board exposes USB HID interface to the PC side.

    "nRF24LU1 Software Development Kit"
    www.nordicsemi.com/.../Prod_brief_Devtools_nRF24LU1_SDK.pdf

    The scroll wheel support for HID mouse is described on this MS WHDC document.

    "Enhanced Wheel Support in Windows Vista"
    download.microsoft.com/.../Wheel.docx

    And this is the HID report descriptor for wheel mouse.
    ( posted to " on MS WHDC // www.microsoft.com/.../wheel.mspx // char ReportDescriptor[118] = { 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x02, // COLLECTION (Logical) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) // ------------------------------ Buttons 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x05, // USAGE_MAXIMUM (Button 5) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x75, 0x01, // REPORT_SIZE (1) 0x95, 0x05, // REPORT_COUNT (5) 0x81, 0x02, // INPUT (Data,Var,Abs) // ------------------------------ Padding 0x75, 0x03, // REPORT_SIZE (3) 0x95, 0x01, // REPORT_COUNT (1) 0x81, 0x03, // INPUT (Cnst,Var,Abs) // ------------------------------ X,Y position 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x02, // REPORT_COUNT (2) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xa1, 0x02, // COLLECTION (Logical) // ------------------------------ Vertical wheel res multiplier 0x09, 0x48, // USAGE (Resolution Multiplier) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x35, 0x01, // PHYSICAL_MINIMUM (1) 0x45, 0x04, // PHYSICAL_MAXIMUM (4) 0x75, 0x02, // REPORT_SIZE (2) 0x95, 0x01, // REPORT_COUNT (1) 0xa4, // PUSH 0xb1, 0x02, // FEATURE (Data,Var,Abs) // ------------------------------ Vertical wheel 0x09, 0x38, // USAGE (Wheel) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical 0x45, 0x00, // PHYSICAL_MAXIMUM (0) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xa1, 0x02, // COLLECTION (Logical) // ------------------------------ Horizontal wheel res multiplier 0x09, 0x48, // USAGE (Resolution Multiplier) 0xb4, // POP 0xb1, 0x02, // FEATURE (Data,Var,Abs) // ------------------------------ Padding for Feature report 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical 0x45, 0x00, // PHYSICAL_MAXIMUM (0) 0x75, 0x04, // REPORT_SIZE (4) 0xb1, 0x03, // FEATURE (Cnst,Var,Abs) // ------------------------------ Horizontal wheel 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) 0x0a, 0x38, 0x02, // USAGE (AC Pan) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION 0xc0 // END_COLLECTION };

Reply
  • I don't have the board, and Nordic doesn't open the source to the web.
    As this brochure shows, I suppose the board exposes USB HID interface to the PC side.

    "nRF24LU1 Software Development Kit"
    www.nordicsemi.com/.../Prod_brief_Devtools_nRF24LU1_SDK.pdf

    The scroll wheel support for HID mouse is described on this MS WHDC document.

    "Enhanced Wheel Support in Windows Vista"
    download.microsoft.com/.../Wheel.docx

    And this is the HID report descriptor for wheel mouse.
    ( posted to " on MS WHDC // www.microsoft.com/.../wheel.mspx // char ReportDescriptor[118] = { 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x01, // COLLECTION (Application) 0x09, 0x02, // USAGE (Mouse) 0xa1, 0x02, // COLLECTION (Logical) 0x09, 0x01, // USAGE (Pointer) 0xa1, 0x00, // COLLECTION (Physical) // ------------------------------ Buttons 0x05, 0x09, // USAGE_PAGE (Button) 0x19, 0x01, // USAGE_MINIMUM (Button 1) 0x29, 0x05, // USAGE_MAXIMUM (Button 5) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x75, 0x01, // REPORT_SIZE (1) 0x95, 0x05, // REPORT_COUNT (5) 0x81, 0x02, // INPUT (Data,Var,Abs) // ------------------------------ Padding 0x75, 0x03, // REPORT_SIZE (3) 0x95, 0x01, // REPORT_COUNT (1) 0x81, 0x03, // INPUT (Cnst,Var,Abs) // ------------------------------ X,Y position 0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x30, // USAGE (X) 0x09, 0x31, // USAGE (Y) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x95, 0x02, // REPORT_COUNT (2) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xa1, 0x02, // COLLECTION (Logical) // ------------------------------ Vertical wheel res multiplier 0x09, 0x48, // USAGE (Resolution Multiplier) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x35, 0x01, // PHYSICAL_MINIMUM (1) 0x45, 0x04, // PHYSICAL_MAXIMUM (4) 0x75, 0x02, // REPORT_SIZE (2) 0x95, 0x01, // REPORT_COUNT (1) 0xa4, // PUSH 0xb1, 0x02, // FEATURE (Data,Var,Abs) // ------------------------------ Vertical wheel 0x09, 0x38, // USAGE (Wheel) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical 0x45, 0x00, // PHYSICAL_MAXIMUM (0) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xa1, 0x02, // COLLECTION (Logical) // ------------------------------ Horizontal wheel res multiplier 0x09, 0x48, // USAGE (Resolution Multiplier) 0xb4, // POP 0xb1, 0x02, // FEATURE (Data,Var,Abs) // ------------------------------ Padding for Feature report 0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical 0x45, 0x00, // PHYSICAL_MAXIMUM (0) 0x75, 0x04, // REPORT_SIZE (4) 0xb1, 0x03, // FEATURE (Cnst,Var,Abs) // ------------------------------ Horizontal wheel 0x05, 0x0c, // USAGE_PAGE (Consumer Devices) 0x0a, 0x38, 0x02, // USAGE (AC Pan) 0x15, 0x81, // LOGICAL_MINIMUM (-127) 0x25, 0x7f, // LOGICAL_MAXIMUM (127) 0x75, 0x08, // REPORT_SIZE (8) 0x81, 0x06, // INPUT (Data,Var,Rel) 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION 0xc0, // END_COLLECTION 0xc0 // END_COLLECTION };

Children
  • I have already got the code for wireless mouse demo. Now the left clik thing just need to change its dongle side code. Could you please see my part, whether it will work on Keil or not.
    /* if(radio_data[APP_MOUSE_BUTTONS]==0x09)
    {

    PAGE_DOWN

    <OnKeyDown()>
    }

    else if(LED1==1&&radio_data[APP_MOUSE_BUTTONS]==0x0A) {

    PAGE_UP <OnKeyUp()> } */

  • Anynoe have the data of usb port and keyboard just like the mouse above? Thanks!!

  • As the above brochure shows, "nRF24LU1 Software Development Kit" provides a keyboard example.

    KEY FEATURES
    - Mouse, keyboard and remote HID classes

    Just tricking 2-3 lines of the examples finishes your purpose.
    Then, what is the problem for you?

    Tsuneo

  • I don't know how to make the transfer of input and output between mouse and keyboard.
    here are some data about the keyboard:

     case 0x7D: ret=0x4B; break; // Keyboard page up
     case 0x7A: ret=0x4E; break; // Keyboard page down
    


    how to make them affect on mouse?

    /* if(radio_data[APP_MOUSE_BUTTONS]==0x09)
    {
    PAGE_DOWN.....???
    }
     else if(LED1==1&&radio_data[APP_MOUSE_BUTTONS]==0x0A)
    {
     PAGE_UP......???
     }
    
             case WDP_KEYBOARD:
                             // If keyboard data
              if(length == APP_KEYBOARD_PL_LENGTH)
              {
                usb_send_packet
                (
                  &radio_data[APP_DATA],
                  USB_EP_KEYBOARD,
                  (APP_KEYBOARD_PL_LENGTH - APP_DATA)
                );
              }
              break;
    

  • Ah, do you want to combine mouse and keyboard on the same device?

    1) First, customize the keyboard example.
    - On the key push, put the keycode of the page-down key (0x4E) to the first byte of the keycode array of the input report. Send the report to the interrupt IN endpoint.

    - On the key release, clear the keycode array by 0 and send the report to the interrupt IN endpoint.

    Connecting the device to a PC, test this customized one and finish it.

    2) Combine keyboard and mouse example

    There are two ways to combine these two HID devices.
    - Multiple Top-Level Collections (TLC)
    - Composite device

    Multiple TLC is simpler than composite device.
    - Combine the report descriptor for keyboard and mouse.
    - - Append the mouse report descriptor after the keyboard one
    - - Add report ID to each one.

    You'll find such a combined report descriptor as the example of this tool from USB.org.
    HID Descriptor Tool - Kbd_mouse.hid
    www.usb.org/.../dt2_4.zip

    - Replace the report descriptor of the customized keyboard example with the combined one.
    - Also change the size of the report descriptor on the HID class descriptor.

    The input report over the interrupt endpoint has to be modified a little.
    - On keyboard event (key-push/release), send the input report for the keyboard. This report has an extra byte at the top of the report for the report ID ( ID = 1, in above example ).

    - On mouse event, send the input report for the mouse. This report also has an extra byte for the report ID ( ID = 2 )

    That's all.

    Tsuneo


  • HI! I am still trying to reach the page_down.
    But I wanna to do "shift the moue cilk function" first.
    namely,I do left clik it will do the "right-click" thing. Can you tach me? Thanks so much!

  • "If I want to use Keil uVision to write a program to make the mouse to left click to have page_down function. How can I do?"
    "HI! I am still trying to reach the page_down."

    *** sigh ***
    Lack of imagination.

    When the device gets "mouse click" event from the remote side, the device puts "page_down" keyboard report to USB. For other mouse events like move, the device puts usual mouse report to USB. In this way, just "mouse click" event is converted to "page_down".

    It is the reason for above combined device of mouse and keyboard.
    This device can put both of mouse and keyboard report.

    "But I wanna to do "shift the moue cilk function" first.
    namely,I do left clik it will do the "right-click" thing."

    Just replace the relation between the input events and the USB outputs.

    shift-click =
    - put shift-key down on keyboard report
    - put mouse click report
    - put shift-key up (ie. all 0) on keyboard report

    Tsuneo

  • Hi! After i changed the code, something funny happend.If i move the wireless mouse, a string of charactors come out! And what more interesting is that some of my keyboard keys have chaged thire functions. When i press "F" the "search rpage "will come out. If I press "E" or
    "M" the page of "computer drives" come out!
    I cannot use my keyboard any more. So i chage back the code and restart my PC. The keyboard became normal again. here are the code i chaged, i donnot know why it will affect my keyboard on PC which is not wireless one. And why only move the mouse ""abc"things came out,why PAGEDOWN never affect? I am so confused...here are the code i have changed

    switch(dev_type)
          {
            case WDP_MOUSE:
                                   // If mouse data
              if(length == APP_MOUSE_PL_LENGTH)
              {
    
                usb_send_packet
                (
                  &radio_data[APP_DATA],
                  USB_EP_KEYBOARD,
                  (APP_KEYBOARD_PL_LENGTH - APP_DATA)
                );
            switch(radio_data[APP_MOUSE_BUTTONS])
        {
          case 0x09:radio_data[APP_MOUSE_BUTTONS]=0x4E;
          default radio_data[APP_MOUSE_BUTTONS]=0;
        }
    
                       }
              break;
    


    the origianl code is

            switch(dev_type)
          {
            case WDP_MOUSE:
                                   // If mouse data
              if(length == APP_MOUSE_PL_LENGTH)
              {
    
                usb_send_packet
                (
                  &radio_data[APP_DATA],
                  USB_EP_MOUSE,
                  (APP_MOUSE_PL_LENGTH - APP_DATA)
                );
    
    
                       }
              break;
            case WDP_KEYBOARD:
                             // If keyboard data
              if(length == APP_KEYBOARD_PL_LENGTH)
              {
                usb_send_packet
                (
                  &radio_data[APP_DATA],
                  USB_EP_KEYBOARD,
                  (APP_KEYBOARD_PL_LENGTH - APP_DATA)
                );
              }
              break;
          }
            }
    

  • You have to keep track of the state of all modifying buttons - left and right shift, shift, ctrl, alt, win, alt gr, ...

  • hi Tsuneo

    there's no Kbd_mouse.hid in the HID Descriptor Tool (dt2_4.zip) from usb.org
    where is it?

    thank you

  • yes please, where is Kbd_mouse.hid ?