Hi,

Am Dienstag 19 Februar 2008 schrieb Ronald Lamprecht:
> Instead of removing code it should be excluded by macros. Have a look in
See the attached patches/tgz. This time the patches should please you more ...

There are still two small issues:

- the configure maemo detection isn't really nice and needs at least a 
seperate detection if pkt-config is available
- the patches aren't 100% seperated as video.cc also contains touchscreen 
related things (the disabling of a visual mouse pointer)

These patches aren't tested yet. I'll give them a try on a clean trunk pull. 
I'll also try the double/float patch.

Till
--- trunk.orig/configure.ac	2008-02-15 13:06:30.000000000 +0100
+++ enigma-1.10/configure.ac	2008-02-22 12:47:18.000000000 +0100
@@ -65,6 +65,31 @@
  CPPFLAGS="$CPPFLAGS -DMACOSX"
 fi
 
+dnl ---------- maemo ----------
+if test "x$LINUX" = xyes; then
+  AC_MSG_CHECKING(for Maemo)
+  # the following line is probably not what we want, but it's working
+  if ! pkg-config --exists maemo-version-dev; then
+    MAEMO=yes
+    AC_MSG_RESULT(yes)
+    PKG_CHECK_MODULES(OSSO, [libosso >= 0.9.19],
+       AC_DEFINE(HAVE_LIBOSSO, [], [Whether libosso is present on the system]), 
+       [AC_MSG_NOTICE([libosso not present.])])
+
+    AC_SUBST(OSSO_LIBS)
+    AC_SUBST(OSSO_CFLAGS)
+    CFLAGS="$CFLAGS -DMAEMO -DTOUCHSCREEN $OSSO_CFLAGS"
+    CXXFLAGS="$CXXFLAGS -DMAEMO $OSSO_CFLAGS"
+    LIBS="$LIBS $OSSO_LIBS"
+  else
+    AC_MSG_RESULT(no)
+  fi
+  # the following is currently not used
+  AC_SUBST(MAEMO)
+fi
+
+AM_CONDITIONAL(MAEMO, test x$MAEMO = xyes)
+
 dnl ---------- Texi2html ----------
 AC_PATH_PROG(TEXI2HTML, texi2html, "")
 
--- trunk.orig/Makefile.am	2008-02-15 13:06:30.000000000 +0100
+++ enigma-1.10/Makefile.am	2008-02-22 13:32:16.000000000 +0100
@@ -3,12 +3,18 @@
 #   tools -> lib-src/lua
 #   src   -> tools, lib-src
 #
-SUBDIRS = m4 lib-src tools intl src data doc po etc
+SUBDIRS = m4 lib-src tools intl src data po etc
 EXTRA_DIST = enigma CHANGES ACKNOWLEDGEMENTS
 
 docdir = @datadir@/doc/enigma
 doc_DATA = README CHANGES COPYING ACKNOWLEDGEMENTS
 
+if MAEMO
+doc_DATA += install_memcard.txt
+else
+SUBDIRS += doc
+endif
+
 ACLOCAL_AMFLAGS = -I m4
 
 tolua:
--- trunk.orig/src/main.cc	2008-02-15 13:04:14.000000000 +0100
+++ enigma-1.10/src/main.cc	2008-02-22 13:29:47.000000000 +0100
@@ -167,7 +167,11 @@
     nosound  = nomusic = show_help = show_version = do_log = do_assert = force_window = false;
     dumpinfo = makepreview = show_fps = false;
     gamename = "";
+#ifndef MAEMO
     datapath = "";
+#else
+    datapath = "/media/mmc2/enigma"; // default alternate datapath for maemo on memory card
+#endif
     preffilename = PREFFILENAME;
 
     def (&nosound,              "nosound");

Attachment: enigma-1.10-maemo-newfiles.tgz
Description: application/tgz

