• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

修订版adcfa63406c1d04d38a40ad5f0e5eaf259424c5c (tree)
时间2020-03-25 23:43:22
作者shimitei <shimitei@gmai...>
Commitershimitei

Log Message

post keydown-event to worker

更改概述

差异

--- a/src/makefile.em
+++ b/src/makefile.em
@@ -2,8 +2,8 @@
22
33 CC = emcc
44 LD = emcc
5-CFLAGS = -fPIC
6-LDFLAGS = -v -s EXIT_RUNTIME=1
5+CFLAGS = -fPIC -s ASYNCIFY=1
6+LDFLAGS = -v -s EXIT_RUNTIME=1 -s ALLOW_MEMORY_GROWTH=1 -s ASYNCIFY=1
77 DEFINES =
88
99 TARGET_FILE = hengband.html
@@ -57,7 +57,7 @@ prebuild :
5757 # ln -s ../lib lib
5858
5959 $(TARGET_FILE): $(OBJS)
60- $(LD) $(LDFLAGS) $(OBJS) --preload-file lib -o $(TARGET_FILE)
60+ $(LD) $(LDFLAGS) $(OBJS) --js-library worker.message.js --preload-file lib -o $(TARGET_FILE)
6161
6262 .SUFFIXES: .c .bc
6363 .c.bc:
--- /dev/null
+++ b/src/worker.message.js
@@ -0,0 +1,3 @@
1+onmessage = function(e) {
2+ console.log('worker:', e);
3+}
--- a/webworker.html
+++ b/webworker.html
@@ -1,11 +1,14 @@
11 <html>
2+<canvas id="canvas" oncontextmenu="event.preventDefault()" width="640px" height="480px" tabindex=-1></canvas>
23 <script>
34 var worker = new Worker("hengband.js");
4-worker.onerror = function (e) {
5- console.log(e);
5+worker.onmessage = function(e) {
6+ console.log('main:', e);
67 }
7-worker.onmessage = function (e) {
8- console.log(e.data);
8+
9+canvas.addEventListener('keydown', onKeydown);
10+function onKeydown(e) {
11+ worker.postMessage({keyCode: e.keyCode, ctrlKey: e.ctrlKey, shiftKey: e.shiftKey});
912 }
1013 </script>
11-</html>>
\ No newline at end of file
14+</html>
\ No newline at end of file