Skip to content

Commit

Permalink
Support comfort yaw transition via controller buttons as well
Browse files Browse the repository at this point in the history
  • Loading branch information
StellaArtois committed Feb 13, 2016
1 parent 91337d8 commit 62fae48
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 32 deletions.
2 changes: 0 additions & 2 deletions applychanges.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,3 @@

REM.\mcp\runtime\bin\python\python_mcp applychanges.py
python applychanges.py

pause
47 changes: 25 additions & 22 deletions patches/net/minecraft/client/Minecraft.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
+
Expand Down Expand Up @@ -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;
}
Expand All @@ -1204,7 +1203,7 @@
}

if (this.currentScreen == null)
@@ -1838,6 +2332,11 @@
@@ -1838,6 +2331,11 @@
this.currentScreen.handleMouseInput();
}
}
Expand All @@ -1216,7 +1215,7 @@
}

if (this.leftClickCounter > 0)
@@ -1889,6 +2388,10 @@
@@ -1889,6 +2387,10 @@
}
else
{
Expand All @@ -1227,7 +1226,7 @@
if (Keyboard.getEventKey() == 1)
{
this.displayInGameMenu();
@@ -1932,10 +2435,12 @@
@@ -1932,10 +2434,12 @@
this.gameSettings.saveOptions();
}

Expand All @@ -1241,7 +1240,7 @@

if (Keyboard.getEventKey() == 61)
{
@@ -1975,6 +2480,11 @@
@@ -1975,6 +2479,11 @@
}
}
}
Expand All @@ -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);
}
Expand All @@ -1266,7 +1265,7 @@

if (this.theWorld != null)
{
@@ -2164,7 +2680,11 @@
@@ -2164,7 +2679,11 @@
this.mcProfiler.endStartSection("pendingConnection");
this.myNetworkManager.processReceivedPackets();
}
Expand All @@ -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)
{
Expand All @@ -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]));

Expand Down Expand Up @@ -1400,7 +1399,7 @@

/**
* unloads the current world first
@@ -2252,6 +2825,13 @@
@@ -2252,6 +2824,13 @@
*/
public void loadWorld(WorldClient worldClientIn, String loadingMessage)
{
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -1454,7 +1453,7 @@
}

this.mcSoundHandler.stopSounds();
@@ -2406,10 +3012,12 @@
@@ -2406,10 +3011,12 @@
return this.thePlayer != null ? this.thePlayer.sendQueue : null;
}

Expand All @@ -1468,7 +1467,7 @@

public static boolean isFancyGraphicsEnabled()
{
@@ -2437,107 +3045,117 @@
@@ -2437,107 +3044,117 @@
Item var2;
int var5;

Expand Down Expand Up @@ -1685,7 +1684,7 @@

if (var1)
{
@@ -2810,11 +3428,18 @@
@@ -2810,11 +3427,18 @@
playerSnooper.addStatToSnooper("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
}

Expand All @@ -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)
{
Expand All @@ -1719,7 +1718,7 @@

/**
* Returns whether snooping is enabled or not.
@@ -3134,4 +3761,1051 @@
@@ -3134,4 +3760,1055 @@
}
}
}
Expand Down Expand Up @@ -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] ");
Expand Down
2 changes: 2 additions & 0 deletions src/com/mtbs3d/minecrift/control/ControlBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 10 additions & 3 deletions src/com/mtbs3d/minecrift/control/ItemLeftControlBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

}
Expand Down
13 changes: 10 additions & 3 deletions src/com/mtbs3d/minecrift/control/ItemRightControlBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

}
Expand Down
9 changes: 8 additions & 1 deletion src/com/mtbs3d/minecrift/gui/GuiMoveAimSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion src/com/mtbs3d/minecrift/provider/MCController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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<String,String>();

try {
ProfileReader bindingsReader = new ProfileReader(ProfileManager.PROFILE_SET_CONTROLLER_BINDINGS, theProfiles);
String line;
Expand Down
8 changes: 8 additions & 0 deletions src/com/mtbs3d/minecrift/settings/VRSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62fae48

Please sign in to comment.