--- trunk.orig/src/client.cc	2008-02-15 13:04:14.000000000 +0100
+++ enigma-1.10/src/client.cc	2008-02-22 13:27:34.000000000 +0100
@@ -52,11 +52,159 @@
 using namespace std;
 
 #include "client_internal.hh"
+
+#ifdef TOUCHSCREEN
+int IS_MAEMO = 1; /* Mostly Keybinding specific stuff */
+int TOUCHSCREEN_MULTIPLE=2;
+int bFirstMove=1;
+#endif
+
+#ifdef MAEMO
+/* the includes below ae required for the tiltstick interface */
+#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/select.h>
+#include <linux/input.h>  /* linux kernel event interface */
+#include <libosso.h>      /* required for screen saver timeout */
+
+int TILTSTICK_SCALE = 2;
+#endif
+
 
 /* -------------------- Auxiliary functions -------------------- */
 
 namespace
 {
+#ifdef MAEMO
+    int tiltstick_evif = 0;
+    osso_context_t *osso_context = NULL;
+
+    /* The maemo 2008 kernel does not include the joystick subsystem. */
+    /* This program thus accesses the TiltStick via the even interface */
+    /* the linux kernel is providing for all input devices */
+
+    /* open the event interface to the TiltStick */
+    int evif_open(void) 
+    {
+        DIR *dirp;
+	struct dirent *dp;
+    
+	dirp = opendir("/dev/input");
+	if(!dirp) {
+	    fprintf(stderr, "Unable to open directory /dev/input");
+	    return -1;
+	}
+    
+	/* try to find TiltStick interface */
+	while ((dp = readdir(dirp)) != NULL) {
+            if(strncmp(dp->d_name, "event", 5) == 0) {
+	        char tiltstick_name[256];
+
+		sprintf(tiltstick_name, "/dev/input/%s", dp->d_name);
+		if((tiltstick_evif = open(tiltstick_name, O_RDONLY)) >= 0) {
+	            struct input_id id;
+
+		    /* suck out some device information */
+		    if(ioctl(tiltstick_evif, EVIOCGID, &id)) {
+		        perror("ioctl(EVIOCGID)");
+		    } else {
+		        /* only the tiltstick uses these vendor ids */
+		        if((id.vendor == 0x1c40) && (id.product == 0x0533)) {
+			    printf("Found device at %s\n", tiltstick_name);
+		      
+			    if(ioctl(tiltstick_evif, EVIOCGNAME(sizeof(tiltstick_name)),
+				     tiltstick_name) < 0) {
+			        perror("ioctl(EVIOCGNAME)");
+			    } else
+			        printf("Device name: %s\n", tiltstick_name);
+
+			    closedir(dirp);
+			    return 0;
+			}
+		    }
+		    
+		    close(tiltstick_evif);
+		    tiltstick_evif = -1;
+		} else
+		    fprintf(stderr, "Unable to open %s: %s\n",
+			    tiltstick_name, strerror(errno));
+	    }
+	}
+	closedir(dirp);
+	return -1;
+    }
+
+    int evif_poll(int *x, int *y) 
+    {
+        fd_set rfds;
+	struct timeval tv;
+	int retval;
+
+	static int xbuf = 0, ybuf = 0;
+	static int xrem = 0, yrem = 0;
+	int xcnt = 1, ycnt = 1;
+
+	if(tiltstick_evif < 0) {
+	    *x = *y = 0;
+	    return -1;
+	}
+
+	if (osso_display_blanking_pause(osso_context) != OSSO_OK) {
+	    fprintf(stderr, "error with display blank\n");
+	}
+
+	*x = xbuf + xrem;
+	*y = ybuf + yrem;
+	
+	do {
+	    FD_ZERO(&rfds);
+	    FD_SET(tiltstick_evif, &rfds);
+	
+	    /* don't wait at all */
+	    tv.tv_sec = tv.tv_usec = 0;
+	    
+	    retval = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
+	    
+	    if (retval == -1)
+	        perror("select()");
+	    else if (retval) {
+	        if(FD_ISSET(tiltstick_evif, &rfds)) {
+		    struct input_event ev;
+	    
+		    
+		    if(read(tiltstick_evif, &ev, sizeof(struct input_event)) < 0) {
+		        perror("read()");
+			return -1;
+		    }
+		    
+		    /* button press */
+		    if(ev.type == 1) printf("but: %d\n", ev.value);
+		    
+		    /* the TiltStick returns signed 12 bit values */
+		    if(ev.type == EV_ABS) {
+		        if(!ev.code) { *x += (xbuf = ev.value); xcnt++; }
+			else         { *y += (ybuf = ev.value); ycnt++; }
+		    }
+		}
+	    }
+	} while(retval > 0);  /* read until no more data available */
+	
+	*x /= xcnt;
+	*y /= ycnt;
+	
+	/* save remainder */
+	xrem = *x % TILTSTICK_SCALE;
+	yrem = *y % TILTSTICK_SCALE;
+	
+	*x /= TILTSTICK_SCALE;
+	*y /= TILTSTICK_SCALE;
+	
+	return 0;
+    }
+#endif // MAEMO  
+
     /*! Display a message and change the current mouse speed. */
     void set_mousespeed (double speed)
     {
@@ -113,11 +261,26 @@
   m_user_input()
 {
     m_network_host = 0;
+#ifdef MAEMO
+    evif_open();
+
+    osso_context = osso_initialize (PACKAGE_TARNAME, PACKAGE_VERSION,
+				    0, NULL);
+    if(osso_context == NULL) {
+        fprintf(stderr, "error initiating osso context\n");
+    }
+#endif
 }
 
 Client::~Client() 
 {
     network_stop();
+
+#ifdef MAEMO
+    if (osso_context) {
+        osso_deinitialize(osso_context);
+    }
+#endif
 }
 
 bool Client::network_start()
@@ -190,11 +353,19 @@
 void Client::handle_events() 
 {
     SDL_Event e;
+
+#ifdef MAEMO
+    int x, y;
+    evif_poll(&x, &y);
+    server::Msg_MouseForce ( V2 (x, y));
+#endif
+
     while (SDL_PollEvent(&e)) {
         switch (e.type) {
         case SDL_KEYDOWN:
             on_keydown(e);
             break;
+#ifndef TOUCHSCREEN
         case SDL_MOUSEMOTION:
             if (abs(e.motion.xrel) > 300 || abs(e.motion.yrel) > 300) {
                 fprintf(stderr, "mouse event with %i, %i\n", e.motion.xrel, e.motion.yrel);
@@ -202,11 +373,33 @@
             else
                 server::Msg_MouseForce (options::GetDouble("MouseSpeed") *
                                         V2 (e.motion.xrel, e.motion.yrel));
+
             break;
         case SDL_MOUSEBUTTONDOWN:
         case SDL_MOUSEBUTTONUP:
             on_mousebutton(e);
             break;
+#else // !TOUCHSCREEN
+	    /* ignore events while touchsceen not touched (for emulation) */
+	    if (e.motion.state & 1) {
+                /* Ignore first moves after stylus lift (mouseup) */
+	        if (bFirstMove==1) { bFirstMove = 0; }
+		else {
+		    if (abs(e.motion.xrel) > 300 || abs(e.motion.yrel) > 300) {
+		        fprintf(stderr, "touchscreen event with %i, %i\n", e.motion.xrel, e.motion.yrel);
+		    }
+		    else
+		        server::Msg_MouseForce (options::GetDouble("MouseSpeed") * TOUCHSCREEN_MULTIPLE *
+						V2 (e.motion.xrel, e.motion.yrel));
+		}
+	    }
+         case SDL_MOUSEBUTTONDOWN: 
+	   break;
+         case SDL_MOUSEBUTTONUP:
+           bFirstMove = 1;
+	   break;
+#endif // !TOUCHSCREEN
+
         case SDL_ACTIVEEVENT: {
             update_mouse_button_state();
             if (e.active.gain == 0 && !video::IsFullScreen())
@@ -441,9 +634,17 @@
                 server::Msg_Command ("suicide"); 
             break;
 
+#ifndef MAEMO
         case SDLK_F4: Msg_AdvanceLevel(lev::ADVANCE_STRICTLY); break;
         case SDLK_F5: Msg_AdvanceLevel(lev::ADVANCE_UNSOLVED); break;
         case SDLK_F6: Msg_JumpBack(); break;
+#else  /* maemos special keys (fullscreen/zoom) report as function keys */
+        case SDLK_F4: show_help(); break;                               /* maemo menu */
+        case SDLK_F5: Msg_AdvanceLevel(lev::ADVANCE_UNSOLVED); break;   /* maemo home */
+	case SDLK_F6: server::Msg_ActivateItem();                       /* maemo fullscreen */
+	case SDLK_F7: Msg_AdvanceLevel(lev::ADVANCE_STRICTLY); break;   /* maemo zoom+ */
+	case SDLK_F8: rotate_inventory(+1); break;                      /* maemo zoom- */
+#endif
 
         case SDLK_F10: {
             lev::Proxy *level = lev::Proxy::loadedLevel();
--- trunk.orig/data/Makefile.am	2008-02-15 13:06:25.000000000 +0100
+++ enigma-1.10/data/Makefile.am	2008-02-21 21:34:41.000000000 +0100
@@ -1,4 +1,12 @@
-SUBDIRS = gfx fonts schemas levels sound soundsets gfx16 gfx32 gfx40 gfx48 
+if MAEMO
+  GFX = gfx32
+  MODELS = models-32.lua
+else
+  GFX = gfx16 gfx32 gfx40 gfx48
+  MODELS = models-16.lua models-32.lua models-40.lua models-48.lua
+endif
+
+SUBDIRS = gfx fonts schemas levels sound soundsets $(GFX)
 
 pkgdata_DATA = \
 	enigma_conf.lua \
@@ -6,10 +14,7 @@
 	models-2d.lua \
 	models-oxyd.lua \
 	models-editor.lua \
-	models-16.lua \
-	models-32.lua \
-	models-40.lua \
-	models-48.lua \
+	$(MODELS) \
 	init.lua \
 	startup.lua \
 	sound-defaults.lua \
--- trunk.orig/src/video.cc	2008-02-15 13:04:14.000000000 +0100
+++ enigma-1.10/src/video.cc	2008-02-22 12:57:58.000000000 +0100
@@ -181,7 +181,9 @@
     
     // Hack to hide the cursor after switching between
     // window/fullscreen mode.
+#ifndef TOUCHSCREEN
     SDL_ShowCursor (SDL_ENABLE);
+#endif
     SDL_ShowCursor (SDL_DISABLE);
 
     SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
@@ -211,6 +213,8 @@
 
 /* -------------------- MouseCursor -------------------- */
 
+#ifndef TOUCHSCREEN
+
 MouseCursor::MouseCursor ()
 : background(0), cursor(0)
 {
@@ -320,12 +324,15 @@
         SCREEN->update_rect (get_oldrect());
     }
 }
+#endif // !TOUCHSCREEN
 
 /* -------------------- Local Variables -------------------- */
 namespace
 {
     Video_SDL   *video_engine = 0;
+#ifndef TOUCHSCREEN
     MouseCursor *cursor       = 0;
+#endif
     Surface     *back_buffer  = 0;
 
     /*! List of available video modes. */
@@ -346,6 +353,7 @@
             Rect (150, 434, 475, 35),        // text area
             true, true,                      // available window, fullscreen
             "-0-","-0-"                      // fallback modes window, fullscreen
+#ifndef MAEMO
         },
         { 
             VM_640x512, 640, 512,            // id, w, h
@@ -516,6 +524,7 @@
             Rect (75, 217, 237, 17),         // text area
             true, true,                      // available window, fullscreen
             "-10-0-","-10-0-"                // fallback modes window, fullscreen
+#endif // !MAEMO
         }
     };
 
@@ -540,6 +549,7 @@
         return false;
     }
 
+#ifndef TOUCHSCREEN
 /*! This function is installed as an event filter by video::Init.  It
   intercepts mouse motions, which are used to update the position of
   the mouse cursor (but passed on to the event queue) */
@@ -551,13 +561,13 @@
         }
         return 1;
     }
-
+#endif
 }
 
 
 /* -------------------- Functions -------------------- */
 
-
+#ifdef TOUCHSCREEN
 
 void video::SetMouseCursor(ecl::Surface *s, int hotx, int hoty) {
     cursor->set_image(s, hotx, hoty);
@@ -582,6 +592,14 @@
     return cursor->get_y();
 }
 
+#else // TOUCHSCREEN
+
+void video::SetMouseCursor(ecl::Surface *s, int hotx, int hoty) { }
+void video::HideMouse() { }
+void video::ShowMouse() { }
+
+#endif // TOUCHSCREEN
+
 /* -------------------- Input grabbing -------------------- */
 
 
@@ -729,7 +747,11 @@
         }
     }
 
