• AVR Freaks

HID boot-keyboard & mouse on same device?

Page: < 123 > Showing page 2 of 3
Author
violin
Super Member
  • Total Posts : 3301
  • Reward points : 0
  • Joined: 2005/05/09 04:59:48
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/11 05:23:17 (permalink)
0
I'm trying to adapt the Circle Mouse code (Microchip C18) to support a HID boot-keyboard and a boot-mouse on the same time (two interface descriptors).


Sorry Violin, what do you mean by "Connected mouse and keyboard to 18452" ?


Bold print means not fully clear on these terms.

Sorry Dario. This was a bit of a rush reply due to time limit.

There was a lot of mentioning of USB and 18f4550 (USB device) in the thread and wasn’t clear in why this was stated, as a USB device is not necessary needed for this operation, involving a USB mouse and computer keyboard, when this can be achieved by SPI directly on generic I/O pins, as in my case with the 18f452, for whatever application intended, with the usage of an LCD for conformation of keystrokes or button-presses and mouse movements.

Is the OP attempting to achieve this via a computer instead, using a USB device. If so this sounds a bit of a roundabout thing to me and haven’t given this method much thought, with the inclusion of a USB slave device being incorporated somehow, so as to complete this operation. Regards

 
post edited by violin - 2008/10/11 05:33:52
#21
xiaofan
Super Member
  • Total Posts : 6247
  • Reward points : 0
  • Joined: 2005/04/14 07:05:25
  • Location: Singapore
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/12 16:54:28 (permalink)
0
ORIGINAL: violin
There was a lot of mentioning of USB and 18f4550 (USB device) in the thread and wasn’t clear in why this was stated, as a USB device is not necessary needed for this operation, involving a USB mouse and computer keyboard, when this can be achieved by SPI directly on generic I/O pins, as in my case with the 18f452, for whatever application intended, with the usage of an LCD for conformation of keystrokes or button-presses and mouse movements.


I am not so sure if this will work for all kind of USB keyboard and Mouse. Yes many of them comes with a PS/2 adapter and work with either USB or PS/2. When you are using 18F452 and SPI, I am pretty sure that you are not talking using USB but using PS/2.

At least I have a USB keyboard which does not work when connecting to the PS/2 port through a PS/2->USB adapter.

  USB_Links and libusb
#22
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/13 01:00:59 (permalink)
0
ORIGINAL: xiaofan

At least I have a USB keyboard which does not work when connecting to the PS/2 port through a PS/2->USB adapter.


A quick comment on this: some 9 months ago, we experienced an issue with a PS/2 - USB adaptor and our keyboards. The converter was sending a Command which none of our datasheet did mention... (as written many times, PS/2 specs *suck* to tell the best...)
Simply starting ro reply ACK to it, and doing nothing else, made our keyboard be recgnized and ok. Of course, taiwan keyboards *did* already implement that and thus were ok... [:@]

GENOVA :D :D ! GODO
#23
violin
Super Member
  • Total Posts : 3301
  • Reward points : 0
  • Joined: 2005/05/09 04:59:48
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/13 10:51:30 (permalink)
0
I am not so sure if this will work for all kind of USB keyboard and Mouse. Yes many of them comes with a PS/2 adapter and work with either USB or PS/2. When you are using 18F452 and SPI, I am pretty sure that you are not talking using USB but using PS/2.

At least I have a USB keyboard which does not work when connecting to the PS/2 port through a PS/2->USB adapter.



Hi Xioafan. I have done a lot of experimenting with mice, track-ball and optical PS/2 and USB connection and as far as I have learnt so far that both USB and PS/2 use the same protocol, just different connections.

As far as Keyboards are concerned I have only recently started doings things with them and at the moment only tried it out with one of my computer keyboards with a PS/2/6way mini din connection. However, I am satisfied at the moment that after a keystroke on a particular key the LCD will display the correct character to the corresponding key for example a keystroke on z will display z on the LCD via the written program, well most times anyway. At the moment I am putting down the missed key down to corruption due to the length of cable between the Keyboard and Microcontroller and have plans to shorten it so as to see if this corrects the issue. I also have the intention of purchasing a USB connection mini keyboard so as to do further experimenting, but feel that I will experience no real issues with them as both USB and PS/2 connection keyboards use the same ASCII protocol.

