mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-25 18:12:41 +01:00
Patch Notes: Blocks + Colored shulker boxes + Concrete powder + Concrete + Glazed terracotta Items + Shulker shell + Iron nugget UI Changes + Added Custom Controls to Keyboard & Mouse, as well as Controller + Added Custom SuperFlat + Added Edit Server Menu + Added Firework Crafting Feature Changes + Host Options + Added Pick Block + Added off-hand slot for maps and arrows. Bug Fixes & changes + TU47: Banner hitbox wrong (and inventory model fixed) + TU47/48: Ice not melting properly + TU48: Dead bushes not dropping sticks + TU48: Guardians and polar bears not dropping cooked fish when on fire + TU48: Bonus chest missing saplings and seeds + TU48: Frosted ice obtainable + TU48: Hoppers not collecting items + TU48: Wither skeletons spawning in 2-high gaps + TU48: End crystals exploding with “TNT Explodes” off + TU48: Tamed ocelots staying hostile + TU48: Signs not placing on tall grass + TU51: Skeleton hitbox wrong + TU53: Fall damage in shallow water + TU53: Squids not spawning in man-made pools + Elytra has been improved to be more accurate to the source material + Removed Spectral Arrow from crafting + Fixed several broken item descriptions + You can no longer cook Pufferfish or Clownfish + Fixed scaling issue with paperdoll and chat + Iron and gold armor can now be smelted into nuggets. + More items can now be used as fuel in a furnace. + Using a firework rocket while gliding with elytra will now give the player a boost. + Changed the color of dyes, wool, carpets, and banners. + Reordered all colored blocks and items in the Creative inventory. Banners now have the same order of colors as all other colored blocks and items. + Fishing rods can now hook on entities without causing knockback or pseudo-damage. + Fixed banner crafting + Fixed Map colors for certain blocks + Fixed Path block height + Fixed String block issues + Fixed Item frame culling. + Fixed Tutorial world NBT/Block State issues + Fixed World Slider + Fixed Enderman AI + Fixed Player animation bug + HUD Flash text changes + Generation accuracy changes + Many other small accuracy changes and fixes
218 lines
7.4 KiB
C++
218 lines
7.4 KiB
C++
#include "stdafx.h"
|
|
|
|
#ifdef _WINDOWS64
|
|
|
|
#include "ControllerBinds.h"
|
|
|
|
struct ControllerBindDef
|
|
{
|
|
unsigned char action;
|
|
const char* id;
|
|
const wchar_t* name;
|
|
const wchar_t* section;
|
|
};
|
|
|
|
static const ControllerBindDef s_controllerBinds[] =
|
|
{
|
|
{ MINECRAFT_ACTION_USE, "use", L"Use", L"Standard" },
|
|
{ MINECRAFT_ACTION_ACTION, "attack", L"Action", L"Standard" },
|
|
{ MINECRAFT_ACTION_JUMP, "jump", L"Jump", L"Standard" },
|
|
{ MINECRAFT_ACTION_DROP, "drop", L"Drop", L"Standard" },
|
|
{ MINECRAFT_ACTION_INVENTORY, "inventory", L"Inventory", L"Standard" },
|
|
{ MINECRAFT_ACTION_CRAFTING, "crafting", L"Crafting", L"Standard" },
|
|
{ MINECRAFT_ACTION_LEFT_SCROLL, "hotbar_left", L"Cycle Held Item Left", L"Standard" },
|
|
{ MINECRAFT_ACTION_RIGHT_SCROLL, "hotbar_right", L"Cycle Held Item Right", L"Standard" },
|
|
{ MINECRAFT_ACTION_SNEAK_TOGGLE, "sneak", L"Sneak/Dismount", L"Standard" },
|
|
{ MINECRAFT_ACTION_SPRINT, "sprint", L"Sprint", L"Standard" },
|
|
{ MINECRAFT_ACTION_PICK_BLOCK, "pick_block", L"Pick Block", L"Standard" },
|
|
{ MINECRAFT_ACTION_RENDER_THIRD_PERSON, "perspective", L"Change Camera Mode", L"Standard" },
|
|
{ MINECRAFT_ACTION_DPAD_LEFT, "fly_left", L"Fly Left", L"Creative" },
|
|
{ MINECRAFT_ACTION_DPAD_RIGHT, "fly_right", L"Fly Right", L"Creative" },
|
|
{ MINECRAFT_ACTION_DPAD_UP, "fly_up", L"Fly Up", L"Creative" },
|
|
{ MINECRAFT_ACTION_DPAD_DOWN, "fly_down", L"Fly Down", L"Creative" },
|
|
};
|
|
|
|
static const int s_controllerBindCount = static_cast<int>(sizeof(s_controllerBinds) / sizeof(s_controllerBinds[0]));
|
|
|
|
int ControllerBinds::GetBindCount()
|
|
{
|
|
return s_controllerBindCount;
|
|
}
|
|
|
|
unsigned char ControllerBinds::GetBindAction(int index)
|
|
{
|
|
return (index >= 0 && index < s_controllerBindCount) ? s_controllerBinds[index].action : 0;
|
|
}
|
|
|
|
const wchar_t* ControllerBinds::GetBindName(int index)
|
|
{
|
|
return (index >= 0 && index < s_controllerBindCount) ? s_controllerBinds[index].name : L"";
|
|
}
|
|
|
|
const wchar_t* ControllerBinds::GetBindSection(int index)
|
|
{
|
|
return (index >= 0 && index < s_controllerBindCount) ? s_controllerBinds[index].section : L"";
|
|
}
|
|
|
|
static void GetControllerBindsPath(char* out, size_t outLen)
|
|
{
|
|
char exePath[MAX_PATH] = {};
|
|
GetModuleFileNameA(nullptr, exePath, MAX_PATH);
|
|
char* lastSlash = strrchr(exePath, '\\');
|
|
if (lastSlash)
|
|
*(lastSlash + 1) = '\0';
|
|
_snprintf_s(out, outLen, _TRUNCATE, "%scontrollerbinds.txt", exePath);
|
|
}
|
|
|
|
void ControllerBinds::Init()
|
|
{
|
|
for (int action = 0; action < MINECRAFT_ACTION_MAX; ++action)
|
|
InputManager.SetGameJoypadMaps(CUSTOM_MAP, static_cast<unsigned char>(action), InputManager.GetGameJoypadMapsRaw(MAP_STYLE_0, static_cast<unsigned char>(action)));
|
|
|
|
char path[MAX_PATH] = {};
|
|
GetControllerBindsPath(path, sizeof(path));
|
|
FILE* f = nullptr;
|
|
if (fopen_s(&f, path, "r") != 0 || !f)
|
|
return;
|
|
char line[128];
|
|
while (fgets(line, sizeof(line), f))
|
|
{
|
|
char* eq = strchr(line, '=');
|
|
if (!eq)
|
|
continue;
|
|
*eq = '\0';
|
|
unsigned int button = static_cast<unsigned int>(strtoul(eq + 1, nullptr, 16)) & GetBindableButtonMask();
|
|
if (button == 0)
|
|
continue;
|
|
for (int i = 0; i < s_controllerBindCount; ++i)
|
|
{
|
|
if (strcmp(line, s_controllerBinds[i].id) == 0)
|
|
{
|
|
InputManager.SetGameJoypadMaps(CUSTOM_MAP, s_controllerBinds[i].action, button);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
fclose(f);
|
|
}
|
|
|
|
unsigned int ControllerBinds::Get(int index)
|
|
{
|
|
if (index < 0 || index >= s_controllerBindCount)
|
|
return 0;
|
|
return InputManager.GetGameJoypadMapsRaw(CUSTOM_MAP, s_controllerBinds[index].action);
|
|
}
|
|
|
|
unsigned int ControllerBinds::GetFromMap(int index, unsigned char map)
|
|
{
|
|
if (index < 0 || index >= s_controllerBindCount || map >= MAP_COUNT)
|
|
return 0;
|
|
return InputManager.GetGameJoypadMapsRaw(map, s_controllerBinds[index].action);
|
|
}
|
|
|
|
void ControllerBinds::CopyLayoutToCustom(unsigned char map)
|
|
{
|
|
if (map >= MAP_COUNT || map == CUSTOM_MAP)
|
|
return;
|
|
for (int i = 0; i < s_controllerBindCount; ++i)
|
|
InputManager.SetGameJoypadMaps(CUSTOM_MAP, s_controllerBinds[i].action, InputManager.GetGameJoypadMapsRaw(map, s_controllerBinds[i].action));
|
|
}
|
|
|
|
void ControllerBinds::Set(int index, unsigned int button)
|
|
{
|
|
if (index < 0 || index >= s_controllerBindCount)
|
|
return;
|
|
InputManager.SetGameJoypadMaps(CUSTOM_MAP, s_controllerBinds[index].action, button);
|
|
}
|
|
|
|
void ControllerBinds::ResetToDefaults()
|
|
{
|
|
for (int i = 0; i < s_controllerBindCount; ++i)
|
|
InputManager.SetGameJoypadMaps(CUSTOM_MAP, s_controllerBinds[i].action, InputManager.GetGameJoypadMapsRaw(MAP_STYLE_0, s_controllerBinds[i].action));
|
|
}
|
|
|
|
void ControllerBinds::Save()
|
|
{
|
|
char path[MAX_PATH] = {};
|
|
GetControllerBindsPath(path, sizeof(path));
|
|
FILE* f = nullptr;
|
|
if (fopen_s(&f, path, "w") != 0 || !f)
|
|
return;
|
|
for (int i = 0; i < s_controllerBindCount; ++i)
|
|
fprintf(f, "%s=%08X\n", s_controllerBinds[i].id, InputManager.GetGameJoypadMapsRaw(CUSTOM_MAP, s_controllerBinds[i].action));
|
|
fclose(f);
|
|
}
|
|
|
|
unsigned int ControllerBinds::GetBindableButtonMask()
|
|
{
|
|
return _360_JOY_BUTTON_A | _360_JOY_BUTTON_B | _360_JOY_BUTTON_X | _360_JOY_BUTTON_Y
|
|
| _360_JOY_BUTTON_START | _360_JOY_BUTTON_BACK | _360_JOY_BUTTON_RB | _360_JOY_BUTTON_LB
|
|
| _360_JOY_BUTTON_RTHUMB | _360_JOY_BUTTON_LTHUMB
|
|
| _360_JOY_BUTTON_DPAD_UP | _360_JOY_BUTTON_DPAD_DOWN | _360_JOY_BUTTON_DPAD_LEFT | _360_JOY_BUTTON_DPAD_RIGHT
|
|
| _360_JOY_BUTTON_RT | _360_JOY_BUTTON_LT;
|
|
}
|
|
|
|
struct ButtonNames
|
|
{
|
|
unsigned int button;
|
|
const wchar_t* xbox;
|
|
const wchar_t* playstation;
|
|
const wchar_t* wiiu;
|
|
const wchar_t* icon;
|
|
};
|
|
|
|
static const ButtonNames s_buttonNames[] =
|
|
{
|
|
{ _360_JOY_BUTTON_A, L"A", L"Cross", L"B", L"ButtonA" },
|
|
{ _360_JOY_BUTTON_B, L"B", L"Circle", L"A", L"ButtonB" },
|
|
{ _360_JOY_BUTTON_X, L"X", L"Square", L"Y", L"ButtonX" },
|
|
{ _360_JOY_BUTTON_Y, L"Y", L"Triangle", L"X", L"ButtonY" },
|
|
{ _360_JOY_BUTTON_START, L"Start", L"Start", L"+", L"ButtonStart" },
|
|
{ _360_JOY_BUTTON_BACK, L"Back", L"Select", L"-", L"ButtonBack" },
|
|
{ _360_JOY_BUTTON_RB, L"RB", L"R1", L"R", L"ButtonRightBumper" },
|
|
{ _360_JOY_BUTTON_LB, L"LB", L"L1", L"L", L"ButtonLeftBumper" },
|
|
{ _360_JOY_BUTTON_RT, L"RT", L"R2", L"ZR", L"ButtonRightTrigger" },
|
|
{ _360_JOY_BUTTON_LT, L"LT", L"L2", L"ZL", L"ButtonLeftTrigger" },
|
|
{ _360_JOY_BUTTON_RTHUMB, L"Right Stick Click", L"R3", L"Right Stick Click", L"ButtonRS" },
|
|
{ _360_JOY_BUTTON_LTHUMB, L"Left Stick Click", L"L3", L"Left Stick Click", L"ButtonLS" },
|
|
{ _360_JOY_BUTTON_DPAD_UP, L"D-Pad Up", L"D-Pad Up", L"D-Pad Up", L"ButtonDpadU" },
|
|
{ _360_JOY_BUTTON_DPAD_DOWN, L"D-Pad Down", L"D-Pad Down", L"D-Pad Down", L"ButtonDpadD" },
|
|
{ _360_JOY_BUTTON_DPAD_LEFT, L"D-Pad Left", L"D-Pad Left", L"D-Pad Left", L"ButtonDpadL" },
|
|
{ _360_JOY_BUTTON_DPAD_RIGHT, L"D-Pad Right", L"D-Pad Right", L"D-Pad Right", L"ButtonDpadR" },
|
|
};
|
|
|
|
const wchar_t* ControllerBinds::GetButtonIconName(unsigned int button)
|
|
{
|
|
for (int i = 0; i < static_cast<int>(sizeof(s_buttonNames) / sizeof(s_buttonNames[0])); ++i)
|
|
{
|
|
if (button == s_buttonNames[i].button)
|
|
return s_buttonNames[i].icon;
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void ControllerBinds::GetButtonName(unsigned int button, int controlType, wchar_t* out, int outLen)
|
|
{
|
|
if (!out || outLen <= 0)
|
|
return;
|
|
out[0] = L'\0';
|
|
for (int i = 0; i < static_cast<int>(sizeof(s_buttonNames) / sizeof(s_buttonNames[0])); ++i)
|
|
{
|
|
if (button & s_buttonNames[i].button)
|
|
{
|
|
const wchar_t* name = s_buttonNames[i].xbox;
|
|
if (controlType == 3 || controlType == 4)
|
|
name = s_buttonNames[i].playstation;
|
|
else if (controlType == 5)
|
|
name = s_buttonNames[i].wiiu;
|
|
if (out[0] != L'\0')
|
|
wcsncat_s(out, outLen, L" / ", _TRUNCATE);
|
|
wcsncat_s(out, outLen, name, _TRUNCATE);
|
|
}
|
|
}
|
|
if (out[0] == L'\0')
|
|
wcsncpy_s(out, outLen, L"None", _TRUNCATE);
|
|
}
|
|
|
|
#endif
|