Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mouse grab
11-16-2008, 06:37 PM,
#6
 
joevenzon Wrote:
alex25 Wrote:what i would like is for vdrift to grab the mouse when running (so i don't end up with the mouse outside the vdrift window) but when it crashes with an exception to actually release the grab

That'd be great, but I haven't been able to figure it out so far. Let me know if you're able to get it working.

this is a quick and dirty hack, but it works for me. basically i am adding a signal handler so when abort is called vdrift releases the mouse first before crashing:
Code:
--- game.cpp    (revision 2219)
+++ game.cpp    (working copy)
@@ -32,6 +32,15 @@
#include <algorithm>
using std::sort;

+#include <signal>
+
+void release_mouse(int a)
+{
+//  eventsystem.SetMouseCursorVisibility(true);
+  std::cout << "should be releasing mouse" << endl;
+  SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
///start the game with the given arguments
void GAME::Start(list <string> & args)
{
@@ -41,6 +50,10 @@
        }

        info_output << "Starting VDrift: " << VERSION << ", " << REVISION << end
l;
+// release the mouse when we abort
+        struct sigaction act;
+        act.sa_handler = release_mouse;
+        sigaction(SIGABRT,&act, NULL);

        InitializeCoreSubsystems();

there must be a better way of doing this, this is just a proof of concept.

actually this code should go in main if implemented in this form.

--alex--
Reply


Messages In This Thread
mouse grab - by alex25 - 11-14-2008, 02:24 AM
[No subject] - by thelusiv - 11-14-2008, 03:37 PM
[No subject] - by alex25 - 11-14-2008, 05:21 PM
[No subject] - by joevenzon_phpbb2_import3 - 11-16-2008, 05:23 PM
Re: mouse grab - by joevenzon_phpbb2_import3 - 11-16-2008, 05:39 PM
[No subject] - by alex25 - 11-16-2008, 06:37 PM
[No subject] - by alex25 - 11-16-2008, 06:43 PM
[No subject] - by joevenzon_phpbb2_import3 - 11-16-2008, 08:49 PM
[No subject] - by alex25 - 11-16-2008, 08:54 PM
[No subject] - by joevenzon_phpbb2_import3 - 11-16-2008, 09:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)