Allow Opening Crafting With Controller
This commit is contained in:
parent
5d65b4092f
commit
f3dc145d4a
@ -29,10 +29,11 @@
|
|||||||
| Action | Function |
|
| Action | Function |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| A | Jump |
|
| A | Jump |
|
||||||
| D-Pad Down | Drop Item |
|
|
||||||
| Y | Open Inventory |
|
| Y | Open Inventory |
|
||||||
| D-Pad Up | Change Perspective |
|
|
||||||
| B | Sneak[^1] |
|
| B | Sneak[^1] |
|
||||||
|
| X | Open Crafting |
|
||||||
|
| D-Pad Up | Change Perspective |
|
||||||
|
| D-Pad Down | Drop Item |
|
||||||
| D-Pad Right | Open Chat |
|
| D-Pad Right | Open Chat |
|
||||||
| Left/Right Bumper | Cycle Selected Item In Toolbar |
|
| Left/Right Bumper | Cycle Selected Item In Toolbar |
|
||||||
| Left Trigger | Attack/Destroy |
|
| Left Trigger | Attack/Destroy |
|
||||||
|
@ -60,6 +60,7 @@ static void character_event(char c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert GLFW Key To SDL Key
|
// Convert GLFW Key To SDL Key
|
||||||
|
#define IMAGINARY_GLFW_CRAFTING_KEY GLFW_KEY_LAST
|
||||||
static SDLKey glfw_key_to_sdl_key(int key) {
|
static SDLKey glfw_key_to_sdl_key(int key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
// Movement
|
// Movement
|
||||||
@ -136,6 +137,9 @@ static SDLKey glfw_key_to_sdl_key(int key) {
|
|||||||
// Chat
|
// Chat
|
||||||
case GLFW_KEY_T:
|
case GLFW_KEY_T:
|
||||||
return SDLK_t;
|
return SDLK_t;
|
||||||
|
// Crafting
|
||||||
|
case IMAGINARY_GLFW_CRAFTING_KEY:
|
||||||
|
return SDLK_WORLD_0;
|
||||||
// Unknown
|
// Unknown
|
||||||
default:
|
default:
|
||||||
return SDLK_UNKNOWN;
|
return SDLK_UNKNOWN;
|
||||||
@ -293,6 +297,9 @@ static SDLKey glfw_controller_button_to_key(int button) {
|
|||||||
case GLFW_GAMEPAD_BUTTON_START:
|
case GLFW_GAMEPAD_BUTTON_START:
|
||||||
case GLFW_GAMEPAD_BUTTON_BACK:
|
case GLFW_GAMEPAD_BUTTON_BACK:
|
||||||
return GLFW_KEY_ESCAPE;
|
return GLFW_KEY_ESCAPE;
|
||||||
|
// Crafting
|
||||||
|
case GLFW_GAMEPAD_BUTTON_X:
|
||||||
|
return IMAGINARY_GLFW_CRAFTING_KEY;
|
||||||
// Unknown
|
// Unknown
|
||||||
default:
|
default:
|
||||||
return GLFW_KEY_UNKNOWN;
|
return GLFW_KEY_UNKNOWN;
|
||||||
|
@ -38,7 +38,8 @@ typedef enum {
|
|||||||
SDLK_F11 = 292,
|
SDLK_F11 = 292,
|
||||||
SDLK_F12 = 293,
|
SDLK_F12 = 293,
|
||||||
SDLK_RSHIFT = 303,
|
SDLK_RSHIFT = 303,
|
||||||
SDLK_LSHIFT = 304
|
SDLK_LSHIFT = 304,
|
||||||
|
SDLK_WORLD_0 = 160 // Used For Controller Crafting Button
|
||||||
} SDLKey;
|
} SDLKey;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -62,7 +62,7 @@ else()
|
|||||||
target_link_libraries(camera screenshot)
|
target_link_libraries(camera screenshot)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(input SHARED src/input/input.cpp src/input/bow.c src/input/attack.c src/input/toggle.c src/input/misc.c src/input/drop.cpp)
|
add_library(input SHARED src/input/input.cpp src/input/bow.c src/input/attack.c src/input/toggle.c src/input/misc.c src/input/drop.cpp src/input/crafting.cpp)
|
||||||
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
||||||
|
|
||||||
add_library(sign SHARED src/sign/sign.cpp)
|
add_library(sign SHARED src/sign/sign.cpp)
|
||||||
|
@ -12,6 +12,7 @@ void input_hide_gui();
|
|||||||
void input_third_person();
|
void input_third_person();
|
||||||
int input_back();
|
int input_back();
|
||||||
void input_drop(int drop_slot);
|
void input_drop(int drop_slot);
|
||||||
|
void input_open_crafting();
|
||||||
|
|
||||||
void input_set_is_left_click(int val);
|
void input_set_is_left_click(int val);
|
||||||
|
|
||||||
|
@ -84,6 +84,10 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
|
|||||||
// Drop Item
|
// Drop Item
|
||||||
input_drop((event->key.keysym.mod & KMOD_CTRL) != 0);
|
input_drop((event->key.keysym.mod & KMOD_CTRL) != 0);
|
||||||
handled = 1;
|
handled = 1;
|
||||||
|
} else if (event->key.keysym.sym == SDLK_WORLD_0) {
|
||||||
|
// Crafting
|
||||||
|
input_open_crafting();
|
||||||
|
handled = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
30
mods/src/input/crafting.cpp
Normal file
30
mods/src/input/crafting.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#include <libreborn/libreborn.h>
|
||||||
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
|
#include "input-internal.h"
|
||||||
|
#include <mods/input/input.h>
|
||||||
|
#include <mods/creative/creative.h>
|
||||||
|
|
||||||
|
// Store Should Open Crafting Menu
|
||||||
|
static int should_open_crafting = 0;
|
||||||
|
void input_open_crafting() {
|
||||||
|
should_open_crafting = 1;
|
||||||
|
}
|
||||||
|
static void _handle_open_crafting(unsigned char *minecraft) {
|
||||||
|
if (should_open_crafting) {
|
||||||
|
should_open_crafting = 0;
|
||||||
|
|
||||||
|
// Set Screen
|
||||||
|
if (!creative_is_restricted() || !(*Minecraft_isCreativeMode)(minecraft)) {
|
||||||
|
unsigned char *screen = (unsigned char *) ::operator new(WORKBENCH_SCREEN_SIZE);
|
||||||
|
ALLOC_CHECK(screen);
|
||||||
|
screen = (*WorkbenchScreen)(screen, 0);
|
||||||
|
(*Minecraft_setScreen)(minecraft, screen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Init
|
||||||
|
void _init_crafting() {
|
||||||
|
input_run_on_tick(_handle_open_crafting);
|
||||||
|
}
|
@ -9,6 +9,7 @@ __attribute__((visibility("internal"))) void _init_bow();
|
|||||||
__attribute__((visibility("internal"))) void _init_misc();
|
__attribute__((visibility("internal"))) void _init_misc();
|
||||||
__attribute__((visibility("internal"))) void _init_toggle();
|
__attribute__((visibility("internal"))) void _init_toggle();
|
||||||
__attribute__((visibility("internal"))) void _init_drop();
|
__attribute__((visibility("internal"))) void _init_drop();
|
||||||
|
__attribute__((visibility("internal"))) void _init_crafting();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,9 @@ void init_input() {
|
|||||||
// Allow Attacking Mobs
|
// Allow Attacking Mobs
|
||||||
_init_attack();
|
_init_attack();
|
||||||
|
|
||||||
|
// Allow Opening Crafting With Controller
|
||||||
|
_init_crafting();
|
||||||
|
|
||||||
// Disable Raw Mouse Motion
|
// Disable Raw Mouse Motion
|
||||||
if (feature_has("Disable Raw Mouse Motion (Not Recommended)", server_disabled)) {
|
if (feature_has("Disable Raw Mouse Motion (Not Recommended)", server_disabled)) {
|
||||||
media_set_raw_mouse_motion_enabled(0);
|
media_set_raw_mouse_motion_enabled(0);
|
||||||
|
@ -854,6 +854,13 @@ static uint32_t HumanoidModel_is_sneaking_property_offset = 0x236; // bool
|
|||||||
|
|
||||||
static void *PlayerRenderer_render_vtable_addr = (void *) 0x107f08;
|
static void *PlayerRenderer_render_vtable_addr = (void *) 0x107f08;
|
||||||
|
|
||||||
|
// WorkbenchScreen
|
||||||
|
|
||||||
|
#define WORKBENCH_SCREEN_SIZE 0x180
|
||||||
|
|
||||||
|
typedef unsigned char *(*WorkbenchScreen_t)(unsigned char *screen, int32_t param_1);
|
||||||
|
static WorkbenchScreen_t WorkbenchScreen = (WorkbenchScreen_t) 0x301cc;
|
||||||
|
|
||||||
// Method That Require C++ Types
|
// Method That Require C++ Types
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user