I still have no idea what a circle mouse is or in how the OP was intending to implement his/her keyboard/mouse to a (18f4550) device with this HID (human-interface-device) boot-mouse and HID boot-Keyboard with two interface descriptors. Regards
post edited by violin - 2008/10/13 10:56:00
#24
xiaofan
Super Member
  • Total Posts : 6247
  • Reward points : 0
  • Joined: 2005/04/14 07:05:25
  • Location: Singapore
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/13 16:08:00 (permalink)
0
"Circle mouse" is one of the example firmware in Microchip's USB firmware framework.
For HID/Boot Protocol/etc you can go to http://www.usb.org.

You are right that many USB mouse/keyboard will support both USB and PS/2 protocol and you only need to use cheap passive converters ( connection: http://pinouts.ru/InputCables/usb_ps2_mouse_pinout.shtml ) to use it.

However this is not always true.
http://en.wikipedia.org/wiki/PS/2_connector

Today's laptops frequently do not include PS/2 ports and so the port is now regarded as a legacy port on Wintel, having been superseded by USB. Many current keyboards and mice support both USB and PS/2 with a simple wiring adapter and active adapters are available which plug into a USB port and provide a pair of PS/2 ports.


The keyword here is "many", which means not all will support both USB and PS/2.

On the other hand, if you want to use your PS/2 keyboard on USB ports, you need some active electronics. I bought a cheap one (just for testing purpose) and it seems to work fine but it does not support the multimedia key. It is something like this (I bought from local shop here in Singapore).
http://sewelldirect.com/usbtops2.asp

  USB_Links and libusb
#25
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/13 19:16:27 (permalink)
0
Back to the OP's question,
Elisandra wrote,
I'm trying to implement a composite device (keyboard + generic HID) based in the keyboard example provided in version 2.2, but I'm having a hard time to make it work.
I've seen some threads in the forum, and I've tried two different aproaches:...
I don't know exactly what changes are needed in the descriptor and how can I address each report or interface


There are two approach,
a) Multiple top-level collections
b) Composite device

a) is simpler than b), but it can support the boot protocol just for either one of the keyboard or the mouse. Usually, you'll select boot keyboard, because boot mouse is not so useful. b) can support boot protocol for both of keyboard and mouse.

OK, look into the detailed implementation.
I've already updated to MCHPFSUSB Framework to v2.3. Then, I write on this version.
http://ww1.microchip.com/downloads/en/DeviceDoc/Microchip%20MCHPFSUSB%20v2.3%20Installer.zip

a) Multiple top-level collection
Start with the "USB Device - HID - Keyboard" example

a-1) Descriptor work

VID/PID
Change VID/PID (at least PID) to your custom one - to avoid conflict with the original.
As long as the device stays on your desktop, you can apply any VID/PID, temporarily.
The registered VID\PIDs on your Windows are listed up on this registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\
OR, view it on USBDeview.
Choose a pair of VID/PID which is not shown on this list.
When you release your product, get an official VID/PID for your device.

usb_config.h
#define MY_VID 0x04D8 // original for keyboard example
#define MY_PID 0x0055

Report descriptor
- Copy the contents of the mouse report descriptor from "USB Device - HID - mouse" example
- Append it after the keyboard report descriptor, and make a single report descriptor as a whole.
- Add report IDs to each top-level collection.


usb_descriptors.c

//Class specific descriptor - HID mouse (? <-- keyboard :-)
ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={
// keyboard top-level collection
{ 0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x06, // USAGE (Keyboard)
0xa1, 0x01, // COLLECTION (Application)
0x85, 0x01, // REPORT_ID (1) <------------
...
0xc0,

// mouse top-level collection
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x02, /* Usage (Mouse) */
0xA1, 0x01, /* Collection (Application) */
0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x00, /* Collection (Physical) */
0x85, 0x02, /* REPORT_ID (2) */ <------------
...
0xC0, 0xC0}
};/* End Collection,End Collection */



- Tune the report descriptor size
- Increase the packet size of interrupt IN endpoint from 8 to 9 (for Report ID)

usb_config.h
#define HID_INT_OUT_EP_SIZE 4
#define HID_INT_IN_EP_SIZE 9
#define HID_RPT01_SIZE (63 + 2 + 50 + 2) // keyboard + report ID + mouse + report ID


usb_descriptors.c

