Skip to content

Commit 0a64e53

Browse files
committed
v0.8.0 rewrote things to let the firmware generate the config
1 parent 803b689 commit 0a64e53

34 files changed

+1039
-231
lines changed

.eslintrc.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ module.exports = {
2020
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],
2121
'@typescript-eslint/explicit-module-boundary-types': 'off',
2222
'@typescript-eslint/no-empty-function': ['error', { allow: ['arrowFunctions'] }],
23-
'@typescript-eslint/no-explicit-any': 'error',
23+
// '@typescript-eslint/no-explicit-any': 'error',
2424
'@typescript-eslint/no-non-null-assertion': 'off',
2525
'@typescript-eslint/no-var-requires': 'off',
2626
'vue/require-default-prop': 'off',
27-
'vue/multi-word-component-names': 'off'
27+
'vue/multi-word-component-names': 'off',
28+
"@typescript-eslint/no-explicit-any": "off"
2829
},
2930
overrides: [
3031
{

build/icon.ico

-14.7 KB
Binary file not shown.

dev-app-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
provider: generic
2-
url: https://example.com/auto-updates
2+
url: https://pog.heaper.de/auto-updates
33
updaterCacheDirName: vue-vite-electron-updater

electron-builder.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ asarUnpack:
1313
afterSign: build/notarize.js
1414
win:
1515
executableName: pog
16+
target:
17+
- target: portable
18+
arch:
19+
- x64
20+
- target: nsis
21+
arch:
22+
- x64
1623
nsis:
17-
artifactName: ${name}-${version}-setup.${ext}
24+
artifactName: ${name}-${version}-${arch}-setup.${ext}
1825
shortcutName: ${productName}
1926
uninstallDisplayName: ${productName}
2027
createDesktopShortcut: always
@@ -25,8 +32,19 @@ mac:
2532
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
2633
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
2734
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
35+
# publish:
36+
# - generic
37+
target:
38+
- target: dmg
39+
arch:
40+
- x64
41+
- arm64
42+
- target: zip
43+
arch:
44+
- x64
45+
- arm64
2846
dmg:
29-
artifactName: ${name}-${version}.${ext}
47+
artifactName: ${name}-${version}-${arch}.${ext}
3048
linux:
3149
target:
3250
- AppImage
@@ -38,5 +56,5 @@ appImage:
3856
artifactName: ${name}-${version}.${ext}
3957
npmRebuild: false
4058
publish:
41-
provider: generic
42-
url: https://pog.heaper.de/auto-updates
59+
provider: github
60+
# url: https://pog.heaper.de/auto-updates

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"name": "pog",
3-
"version": "0.6.0",
3+
"version": "0.8.0",
44
"description": "A KMK firmware configurator",
55
"main": "./out/main/index.js",
66
"author": "Jan Lunge",
77
"homepage": "https://github.com/wlard/pog",
8+
"repository": {
9+
"type": "git",
10+
"url": "https://github.com/janlunge/pog.git"
11+
},
812
"scripts": {
913
"format": "prettier --write .",
1014
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts,.vue --fix",
@@ -27,6 +31,7 @@
2731
"@viselect/vue": "^3.2.5",
2832
"@vueuse/core": "^9.12.0",
2933
"@wlard/vue-class-store": "^3.0.0",
34+
"@wlard/vue3-popper": "^1.3.1",
3035
"daisyui": "^2.50.0",
3136
"dayjs": "^1.11.7",
3237
"decompress": "^4.2.1",
@@ -37,7 +42,8 @@
3742
"tailwindcss": "^3.2.6",
3843
"ulid": "^2.3.0",
3944
"vue-multiselect": "^3.0.0-beta.1",
40-
"vue-router": "^4.1.6"
45+
"vue-router": "^4.1.6",
46+
"vuedraggable": "^4.1.0"
4147
},
4248
"devDependencies": {
4349
"@electron-toolkit/tsconfig": "^1.0.1",

src/main/index.ts

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,115 @@
1-
import { app, shell, BrowserWindow, ipcMain } from 'electron'
1+
import { app, shell, BrowserWindow, ipcMain, Menu } from 'electron'
22
import { join } from 'path'
33
import { electronApp, optimizer, is } from '@electron-toolkit/utils'
44
import icon from '../../resources/icon.png?asset'
55
import { handleSelectDrive, selectKeyboard } from './selectKeyboard'
66
import { updateFirmware } from './kmkUpdater'
77
import { saveConfiguration } from './saveConfig'
8+
import { autoUpdater } from 'electron-updater'
89

910
let mainWindow: BrowserWindow | null = null
1011
export { mainWindow }
12+
13+
const isMac = process.platform === 'darwin'
14+
15+
const template: unknown = [
16+
// { role: 'appMenu' }
17+
...(isMac
18+
? [
19+
{
20+
label: app.name,
21+
submenu: [
22+
{ role: 'about' },
23+
{
24+
label: 'Check for Updates...',
25+
click: () => {
26+
autoUpdater.checkForUpdatesAndNotify()
27+
}
28+
},
29+
{ type: 'separator' },
30+
{ role: 'services' },
31+
{ type: 'separator' },
32+
{ role: 'hide' },
33+
{ role: 'hideOthers' },
34+
{ role: 'unhide' },
35+
{ type: 'separator' },
36+
{ role: 'quit' }
37+
]
38+
}
39+
]
40+
: []),
41+
// { role: 'fileMenu' }
42+
{
43+
label: 'File',
44+
submenu: [isMac ? { role: 'close' } : { role: 'quit' }]
45+
},
46+
// { role: 'editMenu' }
47+
{
48+
label: 'Edit',
49+
submenu: [
50+
{ role: 'undo' },
51+
{ role: 'redo' },
52+
{ type: 'separator' },
53+
{ role: 'cut' },
54+
{ role: 'copy' },
55+
{ role: 'paste' },
56+
...(isMac
57+
? [
58+
{ role: 'pasteAndMatchStyle' },
59+
{ role: 'delete' },
60+
{ role: 'selectAll' },
61+
{ type: 'separator' },
62+
{
63+
label: 'Speech',
64+
submenu: [{ role: 'startSpeaking' }, { role: 'stopSpeaking' }]
65+
}
66+
]
67+
: [{ role: 'delete' }, { type: 'separator' }, { role: 'selectAll' }])
68+
]
69+
},
70+
// { role: 'viewMenu' }
71+
{
72+
label: 'View',
73+
submenu: [
74+
{ role: 'reload' },
75+
{ role: 'forceReload' },
76+
{ role: 'toggleDevTools' },
77+
{ type: 'separator' },
78+
{ role: 'resetZoom' },
79+
{ role: 'zoomIn' },
80+
{ role: 'zoomOut' },
81+
{ type: 'separator' },
82+
{ role: 'togglefullscreen' }
83+
]
84+
},
85+
// { role: 'windowMenu' }
86+
{
87+
label: 'Window',
88+
submenu: [
89+
{ role: 'minimize' },
90+
{ role: 'zoom' },
91+
...(isMac
92+
? [{ type: 'separator' }, { role: 'front' }, { type: 'separator' }, { role: 'window' }]
93+
: [{ role: 'close' }])
94+
]
95+
},
96+
{
97+
role: 'help',
98+
submenu: [
99+
{
100+
label: 'Learn More',
101+
click: async () => {
102+
const { shell } = require('electron')
103+
await shell.openExternal('https://electronjs.org')
104+
}
105+
}
106+
]
107+
}
108+
]
109+
110+
const menu = Menu.buildFromTemplate(template as Electron.MenuItem[])
111+
Menu.setApplicationMenu(menu)
112+
11113
function createWindow(): void {
12114
// Create the browser window.
13115
mainWindow = new BrowserWindow({
@@ -86,3 +188,10 @@ ipcMain.handle('selectDrive', () => handleSelectDrive())
86188
ipcMain.handle('updateFirmware', () => updateFirmware())
87189
ipcMain.on('saveConfiguration', (_event, data) => saveConfiguration(data))
88190
ipcMain.handle('selectKeyboard', (_event, data) => selectKeyboard(data))
191+
192+
autoUpdater.on('update-available', () => {
193+
if (mainWindow) mainWindow.webContents.send('update_available')
194+
})
195+
autoUpdater.on('update-downloaded', () => {
196+
if (mainWindow) mainWindow.webContents.send('update_downloaded')
197+
})

src/main/pythontemplates/boot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# boot.py
2+
import usb_cdc
3+
import supervisor
4+
supervisor.set_next_stack_limit(4096 + 4096)
5+
usb_cdc.enable(console=True, data=True)

src/main/pythontemplates/code.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export const codepy = `# Main Keyboard Configuration
2+
import board
3+
import pog
4+
5+
# import modules & extensions
6+
from kmk.modules.tapdance import TapDance
7+
from kmk.modules.layers import Layers
8+
from kmk.extensions.media_keys import MediaKeys
9+
10+
# check if we just want to run the coord_mappping finder
11+
if pog.coordMappingAssistant:
12+
print('running coordmap setup')
13+
from coordmaphelper import KMKKeyboard
14+
else:
15+
from kb import KMKKeyboard
16+
17+
keyboard = KMKKeyboard()
18+
19+
# Append Modules and Extensions to our Keyboard
20+
keyboard.modules.append(Layers())
21+
keyboard.extensions.append(MediaKeys())
22+
23+
tapdance = TapDance()
24+
tapdance.tap_time = 200
25+
keyboard.modules.append(tapdance)
26+
27+
# Keymap
28+
if not pog.coordMappingAssistant:
29+
import keymap
30+
keyboard.keymap = keymap.keymap
31+
if pog.hasEncoders:
32+
from kb import encoder_handler
33+
encoder_handler.map = keymap.encoderKeymap
34+
35+
36+
if __name__ == '__main__':
37+
keyboard.go()
38+
39+
`
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export const coordmaphelperpy = `# coordmaphelper.py helper script to get your coord map
2+
from kmk.handlers.sequences import simple_key_sequence
3+
from kmk.keys import KC
4+
from kb import KMKKeyboard as _KMKKeyboard
5+
class KMKKeyboard(_KMKKeyboard):
6+
# *2 for split keyboards, which will typically manage twice the number of keys
7+
# of one side. Having this N too large will have no impact (maybe slower boot..)
8+
N = len(_KMKKeyboard.col_pins) * len(_KMKKeyboard.row_pins) *2
9+
coord_mapping = list(range(N))
10+
11+
layer = []
12+
13+
for i in range(N):
14+
c, r = divmod(i, 100)
15+
d, u = divmod(r, 10)
16+
layer.append(
17+
simple_key_sequence(
18+
(
19+
getattr(KC, "N" + str(c)),
20+
getattr(KC, "N" + str(d)),
21+
getattr(KC, "N" + str(u)),
22+
KC.SPC,
23+
)
24+
)
25+
)
26+
keymap = [layer]`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const customkeyspy = `# These are yous custom keycodes do any needed imports at the top
2+
# then you can reference them in your keymap with for example customkeys.MyKey
3+
4+
from kmk.keys import KC
5+
6+
MyKey = KC.X`

0 commit comments

Comments
 (0)