Repository navigation
Expand file tree
/
Copy pathmake-mouse
More file actions
executable file
·142 lines (118 loc) · 4.16 KB
/
Copy pathmake-mouse
File metadata and controls
executable file
·142 lines (118 loc) · 4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
# Exit on error
set -e
# Parse command line arguments
DEBUG_MODE=0
for arg in "$@"; do
case $arg in
--debug)
DEBUG_MODE=1
shift
;;
esac
done
CWD=$(pwd)
if [ $DEBUG_MODE -eq 1 ]; then
echo "=== Running in DEBUG mode for Linux ==="
# Create tmp directory
TMP_DIR="$CWD/.debug"
mkdir -p "$TMP_DIR"
# Build libevdev for host if not already installed
if ! pkg-config --exists libevdev; then
echo "Building libevdev for host system..."
cd "$TMP_DIR"
if [ ! -f "libevdev-1.13.2.tar.xz" ]; then
echo "Downloading libevdev..."
wget -nv https://www.freedesktop.org/software/libevdev/libevdev-1.13.2.tar.xz
fi
if [ ! -d "libevdev-1.13.2" ]; then
echo "Extracting libevdev..."
tar xf libevdev-1.13.2.tar.xz
fi
# Build libevdev for host
cd "$TMP_DIR/libevdev-1.13.2"
echo "Configuring libevdev for host..."
./configure --prefix="$TMP_DIR/install"
echo "Building libevdev..."
make -j$(nproc)
make install
LIBEVDEV_CFLAGS="-I$TMP_DIR/install/include -I$TMP_DIR/install/include/libevdev-1.0"
LIBEVDEV_LIBS="-L$TMP_DIR/install/lib -levdev"
else
echo "Using system libevdev"
LIBEVDEV_CFLAGS=$(pkg-config --cflags libevdev)
LIBEVDEV_LIBS=$(pkg-config --libs libevdev)
fi
# Compile with debug flags
cd "$CWD"
echo "Building mouse application for Linux with debug flags..."
cc -o "$TMP_DIR/mouse" *.c $LIBEVDEV_CFLAGS $LIBEVDEV_LIBS -g -DDEBUG
echo "=== Build completed (DEBUG mode) ==="
echo "Binary is at: $TMP_DIR/mouse"
# Launch the debug application
echo "Launching application in debug mode..."
cd "$TMP_DIR"
sudo ./mouse
else
# Original Android build logic
# NDK path - update this to match your setup
NDK=$HOME/Android/Sdk/ndk/29.0.13113456
API=30
TARGET=armv7a-linux-androideabi
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/linux-x86_64
# Add NDK tools to PATH
export PATH=$TOOLCHAIN/bin:$PATH
# Create build directory in current working directory
BUILD_DIR="$CWD/build"
mkdir -p "$BUILD_DIR"
echo "=== Building for Android $API ($TARGET) ==="
# Download and extract libevdev
cd "$BUILD_DIR"
if [[ ! -f "install/include/libevdev-1.0/libevdev/libevdev.h" || ! -f "install/include/libevdev-1.0/libevdev/libevdev-uinput.h" ]]; then
if [ ! -f "libevdev-1.13.2.tar.xz" ]; then
echo "Downloading libevdev..."
wget -nv https://www.freedesktop.org/software/libevdev/libevdev-1.13.2.tar.xz
fi
if [ ! -d "libevdev-1.13.2" ]; then
echo "Extracting libevdev..."
tar xf libevdev-1.13.2.tar.xz
fi
# Build libevdev
cd "$BUILD_DIR/libevdev-1.13.2"
echo "Configuring libevdev..."
# Configure with Android toolchain
CC="$TOOLCHAIN/bin/clang --target=$TARGET$API" \
CXX="$TOOLCHAIN/bin/clang++ --target=$TARGET$API" \
AR="$TOOLCHAIN/bin/llvm-ar" \
RANLIB="$TOOLCHAIN/bin/llvm-ranlib" \
STRIP="$TOOLCHAIN/bin/llvm-strip" \
./configure --host=$TARGET --prefix="$BUILD_DIR/install" \
--disable-shared --enable-static
echo "Building libevdev..."
make -j$(nproc)
make install
fi
# Now compile the main.c program
echo "Building mouse application..."
# Assuming main.c is in the current directory
cd "$CWD"
"$TOOLCHAIN/bin/clang" --target=$TARGET$API \
-I"$BUILD_DIR/install/include" \
-I"$BUILD_DIR/install/include/libevdev-1.0" \
-L"$BUILD_DIR/install/lib" \
-o "$BUILD_DIR/mouse" *.c \
-levdev
# Strip binary
"$TOOLCHAIN/bin/llvm-strip" "$BUILD_DIR/mouse"
echo "=== Build completed ==="
echo "Binary is at: $BUILD_DIR/mouse"
# make a zip archive with mouse, ../properties/*
if [ -d "$CWD/build/bundle" ]; then
rm -r "$CWD/build/bundle"
fi
mkdir -p "$CWD/build/bundle"
cd "$CWD/build/bundle"
cp -r $CWD/properties/* .
cp "$CWD/build/mouse" .
zip -r -FS FlipMouse.zip .
fi