Pro Micro used as a gamepad and mouse/keyboard

Hi all

So I am trying to program a pro micro to act as either a gamepad or a keyboard/mouse depending on whether a certain switch is on/off.

I have managed to program the micro to act as either a gamepad OR a keyboard/mouse but cannot get it to switch between these within the script (i.e. the pro micro will act as EITHER mouse/keyboard or a gamepad depending upon which program I upload).

If I upload the script attached it will do what I want it to (i.e. be a keyboard/mouse when switch 9 is HIGH but a gamepad when switch 9 is LOW) but only in Windows operating system (I want it to work with a raspberry pi in emulation station).

If I try to use this with emulation station on the raspberry pi it does not recognise any of the keys (or the pro micro itself).

I have provided the script below but have narrowed down the problem to the inclusion of the Mouse.h library. Without this library included the gamepad is recognised within emulation station however I cannot then use the micro as a mouse :frowning:

Does anyone have any suggestions to this? At the moment the only resolution I can see is to use 2 pro micros programmed as either a gamepad or a keyboard/mouse and physically disconnecting the one and connecting the other to the pi but this seems a bit extreme.

Many thanks

Luke

InitialJoystickTestGamePadAndKeyboard3.ino (7.69 KB)

luke1i1:
I have provided the script below but have narrowed down the problem to the inclusion of the Mouse.h library.

No script attached.

Only a useless ".pdf" file.

Need to read the instructions as to how to ask questions here.

Sorry I did try to attach the script but it keeps throwing up an error message when I try to download it. I don't suppose you know what I need to do so you can access it?

Thanks once again

Luke

I know what you can do to accwss it. Read the link Paul__B gave you and look at #7

It is over 9000 characters...

luke1i1:
If I try to use this with emulation station on the raspberry pi it does not recognise any of the keys (or the pro micro itself).

The way i read this, your rpi does not recognise the micro, so the problem lays there?
What c does show up when you run this command on your pi

Anne maybe you can try on the rpi forum too? Doesn't look like an arduino problem since your arduino setup works on windows but not on your pi

$ dmesg | grep tty

Try it without arduino connected and then with your arduino connected. It should show up there

Thanks for the response. The pro micro does work on emulation station if I only upload the gamepad script without the mouse/keyboard libraries (sorry I should have made that clearer).

I will have a look on the raspberry pi forum. Thanks again