Hacking WIP POC switchbruDNS html5 games working controls

naed06

Well-Known Member
OP
Member
Joined
May 16, 2017
Messages
127
Trophies
0
Age
42
XP
2,358
Country
On the back of this thread https://gbatemp.net/threads/tutoria...n-4-0-0-and-add-your-html5-games-here.499813/ I went on the search to see if we could bind the controls on the switch to a custom html game when using the browser via
SwitchBruDNS

I'm not well versed in html5 or JavaScript but I did manage to create a proof of concept that allowed me to bind custom controls to a html5 game

B77_BC511_8365_4_F35_94_C4_2_BF82800_A882.jpg



This uses the gamepad api to allow you to bind gamepad keys to your game

Your welcome to try this game out I made (followed a tutorial and added the gamepad keys after) and when I get around to it later this afternoon I'll post some further information

https://switchgame.000webhostapp.com/index.html

This uses the left/right DPAD to move left and right on the paddle - I also binded the R and L button because I cannot figure out how to make the game full screen and the DPAD tries to scroll the website/select links


EDIT:

Here's the button codes I used with the Gamepad API to allow me to bind controls

Code:
Buttons[0]: B
Buttons[1]: A
Buttons[2]: Y
Buttons[3]: X
Buttons[4]: L
Buttons[5]: R
Buttons[6]: LZ
Buttons[7]: RZ
Buttons[8]: Minus
Buttons[9]: plus
Buttons[10]: left stick  (press)
Buttons[11]: right stick (press)
Buttons[12]: DPAD up
Buttons[13]: DPAD down
Buttons[14]: DPAD left
Buttons[15]: DPAD right
axes[0]: left analogue lef/righ
axes[1]: left analogue up/down
axes[2]: right analogue left/right
axes[3]: right analogue up/down

Here's the tutorial I followed to create the examples above

https://gamedevelopment.tutsplus.co...ontroller-support-to-browser-games--cms-21345
 
Last edited by naed06,
D

Deleted-442439

Guest
Good job! I am on mobile right now so can't try it out, but my understanding of it is this:

Fullscreen: The games canvas must be the only element on the page, the Switch applet does not support true fullscreen the "buttom bar" has a persistence behavior.

The DPAD works as directional keys and a gamepad so having other elements on the screen will cause it to scroll to that element regardless of what you program it too.
 
  • Like
Reactions: naed06

naed06

Well-Known Member
OP
Member
Joined
May 16, 2017
Messages
127
Trophies
0
Age
42
XP
2,358
Country
Good job! I am on mobile right now so can't try it out, but my understanding of it is this:

Fullscreen: The games canvas must be the only element on the page, the Switch applet does not support true fullscreen the "buttom bar" has a persistence behavior.

The DPAD works as directional keys and a gamepad so having other elements on the screen will cause it to scroll to that element regardless of what you program it too.

Thanks for the info

The main thing I've realised it's that no matter what you program the buttons to do the switch will still make it function as normal outside of your html functions

so binding the button B to anything will just make your browser go back to previous page
 
Last edited by naed06,
D

Deleted-442439

Guest
Thanks for the info

The main thing I've realised it's that no matter what you program the buttons to do the switch will still make it function as normal outside of your html functions

so binding the button B to anything will just make your browser go back to previous page

No problem!

In terms of not being able to bind a/b/x/y I have used on screen buttons as a workaround, disregarding the right joy con completly.
 

naed06

Well-Known Member
OP
Member
Joined
May 16, 2017
Messages
127
Trophies
0
Age
42
XP
2,358
Country
thats cool..
i have found that the gamepad api isnt needed but it does work using it

Whilst this is mostly true, I've found lots of games I thought would be cool to play but the controls simply didn't work

Plus this could give us more control over which buttons are binded to controls
 
D

Deleted-442439

Guest
I found a way to get fullscreen working! Embarrassingly easy... just swipe down in the game canvas and the game will go fullscreen...
 

naed06

Well-Known Member
OP
Member
Joined
May 16, 2017
Messages
127
Trophies
0
Age
42
XP
2,358
Country
www.wiiubru.com/test.html was what i did .. just to prove functionality. check the source .. maybe it will help

thanks.... worked for me :)

this'll give me something to look at over the next few days now

EDIT:

does anyone have a list of the Switch browser controls?
this is what i have so far

L analogue = pointer/cursor
R analogue = zoom
X = End
A = OK
B = Back
+ = info
- = info
DPAD = navigate
Home = home

