preview_generator: remove

This commit is contained in:
He4eT 2023-12-04 13:55:00 +01:00 committed by Alexey
commit 7c1ac23768
4 changed files with 0 additions and 206 deletions

View file

@ -24,21 +24,3 @@ flash:
@make keymap_copy
@make qmk_flash
@make keymap_clean
# Creating layer previews:
# make preview[_copy] [layer=number]
layer = -1
preview_cmd = node \
./preview_generator/preview_generator.js \
"${PWD}/keymap/keymap.c" \
"$(layer)"
preview:
@${preview_cmd}
preview_copy:
@${preview_cmd} | xclip -sel clipboard
@echo 'The layout has been copied to the clipboard!'
@echo 'Paste it into the "Raw Data" tab here:'
@echo 'http://www.keyboard-layout-editor.com/'

View file

@ -1,119 +0,0 @@
const legends = {
'NO': '',
'TRNS': '▽',
'MO(1': 'FN1',
'MO(2': 'Mouse\nmode',
'GRV': '~\n`',
'1': '!\n1',
'2': '@\n2',
'3': '#\n3',
'4': '$\n4',
'5': '%\n5',
'6': '^\n6',
'7': '&\n7',
'8': '*\n8',
'9': '(\n9',
'0': ')\n0',
'MINS': '_\n',
'EQL': '+\n=',
'SLSH': '?\n/',
'BSLS': '|\n\\',
'LBRC': '{\n[',
'RBRC': '}\n]',
'SCLN': ':\n;',
'QUOT': '"\n\'',
'COMM': '<\n,',
'DOT': '>\n.',
'GT': '>',
'LT': '<',
'LPRN': '(',
'RPRN': ')',
'LCBR': '{',
'RCBR': '}',
'PLUS': '+',
'PMNS': '',
'PAST': '*',
'PSLS': '/',
'PEQL': '=',
'UNDS': '_',
'ESC': 'Esc',
'ENT': 'Enter',
'SPC': 'Space',
'BSPC': 'Back\nSpace',
'TAB': 'Tab',
'CAPS': 'Caps\nLock',
'LCTL': 'Ctrl',
'RCTL': 'Ctrl',
'LALT': 'Alt',
'RALT': 'Alt',
'LSFT': 'Shift',
'RSFT': 'Shift',
'LGUI': 'OS',
'RGUI': 'OS',
'LCTL_T(ESC': 'Ctrl\nEsc',
'RCTL_T(ESC': 'Ctrl\nEsc',
'OSM(MOD_LCTL': 'OSM\nCtrl',
'OSM(MOD_LALT': 'OSM\nAlt',
'OSM(MOD_LGUI': 'OSM\nOS',
'OSM(MOD_RGUI': 'OSM\nOS',
'HOME': 'Home',
'INS': 'Insert',
'DEL': 'Delete',
'END': 'End',
'PGDN': 'PgDn',
'PGUP': 'PgUp',
'PAUS': 'Pause',
'PSCR': 'PrScr',
'SYRQ': 'SysRq',
'APP': 'Menu',
'LEFT': 'Left',
'DOWN': 'Down',
'RGHT': 'Right',
'UP': 'Up',
'MUTE': 'Mute',
'VOLD': 'Vol ',
'VOLU': 'Vol +',
'ACL0': 'Slow',
'ACL1': 'Usual',
'ACL2': 'Fast',
'BTN1': 'Click',
'BTN2': 'Mouse\n2',
'BTN3': 'Mouse\n3',
'BTN4': 'Mouse\n4',
'BTN5': 'Mouse\n5',
'MS_D': 'Mouse\nDown',
'MS_L': 'Mouse\nLeft',
'MS_R': 'Mouse\nRight',
'MS_U': 'Mouse\nUp',
'WH_D': 'Wheel\ndown',
'WH_U': 'Wheel\nup',
}
const cleanKeys = keys => keys
.map(key => key
.replaceAll(')', '')
.trim())
.filter(Boolean)
const printLegends = keys => keys
.map(key => key.replace('KC_', ''))
.map(key => legends[key] ?? key)
.map(key => [{a: key.includes('\n')
? 5 // 2 lines
: 3 // 1 line
}, key])
module.exports = {
cleanKeys,
printLegends
}

View file

@ -1,37 +0,0 @@
const HALVES_GAP = 5
const NUMBER_OF_ROWS = 8
const row = (keys, start, gapOffset) => [
{x: start},
...keys.slice(0, keys.length / 2),
{x: HALVES_GAP + gapOffset},
...keys.slice(keys.length / 2),
].flat()
const row12 = keys =>
row(keys, 0, 0)
const row4 = (keys, rowIndex) => ({
4: row(keys, 2, 4),
5: row(keys, 4, 0),
6: row(keys, 6, -4),
7: row(keys, 6, -4),
}[rowIndex % NUMBER_OF_ROWS])
const buildRow = (keys, rowIndex) => ({
12: row12(keys),
4: row4(keys, rowIndex)
}[keys.length] || ['Oh no...'])
const layerRange = layerIndex =>
layerIndex === -1
? []
: Array(2)
.fill(layerIndex)
.map((x, i) => x + i)
.map(x => x * NUMBER_OF_ROWS)
module.exports = {
layerRange,
buildRow
}

View file

@ -1,32 +0,0 @@
/**
* Convert the keymap.c file to the "Raw data" for
* http://www.keyboard-layout-editor.com/
*/
const fs = require('fs')
const {buildRow, layerRange} = require('./parts/rows')
const {cleanKeys, printLegends} = require('./parts/keys')
const keymapToKLERawData = (fileContent, layerIndex) =>
fileContent
.split('\n')
.map(row => row.split(','))
.filter(keys => keys.length > 1)
.slice(...layerRange(layerIndex))
.map(cleanKeys)
.map(printLegends)
.map(buildRow)
.map(JSON.stringify)
.join(',\n')
/* */
const keymapFilePath = process.argv[2]
const layerIndex = Number(process.argv[3])
const fileContent = fs.readFileSync(keymapFilePath, 'utf8')
const rawData = keymapToKLERawData(fileContent, layerIndex)
console.log(rawData)