Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cookbook
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
cookbook
Commits
e978c518
Verified
Commit
e978c518
authored
5 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Fix relative mode
parent
adc1d6c6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
recipes/sdl/redox.patch
+46
-50
46 additions, 50 deletions
recipes/sdl/redox.patch
with
46 additions
and
50 deletions
recipes/sdl/redox.patch
+
46
−
50
View file @
e978c518
...
...
@@ -379,8 +379,8 @@ diff -ruwN source/src/thread/pthread/SDL_systhread.c source-new/src/thread/pthre
/* Allow ourselves to be asynchronously cancelled */
diff -ruwN source/src/video/orbital/SDL_orbitalevents.c source-new/src/video/orbital/SDL_orbitalevents.c
--- source/src/video/orbital/SDL_orbitalevents.c 1969-12-31 17:00:00.000000000 -0700
+++ source-new/src/video/orbital/SDL_orbitalevents.c 2019-08-12 1
3
:3
5:31.236162876
-0600
@@ -0,0 +1,2
61
@@
+++ source-new/src/video/orbital/SDL_orbitalevents.c 2019-08-12 1
4
:3
4:59.125356217
-0600
@@ -0,0 +1,2
42
@@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
...
...
@@ -424,51 +424,31 @@ diff -ruwN source/src/video/orbital/SDL_orbitalevents.c source-new/src/video/orb
+static int last_x = 0;
+static int last_y = 0;
+
+/* Variable for mouse relative processing */
+static int mouse_relative = 0;
+
+/* Check to see if we need to enter or leave mouse relative mode */
+
+void ORBITAL_CheckMouseMode(_THIS)
+{
+ if (!this->hidden->window) {
+ return;
+ }
+
+ /* If the mouse is hidden and input is grabbed, we use relative mode */
+ if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
+ (this->input_grab != SDL_GRAB_OFF) ) {
+ if (!mouse_relative) {
+ orb_window_set_mouse_relative(this->hidden->window, true);
+ }
+ mouse_relative = 1;
+ } else {
+ if (mouse_relative) {
+ orb_window_set_mouse_relative(this->hidden->window, false);
+ bool mouse_relative =
+ !(SDL_cursorstate & CURSOR_VISIBLE) &&
+ (this->input_grab != SDL_GRAB_OFF);
+ printf("ORBITAL_CheckMouseMode = %d\n", mouse_relative);
+ if (mouse_relative != this->hidden->mouse_relative) {
+ this->hidden->mouse_relative = mouse_relative;
+ if (this->hidden->window) {
+ orb_window_set_mouse_relative(this->hidden->window, mouse_relative);
+ }
+ mouse_relative = 0;
+ }
+}
+
+/* Current grab mode */
+static SDL_GrabMode grab_mode = SDL_GRAB_OFF;
+
+SDL_GrabMode ORBITAL_GrabInput(_THIS, SDL_GrabMode mode) {
+ if (this->hidden->window) {
+ switch (mode) {
+ case SDL_GRAB_OFF:
+ orb_window_set_mouse_grab(this->hidden->window, false);
+ grab_mode = SDL_GRAB_OFF;
+ break;
+ case SDL_GRAB_ON:
+ orb_window_set_mouse_grab(this->hidden->window, true);
+ grab_mode = SDL_GRAB_ON;
+ break;
+ default:
+ break;
+ bool mouse_grab = mode != SDL_GRAB_OFF;
+ printf("ORBITAL_GrabInput(%d) = %d\n", mode, mouse_grab);
+ if (mouse_grab != this->hidden->mouse_grab) {
+ this->hidden->mouse_grab = mouse_grab;
+ if (this->hidden->window) {
+ orb_window_set_mouse_grab(this->hidden->window, mouse_grab);
+ }
+ }
+ return(
grab_
mode);
+ return
(mode);
+}
+
+void ORBITAL_PumpEvents(_THIS)
...
...
@@ -481,8 +461,9 @@ diff -ruwN source/src/video/orbital/SDL_orbitalevents.c source-new/src/video/orb
+
+ void* event_iter = orb_window_events(this->hidden->window);
+ OrbEventOption oeo = orb_events_next(event_iter);
+
+ while (oeo.tag != OrbEventOption_None) {
+ found_event = true;
+
+ switch (oeo.tag) {
+ case OrbEventOption_Key:
+ keysym.unicode = oeo.key.character;
...
...
@@ -493,7 +474,7 @@ diff -ruwN source/src/video/orbital/SDL_orbitalevents.c source-new/src/video/orb
+ SDL_PrivateKeyboard(oeo.key.pressed ? SDL_PRESSED : SDL_RELEASED, &keysym);
+ break;
+ case OrbEventOption_Mouse:
+ if (mouse_relative) {
+ if (
this->hidden->
mouse_relative) {
+ SDL_PrivateMouseMotion(0, 1, oeo.mouse.x - last_x, oeo.mouse.y - last_y);
+ } else {
+ SDL_PrivateMouseMotion(0, 0, oeo.mouse.x, oeo.mouse.y);
...
...
@@ -680,8 +661,8 @@ diff -ruwN source/src/video/orbital/SDL_orbitalevents_c.h source-new/src/video/o
+/* end of SDL_orbitalevents_c.h ... */
diff -ruwN source/src/video/orbital/SDL_orbitalmouse.c source-new/src/video/orbital/SDL_orbitalmouse.c
--- source/src/video/orbital/SDL_orbitalmouse.c 1969-12-31 17:00:00.000000000 -0700
+++ source-new/src/video/orbital/SDL_orbitalmouse.c 2019-08-12 1
3:31:25.606869756
-0600
@@ -0,0 +1,6
1
@@
+++ source-new/src/video/orbital/SDL_orbitalmouse.c 2019-08-12 1
4:04:19.079802985
-0600
@@ -0,0 +1,6
7
@@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
...
...
@@ -727,21 +708,27 @@ diff -ruwN source/src/video/orbital/SDL_orbitalmouse.c source-new/src/video/orbi
+ return NULL ;
+ }
+
+ printf("ORBITAL_CreateWMCursor = %p\n", cursor);
+
+ return cursor ;
+}
+
+void ORBITAL_FreeWMCursor (_THIS, WMcursor * cursor)
+{
+ printf("ORBITAL_FreeWMCursor(%p)\n", cursor);
+ SDL_free (cursor) ;
+}
+
+int ORBITAL_ShowWMCursor (_THIS, WMcursor * cursor)
+{
+ if (!this->hidden->window) {
+ return;
+ bool mouse_cursor = cursor != NULL;
+ printf("ORBITAL_ShowWMCursor(%p) = %d\n", cursor, mouse_cursor);
+ if (mouse_cursor != this->hidden->mouse_cursor) {
+ this->hidden->mouse_cursor = mouse_cursor;
+ if (this->hidden->window) {
+ orb_window_set_mouse_cursor(this->hidden->window, mouse_cursor);
+ }
+ }
+
+ orb_window_set_mouse_cursor(this->hidden->window, cursor != NULL);
+}
diff -ruwN source/src/video/orbital/SDL_orbitalmouse_c.h source-new/src/video/orbital/SDL_orbitalmouse_c.h
--- source/src/video/orbital/SDL_orbitalmouse_c.h 1969-12-31 17:00:00.000000000 -0700
...
...
@@ -777,8 +764,8 @@ diff -ruwN source/src/video/orbital/SDL_orbitalmouse_c.h source-new/src/video/or
+extern int ORBITAL_ShowWMCursor (_THIS, WMcursor * cursor) ;
diff -ruwN source/src/video/orbital/SDL_orbitalvideo.c source-new/src/video/orbital/SDL_orbitalvideo.c
--- source/src/video/orbital/SDL_orbitalvideo.c 1969-12-31 17:00:00.000000000 -0700
+++ source-new/src/video/orbital/SDL_orbitalvideo.c 2019-08-12 13:
3
2:4
8.391306374
-0600
@@ -0,0 +1,26
0
@@
+++ source-new/src/video/orbital/SDL_orbitalvideo.c 2019-08-12 13:
5
2:4
9.188487962
-0600
@@ -0,0 +1,26
5
@@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
...
...
@@ -963,6 +950,10 @@ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.c source-new/src/video/orbi
+ SDL_SetError("Couldn't create window for requested mode");
+ return(NULL);
+ }
+
+ orb_window_set_mouse_cursor(this->hidden->window, this->hidden->mouse_cursor);
+ orb_window_set_mouse_grab(this->hidden->window, this->hidden->mouse_grab);
+ orb_window_set_mouse_relative(this->hidden->window, this->hidden->mouse_relative);
+ }
+
+ fprintf(stderr, "Setting mode %dx%d@%d\n", width, height, bpp);
...
...
@@ -989,8 +980,9 @@ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.c source-new/src/video/orbi
+
+static void ORBITAL_SetCaption(_THIS, const char *title, const char *icon)
+{
+ if (this->hidden->window)
+ if (this->hidden->window)
{
+ orb_window_set_title(this->hidden->window, title);
+ }
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
...
...
@@ -1041,8 +1033,8 @@ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.c source-new/src/video/orbi
+}
diff -ruwN source/src/video/orbital/SDL_orbitalvideo.h source-new/src/video/orbital/SDL_orbitalvideo.h
--- source/src/video/orbital/SDL_orbitalvideo.h 1969-12-31 17:00:00.000000000 -0700
+++ source-new/src/video/orbital/SDL_orbitalvideo.h 2019-08-12 1
3:22:05.603878968
-0600
@@ -0,0 +1,3
9
@@
+++ source-new/src/video/orbital/SDL_orbitalvideo.h 2019-08-12 1
4:06:11.392352905
-0600
@@ -0,0 +1,
4
3 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
...
...
@@ -1069,6 +1061,7 @@ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.h source-new/src/video/orbi
+#ifndef _SDL_orbitalvideo_h
+#define _SDL_orbitalvideo_h
+
+#include <stdbool.h>
+#include "../SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
...
...
@@ -1079,6 +1072,9 @@ diff -ruwN source/src/video/orbital/SDL_orbitalvideo.h source-new/src/video/orbi
+
+struct SDL_PrivateVideoData {
+ void *window;
+ bool mouse_cursor;
+ bool mouse_grab;
+ bool mouse_relative;
+};
+
+#endif /* _SDL_orbitalvideo_h */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment