Skip to content

Commit

Permalink
First pass at implementing a switch for to allow use of a bound key i…
Browse files Browse the repository at this point in the history
…nstead of crosshair movement to trigger a comfort mode yaw transition.
  • Loading branch information
StellaArtois committed Feb 13, 2016
1 parent e747db6 commit 91337d8
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 24 deletions.
56 changes: 39 additions & 17 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-d21";
+ public final String minecriftVerString = "Minecrift 1.7.10 R2";
+ /* end version */
+ /** END MINECRIFT */
+
Expand Down Expand Up @@ -1182,7 +1182,29 @@
var9 = Mouse.getEventButton();
KeyBinding.setKeyBindState(var9 - 100, Mouse.getEventButtonState());

@@ -1838,6 +2324,11 @@
@@ -1808,6 +2294,12 @@

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);
+ }
+ else {
this.thePlayer.inventory.changeCurrentItem(var4);

if (this.gameSettings.noclip)
@@ -1824,6 +2316,8 @@

this.gameSettings.noclipRate += (float)var4 * 0.25F;
}
+ }
+ /** END MINECRIFT **/
}

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

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

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

if (Keyboard.getEventKey() == 61)
{
@@ -1975,6 +2472,11 @@
@@ -1975,6 +2480,11 @@
}
}
}
Expand All @@ -1231,7 +1253,7 @@
}

for (var9 = 0; var9 < 9; ++var9)
@@ -2070,6 +2572,12 @@
@@ -2070,6 +2580,12 @@

this.sendClickBlockToController(this.currentScreen == null && this.gameSettings.keyBindAttack.getIsKeyPressed() && this.inGameHasFocus);
}
Expand All @@ -1244,7 +1266,7 @@

