11-14-2008, 03:37 PM,
|
|
thelusiv
Administrator
|
Posts: 2,346
Threads: 223
Joined: Jun 2005
|
|
This was driving me crazy too and I bugged Joe about it, so he added this to the config file:
Code: [ control ]...
mousegrab = false
...
PS: omg I'm back! Sadly VDrift post-refactor is not working very well on 64-bit systems, so I won't be doing much. I'm still pretty busy with other stuff too. But I do exist!
|
|
11-14-2008, 05:21 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
thelusiv Wrote:This was driving me crazy too and I bugged Joe about it, so he added this to the config file:
Code: [ control ]...
mousegrab = false
...
thanks, that kind of works but 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 (i've been looking at the code but i can't figure out where it grabs the mouse in the first place).
btw, i am also running on a 64-bit machine and the refactor branch seems to work okay (i don't have a 32-bit machine any more so i can't tell what the differences are).
--alex--
|
|
11-16-2008, 06:37 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
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--
|
|
11-16-2008, 06:43 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
alex25 Wrote:actually this code should go in main if implemented in this form.
something like this:
Code: --- main.cpp (revision 2219)
+++ main.cpp (working copy)
@@ -1,5 +1,7 @@
#include "game.h"
+#include <fenv>
+
#include <list>
using std::list;
@@ -12,9 +14,26 @@
#include "logging.h"
#include "pathmanager.h"
+#include <signal>
+void release_mouse(int a)
+{
+// eventsystem.SetMouseCursorVisibility(true);
+ std::cout << "should be releasing the mouse" << endl;
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
+
int main (int argc, char * argv[])
{
+// catch fpe exceptions.
+// feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
+// feenableexcept(FE_ALL_EXCEPT);
+// release the mouse when we abort
+ struct sigaction act;
+ act.sa_handler = release_mouse;
+ sigaction(SIGABRT,&act, NULL);
+
list <string> args(argv, argv + argc);
//find the path of the log file
ignore the part about fpe exceptions, i guess (and the debug statement).
--alex--
|
|
11-16-2008, 08:54 PM,
|
|
alex25
Senior Member
|
Posts: 531
Threads: 42
Joined: Jun 2006
|
|
joevenzon Wrote:Cool! I take it this is linux only? I wonder if it'll work on OSX.
signal handlers should work on bsd as well but i guess somebody needs to check it out.
--alex--
|
|
|