Jump to content

GemRB 0.2.8 with SDL 1.2 on OSX (plus little bonus :)


hanicka

Recommended Posts

Since today, we can use gemrb on OSX with SDL 1.2 ...

 

I'm sending patch to enable windowed mode and control+click on OSX...

 

(you must add this to ./configure ...

 

LIBS="-lSDLmain" LDFLAGS="-framework Cocoa"

 

)

 

Index: trunk/gemrb/plugins/SDLVideo/SDLVideoDriver.cpp
===================================================================
--- trunk/gemrb/plugins/SDLVideo/SDLVideoDriver.cpp	(revision 4661)
+++ trunk/gemrb/plugins/SDLVideo/SDLVideoDriver.cpp	(working copy)
@@ -234,9 +234,12 @@
	}
	lastTime = time;

-	unsigned char key;
+	unsigned char key = 0;
	bool ConsolePopped = core->ConsolePopped;
-
+	#ifdef __APPLE_CC__ //Control Click is only need on Mac :)
+		bool ControlClick = false;
+	#endif
+	
	if (ConsolePopped) {
		core->DrawConsole();
	}
@@ -251,6 +254,12 @@

		case SDL_KEYUP:
			switch(event.key.keysym.sym) {
+				#ifdef __APPLE_CC__
+					case SDLK_RCTRL:
+					case SDLK_LCTRL:
+						ControlClick = false;
+						break;
+				#endif
				case SDLK_LALT:
				case SDLK_RALT:
					key = GEM_ALT;
@@ -272,6 +281,13 @@
				core->PopupConsole();
				break;
			}
+			#ifdef __APPLE_CC__
+			if (event.key.keysym.sym == SDLK_RCTRL || event.key.keysym.sym == SDLK_LCTRL) {
+				ControlClick = true;
+				break;
+			}
+			#endif
+			
			key = (unsigned char) event.key.keysym.unicode;
			if (key < 32 || key == 127) {
				switch (event.key.keysym.sym) {
@@ -331,7 +347,12 @@
			CursorPos.x = event.button.x; // - mouseAdjustX[CursorIndex];
			CursorPos.y = event.button.y; // - mouseAdjustY[CursorIndex];
			if (Evnt && !ConsolePopped)
-				Evnt->MouseDown( event.button.x, event.button.y, 1 << ( event.button.button - 1 ), GetModState(SDL_GetModState()) );
+				#ifdef __APPLE_CC__
+				if (event.button.button==1 && ControlClick)
+					Evnt->MouseDown( event.button.x, event.button.y, 1 << ( event.button.button ), GetModState(SDL_GetModState()) );
+				else
+				#endif
+					Evnt->MouseDown( event.button.x, event.button.y, 1 << ( event.button.button - 1 ), GetModState(SDL_GetModState()) );

			break;

@@ -343,7 +364,12 @@
			CursorPos.x = event.button.x;
			CursorPos.y = event.button.y;
			if (Evnt && !ConsolePopped)
-				Evnt->MouseUp( event.button.x, event.button.y, 1 << ( event.button.button - 1 ), GetModState(SDL_GetModState()) );
+				#ifdef __APPLE_CC__
+				if (event.button.button==1 && ControlClick)
+					Evnt->MouseUp( event.button.x, event.button.y, 1 << ( event.button.button ), GetModState(SDL_GetModState()) );
+				else
+				#endif
+					Evnt->MouseUp( event.button.x, event.button.y, 1 << ( event.button.button - 1 ), GetModState(SDL_GetModState()) );

			break;
		 case SDL_ACTIVEEVENT:
Index: trunk/gemrb/GemRB.cpp
===================================================================
--- trunk/gemrb/GemRB.cpp	(revision 4661)
+++ trunk/gemrb/GemRB.cpp	(working copy)
@@ -41,7 +41,11 @@
#include <windows.h>
#endif

-int main(int argc, char** argv)
+#ifdef __APPLE_CC__ // we need startup SDL here
+#include "SDL.h"
+#endif
+
+int main(int argc, char*argv[])
{
	core = new Interface( argc, argv );
	if (core->Init() == GEM_ERROR) {

Link to comment

I also don't understand the ctrl thingie.

Wouldn't this disable right click on os/x?

 

Ahh, now i see, ctrl click seems to replace right click?

Is this because of the lack of mouse buttons?

 

How will ControlClick retain its value between calls?

Ok, pollevents will cycle through all events so if you are *really* fast, you probably can get both events on the queue :)

But otherwise, you press ctrl, then the event queue gets emptied. And when you click your mouse button, ControlClick will be set to false already.

Link to comment

ControlClick is set to TRUE on keydown and set to FALSE on keyup, meantime you can click with first button like osx do.

 

you, can add env variable to configure via sdl-config --libs

 

-L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa

 

to "LIBS" simple you add output of sdl-config --libs

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...