Skip to content

Commit

Permalink
Clock Mod
Browse files Browse the repository at this point in the history
Adds a clock to the menus of Beat Saber.
  • Loading branch information
sheakelso committed Jan 9, 2021
1 parent 2435464 commit 5ecef03
Show file tree
Hide file tree
Showing 19 changed files with 703 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

# VSCode config stuff
!.vscode/c_cpp_properties.json
!.vscode/tasks.json

# NDK stuff
out/
[Ll]ib/
[Ll]ibs/
[Oo]bj/
[Oo]bjs/
ndkpath.txt
*.zip
*.txt
extern/
Android.mk.backup
qpm.shared.json
24 changes: 24 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"configurations": [
{
"defines": [
"VERSION=\"0.1.0\"",
"__GNUC__",
"__aarch64__"
],
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/shared",
"${workspaceFolder}/include",
"${workspaceFolder}/extern/**",
"${workspaceFolder}/extern/libil2cpp/il2cpp/libil2cpp",
"C:/androidndk/android-ndk-r21d-windows-x86_64/android-ndk-r21d/**"
],
"name": "Quest",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
118 changes: 118 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
{
"files.associations": {
"iosfwd": "cpp",
"__config": "cpp",
"__nullptr": "cpp",
"thread": "cpp",
"any": "cpp",
"deque": "cpp",
"list": "cpp",
"map": "cpp",
"optional": "cpp",
"queue": "cpp",
"set": "cpp",
"stack": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"variant": "cpp",
"vector": "cpp",
"__bit_reference": "cpp",
"__debug": "cpp",
"__errc": "cpp",
"__functional_base": "cpp",
"__hash_table": "cpp",
"__locale": "cpp",
"__mutex_base": "cpp",
"__node_handle": "cpp",
"__split_buffer": "cpp",
"__string": "cpp",
"__threading_support": "cpp",
"__tree": "cpp",
"__tuple": "cpp",
"algorithm": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"cfenv": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"complex": "cpp",
"condition_variable": "cpp",
"csetjmp": "cpp",
"csignal": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"coroutine": "cpp",
"propagate_const": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"ostream": "cpp",
"random": "cpp",
"ratio": "cpp",
"regex": "cpp",
"scoped_allocator": "cpp",
"span": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"streambuf": "cpp",
"string": "cpp",
"string_view": "cpp",
"strstream": "cpp",
"system_error": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeindex": "cpp",
"typeinfo": "cpp",
"utility": "cpp",
"valarray": "cpp",
"xstring": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"concepts": "cpp",
"filesystem": "cpp",
"shared_mutex": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
},
"C_Cpp.errorSquiggles": "Enabled"
}
68 changes: 68 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "NDK Build",
"detail": "Builds the library using ndk-build.cmd",
"type": "shell",
"command": "ndk-build",
"windows": {
"command": "ndk-build.cmd"
},
"args": ["NDK_PROJECT_PATH=.", "APP_BUILD_SCRIPT=./Android.mk", "NDK_APPLICATION_MK=./Application.mk"],
"group": "build",
"options": {
"env": {}
}
},
{
"label": "Powershell Build",
"detail": "Builds the library using Powershell (recommended)",
"type": "shell",
"command": "./build.ps1",
"windows": {
"command": "./build.ps1"
},
"group": {
"kind": "build",
"isDefault": true
},
"options": {
"env": {}
}
},
{
"label": "Powershell Build and Copy",
"detail": "Builds and copies the library to the Quest using adb and force-quits Beat Saber",
"type": "shell",
"command": "./copy.ps1",
"windows": {
"command": "./copy.ps1"
},
"group": "build",
"options": {
"env": {}
}
},
{
"label": "BMBF Build",
"detail": "Builds a .zip to be uploaded into BMBF",
"type": "shell",
"command": "./buildBMBF.ps1",
"windows": {
"command": "./buildBMBF.ps1"
},
"args": [],
"group": "build",
"options": {
"env": {}
}
},
{
"label": "Start logging",
"detail": "Records a log to log.txt using adb logcat",
"type": "shell",
"command": "./startlogging.bat"
}
]
}
69 changes: 69 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


LOCAL_PATH := $(call my-dir)
TARGET_ARCH_ABI := $(APP_ABI)

rwildcard=$(wildcard $1$2) $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))