/* Configuration 1 Descriptor */
ROM BYTE configDescriptor1[]={
...
/* HID Class-Specific Descriptor */
0x09,//sizeof(USB_HID_DSC)+3, // Size of this descriptor in bytes RRoj hack
DSC_HID, // HID descriptor type
DESC_CONFIG_WORD(0x0111), // HID Spec Release Number in BCD format (1.11)
0x00, // Country Code (0x00 for Not supported)
HID_NUM_OF_DSC, // Number of class descriptors, see usbcfg.h
DSC_RPT, // Report descriptor type
DESC_CONFIG_WORD( HID_RPT01_SIZE ), // Size of the report descriptor <------------
...
/* Endpoint Descriptor */
0x07,/*sizeof(USB_EP_DSC)*/
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
HID_EP | _EP_IN, //EndpointAddress
_INTERRUPT, //Attributes
DESC_CONFIG_WORD(9), //size <------------
0x01 //Interval



a-2) Request support
Standard request:
Get_Descriptor( HID_REPORT )
- Automatically tuned by sizeof(hid_rpt01) in usb_function_hid.c - no modification required.

Class specific requests:
As Microchip cunningly cut the corner, these request handling will pass USBCV without further modification. But if you want to be compliant to the HID spec, implement the request handling more properly.
- Copy the contents of usb_function_hid.c USBCheckHIDRequest() to Keyboard.c USBCBCheckOtherReq()
- Modify these request handlers

Get_Report( INPUT ):
Return current 'snapshot' report of keyboard or mouse
- SetupPkt.W_Value.byte.HB specifies the report type (1: input, 3: feature)
- SetupPkt.W_Value.byte.LB specifies the report ID (1: keyboard, 2: mouse) of the target
- The report format is same as the interrupt endpoint, as follows.

Get_Idle/Set_Idle:
Implement these request for keyboard and mouse separately.
- make 'idle_rate' variables for keyboard and mouse, respectively.
- SetupPkt.W_Value.byte.LB specifies the report ID (1: keyboard, 2: mouse)
- Copy and modify the original GET_IDLE and SET_IDLE handler for keyboard and mouse.
- The default value of 'idle_rate' is 0 (infinite).

Reference sections on the HID spec,
Appendix C: Keyboard Implementation (HID1_11.pdf p62)
Appendix F.3 Boot Keyboard Requirements (HID1_11.pdf p74)
http://www.usb.org/developers/devclass_docs/HID1_11.pdf

The keyboard report descriptor defines OUTPUT report, but Set_Report( OUPUT ) is not implemented.
Set_Report( OUTPUT )
- SetupPkt.W_Value.byte.HB specifies the report type (2: output, 3: feature)
- SetupPkt.W_Value.byte.LB specifies the report ID (1: keyboard, 2: mouse) of the target
- set another handler to outPipes[0].pFunc. This handler is called after DATA stage.
Copy usb_function_cdc.c USBCheckCDCRequest() SET_LINE_CODING, and modify it.


a-3) Interrupt endpoint support

In Keyboard.c ProcessIO(), replace Keyboard() as follows

First, Run the device specific task, like keyscan, mouse click check, etc
Then,

if(!HIDTxHandleBusy(lastTransmission)) {
if (active_protocol == 1) { // Report protocol
if (mouse_moved) {
// make up mouse report
lastTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x04); // send Report_ID + 3 byte
} else if (any_key_chenge) {
// make up keyboard report
lastTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x09); // send Report_ID + 8 byte
}
} else { // boot protocol
// make up keyboard report
lastTransmission = HIDTxPacket(HID_EP, (BYTE*)hid_report_in, 0x08); // usual 8 byte
}
}


As a boot keyboard, send the input report for every interrupt IN transaction.

For report protocol, either keyboard or mouse report, the input report starts with the report_ID (keyboard: 1, mouse: 2). After this report_ID, usual input report for keyboard or mouse follows.

See this post for the format of (usual) 8 bytes keyboard input report.
"USB HID KEYBOARD" on SiLabs USB Forum
http://www.cygnal.org/ubb/Forum9/HTML/001381.html

For the mouse input report,
B.2 Protocol 2 (Mouse) (HID1_11.pdf p61)

Tsuneo

[EDIT]
Add these lines to a-1) Descriptor work
#define HID_INT_OUT_EP_SIZE 4
#define HID_INT_IN_EP_SIZE 9
post edited by chinzei - 2008/10/14 02:00:18
#26
Elisandra
Starting Member
  • Total Posts : 83
  • Reward points : 0
  • Joined: 2007/08/10 12:55:45
  • Location: Brazil
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 07:45:55 (permalink)
0
Hi!

Sorry for taking so long to answer... And thanks for your help! Smile

@ violin
(her is the correct pronoun Smile).
I think we are not talking about the same thing. I'm not doing a converter.. my original idea was to implement a Keyboard + generic HID device. I guess the mouse came up because the example I'm adapting was of a mouse + a gamepad. Or maybe because I'm asking my questions on someone else thread grin sorry about that by the way, I should have started my own thread on this subject.

@ Dario
As for one button sending CTRL-C, I've done it in the past many times, using a singe keyboard device.

I can see that things could possibly get more complicated if you are going to make a device with a "boot" interface such as a keyboard, and a "non-boot" one - the generic HID.

Yes, I've done it too, but I don't want to change the firmware and program my board every time I want to change buttons functions. I don't know how to do it using just a keyboard. As I have some (little) experience with generic HID, I though I could make a composite device (Keyboard + generic) and configure my keyboard through the generic device. So I could also learn about composite devices.

@ Tsuneo
wow, great explanation! thank you! I've tried to use two reports, my device was enumerated correctly, but I didn't know all the necessary changes, so I couldn't communicate with it. I have some experience using the framework, I'm very far from being experienced with USB. After this explanation, I think it worth to try it again.

Right now, I'm using an example found in this forum (http://forum.microchip.com/tm.aspx?m=366157), using 2 interfaces. It worked fine with the keyboard and the generic with one IN endpoint. It's also working now with keyboard + generic with one OUT endpoint. But I'm still not able to do a keyboard + generic with one IN and one OUT endpoint. In this case it fails enumeration.

For my device, a keyboard + generic with OUT endpoint "solves" the problem, I can configure my buttons. For me, it's still not enough, I want to be able to do a composite device properly. As I told you before, I'm working on this on my free time, which is rare now Smile. I'll study more, I must understand better the protocol in order to understand better the framework and be able to make the changes I want to. I don't want to bother you guys with my questions forever!
I'll try to follow Tsuneo's steps. If I have any progress I'll report here.

Regards!
Elisandra

#27
violin
Super Member
  • Total Posts : 3301
  • Reward points : 0
  • Joined: 2005/05/09 04:59:48
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 10:15:25 (permalink)
0
"Circle mouse" is one of the example firmware in Microchip's USB firmware framework.
For HID/Boot Protocol/etc you can go to http://www.usb.org.

 
Ah. Thanks for that.

You are right that many USB mouse/keyboard will support both USB and PS/2 protocol and you only need to use cheap passive converters ( connection: http://pinouts.ru/InputCables/usb_ps2_mouse_pinout.shtml ) to use it.

However this is not always true.
http://en.wikipedia.org/wiki/PS/2_connector

quote:


Today's laptops frequently do not include PS/2 ports and so the port is now regarded as a legacy port on Wintel, having been superseded by USB. Many current keyboards and mice support both USB and PS/2 with a simple wiring adapter and active adapters are available which plug into a USB port and provide a pair of PS/2 ports.



The keyword here is "many", which means not all will support both USB and PS/2.

On the other hand, if you want to use your PS/2 keyboard on USB ports, you need some active electronics. I bought a cheap one (just for testing purpose) and it seems to work fine but it does not support the multimedia key. It is something like this (I bought from local shop here in Singapore).
http://sewelldirect.com/usbtops2.asp

 
I am not fully understanding in what you are saying. My intention is not to switch keyboards from PS/2 to USB but directly to hardwire it to microcontroller, in which can successfully do. BTW, I have successfully dealt with the glitch in the occasional miss keystroke that I was experiencing.
 
So far as already mentioned I have only hardwired a PS/2 connection to a microcontroller and for experience I was thinking of hardwiring a USB one to it, although this is not entirely necessary as the PS/2 connection keyboard works well as I now have experienced and only need one type of connection keyboard to do in what I am intending to do with it.
 
With the mouse I am well and truly satisfied with the way it functions and also with my coding. I even tried it out today with a USB wireless mouse and it work well, as if I knew it wouldn’t. Smile  Regards


 
#28
violin
Super Member
  • Total Posts : 3301
  • Reward points : 0
  • Joined: 2005/05/09 04:59:48
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 10:23:27 (permalink)
0
@ violin
(her is the correct pronoun Smile).
I think we are not talking about the same thing. I'm not doing a converter.. my original idea was to implement a Keyboard + generic HID device. I guess the mouse came up because the example I'm adapting was of a mouse + a gamepad. Or maybe because I'm asking my questions on someone else thread grin sorry about that by the way, I should have started my own thread on this subject.

 
Hi. Sorry for jumping in. Although I am still not entirely clear in your implementation of your application, even though I guess we are both on different lines. Regards

 
#29
fabim
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2008/10/14 11:18:56
  • Location: 0
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 11:28:03 (permalink)
0
pink

Hi
  I am new to this wonderful forum, I am the world and work with microchip products to 8 years.
  I am a long time looking for information on how to join HID USB-2 components in the same uController.
  My project is a special mouse for people with physical disabilities.
  The mouse will have some features of keyboard to keyboard shortcuts.
  I am searching the forum, until I found something in this post here, but not for C18 and PIC18F.
  If possible, I would like to help in this battle.
  Simple example of how to constitute a search with 2 components hid mouse and keyboard.
  Grateful.
#30
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 13:41:24 (permalink)
0
Still continues Smile

b) Composite device
We are going to combine "USB Device - HID - Keyboard" and "USB Device - HID - mouse"