meaning Y, L, R, ZL, ZR do nothing??
 
Last edited by naed06,
D

Deleted-442439

Guest
thanks.... worked for me :)

this'll give me something to look at over the next few days now

EDIT:

does anyone have a list of the Switch browser controls?
this is what i have so far

L analogue = pointer/cursor
R analogue = zoom
X = End
A = OK
B = Back
+ = info
- = info
DPAD = navigate
Home = home

meaning Y, L, R, ZL, ZR do nothing??

Your list is correct, Y,L,R,ZL;ZR have no mapped functions, and can be mapped to gamepad inputs in game. Will start to do more testing now. I hope that we in the feature will have a way to use HTML5 games in .NRO through the Homebrew launcher, will contact the devs I know and ask what could be possible. (without us having to learn C++)
 
  • Like
Reactions: naed06

Ep8Script

Well-Known Member
Member
Joined
Aug 5, 2017
Messages
335
Trophies
0
XP
555
Country
Australia
In my development of the DNS landing page, I've found the simple fact that if you use history.pushState you can override the B button. Unlikely you could override the X or +/- buttons though.
 
D

Deleted-442439

Guest
In my development of the DNS landing page, I've found the simple fact that if you use history.pushState you can override the B button. Unlikely you could override the X or +/- buttons though.

Even if it overides I presume the page will stll be reloaded (thus resetting the game) or can you actually block the function?
 
D

Deleted-442439

Guest
HTML5 is surprisingly versatile, so I have begun porting/recreating NSMB.
It is not even remotely what I would call worthy of public release, but I made sure it supports the gamepad API and it runs on Switch, I am aware of the bugs in the current version this is simply a proof of concept:
https://jjbredesen.itch.io/switchtest

@Ep8Script would be cool if we could get this on the SwitchbruDNS "other links" page once I get W1-1 working?
 
Last edited by ,

Ep8Script

Well-Known Member
Member
Joined
Aug 5, 2017
Messages
335
Trophies
0
XP
555
Country
Australia
HTML5 is surprisingly versatile, so I have begun porting/recreating NSMB.
It is not even remotely what I would call worthy of public release, but I made sure it supports the gamepad API and it runs on Switch, I am aware of the bugs in the current version this is simply a proof of concept:
https://jjbredesen.itch.io/switchtest

@Ep8Script would be cool if we could get this on the SwitchbruDNS "other links" page once I get W1-1 working?
Sure! It seems like you've made a decent start, I look forward to it. :)
 

Ep8Script

Well-Known Member
Member
Joined
Aug 5, 2017
Messages
335
Trophies
0
XP
555
Country
Australia
Just tried it out on the Switch and it seems the framerate is ridiculously low, almost unplayable... might not be worth the effort you're putting in dude, but it does look good on PC, so good job.
 
D

Deleted-442439

Guest
Just tried it out on the Switch and it seems the framerate is ridiculously low, almost unplayable... might not be worth the effort you're putting in dude, but it does look good on PC, so good job.

Thanks! And yeah it is terrible, but there is massive room for improvements, I am using ripped animations from the DS game and Nintendo somehow decided that 80 frames for a idle animation was a good idea... So I can cut down on them without effecting the feel and also keep the blocks in 1 frame instead of 4-5, not sure if it is slow on Switch due to CPU usage or memory usage, but I am inclined to believe the latter. (Don't see why a web applet for hotstop logins would get much memory allocation)
 

Ep8Script

Well-Known Member
Member
Joined
Aug 5, 2017
Messages
335
Trophies
0
XP
555
Country
Australia
Thanks! And yeah it is terrible, but there is massive room for improvements, I am using ripped animations from the DS game and Nintendo somehow decided that 80 frames for a idle animation was a good idea... So I can cut down on them without effecting the feel and also keep the blocks in 1 frame instead of 4-5, not sure if it is slow on Switch due to CPU usage or memory usage, but I am inclined to believe the latter. (Don't see why a web applet for hotstop logins would get much memory allocation)
Well good luck! Lmk when you get it running well, if you can pull it off. :)
 

naed06

Well-Known Member
OP
Member
Joined
May 16, 2017
Messages
127
Trophies
0
Age
42
XP
2,358
Country
Is there a way we can test the memory theory?

Maybe create a version of your NSMB with most of the stuff stripped out to see if there is any performance improvements?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-