Compare commits

..

4 Commits

Author SHA1 Message Date
b0707744e2 fix nixpkgs to 25.11, update to new zig api 2025-12-01 10:00:33 +01:00
ce2d957a88 flake: update 2025-09-23 22:05:08 +02:00
4962f12867 flake: update 2025-01-25 11:54:55 +01:00
79a35cf42e flake: format and update zig 2025-01-25 11:54:19 +01:00
4 changed files with 56 additions and 41 deletions

View File

@@ -19,9 +19,11 @@ pub fn build(b: *std.Build) void {
.name = "zremap",
// In this case the main source file is merely a path, however, in more),
// complicated build scripts, this could be a generated file.
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
exe.linkLibC();
exe.linkSystemLibrary("evdev");
@@ -57,9 +59,11 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_unit_tests = b.addRunArtifact(unit_tests);

11
flake.lock generated
View File

@@ -2,11 +2,12 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1718318537,
"narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=",
"path": "/nix/store/qqwr649pc0qprc9lw2fmdsi1km6p7q2h-source",
"rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420",
"type": "path"
"lastModified": 1758446476,
"narHash": "sha256-5rdAi7CTvM/kSs6fHe1bREIva5W3TbImsto+dxG4mBo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "a1f79a1770d05af18111fbbe2a3ab2c42c0f6cd0",
"type": "github"
},
"original": {
"id": "nixpkgs",

View File

@@ -1,34 +1,44 @@
{
description = "zremap nix flake";
outputs = {
self,
nixpkgs,
}: {
defaultPackage.x86_64-linux = with import nixpkgs {system = "x86_64-linux";};
stdenv.mkDerivation {
pname = "zremap";
version = "0.2";
src = self;
nativeBuildInputs = [zig.hook];
buildInputs = [libevdev pkg-config];
buildPhase = ''
NIX_CFLAGS_COMPILE="-static -isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
'';
};
outputs =
{
self,
nixpkgs,
}:
{
defaultPackage.x86_64-linux =
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
pname = "zremap";
version = "0.2";
src = self;
nativeBuildInputs = [ zig.hook ];
buildInputs = [
libevdev
pkg-config
];
buildPhase = ''
NIX_CFLAGS_COMPILE=" -isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
'';
};
devShells.x86_64-linux.default = with import nixpkgs {system = "x86_64-linux";};
mkShell {
nativeBuildInputs = [zig_0_12 lldb];
buildInputs = [
libevdev
pkg-config
];
devShells.x86_64-linux.default =
with import nixpkgs { system = "x86_64-linux"; };
mkShell {
nativeBuildInputs = [
zig
lldb
];
buildInputs = [
libevdev
pkg-config
];
shellHook = ''
NIX_CFLAGS_COMPILE="-isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
echo "happy hacking!"
'';
};
};
shellHook = ''
NIX_CFLAGS_COMPILE="-isystem $(pkg-config --variable=includedir libevdev)/libevdev-1.0 $NIX_CFLAGS_COMPILE"
echo "happy hacking!"
'';
};
};
}

View File

@@ -47,10 +47,10 @@ fn uinputWriteKey(uinput_dev: *c.libevdev_uinput, key: u16) !void {
const pressKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 1, .time = undefined };
const releaseKey = c.input_event{ .type = c.EV_KEY, .code = key, .value = 0, .time = undefined };
const sync = c.input_event{ .type = c.EV_SYN, .code = c.SYN_REPORT, .value = 0, .time = undefined };
std.time.sleep(20000);
std.Thread.sleep(20 * std.time.ns_per_ms);
try uinputWrite(uinput_dev, &pressKey);
try uinputWrite(uinput_dev, &sync);
std.time.sleep(20000);
std.Thread.sleep(20 * std.time.ns_per_ms);
try uinputWrite(uinput_dev, &releaseKey);
}