Main > Driving & Racing Cabinets

Mame hacks that make driving games play better with mouse/spinner/360wheel

<< < (21/21)

Yolo_Swaggins:
Hi Geecab i just tried your code and it seems to be totally not working at all for me. The steering wheel doesn't behave normal at all and starts pulling to the side etc. How is it your testing this code? On a controller? It doesn't seem to work at all for a steering wheel. Maybe im doing something wrong?


--- Code: ---    // Merge in the wheel edge latch bit
    if (m_hdc68k_wheel_edge)
    {
        result ^= 0x4000;
        printf("hdc68k_port1_r: merge latch result=%04X m_hdc68k_last_wheel=%04X\n", result, m_hdc68k_last_wheel);
        m_hdc68k_wheel_edge = 0;
    }


    m_hdc68k_last_port1 = result;
    return result;
}
   

uint16_t harddriv_state::hda68k_port1_r()
{
    uint16_t result = m_a80000->read();

   if (m_hdc68k_wheel_edge)
    {
        result ^= 0x4000;
        printf("hda68k_port1_r: merge latch result=%04X m_hdc68k_last_wheel=%04X\n", result, m_hdc68k_last_wheel);
        m_hdc68k_wheel_edge = 0;
    }

    return result;
}

uint16_t harddriv_state::hdc68k_wheel_r()
{
// grab the new wheel value
uint16_t new_wheel, raw_wheel = m_12badc[0].read_safe(0xffff);
int wheel_diff = 0;
bool is_wheel_increasing = false;
static uint8_t wheel_snapshot = 0;
static uint8_t wheel_offset = 0;
static bool steering_enabled = true;

if (machine().input().code_pressed(KEYCODE_S))
{
if (steering_enabled)
{
popmessage("Steering disabled (Re-center your wheel now...)");
steering_enabled = false;
wheel_snapshot = (m_hdc68k_last_wheel+wheel_offset)&0xff;
}

return ((wheel_snapshot << 8) | 0xff);
}
else
{
if (!steering_enabled)
{
popmessage("Steering enabled");
steering_enabled = true;
wheel_offset = (wheel_snapshot - raw_wheel)&0xff;
m_hdc68k_last_wheel = raw_wheel;
}
}

// Work out which way the wheel is spinning
if((m_hdc68k_last_wheel < 0x400) && (raw_wheel > 0xC00))        is_wheel_increasing = false;    //Wrapped from bottom to top
else if ((m_hdc68k_last_wheel > 0xC00) && (raw_wheel < 0x400))  is_wheel_increasing = true;     //Wrapped from top to bottom
else if(m_hdc68k_last_wheel > raw_wheel)                        is_wheel_increasing = false;
else if(m_hdc68k_last_wheel < raw_wheel)                        is_wheel_increasing = true;

//Steering damping:
//Ensure we don't jump from one encoder value to another too quickly confusing the game
//The game is aware only of changes to m_12badc's lower byte. This means the game can get easily confused if you where to move
//the wheel very quickly from say position 0x800 to 0xC12 in one cycle (Which was perhaps physically impossible using the
//actual arcade encoder). The game would be under the impression the wheel has moved only 0x12 values, rather than 0x412 values.
//If we detect a large change, slowly feed that information back to the game in managemtble amounts.
new_wheel = m_hdc68k_last_wheel;
while(new_wheel != raw_wheel)
{
if (is_wheel_increasing)
{
if (new_wheel >= 0xFFF) new_wheel = 0x000;
else new_wheel++;
}
else
{
if (new_wheel <= 0x000) new_wheel = 0xFFF;
else new_wheel--;
}

//Lets say the encoder can't move more that 32 teeth per cycle...
if (wheel_diff++ > 0x10) break;
}

if (machine().input().code_pressed(KEYCODE_LSHIFT))
{
popmessage("wheel=0x%04X", new_wheel);
}

m_hdc68k_last_wheel = new_wheel;
return ((new_wheel+wheel_offset) << 8) | 0xff;
}
--- End code ---

I'm trying this on a Logitech wheel at 900 degrees for input and having no luck at all.

geecab:
Ah jeez, that doesn't sound good. I tested it with mouse and also a flight yoke. Have you made this change too...

In hardriv.cpp, in the "static INPUT_PORTS_START( hdrivair )" section, change the ITP_PADDLE steering control for:
PORT_BIT( 0xfff, 0x000, IPT_POSITIONAL ) PORT_POSITIONS(0xfff) PORT_WRAPS PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_REVERSE PORT_NAME("Steering Wheel")

When you say it not working,  is that even without pressing the S key at all?

Yolo_Swaggins:

--- Quote from: geecab on May 11, 2024, 03:37:51 pm ---Ah jeez, that doesn't sound good. I tested it with mouse and also a flight yoke. Have you made this change too...

In hardriv.cpp, in the "static INPUT_PORTS_START( hdrivair )" section, change the ITP_PADDLE steering control for:
PORT_BIT( 0xfff, 0x000, IPT_POSITIONAL ) PORT_POSITIONS(0xfff) PORT_WRAPS PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_REVERSE PORT_NAME("Steering Wheel")

When you say it not working,  is that even without pressing the S key at all?

--- End quote ---

Yeah i did that it just totally messes up the steering and makes it unplayable, a flight yoke has a much narrower range of movement than a driving steering wheel i guess thats the problem with the code? Pressing the S key doesnt help at all because the wheel goes out of alignment as soon as you start the game even on the menu where you choose to skip flight training it doesn't work just starts acting really weird. It goes way out of alignment even when not moving it fast at all and just acts really bugged tbh it's unplayable. If you can try it with a 900 degree wheel give it a go and see what happens. I made a account on the bannisters forum you linked here but it seems like the admins not going to approve it and it was 23 hours ago i made the account and it says if it's not approved in 24 hours it gets deleted.

geecab:
Hm, I built the mame code straight from github with only those 2 changes I mentioned (No other hacks). Worked ok for me. Weird, I double check the code tonight.

As the physical controls we are testing with are different, I guess that's why we are seeing different results.

As we both have mouses though, perhaps see how it plays with your mouse ("mame hdrivair -mouse")? At least you should see what I tried to achieve :)

Yolo_Swaggins:
Can ports be wrapped for IPT_PADDLE? I think that could fix it for the steering wheel? I'll have another try today with it on different controllers and see what happens, i have a xbox one controller and a PS5 controller too.

Navigation

[0] Message Index

[*] Previous page

Go to full version