Issue with Toggle for Sprint/Walk in Police Simulator (PC)

67 views
Skip to first unread message

Frederik Girbrach

unread,
Nov 1, 2024, 11:37:22 AM11/1/24
to QuadStick
Hi guys! I'm new here, but I’ve already understood about 80% of the material. The "Quadstick FPS Game Controller" is connected to my "Windows laptop," and I've downloaded the game "Police Simulator: Patrol Officers" via "Steam."

Now, I want to get more familiar with the controller through the game, and I only want to program the "W key" to toggle for "walking" when I blow soft into all three openings on the mouthpiece simultaneously.

For "sprinting," I want the "W key" and "Shift key" to toggle when I blow strongly into all three openings on the mouthpiece simultaneously.

When I blow strongly into all three holes, the character starts sprinting as planned, and when I blow again, the character stops. However, when I then blow soft into all three holes to walk normally, the character starts sprinting again. It seems as if the "Shift key" only toggles every secong time I blow strongly into all three openings.

Am I overlooking something or have I configured something incorrectly? Here’s the link to my spreadsheet: https://docs.google.com/spreadsheets/d/1vlp9oi1CyO2mrm1rANbHWbOcPREKHIx9UjPMkBra4wc/edit?usp=drivesdk

P.S. At the bottom, I’ve set up two controller commands to try to disable the "Shift key" in a different way, but neither has any effect. Only when I blow strongly into all three openings does it toggle again.

Fred Davison

unread,
Nov 1, 2024, 7:40:22 PM11/1/24
to Frederik Girbrach, QuadStick
The shift and W latches are getting out of sync.

kb_w,          delayed_latch 250, mp_triple_puff
kb_left_shift, delayed_latch 250, mp_triple_puff

kb_w,          toggle,            mp_triple_puff_soft
kb_left_shift, force_off,         mp_triple_puff_soft

The first two rows will turn on W and shift immediately on a hard puff, and will hold them on if the puff is longer than 1/4 second.  If the puff is shorter, they will go off when the puff is released.
The second two rows with alternate turning the W on and will clear the left shift.

From a dead stop, either hard or soft puff will get you moving.   Once moving a short hard or soft will stop you.
To go from a walk to a run, a hard puff will keep the W on and turn on the shift, then latch them both on.
To go from a run to a walk, a short puff, either hard or soft, will cancel the run, then a soft puff will resume walking.
If you want to just cancel the shift key only, then pick another input and have it force_off the shift key but leave the W key alone.



Frederik Girbrach

unread,
Nov 2, 2024, 5:52:50 AM11/2/24
to QuadStick
Hi Fred! Thanks very much for your response.

Just to avoid any misunderstandings, I don’t want to start sprinting from a walking state but rather from a standstill. So here’s what I’m aiming for:

mp_triple_puff_soft,      start walking slowly from a standstill,
mp_triple_puff_soft,      stop walking and stay still,

mp_triple_puff,           start sprinting from a standstill,
mp_triple_puff,           stop sprinting and stay still,

So I could set up the controls as follows, right? (without delay_latch)

kb_w,          toggle,    mp_triple_puff_soft

kb_w,          toggle,    mp_triple_puff
kb_left_shift, toggle,    mp_triple_puff

If this is correct, then the following should happen in the game, right?

Execute a single "puff_soft": the "W key" is held down, and the character begins walking.
Execute another  "puff_soft": the "W key" is released, and the character stops again.

Execute a single "puff_hard": the "W key" and "Shift key" are held down, and the character starts sprinting.
Execute another  "puff_hard": the "W key" and "Shift key" are released, and the character stops again.

Frederik Girbrach

unread,
Nov 2, 2024, 1:00:47 PM11/2/24
to QuadStick
My goodness... I was starting to think I was losing it, but the problem is solved. It was actually with the game itself. Leaving the controller aside, in the game you only need to click the Shift key once to activate sprinting and don't have to hold it down continuously. The controller was doing exactly what it was supposed to do the whole time.

