Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:42 13 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Pico As HID Mouse

Author Message
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 11:17pm 24 Nov 2024
Copy link to clipboard 
Print this post

I have been looking at using the Waveshare RP2040-Zero as a HID device.

I am using the Arduino Leonardo know as BadUSB to give me keyboard and mouse
operations with the push of a single key.

My next step is to add SDcard with definitions for each button so no need to
redo the program with new changes in what buttons do.

Eventually looking to build this.



While looking I found
Pico as mouse


 His PCB could find other one time uses for PioMite projects.

Have FUN
Quazee137
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2542
Posted: 11:30pm 24 Nov 2024
Copy link to clipboard 
Print this post

I got usb wireless kb with mouse pad and works with pico usb vga/hdmi
does what you want and can be standard kb and mouse
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 06:48am 25 Nov 2024
Copy link to clipboard 
Print this post

What it will do is map keys from keypad to keyboard and mouse functions.
 Not pass on the keys on the keypad but a macro that can be mixed key and mouse
 under any key. The map would be on the SDcard so the mapping can be done
 without reprogramming the pico.

 I am using custom mapped alt+x keys to do things as I can not use my right
 hand yet. Here is my Minecraft 5 button arduino device. Saves me a lot of
 typing that is hard to do one handed.

#include <Keyboard.h>             //Including the keyboard library
#include <Mouse.h>                //Including the mouse library

void setup() {
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(9, INPUT_PULLUP);
pinMode(14, INPUT_PULLUP);
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);

Keyboard.begin();
Mouse.begin();

}

void loop() {

while (digitalRead(10) == HIGH) {
}

if (digitalRead(11) == LOW) {

Mouse.press(MOUSE_RIGHT);
delay(50);
Mouse.release(MOUSE_RIGHT);
delay(50);
Keyboard.press(KEY_LEFT_SHIFT);
delay(200);

Mouse.click();
delay(200);

Mouse.click();
delay(200);

Mouse.click();
delay(200);

Mouse.click();
delay(200);

Mouse.click();
delay(200);

Keyboard.press(KEY_ESC);
delay(100);
Keyboard.release(KEY_LEFT_SHIFT);
Keyboard.release(KEY_ESC);
delay(250);

}

 if (digitalRead(9) == LOW) {

   delay(100);
   Keyboard.write('t');
   delay(100);
   Keyboard.write('/');
   Keyboard.write('s');
   Keyboard.write('e');
   Keyboard.write('l');
   Keyboard.write('l');
   Keyboard.write(' ');
   Keyboard.write('h');
   Keyboard.write('a');
   Keyboard.write('n');
   Keyboard.write('d');  
   Keyboard.write(10);
   delay(250);
}

 if (digitalRead(14) == LOW) {
   Keyboard.write('t');
   delay(100);
   Keyboard.print("/nv");
   Keyboard.write(10);
   delay(250);
   }

 // to be mapped to asd movement keys used in minecraft
 // or add analog joystick
 if (digitalRead(A0) == LOW) { Keyboard.write('s'); }
 if (digitalRead(A1) == LOW) { Keyboard.write('a'); }
 if (digitalRead(A2) == LOW) { Keyboard.write('d'); }

 if (digitalRead(16) == LOW) {

   Keyboard.write('t');
   delay(100);
   Keyboard.write('/');
   Keyboard.write('u');
   Keyboard.write('s');
   Keyboard.write('e');
   Keyboard.write(' ');    
   Keyboard.write('v');
   Keyboard.write('i');
   Keyboard.write('s');
   Keyboard.write('i');
   Keyboard.write('t');
   Keyboard.write(' ');
   Keyboard.write('o');
   Keyboard.write('r');
   Keyboard.write(' ');
   Keyboard.write('w');
   Keyboard.write('a');
   Keyboard.write('r');
   Keyboard.write('p');
   Keyboard.write('s');
   Keyboard.write(' ');
   Keyboard.write('h');
   Keyboard.write('a');
   Keyboard.write('v');
   Keyboard.write('e');
   Keyboard.write(' ');
   Keyboard.write('F');
   Keyboard.write('U');
   Keyboard.write('N');
   Keyboard.write(' ');
 delay(250);
   Keyboard.write(10);
 delay(250);

 }
}




 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 07:32am 25 Nov 2024
Copy link to clipboard 
Print this post

Hi Quazee,

In stead of providing key maps on SD card, you could provide the whole MMBasic program on SD card. Will make is easier for the sequences and timing). Your pico zero should only have a "load program" in a flash slot, and autorun that flash slot at power up.

The thing I fail to see, is the USB wireless receiver. Typically that plugs into a PC (where Minecraft resides). But the transmitter. Where do you purchase that ? Or are you planning to reverse engineer a wireless mouse and keyboard for the wireless section.

I have not ever played Minecraft, but did play the linux clone MineTest. It is fun to do, and when you have a mission, it can occupy your mind for hours..

Regards,

Volhout
Edited 2024-11-25 17:33 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 08:14am 25 Nov 2024
Copy link to clipboard 
Print this post