+#ifndef MAEMO
     bool isFullScreen = app.prefs->getBool("FullScreen");
+#else
+    bool isFullScreen = true;
+#endif
     int vidmode = -1;
     if (app.prefs->getString("VideoModesFullscreen").empty()) {
         // initialize from 1.0 mode if never set before
@@ -781,13 +803,14 @@
         SDL_WM_SetIcon(icn->get_surface(), NULL);
 #endif
 
+#ifndef TOUCHSCREEN
     cursor = new MouseCursor;
     int x, y;
     SDL_GetMouseState(&x, &y);
     cursor->move(x,y);
 
     SDL_SetEventFilter(event_filter);
-
+#endif
 
     UpdateGamma();
 }
@@ -796,21 +819,29 @@
 {
     SDL_SetEventFilter(0);
     delete video_engine;
+#ifndef TOUCHSCREEN
     delete cursor;
+#endif
     delete back_buffer;
     video_engine = 0;
+#ifndef TOUCHSCREEN
     cursor = 0;
+#endif
     back_buffer = 0;
 }
 
 void video::ChangeVideoMode() 
 {
+#ifndef TOUCHSCREEN
     MouseCursor *oldcursor = cursor;
     cursor = 0;
+#endif
     Shutdown();
     Init();
+#ifndef TOUCHSCREEN
     delete cursor;
     cursor = oldcursor;
+#endif
 }
 
 ecl::Screen * video::GetScreen() {
--- trunk.orig/src/video.hh	2008-02-15 13:04:14.000000000 +0100
+++ enigma-1.10/src/video.hh	2008-02-22 13:01:41.000000000 +0100
@@ -32,6 +32,7 @@
     enum VideoModes {
         VM_None      = -1,
         VM_640x480   = 0,   ///< 32 bit basic    -  4:3  - VGA
+#ifndef MAEMO
         VM_640x512   = 1,   ///< 32 bit embedded -  5:4  - none
         VM_800x600   = 2,   ///< 40 bit basic    -  4:3  - SVGA
         VM_1024x768  = 3,   ///< 48 bit embedded -  4:3  - XGA
@@ -42,6 +43,7 @@
         VM_1280x1024 = 8,   ///< 64 bit embedded -  5:4  - SXGA
         VM_1680x1050 = 9,   ///< 64 bit embedded - 16:10 - WSXGA+
         VM_320x240   = 10,  ///< 16 bit basic    -  4:3  - CGA
+#endif
         VM_COUNT
     };
     
--- trunk.orig/src/gui/OptionsMenu.cc	2008-02-15 13:04:12.000000000 +0100
+++ enigma-1.10/src/gui/OptionsMenu.cc	2008-02-22 13:05:37.000000000 +0100
@@ -124,7 +124,7 @@
     };
 
 