But now I have three new questions:
1. How can I set a key to be pressed twice in a row?
2. How can I set a key to be pressed "X times" in a row with an interval of "X-milliseconds"?
3. What are the other functions in the spreadsheet dropdown menu (repeat, tab, delay, and so on), and what values can be entered in which format? 

Is there any existing documentation where I can read about this?




Steven F

unread,
Nov 2, 2024, 3:39:20 PM11/2/24
to QuadStick

Fred Davison

unread,
Nov 2, 2024, 5:03:39 PM11/2/24
to Frederik Girbrach, QuadStick
There is a user manual on the documentation page of the website.


Pulse or repeat might be able to do what you want.

Referring back to your prior email.  I used delayed_latch instead of toggle to guarantee that the W key and the shift keys were synchronized.  Toggle always alternates and if the W and shift keys are 180 degrees out of phase, they will stay that way.  Delayed latch always starts out with a cleared latch.


Frederik Girbrach

unread,
Nov 10, 2024, 7:10:46 AM11/10/24
to QuadStick
Thank you, Steven F! That was really helpful and I was able to read up on it more.

Fred Davison: Yes, I was dealing with that issue all along. When I use the "delay_latch" function, the "Shift key" is "held" by the PC, but in the game, it just toggles instead. The "force_off" function doesn’t affect the "Shift key" in the game either; it stays activated and can only be deactivated/toggled by pressing it again.

... hence my confusion!

Currently, my programming looks like this:

kb_w,                toggle,      mp_triple_puff_soft,     start walking/stop walking

kb_w,                toggle,       mp_triple_puff,             start running/stop running
kb_left_shift,   normal,      mp_triple_puff

As long as I follow the input order correctly, everything works as intended. Only the cut scenes (where the character automatically stops) cause some desynchronization, but I think that’s unavoidable.

---------------------------------------------------------------------------- 

I’ve now programmed all the functions for "walking" to my liking, and now I want to focus on "driving." In the game, the W, A, S, and D keys are used for this. Is it even possible to map this to the joystick so I can use it for minimal and maximum steering movements, or would I need to play on a console for that?


Fred Davison

unread,
Nov 10, 2024, 10:56:52 AM11/10/24
to Frederik Girbrach, QuadStick
You could probably find a setting in the game to change the shift key behavior, if you felt like it.

For steering with WASD; keys are 100% on or off, nothing in between.  We often use:

kb_wgreater_than 10up
kb_agreater_than 10left
kb_sgreater_than 10down
kb_dgreater_than 10right

but that will not work well for steering.

There is a "duty_cycle" function that will turn a key on and off rapidly, with the percentage of "on" time being proportional to the joystick (or sip/puff pressure) position.

kb_wduty 60up
kb_aduty 60left
kb_sduty 60down
kb_dduty 60right

It produces a wobbly result, but it is better than trying to modulate the steering with rapid head or lip movements.

duty

 As the input value goes from 0 to 100%, scale the duration of the on-time of the output.  The default minimum on/off time is 100ms.  An optional parameter, in milliseconds, can be added to adjust the minimum on/off time.

Example game:  Half Life

If the game will use a game controller, and driving is a big part of it, switching over to using a game controller will probably work better.




Frederik Girbrach

unread,
Nov 13, 2024, 5:32:48 AM11/13/24
to QuadStick
Thank you, Fred! Your answers have been very helpful so far. Your well-formulated answers really help make it easy to understand quickly.

I've tried both options, but unfortunately, they don't perform very well in the game. Instead, I’m now using the Quadstick in Xbox 360 controller emulation mode, which is working better, but I have two issues:

Problem 1: I’m currently using the Quadstick joystick’s up/down movements for acceleration (right_trigger) and braking (left_trigger). However, even though I’ve set a deadzone for the joystick in QMP, the "drive" sheet still detects even the smallest up and down movements of the joystick.

Do I need to use the "greater_than" function for this?

Problem 2: I’d like the upward movement of the joystick in the same sheet to deliver 100% output at only 50% upward movement.

Can I add the "deflection_multiplier_up" function in the last row of the sheet so that only the "drive" mode is affected as desired, and if so, in which column should I enter the corresponding value?

Spreadsheet link: 
Reply all
Reply to author
Forward
0 new messages