mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
6008105b4f
Everything should be available in the selftest part of the tree, but providing an example without uhid and hidraw will be more easy to follow for users. This example will probably ever only work on the Etekcity Scroll 6E because we need to adapt the various raw values to the actual device. On that device, the X and Y axis will be swapped and inverted, and on any other device, chances are high that the device will not work until Ctrl-C is hit. The Makefiles are taken from samples/bpf to not reinvent the wheel and to force using in-kernel libbpf and bpftool. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
19 lines
377 B
C
19 lines
377 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/* Copyright (c) 2022 Benjamin Tissoires
|
|
*/
|
|
|
|
#include "vmlinux.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
#include "hid_bpf_attach.h"
|
|
#include "hid_bpf_helpers.h"
|
|
|
|
SEC("syscall")
|
|
int attach_prog(struct attach_prog_args *ctx)
|
|
{
|
|
ctx->retval = hid_bpf_attach_prog(ctx->hid,
|
|
ctx->prog_fd,
|
|
0);
|
|
return 0;
|
|
}
|