Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display axis bar including digital value. #10

Open
NorioFujii opened this issue May 20, 2020 · 0 comments
Open

Display axis bar including digital value. #10

NorioFujii opened this issue May 20, 2020 · 0 comments

Comments

@NorioFujii
Copy link

NorioFujii commented May 20, 2020

Thank you awesome example program.
I have changed axis bar too convinient.

To display Axis bar including digital number value, add CSS.

.axis::before {
min-height: 14px;
content: attr(num);
color: red;
vertical-align: text-top;
font-size: x-small;
font-weight: bold;
margin-left: 3px;
}

And rewrite part of addgamepad function for "num" attribute,

var b = $("<div class='buttons'>");
for (var i=0; i<gamepad.buttons.length; i++) {
var e = $("<span class='button'>"+i+"</span>");
b.append(e);
}
d.append(b);
var a = $("<div class='axes'>");
for (i=0; i<gamepad.axes.length; i++) {
e = $("<progress class='axis'>",{"max":"2","value":"1","num":"ax"+i});
a.append(e);
}
d.append(a);
document.body.appendChild(d[0]);
rAF(updateStatus);

And updatestatus function too,
var a = axes[i];
a.setAttribute("max", "2");
a.setAttribute("num", "ax"+i+ ": " + controller.axes[i].toFixed(4));
a.setAttribute("value", controller.axes[i] + 1);

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant