From 62fae48ae2bfdefc56c0151b542fb666b1e4dfbd Mon Sep 17 00:00:00 2001 From: StellaArtois Date: Sat, 13 Feb 2016 15:52:48 +0000 Subject: [PATCH] Support comfort yaw transition via controller buttons as well --- applychanges.bat | 2 - .../net/minecraft/client/Minecraft.java.patch | 47 ++++++++++--------- .../minecrift/control/ControlBinding.java | 2 + .../control/ItemLeftControlBinding.java | 13 +++-- .../control/ItemRightControlBinding.java | 13 +++-- .../minecrift/gui/GuiMoveAimSettings.java | 9 +++- .../minecrift/provider/MCController.java | 7 ++- .../mtbs3d/minecrift/settings/VRSettings.java | 8 ++++ 8 files changed, 69 insertions(+), 32 deletions(-) diff --git a/applychanges.bat b/applychanges.bat index a7efa73a..51185370 100644 --- a/applychanges.bat +++ b/applychanges.bat @@ -2,5 +2,3 @@ REM.\mcp\runtime\bin\python\python_mcp applychanges.py python applychanges.py - -pause diff --git a/patches/net/minecraft/client/Minecraft.java.patch b/patches/net/minecraft/client/Minecraft.java.patch index 8ac6969a..dac5918a 100644 --- a/patches/net/minecraft/client/Minecraft.java.patch +++ b/patches/net/minecraft/client/Minecraft.java.patch @@ -225,7 +225,7 @@ + * The minecriftVerString will be automatically updated by the build scripts, do not modify here. + * Modify minecriftversion.py in root minecrift dir. + */ -+ public final String minecriftVerString = "Minecrift 1.7.10 R2"; ++ public final String minecriftVerString = "Minecrift 1.7.10 R2-A1"; + /* end version */ + /** END MINECRIFT */ + @@ -1182,20 +1182,19 @@ var9 = Mouse.getEventButton(); KeyBinding.setKeyBindState(var9 - 100, Mouse.getEventButtonState()); -@@ -1808,6 +2294,12 @@ +@@ -1808,6 +2294,11 @@ if (var4 != 0) { + /** MINECRIFT **/ -+ if ((this.vrSettings.useVrComfort == VRSettings.VR_COMFORT_PITCHANDYAW || this.vrSettings.useVrComfort == VRSettings.VR_COMFORT_YAW) && -+ this.vrSettings.useKeyBindingForComfortYaw) { -+ this.lookaimController.triggerYawTransition(var4 > 0 ? true : false); ++ if (Minecraft.getMinecraft().vrSettings.isComfortYawTransitionKeyAllowed()) { ++ this.triggerYawTransition(var4 > 0 ? false : true); + } + else { this.thePlayer.inventory.changeCurrentItem(var4); if (this.gameSettings.noclip) -@@ -1824,6 +2316,8 @@ +@@ -1824,6 +2315,8 @@ this.gameSettings.noclipRate += (float)var4 * 0.25F; } @@ -1204,7 +1203,7 @@ } if (this.currentScreen == null) -@@ -1838,6 +2332,11 @@ +@@ -1838,6 +2331,11 @@ this.currentScreen.handleMouseInput(); } } @@ -1216,7 +1215,7 @@ } if (this.leftClickCounter > 0) -@@ -1889,6 +2388,10 @@ +@@ -1889,6 +2387,10 @@ } else { @@ -1227,7 +1226,7 @@ if (Keyboard.getEventKey() == 1) { this.displayInGameMenu(); -@@ -1932,10 +2435,12 @@ +@@ -1932,10 +2434,12 @@ this.gameSettings.saveOptions(); } @@ -1241,7 +1240,7 @@ if (Keyboard.getEventKey() == 61) { -@@ -1975,6 +2480,11 @@ +@@ -1975,6 +2479,11 @@ } } } @@ -1253,7 +1252,7 @@ } for (var9 = 0; var9 < 9; ++var9) -@@ -2070,6 +2580,12 @@ +@@ -2070,6 +2579,12 @@ this.sendClickBlockToController(this.currentScreen == null && this.gameSettings.keyBindAttack.getIsKeyPressed() && this.inGameHasFocus); } @@ -1266,7 +1265,7 @@ if (this.theWorld != null) { -@@ -2164,7 +2680,11 @@ +@@ -2164,7 +2679,11 @@ this.mcProfiler.endStartSection("pendingConnection"); this.myNetworkManager.processReceivedPackets(); } @@ -1279,7 +1278,7 @@ this.mcProfiler.endSection(); this.systemTime = getSystemTime(); } -@@ -2174,6 +2694,15 @@ +@@ -2174,6 +2693,15 @@ */ public void launchIntegratedServer(String folderName, String worldName, WorldSettings worldSettingsIn) { @@ -1295,7 +1294,7 @@ this.loadWorld((WorldClient)null); System.gc(); ISaveHandler var4 = this.saveLoader.getSaveLoader(folderName, false); -@@ -2207,37 +2736,81 @@ +@@ -2207,37 +2735,81 @@ this.loadingScreen.displaySavingString(I18n.format("menu.loadingLevel", new Object[0])); @@ -1400,7 +1399,7 @@ /** * unloads the current world first -@@ -2252,6 +2825,13 @@ +@@ -2252,6 +2824,13 @@ */ public void loadWorld(WorldClient worldClientIn, String loadingMessage) { @@ -1414,7 +1413,7 @@ if (worldClientIn == null) { NetHandlerPlayClient var3 = this.getNetHandler(); -@@ -2264,6 +2844,23 @@ +@@ -2264,6 +2843,23 @@ if (this.theIntegratedServer != null) { this.theIntegratedServer.initiateShutdown(); @@ -1438,7 +1437,7 @@ } this.theIntegratedServer = null; -@@ -2290,6 +2887,15 @@ +@@ -2290,6 +2886,15 @@ this.mcResourcePackRepository.func_148529_f(); this.setServerData((ServerData)null); this.integratedServerIsRunning = false; @@ -1454,7 +1453,7 @@ } this.mcSoundHandler.stopSounds(); -@@ -2406,10 +3012,12 @@ +@@ -2406,10 +3011,12 @@ return this.thePlayer != null ? this.thePlayer.sendQueue : null; } @@ -1468,7 +1467,7 @@ public static boolean isFancyGraphicsEnabled() { -@@ -2437,107 +3045,117 @@ +@@ -2437,107 +3044,117 @@ Item var2; int var5; @@ -1685,7 +1684,7 @@ if (var1) { -@@ -2810,11 +3428,18 @@ +@@ -2810,11 +3427,18 @@ playerSnooper.addStatToSnooper("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize())); } @@ -1704,7 +1703,7 @@ for (int var0 = 16384; var0 > 0; var0 >>= 1) { GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, var0, var0, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null); -@@ -2822,12 +3447,14 @@ +@@ -2822,12 +3446,14 @@ if (var1 != 0) { @@ -1719,7 +1718,7 @@ /** * Returns whether snooping is enabled or not. -@@ -3134,4 +3761,1051 @@ +@@ -3134,4 +3760,1055 @@ } } } @@ -2765,6 +2764,10 @@ + this.displayHeight = this.currentDisplayHeight; + } + ++ public void triggerYawTransition(boolean isPositive) { ++ this.lookaimController.triggerYawTransition(isPositive); ++ } ++ + public void print(String s) + { + s = s.replace("\n", "\n[Minecrift] "); diff --git a/src/com/mtbs3d/minecrift/control/ControlBinding.java b/src/com/mtbs3d/minecrift/control/ControlBinding.java index 005abab1..07863464 100644 --- a/src/com/mtbs3d/minecrift/control/ControlBinding.java +++ b/src/com/mtbs3d/minecrift/control/ControlBinding.java @@ -23,6 +23,8 @@ public interface ControlBindCallback { public static void CreateBindingList( GameSettings settings ) { + bindings.clear(); + // In game bindings.add( new WalkForwardBinding()); bindings.add( new WalkBackwardBinding()); diff --git a/src/com/mtbs3d/minecrift/control/ItemLeftControlBinding.java b/src/com/mtbs3d/minecrift/control/ItemLeftControlBinding.java index 5d6560e3..02d1d0d8 100644 --- a/src/com/mtbs3d/minecrift/control/ItemLeftControlBinding.java +++ b/src/com/mtbs3d/minecrift/control/ItemLeftControlBinding.java @@ -22,9 +22,16 @@ public void setValue(float value) { @Override public void setState(boolean state) { if( state ) { - EntityClientPlayerMP thePlayer = Minecraft.getMinecraft().thePlayer; - if( thePlayer != null ) - thePlayer.inventory.changeCurrentItem(1); + Minecraft mc = Minecraft.getMinecraft(); + EntityClientPlayerMP thePlayer = mc.thePlayer; + if( thePlayer != null ) { + if (Minecraft.getMinecraft().vrSettings.isComfortYawTransitionKeyAllowed()) { + mc.triggerYawTransition(false); + } + else { + thePlayer.inventory.changeCurrentItem(1); + } + } } } diff --git a/src/com/mtbs3d/minecrift/control/ItemRightControlBinding.java b/src/com/mtbs3d/minecrift/control/ItemRightControlBinding.java index f673cd2d..07075434 100644 --- a/src/com/mtbs3d/minecrift/control/ItemRightControlBinding.java +++ b/src/com/mtbs3d/minecrift/control/ItemRightControlBinding.java @@ -22,9 +22,16 @@ public void setValue(float value) { @Override public void setState(boolean state) { if( state ) { - EntityClientPlayerMP thePlayer = Minecraft.getMinecraft().thePlayer; - if( thePlayer != null ) - thePlayer.inventory.changeCurrentItem(-1); + Minecraft mc = Minecraft.getMinecraft(); + EntityClientPlayerMP thePlayer = mc.thePlayer; + if( thePlayer != null ) { + if (Minecraft.getMinecraft().vrSettings.isComfortYawTransitionKeyAllowed()) { + mc.triggerYawTransition(true); + } + else { + thePlayer.inventory.changeCurrentItem(-1); + } + } } } diff --git a/src/com/mtbs3d/minecrift/gui/GuiMoveAimSettings.java b/src/com/mtbs3d/minecrift/gui/GuiMoveAimSettings.java index b7fa6a6b..b801e20a 100644 --- a/src/com/mtbs3d/minecrift/gui/GuiMoveAimSettings.java +++ b/src/com/mtbs3d/minecrift/gui/GuiMoveAimSettings.java @@ -169,7 +169,14 @@ else if( var8 == VRSettings.VrOptions.AIM_PITCH_OFFSET ) private boolean getEnabledState(VRSettings.VrOptions var8) { - String s = var8.getEnumString(); + int s = var8.returnEnumOrdinal(); + + if (Minecraft.getMinecraft().lookaimController instanceof MCController && + !Minecraft.getMinecraft().lookaimController.isInitialized() && + s == ID_GENERIC_REINIT) { + return false; + } + return true; } diff --git a/src/com/mtbs3d/minecrift/provider/MCController.java b/src/com/mtbs3d/minecrift/provider/MCController.java index 70f18401..a0e2fd3e 100644 --- a/src/com/mtbs3d/minecrift/provider/MCController.java +++ b/src/com/mtbs3d/minecrift/provider/MCController.java @@ -305,7 +305,7 @@ public boolean init() { System.out.println("[Minecrift] Init MCController"); resetControllerEnvironment(); Controllers.create(); - hasControllers = Controllers.getControllerCount()> 0; + hasControllers = Controllers.getControllerCount() > 0; loadBindings(); System.out.println("[Minecrift] Initialized controllers: "+getInitializationStatus()); @@ -427,6 +427,11 @@ private void loadBindings() { } private void loadBindings(JSONObject theProfiles) { + // Cleanup any current bindings + ingame = new BindingMap(); + GUI = new BindingMap(); + bindingSaves = new HashMap(); + try { ProfileReader bindingsReader = new ProfileReader(ProfileManager.PROFILE_SET_CONTROLLER_BINDINGS, theProfiles); String line; diff --git a/src/com/mtbs3d/minecrift/settings/VRSettings.java b/src/com/mtbs3d/minecrift/settings/VRSettings.java index f883efc5..d8be50bc 100644 --- a/src/com/mtbs3d/minecrift/settings/VRSettings.java +++ b/src/com/mtbs3d/minecrift/settings/VRSettings.java @@ -2281,6 +2281,14 @@ public static double getInertiaAddFactor(int inertiaFactor) return addFac; } + public boolean isComfortYawTransitionKeyAllowed() { + if ((this.useVrComfort == VR_COMFORT_PITCHANDYAW || this.useVrComfort == VR_COMFORT_YAW) && + this.useKeyBindingForComfortYaw) { + return true; + } + return false; + } + public static enum VrOptions { // Minecrift below here