Esc/Pause after a certain time

Hi guys, I would like to create a plugin that puts the game on pause after a certain amount of time. In the UpdateScoring function I managed to get the current race time using the info.mCurrentET value; I then tried to emulate a Esc or P keyboard stroke using the keybd_event() function, but to no avail: the game never pauses nor shows the Esc menu.

Is it possible to send such input to the sim or does the game ignores these kind of emulated inputs? I also tried to send the mCurrentEt to a server I wrote: it basically received the value and emulated the keystroke, but also in this case I don't get any result. Do you have any idea?

'Pause' is one of the recognised HW controls, and since it's not a 'driving control' you should probably be able to use it.

Return true from HasHardwareInputs(), then in CheckHWControl() test for "Pause" (and/or "AlternateEsc" if you want that), and if that test passes then set fRetVal to 1.0 and return true. (note fRetVal is a double; I think the template may have that correct now, but it's had a couple of leftover floats in the past so I'd check it)

Worth a shot

*Here's a list of HW controls I generated back in build 930, if anyone's interested (remember any driving controls can only be read):

Did you check that your test is being run and is being found true? Just asking because I chased my tail for hours once before working out the function still had a float as input, so wasn't being called...

After doing further tests I managed to emulate an Esc keystroke, but I have some doubts on how CheckHWControl works. At first I thought that it would check if a button was pressed and, in that case, it would let you do some maths: let's say something like this.

By doing this, though, as soon as the race starts I see the Esc menu appear without having to physically press it on my keyboard. With the following code, instead, when sessionStop == true the Esc menu appears, otherwise it doesn't.

Every single graphics update, every single defined control is checked for. So CheckHWControl is called with controlName="Throttle", then again with controlName="Brake", ... all the way through every single control name. If the user has pressed any of those then rRetVal will show 1.0 (for digital) and presumably 0.0-1.0 for analog (not sure on that).

So if you just test for controlName == "AlternateEsc", you'll get true every single frame (and because your first example then sets fRetVal to 1.0 and returns true, your game registers the Esc).

To answer your question: both

(your second example, you don't really need to set fRetVal to 0.0 if you don't want to Esc; it'll only be 1.0 if the user has pressed AltEsc, and you probably don't want to cancel it. You also probably only need to return true when you set it to 1.0)