Last active
June 29, 2024 09:31
-
-
Save sago35/79c8ea1f1b55202aa6c95d76f26325aa to your computer and use it in GitHub Desktop.
Dockerfile for vial-web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:22.04 | |
RUN apt-get update && apt-get install -y tzdata | |
# timezone setting | |
ENV TZ=Asia/Tokyo | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
bash \ | |
xz-utils \ | |
bzip2 \ | |
wget \ | |
python3-openssl \ | |
build-essential libssl-dev zlib1g-dev \ | |
libbz2-dev libreadline-dev libsqlite3-dev curl \ | |
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev | |
RUN ln -s /usr/bin/python3 /usr/bin/python | |
WORKDIR /app | |
RUN git clone https://github.com/vial-kb/vial-web.git | |
WORKDIR /app/vial-web | |
RUN git clone https://github.com/vial-kb/vial-gui.git | |
#RUN git clone https://github.com/sago35/vial-gui.git && cd vial-gui && git checkout debug | |
RUN git clone https://github.com/vial-kb/via-keymap-precompiled.git | |
RUN chmod +x fetch-emsdk.sh fetch-deps.sh build-deps.sh | |
RUN ./fetch-emsdk.sh | |
RUN ./fetch-deps.sh | |
RUN ./build-deps.sh | |
WORKDIR /app/vial-web/src | |
RUN chmod +x build.sh | |
RUN ./build.sh | |
WORKDIR /app/vial-web/src/build | |
COPY server.py /app/vial-web/src/server.py | |
EXPOSE 8000 | |
CMD ["python", "../server.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from http.server import HTTPServer, SimpleHTTPRequestHandler, test | |
import sys | |
class CORSRequestHandler (SimpleHTTPRequestHandler): | |
def end_headers (self): | |
self.send_header('Access-Control-Allow-Origin', '*') | |
self.send_header('Cross-Origin-Embedder-Policy', 'require-corp') | |
self.send_header('Cross-Origin-Opener-Policy', 'same-origin') | |
SimpleHTTPRequestHandler.end_headers(self) | |
if __name__ == '__main__': | |
test(CORSRequestHandler, HTTPServer, port=int(sys.argv[1]) if len(sys.argv) > 1 else 8000) |
以下で server を立ち上げる。
$ docker run -p 8000:8000 -it vial-web-debug bash
$ cd /app/vial-web/src/build
$ python server.py
こんな感じに変更すると JIS な配列を読み込めているように見える。
実際の remap の動作 (USB にどのようなデータが流れるか) は確認していない。
root@6c284f6ca145:/app/vial-web/src# cat ../vial-gui/src/main/python/keymaps.py
from keycodes.keycodes import Keycode
from keymap import brazilian, canadian_csa, danish, eurkey, french, german, hebrew, hungarian, japanese, latam, norwegian, russian, slovak, spanish, swedish, swedish_swerty, swiss
KEYMAPS = [
("QWERTY", dict()),
("Brazilian (QWERTY)", brazilian.keymap),
("Canadian CSA (QWERTY)", canadian_csa.keymap),
("Danish (QWERTY)", danish.keymap),
("EurKey (QWERTY)", eurkey.keymap),
("French (AZERTY)", french.keymap),
("French (MAC)", french.keymap_mac),
("German (QWERTZ)", german.keymap),
("Hebrew (Standard)", hebrew.keymap),
("Hungarian (QWERTZ)", hungarian.keymap),
("Japanese (QWERTZ)", japanese.keymap),
("Latin American (QWERTY)", latam.keymap),
("Norwegian (QWERTY)", norwegian.keymap),
("Russian (ЙЦУКЕН)", russian.keymap),
("Slovak (QWERTY)", slovak.keymap),
("Spanish (QWERTY)", spanish.keymap),
("Swedish (QWERTY)", swedish.keymap),
("Swedish (SWERTY)", swedish_swerty.keymap),
("Swiss (QWERTZ)", swiss.keymap)
]
# make sure that qmk IDs we used are all correct
for name, keymap in KEYMAPS:
for qmk_id in keymap.keys():
if Keycode.find_by_qmk_id(qmk_id) is None:
raise RuntimeError("Misconfigured - cannot find QMK keycode {}".format(qmk_id))
root@6c284f6ca145:/app/vial-web/src# cat ../vial-gui/src/main/python/keymap/japanese.py
# coding: utf-8
keymap = {
"KC_LBRACKET": "`\n@",
"KC_RBRACKET": "{\n[",
"KC_2": "\"\n2",
"KC_6": "&\n6",
"KC_7": "'\n7",
"KC_8": "(\n8",
"KC_9": ")\n9",
"KC_0": "\n0",
"KC_MINUS": "=\n-",
"KC_EQUAL": "~\n^",
"KC_SCOLON": "+\n;",
"KC_QUOTE": "*\n:",
"KC_NONUS_HASH": "}\n]",
"KC_GRAVE": "HAN/\nZEN",
"KC_KP_DOT": ","
}
上記の japanese.py (japanese.keymap) を使ってみた結果が以下。ちゃんと意図通りになっている模様。
https://twitter.com/sago35tk/status/1688145941277392898?s=20
以下を実行すると USB のやり取りを Chrome 等の dev console から見ることができる。
$ git revert 5c198e1ec60f3dfe3376503f35291b7ee7b4ced8
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
以下の vial-web 用の設定。
https://github.com/vial-kb/vial-web