linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
94 stars 46 forks source link

Trying to compile on AOSP source #29

Closed hmtheboy154 closed 3 years ago

hmtheboy154 commented 3 years ago

Hello, I'm trying to compile iptsd with Android-x86 source to support touch for Surface devices. However, when compiling I have this error.

external/iptsd/src/devices.c: In function 'iptsd_devices_create_stylus':
external/iptsd/src/devices.c:27:22: error: storage size of 'setup' isn't known
  struct uinput_setup setup;
                      ^
external/iptsd/src/devices.c:28:26: error: storage size of 'abs_setup' isn't known
  struct uinput_abs_setup abs_setup;
                          ^
external/iptsd/src/devices.c:37:27: error: invalid application of 'sizeof' to incomplete type 'struct uinput_setup'
  memset(&setup, 0, sizeof(struct uinput_setup));
                           ^
external/iptsd/src/devices.c:38:31: error: invalid application of 'sizeof' to incomplete type 'struct uinput_abs_setup'
  memset(&abs_setup, 0, sizeof(struct uinput_abs_setup));
                               ^
external/iptsd/src/devices.c:58:26: error: 'UI_ABS_SETUP' undeclared (first use in this function)
  iptsd_utils_ioctl(file, UI_ABS_SETUP, &abs_setup);
                          ^
external/iptsd/src/devices.c:58:26: note: each undeclared identifier is reported only once for each function it appears in
external/iptsd/src/devices.c:96:36: error: 'UI_DEV_SETUP' undeclared (first use in this function)
  int ret = iptsd_utils_ioctl(file, UI_DEV_SETUP, &setup);
                                    ^
external/iptsd/src/devices.c: In function 'iptsd_devices_create_touch':
external/iptsd/src/devices.c:112:22: error: storage size of 'setup' isn't known
  struct uinput_setup setup;
                      ^
external/iptsd/src/devices.c:113:26: error: storage size of 'abs_setup' isn't known
  struct uinput_abs_setup abs_setup;
                          ^
external/iptsd/src/devices.c:131:27: error: invalid application of 'sizeof' to incomplete type 'struct uinput_setup'
  memset(&setup, 0, sizeof(struct uinput_setup));
                           ^
external/iptsd/src/devices.c:132:31: error: invalid application of 'sizeof' to incomplete type 'struct uinput_abs_setup'
  memset(&abs_setup, 0, sizeof(struct uinput_abs_setup));
                               ^
external/iptsd/src/devices.c:151:26: error: 'UI_ABS_SETUP' undeclared (first use in this function)
  iptsd_utils_ioctl(file, UI_ABS_SETUP, &abs_setup);
                          ^
external/iptsd/src/devices.c:225:32: error: 'UI_DEV_SETUP' undeclared (first use in this function)
  ret = iptsd_utils_ioctl(file, UI_DEV_SETUP, &setup);
                                ^
ninja: build stopped: subcommand failed.

Here is my Android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
INIH_INCLUDE := $(LOCAL_PATH)/../inih
LOCAL_CLANG := false
LOCAL_CFLAGS := -Wundef \
    -Wuninitialized \
    -Wno-unused-result \
    -Wlogical-op \
    -Wmissing-include-dirs \
    -Wold-style-definition \
    -Wpointer-arith \
    -Winit-self \
    -Wstrict-prototypes \
    -Wendif-labels \
    -Wstrict-aliasing=2 \
    -Woverflow \
    -Wmissing-prototypes \
    -Wno-missing-braces \
    -Wno-missing-field-initializers \
    -Wno-unused-parameter -std=gnu99
LOCAL_C_INCLUDES:= $(INIH_INCLUDE)
LOCAL_SRC_FILES :=   src/cone.c  \
    src/config.c  \
    src/contact.c  \
    src/control.c  \
    src/data.c  \
    src/devices.c  \
    src/finger.c  \
    src/heatmap.c  \
    src/hid.c  \
    src/main.c  \
    src/reader.c  \
    src/payload.c  \
    src/singletouch.c  \
    src/stylus.c  \
    src/touch.c  \
    src/touch-processing.c  \
    src/utils.c \
    debug/debug.c \
    src/control.c \
    src/utils.c
LOCAL_MODULE := iptsd
LOCAL_SHARED_LIBRARIES := libinih
include $(BUILD_EXECUTABLE)
StollD commented 3 years ago

You build environment is missing the uinput kernel headers. Is CONFIG_INPUT_UINPUT enabled in your kernel?

hmtheboy154 commented 3 years ago

You build environment is missing the uinput kernel headers. Is CONFIG_INPUT_UINPUT enabled in your kernel?

Yes I do. But from what I see AOSP source didn't use my Linux Kernel source headers. Instead it use the one inside bionic libraries https://android.googlesource.com/platform/bionic/+/refs/tags/android-7.1.2_r39/libc/kernel/

StollD commented 3 years ago

Yeah that doesnt have the required definitions, probably because of the minimum required kernel version for nougat. But it seems to be available starting with Oreo. Is there any reason you are building Nougat instead of a more recent release?

https://android.googlesource.com/platform/bionic/+/refs/tags/android-8.1.0_r81/libc/kernel/uapi/linux/uinput.h

Also FYI, iptsd depends on a header file that is automatically generated by meson. You will need to either call meson to generate it, or synthesize your own to get the latest versions from master to build.

hmtheboy154 commented 3 years ago

Yeah that doesnt have the required definitions, probably because of the minimum required kernel version for nougat. But it seems to be available starting with Oreo. Is there any reason you are building Nougat instead of a more recent release?

https://android.googlesource.com/platform/bionic/+/refs/tags/android-8.1.0_r81/libc/kernel/uapi/linux/uinput.h

There are many users out there still prefer Android-x86 7.1 or other similar version like PrimeOS or PhoenixOS since they are more stable and more "battery-friendly" than newer version. But since you are pointing out that Oreo have it, I'll try to get in touch with @electrikjesus from BlissOS and try to compile in newer version. Still, I hope we can find a solution so that nougat users can get touch working.

Also FYI, iptsd depends on a header file that is automatically generated by meson. You will need to either call meson to generate it, or synthesize your own to get the latest versions from master to build.

StollD commented 3 years ago

But since you are pointing out that Oreo have it, I'll try to get in touch with @electrikjesus from BlissOS and try to compile in newer version. Still, I hope we can find a solution so that nougat users can get touch working.

Just patch bionic to include the updated header file, or add it to the include path when iptsd is being built. Upstream doesnt have it because Nougat can run on ancient kernels (3.1y or so), which dont support these interfaces. But if you don't plan to run it on these ancient kernels, you can just add it yourself.

hmtheboy154 commented 3 years ago

Thanks for your suggestion, I'll try out soon

hmtheboy154 commented 3 years ago

But since you are pointing out that Oreo have it, I'll try to get in touch with @electrikjesus from BlissOS and try to compile in newer version. Still, I hope we can find a solution so that nougat users can get touch working.

Just patch bionic to include the updated header file, or add it to the include path when iptsd is being built. Upstream doesnt have it because Nougat can run on ancient kernels (3.1y or so), which dont support these interfaces. But if you don't plan to run it on these ancient kernels, you can just add it yourself.

It's working, thanks for your help :D

[100% 6/6] Install: out/target/product/x86_64/system/bin/iptsd