Skip to content

Example code for handling both keyboard AND mouse ? #17

Open
@Pigeo

Description

@Pigeo

I tried to merge the keyboard and mouse examples into one single example that would allow me to plug-in either a keyboard OR a mouse, without having to recompile each time I want to change between mouse and keyboard.

I tried the following, without success :

// Initialize USB Controller
USBHost usb;
// Attach mouse controller to USB
MouseController mouse(usb);
// Attach keyboard controller to USB
KeyboardController keyboard(usb);

=> It seems this library doesn't support having two controllers on the same USBHost instance. Could you confirm that ?

Then I tried the following, which also didn't work :

// Initialize USB Controller
USBHost usb1;
USBHost usb2;
// Attach mouse controller to USB
MouseController mouse(usb2);
// Attach keyboard controller to USB
KeyboardController keyboard(usb1);

=> Could you tell me which one of these two approaches should be the good one ? And then I suggest to add in the source code some assertions to avoid users making forbidden things (putting two controllers on the same USBHost instance and/or creating two USBHost instances at same time, etc.)

The idea behind that request, is I want to be able to use a mouse connected to my DUE, and sometimes, but rarely, I want to be able to disconnect the mouse, put a keyboard instead, type some phrase on it, and then remove it and plug-in the mouse again.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions