Project - Virtual Switch Joystick

 
.The 360 degree travel returns 8 discrete directions as compass points, plus center Off
 Quick demo - LibraryYouTube

 The script is quite straightforward,
 all the heavy lifting being done by javascript.
 
 Upload "joy_cb.min.js.gz" to your device,
 it can be found at the bottom of this page.

 Another version of the script offers proportional control.
 Another offers joystick overlay for a Pan and Tilt cctv platform.


Basic:
'On-screen virtual Switch Joystick - Electroguard - developed on Annex 1.41 beta 6
title$ = "Virtual Joystick"
joy$ = ""
jsexternal "/
joy_cb.min.js.gz"
pause 500
gosub screen
onhtmlchange change                         
wait

screen:
cls
a$ = "<br><br>"
a$=a$ + |<div style='display: table; margin-right: auto; margin-left: auto;'>| + textbox$(title$,"t") + |</div>|+"<br>"
a$=a$ + |<div style='display: table; margin-right: auto; margin-left: auto;'>|
a$=a$ + |<div id="joyDiv" style="width:200px;height:200px;margin-bottom:20px;margin:10px"></div>|
a$=a$ + |<br><div style="display: table; margin-right: auto; margin-left: auto;">| + textbox$(joy$,"t") + |</div>|
a$=a$ + cssid$("t","text-align:center;border-style: none;")
autorefresh 100
html a$
a$ = |joy = new JoyStick('joyDiv');|
a$ = a$ + |joy.SetCallback(function(e) {connection.send('cmd:immediatxJOY$="' + e.GetDir() + '":HtmlEventVar$="joy$"\n' )});|
jscript a$
a$ = ""
return

change:

                               'joystick activity returns directions directly into joy$ textbox
return

End 
  '-------------------------   End   --------------------------






ċ
joy_cb.min.js.gz
(2k)
Robin Baker,
Apr 26, 2020, 8:30 AM
Comentarios