Homebrew Question Emulate keystrokes on PC to send to Switch via USB?

DiscostewSM

Well-Known Member
OP
Member
Joined
Feb 10, 2009
Messages
5,484
Trophies
2
Location
Sacramento, California
Website
lazerlight.x10.mx
XP
5,469
Country
United States
"Emulate keystrokes? Why would you want that when you can just plug in a USB keyboard to Switch?"

Hear me out.

In a few weeks, FUZE4 will be released, which is a text-based programming language/environment for the Switch where you can create your own stuff. I'm hoping to make a few things with it, including porting my Mega Man 2 PTC project to it (originally made for Petit Computer on the DSi). The languages are incompatible, so I'd have to redo it. While I could do it straight on the Switch, doing such a thing right on a system isn't how I did my previous project. When I did that one, I did the majority of my programming, editing of images, compression, etc all on my PC, and used PTCUtilities to generate QR codes and then scan them into my 3DS. FUZE4, according to the devs and likely controlled by Nintendo, has no means to inject data externally with the exception of one. A USB keyboard, one character at a time.

My thought, if possible, is connect the Switch to a PC via USB, and on the PC side, have a program that can send emulated keystrokes to the Switch. Not simply using a PC's keyboard, but even have a kind of copy/paste function where it'll stream a selection of data via emulated keystrokes from PC to Switch. Not exactly a fast way of sending a LOT of data, but a way nonetheless.

"Sure, good for code, but what about graphics? Audio? Everything else?"

Well, as far as I understand, assets made with the program, like graphics, use the program's own file handling functions to read/write them. So technically, we could code a file-write program with the asset inserted as static data, send it all as code, then run the program for it to write that asset to memory. An advantage of having all the stuff on the PC to send it to Switch in this fashion is that it'll allow sharing beyond the scope allowed by the devs. What they said was that sharing of projects is restricted to the friend list, but if we have the data outside of the program, we can share it however we want.

So yeah........is there a program that could allow this, or maybe someone could make one? Doesn't even have to be specifically PC->Switch, just having a PC act like a keyboard to whatever else connects to it.
 

galaxior

Member
Newcomer
Joined
Apr 25, 2019
Messages
9
Trophies
0
Age
34
XP
135
Country
United Kingdom
A pure software solution is not possible due to the nature of USB. USB is asymmetric and one side is the host and the other is the peripheral device. It's pretty much guaranteed that your computer's USB ports can only act in host mode whereas they'd need to be able to operate as a peripheral for this to work.

It's technically possible for a USB port to operate as either but this is typically only found in mobile devices and is known as USB OTG (On the go), with a OTG supporting device what you suggest should be possible

One of the easiest/cheapest hardware devices to do this would be using a Raspberry Pi Zero which has OTG fucntionality and could act as a HID keyboard. There are many tutorials demonstrating how it can be done

With the Pi in place and connected to the Switch you you could just forward your keyboard inputs (or an entire text selection as you suggest) over to the pi via WiFi and it could relay them to the Switch
 
Last edited by galaxior,

The Real Jdbye

*is birb*
Member
Joined
Mar 17, 2010
Messages
23,246
Trophies
4
Location
Space
XP
13,798
Country
Norway
A pure software solution is not possible due to the nature of USB. USB is asymmetric and one side is the host and the other is the peripheral device. It's pretty much guaranteed that your computer's USB ports can only act in host mode whereas they'd need to be able to operate as a peripheral for this to work.

It's technically possible for a USB port to operate as either but this is typically only found in mobile devices and is known as USB OTG (On the go), with a OTG supporting device what you suggest should be possible

One of the easiest/cheapest hardware devices to do this would be using a Raspberry Pi Zero which has OTG fucntionality and could act as a HID keyboard. There are many tutorials demonstrating how it can be done

With the Pi in place and connected to the Switch you you could just forward your keyboard inputs (or an entire text selection as you suggest) over to the pi via WiFi and it could relay them to the Switch
An Arduino or a Teensy of some sort would also work.
 

stitchxd

Well-Known Member
Member
Joined
Apr 27, 2017
Messages
401
Trophies
0
Location
nope
Website
gnusocial.me
XP
689
Country
United States
A pure software solution is not possible due to the nature of USB. USB is asymmetric and one side is the host and the other is the peripheral device. It's pretty much guaranteed that your computer's USB ports can only act in host mode whereas they'd need to be able to operate as a peripheral for this to work.

It's technically possible for a USB port to operate as either but this is typically only found in mobile devices and is known as USB OTG (On the go), with a OTG supporting device what you suggest should be possible

One of the easiest/cheapest hardware devices to do this would be using a Raspberry Pi Zero which has OTG fucntionality and could act as a HID keyboard. There are many tutorials demonstrating how it can be done

With the Pi in place and connected to the Switch you you could just forward your keyboard inputs (or an entire text selection as you suggest) over to the pi via WiFi and it could relay them to the Switch

The switch has Keyboard support, it might be possible to create a sysmodule (and a driver for windows/linux) to do what OP is looking for. Sys module will take virtual key input from the PC and pass it to the Switch's kernel as key input. I wouldn't know how to implement, but it sure could be done right?
 

LyfeOnEdge

Well-Known Member
Newcomer
Joined
Feb 24, 2019
Messages
72
Trophies
0
Age
27
XP
482
Country
United States
"Emulate keystrokes? Why would you want that when you can just plug in a USB keyboard to Switch?"

Hear me out.

In a few weeks, FUZE4 will be released, which is a text-based programming language/environment for the Switch where you can create your own stuff. I'm hoping to make a few things with it, including porting my Mega Man 2 PTC project to it (originally made for Petit Computer on the DSi). The languages are incompatible, so I'd have to redo it. While I could do it straight on the Switch, doing such a thing right on a system isn't how I did my previous project. When I did that one, I did the majority of my programming, editing of images, compression, etc all on my PC, and used PTCUtilities to generate QR codes and then scan them into my 3DS. FUZE4, according to the devs and likely controlled by Nintendo, has no means to inject data externally with the exception of one. A USB keyboard, one character at a time.

My thought, if possible, is connect the Switch to a PC via USB, and on the PC side, have a program that can send emulated keystrokes to the Switch. Not simply using a PC's keyboard, but even have a kind of copy/paste function where it'll stream a selection of data via emulated keystrokes from PC to Switch. Not exactly a fast way of sending a LOT of data, but a way nonetheless.

"Sure, good for code, but what about graphics? Audio? Everything else?"

Well, as far as I understand, assets made with the program, like graphics, use the program's own file handling functions to read/write them. So technically, we could code a file-write program with the asset inserted as static data, send it all as code, then run the program for it to write that asset to memory. An advantage of having all the stuff on the PC to send it to Switch in this fashion is that it'll allow sharing beyond the scope allowed by the devs. What they said was that sharing of projects is restricted to the friend list, but if we have the data outside of the program, we can share it however we want.

So yeah........is there a program that could allow this, or maybe someone could make one? Doesn't even have to be specifically PC->Switch, just having a PC act like a keyboard to whatever else connects to it.
An ATMEGA32U4 could do it pretty easily. Alternatively you could probably set up ftp so it would be a simple matter of saving the files in a local file then pushing them to the switch
 

galaxior

Member
Newcomer
Joined
Apr 25, 2019
Messages
9
Trophies
0
Age
34
XP
135
Country
United Kingdom
The switch has Keyboard support, it might be possible to create a sysmodule (and a driver for windows/linux) to do what OP is looking for. Sys module will take virtual key input from the PC and pass it to the Switch's kernel as key input. I wouldn't know how to implement, but it sure could be done right?
Potentially yes, I guess to be more accurate I should have said no pure software solution on only the PC side is possible (which is how I interpreted the post). A solution with software running on both ends does sound feasible but I have no experience with switch sysmodules either

Sent from my BLA-L09 using Tapatalk
 
  • Like
Reactions: stitchxd

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Maximumbeans @ Maximumbeans: How's it going my loves