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.>
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.
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
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 ?