Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easier to enter initials with keyboard controls on the high-score page #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/main/engine/ohiscore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@ void OHiScore::do_input(uint32_t adr)
// Source: 0xD4DA
int8_t OHiScore::read_controls()
{
int fast_threshold, slow_threshold;

if (input.analog || input.gamepad) {
fast_threshold = 0x30;
slow_threshold = 0x10;
} else {
// Don't demand as much of a steering input to change letters when using keyboard
fast_threshold = 0x10;
slow_threshold = 0x04;
}

// Determine when accelerator has been pressed then depressed
if (oinputs.input_acc < 0x30)
{
Expand All @@ -404,7 +415,7 @@ int8_t OHiScore::read_controls()

// Check Steering Wheel
int8_t movement = 1; // default to right
int16_t steering = (oinputs.input_steering & 0xFF) - 0x80;
int16_t steering = (oinputs.input_steering & 0xFF) - OInputs::STEERING_CENTRE;
if (steering < 0)
{
steering = -steering;
Expand All @@ -413,9 +424,9 @@ int8_t OHiScore::read_controls()

// Set increment to potentially advance to next letter.
// This depends on how far the steering wheel is turned.
if (steering >= 0x30)
if (steering >= fast_threshold)
steer += 5;
else if (steering >= 0x10)
else if (steering >= slow_threshold)
steer += 1;

if (steer >= 0x14)
Expand Down Expand Up @@ -792,4 +803,4 @@ void OHiScore::convert_lap_time(uint16_t time)
// Output Minutes
laptime[1] = (minutes & 0xF) | TILE_PROPS;
laptime[0] = ((minutes & 0xF0) >> 4) | TILE_PROPS;
}
}
4 changes: 3 additions & 1 deletion src/main/engine/oinputs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class OInputs
bool is_analog_r();
bool is_analog_select();

// Steering position is a one-byte value, center of range == neutral
const static uint8_t STEERING_CENTRE = 0x80;

private:
// ------------------------------------------------------------------------
// Variables for port
Expand All @@ -77,7 +80,6 @@ class OInputs

const static uint8_t STEERING_MIN = 0x48;
const static uint8_t STEERING_MAX = 0xB8;
const static uint8_t STEERING_CENTRE = 0x80;

// Current steering value
int16_t steering_old;
Expand Down