improved triggers management

This commit is contained in:
e7d 2016-05-13 21:28:50 +02:00
parent 5101c63963
commit 9d665ba625
4 changed files with 54 additions and 2 deletions

View File

@ -3,39 +3,52 @@
width: 806px; width: 806px;
height: 598px; height: 598px;
} }
.gamepad.white { .gamepad.white {
background-image: url(base-white.svg); background-image: url(base-white.svg);
} }
.gamepad.disconnected { .gamepad.disconnected {
background-image: url(disconnected.svg); background-image: url(disconnected.svg);
} }
.gamepad.disconnected div { .gamepad.disconnected div {
display: none; display: none;
} }
.gamepad .triggers { .gamepad .triggers {
width: 588px; width: 588px;
height: 90px; height: 90px;
position: absolute; position: absolute;
left: 109px; left: 109px;
} }
.gamepad .trigger { .gamepad .trigger {
width: 99px; width: 99px;
height: 100%; height: 100%;
background: url(triggers.svg); background: url(triggers.svg);
} }
.gamepad .trigger[data-value="0"] {
opacity: 0;
}
.gamepad .trigger.left { .gamepad .trigger.left {
float: left; float: left;
} }
.gamepad .trigger.right { .gamepad .trigger.right {
float: right; float: right;
background-position-x: 99px; background-position-x: 99px;
} }
.gamepad .bumper { .gamepad .bumper {
width: 99px; width: 99px;
height: 23px; height: 23px;
background: url(bumper.svg) no-repeat; background: url(bumper.svg) no-repeat;
opacity: 0; opacity: 0;
} }
.gamepad .bumpers { .gamepad .bumpers {
position: absolute; position: absolute;
width: 588px; width: 588px;
@ -43,18 +56,22 @@
left: 109px; left: 109px;
top: 94px; top: 94px;
} }
.gamepad .bumper[data-pressed="true"] { .gamepad .bumper[data-pressed="true"] {
opacity: 1; opacity: 1;
} }
.gamepad .bumper.left { .gamepad .bumper.left {
/* -webkit-transform: rotateY(180deg); */ /* -webkit-transform: rotateY(180deg); */
/* transform: rotateY(180deg); */ /* transform: rotateY(180deg); */
float: left; float: left;
} }
.gamepad .bumper.right { .gamepad .bumper.right {
float: right; float: right;
transform: rotateY(180deg); transform: rotateY(180deg);
} }
.gamepad .touchpad { .gamepad .touchpad {
width: 262px; width: 262px;
height: 151px; height: 151px;
@ -62,9 +79,11 @@
left: 272px; left: 272px;
top: 122px; top: 122px;
} }
.gamepad .touchpad[data-pressed="true"] { .gamepad .touchpad[data-pressed="true"] {
background: url(touchpad.svg) no-repeat center; background: url(touchpad.svg) no-repeat center;
} }
.gamepad .meta { .gamepad .meta {
width: 42px; width: 42px;
height: 42px; height: 42px;
@ -72,9 +91,11 @@
left: 382px; left: 382px;
bottom: 216px; bottom: 216px;
} }
.gamepad .meta[data-pressed="true"] { .gamepad .meta[data-pressed="true"] {
background: url(meta.svg) no-repeat center; background: url(meta.svg) no-repeat center;
} }
.gamepad .arrows { .gamepad .arrows {
position: absolute; position: absolute;
width: 352px; width: 352px;
@ -82,22 +103,27 @@
top: 142px; top: 142px;
left: 227px; left: 227px;
} }
.gamepad .select, .gamepad .start { .gamepad .select, .gamepad .start {
background: url(start.svg); background: url(start.svg);
width: 28px; width: 28px;
height: 46px; height: 46px;
opacity: 0; opacity: 0;
} }
.gamepad .select[data-pressed="true"], .gamepad .start[data-pressed="true"] { .gamepad .select[data-pressed="true"], .gamepad .start[data-pressed="true"] {
opacity: 1; opacity: 1;
} }
.gamepad .select { .gamepad .select {
float: left; float: left;
} }
.gamepad .start { .gamepad .start {
float: right; float: right;
background-position: 28px 0; background-position: 28px 0;
} }
.gamepad .buttons { .gamepad .buttons {
position: absolute; position: absolute;
width: 170px; width: 170px;
@ -105,33 +131,40 @@
top: 159px; top: 159px;
left: 567px; left: 567px;
} }
.gamepad .button { .gamepad .button {
position: absolute; position: absolute;
width: 56px; width: 56px;
height: 56px; height: 56px;
background: url(buttons.svg); background: url(buttons.svg);
} }
.gamepad .button[data-pressed="true"] { .gamepad .button[data-pressed="true"] {
background-position-y: 56px; background-position-y: 56px;
} }
.gamepad .a { .gamepad .a {
background-position: 0 0; background-position: 0 0;
bottom: 0px; bottom: 0px;
left: 56px; left: 56px;
} }
.gamepad .b { .gamepad .b {
background-position: -56px 0; background-position: -56px 0;
top: 56px; top: 56px;
right: 0px; right: 0px;
} }
.gamepad .x { .gamepad .x {
background-position: 112px 0; background-position: 112px 0;
top: 56px; top: 56px;
} }
.gamepad .y { .gamepad .y {
background-position: 56px 0; background-position: 56px 0;
left: 56px; left: 56px;
} }
.gamepad .sticks { .gamepad .sticks {
position: absolute; position: absolute;
width: 361px; width: 361px;
@ -139,26 +172,32 @@
top: 308px; top: 308px;
left: 228px; left: 228px;
} }
.gamepad .stick { .gamepad .stick {
position: absolute; position: absolute;
background: url(sticks.svg); background: url(sticks.svg);
height: 94px; height: 94px;
width: 94px; width: 94px;
} }
.gamepad .stick[data-pressed="true"].left { .gamepad .stick[data-pressed="true"].left {
background-position-x: -96px; background-position-x: -96px;
} }
.gamepad .stick[data-pressed="true"].right { .gamepad .stick[data-pressed="true"].right {
background-position-x: -192px; background-position-x: -192px;
} }
.gamepad .stick.left { .gamepad .stick.left {
top: 0; top: 0;
left: 0; left: 0;
} }
.gamepad .stick.right { .gamepad .stick.right {
top: calc(100% - 105px); top: calc(100% - 105px);
left: calc(100% - 105px); left: calc(100% - 105px);
} }
.gamepad .dpad { .gamepad .dpad {
position: absolute; position: absolute;
width: 125px; width: 125px;
@ -166,42 +205,51 @@
top: 181px; top: 181px;
left: 92px; left: 92px;
} }
.gamepad .face { .gamepad .face {
background: url(dpad.svg); background: url(dpad.svg);
position: absolute; position: absolute;
} }
.gamepad .face.up, .gamepad .face.down { .gamepad .face.up, .gamepad .face.down {
width: 36px; width: 36px;
height: 52px; height: 52px;
} }
.gamepad .face.left, .gamepad .face.right { .gamepad .face.left, .gamepad .face.right {
width: 52px; width: 52px;
height: 36px; height: 36px;
} }
.gamepad .face.up { .gamepad .face.up {
left: 44px; left: 44px;
top: 0; top: 0;
background-position: -37px 0px; background-position: -37px 0px;
} }
.gamepad .face.down { .gamepad .face.down {
left: 44px; left: 44px;
bottom: 0; bottom: 0;
background-position: 0px 0; background-position: 0px 0;
} }
.gamepad .face.left { .gamepad .face.left {
top: 44px; top: 44px;
left: 0; left: 0;
background-position: 104px 0; background-position: 104px 0;
} }
.gamepad .face.right { .gamepad .face.right {
top: 44px; top: 44px;
right: 0px; right: 0px;
background-position: 52px 0; background-position: 52px 0;
} }
.gamepad .face[data-pressed="true"] { .gamepad .face[data-pressed="true"] {
/* margin-top: 5px; */ /* margin-top: 5px; */
background-position-y: 52px; background-position-y: 52px;
} }
.gamepad.half { .gamepad.half {
margin-top: -300px; margin-top: -300px;
} }

View File

@ -1,5 +1,5 @@
function updateButton($button) { function updateButton($button) {
value = $button.attr('data-value'); value = parseFloat($button.attr('data-value'), 10);
if ($button.is('.trigger')) { if ($button.is('.trigger')) {
$button.css({ $button.css({

View File

@ -30,6 +30,10 @@
opacity: 1; opacity: 1;
} }
.gamepad .trigger[data-value="0"] {
opacity: 0;
}
.gamepad .trigger.left { .gamepad .trigger.left {
float: left; float: left;
background-position: 0 0; background-position: 0 0;

View File

@ -1,5 +1,5 @@
function updateButton($button) { function updateButton($button) {
value = $button.attr('data-value'); value = parseFloat($button.attr('data-value'), 10);
if ($button.is('.trigger')) { if ($button.is('.trigger')) {
$button.css({ $button.css({