Composite Keyboard + Mouse

Composite Keyboard + Mouse

Postby Dren » Tue Aug 09, 2016 4:50 pm

Hello,

I am trying to use a PIC24EP256GU814 to connect to a PC via USB and appear as a standard multimedia Keyboard AND mouse.
This PIC is not supported by the MCC or Harmony, but I managed to get the MLA examples running and it appears and works as either a HID_Keyboard or a HID_Mouse.

The trouble I am having is setting it up as a composite device so that it appears as both. I managed to edit the declaration and while it enumerates successfully in windows 10, it no longer works as a keyboard or a mouse.

Has anyone else done a project like this ? Do you have some example code you don't mind sharing the USB part of ?

All the best

Dren
Dren
 
Posts: 9
Joined: Fri Jul 15, 2016 9:05 am
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby Dren » Wed Aug 10, 2016 12:15 pm

I tried posting this reply on Microchip forums... gave up !!!

When I send a report I send either a keyboard report or a mouse report, which works fine when the USB is declared as a keyboard or mouse. When the USB is declared as a composite device, I still sending the same Keyboard report, do I need to send a composite report ? I thought that the 2 devices would be independent ? There is only 1 input report ?

Personally I feel like wiping the whole lot and starting from scratch with a new microprocessor, this is wasting days of my time ! However amateur and messy the USB framework is below the waterline, the User interface should be nice and clear. ONE file that sets up the descriptor and ONE file that handles the interface, all the other repeated defines + status checking + rubbish (even clutter in MAIN !) should be swept away behind the scenes. Oh and the ridiculously complex interdependences of the USB Stack files sorted out.. You define and enumerate what you need in a main USB header, NOT merrily create them willy-nilly as you go along ! BTW why is it USB Stack, with a SPACE ! That throws out command line compilers, keep to a standard, say usb or USB or even USBStack or USB_Stack. Then the MLA itself has dozens and dozens of copies of the same dozen USB files, why not a common directory ? In fact why so many files in the first place ?

case you hadn't guessed I have really had enough of trying to working with this really disappointing framework code. I just haven't got the time to waste so much of it getting to understand this badly written microchip muddle. Esp when I shouldn't need to !

I needed to let off some steam... ahhhhh that's better. Now a cup of tea, then I can get back to it... thinking good thoughts....
Dren
 
Posts: 9
Joined: Fri Jul 15, 2016 9:05 am
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby vloki » Wed Aug 10, 2016 12:29 pm

Dren wrote:BTW why is it USB Stack, with a SPACE ! That throws out command line compilers, keep to a standard, say usb or USB or even USBStack or USB_Stack.

What version you are talking about?
vloki
Verified identity
 
Posts: 162
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby Dren » Wed Aug 10, 2016 2:03 pm

In the very few example projects I could find, the usb stuff is all in a directory called "USB Stack" ... .err... not that THAT really matters. I am actually more concerned about getting something working TBH.
Dren
 
Posts: 9
Joined: Fri Jul 15, 2016 9:05 am
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby NorthGuy » Wed Aug 10, 2016 4:19 pm

I don't know how the framework works, but composite device is relatively simple. You change your descriptor so that it assigns some endpoints to mouse and some endpoints to keyboard. Each device gets its own HID interface. Then you use mouse endpoints to send/receive reports for the mouse, and you use keyboard endpoints to send/receive reports for the keyboard.
User avatar
NorthGuy
Verified identity
 
Posts: 17
Joined: Sat Jul 30, 2016 3:08 am
PIC experience: Professional 2-5 years with MCHP products

Re: Composite Keyboard + Mouse

Postby Dren » Thu Aug 11, 2016 12:37 pm

The framework seems to be a nightmare of bad coding and obscurity. Oh you make it all sound so simple and really it SHOULD be that easy.

HOWEVER... How does that work with the framework ? For example, I just tried setting USB_MAX_NUM_CONFIG_DSC to 2, as I have a keyboard and mouse is that 2 ? As they are combined is that 1 ? As it is a multimedia keyboard is that 3 ? I have no idea what to do and no idea where to even find the information to use it ?

How do I send information to the PC as a mouse and/or keyboard using the framework ? Do I need to edit the report in some way ? Without any user guide I am trying to reverse engineer the most appalling code I've seen for years, and figure out how to use it when I also have limited knowledge of USB.

I have a working demo of a keyboard and I have managed to get the multi enumeration correct, err.. now what do I do ?
Dren
 
Posts: 9
Joined: Fri Jul 15, 2016 9:05 am
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby NorthGuy » Thu Aug 11, 2016 4:14 pm

Sorry, I didn't use the framework. When I needed USB, I decided not to waste a bit of my time studying libraries. I studied USB documentation and the datasheet for the PIC. It took me a weak of hard work before my device could transmit data, then another week to make it work at desired speed across OSes and USB controllers. So what? People may spend much longer with the libraries if thing don't work immediately out of the box, and then they say: "It took me weeks to make the USB library work as I need. Don't even think doing it without the library, it's so complex." Most importantly, if I need a USB device for another project, I will do it real quick, because now I know how.
User avatar
NorthGuy
Verified identity
 
Posts: 17
Joined: Sat Jul 30, 2016 3:08 am
PIC experience: Professional 2-5 years with MCHP products

Re: Composite Keyboard + Mouse

Postby vloki » Thu Aug 11, 2016 4:27 pm

Dren wrote:The framework seems to be a nightmare of bad coding and obscurity.

Seems you are not using the actual MCHP usb libraries. I think it is a nightmare too for beginners
because of the dozens of configurations for different PICs and boards but you may have a look here
-> http://www.microchip.com/mplab/microchi ... plications
vloki
Verified identity
 
Posts: 162
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby Dren » Mon Aug 15, 2016 10:46 am

Yes I am using the latest MLA microchip libraries and after a few frustrating weeks trying to use them I am more certain than ever that they are the work of an incompetent engineer.

I can only assume that they were deliberately designed in a such an idiotic manner to make them obscure. They are amateur, badly written, fragile and INSANELY broken down into horribly interdependent files, poor structure, poor design, poor implementation. Weeks of my time wasted on them (so far), I could rant on for a while... (oh trust me I really could !)

I wish I had adopted NorthGuy's approach, by now I would both have it working and understand USB in depth.

To sum it up, in my professional opinion, the MLA USB is just one huge steaming pile of poo !
Dren
 
Posts: 9
Joined: Fri Jul 15, 2016 9:05 am
PIC experience: Professional 5+ years with MCHP products

Re: Composite Keyboard + Mouse

Postby vloki » Mon Aug 15, 2016 1:19 pm

Dren wrote:Yes I am using the latest MLA microchip libraries

Dren wrote:In the very few example projects I could find, the usb stuff is all in a directory called "USB Stack" ... .err... not that THAT really matters. I am actually more concerned about getting something working TBH.

I have 6 Versions of MLA installed on my computer but there is no directory called "USB Stack" nor anything similar.
Attachments
screenshot26.png
screenshot26.png (2.47 KiB) Viewed 915 times
vloki
Verified identity
 
Posts: 162
Joined: Wed May 28, 2014 8:42 am
Location: Germany
PIC experience: Professional 5+ years with MCHP products

Next

Return to USB

Who is online

Users browsing this forum: No registered users and 1 guest

cron