Skip to content

Commit

Permalink
Added configurable mouse flight sensitivity (0.005 - 1.0). Also, chan…
Browse files Browse the repository at this point in the history
…gelog updates.
  • Loading branch information
AnotherCommander committed Nov 19, 2024
1 parent 7f5034b commit 222d325
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Doc/CHANGELOG.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ General:
* OXZ Manager: Implemented filter by category.
* OXZ Manager: Leading whitespaces in text filters are now ignored for reduced
confusion.
* Updated the wormhole cloud effect.
* Mouse flight sensitivity made configurable by editing the preferences file.

Expansion Pack Development:
===========================
Expand Down
3 changes: 2 additions & 1 deletion src/SDL/MyOpenGLView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ MA 02110-1301, USA.

#define MAX_COLOR_SATURATION 2.0f

#define MOUSEVIRTUALSTICKSENSITIVITYFACTOR 0.95f
#define MOUSEX_MAXIMUM 0.6
#define MOUSEY_MAXIMUM 0.6

Expand Down Expand Up @@ -177,6 +176,8 @@ extern int debug;
NSMutableString *typedString;

NSPoint virtualJoystickPosition;

float _mouseVirtualStickSensitivityFactor;

NSSize viewSize;
GLfloat display_z;
Expand Down
10 changes: 7 additions & 3 deletions src/SDL/MyOpenGLView.m
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ - (id) init

virtualJoystickPosition = NSMakePoint(0.0,0.0);
mouseWarped = NO;

_mouseVirtualStickSensitivityFactor = OOClamp_0_1_f([prefs oo_floatForKey:@"mouse-flight-sensitivity" defaultValue:0.95f]);
// ensure no chance of a divide by zero later on
if (_mouseVirtualStickSensitivityFactor < 0.005f) _mouseVirtualStickSensitivityFactor = 0.005f;

typedString = [[NSMutableString alloc] initWithString:@""];
allowingStringInput = gvStringInputNo;
Expand Down Expand Up @@ -2057,8 +2061,8 @@ - (void)pollControls
SDL_MouseButtonEvent *mbtn_event;
SDL_MouseMotionEvent *mmove_event;
int mxdelta, mydelta;
float mouseVirtualStickSensitivityX = viewSize.width * MOUSEVIRTUALSTICKSENSITIVITYFACTOR;
float mouseVirtualStickSensitivityY = viewSize.height * MOUSEVIRTUALSTICKSENSITIVITYFACTOR;
float mouseVirtualStickSensitivityX = viewSize.width * _mouseVirtualStickSensitivityFactor;
float mouseVirtualStickSensitivityY = viewSize.height * _mouseVirtualStickSensitivityFactor;
NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate];
Uint16 key_id;
int scan_code;
Expand Down Expand Up @@ -2163,7 +2167,7 @@ reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call
// annoyingly fatal in battle).
if(mouseInDeltaMode)
{
// possible TODO - make virtual stick sensitivity configurable
// note: virtual stick sensitivity is configurable
SDL_GetRelativeMouseState(&mxdelta, &mydelta);
double mxd=(double)mxdelta / mouseVirtualStickSensitivityX;
double myd=(double)mydelta / mouseVirtualStickSensitivityY;
Expand Down

0 comments on commit 222d325

Please sign in to comment.