Descent3 icon indicating copy to clipboard operation
Descent3 copied to clipboard

Controls do not work correctly on M-series Macs

Open jcoby opened this issue 10 months ago • 6 comments

Build Version

86a6c139ee9b71ffa2a043a1778765367ee0652e

Operating System Environment

  • [ ] Microsoft Windows (32-bit)
  • [ ] Microsoft Windows (64-bit)
  • [X] Mac OS X
  • [ ] Linux (specify distribution and version below)

CPU Environment

  • [ ] x86 (32-bit Intel/AMD)
  • [ ] x86_64 (64-bit Intel/AMD)
  • [ ] ARM (32-bit)
  • [X] ARM64 (64-bit; sometimes called AArch64)
  • [ ] Other (RISC V, PPC...)

Game Modes Affected

  • [X] Single player
  • [ ] Anarchy
  • [ ] Hyper-Anarchy
  • [ ] Robo-Anarchy
  • [ ] Team Anarchy
  • [ ] Capture the Flag
  • [ ] Bounty
  • [ ] Entropy
  • [ ] Hoard
  • [ ] Monsterball
  • [ ] Cooperative

Game Environment

No response

Description

The player is only allowed to pitch down, yaw right, roll left on the M-series Mac. Affects both the mouse and keyboard. Cross controls do work (rolling left + right stops rolling, pitching up + down stops pitching, etc) so it appears to be a problem with applying the input to the game state not detecting the input.

Regression Status

No response

Steps to Reproduce

No response

jcoby avatar Apr 23 '24 13:04 jcoby

Could be here sensitivity problem? On Linux I have to manually set mouse and keyboard sensitivity. On first run all values are sets to 0.

winterheart avatar Apr 23 '24 19:04 winterheart

Could be here sensitivity problem? On Linux I have to manually set mouse and keyboard sensitivity. On first run all values are sets to 0.

Doesn't seem to be. I can pitch up, yaw left, roll right just fine. All the settings are the default 1.0 on the config pages too.

jcoby avatar Apr 23 '24 20:04 jcoby

This may be something SDL related, I don't trust the m-series to have maintained 1.2 compatibility very well if at all.

JeodC avatar Apr 23 '24 21:04 JeodC

This may be something SDL related, I don't trust the m-series to have maintained 1.2 compatibility very well if at all.

Possibly but it doesn't act that way. For example, when I yaw right the ship rolls right something like 30° and yaws right. When I try to yaw left the ship rolls left the same 30° but doesn't actually yaw left. I can also slide in all 6 directions without issues so I'm wondering if there is some trickery going on inside the matrix math that 64 bit doesn't like.

jcoby avatar Apr 23 '24 21:04 jcoby

Can confirm on my M3 MacBook Pro.

MaddTheSane avatar Apr 23 '24 23:04 MaddTheSane

It looks like the arrow keys in the automap work fine.

MaddTheSane avatar Apr 25 '24 00:04 MaddTheSane

This also affects game controllers (although having a good set-up for Descent 3 on a modern computer would probably be its own discussion).

My guess is some programmer logic is probably padded in a way to make it no longer work on ARM64.

MaddTheSane avatar Apr 25 '24 09:04 MaddTheSane

And I just tested it on an Intel Mac running 10.3.6: no issue.

MaddTheSane avatar Apr 25 '24 09:04 MaddTheSane

Great info, thanks!

JeodC avatar Apr 25 '24 10:04 JeodC

It may be worth looking into InSprocket.c in the mac folder.

JeodC avatar Apr 25 '24 14:04 JeodC

Mac OS X doesn't have Input Sprocket: It was one of the many Mac OS 9 technologies that didn't make the transition (Draw Sprocket, one of the components of the gaming sprockets, did, but has since been deprecated).

MaddTheSane avatar Apr 25 '24 19:04 MaddTheSane

Mac OS X doesn't have Input Sprocket: It was one of the many Mac OS 9 technologies that didn't make the transition (Draw Sprocket, one of the components of the gaming sprockets, did, but has since been deprecated).

Ah, thank you. I'm entirely unfamiliar.

