Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
- Unlock Cosmetics (Hats, Visors, Skins, Pets, Nameplates, Cosmicubes, Bundles)
- Full Resolution (The game runs at half resolution by default)
- UwUify Game
- Keyboard Mode

### Other

Expand Down
1,903 changes: 1,903 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/core/ModuleManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BaseModule } from "./BaseModule";

import { KeyboardModule } from "../modules/Keyboard";
import { PassiveModule } from "../modules/Passive";
import { PlayerModule } from "../modules/Player";
import { ShipModule } from "../modules/Ship";
Expand All @@ -12,6 +13,7 @@ export class ModuleManager {

// prettier-ignore
private static modules: BaseModule[] = [
new KeyboardModule(),
new PassiveModule(),
new PlayerModule(),
new ShipModule(),
Expand Down
3 changes: 2 additions & 1 deletion src/data/State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export const State = {

unlockCosmetics: false,
disableAnalytics: false,
uwuifyMode: false
uwuifyMode: false,
keyboardMode: false
};
3 changes: 1 addition & 2 deletions src/i18n/localization/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
"full_resolution": "Volle Auflösung",
"disable_analytics": "Disable Analytics",

"uwuify": "UwU?",
"select_platform": "Select Platform"
"uwuify": "UwU?"
},
"other": {
"language": "Select Language",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/localization/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"disable_analytics": "Disable Analytics",

"uwuify": "UwU?",
"select_platform": "Select Platform"
"keyboard_mode": "Keyboard Mode",
"keyboard_mode_note": "Requires a physical keyboard. Touch controls may not work."
},
"other": {
"language": "Select Language",
Expand Down
70 changes: 70 additions & 0 deletions src/modules/Keyboard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { AssemblyHelper } from "../core/AssemblyHelper";
import { BaseModule } from "../core/BaseModule";
import { State } from "../data/State";

export class KeyboardModule extends BaseModule {
name = "Keyboard";

// Classes
private ActiveInputManager!: Il2Cpp.Class;

// Methods
private ActiveInputManager_UpdateActiveControlType!: Il2Cpp.Method;
private ActiveInputManager_OnLastActiveControllerChanged!: Il2Cpp.Method;
private ActiveInputManager_ShouldEnableTouch!: Il2Cpp.Method;
private HudManager_SetTouchType!: Il2Cpp.Method;

private keyboardInputValue!: Il2Cpp.ValueType;
private keyboardControlValue!: Il2Cpp.ValueType;

public init(): void {
this.ActiveInputManager = AssemblyHelper.AssemblyCSharp.class("ActiveInputManager");

this.ActiveInputManager_UpdateActiveControlType = this.ActiveInputManager.method<void>("UpdateActiveControlType", 0);
this.ActiveInputManager_OnLastActiveControllerChanged = this.ActiveInputManager.method<void>("OnLastActiveControllerChanged", 2);
this.ActiveInputManager_ShouldEnableTouch = this.ActiveInputManager.method<boolean>("ShouldEnableTouch", 0);

// Nested enum
const InputType = AssemblyHelper.AssemblyCSharp.class("ActiveInputManager/InputType");
this.keyboardInputValue = InputType.field<Il2Cpp.ValueType>("Keyboard").value;

const ControlTypes = AssemblyHelper.AssemblyCSharp.class("ControlTypes");
this.keyboardControlValue = ControlTypes.field<Il2Cpp.ValueType>("Keyboard").value;

const HudManager = AssemblyHelper.AssemblyCSharp.class("HudManager");
this.HudManager_SetTouchType = HudManager.method<void>("SetTouchType", 1);
}

public initHooks(): void {
const module = this;

this.ActiveInputManager_UpdateActiveControlType.implementation = function (): void {
if (!State.keyboardMode) return this.method<void>("UpdateActiveControlType").invoke();
module.setKeyboardMode();
};

this.ActiveInputManager_OnLastActiveControllerChanged.implementation = function (player, controller): void {
if (!State.keyboardMode) return this.method<void>("OnLastActiveControllerChanged").invoke(player, controller);
module.setKeyboardMode();
};

this.ActiveInputManager_ShouldEnableTouch.implementation = function (): boolean {
if (!State.keyboardMode) return this.method<boolean>("ShouldEnableTouch").invoke();
return false;
};

// type: ControlTypes enum
// @ts-ignore
this.HudManager_SetTouchType.implementation = function (type: Il2Cpp.ValueType): void {
const returnArg = State.keyboardMode ? module.keyboardControlValue : type;
this.method<void>("SetTouchType").invoke(returnArg);
};
}

/**
* Sets `ActiveInputManager.currentControlType` to `ActiveInputManager.InputType.Keyboard`
*/
private setKeyboardMode(): void {
this.ActiveInputManager.field("currentControlType").value = this.keyboardInputValue;
}
}
7 changes: 7 additions & 0 deletions src/ui/tabs/PassiveTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,12 @@ export class PassiveTab {
})
)
);

add(
layout.toggle(I18n.t("menu.functions.keyboard_mode"), (state: boolean) => {
State.keyboardMode = state;
})
);
add(layout.textView(I18n.t("menu.functions.keyboard_mode_note")));
}
}
8 changes: 8 additions & 0 deletions src/utils/UnityUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ export class UnityUtils {
return component.method<void>("set_enabled").invoke(state);
}

/**
* Wrapper over `m_CachedPtr` field
*
* Use it to check whether a Unity Object has been destroyed
* but still returns a non-zero address
*
* @param object
*/
static cachedPtr(object: Il2Cpp.Object): Il2Cpp.Pointer {
return object.field<Il2Cpp.Pointer>("m_CachedPtr").value;
}
Expand Down
Loading