change defines to IPT(input) instead of KEY

This commit is contained in:
flafmg 2025-07-24 21:13:52 -03:00
parent 3c729c656b
commit 164a6552bf
3 changed files with 63 additions and 63 deletions

View File

@ -853,29 +853,29 @@ static void LocalPlayer_DoRespawn(struct LocalPlayer* p) {
p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide); p->Base.OnGround = Entity_TouchesAny(&bb, LocalPlayer_IsSolidCollide);
} }
static cc_key_flags LocalPlayer_HandleRespawn(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_HandleRespawn(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex]; struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
if (p->Hacks.CanRespawn) { if (p->Hacks.CanRespawn) {
LocalPlayer_DoRespawn(p); LocalPlayer_DoRespawn(p);
return KEY_HANDLED; return IPT_HANDLED;
} else if (!p->_warnedRespawn) { } else if (!p->_warnedRespawn) {
p->_warnedRespawn = true; p->_warnedRespawn = true;
if (hackPermMsgs) Chat_AddRaw("&cRespawning is currently disabled"); if (hackPermMsgs) Chat_AddRaw("&cRespawning is currently disabled");
} }
return KEY_NONE; return IPT_NONE;
} }
static cc_key_flags LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_HandleSetSpawn(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex]; struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
if (p->Hacks.CanRespawn) { if (p->Hacks.CanRespawn) {
if (!p->Hacks.CanNoclip && !p->Base.OnGround) { if (!p->Hacks.CanNoclip && !p->Base.OnGround) {
Chat_AddRaw("&cCannot set spawn midair when noclip is disabled"); Chat_AddRaw("&cCannot set spawn midair when noclip is disabled");
return KEY_NONE; return IPT_NONE;
} }
/* Spawn is normally centered to match vanilla Minecraft classic */ /* Spawn is normally centered to match vanilla Minecraft classic */
@ -897,44 +897,44 @@ static cc_key_flags LocalPlayer_HandleSetSpawn(int key, struct InputDevice* devi
return LocalPlayer_HandleRespawn(key, device); return LocalPlayer_HandleRespawn(key, device);
} }
static cc_key_flags LocalPlayer_HandleFly(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_HandleFly(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex]; struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
if (p->Hacks.CanFly && p->Hacks.Enabled) { if (p->Hacks.CanFly && p->Hacks.Enabled) {
HacksComp_SetFlying(&p->Hacks, !p->Hacks.Flying); HacksComp_SetFlying(&p->Hacks, !p->Hacks.Flying);
return KEY_HANDLED; return IPT_HANDLED;
} else if (!p->_warnedFly) { } else if (!p->_warnedFly) {
p->_warnedFly = true; p->_warnedFly = true;
if (hackPermMsgs) Chat_AddRaw("&cFlying is currently disabled"); if (hackPermMsgs) Chat_AddRaw("&cFlying is currently disabled");
} }
return KEY_NONE; return IPT_NONE;
} }
static cc_key_flags LocalPlayer_HandleNoclip(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_HandleNoclip(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex]; struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
p->Hacks._noclipping = true; p->Hacks._noclipping = true;
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
if (p->Hacks.CanNoclip && p->Hacks.Enabled) { if (p->Hacks.CanNoclip && p->Hacks.Enabled) {
if (p->Hacks.WOMStyleHacks) return KEY_HANDLED; /* don't handle this here */ if (p->Hacks.WOMStyleHacks) return IPT_HANDLED; /* don't handle this here */
if (p->Hacks.Noclip) p->Base.Velocity.y = 0; if (p->Hacks.Noclip) p->Base.Velocity.y = 0;
HacksComp_SetNoclip(&p->Hacks, !p->Hacks.Noclip); HacksComp_SetNoclip(&p->Hacks, !p->Hacks.Noclip);
return KEY_HANDLED; return IPT_HANDLED;
} else if (!p->_warnedNoclip) { } else if (!p->_warnedNoclip) {
p->_warnedNoclip = true; p->_warnedNoclip = true;
if (hackPermMsgs) Chat_AddRaw("&cNoclip is currently disabled"); if (hackPermMsgs) Chat_AddRaw("&cNoclip is currently disabled");
} }
return KEY_NONE; return IPT_NONE;
} }
static cc_key_flags LocalPlayer_HandleJump(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_HandleJump(int key, struct InputDevice* device) {
struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex]; struct LocalPlayer* p = &LocalPlayer_Instances[device->mappedIndex];
struct HacksComp* hacks = &p->Hacks; struct HacksComp* hacks = &p->Hacks;
struct PhysicsComp* physics = &p->Physics; struct PhysicsComp* physics = &p->Physics;
int maxJumps; int maxJumps;
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
physics->Jumping = true; physics->Jumping = true;
if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) { if (!p->Base.OnGround && !(hacks->Flying || hacks->Noclip)) {
@ -945,28 +945,28 @@ static cc_key_flags LocalPlayer_HandleJump(int key, struct InputDevice* device)
PhysicsComp_DoNormalJump(physics); PhysicsComp_DoNormalJump(physics);
physics->MultiJumps++; physics->MultiJumps++;
} }
return KEY_HANDLED; return IPT_HANDLED;
} }
return KEY_NONE; return IPT_NONE;
} }
static cc_key_flags LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_TriggerHalfSpeed(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks; struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
cc_bool touch = device->type == INPUT_DEVICE_TOUCH; cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled; hacks->HalfSpeeding = (!touch || !hacks->HalfSpeeding) && hacks->Enabled;
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags LocalPlayer_TriggerSpeed(int key, struct InputDevice* device) { static cc_ipt_flags LocalPlayer_TriggerSpeed(int key, struct InputDevice* device) {
struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks; struct HacksComp* hacks = &LocalPlayer_Instances[device->mappedIndex].Hacks;
cc_bool touch = device->type == INPUT_DEVICE_TOUCH; cc_bool touch = device->type == INPUT_DEVICE_TOUCH;
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled; hacks->Speeding = (!touch || !hacks->Speeding) && hacks->Enabled;
return KEY_HANDLED; return IPT_HANDLED;
} }
static void LocalPlayer_ReleaseHalfSpeed(int key, struct InputDevice* device) { static void LocalPlayer_ReleaseHalfSpeed(int key, struct InputDevice* device) {

View File

@ -632,69 +632,69 @@ static void BindReleased_PickBlock(int key, struct InputDevice* device) {
} }
static cc_key_flags BindTriggered_HideFPS(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_HideFPS(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
Gui.ShowFPS = !Gui.ShowFPS; Gui.ShowFPS = !Gui.ShowFPS;
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_Fullscreen(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_Fullscreen(int key, struct InputDevice* device) {
Game_ToggleFullscreen(); Game_ToggleFullscreen();
return KEY_HANDLED | KEY_SUPPRESS_UI; return IPT_HANDLED | IPT_SUPPRESS_UI;
} }
static cc_key_flags BindTriggered_Fog(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_Fog(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
Game_CycleViewDistance(); Game_CycleViewDistance();
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_HideGUI(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_HideGUI(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
Game_HideGui = !Game_HideGui; Game_HideGui = !Game_HideGui;
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_SmoothCamera(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_SmoothCamera(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
InputHandler_Toggle(key, &Camera.Smooth, InputHandler_Toggle(key, &Camera.Smooth,
" &eSmooth camera is &aenabled", " &eSmooth camera is &aenabled",
" &eSmooth camera is &cdisabled"); " &eSmooth camera is &cdisabled");
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_AxisLines(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_AxisLines(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
InputHandler_Toggle(key, &AxisLinesRenderer_Enabled, InputHandler_Toggle(key, &AxisLinesRenderer_Enabled,
" &eAxis lines (&4X&e, &2Y&e, &1Z&e) now show", " &eAxis lines (&4X&e, &2Y&e, &1Z&e) now show",
" &eAxis lines no longer show"); " &eAxis lines no longer show");
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_AutoRotate(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_AutoRotate(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
InputHandler_Toggle(key, &AutoRotate_Enabled, InputHandler_Toggle(key, &AutoRotate_Enabled,
" &eAuto rotate is &aenabled", " &eAuto rotate is &aenabled",
" &eAuto rotate is &cdisabled"); " &eAuto rotate is &cdisabled");
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_ThirdPerson(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_ThirdPerson(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
Camera_CycleActive(); Camera_CycleActive();
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_DropBlock(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_DropBlock(int key, struct InputDevice* device) {
if (Gui.InputGrab) return KEY_NONE; if (Gui.InputGrab) return IPT_NONE;
if (Inventory_CheckChangeSelected() && Inventory_SelectedBlock != BLOCK_AIR) { if (Inventory_CheckChangeSelected() && Inventory_SelectedBlock != BLOCK_AIR) {
/* Don't assign SelectedIndex directly, because we don't want held block /* Don't assign SelectedIndex directly, because we don't want held block
@ -702,17 +702,17 @@ static cc_key_flags BindTriggered_DropBlock(int key, struct InputDevice* device)
Inventory_Set(Inventory.SelectedIndex, BLOCK_AIR); Inventory_Set(Inventory.SelectedIndex, BLOCK_AIR);
Event_RaiseVoid(&UserEvents.HeldBlockChanged); Event_RaiseVoid(&UserEvents.HeldBlockChanged);
} }
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_key_flags BindTriggered_IDOverlay(int key, struct InputDevice* device) { static cc_ipt_flags BindTriggered_IDOverlay(int key, struct InputDevice* device) {
struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS); struct Screen* s = Gui_GetScreen(GUI_PRIORITY_TEXIDS);
if (s) { if (s) {
Gui_Remove(s); Gui_Remove(s);
} else { } else {
TexIdsOverlay_Show(); TexIdsOverlay_Show();
} }
return KEY_HANDLED; return IPT_HANDLED;
} }
static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) { static cc_bool BindTriggered_BreakLiquids(int key, struct InputDevice* device) {
@ -834,7 +834,7 @@ static void OnPointerUp(void* obj, int idx) {
static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) { static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) {
struct Screen* s; struct Screen* s;
cc_key_flags triggered_flags; cc_ipt_flags triggered_flags;
int i; int i;
if (Input.DownHook && Input.DownHook(key, device)) return; if (Input.DownHook && Input.DownHook(key, device)) return;
@ -852,7 +852,7 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
Game_ScreenshotRequested = true; return; Game_ScreenshotRequested = true; return;
} }
triggered_flags = KEY_NONE; triggered_flags = IPT_NONE;
for (i = 0; !was && i < BIND_COUNT; i++) for (i = 0; !was && i < BIND_COUNT; i++)
{ {
if (!InputBind_Claims(i, key, device)) continue; if (!InputBind_Claims(i, key, device)) continue;
@ -861,7 +861,7 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
if (!Bind_OnTriggered[i]) continue; if (!Bind_OnTriggered[i]) continue;
triggered_flags |= Bind_OnTriggered[i](key, device); triggered_flags |= Bind_OnTriggered[i](key, device);
} }
if (!(triggered_flags & KEY_SUPPRESS_UI)) { //if key is supressing gui's key handling skip it if (!(triggered_flags & IPT_SUPPRESS_UI)) { //if key is supressing gui's key handling skip it
for (i = 0; i < Gui.ScreensCount; i++) for (i = 0; i < Gui.ScreensCount; i++)
{ {
s = Gui_Screens[i]; s = Gui_Screens[i];
@ -886,7 +886,7 @@ static void OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* dev
/* Hotkeys should not be triggered multiple times when holding down */ /* Hotkeys should not be triggered multiple times when holding down */
if (was) return; if (was) return;
if (triggered_flags & KEY_HANDLED) { if (triggered_flags & IPT_HANDLED) {
} else if (key == CCKEY_F5 && Game_ClassicMode) { } else if (key == CCKEY_F5 && Game_ClassicMode) {
int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY; int weather = Env.Weather == WEATHER_SUNNY ? WEATHER_RAINY : WEATHER_SUNNY;
Env_SetWeather(weather); Env_SetWeather(weather);

View File

@ -53,12 +53,12 @@ cc_bool Input_HandleMouseWheel(float delta);
void InputHandler_Tick(float delta); void InputHandler_Tick(float delta);
void InputHandler_OnScreensChanged(void); void InputHandler_OnScreensChanged(void);
typedef cc_uint8 cc_key_flags; /*dont know if this is the best place to put this*/ typedef cc_uint8 cc_ipt_flags; /*dont know if this is the best place to put this*/
#define KEY_NONE 0x00 /* key havent been handled */ #define IPT_NONE 0x00 /* key havent been handled */
#define KEY_HANDLED 0x01 /* key has been handled */ #define IPT_HANDLED 0x01 /* key has been handled */
#define KEY_SUPPRESS_UI 0x02 /* key supresses GUI's key processing*/ #define IPT_SUPPRESS_UI 0x02 /* key supresses GUI's key processing*/
typedef cc_key_flags (*BindTriggered)(int key, struct InputDevice* device); /*changes this to use 'cc_key_flag' instead of bool*/ typedef cc_ipt_flags (*BindTriggered)(int key, struct InputDevice* device); /*changes this to use 'cc_key_flag' instead of bool*/
typedef void (*BindReleased)(int key, struct InputDevice* device); typedef void (*BindReleased)(int key, struct InputDevice* device);
/* Gets whether the given input binding is currently being triggered */ /* Gets whether the given input binding is currently being triggered */
CC_API cc_bool KeyBind_IsPressed(InputBind binding); CC_API cc_bool KeyBind_IsPressed(InputBind binding);