Allow Disabling Raw Mouse Motion
This commit is contained in:
parent
1eb06b6b60
commit
0fd562af40
@ -29,3 +29,4 @@ TRUE External Server Support
|
||||
TRUE Load Language Files
|
||||
TRUE Implement Sound Engine
|
||||
TRUE Close Current Screen On Death
|
||||
FALSE Disable Raw Mouse Motion (Not Recommended)
|
||||
|
@ -27,7 +27,7 @@ void media_set_interactable(int toggle) {
|
||||
// GLFW Code Not Needed In Headless Mode
|
||||
#ifndef MCPI_HEADLESS_MODE
|
||||
|
||||
static GLFWwindow *glfw_window;
|
||||
static GLFWwindow *glfw_window = NULL;
|
||||
|
||||
// Handle GLFW Error
|
||||
static void glfw_error(__attribute__((unused)) int error, const char *description) {
|
||||
@ -227,6 +227,20 @@ static void glfw_scroll(__attribute__((unused)) GLFWwindow *window, __attribute_
|
||||
// Track Media Layer State
|
||||
static int is_running = 0;
|
||||
|
||||
// Track If Raw Mouse Motion Is Enabled
|
||||
static int raw_mouse_motion_enabled = 1;
|
||||
void media_set_raw_mouse_motion_enabled(int enabled) {
|
||||
raw_mouse_motion_enabled = enabled;
|
||||
#ifndef MCPI_HEADLESS_MODE
|
||||
if (is_running) {
|
||||
glfwSetInputMode(glfw_window, GLFW_RAW_MOUSE_MOTION, GLFW_FALSE);
|
||||
}
|
||||
#endif // #ifndef MCPI_HEADLESS_MODE
|
||||
if (!raw_mouse_motion_enabled) {
|
||||
WARN("%s", "Raw mouse motion has been DISABLED, this IS NOT recommended, and should only ever be used on systems that don't support or have broken raw mouse motion.");
|
||||
}
|
||||
}
|
||||
|
||||
// Disable V-Sync
|
||||
static int disable_vsync = 0;
|
||||
void media_disable_vsync() {
|
||||
@ -409,7 +423,7 @@ static void update_cursor() {
|
||||
glfwSetInputMode(glfw_window, GLFW_CURSOR, new_mode);
|
||||
|
||||
// Handle Cursor Lock/Unlock
|
||||
if ((new_mode == GLFW_CURSOR_DISABLED && old_mode != GLFW_CURSOR_DISABLED) || (new_mode != GLFW_CURSOR_DISABLED && old_mode == GLFW_CURSOR_DISABLED)) {
|
||||
if (raw_mouse_motion_enabled && ((new_mode == GLFW_CURSOR_DISABLED && old_mode != GLFW_CURSOR_DISABLED) || (new_mode != GLFW_CURSOR_DISABLED && old_mode == GLFW_CURSOR_DISABLED))) {
|
||||
// Use Raw Mouse Motion
|
||||
glfwSetInputMode(glfw_window, GLFW_RAW_MOUSE_MOTION, new_mode == GLFW_CURSOR_DISABLED ? GLFW_TRUE : GLFW_FALSE);
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ void media_cleanup();
|
||||
void media_get_framebuffer_size(int *width, int *height);
|
||||
void media_set_interactable(int is_interactable);
|
||||
void media_disable_vsync();
|
||||
void media_set_raw_mouse_motion_enabled(int enabled);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -336,3 +336,20 @@ CALL(63, media_disable_vsync, void, ()) {
|
||||
media_disable_vsync();
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL(64, media_set_raw_mouse_motion_enabled, void, (int enabled)) {
|
||||
#if defined(MEDIA_LAYER_PROXY_SERVER)
|
||||
// Lock Proxy
|
||||
start_proxy_call();
|
||||
|
||||
// Arguments
|
||||
write_int(enabled);
|
||||
|
||||
// Release Proxy
|
||||
end_proxy_call();
|
||||
#else
|
||||
int enabled = read_int();
|
||||
// Run
|
||||
media_set_raw_mouse_motion_enabled(enabled);
|
||||
#endif
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ if(BUILD_ARM_COMPONENTS)
|
||||
|
||||
# MCPI Depends On GLESv2, But Uses GLESv1_CM
|
||||
install_symlink("libGLESv1_CM.so.1" "${MCPI_LIB_DIR}/libGLESv2.so")
|
||||
# Prevent MCPI From Linking To The Legacy GL Driver When Directly Linking To GL
|
||||
# Prevent MCPI From Linking To The Legacy GL Driver When Directly Linking To GL (RPI-Specific)
|
||||
if(NOT MCPI_HEADLESS_MODE AND NOT MCPI_USE_MEDIA_LAYER_PROXY)
|
||||
# Symlinks
|
||||
install_symlink("/usr/lib/arm-linux-gnueabihf/libEGL.so.1" "${MCPI_LIB_DIR}/libEGL.so")
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <libreborn/libreborn.h>
|
||||
#include <symbols/minecraft.h>
|
||||
#include <media-layer/core.h>
|
||||
|
||||
#include "../feature/feature.h"
|
||||
#include "../init/init.h"
|
||||
@ -46,4 +47,9 @@ void init_input() {
|
||||
|
||||
// Allow Attacking Mobs
|
||||
_init_attack();
|
||||
|
||||
// Disable Raw Mouse Motion
|
||||
if (feature_has("Disable Raw Mouse Motion (Not Recommended)", 9)) {
|
||||
media_set_raw_mouse_motion_enabled(0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user