TaylorAlexander a month ago

Something similar that I want us USB Force Feedback wheel (and joystick) support for the RP2040. I looked pretty deeply in to this and I was unable to find any libraries which do the necessary USB magic for the chip to build devices which show up on a computer as force feedback. There’s some code for the Atmega32u4 to do it and in general there is documentation around the web for how this stuff works, but actually digging in to USB spec stuff is not really my thing.

There is an open source gamepad library for the RP2040 but they said on GitHub issues and discord that they have no plan to pursue force feedback support.

But I designed a really nice brushless motor controller for the RP2040 and I’d love to make a force feedback wheel with it! I already have a motorized wheel I built to test this and I even made it work with motorized return to center as a regular USB joystick device, I just don’t know the magic incantations to make it in to a force feedback device.

  • pjc50 a month ago

    Some discussion of how to do this in a PIC context: https://forum.microchip.com/s/topic/a5C3l000000M4PDEA0/t2469...

    If you have enough USB experience you might be able to do it by (a) adding the necessary configuration reports to expose HID force feedback and (b) implementing the matching endpoint. But it's quite fiddly and benefits from having a device you can copy.

  • henrebotha a month ago

    The open source gamepad firmware you mention is GP2040-CE. I can guarantee you users will be happy if force feedback gets merged in. Stuff moves fast; by now, opinions on this might have changed. I'd encourage interested parties to join the Discord and discuss it.

  • jononor a month ago

    Use the atmega32u4 and it's force feedback implementation to handle the USB communication? Communicating with it over I2C or similar?

    • TaylorAlexander a month ago

      Definitely possible, but it would ruin an otherwise nice development environment. For personal use that would be fine, but I tend to try to design things as nice complete open source projects people could use and enjoy using. Plugging in to one USB port to program the RP2040 and then another to test the force feedback control is not ideal for development.

      It would work though, and I do want a wheel even for myself (the surplus motor I got for it is a beast). Might be my best bet.

mongol a month ago

Imagine something like this but having two USB inputs, one for the keyboard and one for your phone. Then your phone could inject passwords managed in the password manager in your phone. No need to keep them in the cloud.

Unfortunately I don't think Android supports acting like a HID device. But possibly custom firmware in the dongle could support some USB serial protocol.

  • jrexilius a month ago

    That's the exact opposite model of what I built [1], because I view the phone as just as unreliable as desktop or laptop. Actually even less reliable, given my choice of workstation OS.

    I went with a USB and BLE chip on the external side of my keyboard to connect to both workstation and phone to push the passwords, MFA, and encrypted text from the manager I built into the keyboard itself.

    1: https://www.anomie.tech/products/anigma/ce/

  • stavros a month ago

    I don't keep passwords in the cloud because I'm afraid they'll be stolen from my computer, I keep them there for backup.

    • TeMPOraL a month ago

      And you use the passwords from the cloud to test your ability to restore from backup? ;).

      • stavros a month ago

        No no, I have them memorized.

        • TeMPOraL a month ago

          Even the OTPs? :).

          • stavros a month ago

            I mean the reason I use BitWarden instead of KeePassX isn't because I'm worried someone will steal the KeePassX database file, but that I'll lose it.

  • peterburkimsher a month ago

    Anrdoid and iOS don't support USB HID natively. The iPod does with Rockbox, but I'm probably the only person still carrying one around.

    The best solution I've found for pocket-sized USB HID is an EspUSB Tiny:

    https://github.com/cnlohr/espusb

    It's an ESP8285 acting as a USB keyboard, with the keystrokes coming over WiFi from a nearby phone.

    • numpad0 a month ago

      Acting like USB HID and hosting USB HID devices are two different things, GP's suggestion might be possible with Android Open Accessory(aka abusing adb in Google sanctioned way) or through a rooted phone with a custom kernel mode gadget driver.

      An RP2040 device with 2 USB downstream facing port and 1 USB upstream facing port can be made, stuffed into a conspicuous Y-cable, appropriately programmed and appear as a single USB keyboard. Out of my reach but not impossible.

      • monocasa a month ago

        Just going to through out there that you don't need a custom kernel driver to do this on Android. There's a userspace gadget API; you only need a rooted phone to have the permissions to access the relevant device and config files.

        http://www.linux-usb.org/gadget/usb.c

      • brokenmachine a month ago

        ESP32-S2, ESP32-C3 and ESP32-S3 have USB-OTG to act as USB Hosts. I've seen cheap ESP32-S3 boards with two USBC connectors, one for USB-OTG and the other to connect to the PC.

        edit: Actually the port to connect to the PC goes through a UART chip, so you can't emulate HID devices using that port. So it won't work.

    • felixg3 a month ago

      Do you have a suggestion for a Bluetooth HID bridge? To use Bluetooth mice and keyboards with a generic dongle that presents as a usb HID to the computer, similar to how apple does peripheral support?

      • peterburkimsher a month ago

        Are you looking for a product, or one to build yourself?

        If you want a product, why not just get a USB-Bluetooth adaptor? It would support HID as well as A2DP (music) and other Bluetooth protocols.

        If you want to build something, I'd recommend getting a board with an ESP32.

        The ESP32 comes with plenty of example code in their esp-idf SDK. You'd be needing:

        esp-idf/examples/peripherals/usb/device/tusb_hid

        esp-idf/examples/bluetooth/esp_hid_host

  • rzzzt a month ago

    You can set up a network connection over USB (intended for tethered operation).

  • Rygian a month ago

    Or just use kdeconnect.

  • willwade a month ago

    ..Or iOS, Windows.. or Mac..

