Skip to content

Commit

Permalink
FreeBSD related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gvalkov committed Feb 2, 2025
1 parent 3e6fd3e commit 78650f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Changelog

- Slightly faster reading of events.

- Fix build on FreeBSD.


1.8.0 (Jan 25, 2025)
====================
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import shutil
import textwrap
import platform
from pathlib import Path
from subprocess import run

Expand All @@ -25,7 +26,11 @@ def create_ecodes(headers=None):
include_paths.update(c_inc_path.split(":"))

include_paths.add("/usr/include")
files = ["linux/input.h", "linux/input-event-codes.h", "linux/uinput.h"]
if platform.system().lower() == "freebsd":
files = ["dev/evdev/input.h", "dev/evdev/input-event-codes.h", "dev/evdev/uinput.h"]
else:
files = ["linux/input.h", "linux/input-event-codes.h", "linux/uinput.h"]

headers = [os.path.join(path, file) for path in include_paths for file in files]

headers = [header for header in headers if os.path.isfile(header)]
Expand Down
3 changes: 2 additions & 1 deletion src/evdev/genecodes_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


# -----------------------------------------------------------------------------
macro_regex = r"#define +((?:KEY|ABS|REL|SW|MSC|LED|BTN|REP|SND|ID|EV|BUS|SYN|FF|UI_FF|INPUT_PROP)_\w+)"
macro_regex = r"#define\s+((?:KEY|ABS|REL|SW|MSC|LED|BTN|REP|SND|ID|EV|BUS|SYN|FF|UI_FF|INPUT_PROP)_\w+)"
macro_regex = re.compile(macro_regex)

# Uname without hostname.
Expand All @@ -38,6 +38,7 @@
#include <Python.h>
#ifdef __FreeBSD__
#include <dev/evdev/input.h>
#include <dev/evdev/uinput.h>
#else
#include <linux/input.h>
#include <linux/uinput.h>
Expand Down

0 comments on commit 78650f8

Please sign in to comment.