400 lines
7.4 KiB
Ruby
Executable file
400 lines
7.4 KiB
Ruby
Executable file
#!/usr/bin/env ruby
|
||
|
||
# https://developer.valvesoftware.com/wiki/Bind
|
||
# https://developer.valvesoftware.com/wiki/List_of_L4D2_Cvars
|
||
|
||
keys = [
|
||
{
|
||
ingame: 'escape',
|
||
short: 'ESC',
|
||
title: 'Escape',
|
||
keycap: 'ESC',
|
||
},
|
||
{
|
||
ingame: 'tab',
|
||
short: 'TAB',
|
||
title: 'Tabulator',
|
||
keycap: '↹',
|
||
},
|
||
{
|
||
ingame: 'capslock',
|
||
short: 'CAPS',
|
||
title: 'Capslock',
|
||
keycap: '⇪',
|
||
},
|
||
{
|
||
ingame: 'shift',
|
||
short: 'SFT',
|
||
title: 'Shift',
|
||
keycap: '⇧',
|
||
},
|
||
{
|
||
ingame: 'ctrl',
|
||
short: 'CTL',
|
||
title: 'Control',
|
||
keycap: 'CTL',
|
||
},
|
||
{
|
||
ingame: 'alt',
|
||
short: 'ALT',
|
||
title: 'ALT',
|
||
keycap: 'ALT',
|
||
},
|
||
{
|
||
ingame: 'space',
|
||
short: 'SPC',
|
||
title: 'Space',
|
||
keycap: 'SPACE',
|
||
},
|
||
{
|
||
ingame: 'backspace',
|
||
short: 'BSP',
|
||
title: 'Backspace',
|
||
keycap: '⇦',
|
||
},
|
||
{
|
||
ingame: 'enter',
|
||
short: 'ENT',
|
||
title: 'Enter',
|
||
keycap: '↵',
|
||
},
|
||
{
|
||
ingame: 'semicolon',
|
||
short: ';',
|
||
title: 'Semicolon',
|
||
keycap: ';',
|
||
},
|
||
{
|
||
ingame: 'lwin',
|
||
short: 'LWIN',
|
||
title: 'Left Super',
|
||
keycap: '⊞',
|
||
},
|
||
{
|
||
ingame: 'rwin',
|
||
short: 'RWIN',
|
||
title: 'Right Super',
|
||
keycap: '⊞',
|
||
},
|
||
{
|
||
ingame: 'apps',
|
||
short: 'MENU',
|
||
title: 'Menu',
|
||
keycap: '≡',
|
||
},
|
||
{
|
||
ingame: 'numlock',
|
||
short: 'NUM',
|
||
title: 'Numlock',
|
||
keycap: 'NUM',
|
||
},
|
||
{
|
||
ingame: 'scrolllock',
|
||
short: 'SCR',
|
||
title: 'Scrollock',
|
||
keycap: 'SCR',
|
||
},
|
||
{
|
||
ingame: 'uparrow',
|
||
short: 'ARU',
|
||
title: 'Arrow Up',
|
||
keycap: '↑',
|
||
},
|
||
{
|
||
ingame: 'downarrow',
|
||
short: 'ARD',
|
||
title: 'Arrow Down',
|
||
keycap: '↓',
|
||
},
|
||
{
|
||
ingame: 'leftarrow',
|
||
short: 'ARL',
|
||
title: 'Arrow Left',
|
||
keycap: '←',
|
||
},
|
||
{
|
||
ingame: 'rightarrow',
|
||
short: 'ARR',
|
||
title: 'Arrow Right',
|
||
keycap: '→',
|
||
},
|
||
{
|
||
ingame: 'ins',
|
||
short: 'INS',
|
||
title: 'Insert',
|
||
keycap: 'INS',
|
||
},
|
||
{
|
||
ingame: 'del',
|
||
short: 'DEL',
|
||
title: 'Delete',
|
||
keycap: 'DEL',
|
||
},
|
||
{
|
||
ingame: 'pgdn',
|
||
short: 'PGD',
|
||
title: 'Page Down',
|
||
keycap: '⇣',
|
||
},
|
||
{
|
||
ingame: 'pgup',
|
||
short: 'PGU',
|
||
title: 'Page Up',
|
||
keycap: '⇡',
|
||
},
|
||
{
|
||
ingame: 'home',
|
||
short: 'HOM',
|
||
title: 'Home',
|
||
keycap: '⌂',
|
||
},
|
||
{
|
||
ingame: 'end',
|
||
short: 'END',
|
||
title: 'End',
|
||
keycap: '⇥',
|
||
},
|
||
{
|
||
ingame: 'pause',
|
||
short: 'PAU',
|
||
title: 'Pause',
|
||
keycap: '⏸',
|
||
},
|
||
{
|
||
ingame: 'kp_end',
|
||
short: 'N1',
|
||
title: 'Keypad 1 (End)',
|
||
keycap: '1',
|
||
},
|
||
{
|
||
ingame: 'kp_downarrow',
|
||
short: 'N2',
|
||
title: 'Keypad 2 (Arrow Down)',
|
||
keycap: '2',
|
||
},
|
||
{
|
||
ingame: 'kp_pgdn',
|
||
short: 'N3',
|
||
title: 'Keypad 3 (Page Down)',
|
||
keycap: '3',
|
||
},
|
||
{
|
||
ingame: 'kp_leftarrow',
|
||
short: 'N4',
|
||
title: 'Keypad 4 (Arrow Left)',
|
||
keycap: '4',
|
||
},
|
||
{
|
||
ingame: 'kp_5',
|
||
short: 'N5',
|
||
title: 'Keypad 5',
|
||
keycap: '5',
|
||
},
|
||
{
|
||
ingame: 'kp_rightarrow',
|
||
short: 'N6',
|
||
title: 'Keypad 6 (Arrow Right)',
|
||
keycap: '6',
|
||
},
|
||
{
|
||
ingame: 'kp_home',
|
||
short: 'N7',
|
||
title: 'Keypad 7 (Home)',
|
||
keycap: '7',
|
||
},
|
||
{
|
||
ingame: 'kp_uparrow',
|
||
short: 'N8',
|
||
title: 'Keypad 8 (Arrow Up)',
|
||
keycap: '8',
|
||
},
|
||
{
|
||
ingame: 'kp_pgup',
|
||
short: 'N9',
|
||
title: 'Keypad 9 (Page Up)',
|
||
keycap: '9',
|
||
},
|
||
{
|
||
ingame: 'kp_enter',
|
||
short: 'NENT',
|
||
title: 'Keypad Enter',
|
||
keycap: '↵',
|
||
},
|
||
{
|
||
ingame: 'kp_ins',
|
||
short: 'NINS',
|
||
title: 'Keypad 0',
|
||
keycap: '0',
|
||
},
|
||
{
|
||
ingame: 'kp_del',
|
||
short: 'NDEL',
|
||
title: 'Keypad .',
|
||
keycap: '.',
|
||
},
|
||
{
|
||
ingame: 'kp_slash',
|
||
short: 'NSL',
|
||
title: 'Keypad /',
|
||
keycap: '/',
|
||
},
|
||
{
|
||
ingame: 'kp_multiply',
|
||
short: 'NMUL',
|
||
title: 'Keypad *',
|
||
keycap: '*',
|
||
},
|
||
{
|
||
ingame: 'kp_minus',
|
||
short: 'NMIN',
|
||
title: 'Keypad -',
|
||
keycap: '-',
|
||
},
|
||
{
|
||
ingame: 'kp_plus',
|
||
short: 'NPLS',
|
||
title: 'Keypad +',
|
||
keycap: '+',
|
||
},
|
||
{
|
||
ingame: 'mwheeldown',
|
||
short: 'WLD',
|
||
title: 'Mousewheel Down',
|
||
keycap: '⇟',
|
||
},
|
||
{
|
||
ingame: 'mwheelup',
|
||
short: 'WLU',
|
||
title: 'Mousewheel Up',
|
||
keycap: '⇞',
|
||
},
|
||
{
|
||
ingame: 'mouse1',
|
||
short: 'M1',
|
||
title: 'Mouse 1',
|
||
keycap: '🖱️1',
|
||
},
|
||
{
|
||
ingame: 'mouse2',
|
||
short: 'M2',
|
||
title: 'Mouse 2',
|
||
keycap: '🖱️2',
|
||
},
|
||
{
|
||
ingame: 'mouse3',
|
||
short: 'M3',
|
||
title: 'Mouse 3',
|
||
keycap: '🖱️3',
|
||
},
|
||
{
|
||
ingame: 'mouse4',
|
||
short: 'M4',
|
||
title: 'Mouse 4',
|
||
keycap: '🖱️4',
|
||
},
|
||
{
|
||
ingame: 'mouse5',
|
||
short: 'M5',
|
||
title: 'Mouse 5',
|
||
keycap: '🖱️5',
|
||
},
|
||
]
|
||
%(0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜß,.+-*/#^´<>).each_char do |char|
|
||
keys.append({
|
||
ingame: char,
|
||
short: char,
|
||
title: char,
|
||
keycap: char,
|
||
})
|
||
end
|
||
(1..12).each do |num|
|
||
keys.append({
|
||
ingame: "F#{num}",
|
||
short: "F#{num}",
|
||
title: "Function #{num}",
|
||
keycap: "F#{num}",
|
||
})
|
||
end
|
||
|
||
keycaps = {
|
||
'h1': {
|
||
width: 1,
|
||
points: '-0.44,-0.44 0.44,-0.44 0.44,0.44 -0.44,0.44',
|
||
},
|
||
'h1.25': {
|
||
width: 1.25,
|
||
points: '-0.565,-0.44 0.565,-0.44 0.565,0.44 -0.565,0.44',
|
||
},
|
||
'h1.5': {
|
||
width: 1.5,
|
||
points: '-0.69,-0.44 0.69,-0.44 0.69,0.44 -0.69,0.44',
|
||
},
|
||
'h1.75': {
|
||
width: 1.75,
|
||
points: '-0.815,-0.44 0.815,-0.44 0.815,0.44 -0.815,0.44',
|
||
},
|
||
'h2': {
|
||
width: 2,
|
||
points: '-0.94,-0.44 0.94,-0.44 0.94,0.44 -0.94,0.44',
|
||
},
|
||
'h2.5': {
|
||
width: 2.5,
|
||
points: '-1.19,-0.44 1.19,-0.44 1.19,0.44 -1.19,0.44',
|
||
},
|
||
'h2.75': {
|
||
width: 2.75,
|
||
points: '-1.315,-0.44 1.315,-0.44 1.315,0.44 -1.315,0.44',
|
||
},
|
||
'h6.5': {
|
||
width: 6.5,
|
||
points: '-3.19,-0.44 3.19,-0.44 3.19,0.44 -3.19,0.44',
|
||
},
|
||
'v2': {
|
||
width: 1,
|
||
points: '-0.44,-0.44 0.44,-0.44 0.44,1.44 -0.44,1.44',
|
||
},
|
||
'enter_iso': {
|
||
width: 1.5,
|
||
points: '-0.69,-0.44 0.69,-0.44 0.69,1.44 -0.44,1.44 -0.44,0.44 -0.69,0.44',
|
||
},
|
||
}
|
||
|
||
keyboard = {
|
||
0 => 'ESC :1 F1 F2 F3 F4 :.5 F5 F6 F7 F8 :.5 F9 F10 F11 F12 :.25 PNT ROL PAU',
|
||
1.25 => '^ 1 2 3 4 5 6 7 8 9 0 ß ´ BSP:h2 :.25 INS HOM PGU :.25 NUM / * -',
|
||
2.25 => 'TAB:h1.5 Q W E R T Z U I O P Ü + ENT:enter_iso :.25 DEL END PGD :.25 7 8 9 +:v2',
|
||
3.25 => 'CAPS:h1.75 A S D F G H J K L Ö Ä # :1.25 :.25 :1 :1 :1 :.25 4 5 6',
|
||
4.25 => 'SFT:h1.25 < Y X C V B N M , . - SFT:h2.75 :.25 :1 ARU :1 :.25 1 2 3 ENT:v2',
|
||
5.25 => 'CTL:h1.25 LWIN:h1.25 ALT:h1.25 SPC:h6.5 AGR:h1.25 RWIN:h1.25 MENU CTL:h1.25 :.25 ARL ARD ARR :.25 0:h2 DEL'
|
||
}
|
||
|
||
keyboard_keys = []
|
||
total_h = 0
|
||
total_v = 0
|
||
|
||
keyboard.each do |row_v, row_text|
|
||
row_h = 0
|
||
row_text.split.each do |element|
|
||
if element.start_with? ':'
|
||
row_h += element[1..].to_f
|
||
else
|
||
short, keycap = element.split(':')
|
||
key = keys.find{|k| k[:short] == short}
|
||
keycap ||= :h1
|
||
keyboard_keys.append({
|
||
is_known: !!key,
|
||
label: key ? key[:keycap] : short,
|
||
keycap: keycap,
|
||
x: row_h + keycaps[keycap.to_sym][:width]/2.0,
|
||
y: 0.5 + row_v,
|
||
})
|
||
row_h += keycaps[keycap.to_sym][:width]
|
||
end
|
||
end
|
||
total_h = [total_h, row_h].max
|
||
total_v = [total_v, row_v].max
|
||
end
|
||
|
||
require "erb"
|
||
html = ERB.new(File.read(File.join(__dir__, 'keyboard.erb'))).result_with_hash({keys: keyboard_keys, total_h: total_h, total_v: total_v+1})
|
||
File.write(File.join(__dir__, 'keyboard.html'), html)
|