nexus\api/
gamebind.rs

1//! Game keybinds.
2
3use crate::{AddonApi, GameBindApi};
4
5/// Game keybinds.
6#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8#[cfg_attr(
9    feature = "strum",
10    derive(
11        strum::AsRefStr,
12        strum::Display,
13        strum::EnumCount,
14        strum::EnumIter,
15        strum::IntoStaticStr,
16        strum::VariantArray,
17        strum::VariantNames
18    )
19)]
20#[repr(C)]
21pub enum GameBind {
22    // Movement
23    MoveForward = 0,
24    MoveBackward = 1,
25    MoveLeft = 2,
26    MoveRight = 3,
27    MoveTurnLeft = 4,
28    MoveTurnRight = 5,
29    MoveDodge = 6,
30    MoveAutoRun = 7,
31    MoveWalk = 8,
32    MoveJump = 9,
33    MoveSwimUp = 10,
34    MoveSwimDown = 11,
35    MoveAboutFace = 12,
36
37    // Skills
38    SkillWeaponSwap = 17,
39    SkillWeapon1 = 18,
40    SkillWeapon2 = 19,
41    SkillWeapon3 = 20,
42    SkillWeapon4 = 21,
43    SkillWeapon5 = 22,
44    SkillHeal = 23,
45    SkillUtility1 = 24,
46    SkillUtility2 = 25,
47    SkillUtility3 = 26,
48    SkillElite = 27,
49    SkillProfession1 = 28,
50    SkillProfession2 = 29,
51    SkillProfession3 = 30,
52    SkillProfession4 = 31,
53    SkillProfession5 = 79,
54    SkillProfession6 = 201,
55    SkillProfession7 = 202,
56    SkillSpecialAction = 82,
57
58    // Targeting
59    TargetAlert = 131,
60    TargetCall = 32,
61    TargetTake = 33,
62    TargetCallLocal = 199,
63    TargetTakeLocal = 200,
64    TargetEnemyNearest = 34,
65    TargetEnemyNext = 35,
66    TargetEnemyPrev = 36,
67    TargetAllyNearest = 37,
68    TargetAllyNext = 38,
69    TargetAllyPrev = 39,
70    TargetLock = 40,
71    TargetSnapGroundTarget = 80,
72    TargetSnapGroundTargetToggle = 115,
73    TargetAutoTargetingDisable = 116,
74    TargetAutoTargetingToggle = 117,
75    TargetAllyTargetingMode = 197,
76    TargetAllyTargetingModeToggle = 198,
77
78    // UI Binds
79    UiTradingPost = 41,
80    UiContacts = 42,
81    UiGuild = 43,
82    UiHero = 44,
83    UiInventory = 45,
84    UiPets = 46,
85    UiLogout = 47,
86    UiMail = 71,
87    UiOptions = 48,
88    UiParty = 49,
89    UiPvp = 73,
90    UiPvpBuild = 75,
91    UiScoreboard = 50,
92    UiWizardsVault = 209,
93    UiInformation = 51,
94    UiChatToggle = 70,
95    UiChatCommand = 52,
96    UiChatFocus = 53,
97    UiChatReply = 54,
98    UiToggle = 55,
99    UiSquadBroadcastChatToggle = 85,
100    UiSquadBroadcastChatCommand = 83,
101    UiSquadBroadcastChatFocus = 84,
102
103    // Camera
104    CameraFree = 13,
105    CameraZoomIn = 14,
106    CameraZoomOut = 15,
107    CameraReverse = 16,
108    CameraActionMode = 78,
109    CameraActionModeDisable = 114,
110
111    // Screenshots
112    ScreenshotNormal = 56,
113    ScreenshotStereoscopic = 57,
114
115    // Map
116    MapToggle = 59,
117    MapFocusPlayer = 60,
118    MapFloorDown = 61,
119    MapFloorUp = 62,
120    MapZoomIn = 63,
121    MapZoomOut = 64,
122
123    // Mounts
124    MountToggle = 152,
125    MountMovement = 130,
126    MountSecondaryMovement = 153,
127    MountRaptor = 155,
128    MountSpringer = 156,
129    MountSkimmer = 157,
130    MountJackal = 158,
131    MountGriffon = 159,
132    MountRollerBeetle = 161,
133    MountWarclaw = 169,
134    MountSkyscale = 170,
135    MountSiegeTurtle = 203,
136
137    // Spectator Binds
138    SpectatorNearestFixed = 102,
139    SpectatorNearestPlayer = 103,
140    SpectatorPlayerRed1 = 104,
141    SpectatorPlayerRed2 = 105,
142    SpectatorPlayerRed3 = 106,
143    SpectatorPlayerRed4 = 107,
144    SpectatorPlayerRed5 = 108,
145    SpectatorPlayerBlue1 = 109,
146    SpectatorPlayerBlue2 = 110,
147    SpectatorPlayerBlue3 = 111,
148    SpectatorPlayerBlue4 = 112,
149    SpectatorPlayerBlue5 = 113,
150    SpectatorFreeCamera = 120,
151    SpectatorFreeCameraMode = 127,
152    SpectatorFreeMoveForward = 121,
153    SpectatorFreeMoveBackward = 122,
154    SpectatorFreeMoveLeft = 123,
155    SpectatorFreeMoveRight = 124,
156    SpectatorFreeMoveUp = 125,
157    SpectatorFreeMoveDown = 126,
158
159    // Squad Markers
160    SquadMarkerPlaceWorldArrow = 86,
161    SquadMarkerPlaceWorldCircle = 87,
162    SquadMarkerPlaceWorldHeart = 88,
163    SquadMarkerPlaceWorldSquare = 89,
164    SquadMarkerPlaceWorldStar = 90,
165    SquadMarkerPlaceWorldSwirl = 91,
166    SquadMarkerPlaceWorldTriangle = 92,
167    SquadMarkerPlaceWorldCross = 93,
168    SquadMarkerClearAllWorld = 119,
169    SquadMarkerSetAgentArrow = 94,
170    SquadMarkerSetAgentCircle = 95,
171    SquadMarkerSetAgentHeart = 96,
172    SquadMarkerSetAgentSquare = 97,
173    SquadMarkerSetAgentStar = 98,
174    SquadMarkerSetAgentSwirl = 99,
175    SquadMarkerSetAgentTriangle = 100,
176    SquadMarkerSetAgentCross = 101,
177    SquadMarkerClearAllAgent = 118,
178
179    // Mastery Skills
180    MasteryAccess = 196,
181    MasteryAccessFishing = 204,
182    MasteryAccessSkiff = 205,
183    MasteryAccessJadeBotWaypoint = 206,
184    MasteryAccessRiftScan = 207,
185    MasteryAccessSkyscale = 208,
186
187    // Miscellaneous Binds
188    MiscAoELoot = 74,
189    MiscInteract = 65,
190    MiscShowEnemies = 66,
191    MiscShowAllies = 67,
192    MiscStowDrawWeapon = 68,
193    MiscToggleLanguage = 69,
194    MiscTogglePetCombat = 76,
195    MiscToggleFullScreen = 160,
196
197    // Toys/Novelties
198    ToyUseDefault = 162,
199    ToyUseSlotChair = 163,
200    ToyUseSlotInstrument = 164,
201    ToyUseSlotHeltItem = 165,
202    ToyUseSlotToy = 166,
203    ToyUseSlotTonic = 167,
204
205    // Build Templates
206    Loadout1 = 171,
207    Loadout2 = 172,
208    Loadout3 = 173,
209    Loadout4 = 174,
210    Loadout5 = 175,
211    Loadout6 = 176,
212    Loadout7 = 177,
213    Loadout8 = 178,
214
215    // Equipment Templates
216    GearLoadout1 = 182,
217    GearLoadout2 = 183,
218    GearLoadout3 = 184,
219    GearLoadout4 = 185,
220    GearLoadout5 = 186,
221    GearLoadout6 = 187,
222    GearLoadout7 = 188,
223    GearLoadout8 = 189,
224}
225
226pub type RawGamebindPressAsync = unsafe extern "C-unwind" fn(game_bind: GameBind);
227
228pub type RawGamebindReleaseAsync = unsafe extern "C-unwind" fn(game_bind: GameBind);
229
230pub type RawGamebindInvokeAsync = unsafe extern "C-unwind" fn(game_bind: GameBind, duration: i32);
231
232pub type RawGamebindPress = unsafe extern "C-unwind" fn(game_bind: GameBind);
233
234pub type RawGamebindRelease = unsafe extern "C-unwind" fn(game_bind: GameBind);
235
236pub type RawGamebindIsBound = unsafe extern "C-unwind" fn(game_bind: GameBind) -> bool;
237
238/// Presses the given [`GameBind`] asynchronously.
239#[inline]
240pub fn press_gamebind_async(bind: GameBind) {
241    let GameBindApi { press_async, .. } = AddonApi::get().game_bind;
242    unsafe { press_async(bind) }
243}
244
245/// Releases the given [`GameBind`] asynchronously.
246#[inline]
247pub fn release_gamebind_async(bind: GameBind) {
248    let GameBindApi { release_async, .. } = AddonApi::get().game_bind;
249    unsafe { release_async(bind) }
250}
251
252/// Presses the given [`GameBind`] asynchronously and release after the given duration.
253#[inline]
254pub fn invoke_gamebind_async(bind: GameBind, duration: i32) {
255    let GameBindApi { invoke_async, .. } = AddonApi::get().game_bind;
256    unsafe { invoke_async(bind, duration) }
257}
258
259/// Presses the given [`GameBind`].
260#[inline]
261pub fn press_gamebind(bind: GameBind) {
262    let GameBindApi { press, .. } = AddonApi::get().game_bind;
263    unsafe { press(bind) }
264}
265
266/// Releases the given [`GameBind`].
267#[inline]
268pub fn release_gamebind(bind: GameBind) {
269    let GameBindApi { release, .. } = AddonApi::get().game_bind;
270    unsafe { release(bind) }
271}
272
273/// Checks if the given [`GameBind`] is bound.
274#[inline]
275pub fn is_gamebind_bound(bind: GameBind) -> bool {
276    let GameBindApi { is_bound, .. } = AddonApi::get().game_bind;
277    unsafe { is_bound(bind) }
278}