JeodC avatar Apr 25 '24 20:04 JeodC

Some progress here. Patch (below) seems to allow controlling semi-normally but I quite honestly don't understand how any movement was possible before.

The tangles struct works with fixed point math and is always (0,0,0) at 0.017 per frame when converted from float. The FloatToFix call converts it to a fixed point number.

The 0.00002 multiplier is completely arbitrary and is mostly what "feels right"

index 4a32807..657a909 100644
--- a/physics/physics.cpp
+++ b/physics/physics.cpp
@@ -1,5 +1,5 @@
 /*
-* Descent 3 
+* Descent 3
 * Copyright (C) 2024 Parallax Software
 *
 * This program is free software: you can redistribute it and/or modify
@@ -664,14 +664,33 @@ bool PhysicsDoSimRot(object *obj, float frame_time, matrix *orient, vector *rott
     PhysicsApplyConstRotForce(*obj, *rotthrust, *rotvel, frame_time);
   }
 
+// if(obj->type == OBJ_PLAYER ) {
+//   mprintf((0, "Player Rotational Velocity = %f %f %f)\n", rotvel->x, rotvel->y, rotvel->z));
+//   mprintf((0, "Player Rotational Velocity = %f %f %f)\n", rotvel->x * frame_time, rotvel->y * frame_time, rotvel->z * frame_time));
+// }
   // Apply rotation to the "un-rollbanked" object
-  tangles.p = rotvel->x * frame_time;
-  tangles.h = rotvel->y * frame_time;
-  tangles.b = rotvel->z * frame_time;
+  tangles.p = FloatToFix(rotvel->x * frame_time *.00002);
+  tangles.h = FloatToFix(rotvel->y * frame_time*.00002);
+  tangles.b = FloatToFix(rotvel->z * frame_time*.00002);
+#define XYZm(v) (v).x, (v).y, (v).z
+
+  if(obj->type == OBJ_PLAYER ) {
+  // mprintf((0, "tangles (%f) = %d %d %d (%f %f %f)\n", frame_time, tangles.p, tangles.h, tangles.b, rotvel->x, rotvel->y, rotvel->z));
+  //   	mprintf((0, " rotmat 1 %f, %f, %f,\n%f, %f, %f,\n%f %f %f\n\n", XYZm(rotmat.fvec), XYZm(rotmat.rvec),
+  // XYZm(rotmat.uvec)));
+
+//   mprintf((0, "Player Rotational Velocity = %f %f %f)\n", rotvel->x * frame_time, rotvel->y * frame_time, rotvel->z * frame_time));
+}
 
   vm_AnglesToMatrix(&rotmat, tangles.p, tangles.h, tangles.b);
   *orient = *orient * rotmat; // ObjSetOrient is below
 
+  if(obj->type == OBJ_PLAYER) {
+
+  // 	mprintf((0, " rotmat 2 %f, %f, %f,\n%f, %f, %f,\n%f %f %f\n\n", XYZm(rotmat.fvec), XYZm(rotmat.rvec),
+  // XYZm(rotmat.uvec)));
+  }
+
   // Determine the new turnroll from this amount of turning
   if (pi->flags & PF_TURNROLL) {
     set_object_turnroll(obj, rotvel, turnroll);
@@ -685,8 +704,11 @@ bool PhysicsDoSimRot(object *obj, float frame_time, matrix *orient, vector *rott
     *orient = *orient * rotmat; // ObjSetOrient is below
   }
 
-  //	mprintf((0, " a %f, %f, %f,\n%f, %f, %f,\n%f %f %f\n\n", XYZ(&obj->orient.fvec), XYZ(&obj->orient.rvec),
+  // if(obj->type == OBJ_PLAYER) {
+
+  // 	mprintf((0, " a %f, %f, %f,\n%f, %f, %f,\n%f %f %f\n\n", XYZ(&obj->orient.fvec), XYZ(&obj->orient.rvec),
   // XYZ(&obj->orient.uvec)));
+  // }
 
   // Make sure the new orientation is valid
   vm_Orthogonalize(orient);

jcoby avatar Apr 26 '24 16:04 jcoby