für meinen FPC_DOOM port benötige ich natürlich auch eine Taste zum "schießen". Hierfür ist die Rechte CTRL Taste vorgesehen und schon geht das drama los.
Im OnKeyDown Event bekommt man immer nur VK_Control egal welche der beiden Tasten man drückt.
Dafür habe ich dann folgenden Workaround gebastelt:
Code: Alles auswählen
Procedure TForm1.OpenGLControl1KeyDown(Sender: TObject; Var Key: Word;
Shift: TShiftState);
Var
ev: event_t;
Begin
// See d_event.pas for descriptions
ev := GetTypedEmptyEvent(ev_keydown);
If key = VK_CONTROL Then Begin
If GetKeyState(VK_RCONTROL) <> 0 Then Begin
key := VK_RCONTROL;
End
Else Begin
key := VK_LCONTROL;
End;
End;
// Siehe i_input.c I_HandleKeyboardEvent
ev.data1 := Key; // doomkeys.h is made to be equal to lcl
ev.data2 := Key; // TODO: muss noch richtig gemacht werden ?
ev.data3 := Key; // TODO: muss noch richtig gemacht werden ?
D_PostEvent(ev);
End;
auf jeden Fall immer 0 -> damit kann ich im OnKeyUp nicht mehr herausfinden welche CTRL Taste nun gedrückt wurde. Habt ihr da ne Idee ? das ganze muss unter Windows und Linux auf jeden Fall funktionieren ..GetKeyState(VK_RCONTROL)
Laut LCLintf.pas
soll Application.ExtendedKeysSupport := true was bringen, hab bei mir aber leider nichts gebrachtCode: Alles auswählen
// VK_L & VK_R - left and right Alt, Ctrl and Shift virtual keys. // When Application.ExtendedKeysSupport is false, these keys are // used only as parameters to GetAsyncKeyState() and GetKeyState(). // No other API or message will distinguish left and right keys in this way // // When Application.ExtendedKeysSupport is true, these keys will be sent // on KeyDown / KeyUp instead of the generic VK_SHIFT, VK_CONTROL, etc. VK_LSHIFT = $A0; VK_RSHIFT = $A1; VK_LCONTROL = $A2; VK_RCONTROL = $A3;
