Skip to content

Commit

Permalink
한영키의 키 바인딩 설정 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
sokcuri committed Aug 28, 2019
1 parent 6c57270 commit d712e7e
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/main/java/kr/neko/sokcuri/naraechat/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.INestedGuiEventHandler;
import net.minecraft.client.gui.screen.ControlsScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.client.util.InputMappings;
import net.minecraftforge.client.event.GuiScreenEvent;
Expand Down Expand Up @@ -75,11 +77,24 @@ public interface Imm32 extends StdCallLibrary {
}

@SubscribeEvent
public void onSpecialKeyPressed(GuiScreenEvent.KeyboardKeyPressedEvent.Pre event) {
public void proxyHangulSpecificKey(GuiScreenEvent.KeyboardKeyPressedEvent.Pre event) {

int keyCode = event.getKeyCode();
int scanCode = event.getScanCode();

Minecraft mc = Minecraft.getInstance();

KeyModifier activeModifier = KeyModifier.getActiveModifier();

int glfwModifier = 0;
if (activeModifier == KeyModifier.SHIFT) {
glfwModifier = GLFW_MOD_SHIFT;
} else if (activeModifier == KeyModifier.CONTROL) {
glfwModifier = GLFW_MOD_CONTROL;
} else if (activeModifier == KeyModifier.ALT) {
glfwModifier = GLFW_MOD_ALT;
}

// 102 키보드 문제 수정. 한글/한자 키를 강재로 리매핑한다
if (keyCode == -1 && scanCode == 0x1F2 || keyCode == -1 && scanCode == 0x1F1) {
if (scanCode == 0x1F2) {
Expand All @@ -91,19 +106,17 @@ public void onSpecialKeyPressed(GuiScreenEvent.KeyboardKeyPressedEvent.Pre event
}

event.setCanceled(true);
}

int glfwModifier = 0;
if (KeyModifier.getActiveModifier() == KeyModifier.SHIFT) {
glfwModifier = GLFW_MOD_SHIFT;
} else if (KeyModifier.getActiveModifier() == KeyModifier.CONTROL) {
glfwModifier = GLFW_MOD_CONTROL;
} else if (KeyModifier.getActiveModifier() == KeyModifier.ALT) {
glfwModifier = GLFW_MOD_ALT;
// 키 바인딩 설정창일 때 우측 CONTROL이나 ALT가 단독으로만 동작하게 만들기
if (mc.currentScreen instanceof ControlsScreen) {
ControlsScreen controlsScreen = (ControlsScreen)mc.currentScreen;
if (keyCode == GLFW_KEY_RIGHT_CONTROL || keyCode == GLFW_KEY_RIGHT_ALT) {
controlsScreen.keyPressed(keyCode, scanCode, glfwModifier);
controlsScreen.buttonId = null;
event.setCanceled(true);
return;
}

Minecraft mc = Minecraft.getInstance();
mc.currentScreen.keyPressed(keyCode, scanCode, glfwModifier);
mc.currentScreen.keyReleased(keyCode, scanCode, glfwModifier);
}

KeyModifier modifier = KeyModifier.getActiveModifier();
Expand Down

0 comments on commit d712e7e

Please sign in to comment.