How to map controller or keyboard inputs to a specific coordinate of the touch screen (Desmume)
Guides
/
How to map controller or keyboard inputs to a specific coordinate of the touch screen (Desmume)
Updated 3 years ago by JuegAriel

In case you don't understand what the title means, I'll give an example. If you're playing this game on emulator, you may have noticed you have to use the mouse to use a Vibe ability. Because of that, you may need to interrupt your gameplay very often to use the mouse. With this, instead of using the mouse, you can just use another button from your keyboard or controller to trigger the Vibe ability.

For this, I'll be using a Lua script, on Desmume 0.9.11. I've tried with newer builds of Desmume, but the script ends up crashing due to it being more unstable, so I really recommend 0.9.11.

Controls

The first step is to figure out how you want your controls to look like. I personally use a PC controller very similar to a PS3 controller. With that, I use the D-pad, the 4 face buttons, and 2 of the triggers as the regular DS buttons. But I also use both analog sticks to trigger the 4 Vibe abilities. Left stick up means Joy, Left stick down means Gloom, Right stick up means Rage and Right stick down means Calm. It may not be the best control scheme, but it definitely works for me.

Downloading the Lua script

Here is the link to the file, it would be a good idea to have it on the same directory as Desmume. https://www.mediafire.com/file/chmse1rw3nsab78/SPP_touch.lua/file

But that's not all, for the emulator to recognize and run a Lua script, you need two different .dll files. Make sure to choose the one you need.

64bit: https://sourceforge.net/projects/luabinaries/files/5.1.5/Windows%20Libraries/Dynamic/lua-5.1.5_Win64_dll16_lib.zip/download 32bit: https://sourceforge.net/projects/luabinaries/files/5.1.5/Windows%20Libraries/Dynamic/lua-5.1.5_Win32_dll16_lib.zip/download

Once you have downloaded the .zip, extract it, and move the two .dll files at the same directory as Desmume.

IMPORTANT: Rename "lua5.1.dll" to "lua51.dll", due to how old Desmume is, it will only recognize that name!

Modifying the script

First, make sure you have your main controls set up in Desmume (Config --> Control Config)

After that, decide which 4 keyboard buttons you want to use for the Vibe abilities. Make sure that they don't interfere with anything else (Hotkeys on the emulator or on livesplit, something that makes a menu pop up, etc.)

Once you have decided, you'll need to modify the Lua script. Here's how it's done.

First, the code looks like this: [quote] while true do if input.get().numpad4 then stylus.set{x=40, y=40, touch=true} end if input.get().numpad5 then stylus.set{x=210, y=40, touch=true} end if input.get().numpad1 then stylus.set{x=40, y=140, touch=true} end if input.get().numpad2 then stylus.set{x=210, y=140, touch=true} end emu.frameadvance() end [/quote] Do you see those input.get(). commands? whatever they have afterwards is what each Vibe ability corresponds to. So in the default code, Numpad 4 corresponds to Joy, Numpad 5 corresponds to Rage, Numpad 1 corresponds to Gloom and Numpad 2 corresponds to Calm.

All you need to do is change numpad4, numpad5, numpad1 and numpad2 to whatever keys you want. Here is how to write every key in the keyboard:

  • Locks: "capslock", "numlock", "scrolllock"
  • Numbers: "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
  • Letters: "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z
  • Function keys: "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24"
  • Directional Keys: "left", "up", "right", "down"
  • Numpad: "numpad0", "numpad1", "numpad2", "numpad3", "numpad4", "numpad5", "numpad6", "numpad7", "numpad8", "numpad9", "numpad*", "numpad+", "numpad-", "numpad.", "numpad/"
  • Others: "backspace", "tab", "enter", "shift", "control", "alt", "pause", "escape", "space", "pageup", "pagedown", "end", "home", "insert", "delete", "semicolon", "plus", "minus", "comma", "period", "slash", "backslash", "tilde", "quote", "leftbracket", "rightbracket"

Once you have modified your script, save it as SPP_touch.lua (in other words, don't change its name)

How to run the Lua script

On Desmume, go to Tools --> Lua Scripting --> New Lua Script Window... On that new window, press Browse... and open SPP_touch.lua The code should now be running and you can test it by loading the ROM and trying to use the Vibe abilities using the keys you assigned.

What about Controller?

This is where it gets a bit more complicated. Lua doesn't have a way to read controller inputs directly. That means that you'll have to map controller inputs to keyboard.

Fortunately, there's an easy way to do that with Joy2Key ( https://joytokey.net/en/ ) All you need to do is map the controller inputs you want to the keyboard keys that you assigned to your Vibe abilities.

Example of mapped inputs

Here's a video example of myself playing the game, using analog sticks to trigger the Vibe abilities:

Help/Contact

Since I'm really bad at explaining things, I imagine there's going to be some questions about this. If you have one, please @ me on the Super Princess Peach Discord or DM me (Discord Tag: JuegAriel#7418)

Anyways, I hope all of this helped some new runners get into this!

-JA

Game stats
Followers
140
Runs
161
Players
24
Latest threads
Posted 4 years ago
Posted 4 years ago
Moderators