Skip to content
This repository has been archived by the owner on Feb 25, 2024. It is now read-only.

my dacman 5x7 conf #1

Draft
wants to merge 41 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5b71883
use encoding utf-8 to read keymap.c (#64)
yearski Dec 16, 2021
4e44d83
fix test (#66)
yskoht Dec 22, 2021
2e925c7
Update version
yskoht Dec 22, 2021
61ac7d2
Release 1.9.1
yskoht Dec 22, 2021
e287c9b
Ergodash 2u inner (#61)
yearski Dec 22, 2021
23efd74
refactor/update ascii art and layout: ergodash (#62)
yearski Dec 22, 2021
9e67351
Add --layout option (#68)
yskoht Dec 30, 2021
a6ad816
Merge ergodash_2u_inner into ergodash (#69)
yskoht Dec 30, 2021
dbac9ff
Add layout for each keyboard in help (#70)
yskoht Dec 30, 2021
72df5e3
Fix test (#71)
yskoht Dec 30, 2021
ba1a0ce
Update version
yskoht Dec 30, 2021
feab873
Release 1.10.0
yskoht Dec 30, 2021
06e92dd
Fix documents (#73)
yskoht Dec 30, 2021
bd16466
Update version
yskoht Dec 30, 2021
a9dde6c
Release 1.10.1
yskoht Dec 30, 2021
b9556e4
Add support for dactyl manuform 6x6 (#79)
tgermain Feb 27, 2022
920656c
Update version
yskoht Feb 27, 2022
c233eb5
Fix tests
yskoht Feb 27, 2022
1331620
Release 1.11.0
yskoht Feb 27, 2022
d45aacf
Add mit and grid planck layouts (#78)
renzmann Feb 28, 2022
cf10455
Refactoring (#81)
yskoht Mar 21, 2022
d8a792a
Update version
yskoht Mar 21, 2022
4924fb4
Release 1.12.0
yskoht Mar 21, 2022
2165793
Add support for id75 keyboard
asyncee Sep 19, 2022
c8c6f91
Merge pull request #83 from asyncee/develop
yskoht Sep 25, 2022
4e72b0a
Fix id75
yskoht Sep 25, 2022
55fe8a2
Fix README.md
yskoht Sep 25, 2022
5fc1a05
Fix crkbd test
yskoht Sep 25, 2022
dae8460
Fix ergo42 test
yskoht Sep 25, 2022
dea6fad
Fix ergodash test
yskoht Sep 25, 2022
6cc46f3
Fix fortitude60 test
yskoht Sep 25, 2022
64f6894
Fix helix test
yskoht Sep 25, 2022
ac46cdd
Fix kinesis test
yskoht Sep 25, 2022
881ec92
Fix lets_split test
yskoht Sep 25, 2022
26bfe7f
Fix moonlander test
yskoht Sep 25, 2022
eddb032
Fix sofle test
yskoht Sep 25, 2022
4277f81
Fix planck test
yskoht Sep 25, 2022
6a97c2b
Add test for id75
yskoht Sep 25, 2022
720625d
Update version
yskoht Sep 25, 2022
9499a5b
Release 1.13.0
yskoht Sep 25, 2022
83ba971
my dacman 5x7 conf
grota Oct 1, 2022
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
30 changes: 15 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

# Contributing

Your any contributions are welcome! Adding keyboard, fixing bug, updating document, adding test and creating new feature, etc.

- Getting code
- Creating feature branch from develop
- If you want to add a new keyboard
- Adding keymapviz/keyboards/*keyboard_name*/\_\_init__.py
- Adding keymapviz/keyboards/*keyboard_name*/layout_editor.json
- Fixing keymapviz/\_\_init__.py
- Fixing keymapviz/README.md
- Adding keymapviz/keyboards/_keyboard_name_/\_\_init\_\_.py
- Adding keymapviz/keyboards/_keyboard_name_/layout_editor/default.json
- Fixing keymapviz/\_\_init\_\_.py
- Fixing keymapviz/README.md
- Run
- Committing & push your code and
- Create pull request
Expand Down Expand Up @@ -37,33 +36,34 @@ $ git branch

## If you want to add a new keyboard

You need to add two new files. (Replace *keyboard_name* with the name of the keyboard you want to add.)
You need to add two new files. (Replace _keyboard_name_ with the name of the keyboard you want to add.)

- keymapviz/keyboards/*keyboard_name*/\_\_init__.py
- keymapviz/keyboards/*keyboard_name*/layout_editor.json
- keymapviz/keyboards/_keyboard_name_/\_\_init\_\_.py
- keymapviz/keyboards/_keyboard_name_/layout_editor/default.json

And fix two files.

- keymapviz/\_\_init__.py
- keymapviz/\_\_init\_\_.py
- keymapviz/README.md

### Adding keymapviz/keyboards/*keyboard_name*/\_\_init__.py
### Adding keymapviz/keyboards/_keyboard_name_/\_\_init\_\_.py

Define three variables in this file. `keymap_keyword`, `layout_editor_json` and `ascii_art`.
(`fancy_ascii_art` is optional.)

- `keymap_keyword`: The regular expression for the macro keywords used to define the keymap in `keymap.c` of qmk.
- `layout_editor_json`: The path to `layout_editor.json` file.
- `ascii_art`: ASCII art. `{}` is replaced by a key legend. If you want to place the key legend in a desired location, you need to write the key index in the bracket. Please refer to these files.
- [keymapviz/keyboards/lets_split/\_\_init__.py](#keymapviz/keyboards/lets_split/__init__.py)
- [keymapviz/keyboards/ergodox/\_\_init__.py](#keymapviz/keyboards/ergodox/__init__.py)
- [keymapviz/keyboards/lets_split/\_\_init\_\_.py](https://github.com/yskoht/keymapviz/blob/develop/keymapviz/keyboards/lets_split/__init__.py)
- [keymapviz/keyboards/ergodox/\_\_init\_\_.py](https://github.com/yskoht/keymapviz/blob/develop/keymapviz/keyboards/ergodox/__init__.py)

### Adding keymapviz/keyboards/*keyboard_name*/layout_editor.json
### Adding keymapviz/keyboards/_keyboard_name_/layout_editor/default.json

Download json of your keyboard from [http://www.keyboard-layout-editor.com/](http://www.keyboard-layout-editor.com/) and replace legend with `{number}`. Please refer to the file.

- [keymapviz/keyboards/lets_split/layout_editor.json](#keymapviz/keyboards/lets_split/layout_editor.json)
- [keymapviz/keyboards/lets_split/layout_editor/default.json](https://github.com/yskoht/keymapviz/blob/develop/keymapviz/keyboards/lets_split/layout_editor/default.json)

### Fixing keymapviz/\_\_init__.py
### Fixing keymapviz/\_\_init\_\_.py

Add keyboard.

Expand Down
40 changes: 27 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Keymapviz

[![Python Version](https://img.shields.io/badge/Python-3.x-blue.svg)](PythonVersion)
Expand All @@ -9,34 +8,38 @@ Keymapviz can convert keymap.c in [qmk_firmware](https://github.com/qmk/qmk_firm
Following keyboards are supported.

- [crkbd](https://github.com/qmk/qmk_firmware/tree/master/keyboards/crkbd)
- [dactyl_manuform5x6](https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired/dactyl_manuform/5x6)
- [dactyl_manuform6x6](https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired/dactyl_manuform/6x6)
- [ergo42](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergo42)
- [ergodash](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergodash)
- [ergodash](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergodash) (layout: `default`, `2u_inner`)
- [ergodone](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergodone)(ergodox)
- [ergodox_ez](https://github.com/qmk/qmk_firmware/tree/master/keyboards/ergodox_ez)(ergodox)
- [fortitude60](https://github.com/qmk/qmk_firmware/tree/master/keyboards/fortitude60)
- [helix](https://github.com/qmk/qmk_firmware/tree/master/keyboards/helix)
- [kaishi65](https://github.com/qmk/qmk_firmware/tree/master/keyboards/kbdclack/kaishi65)
- [id75](https://github.com/qmk/qmk_firmware/tree/master/keyboards/idobao/id75)
- [kaishi65](https://github.com/qmk/qmk_firmware/tree/master/keyboards/kbdclack/kaishi65)
- [kinesis](https://github.com/qmk/qmk_firmware/tree/master/keyboards/kinesis)
- [kyria](https://github.com/qmk/qmk_firmware/tree/master/keyboards/splitkb/kyria)
- [lets_split](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lets_split)
- [lily58](https://github.com/qmk/qmk_firmware/tree/master/keyboards/lily58)
- [mint60](https://github.com/qmk/qmk_firmware/tree/master/keyboards/mint60)
- [sweet16](https://github.com/qmk/qmk_firmware/tree/master/keyboards/1upkeyboards/sweet16)
- [dactyl_manuform5x6](https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired/dactyl_manuform/5x6)
- [sofle](https://github.com/qmk/qmk_firmware/tree/master/keyboards/sofle)
- [moonlander](https://github.com/qmk/qmk_firmware/tree/master/keyboards/moonlander)
- [planck](https://github.com/qmk/qmk_firmware/tree/master/keyboards/planck) (layout: `default`(=`grid`), `mit`)
- [sofle](https://github.com/qmk/qmk_firmware/tree/master/keyboards/sofle)
- [sweet16](https://github.com/qmk/qmk_firmware/tree/master/keyboards/1upkeyboards/sweet16)
- [dactyl_manuform5x7](https://github.com/qmk/qmk_firmware/tree/master/keyboards/handwired/dactyl_manuform/5x7)

## Install

Keymapviz works with ***Python3***.
Keymapviz works with **_Python3_**.

```sh
$ pip3 install keymapviz
```

## Usage

Output ascii art.
### Output ascii art

```sh
$ keymapviz qmk_firmware/keyboards/ergodox_ez/keymaps/default/keymap.c
Expand Down Expand Up @@ -110,34 +113,39 @@ $ keymapviz qmk_firmware/keyboards/ergodox_ez/keymaps/default/keymap.c
*/
```

Legend replacements.
### Legend replacements

A config file containing legend replacements can be provided to change the legends to your liking. It should have a section named 'legends' and e.g. look like:

```
[legends]
KC_BLSLS=\
KC_QUOT='
```

It can then be provided on the commandline like:

```
$ keymapviz qmk_firmware/keyboards/lets_split/keymaps/default/keymap.c -c /path/to/config.properties
```

An example file is provided in the root of this project, named `config.properties`.

Output json file.
This json file can be used in [http://www.keyboard-layout-editor.com/](http://www.keyboard-layout-editor.com/).


```sh
$ keymapviz qmk_firmware/keyboards/lets_split/keymaps/default/keymap.c -t json -o 'lets_split{}.json'
$ ls lets_split*.json
lets_split0.json lets_split1.json lets_split2.json lets_split3.json lets_split4.json lets_split5.json
```

Output fancy ascii art.
### Output fancy ascii art

Uses unicode symbols for drawing the box outlines.

```sh
$ keymapviz -t fancy ~/qmk_firmware/keyboards/kbdclack/kaishi65/keymaps/default/keymap.c
$ keymapviz -t fancy qmk_firmware/keyboards/kbdclack/kaishi65/keymaps/default/keymap.c

/*┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬────┐
*│ES │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ MI│ EQ│ BS │ GR │
Expand Down Expand Up @@ -168,12 +176,18 @@ $ keymapviz -t fancy ~/qmk_firmware/keyboards/kbdclack/kaishi65/keymaps/default
*/
```

Replace ascii-art in keymap.c. (Generate backup as keymap.c.bac)
### Replace ascii-art in keymap.c

Generate backup as keymap.c.bac

```sh
$ keymapviz -r keymap.c
```

## Contributing

Please see [CONTRIBUTING.md](./CONTRIBUTING.md).

## License

This software is released under the MIT License, see LICENSE.
31 changes: 25 additions & 6 deletions keymapviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
import keymapviz.keyboards.lily58
import keymapviz.keyboards.sweet16
import keymapviz.keyboards.dactyl_manuform5x6
import keymapviz.keyboards.dactyl_manuform5x7
import keymapviz.keyboards.sofle
import keymapviz.keyboards.moonlander
import keymapviz.keyboards.planck
import keymapviz.keyboards.dactyl_manuform6x6
import keymapviz.keyboards.id75


KEYBOARDS = {
Expand All @@ -42,16 +46,21 @@
'kyria': keymapviz.keyboards.kyria,
'sweet16': keymapviz.keyboards.sweet16,
'dactyl_manuform5x6': keymapviz.keyboards.dactyl_manuform5x6,
'dactyl_manuform5x7': keymapviz.keyboards.dactyl_manuform5x7,
'sofle': keymapviz.keyboards.sofle,
'moonlander': keymapviz.keyboards.moonlander,
'planck': keymapviz.keyboards.planck,
'dactyl_manuform6x6': keymapviz.keyboards.dactyl_manuform6x6,
'id75': keymapviz.keyboards.id75,
}


class Keymapviz():
def __init__(self, keyboard, keymap_c, legends = None):
def __init__(self, keyboard, keymap_c, layout = None, legends = None):
self.__keymap_c = keymap_c.read()
self.keyboard = KEYBOARDS[keyboard]
self.keymaps = self.__parse_keymap_c()
self.layout = layout if layout else 'default'
self.legends = legends if legends else {}


Expand Down Expand Up @@ -106,13 +115,22 @@ def __get_final_ascii_art(self, ascii_art):
self.__ascii_art = [aa.format(*self.__legends(_)) for _ in self.keymaps]
return self.__ascii_art

def ascii_art(self):
return self.__get_final_ascii_art(self.keyboard.ascii_art)

def __get_layout(self, format, layout):
try:
return format[layout]
except KeyError:
print('The keyboard dose not have the layout `{}`.'.format(layout), file=sys.stderr)
sys.exit(1)

def ascii_art(self):
aa = self.__get_layout(self.keyboard.ascii_art, self.layout)
return self.__get_final_ascii_art(aa)

def layout_editor_json(self):
path_ = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(path_, self.keyboard.layout_editor_json)) as f:
json_file = self.__get_layout(self.keyboard.layout_editor_json, self.layout)
with open(os.path.join(path_, json_file)) as f:
json_ = json.load(f)
return [self.__json_format(json_, _) for _ in self.keymaps]

Expand Down Expand Up @@ -151,8 +169,9 @@ def __get_box_drawing(self, left, down, up, right, center):
def fancy_art(self):
if hasattr(self.keyboard, 'fancy_ascii_art'):
# There already exists a man-made fancy ascii art for this keyboard.
return self.__get_final_ascii_art(self.keyboard.fancy_ascii_art)
aa = self.keyboard.ascii_art
faa = self.__get_layout(self.keyboard.fancy_ascii_art, self.layout)
return self.__get_final_ascii_art(faa)
aa = self.__get_layout(self.keyboard.ascii_art, self.layout)
keymapviz_signature_pattern = r'[A-Za-z ]*\[keymapviz\].*\*/\s*$'
# If the keymapviz signature is adjacent to certain outline characters,
# self.__get_box_drawing will incorrectly interpret the characters composing the signature
Expand Down
11 changes: 7 additions & 4 deletions keymapviz/keyboards/crkbd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-

keymap_keyword = '(?:LAYOUT|LAYOUT_kc|LAYOUT_split_3x6_3)'
layout_editor_json = 'keyboards/crkbd/layout_editor.json'
layout_editor_json = {
'default': 'keyboards/crkbd/layout_editor/default.json',
}

ascii_art = '''
ascii_art = {
'default': '''
/* ,-----------------------------------------. ,-----------------------------------------.
* |{ }|{ }|{ }|{ }|{ }|{ }| |{ }|{ }|{ }|{ }|{ }|{ }|
* |------+------+------+------+------+------| |------+------+------+------+------+------|
Expand All @@ -14,5 +17,5 @@
* |{ }|{ }|{ }| |{ }|{ }|{ }|
* `--------------------' `--------------------'
* generated by [keymapviz] */
'''

''',
}
16 changes: 11 additions & 5 deletions keymapviz/keyboards/dactyl_manuform5x6/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# -*- coding: utf-8 -*-

keymap_keyword = '(?:KEYMAP|LAYOUT_5x6)'
layout_editor_json = 'keyboards/dactyl_manuform5x6/layout_editor.json'
layout_editor_json = {
'default': 'keyboards/dactyl_manuform5x6/layout_editor/default.json',
}

ascii_art = '''
ascii_art = {
'default': '''
/* ,-------------------------------. ,-------------------------------.
* ,---------------|{ 2 }|{ 3 }|{ 4 }|{ 5 }| |{ 6 }|{ 7 }|{ 8 }|{ 9 }|--------------.
* |{ 0 }|{ 1 }|-------+-------+-------+-------| |-------+-------+-------+-------|{ 10 }|{ 11 }|
Expand All @@ -22,9 +25,11 @@
* |-------+-------| |-------+-------|
* |{ 60 }|{ 61 }| |{ 62 }|{ 63 }|
* `---------------' `---------------' generated by [keymapviz] */
'''
''',
}

fancy_ascii_art = '''
fancy_ascii_art = {
'default': '''
/* ┌───────┬───────┬───────┬───────┐ ┌───────┬───────┬───────┬───────┐
* ┌───────┬───────┤{ 2 }│{ 3 }│{ 4 }│{ 5 }│ │{ 6 }│{ 7 }│{ 8 }│{ 9 }├───────┬──────┐
* │{ 0 }│{ 1 }├───────┼───────┼───────┼───────┤ ├───────┼───────┼───────┼───────┤{ 10 }│{ 11 }│
Expand All @@ -43,4 +48,5 @@
* ├───────╄━━━━━━━┩ ┡━━━━━━━╃───────┤
* │{ 60 }│{ 61 }│ │{ 62 }│{ 63 }│
* └───────┴───────┘ └───────┴───────┘ generated by [keymapviz] */
'''
''',
}
53 changes: 53 additions & 0 deletions keymapviz/keyboards/dactyl_manuform5x7/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-

keymap_keyword = '(?:KEYMAP|LAYOUT_5x7_sym)'
layout_editor_json = {
'default': 'keyboards/dactyl_manuform5x6/layout_editor/default.json',
}

ascii_art = {
'default': '''
/*
/* ,-------------------------------------------------------. ,-------------------------------------------------------.
* |{ 0 }|{ 1 }|{ 2 }|{ 3 }|{ 4 }|{ 5 }|{ 6 }| |{ 7 }|{ 8 }|{ 9 }|{ 10 }|{ 11 }|{ 12 }|{ 13 }|
* |-------+-------|-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
* |{ 14 }|{ 15 }|{ 16 }|{ 17 }|{ 18 }|{ 19 }|{ 20 }| |{ 21 }|{ 22 }|{ 23 }|{ 24 }|{ 25 }|{ 26 }|{ 27 }|
* |-------+-------|-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
* |{ 28 }|{ 29 }|{ 30 }|{ 31 }|{ 32 }|{ 33 }|{ 34 }| |{ 35 }|{ 36 }|{ 37 }|{ 38 }|{ 39 }|{ 40 }|{ 41 }|
* |-------+-------|-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
* |{ 42 }|{ 43 }|{ 44 }|{ 45 }|{ 46 }|{ 47 }|{ 48 }| |{ 49 }|{ 50 }|{ 51 }|{ 52 }|{ 53 }|{ 54 }|{ 55 }|
* |-------+-------|-------+-------+-------+-------+-------| |-------+-------+-------+-------+-------+-------+-------|
* |{ 56 }|{ 57 }|{ 58 }|{ 59 }| |{ 60 }|{ 61 }|{ 62 }|{ 63 }|
* `-------+-------|-------+-------+ +-------+-------+-------+-------'
* ,---------------. ,---------------.
* |{ 64 }|{ 65 }| |{ 66 }|{ 67 }|
* `-------+-------+-------| ,-------+-------+-------'
* |{ 68 }|{ 69 }| |{ 70 }|{ 71 }|
* |-------+-------| |-------+-------|
* |{ 72 }|{ 73 }| |{ 74 }|{ 75 }|
* `---------------' `---------------' generated by [keymapviz] */
''',
}

fancy_ascii_art = {
'default': '''
/* ┌───────┬───────┬───────┬───────┬───────┬───────┬───────┐ ┌───────┬───────┬───────┬───────┬───────┬───────┬───────┐
* │{ 0 }│{ 1 }│{ 2 }│{ 3 }│{ 4 }│{ 5 }│{ 6 }│ │{ 7 }│{ 8 }│{ 9 }│{ 10 }│{ 11 }│{ 12 }│{ 13 }│
* ├───────┼───────┼───────┼───────┼───────┼───────┼───────│ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┤
* │{ 14 }│{ 15 }│{ 16 }│{ 17 }│{ 18 }│{ 19 }│{ 20 }│ │{ 21 }│{ 22 }│{ 23 }│{ 24 }│{ 25 }│{ 26 }│{ 27 }│
* ├───────┼───────┼───────┼───────┼───────┼───────┼───────│ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┤
* │{ 28 }│{ 29 }│{ 30 }│{ 31 }│{ 32 }│{ 33 }│{ 34 }│ │{ 35 }│{ 36 }│{ 37 }│{ 38 }│{ 39 }│{ 40 }│{ 41 }│
* ├───────┼───────┼───────┼───────┼───────┼───────┼───────│ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┤
* │{ 42 }│{ 43 }│{ 44 }│{ 45 }│{ 46 }│{ 47 }│{ 48 }│ │{ 49 }│{ 50 }│{ 51 }│{ 52 }│{ 53 }│{ 54 }│{ 55 }│
* ├───────┼───────┼───────┼───────┼───────┴───────┴───────┘ └───────┴───────┴───────┼───────┼───────┼───────┼───────┤
* │{ 56 }│{ 57 }│{ 58 }│{ 59 }│ │{ 60 }│{ 61 }│{ 62 }│{ 63 }│
* └───────┴───────┴───────┴───────┘ └───────┴───────┴───────┴───────┘
* ┌───────┬───────┐ ┌───────┬───────┐
* │{ 64 }│{ 65 }│ │{ 66 }│{ 67 }│
* └───────┼───────┼───────┐ ┌───────┼───────┼───────┘
* │{ 68 }│{ 69 }│ │{ 70 }│{ 71 }│
* ├───────┼───────│ ├───────┼───────┤
* │{ 72 }│{ 73 }│ │{ 74 }│{ 75 }│
* └───────┴───────┘ └───────┴───────┘ generated by [keymapviz] */
''',
}
Loading