if (this.theWorld != null)
{
@@ -2164,7 +2672,11 @@
@@ -2164,7 +2680,11 @@
this.mcProfiler.endStartSection("pendingConnection");
this.myNetworkManager.processReceivedPackets();
}
Expand All @@ -1257,7 +1279,7 @@
this.mcProfiler.endSection();
this.systemTime = getSystemTime();
}
@@ -2174,6 +2686,15 @@
@@ -2174,6 +2694,15 @@
*/
public void launchIntegratedServer(String folderName, String worldName, WorldSettings worldSettingsIn)
{
Expand All @@ -1273,7 +1295,7 @@
this.loadWorld((WorldClient)null);
System.gc();
ISaveHandler var4 = this.saveLoader.getSaveLoader(folderName, false);
@@ -2207,37 +2728,81 @@
@@ -2207,37 +2736,81 @@

this.loadingScreen.displaySavingString(I18n.format("menu.loadingLevel", new Object[0]));

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

/**
* unloads the current world first
@@ -2252,6 +2817,13 @@
@@ -2252,6 +2825,13 @@
*/
public void loadWorld(WorldClient worldClientIn, String loadingMessage)
{
Expand All @@ -1392,7 +1414,7 @@
if (worldClientIn == null)
{
NetHandlerPlayClient var3 = this.getNetHandler();
@@ -2264,6 +2836,23 @@
@@ -2264,6 +2844,23 @@
if (this.theIntegratedServer != null)
{
this.theIntegratedServer.initiateShutdown();
Expand All @@ -1416,7 +1438,7 @@
}

this.theIntegratedServer = null;
@@ -2290,6 +2879,15 @@
@@ -2290,6 +2887,15 @@
this.mcResourcePackRepository.func_148529_f();
this.setServerData((ServerData)null);
this.integratedServerIsRunning = false;
Expand All @@ -1432,7 +1454,7 @@
}

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

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

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

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

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

Expand All @@ -1682,7 +1704,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 +3439,14 @@
@@ -2822,12 +3447,14 @@

if (var1 != 0)
{
Expand All @@ -1697,7 +1719,7 @@

/**
* Returns whether snooping is enabled or not.
@@ -3134,4 +3753,1051 @@
@@ -3134,4 +3761,1051 @@
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/com/mtbs3d/minecrift/api/IBodyAimController.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,6 @@ public interface IBodyAimController extends IBasePlugin {
*/
public double ratchetingYawTransitionPercent();
public double ratchetingPitchTransitionPercent();

public void triggerYawTransition(boolean isPositive);
}
25 changes: 21 additions & 4 deletions src/com/mtbs3d/minecrift/control/Aim.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ public void updateAim(int aimType, float aimPitchAdd, float aimYawAdd, float aim

configureComfortMode();


// *** Pitch ***

float headPitch = this.mc.headTracker.getHeadPitchDegrees(EyeType.ovrEye_Center);
float headPitchDelta = headPitch - this.prevHeadPitch;
this.prevHeadPitch = headPitch;

//Pitch
if (holdCenter) {
aimPitch = headPitch;
}
Expand Down Expand Up @@ -162,11 +164,13 @@ else if( this.mc.vrSettings.allowMousePitchInput ) // No keyhole with allow

boolean pitchGood = aimPitch != 90 && aimPitch != -90;


// *** Yaw ***

float headYaw = this.mc.headTracker.getHeadYawDegrees(EyeType.ovrEye_Center);
float headYawDelta = headYaw - this.prevHeadYaw;
this.prevHeadYaw = headYaw;

// Yaw
if (holdCenter) {
aimYaw = headYaw;
}
Expand Down Expand Up @@ -200,9 +204,19 @@ else if (aimYaw < keyholeYawLeft)
}

// Only accrue controller yaw *delta* while touching the edge of the keyhole...
if( pitchGood && aimYawAdd != 0 )
if( pitchGood && aimYawAdd != 0)
{
aimYaw += aimYawAdd;

// If we are using cycle left / cycle right key mapping for yaw control,
// don't accrue any additional yaw here...
if(this.mc.vrSettings.useKeyBindingForComfortYaw && aimYaw > keyholeYawRight) {
aimYaw = keyholeYawRight;
}
else if(this.mc.vrSettings.useKeyBindingForComfortYaw && aimYaw < keyholeYawLeft) {
aimYaw = keyholeYawLeft;
}

if( aimYaw > keyholeYawRight )
{
if (aimYawAdd > 0 || aimType != VRSettings.AIM_TYPE_LOOSE)
Expand Down Expand Up @@ -245,7 +259,6 @@ else if( aimYaw < keyholeYawLeft )
discreteYaw.update(0, currentTimeSecs);
bodyYaw = (float)discreteYaw.getCurrent(this.mc.PredictedDisplayTimeSeconds);
bodyYaw -= (!this.mc.vrSettings.crosshairHeadRelative ? 0 : headYawDelta);
updatedYaw = true;
}

bodyYaw %= 360;
Expand Down Expand Up @@ -294,6 +307,10 @@ static public double getYawTransitionPercent() {
return discreteYaw._percent;
}

static public void triggerYawChange(boolean isPositive) {
discreteYaw.triggerChange(isPositive);
}

static public double getPitchTransitionPercent() {
return discretePitch._percent;
}
Expand Down
9 changes: 9 additions & 0 deletions src/com/mtbs3d/minecrift/control/DiscreteAngle.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ else if (_state == DiscreteAngleState.TRACKING && _delta <= -_trigger)
}
}

public void triggerChange(boolean isPositive) {
if (isPositive) {
_delta += _trigger;
}
else {
_delta -= _trigger;
}
}

public double getCurrent(double currentTimeSecs)
{
double angle = _currentReported;
Expand Down
24 changes: 22 additions & 2 deletions src/com/mtbs3d/minecrift/gui/GuiLocomotionSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class GuiLocomotionSettings extends BaseGuiSettings implements GuiEventEx
VRSettings.VrOptions.DUMMY,
VRSettings.VrOptions.DUMMY,
VRSettings.VrOptions.USE_VR_COMFORT,
VRSettings.VrOptions.DUMMY,
VRSettings.VrOptions.VR_COMFORT_USE_KEY_BINDING_FOR_YAW,
VRSettings.VrOptions.VR_COMFORT_TRANSITION_LINEAR,
VRSettings.VrOptions.VR_COMFORT_TRANSITION_ANGLE_DEGS,
VRSettings.VrOptions.VR_COMFORT_TRANSITION_TIME_SECS,
Expand Down Expand Up @@ -99,7 +99,15 @@ private boolean getEnabledState(VRSettings.VrOptions var8)
(s == VRSettings.VrOptions.VR_COMFORT_TRANSITION_ANGLE_DEGS.getEnumString() ||
s == VRSettings.VrOptions.VR_COMFORT_TRANSITION_TIME_SECS.getEnumString() ||
s == VRSettings.VrOptions.VR_COMFORT_TRANSITION_BLANKING_MODE.getEnumString() ||
s == VRSettings.VrOptions.VR_COMFORT_TRANSITION_LINEAR.getEnumString()))
s == VRSettings.VrOptions.VR_COMFORT_TRANSITION_LINEAR.getEnumString() ||
s == VRSettings.VrOptions.VR_COMFORT_USE_KEY_BINDING_FOR_YAW.getEnumString()))
{
return false;
}

