Skip to content

Commit

Permalink
fix problems related to macOS
Browse files Browse the repository at this point in the history
Update CocoaInput-lib
- Korea-Minecraft-Forum/CocoaInput-lib@80cd730 fix crash possibility & sonoma preliminary support

fixes #4, rect is not rendered in the correct position
  • Loading branch information
LemonCaramel committed Nov 4, 2023
1 parent fdc766d commit 7694f64
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,7 @@ git clone https://github.com/Korea-Minecraft-Forum/CocoaInput.git
cd CocoaInput
```

2. Compile native library<br>
CocoaInput needs native-platform libraries to work.
To compile them, run one of below scripts which is your platform.
- native/build_lib_for_mac.sh - For macOS
- native/build_lib_for_x11.sh - For Linux
- native/build_lib_for_win.sh - For Windows
- (native/build_lib_all.sh - For all platform, You should create remote_build.sh to build macOS lib remotely.)

3. Compile Mod<br>
2. Compile Mod<br>
Type below command.
Forge mod will be located in "forge/build/libs".
Fabric mod will be located in "fabric/build/libs".
Expand All @@ -31,7 +23,25 @@ Place it in your mods directory.

CocoaInput requires [MinecraftForge](https://github.com/MinecraftForge/MinecraftForge) or [Fabric](https://github.com/FabricMC/fabric-loader).

This mod uses [Java Native Access](https://github.com/java-native-access/jna) (Apache Licence2) and binary for Minecraft 1.7.10 contains it.
## Troubleshooting (macOS 14.0+)
If you are using macOS Sonoma or later versions, you may experience the following issue:
- Some characters are skipped when typing very quickly.
- The client crashes when a system key is pressed (e.g., input source switch).

Most of the causes are due to the Input Tooltip added in Sonoma. However, Apple has not provided an API to disable it.

![macOS Sonoma Indicator](https://github.com/LemonCaramel/caramelChat/assets/45729082/e1d34917-1892-4cb6-aa3f-38fdab58fad9)


You can disable the Input Tooltip system-wide through the following guide.

Open the Terminal and enter the following command:
```Bash
sudo mkdir -p /Library/Preferences/FeatureFlags/Domain
sudo /usr/libexec/PlistBuddy -c "Add 'redesigned_text_cursor:Enabled' bool false" /Library/Preferences/FeatureFlags/Domain/UIKit.plist
```
And then, reboot your Macintosh. This will return you to the input environment from before Sonoma.


## License
Minecraft Mod Public License Japanese Translation
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface Func_setMarkedText extends Callback {
}

interface Func_firstRectForCharacterRange extends Callback {
Pointer invoke();
void invoke(Pointer pointer);
}

// used to provide Objective-C with logging way
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jp.axer.cocoainput.arch.darwin;

import com.sun.jna.Memory;
import com.mojang.blaze3d.platform.Window;
import com.sun.jna.Pointer;
import jp.axer.cocoainput.CocoaInput;
import jp.axer.cocoainput.arch.darwin.CallbackFunction.Func_firstRectForCharacterRange;
Expand All @@ -10,6 +10,7 @@
import jp.axer.cocoainput.plugin.IMEReceiver;
import jp.axer.cocoainput.util.ModLogger;
import jp.axer.cocoainput.util.Rect;
import net.minecraft.client.Minecraft;
import java.util.UUID;

public class DarwinIMEOperator implements IMEOperator {
Expand Down Expand Up @@ -43,7 +44,7 @@ public void invoke(String str, int position1, int length1, int position2, int le

firstRectForCharacterRange_p = new Func_firstRectForCharacterRange() {
@Override
public Pointer invoke() {
public void invoke(Pointer pointer) {
ModLogger.debug("Called to determine where to draw.");
Rect point = owner.getRect();
float[] buff;
Expand All @@ -52,15 +53,17 @@ public Pointer invoke() {
} else {
buff = new float[]{point.getX(), point.getY(), point.getWidth(), point.getHeight()};
}
Window window = Minecraft.getInstance().getWindow();
double factor = CocoaInput.getScreenScaledFactor();
buff[0] *= factor;
buff[1] *= factor;
buff[2] *= factor;
buff[3] *= factor;

Pointer ret = new Memory(Float.BYTES * 4);
ret.write(0, buff, 0, 4);
return ret;
buff[0] += window.getX();
buff[1] += window.getY();

pointer.write(0, buff, 0, 4);
}
};

Expand Down
Binary file modified common/src/main/resources/darwin/libcocoainput.dylib
100644 → 100755
Binary file not shown.

0 comments on commit 7694f64

Please sign in to comment.