summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRay <[email protected]>2019-05-21 20:59:13 +0200
committerRay <[email protected]>2019-05-21 20:59:13 +0200
commitb1806f660070ec5b54fe20bd266f8b33b3c3bc13 (patch)
treeb6c9103a7e88f0850436059afb932eded4618376 /src
parent322cf34fe0666ee8ce6f4a8141be79272a86258c (diff)
downloadraylib-b1806f660070ec5b54fe20bd266f8b33b3c3bc13.tar.gz
raylib-b1806f660070ec5b54fe20bd266f8b33b3c3bc13.zip
Add config SUPPORT_SSH_KEYBOARD_RPI
Allow to reconfigure stdin to read input keys, this process could lead to undesired effects. Use with care. Disabled by default.
Diffstat (limited to 'src')
-rw-r--r--src/CMakeOptions.txt1
-rw-r--r--src/config.h2
-rw-r--r--src/core.c29
3 files changed, 24 insertions, 8 deletions
diff --git a/src/CMakeOptions.txt b/src/CMakeOptions.txt
index 5e1d9e47..49b83571 100644
--- a/src/CMakeOptions.txt
+++ b/src/CMakeOptions.txt
@@ -25,6 +25,7 @@ set(OFF ${INCLUDE_EVERYTHING} CACHE INTERNAL "Replace any OFF by default with \$
option(SUPPORT_CAMERA_SYSTEM "Provide camera module (camera.h) with multiple predefined cameras: free, 1st/3rd person, orbital" ON)
option(SUPPORT_GESTURES_SYSTEM "Gestures module is included (gestures.h) to support gestures detection: tap, hold, swipe, drag" ON)
option(SUPPORT_MOUSE_GESTURES "Mouse gestures are directly mapped like touches and processed by gestures system" ON)
+option(SUPPORT_SSH_KEYBOARD_RPI "Reconfigure standard input to receive key inputs, works with SSH connection" OFF)
option(SUPPORT_DEFAULT_FONT "Default font is loaded on window initialization to be available for the user to render simple text. If enabled, uses external module functions to load default raylib font (module: text)" ON)
option(SUPPORT_SCREEN_CAPTURE "Allow automatic screen capture of current screen pressing F12, defined in KeyCallback()" ON)
option(SUPPORT_GIF_RECORDING "Allow automatic gif recording of current screen pressing CTRL+F12, defined in KeyCallback()" ON)
diff --git a/src/config.h b/src/config.h
index ebe1a7da..dd365f1f 100644
--- a/src/config.h
+++ b/src/config.h
@@ -43,6 +43,8 @@
// Mouse gestures are directly mapped like touches and processed by gestures system
#define SUPPORT_MOUSE_GESTURES 1
// Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
+//#define SUPPORT_SSH_KEYBOARD_RPI 1
+//Reconfigure standard input to receive key inputs, works with SSH connection.
//#define SUPPORT_BUSY_WAIT_LOOP 1
// Wait for events passively (sleeping while no events) instead of polling them actively every frame
//#define SUPPORT_EVENTS_WAITING 1
diff --git a/src/core.c b/src/core.c
index 28283d88..d8d85144 100644
--- a/src/core.c
+++ b/src/core.c
@@ -50,6 +50,11 @@
* #define SUPPORT_TOUCH_AS_MOUSE
* Touch input and mouse input are shared. Mouse functions also return touch information.
*
+* #define SUPPORT_SSH_KEYBOARD_RPI (Raspberry Pi only)
+* Reconfigure standard input to receive key inputs, works with SSH connection.
+* WARNING: Reconfiguring standard input could lead to undesired effects, like breaking other running processes or
+* blocking the device is not restored properly. Use with care.
+*
* #define SUPPORT_BUSY_WAIT_LOOP
* Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used
*
@@ -489,16 +494,19 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
#endif
#if defined(PLATFORM_RPI)
+#if defined(SUPPORT_SSH_KEYBOARD_RPI)
+static void InitKeyboard(void); // Init raw keyboard system (standard input reading)
+static void ProcessKeyboard(void); // Process keyboard events
+static void RestoreKeyboard(void); // Restore keyboard system
+#endif
+
static void InitEvdevInput(void); // Evdev inputs initialization
static void EventThreadSpawn(char *device); // Identifies a input device and spawns a thread to handle it if needed
static void *EventThread(void *arg); // Input device events reading thread
-static void InitKeyboard(void); // Init raw keyboard system (standard input reading)
-static void ProcessKeyboard(void); // Process keyboard events
-static void RestoreKeyboard(void); // Restore keyboard system
static void InitGamepad(void); // Init raw gamepad input
static void *GamepadThread(void *arg); // Mouse reading thread
-#endif
+#endif // PLATFORM_RPI
#if defined(_WIN32)
// NOTE: We include Sleep() function signature here to avoid windows.h inclusion
@@ -610,8 +618,10 @@ void InitWindow(int width, int height, const char *title)
#if defined(PLATFORM_RPI)
// Init raw input system
InitEvdevInput(); // Evdev inputs initialization
- InitKeyboard(); // Keyboard init
InitGamepad(); // Gamepad init
+#if defined(SUPPORT_SSH_KEYBOARD_RPI)
+ InitKeyboard(); // Keyboard init
+#endif
#endif
#if defined(PLATFORM_WEB)
@@ -3544,7 +3554,7 @@ static void PollInputEvents(void)
}
#endif
-#if defined(PLATFORM_RPI)
+#if defined(PLATFORM_RPI) && defined(SUPPORT_SSH_KEYBOARD_RPI)
// NOTE: Keyboard reading could be done using input_event(s) reading or just read from stdin,
// we now use both methods inside here. 2nd method is still used for legacy purposes (Allows for input trough SSH console)
ProcessKeyboard();
@@ -4181,6 +4191,8 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
#endif
#if defined(PLATFORM_RPI)
+
+#if defined(SUPPORT_SSH_KEYBOARD_RPI)
// Initialize Keyboard system (using standard input)
static void InitKeyboard(void)
{
@@ -4341,6 +4353,7 @@ static void RestoreKeyboard(void)
// Reconfigure keyboard to default mode
ioctl(STDIN_FILENO, KDSKBMODE, defaultKeyboardMode);
}
+#endif //SUPPORT_SSH_KEYBOARD_RPI
// Initialise user input from evdev(/dev/input/event<N>) this means mouse, keyboard or gamepad devices
static void InitEvdevInput(void)
@@ -4739,7 +4752,7 @@ static void *EventThread(void *arg)
// Gesture update
if (gestureUpdate)
{
-#if defined(SUPPORT_GESTURES_SYSTEM)
+ #if defined(SUPPORT_GESTURES_SYSTEM)
GestureEvent gestureEvent = { 0 };
gestureEvent.pointCount = 0;
@@ -4761,7 +4774,7 @@ static void *EventThread(void *arg)
gestureEvent.position[3] = touchPosition[3];
ProcessGestureEvent(gestureEvent);
-#endif
+ #endif
}
}
else