MrLeap a month ago

This seems purpose built for me. I ordered a foot pedal online with the intention of hooking OBS up to it. It seems to send a 'b' keydown event when it's pressed, with no clear way to change it. Utterly useless out of the box lol.

  • Karliss a month ago

    If you know just a little bit of electronics, for something like a pedal it might be more straight forward to take it apart, wire up the pedal switch directly to rpi pico and run something like QMK or any other usb keyboard firmware on it. That way avoiding the complexity of pedal->usb->pi pico->usb->computer. Full USB hid stack and supporting arbitrary HID device as input can be ridiculously complex.

    And since you are skipping the redundant USB step, you can also use dumb non USB pedals. There are plenty of options available meant for sewing machines, midi keyboards and industrial equipment. Just need to watch out as some of them contain a potentiometer for modulating the output instead of on/off switch. That may or may not be what you want. It should still be possible to emulate regular switches with them, but it will require a bit more coding.

    This is more suited for moderate complexity HID devices where direct rewiring is less practical due to amount of inputs (keyboard) or size constraints+non trivial undocumented sensors(mice, barcode scanner, other specialized input devices), or don't want to take it apart.

  • ThrowawayTestr a month ago

    You could probably use autohotkey to detect when that device sends a "b" and intercept it.

    • reaperman a month ago

      Too many games consider AHK to be high risk for scripting and raises your anti-cheat score. So I am wary of running AHK when playing games which have anti-cheat.

      • ThrowawayTestr a month ago

        Then rip out the insides and replace them with a microcontroller.

  • qingcharles a month ago

    What on Earth? :(

    Was it a lot cheaper than the Elgato one?

    https://www.amazon.com/Elgato-Stream-Deck-Pedal-footswitches...

    I'm thinking this remapper would get some buttons working on some old USB keyboards that have driver issues. BUT, the cost and time to make one of these remappers makes it only useful in very extreme circumstances where buying a alternate replacement device is not possible, feasible or desirable.

    • MrLeap a month ago

      Much cheaper. https://www.amazon.com/dp/B08MC456TC

      Looking at the store page is refreshing my memory. I ended up being unwilling to install the sketchy software. I just took it for granted it would come with a sensible default. Mouse3+, or a joypad input. Something.

dark-star a month ago

This looks really awesome. It could easily replace a dozen AHK scripts on my system...

And, despite its obvious usefulness, this can also be used as base for a device to mess with coworkers. Change the firmware so that it rotates the mouse "north" by an arbitrary value between -30° and +30°, slowly changing over time. Or randomly remap keyboard keys to other neighboring keys but only once every n seconds/minutes. Just enough to evade suspicion. So many possibilities :-D

aloer a month ago

I saw this video [0] from the creator of this project the other day. Here he shows how to connect a USB joystick with a playstation access controller [1] by mapping from USB to 3.5mm analog output.

I found this because I was looking for something else for the access controller. It's basically the other way around: I want to use the controller on a mac and need to remap it's outputs to something useful. I don't have a playstation and apparently you need one to remap the controller keys once before plugging it in to a PC, otherwise only 3 out of 8 buttons will send something that is recognized as USB HID

[0] https://www.youtube.com/watch?v=MtXdPWN6NBw [1] https://www.playstation.com/en-us/accessories/access-control...

  • jfedor2 a month ago

    You could totally use HID Remapper to do what you want.

    The PlayStation Access Controller has profiles that can be configured from a PS5 as you say, but regardless of the current profile or mapping, it always sends the raw button/joystick states in the report. They're not properly exposed in the report descriptor, but they're there. You would have to use what HID Remapper calls "custom usages" to get to this raw data. I can assist you with that if you're interested. Though it might be easier to find someone with a PS5 for the one time setup.

gsliepen a month ago

> It works completely in hardware

No, it works completely in software, it's just on a different CPU. Still neat though!

bb88 a month ago

It turns out the RP2040 is turning out to be a really nice microprocessor.

The only thing missing is Wifi really.

hesdeadjim a month ago

I always wonder with these things if game anti-cheat software will flag you based on the hardware identifiers not matching known manufacturers of peripherals.

  • duskwuff a month ago

    There are so many manufacturers of USB peripherals in the world that trying to allowlist "known" manufacturers would be futile.

  • jfedor2 a month ago

    Trivial to spoof if one were so inclined.

anilakar a month ago

I've been planning on turning an old ambidextrous Logitech Marble Mouse into a cheap CAD spacemouse and this might be just what I need.

bankcust08385 a month ago

I don't see the point except for rare fixed applications without admin OS access. Do it in software for free. Karabiner Elements etc.

  • nottorp a month ago

    Multiple OS installs / multiple boxes on the same keyboard.

    Then it's "do it 4 times in software for free" and the software is not the same and this solution suddenly becomes attractive.

    You could solve it by getting a keyboard that supports macros on the keyboard hardware maybe. Or keep your existing keyboard you know and love and insert this little solution.

  • hexmiles a month ago

    I use a keyboard with qmk which is quite similar to this, before that I used a bunch of autohotkey scripts. To me qmk is a better solution since it works on any computer and any programs (autohotkey struggles with some applications that I belive use lower level input handling, I cannot speak for Karabiner since I don't use it), without needing to install anything. To me is a big plus

sandreas a month ago

I recently thought about using a cheap USB HDMI capture card (7 bucks) and a RP2040(7 bucks) to build a PiKVM like device.

Connecting the 2040 via serial emulating USB keyboard and mouse would make it possible to use older rasperry pi 3 devices for pikvm.

This project seems to prove that this is possible...

  • ranger_danger a month ago

    I think the processing power necessary to do this at modern resolutions (1080p60/4k/etc.) is way out of any rpi's league. Usually this is done on an FPGA which is exactly what makes it so expensive.

    • sandreas a month ago

      Mmh thanks for you response. PiKVM[1] is a ready to use product an it works on >= RPI4... So if this was correct, how would you explain?

      1: https://pikvm.org/

      • ranger_danger a month ago

        "works" is subjective: https://docs.pikvm.org/faq/#common-questions

        > I am expecting to see 60fps and I am not, why?

        "PiKVM receives the entire signal, but then the encoding is the bottleneck. For 1080p, this is no more than 30 fps. V4 throws out every second frame of 60 hz/fps, and 30 fps is encoded. V3 and DIY can't process 60 hz and is only able to capture 50 hz, and in the same way they take every second frame, all you get out is 25 fps. The reason why V3 and DIY does not encode 30 out of 50 is that the picture will be jerky, but smooth at 25."

        The main website claims 1080p60 support, which is true on the input side, but that's not what you get on the output... a bit of false advertising IMO.

peterburkimsher a month ago

I use an Apple keyboard on my work PC, but would rather use Command-C and Command-V instead of Ctrl-C and Ctrl-V.

This remapper should be able to remap the Command/Windows key to Ctrl.

gsich a month ago

Also useful if you want a 1000Hz mouse who doesn't natively support it.

  • dark-star a month ago

    I read that too, and wonder about the usefulnes of this feature.

    If your mouse has a sample rate of, say, 100Hz, what benefit does it bring to increase that to 1000Hz? You would still get 10 samples with the same data, then the next 10, and so on...

    Or am I missing something here?

    • jfedor2 a month ago

      It just doesn't work the way you describe.

      Many mice are capable of higher reporting rates than their defaults, they just need to be asked nicely.

      • dark-star a month ago

        But then the mouse "natively supports" 1000 Hz? OP said it helps with devices that don't "natively support it". The GitHub page calls it "polling rate overclocking" (whatever that means), which doesn't sound like it would "unlock" anything (or "ask nicely" as you put it) in the mouse but rather just increase the sampling frequency?

        • xeonmc a month ago

          For reference, most mice sensors have sampling frequency in excess of 5000fps on the low end, but the data is consolidated and reported at a 125hz usb polling rate.