-
+#ifndef MAEMO
     /* -------------------- VideoModeButton -------------------- */
     
     VideoModeButton::VideoModeButton() : ValueButton(0, 1) {
@@ -160,7 +160,7 @@
         const video::VMInfo * vi = video::GetInfo(video::GetVideoMode(value, isFullScreen));
         return vi->name;
     }
-
+#endif // !MAEMO
 
     /* -------------------- SoundSetButton -------------------- */
     
@@ -219,13 +219,14 @@
         return string();
     }
     
-
+#ifndef MAEMO
     /* -------------------- FullscreenButton -------------------- */
     
     FullscreenButton::FullscreenButton()
         : BoolOptionButton("FullScreen", N_("Yes"), N_("No"))
     {
     }
+#endif
     
     /* -------------------- LanguageButton -------------------- */
     
@@ -341,18 +342,22 @@
         BuildVList rightlabels (this, Rect(but_width+midspacing, 0, label_width, but_height), spacing);
         BuildVList right(this, Rect(but_width+midspacing+label_width, 0, but_width, but_height), spacing);
         leftlabels.add (new Label(N_("Language: "), HALIGN_RIGHT));
+#ifndef MAEMO
         leftlabels.add (new Label(N_("Fullscreen: "), HALIGN_RIGHT));
         leftlabels.add (new Label(N_("Video mode: "), HALIGN_RIGHT));