# Build the modloader shared library
include $(CLEAR_VARS)
# Creating prebuilt for dependency: modloader - version: 1.0.4
include $(CLEAR_VARS)
LOCAL_MODULE := modloader
LOCAL_EXPORT_C_INCLUDES := extern/modloader
LOCAL_SRC_FILES := extern/libmodloader.so
include $(PREBUILT_SHARED_LIBRARY)
# Creating prebuilt for dependency: beatsaber-hook - version: 0.8.4
include $(CLEAR_VARS)
LOCAL_MODULE := beatsaber-hook_0_8_4
LOCAL_EXPORT_C_INCLUDES := extern/beatsaber-hook
LOCAL_SRC_FILES := extern/libbeatsaber-hook_0_8_4.so
LOCAL_CPP_FEATURES += exceptions
include $(PREBUILT_SHARED_LIBRARY)
# Creating prebuilt for dependency: codegen - version: 0.4.0
include $(CLEAR_VARS)
LOCAL_MODULE := codegen_0_4_0
LOCAL_EXPORT_C_INCLUDES := extern/codegen
LOCAL_SRC_FILES := extern/libcodegen_0_4_0.so
include $(PREBUILT_SHARED_LIBRARY)
# Creating prebuilt for dependency: questui - version: 0.2.8
include $(CLEAR_VARS)
LOCAL_MODULE := questui
LOCAL_EXPORT_C_INCLUDES := extern/questui
LOCAL_SRC_FILES := extern/libquestui.so
include $(PREBUILT_SHARED_LIBRARY)
# Creating prebuilt for dependency: custom-types - version: 0.2.14
include $(CLEAR_VARS)
LOCAL_MODULE := custom-types
LOCAL_EXPORT_C_INCLUDES := extern/custom-types
LOCAL_SRC_FILES := extern/libcustom-types.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := clockmod
LOCAL_SRC_FILES += $(call rwildcard,src/,*.cpp)
LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.cpp)
LOCAL_SRC_FILES += $(call rwildcard,extern/beatsaber-hook/src/inline-hook,*.c)
LOCAL_SHARED_LIBRARIES += modloader
LOCAL_SHARED_LIBRARIES += beatsaber-hook_0_8_4
LOCAL_SHARED_LIBRARIES += codegen_0_4_0
LOCAL_SHARED_LIBRARIES += questui
LOCAL_SHARED_LIBRARIES += custom-types
LOCAL_LDLIBS += -llog
LOCAL_CFLAGS += -I'extern/libil2cpp/il2cpp/libil2cpp' -DID='"clockmod"' -DVERSION='"0.1.0"' -I'./shared' -I'./extern' -isystem'extern/codegen/include'
LOCAL_CPPFLAGS += -std=c++2a
LOCAL_C_INCLUDES += ./include ./src
include $(BUILD_SHARED_LIBRARY)
5 changes: 5 additions & 0 deletions Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_ABI := arm64-v8a
APP_PLATFORM := 25
APP_PIE:= true
APP_STL := c++_static
APP_CPPFLAGS := -std=gnu++2a
29 changes: 29 additions & 0 deletions bmbfmod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"id": "clockmod",
"name": "Clock Mod",
"version": "0.1.0",
"author": "BoopetyDoopety",
"description": [
"Displays the time in game. \n\nDoes not currently work with Hitscore Visualiser"
],
"category": "Gameplay",
"gameVersion": "1.13.0",
"platform": "Quest",
"components": [
{
"type": "HookMod",
"installAction": {
"installLibraryFile": "libclockmod.so"
},
"uninstallAction": {
"removeLibraryFile": "libclockmod.so"
}
},
{
"type": "HookModLibrary",
"installAction": {
"installLibraryFile": "libbeatsaber-hook_0_8_4.so"
}
}
]
}
8 changes: 8 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$NDKPath = Get-Content $PSScriptRoot/ndkpath.txt

$buildScript = "$NDKPath/build/ndk-build"
if (-not ($PSVersionTable.PSEdition -eq "Core")) {
$buildScript += ".cmd"
}

& $buildScript NDK_PROJECT_PATH=$PSScriptRoot APP_BUILD_SCRIPT=$PSScriptRoot/Android.mk NDK_APPLICATION_MK=$PSScriptRoot/Application.mk
6 changes: 6 additions & 0 deletions buildBMBF.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Builds a .zip file for loading with BMBF
& $PSScriptRoot/build.ps1

if ($?) {
Compress-Archive -Path "./libs/arm64-v8a/libclockmod.so", "./libs/arm64-v8a/libbeatsaber-hook_0_8_4.so", "./bmbfmod.json" -DestinationPath "./clockmod_v0.1.0.zip" -Update
}
12 changes: 12 additions & 0 deletions copy.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
& $PSScriptRoot/build.ps1
if ($?) {
adb push libs/arm64-v8a/libclockmod.so /sdcard/Android/data/com.beatgames.beatsaber/files/mods/libclockmod.so
if ($?) {
adb shell am force-stop com.beatgames.beatsaber
adb shell am start com.beatgames.beatsaber/com.unity3d.player.UnityPlayerActivity
if ($args[0] -eq "--log") {
$timestamp = Get-Date -Format "MM-dd HH:mm:ss.fff"
adb logcat -T "$timestamp" main-modloader:W QuestHook[clockmod`|v0.1.0]:* AndroidRuntime:E *:S
}
}
}
Loading

0 comments on commit 5ecef03

Please sign in to comment.