The online racing simulator
Sending single characters to LFS by InSim
I guess it was asked before, but I can't find anything...
I want to send the - key (blocking messages) to LFS by using

struct SingleCharPack // send to LFS to simulate single character
{
char Id [4]; // SCH + zero
char Char; // key to press
byte Flags; // bit 0 : SHIFT / bit 1 : CTRL
byte Spare2;
byte Spare3;
};

what i don't really understand is, what flag to use if i don't want to use SHIFT or CTRL? just 2 or so?

I also wonder why this works sometimes and sometimes not...
I want to send a - (block message) if the race starts, therefore i send this charater if i get the "IS_RST // Race STart" packet, but LFS does nothing...

and is it possible to determine the block state? (if messages are blocked or not)
For the flags, it refers to the actual bits (1 or 0) within the byte, not the decimal value. So:
0: no shift or ctrl pressed (in binary 00)
1: SHIFT (in binary 01)
2: CTRL (in binary 10)
3: SHIFT+CTRL (in binary 11)

And to determine the state, the only way I can see would be to send 2 such packets quickly, and parse the output. Not very elegant though .
thx...
but this sending doesn't work here...
(patch P8)
Try sending character 0x2D or 0x7E instead of "-". Maybe - is different on your keyboard settings ...
hmmm...
doesn't work

i tried this:
c:= Chr(45); //HEX = 2D

but it doesn't work. flag was 0!

i tried c:= 'R' and flag 1 and the restart vote has been done...
strange

EDIT:
strage that when i send L with flag 0 nothing happens, but the limiter should be switch on/off.
if i send L with flag 1 the the suspension is shown...

seems that i can't send only characters with flag 0....
btw: i get an error sound, when sending - to LFS...
seems really that i send the wrong character...
i used decimal 45 which is HEX 0x2D which should be - but the same problem
Maybe it got something to do with the recent language patches, what version are you using?
used P8 & P9
but its really strange:
sending L with Flag 0 doesn't work (Limiter on/off Key L), but sending L with Flag 1 works (Live-Suspension SHIFT+L).
so, I think sending single chars doesn't work correctly.....

SCAWEN????
no idea?
what are you thinking, SCAWEN, VICTOR, ERIC (well, i think eric doesn't have any thing to do with that )?
Try sending the character 0xbd instead of the '-' character. Because now, the in-game keys need a windows virtual key code, rather than an ascii character. The VK_xxx should match ASCII for A-Z and 0-9 and some others. But the - key varies between keyboards... so the virtual key code does not match the ascii character.

I don't think it's related to ctrl or shift. For example have you tried sending a 'T' keypress? It should open a text box (though i haven't tested this). I think the L key and other user-assignable keys don't work because they aren't processed in the same way. It's detecting if that key is held down, instead processing a keypress.
thx for answer...
sendig T works!
but how do i send a HEX as a CHAR?
don't really know how to do that in Delphi...sorry, noob
i only be able to send chars....how do i convert hex in a char?
sorry about this maybe stupid question, but i really don't know...

/edit, i tried to send chr(189), but it doesn't work...
in my codetable, 189 should be BD, hope i refere to the correct thing!
my codetable shows the decimal value of an char eg. 065 for A and the hex value 41 (for A)...
so, sending Chr(65) should be the same as sending hex 41...right? so hex 41 should be 0x41....right?

therefor sending 189 should be 0XBD ==> '-'


procedure SendChar;
var c: Char;
begin
c:= Chr(189);
SendMSTPacket(UDPClient, 'Sending char: '+ c+ #0); //shows message in LFS to see what char was recieved
SendSCHPacket(c, 0, UDPClient); //sends key press to LFS via InSim; c = char, 0 = flag
end;


function Chr(X: Byte): Char;

[b]Description[/b]
Chr returns the character with the ordinal value (ASCII value) of the byte-type expression, X.

OK... i don't know Delphi but i think your code is right.

I've just run a test and i've found out that because it was using a signed char, no key above 127 would work - it would just be an unknown key in LFS. So that's why 0xbd did not work. I've just fixed the LFS code so that the higher VK_xxx will work in future. Thanks for the bug find.
good to hear...
i thought it was me hehehehe...
thx scawen!

FGED GREDG RDFGDR GSFDG