+#endif
         leftlabels.add (new Label(N_("Gamma correction: "), HALIGN_RIGHT));
         leftlabels.add (new Label(N_("Mouse speed: "), HALIGN_RIGHT));
     
         language = new LanguageButton(this);
         left.add (language);
+#ifndef MAEMO
         fullscreen = new FullscreenButton();
         fullscreen->set_listener(this);
         left.add (fullscreen);
         videomode = new VideoModeButton();
         left.add (videomode);
+#endif
         left.add (new GammaButton);
         left.add (new MouseSpeedButton);
     
@@ -433,6 +438,7 @@
 
     bool OptionsMenu::on_event (const SDL_Event &e)
     {
+#ifndef MAEMO
         bool handled=false;
         if (e.type == SDL_KEYUP) {
             if ((e.key.keysym.sym==SDLK_RETURN) &&
@@ -444,6 +450,9 @@
             }
         }
         return handled;
+#else
+        return false;
+#endif
     }
     
     void OptionsMenu::on_action(Widget *w)
@@ -453,6 +462,7 @@
         else if (w == language)
             // language changed - retranslate and redraw everything
             invalidate_all();
+#ifndef MAEMO
         else if (w == fullscreen) {
             // switch the fullscreen button and option
             fullscreen->on_action(fullscreen);
@@ -461,6 +471,7 @@
             videomode->reinit();
             invalidate_all();
         }
+#endif
     }
     
     void OptionsMenu::tick (double)
--- trunk.orig/src/gui/MainMenu.cc	2008-02-15 13:04:12.000000000 +0100
+++ enigma-1.10/src/gui/MainMenu.cc	2008-02-22 13:07:10.000000000 +0100
@@ -290,7 +290,11 @@
     
     void MainMenu::tick(double /* dtime */) 
     {
+#ifndef MAEMO
         bool isFullScreen = app.prefs->getBool("FullScreen");
+#else
+	bool isFullScreen = true;
+#endif
         if (app.selectedVideoMode != video::GetVideoMode()
                 || isFullScreen != video::IsFullScreen())
         {
_______________________________________________
Enigma-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/enigma-devel

Reply via email to