if ((this.guivrSettings.useVrComfort != this.guivrSettings.VR_COMFORT_YAW &&
this.guivrSettings.useVrComfort != this.guivrSettings.VR_COMFORT_PITCHANDYAW) &&
s == VRSettings.VrOptions.VR_COMFORT_USE_KEY_BINDING_FOR_YAW.getEnumString())
{
return false;
}
Expand Down Expand Up @@ -147,6 +155,7 @@ else if (par1GuiButton.id == ID_GENERIC_DEFAULTS)
vr.movementQuantisation = 0;
vr.inertiaFactor = VRSettings.INERTIA_NORMAL;
vr.allowPitchAffectsHeightWhileFlying = false;
vr.useKeyBindingForComfortYaw = false;
Minecraft.getMinecraft().gameSettings.viewBobbing = true;

Minecraft.getMinecraft().gameSettings.saveOptions();
Expand Down Expand Up @@ -290,6 +299,17 @@ protected String[] getTooltipLines(String displayString, int buttonId)
" ON: (Recommended) Pitch input affects elevation",
" while flying. An enjoyable travel experience!"
};
case VR_COMFORT_USE_KEY_BINDING_FOR_YAW:
return new String[]{
"Determines how a comfort mode yaw transition (player",
"turn to the left or right) is triggered.",
" Crosshair: (Default) Moving the crosshair to the edge",
" of the keyhole will trigger a yaw",
" transition.",
" Key: The 'Cycle Item Left / Right' key or",
" controller binding wil instead be used to",
" trigger a yaw transition."
};
default:
return null;
}
Expand Down
5 changes: 5 additions & 0 deletions src/com/mtbs3d/minecrift/provider/MCController.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,4 +558,9 @@ public void loadDefaults() {
ProfileManager.loadControllerDefaults();
loadBindings();
}

@Override
public void triggerYawTransition(boolean isPositive) {
this.joyAim.triggerYawChange(isPositive);
}
}
5 changes: 5 additions & 0 deletions src/com/mtbs3d/minecrift/provider/MCHydra.java
Original file line number Diff line number Diff line change
Expand Up @@ -794,4 +794,9 @@ public void saveOptions() {
public void loadDefaults() {

}

@Override
public void triggerYawTransition(boolean isPositive) {
this.discreteYaw.triggerChange(isPositive);
}
}
5 changes: 5 additions & 0 deletions src/com/mtbs3d/minecrift/provider/MCMouse.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,9 @@ public void saveOptions() {
public void loadDefaults() {

}

@Override
public void triggerYawTransition(boolean isPositive) {
this.aim.triggerYawChange(isPositive);
}
}
Loading

0 comments on commit 91337d8

Please sign in to comment.