b-0) Preparation before union of two devices
Unfortunately, this USB implementation doesn't suppose such a composite device of the same class. The 'namespaces' (#define, variables, arrays and subroutine name) overlap on the two interfaces of the same class. Then, split the namespace on a working copy first.

Copy the entire code of "USB Device - HID - mouse" to a working folder.
Copy usb_function_hid.c and usb_function_hid.h to the working folder, too, and rename these two files. Of course, replace these two files on the IDE work space after renaming them.
usb_function_hid.c ---> usb_function_hid_m.c
usb_function_hid.h ---> usb_function_hid_m.h

In this stage, build and run the project once to check this modification.
You may see the error of include file name - fix it


On usb_function_hid_m.c and usb_function_hid_m.h,
rename the variables and subroutines defined in these files, like

BYTE idle_rate; ---> idle_rate_m
BYTE active_protocol; ---> active_protocol_m
BYTE hid_rpt_rx_len; ---> hid_rpt_rx_len_m

- USBCheckHIDRequest() ---> USBCheckHIDRequest_m()
- HIDGetReportHandler() ---> HIDGetReportHandler_m()
- HIDSetReportHandler() ---> HIDSetReportHandler_m()

Build the project, and you'll see errors that the original variables and subroutines are not found. Using this error, rename the references, too. Run and test again.

Next, move the address of the endpoint.
On usb_config.h,
- Increase USB_MAX_EP_NUMBER from 1 to 2
- Rename #define's on the ENDPOINTS ALLOCATION section
- Change the HID_EP_M from 1 to 2 (endpoint address)


usb_config.h

/** DEFINITIONS ****************************************************/
...
#define USB_MAX_NUM_INT 1 // change this number afterward
#define USB_MAX_EP_NUMBER 2 // <---- to move the endpoint

/** ENDPOINTS ALLOCATION *******************************************/
/* HID */
#define HID_INTF_ID_M 0x00 // change the IF number afterward
#define HID_EP_M 2 // <--- end point address
#define HID_INT_OUT_EP_SIZE_M 3
#define HID_INT_IN_EP_SIZE_M 3
#define HID_NUM_OF_DSC_M 1
#define HID_RPT01_SIZE_M 50

- Add arrays to the USB RAM space on usb_function_hid_m.c
- Replace ALL hid_report_in to hid_report_in_m on mouse.c

usb_function_hid_m.c
// Add these arrays
#pragma udata USB_MOUSE_BUF = 0x500
volatile unsigned char hid_report_out_m[HID_INT_OUT_EP_SIZE_M];
volatile unsigned char hid_report_in_m[HID_INT_IN_EP_SIZE_M];
#pragma udata

usb_function_hid_m.h
extern volatile unsigned char hid_report_out_m[HID_INT_OUT_EP_SIZE_M];
extern volatile unsigned char hid_report_in_m[HID_INT_IN_EP_SIZE_M];

- Rename hid_rpt01 to hid_rpt01_m on usb_descriptors.c
ROM struct{BYTE report[HID_RPT01_SIZE_M];}hid_rpt01_m={

Build the project, check errors, rename the references and test run.


Now, solid code with separated namespace is established.
At last, these two devices are combined into a composite device.
We use a merge utility to work out this step, for example,

WinMerge http://www.winmerge.org/

Comparing the files of the same name from the two project, merge the two devices into composite one. Merge utility highlights the difference we made on above step. It helps us to find the part to be merged, or modified.
On the next steps, modified mouse example is merged to the keyboard example.

b-1) Descriptor work

