diff --git a/Makefile b/Makefile index c44637d..23b88f1 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ $(OUT)ppkb-usb-debugger: usb-debugger.c common.c $(OUT)kmap.h: keymaps/physical-map.txt keymaps/factory-keymap.txt @mkdir -p $(OUT) - php keymaps/map-to-c.php $^ > $@ + php keymaps/map-to-c.php $^ $@ $(OUT)ppkb-i2c-inputd: i2c-inputd.c $(OUT)kmap.h common.c @mkdir -p $(OUT) diff --git a/keymaps/map-to-c.php b/keymaps/map-to-c.php index 681e962..1a99327 100644 --- a/keymaps/map-to-c.php +++ b/keymaps/map-to-c.php @@ -20,9 +20,23 @@ * along with this program. If not, see . */ +set_error_handler(function($severity, $message, $file, $line) { + if (!(error_reporting() & $severity)) + return; + + throw new ErrorException($message, 0, $severity, $file, $line); +}); + +if (count($argv) != 4) { + echo "Usage: $argv[0] \n"; + exit(1); +} + $pmap = file_get_contents($argv[1]); $kmap = file_get_contents($argv[2]); +ob_start(); + // high nibble = row, low nibble col $el_phys_map = []; foreach (explode("\n", $pmap) as $ln) { @@ -100,3 +114,6 @@ function kmap_to_code($name, $map) { kmap_to_code("keymap_base", $phys_key_base); kmap_to_code("keymap_fn", $phys_key_fn); kmap_to_code("keymap_pine", $phys_key_pine); + +file_put_contents($argv[3], ob_get_contents()); +ob_end_clean();