Skip to content

Commit

Permalink
0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
rudojaksa committed Jan 21, 2024
1 parent 2cbb9e7 commit a39ebc0
Show file tree
Hide file tree
Showing 30 changed files with 153 additions and 115 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PACKAGE := dvorak-hhkb
VERSION := 0.2
VERSION := 0.3
AUTHOR := R.Jaksa 2023 GPLv3
SUBVERS :=

Expand Down Expand Up @@ -55,7 +55,7 @@ XKB0 := $(shell find xkb/compat -type f -o -type l | grep -v -F .bkp)
XKB0 += $(shell find xkb/rules -type f -o -type l | grep -v -F .bkp)
XKB0 += $(shell find xkb/types -type f -o -type l | grep -v -F .bkp)
XKB0 += xkb/geometry/$(MODEL)
XKB0 += xkb/keycodes/$(MODEL)
XKB0 += xkb/keycodes/$(RANGE)
XKB0 += xkb/symbols/$(LAYOUT)-$(RANGE)
XKB := $(XKB0:%=/usr/share/X11/%)

Expand Down Expand Up @@ -86,13 +86,13 @@ build/xkb/keycodes build/xkb/symbols build/xkb/rules build/xkb/compat build/xkb/
# although, cpp resolves "// \" comment as a continuing line unfortunately
# although, cpp -P as a side-effect removes all formatting incl. empty lines and all comments
build/xkb/keycodes/%: xkb/keycodes/%.c xkb/keycodes/*.h config Makefile | build/xkb/keycodes
UTIL/pcpp $< > $@
UTIL/pcpp -v $< > $@

build/xkb/symbols/%: xkb/symbols/%.c xkb/symbols/*.h config Makefile | build/xkb/symbols
UTIL/pcpp $< > $@
UTIL/pcpp -v $< > $@

build/xkb/geometry/%: xkb/geometry/%.c xkb/geometry/*.h config Makefile | build/xkb/geometry
UTIL/pcpp $< > $@
UTIL/pcpp -v $< > $@

build/xkb/rules/%: xkb/rules/% config Makefile | build/xkb/rules
cat $< | sed 's:MODEL:$(MODEL):g' | sed 's:RANGE:$(RANGE):g' | sed 's:LAYOUT:$(LAYOUT):g' > $@
Expand All @@ -101,7 +101,7 @@ build/xorg.conf.d/%: xorg.conf.d/% config Makefile | build/xorg.conf.d
cat $< | sed 's:MODEL:$(MODEL):g' | sed 's:RANGE:$(RANGE):g' | sed 's:LAYOUT:$(LAYOUT):g' > $@

build/etc/default/%: etc/default/% config Makefile | build/etc/default
cat $< | sed 's:"MODEL":"$(MODEL)":g' | sed 's:"RANGE":"$(RANGE)":g' | sed 's:"LAYOUT":"$(LAYOUT)":g' > $@
cat $< | sed 's:"MODEL":"$(MODEL)":g' | sed 's:"LAYOUT-RANGE":"$(LAYOUT)-$(RANGE)":g' > $@

build/xkb/compat/%: xkb/compat/% Makefile | build/xkb/compat
cp $< $@
Expand Down Expand Up @@ -151,6 +151,7 @@ clean:
mrproper: clean
rm doc/hhkb.png

# TODO: git message -> just a version
include ~/.github/Makefile.git

# --------------------------------------------------------------------------------------- R.Jaksa 2023
1 change: 1 addition & 0 deletions NEW
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
0.3 - HHKB Lite and Professional keymaps and symbols merged
0.2 - configurable setup (HHKB type, KP presence, CE extensions)
- added HHKB Lite
0.1 - simple HHKB Professional 2 setup
69 changes: 57 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,30 @@ Similar to: `setxkbmap -rules evdev -layout dvorak -option altwin:meta_win -mode
* minimal configuration file, without any code for other keyboards or layouts
* commented output code with a simple structure, easy to further customize

Tested:
HHKB Professional 2 (PD-KB400) with 001001 DIP switch setup (default with just the backspace activated)
HHKB Lite (KB9975) with 1100 DIP switch setup (backspace, Windows)

HHKB Professional 2 (PD-KB400) DIP switch setup:
```
0 0 1 0 0 1
| | | | | +--> Wake Up enable
| | | +-+----> Alt-Muhenkan-Henenkan-Alt
| | +--------> Backspace (not Delete)
+-+----------> HHKB
```

HHKB Lite (KB9975) DIP switch setup:

```
+-+-+-----> Alt-Muhenkan-Henenkan-Alt
1 0 0 0
1 1 0 0
| +-+-+-----> Alt-Windows-Windows-Alt + FnTab CapsLock
+-----------> Backspace (not Delete)
```

Original HHKB (PD-KB02) switch setup:
```
position 3 -> Backspace Muhenkan
```

Contains:

Expand All @@ -43,34 +64,58 @@ is not possible.
1. edit the `config` file to select HHKB model and the keypad presence
2. run `make` to create `build/xkb` files and a `doc/hhkb.png` visual
1. Run the `sudo make install` to copy created configuration files to required directories:
`/usr/share/X11/xkb`
`/usr/share/X11/xorg.conf.d`
`/etc/default/keyboard`
`/usr/share/X11/xkb` &larr; new files will be installed here
`/usr/share/X11/xorg.conf.d` &larr; new file will be installed here
`/etc/default/keyboard` &larr; this will be overwritten
2. Manually add `setxkbmap -rules dvorak-hhkb` to your `.xinitrc` or session startup script, if needed.
3. Call `setxkbmap -rules dvorak-hhkb` or reboot the computer to activate the setup.

### Hacking

Changes to the configuration **can make your keyboard not working,** you will
need a remote acces to fix it back!

The xkb configuration files are assembled in the `build` directory from sources
in `xkb` directory by a simplified cpp preprocesor which handles include
directives and keeps comments.

Changes to the configuration can make your keyboard not working, you will need
a remote acces to fix it back!
Some debug commands:

To debug modifiers map:
``` sh
xmodmap -pm
```
xkbcomp $DISPLAY -

To debug rules:
``` sh
setxkbmap -print -verbose 10
cat /usr/share/X11/xkb/keycodes/evdev | grep = # keycodes numbers
```

To debug keycodes/symbols:
``` sh
xev -event keyboard
cat /usr/share/X11/xkb/keycodes/evdev | grep = # keycodes numbers
xmodmap -pke
xmodmap -pk
xkbcomp $DISPLAY -
```

To sample the current setup, edit at and apply back:
``` sh
xkbcomp $DISPLAY output.xkb
edit output.xkb
xkbcomp output.xkb $DISPLAY
```

To check the geometry:
``` sh
setxkbmap -print | xkbcomp -w 4 -xkm - - | xkbprint -ll 1 -fit -color - /tmp/kbd.ps; gv -swap -scale=2 /tmp/kbd.ps &
setxkbmap -print -rules dvorak-hhkb | xkbcomp -xkm - - | xkbprint -color - /tmp/kbd.ps; gv -swap -scale=3 /tmp/kbd.ps &
```

To debug indicators:
``` sh
xkbvleds
```

### Links

Documentation:
Expand Down
4 changes: 4 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
* fix NumLock breaking Alt
* qwerty

* rewrite xkbprint to produce svg
- add all-levels output
- also write txt visualization to terminal

* include geometry for Fn keys
16 changes: 9 additions & 7 deletions UTIL/pcpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
# TODO: actually, double include is useful when including inside blocks!

for(@ARGV) { $VERBOSE=1 and $_="" if $_ eq "-v" }
our $CR_="\033[31m"; # color red
our $CG_="\033[32m"; # color green
our $CM_="\033[35m"; # color magenta
our $CK_="\033[90m"; # color black
our $CD_="\033[0m"; # color default
$CR_="\033[31m"; # color red
$CG_="\033[32m"; # color green
$CM_="\033[35m"; # color magenta
$CC_="\033[36m"; # color cyan
$CK_="\033[90m"; # color black
$CD_="\033[0m"; # color default
sub pr { print STDERR @_ }
sub pf { printf STDERR @_ }

Expand Down Expand Up @@ -115,8 +116,9 @@ sub ivp {
my $cc = $_[0];
my $path = $_[1];
my $sy = "#";
$cc=$CG_ if defined $path and $path eq $file;
pr "$CK_$sy include \"$cc$file$CK_\"$CD_ $CK_#$CD_";
pr " $cc$path$CD_" if defined $path and $path ne $file;
pr " $CG_$path$CD_" if defined $path and $path ne $file;
pr " $CK_$how $lv$CD_\n" }
sub iverb {
return if not $VERBOSE;
Expand All @@ -127,7 +129,7 @@ sub iverb {
local $lv = $_[4];
if ($ok==1) { ivp $CK_ } # double include
elsif($ok==2) { ivp $CM_,btf($path) } # speculative
elsif($ok==3) { ivp $CG_,btf($path) } # OK
elsif($ok==3) { ivp $CC_,btf($path) } # OK
else { prd $CR_,$file,$how }} # not found

# line by line add a file to the output, parse # macros
Expand Down
5 changes: 4 additions & 1 deletion etc/default/keyboard
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# man ckbcomp
# man keyboard(5)
# XKBLAYOUT is xkb/symbols

XKBMODEL="MODEL"
XKBLAYOUT="LAYOUT"
XKBLAYOUT="LAYOUT-RANGE"
1 change: 0 additions & 1 deletion xkb/geometry/hhkb.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
width = 294;
height = 110;
section.left = 1;
row.left = 3;
Expand Down
3 changes: 2 additions & 1 deletion xkb/geometry/hhkbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ default xkb_geometry "hhkbl" {

# include "hhkb.h"

description = "HHKB Lite";
width = 294;
description = "HHKB Lite";
text "brand" { left=18; top=2; fontSize=18; text="PFU"; };
text "label" { left=251; top=91; fontSize=15; text="Happy Hacking\n Keyboard Lite"; };

Expand Down
6 changes: 3 additions & 3 deletions xkb/geometry/hhkbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ section "HHKB" { top=10;
<FN> };};
row { top=77; left=30; keys {
<LALT>,
{ <LMTA>,"TAB" },
{ <LWIN>,"TAB" },
{ <SPCE>,"SPCE" },
{ <RALT>,"TAB" },
<LVL3> };};};
{ <RWIN>,"TAB" },
<RALT> };};};

/// R.Jaksa 2023
5 changes: 3 additions & 2 deletions xkb/geometry/hhkblkp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ default xkb_geometry "hhkblkp" {

# include "hhkb.h"

description = "HHKB Lite + KP";
width = 417;
description = "HHKB Lite + KP";
text "brand" { left=18; top=2; fontSize=18; text="PFU"; };
text "label" { left=251; top=91; fontSize=15; text="Happy Hacking\n Keyboard Lite"; };

# include "kp.h"
# include "hhkbl.h"

Expand Down
5 changes: 3 additions & 2 deletions xkb/geometry/hhkbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ default xkb_geometry "hhkbp2" {

# include "hhkb.h"

description = "HHKB Professional 2";
width = 294;
description = "HHKB Professional 2";
text "label" { left=253; top=91; fontSize=15; text=" HHKB\nProfessional 2"; };

# include "hhkbp2.h"

}; // R.Jaksa 2023
6 changes: 3 additions & 3 deletions xkb/geometry/hhkbp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ section "HHKB" { top=10;
{ <FN>,color="grey12" }};};
row { top=77; left=30; keys {
{ <LALT>,color="grey12" },
{ <LMTA>,"TAB",color="grey12" },
{ <MUHE>,"TAB",color="grey12" },
{ <SPCE>,"SPCE" },
{ <RALT>,"TAB",color="grey12" },
{ <LVL3>,color="grey12" }};};};
{ <HENK>,"TAB",color="grey12" },
{ <RALT>,color="grey12" }};};};

/// R.Jaksa 2023
3 changes: 2 additions & 1 deletion xkb/geometry/hhkbp2kp.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ default xkb_geometry "hhkbp2kp" {

# include "hhkb.h"

description = "HHKB Professional 2 + KP";
width = 417;
description = "HHKB Professional 2 + KP";
text "label" { left=253; top=91; fontSize=15; text=" HHKB\nProfessional 2"; };

# include "kp.h"
Expand Down
2 changes: 0 additions & 2 deletions xkb/geometry/kp.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// KP section

width = 417;

// outlines
shape "KP" { cornerRadius=2, {[85,110]}};
solid "edges2" { top=-4; left=326; angle=1; shape="KP"; color="grey6"; };
Expand Down
5 changes: 2 additions & 3 deletions xkb/keycodes/hhkbl.c → xkb/keycodes/hhkb.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// HHKB Lite -*-c-*-
// HHKB -*-c-*-

default xkb_keycodes "hhkbl" {
default xkb_keycodes "hhkb" {

minimum = 8; maximum = 255;

# include "hhkb.h"
# include "hhkbl.h"

}; // R.Jaksa 2023
15 changes: 14 additions & 1 deletion xkb/keycodes/hhkb.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// main HHKB block
// HHKB Professional 2 (001001)
// HHKB Lite (1100)

<ESC> = 9; // Esc
<AE01> = 10; // 1!
Expand Down Expand Up @@ -58,6 +59,16 @@
<AB10> = 61; // zZ
<RTSH> = 62; // Shift
// Fn

<LALT> = 64; // Alt

<MUHE> = 102; // Meta
<LWIN> = 133; // Meta
<SPCE> = 65; // Space
<HENK> = 100; // Alt
<RWIN> = 134; // Alt
<RALT> = 108; // ISO_Level3_Shift / Meta

// Fn block

<FK01> = 67; // 1
Expand Down Expand Up @@ -89,4 +100,6 @@
<PGDN> = 117; // v -> Next
<DOWN> = 116; // z

<STOP> = 136; // RALT -> Cancel (Professional 2)

/// R.Jaksa 2023
5 changes: 2 additions & 3 deletions xkb/keycodes/hhkblkp.c → xkb/keycodes/hhkbkp.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// HHKB Lite + KP -*-c-*-
// HHKB + KP -*-c-*-

default xkb_keycodes "hhkblkp" {
default xkb_keycodes "hhkbkp" {

minimum = 8; maximum = 255;

# include "hhkb.h"
# include "hhkbl.h"
# include "kp.h"

}; // R.Jaksa 2023
9 changes: 0 additions & 9 deletions xkb/keycodes/hhkbl.h

This file was deleted.

10 changes: 0 additions & 10 deletions xkb/keycodes/hhkbp2.c

This file was deleted.

11 changes: 0 additions & 11 deletions xkb/keycodes/hhkbp2.h

This file was deleted.

Loading

0 comments on commit a39ebc0

Please sign in to comment.