I have to agree that not having “raw” input states is very limiting. A simple fix for Windows clients is GetAsyncKeyState (or just tapping into the game’s actual input system, which is the better alternative, since GAKS isn’t exactly “fast”, especially when you can use DirectInput or similar methods). Unfortunately, since the FiveM client locks down all PInvoke calls (which sucks, but it is what it is), we can’t do this ourselves.
Using the game’s mapped keys is all well and good, until a server owner sets things up for a specific key layout, only to find that some Joe Schmoe decided to remap “move forward” to mouse scroll down, or some other crazy combination.
Also, we flat out don’t have the ability to map to certain keys by default; I, O, P, F11, F12, NumPad0/1/2/3/7/9/+/-/. etc
The following is my enum for making my life easier with at least the “default” key bindings, you’ll notice the large amount of missing keys (all of which may not actually map to what you expect them to)
// NOTE: These keybinds are for QWERTY keyboards.
// AZERTY keyboards will have them in the same place, but with different characters.
// We are only using binds that "exist" for both.
public enum ControlKey
{
PageUp = Control.ScriptedFlyZUp,
PageDown = Control.ScriptedFlyZDown,
// Home
// End
// Insert
Delete = Control.PhoneOption,
ArrowUp = Control.Phone,
ArrowDown = Control.PhoneDown,
ArrowLeft = Control.PhoneLeft,
ArrowRight = Control.PhoneRight,
MouseScrollUp = Control.SelectPrevWeapon,
MouseScrollDown = Control.SelectNextWeapon,
MouseLButton = Control.Attack,
MouseRButton = Control.Aim,
// MouseMButton
// MouseXButton1
// MouseXButton2
Escape = Control.ReplayToggleTimeline,
Grave = Control.EnterCheatCode,
Tab = Control.SelectWeapon,
CapsLock = Control.SpecialAbilityPC,
LeftShift = Control.Sprint,
LeftCtrl = Control.Duck,
LeftAlt = Control.CharacterWheel,
Enter = Control.SkipCutscene,
Backspace = Control.PhoneCancel,
Hyphen = Control.VehiclePrevRadioTrack,
Equals = Control.VehicleNextRadioTrack,
Comma = Control.VehiclePrevRadio,
Period = Control.VehicleNextRadio,
// OpenBracket
// CloseBracket
// Pipe/BackSlash
// SemiColon
// Apostrophe
// ForwardSlash
// RightShift
// RightAlt
// RightControl
Space = Control.Jump,
A = Control.MoveLeftOnly,
B = Control.SpecialAbilitySecondary,
C = Control.LookBehind,
D = Control.MoveRightOnly,
E = Control.Pickup,
F = Control.Enter,
G = Control.Detonate,
H = Control.VehicleHeadlight,
// I
K = Control.ReplayShowhotkey,
L = Control.CinematicSlowMo,
M = Control.InteractionMenu,
N = Control.PushToTalk,
// O
// P
Q = Control.Cover,
R = Control.Reload,
S = Control.MoveDownOnly,
T = Control.MpTextChatAll,
U = Control.ReplayScreenshot,
V = Control.NextCamera,
W = Control.MoveUpOnly,
X = Control.VehicleDuck,
Y = Control.MpTextChatTeam,
Z = Control.MultiplayerInfo,
N1 = Control.SelectWeaponUnarmed,
N2 = Control.SelectWeaponMelee,
N3 = Control.SelectWeaponShotgun,
N4 = Control.SelectWeaponHeavy,
N5 = Control.SelectWeaponSpecial,
N6 = Control.SelectWeaponHandgun,
N7 = Control.SelectWeaponSmg,
N8 = Control.SelectWeaponAutoRifle,
N9 = Control.SelectWeaponSniper,
// N0
// NumPad0
// NumPad1
// NumPad2
// NumPad3
NumPad4 = Control.VehicleFlyRollLeftOnly,
NumPad5 = Control.VehicleFlyPitchDownOnly,
// NumPad7
NumPad6 = Control.VehicleFlyRollRightOnly,
NumPad8 = Control.VehicleFlyPitchUpOnly,
// NumPad9
// NumPadPlus
// NumPadMinus
// NumPadMul
// NumPadDiv
// NumPadPeriod
F1 = Control.ReplayStartStopRecording,
F2 = Control.ReplayStartStopRecordingSecondary,
F3 = Control.SaveReplayClip,
F5 = Control.SelectCharacterMichael,
F6 = Control.SelectCharacterFranklin,
F7 = Control.SelectCharacterTrevor,
F8 = Control.SelectCharacterMultiplayer,
F9 = Control.DropWeapon,
F10 = Control.DropAmmo,
// F11
// F12
}