Volhout the USB wireless receiver comes with the keypad which has
 the transmitter built in. I guess no one is understanding what this
 is to do.

 I am using the keypad as my first test but the pico part would be able
 to have any keyboard plugged in and send the macro for the pressed key
 out to the computer. With a full keyboard one could map a lot of words
 and mouse functions being sent to the computer. Best part it should be
 OS independent Linux, Windows ?Mac. Would act as if someone typing or
 using mouse. There are very costly macro keyboards that do some of what
 I want this to do.

 Think of it like this I have my main keyboard plugged in if you plug in
 a 2nd they act the same. Press "A" on ether and get and "A".

 Using this idea your main still sends and "A" for the A key but the keyboard
 plugged into the device would send "Hello world. How are you?" as that is what
 remapped when the "A" is sent by the 2nd keyboard. The pico gets the keys from
 2nd keyboard and looks up what to send from the SDcard.

 Hope this is a better description its function.

 Have FUN
 Quazee137 "this took some time to type one handed lots of fixing"
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 08:27am 25 Nov 2024
Copy link to clipboard 
Print this post

Thanks,

Makes ense now. Sorry you had to go though so many challenges to type a response.
This will be a challenge when coding for the pico also.
Or do you use a speach decoder, or AI to write the code ?

Volhout
PicomiteVGA PETSCII ROBOTS
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7871
Posted: 10:08am 25 Nov 2024
Copy link to clipboard 
Print this post

Another Minetest fan. :)
It's a faster performer than Minecraft and runs pretty well on lower powered machines.

Circuit Python has native HID support. It's pretty trivial to simulate keyboard presses or send strings in response to a single key press. I've never tried mouse support though. I don't know how well it will do with that - if at all.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 10:51am 25 Nov 2024
Copy link to clipboard 
Print this post

Just me coding. well with arduino some cut and paste with mods. LOL
 
I played minetest in its early days it was crude at the time and has gotten
very good.

My Granddaughter got my to play at a skyblock server. Her and friends had
a cobble gen and wanted a stone gen. She said my work looked like redstone
stuff. So I had a look and got the cobble gen to make stone. I found I loved
doing things with redstone. When m$ made users get m$ accounts my granddaughter
lost her minecraft account. Yea how many kids had kept old email accounts.
With no access to their email all three of my grandkids lost orginal minecraft.

I have been on my current skyblock for just over three years now. I have four
desktops setup. #1. skyblock #2. eaglecad #3. coding #4. music-videos.

I have a youtube channel. T-Neko granddaughter had me start years ago to help
her friends do redstone. I'm not good at the videos but they did get the
information across.

Then added fly bys of passed great islands talented players did. Also made music
and video resource packs.

Playing Minecraft better than TV, golf, card club or bingo.

At 69 having FUN like a kid.
Quazee137

p.s. Don't feel bad its good to type more than just code.
Shoulder doing very good, ribs and bit less good, and hand numbish.
Edited 2024-11-25 20:55 by Quazee137
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 11:46am 25 Nov 2024
Copy link to clipboard 
Print this post

Hi Quazee,

Thanks for hinting me to BadUSB. Interesting stuff, compiled though. Lots of hackers around there.
The scripting version running on Pi ZERO is Flipper-Zero. That is more in line with what you want. There is a core, and script files. Won't be long before the 2040 libraries exist (they may already exist, didn't dive that deep yet).

Volhout
Edited 2024-11-25 21:48 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 06:50am 28 Nov 2024
Copy link to clipboard 
Print this post

Volhout check this out https://usbnova.com/

  like the BadUsb at setup it works a USB storage device. Better than SDcard.

   I'm looking over the code to see how it does the USB keyboard emulation.

  Have FUN
  Quazee137


  Not sure if there is any interest here I have a ESP-01S talking to 2nd
  ESP-01S. I will post code for sender and receiver if there is.

  These are code bits I got from many sources. Not great looking but is working.
Edited 2024-11-28 16:53 by Quazee137
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 08:20am 28 Nov 2024
Copy link to clipboard 
Print this post

Hi Quazee,

The usbnova source could be interesting. It is RP2040 code, so could port to any pico.

Does your ESP code provide a wireless serial link ? Or is it one sender, one receiver ? Uni directional.

Volhout
PicomiteVGA PETSCII ROBOTS
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3360
Posted: 02:02pm 28 Nov 2024
Copy link to clipboard 
Print this post

  Quazee137 said  I have a ESP-01S talking to 2nd
  ESP-01S. I will post code for sender and receiver if there is.


Please do.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Quazee137

Guru

Joined: 07/08/2016
Location: United States
Posts: 593
Posted: 02:14pm 28 Nov 2024
Copy link to clipboard 
Print this post

The test setup is a sender connected to a controller and when it is powered
 up it ask the receiver to turn on its pump. Receiver turns on pump relay and
 sends a call back so the sender knows it is connected and pump is on.

 When the sender powers down the receiver turns pump off and is now in idle
 mode for now using leds and ESP-01S relay module. If the sender does not
 get the call back response it can do an alert for now blink red led.

 Using ESPNOW makes it easy so later on sender will talk to more than one
 receiver working up to eight or more relays. Next test will be D1 ESP's
 with antenna's to help with range, noise and a lot more pin to play with.

 I have some ESP-07S meant to use external antennas.
 Being lazy as I need to make a holder/programmer should also work with ESP-12.  


 Have FUN and those that do turkey day "Happy Thanks Giving"

 Quazee137
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5059
Posted: 02:30pm 28 Nov 2024
Copy link to clipboard 
Print this post

Hi Quazee137,

I am obsolutely interested, especially since it operates outside/alongside a WIFI network. If not directly 1:1 applicable, then the code can help me understand ESP-NOW. Eager to learn. I have (somewhere) a D1, and an ESP-01, so I could try to duplicate your setup.

Volhout
Edited 2024-11-29 00:32 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025