Skip to content

Commit

Permalink
Increased mumber of supported joysticks to 4. Adjustments to the stic…
Browse files Browse the repository at this point in the history
…k mapper screen to be able to list more than two joysticks.
  • Loading branch information
AnotherCommander committed May 20, 2018
1 parent d650b61 commit 4206592
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
37 changes: 32 additions & 5 deletions src/Core/Entities/PlayerEntityStickMapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import "OOJoystickManager.h"
#import "OOTexture.h"
#import "OOCollectionExtractors.h"
#import "HeadUpDisplay.h"

@interface PlayerEntity (StickMapperInternal)

Expand All @@ -52,7 +53,8 @@ - (void) setGuiToStickMapperScreen:(unsigned)skip resetCurrentRow: (BOOL) resetC
{
GuiDisplayGen *gui = [UNIVERSE gui];
OOJoystickManager *stickHandler = [OOJoystickManager sharedStickHandler];
NSArray *stickList = [stickHandler listSticks];
NSArray *stickList = [stickHandler listSticks];
unsigned stickCount = [stickList count];
unsigned i;

OOGUITabStop tabStop[GUI_MAX_COLUMNS];
Expand All @@ -65,11 +67,36 @@ - (void) setGuiToStickMapperScreen:(unsigned)skip resetCurrentRow: (BOOL) resetC
[gui clear];
[gui setTitle:[NSString stringWithFormat:@"Configure Joysticks"]];

for(i=0; i < [stickList count]; i++)
{
for(i=0; i < stickCount; i++)
{
NSString *stickNameForThisRow = [NSString stringWithFormat: @"Stick %d %@", i+1, [stickList objectAtIndex: i]];
// for more than 2 sticks, the stick name rows are populated by more than one name if needed
NSString *stickNameAdditional = nil;
if (stickCount > 2 && OOStringWidthInEm(stickNameForThisRow) > 18.0)
{
// string is too long, truncate it until its length gets below threshold
do {
stickNameForThisRow = [[stickNameForThisRow substringToIndex:[stickNameForThisRow length] - 5]
stringByAppendingString:@"..."];
} while (OOStringWidthInEm(stickNameForThisRow) > 18.0);
}
unsigned j = i + 2;
if (j < stickCount)
{
stickNameAdditional = [NSString stringWithFormat: @"Stick %d %@", j+1, [stickList objectAtIndex: j]];
if (OOStringWidthInEm(stickNameAdditional) > 11.0)
{
// string is too long, truncate it until its length gets below threshold
do {
stickNameAdditional = [[stickNameAdditional substringToIndex:[stickNameAdditional length] - 5]
stringByAppendingString:@"..."];
} while (OOStringWidthInEm(stickNameAdditional) > 11.0);
}
}
[gui setArray:[NSArray arrayWithObjects:
[NSString stringWithFormat: @"Stick %d", i+1],
[stickList objectAtIndex: i],
stickNameForThisRow,
@"", // skip one column
stickNameAdditional,
nil]
forRow:i + GUI_ROW_STICKNAME];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/OOJoystickManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ enum {
};

// Stick constants
#define MAX_STICKS 2
#define MAX_STICKS 4
#define MAX_AXES 16
#define MAX_REAL_BUTTONS 64
#define MAX_HATS 4
Expand Down

0 comments on commit 4206592

Please sign in to comment.