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

Chrome + Linux + Logitech Dual Action #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Quick start

Add

<script src=".../gamepad.js" type="text/javascript"></script>
<script src="../gamepad.js" type="text/javascript"></script>

to your html.

Expand Down
65 changes: 33 additions & 32 deletions build.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# Simple script to slurp all the icons we have, convert them to data urls, and
# append to gamepad_no_images.js to create the final gamepad.js that most
# people will want to use.

import base64
import platform
import os
import sys

def main():
result = ''
for device in os.listdir("images"):
cur_dir = os.path.join("images", device)
result += "var Gamepad_ImageDataUrls_%s = {};\n" % device
for image in os.listdir(cur_dir):
basename, ext = os.path.splitext(image)
if ext == '.png':
data = base64.standard_b64encode(open(os.path.join(cur_dir, image), 'rb').read())
result += ("Gamepad_ImageDataUrls_%s.%s = 'data:image/png;base64,%s';\n" % (device, basename, data))
final = open("gamepad_no_images.js", "rb").read()
open("gamepad_uncompressed.js", "wb").write(final.replace("// @IMAGEDATAURLS@\n", result))

javaPath = 'java'
# no idea.
if sys.platform == 'win32' and platform.architecture()[0] == '64bit':
javaPath = "c:\\windows\\SysWow64\\java.exe"
ret = os.system(javaPath + " -jar closure/compiler.jar --js gamepad_uncompressed.js --js_output_file gamepad.js --compilation_level SIMPLE_OPTIMIZATIONS")
if ret != 0:
return ret

if __name__ == "__main__":
sys.exit(main())
#!/usr/bin/python
# Simple script to slurp all the icons we have, convert them to data urls, and
# append to gamepad_no_images.js to create the final gamepad.js that most
# people will want to use.

import base64
import platform
import os
import sys

def main():
result = ''
for device in os.listdir("images"):
cur_dir = os.path.join("images", device)
result += "var Gamepad_ImageDataUrls_%s = {};\n" % device
for image in os.listdir(cur_dir):
basename, ext = os.path.splitext(image)
if ext == '.png':
data = base64.standard_b64encode(open(os.path.join(cur_dir, image), 'rb').read())
result += ("Gamepad_ImageDataUrls_%s.%s = 'data:image/png;base64,%s';\n" % (device, basename, data))
final = open("gamepad_no_images.js", "rb").read()
open("gamepad_uncompressed.js", "wb").write(final.replace("// @IMAGEDATAURLS@\n", result))

javaPath = 'java'
# no idea.
if sys.platform == 'win32' and platform.architecture()[0] == '64bit':
javaPath = "c:\\windows\\SysWow64\\java.exe"
ret = os.system(javaPath + " -jar closure/compiler.jar --js gamepad_uncompressed.js --js_output_file gamepad.js --compilation_level SIMPLE_OPTIMIZATIONS")
if ret != 0:
return ret

if __name__ == "__main__":
sys.exit(main())
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ <h1 id='title'></h1>
for (var j = 0; j < names.length; ++j) {
var name = names[j];
var buttonDom = document.getElementById('pad' + i + '_' + names[j]);
buttonDom.src = pad.images[name];
if (pad.images) buttonDom.src = pad.images[name];
if (j >= 2)
buttonDom.style.opacity = pad[name] / 0.8 + 0.2;
}
Expand Down
Loading