Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits)

I don’t have specific support for that right now, but you can edit new_pollGamepads to add this feature:

Directly above dx = dx * speed;, add the following:

// Edit: Keyboard arrow controls
if ($gameSwitches && $gameSwitches.value(12345)) { // Replace with your Switch ID.
  if (Input.isPressed('left')) dx -= 1;
  if (Input.isPressed('right')) dx += 1;
  if (Input.isPressed('up')) dy -= 1;
  if (Input.isPressed('down')) dy += 1;
}
// End of edit.

This is untested, but I’m confident it’ll work.
(Flipping a sign here or there may be necessary.)

Note that this will use the main directional input to move the cursor, which means the L-stick and D-pad should also work. If you’d like the input to be distinct, I recommend (dynamically, if there’s a collision) binding a custom intent in Input.keyMapper and checking for that in the snippet above instead.

(1 edit)

After modifying your edit a bit. It achieves what I want. Your original edit has the error of null value (somehow). I'll just share my edit.

if (Input.isPressed('left') && $gameSwitches.value(n)) dx -= 1;
if (Input.isPressed('right') && $gameSwitches.value(n)) dx += 1;
if (Input.isPressed('up') && $gameSwitches.value(n)) dy -= 1;
if (Input.isPressed('down')&& $gameSwitches.value(n)) dy += 1;

Not exactly a pretty code, but it works. Thanks for your help.

(2 edits)

Oh, most likely it gets called before the game state is initialised. I updated it with a more reliable fix for that.

You may also want to check that the current scene isn’t a menu, if the player can open one while the Switch is ON.

Edit: Typos.

(+1)
You may also want to check for whether that the current scene isn’t a menu, if the player can open one while the Switch is ON.

Yea I noticed that. Thanks for your help!

Sorry for another question. I hope you don't mind it.

Can you show me the function that show the cursor? I tried to find it and use the said function when a switch is on.

Thanks in advance.

You can activate it at any time with a(n e.g. “Script” Command) call to TSC_RStick_Mouse.startVirtualInput(). It’s fine to call this every frame.

Similarly, TSC_RStick_Mouse.endVirtualInput() will hide the virtual cursor on the next sprite update, and it’s fine to call that every frame too.

Thanks for your reply, appreciate it!