VID/PID
Change VID/PID to your custom one, as usual

Descriptors

usb_descriptors.c
- Copy Interface, HID class and endpoint descriptors from mouse example
- Append it after the endpoint descriptor of the keyboard

- Tune the descriptors,
Configuration Descriptor - Total length (0x0022 * 2 - 9)
Configuration Descriptor - Number of interfaces (2)
mouse Interface Descriptor - Interface Number (1)

- Copy the report descriptor from the mouse example.

In usb_config.h
- USB_MAX_NUM_INT: from 1 to 2
- USB_MAX_EP_NUMBER: from 1 to 2
- Copy all #define's of HID section from mouse example
- change HID_INTF_ID_M to 1

usb_config.h
/** DEFINITIONS ****************************************************/
// change the values
#define USB_MAX_NUM_INT 2 // number of interfaces
#define USB_MAX_EP_NUMBER 2 // number of endpoints pairs (IN/OUT)

/** ENDPOINTS ALLOCATION *******************************************/
/* HID */
#define HID_INTF_ID_M 0x01 // <---- change to 1
#define HID_EP_M 2
#define HID_INT_OUT_EP_SIZE_M 3
#define HID_INT_IN_EP_SIZE_M 3
#define HID_NUM_OF_DSC_M 1
#define HID_RPT01_SIZE_M 50


b-2) Request support

Class specific request

- Copy usb_function_hid_m.c and usb_function_hid_m.h to the keyboard project.
- Rewrite USBCBCheckOtherReq() (keyboard.c) to support mouse interface

keyboard.c

void USBCBCheckOtherReq(void)
{
// dispatch request to specified interface by wIndex
switch ( SetupPkt.wIndex ) {
case HID_INTF_ID: USBCheckHIDRequest(); break;
case HID_INTF_ID_M: USBCheckHIDRequest_m(); break;
default: break;
}
}//end


b-3) Interrupt endpoints support

- Join ProcessIO() (keyboard.c)
- Drag mouse-specific routines into keyboard.c

keyboard.c

void ProcessIO(void)
{
//Blink the LEDs according to the USB device status
BlinkUSBStatus();

// User Application USB tasks
if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) return;

//Call the function that behaves like a keyboard
Keyboard();


// imported from mouse example
if(Switch3IsPressed()) //Note: Switch3IsPressed() implements only the
{ //.....
//is not implemented in this example.
emulate_mode = !emulate_mode;
}

//Call the function that emulates the mouse
Emulate_Mouse();

}//end ProcessIO


I think I list up most of the modification here, but please compare the files well and check the difference.


As above modification shows, multiple top-level collections share the requests and the interrupt endpoint. The addition of another HID device(s) doesn't change the basic stack structure so much. It is implemented at the each subroutine level. The report ID identifies the devices. As the result, modification is simpler. Instead, as the bandwidth of the single interrupt endpoint is also shared, the response decreases along with the number of implemented devices.

For composite device, on the other hand, devices are independent at the interface level. Each device has its own interface and endpoint, its own request and endpoint handlers. Then, we have to duplicate these stuffs to implement it. The structure of the stack are modified so much. But the performance on the interrupt endpoint is the same as the original devices.

Tsuneo
#31
DarioG
Allmächtig.
  • Total Posts : 54081
  • Reward points : 0
  • Joined: 2006/02/25 08:58:22
  • Location: Oesterreich
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 15:19:57 (permalink)
0
Thanks Tsuneo - I did do almost all of the steps you 're suggesting here Smile in my mouse+keyboard.
That's a great tutorial, for example I can see I missed handling the 2 Idle settings separately.

@Elisandra: I understand you, I did do a re-configurable USB keyboard using a RS232 link to program it... of course, such a waste Smile but it was 2003 or so.
Hope you get the expected results and tell us how to do it grin

GENOVA :D :D ! GODO
#32
muhzd
Super Member
  • Total Posts : 861
  • Reward points : 0
  • Joined: 2008/05/15 10:43:19
  • Location: Malaysia
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/14 22:49:24 (permalink)
0
Thanks chinzei. this is very informative and usefull. I know ill be working on this too one day. so im subscribing.
[8D]
[8|]
post edited by muhzd - 2008/10/15 09:11:37
#33
Elisandra
Starting Member
  • Total Posts : 83
  • Reward points : 0
  • Joined: 2007/08/10 12:55:45
  • Location: Brazil
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/15 06:25:35 (permalink)
0
Hi!

Thank you Tsuneo!! Your explanation is so clear that now the points I was missing seems quite obvious... It would never work the way I was trying to implement it grin I'll try both methods as soon as I have some free time.

@ Dario: I think I'll only have some free time by the weekend, but as soon as I get positive results I'll post them here.

Best regards!
Elisandra
#34
chinzei
Super Member
  • Total Posts : 2250
  • Reward points : 0
  • Joined: 2003/11/07 12:39:02
  • Location: Tokyo, Japan
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2008/10/29 20:19:51 (permalink)
0
Correction for my above comment,
Original: chinzei

VID/PID
Change VID/PID (at least PID) to your custom one - to avoid conflict with the original.
As long as the device stays on your desktop, you can apply any VID/PID, temporarily.
The registered VID\PIDs on your Windows are listed up on this registry key.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\
OR, view it on USBDeview.
Choose a pair of VID/PID which is not shown on this list.
When you release your product, get an official VID/PID for your device.


In my above comment, I missed about the registered INF files.
To select a temporary VID/PID for development, the check on the hardware registry key is not enough. It may still cause VID/PID conflict with the registered INF files.

The registered INF files are held in this folder.
C:\Windows\inf\

As the default, this folder is invisible. You'll need to change the folder option to see this folder on the explorer.

After choosing a candidate of the temporary VID/PID,
Search all .inf files in this folder using an utility like Grep, or multi-file search of your favorite text editor, or Windows search companion (search contents) from the start button.

The search string is,

USB\VID_vvvv&PID_pppp

where, vvvv / pppp - 4 digit HEX number of the VID/PID candidate.
Enable "ignore Capital" option.

When no INF file holds this candidate VID/PID, the VID/PID is actually unique on your PC.

Tsuneo
post edited by chinzei - 2008/10/29 20:36:47
#35
prrole
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2008/02/13 06:28:47
  • Location: 0
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2009/01/20 10:28:02 (permalink)
0
A zip file with working project for composite using 2.3 would be hugely appreciated.



#36
GGory
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2009/02/24 02:18:16
  • Location: 0
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2009/02/24 02:24:55 (permalink)
0
Here is my working project for the composit keyboard and mouse (b version). Maybe you need to set up project options for your taste.
What I use is 18F4550 with PDFSUSB bootloader, not the HID one. So if you use HID bootloader you have to uncomment the lines for that and change the linker script.
#37
GGory
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2009/02/24 02:18:16
  • Location: 0
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2009/02/24 02:40:40 (permalink)
0
I have a question about composit keyboards. I would like to modify the above attached device with the followings
I started adding multimedia and power (sleep, wake up..) functions to the keyboard and scroll function to the mouse. But it is important to be boot keyboard and for the mouse to be boot mouse for BIOS.

I used the 2 endpoints which is the maximum for low-speed devices. So I think I have to make collections to succesfully do the job. (like in the solution a, above) So I added Report ID's to the keyboard and did another collection for power management buttons. My question is If I do it in this way, will my keyboard remain boot keyboard for BIOS? And what is the disatvantage of that solution.

In an earlyer post I saw that for boot device I can send 8 bytes and for operating systems, I can send 9 bytes. But how can I differenciate when the device should send the report for boot and when can it send the one with different Report ID's?

Thanks for the answerd
#38
potyo
Starting Member
  • Total Posts : 74
  • Reward points : 0
  • Joined: 2006/06/12 16:23:48
  • Location: Ada, Serbia
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2009/02/24 03:57:20 (permalink)
0
Why don't use Full speed and more endpoints?
#39
GGory
New Member
  • Total Posts : 7
  • Reward points : 0
  • Joined: 2009/02/24 02:18:16
  • Location: 0
  • Status: offline
RE: HID boot-keyboard & mouse on same device? 2009/02/24 04:28:17 (permalink)
0
Szia Potyo :)

I thought HID keyboards and mouse must be low-speed devices. Especially boot devices. Or they must not?
I would not like to install drivers for my device, instead I want to use the inbuilt windows drivers.
#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5