aboutsummaryrefslogtreecommitdiff
path: root/freeciv
diff options
context:
space:
mode:
Diffstat (limited to 'freeciv')
-rw-r--r--freeciv/Makefile53
-rw-r--r--freeciv/files/kbdmouse.h21
-rw-r--r--freeciv/files/keyboard.c94
-rw-r--r--freeciv/patches/100-small-screen-defaults.patch47
-rw-r--r--freeciv/patches/200-kbdmouse.patch171
5 files changed, 386 insertions, 0 deletions
diff --git a/freeciv/Makefile b/freeciv/Makefile
new file mode 100644
index 0000000..236e9e0
--- /dev/null
+++ b/freeciv/Makefile
@@ -0,0 +1,53 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=freeciv
+PKG_VERSION:=2.2.3
+PKG_RELEASE:=1
+
+PKG_SOURCE:=freeciv-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/freeciv
+PKG_MD5SUM:=b324e3c59f029d0566482f584181a4b2
+
+PKG_BUILD_DIR=$(BUILD_DIR)/freeciv-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/freeciv
+ SECTION:=games
+ CATEGORY:=Games
+ DEPENDS:=+libsdl +libsdl-image +libsdl-mixer +libfreetype +libiconv
+ TITLE:=Freeciv
+ URL:=http://freeciv.wikia.com/
+endef
+
+define Package/freeciv/description
+Open Source Civilization-like game (SDL client)
+endef
+
+# SDL depends on DirectFB but somehow the libs are not not found automatically
+EXTRA_LDFLAGS += $(shell $(STAGING_DIR)/root-xburst/usr/bin/directfb-config --libs --prefix=$(STAGING_DIR)/usr)
+
+EXTRA_CPPFLAGS += \
+ -DALWAYS_ROOT -DSMALL_SCREEN \
+ -DKBDMOUSE='\"$(SOURCE)/files/kbdmouse.h\"'
+
+CONFIGURE_ARGS += \
+ --enable-ipv6=no \
+ --enable-client=sdl \
+ --disable-nls \
+ --with-sdl-prefix=$(STAGING_DIR)/usr \
+ --with-libiconv-prefix=$(STAGING_DIR)/usr/lib/libiconv
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) DESTDIR="$(PKG_INSTALL_DIR)" \
+ install
+endef
+
+define Package/freeciv/install
+ $(INSTALL_DIR) $(1)/usr/bin
+ $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/{civmanual,freeciv-server,freeciv-sdl} $(1)/usr/bin/
+ $(INSTALL_DIR) $(1)/usr/share
+ $(CP) -r $(PKG_INSTALL_DIR)/usr/share/freeciv $(1)/usr/share/
+endef
+
+$(eval $(call BuildPackage,freeciv))
diff --git a/freeciv/files/kbdmouse.h b/freeciv/files/kbdmouse.h
new file mode 100644
index 0000000..a99ba10
--- /dev/null
+++ b/freeciv/files/kbdmouse.h
@@ -0,0 +1,21 @@
+/*
+ *
+ * Keyboard Mouse Emulation Config
+ *
+ */
+
+#include "keyboard.c"
+
+#define KBDMOUSE_LEFT_CLICK NNKEY_QI
+#define KBDMOUSE_MIDDLE_CLICK NNKEY_VOLUMEDOWN
+#define KBDMOUSE_RIGHT_CLICK NNKEY_VOLUMEUP
+
+#define KBDMOUSE_UP NNKEY_UP
+#define KBDMOUSE_DOWN NNKEY_DOWN
+#define KBDMOUSE_LEFT NNKEY_LEFT
+#define KBDMOUSE_RIGHT NNKEY_RIGHT
+
+#define KBDMOUSE_STEP 5
+
+#define KBDMOUSE_REPEAT_DELAY SDL_DEFAULT_REPEAT_DELAY
+#define KBDMOUSE_REPEAT_INTERVAL (SDL_DEFAULT_REPEAT_INTERVAL/2)
diff --git a/freeciv/files/keyboard.c b/freeciv/files/keyboard.c
new file mode 100644
index 0000000..cde8c0d
--- /dev/null
+++ b/freeciv/files/keyboard.c
@@ -0,0 +1,94 @@
+/*
+ keyboard.c
+
+ Contains defines for every
+ key on the Ben NanoNote.
+
+ Data collected and compiled
+ by xdpirate of #qi-hardware
+ on irc.freenode.net
+*/
+
+/* Function keys */
+#define NNKEY_F1 282
+#define NNKEY_F2 283
+#define NNKEY_F3 284
+#define NNKEY_F4 285
+#define NNKEY_F5 286
+#define NNKEY_F6 287
+#define NNKEY_F7 288
+#define NNKEY_F8 289
+
+/* First (top) keyboard row */
+#define NNKEY_Q 113
+#define NNKEY_W 119
+#define NNKEY_E 101
+#define NNKEY_R 114
+#define NNKEY_T 116
+#define NNKEY_Y 121
+#define NNKEY_U 117
+#define NNKEY_I 105
+#define NNKEY_O 111
+#define NNKEY_P 112
+
+/* Second keyboard row */
+#define NNKEY_A 97
+#define NNKEY_S 115
+#define NNKEY_D 100
+#define NNKEY_F 102
+#define NNKEY_G 103
+#define NNKEY_H 104
+#define NNKEY_J 106
+#define NNKEY_K 107
+#define NNKEY_L 108
+#define NNKEY_BACKSPACE 8
+
+/* Third keyboard row */
+#define NNKEY_ESCAPE 27
+#define NNKEY_Z 122
+#define NNKEY_X 120
+#define NNKEY_C 99
+#define NNKEY_V 118
+#define NNKEY_B 98
+#define NNKEY_N 110
+#define NNKEY_M 109
+#define NNKEY_EQUALS 61
+#define NNKEY_ENTER 13 // Enter and Return are very often used interchangeably, so since there's
+#define NNKEY_RETURN 13 // only one Enter key on the NN, they're both defined to the same key
+
+/* Fourth keyboard row, not including arrows/volume */
+#define NNKEY_TAB 9
+#define NNKEY_CAPSLOCK 301 // Same key, two constants
+#define NNKEY_CAPS 301 // for simplicity
+#define NNKEY_BACKSLASH 92
+#define NNKEY_APOSTROPHE 180
+#define NNKEY_COMMA 44
+#define NNKEY_PERIOD 46
+#define NNKEY_SLASH 47
+
+/* Fifth (bottom) keyboard row, not including arrows/volume */
+#define NNKEY_SHIFT 304
+#define NNKEY_ALT 308
+#define NNKEY_FUNCTION 306 // Same
+#define NNKEY_FN 306 // key
+#define NNKEY_RED 307 // Same
+#define NNKEY_ALTGR 307 // key
+#define NNKEY_SPACE 32
+#define NNKEY_QI 0 // Yes, the Qi-button actually returns 0!
+#define NNKEY_CTRL 305 // Same
+#define NNKEY_CONTROL 305 // key
+
+/* Arrow keys and Volume keys */
+#define NNKEY_UP 273
+#define NNKEY_DOWN 274
+#define NNKEY_LEFT 276
+#define NNKEY_RIGHT 275
+#define NNKEY_VOLUP 292
+#define NNKEY_VOLUMEUP 292
+#define NNKEY_VOLDOWN 293
+#define NNKEY_VOLUMEDOWN 293
+
+#define NNKEY_POWER 0 // NOTE: This key is only here for completeness' sake,
+ // the NanoNote will automatically turn off after
+ // pressing this key. It shares a key code with the
+ // Qi-button (Line 77).
diff --git a/freeciv/patches/100-small-screen-defaults.patch b/freeciv/patches/100-small-screen-defaults.patch
new file mode 100644
index 0000000..cd89f90
--- /dev/null
+++ b/freeciv/patches/100-small-screen-defaults.patch
@@ -0,0 +1,47 @@
+--- a/client/options.c 2010-10-05 02:21:47.218844129 +0200
++++ b/client/options.c 2010-10-05 02:27:49.427604885 +0200
+@@ -413,9 +413,15 @@
+
+ /* gui-sdl client specific options. */
+ char gui_sdl_default_theme_name[512] = FC_SDL_DEFAULT_THEME_NAME;
++#ifdef SMALL_SCREEN
++bool gui_sdl_fullscreen = TRUE;
++int gui_sdl_screen_width = 320;
++int gui_sdl_screen_height = 240;
++#else
+ bool gui_sdl_fullscreen = FALSE;
+ int gui_sdl_screen_width = 640;
+ int gui_sdl_screen_height = 480;
++#endif
+
+ /* gui-win32 client specific options. */
+ bool gui_win32_better_fog = TRUE;
+@@ -996,6 +1002,20 @@
+ "Serif 10", NULL),
+
+ /* gui-sdl client specific options. */
++#ifdef SMALL_SCREEN
++ GEN_BOOL_OPTION(gui_sdl_fullscreen, N_("Full Screen"),
++ N_("If this option is set the client will use the "
++ "whole screen area for drawing"),
++ COC_INTERFACE, GUI_SDL, TRUE, NULL),
++ GEN_INT_OPTION(gui_sdl_screen_width, N_("Screen width"),
++ N_("This option saves the width of the selected screen "
++ "resolution"),
++ COC_INTERFACE, GUI_SDL, 320, 320, 3200, NULL),
++ GEN_INT_OPTION(gui_sdl_screen_height, N_("Screen height"),
++ N_("This option saves the height of the selected screen "
++ "resolution"),
++ COC_INTERFACE, GUI_SDL, 240, 240, 2400, NULL),
++#else
+ GEN_BOOL_OPTION(gui_sdl_fullscreen, N_("Full Screen"),
+ N_("If this option is set the client will use the "
+ "whole screen area for drawing"),
+@@ -1008,6 +1028,7 @@
+ N_("This option saves the height of the selected screen "
+ "resolution"),
+ COC_INTERFACE, GUI_SDL, 480, 240, 2400, NULL),
++#endif
+
+ /* gui-win32 client specific options. */
+ GEN_BOOL_OPTION(gui_win32_better_fog,
diff --git a/freeciv/patches/200-kbdmouse.patch b/freeciv/patches/200-kbdmouse.patch
new file mode 100644
index 0000000..57865f6
--- /dev/null
+++ b/freeciv/patches/200-kbdmouse.patch
@@ -0,0 +1,171 @@
+--- a/client/gui-sdl/gui_main.c 2010-10-05 02:45:33.008848029 +0200
++++ b/client/gui-sdl/gui_main.c 2010-10-07 13:17:01.548258233 +0200
+@@ -78,6 +78,10 @@
+
+ #include "gui_main.h"
+
++#ifdef KBDMOUSE
++#include KBDMOUSE
++#endif
++
+ #define UNITS_TIMER_INTERVAL 128 /* milliseconds */
+ #define MAP_SCROLL_TIMER_INTERVAL 500
+
+@@ -496,6 +500,108 @@
+ return(1);
+ }
+
++#ifdef KBDMOUSE
++
++int keyboard_mouse(SDL_Event *event)
++{
++ SDL_Event new;
++ int x, y;
++
++ switch (event->type) {
++ case SDL_KEYDOWN:
++ switch ((int)event->key.keysym.sym) {
++ case KBDMOUSE_LEFT_CLICK:
++ case KBDMOUSE_MIDDLE_CLICK:
++ case KBDMOUSE_RIGHT_CLICK:
++ SDL_GetMouseState(&x, &y);
++
++ new = (SDL_Event) {
++ .type = SDL_MOUSEBUTTONDOWN,
++ .button = {
++ .type = SDL_MOUSEBUTTONDOWN,
++ .which = 0,
++ .state = SDL_PRESSED,
++ .x = (Uint16)x,
++ .y = (Uint16)y
++ }
++ };
++ switch ((int)event->key.keysym.sym) {
++ case KBDMOUSE_LEFT_CLICK: new.button.button = SDL_BUTTON_LEFT; break;
++ case KBDMOUSE_MIDDLE_CLICK: new.button.button = SDL_BUTTON_MIDDLE; break;
++ case KBDMOUSE_RIGHT_CLICK: new.button.button = SDL_BUTTON_RIGHT; break;
++ }
++
++ SDL_PushEvent(&new);
++ return 0;
++
++ case KBDMOUSE_UP:
++ case KBDMOUSE_DOWN:
++ case KBDMOUSE_LEFT:
++ case KBDMOUSE_RIGHT:
++ SDL_GetMouseState(&x, &y);
++
++ switch ((int)event->key.keysym.sym) {
++ case KBDMOUSE_UP: y -= KBDMOUSE_STEP; break;
++ case KBDMOUSE_DOWN: y += KBDMOUSE_STEP; break;
++ case KBDMOUSE_RIGHT: x += KBDMOUSE_STEP; break;
++ case KBDMOUSE_LEFT: x -= KBDMOUSE_STEP; break;
++ }
++
++ SDL_WarpMouse((Uint16)x, (Uint16)y);
++ return 0;
++ }
++ break;
++
++ case SDL_KEYUP:
++ switch ((int)event->key.keysym.sym) {
++ case KBDMOUSE_LEFT_CLICK:
++ case KBDMOUSE_MIDDLE_CLICK:
++ case KBDMOUSE_RIGHT_CLICK:
++ SDL_GetMouseState(&x, &y);
++
++ new = (SDL_Event) {
++ .type = SDL_MOUSEBUTTONUP,
++ .button = {
++ .type = SDL_MOUSEBUTTONUP,
++ .which = 0,
++ .state = SDL_RELEASED,
++ .x = (Uint16)x,
++ .y = (Uint16)y
++ }
++ };
++ switch ((int)event->key.keysym.sym) {
++ case KBDMOUSE_LEFT_CLICK: new.button.button = SDL_BUTTON_LEFT; break;
++ case KBDMOUSE_MIDDLE_CLICK: new.button.button = SDL_BUTTON_MIDDLE; break;
++ case KBDMOUSE_RIGHT_CLICK: new.button.button = SDL_BUTTON_RIGHT; break;
++ }
++
++ SDL_PushEvent(&new);
++ return 0;
++
++ case KBDMOUSE_UP:
++ case KBDMOUSE_DOWN:
++ case KBDMOUSE_LEFT:
++ case KBDMOUSE_RIGHT:
++ return 0;
++ }
++ break;
++
++ default:
++ break;
++ }
++
++ return -1;
++}
++
++#else
++
++int keyboard_mouse(SDL_Event *event __attribute__((unused)))
++{
++ return -1;
++}
++
++#endif
++
+ /**************************************************************************
+ ...
+ **************************************************************************/
+@@ -596,6 +702,9 @@
+
+ while (SDL_PollEvent(&Main.event) == 1) {
+
++ if (!keyboard_mouse(&Main.event))
++ continue;
++
+ switch (Main.event.type) {
+
+ case SDL_QUIT:
+@@ -763,6 +872,10 @@
+ putenv((char *)"SDL_VIDEO_CENTERED=yes");
+
+ init_sdl(iSDL_Flags);
++
++#ifdef KBDMOUSE
++ SDL_EnableKeyRepeat(KBDMOUSE_REPEAT_DELAY, KBDMOUSE_REPEAT_INTERVAL);
++#endif
+
+ freelog(LOG_NORMAL, _("Using Video Output: %s"),
+ SDL_VideoDriverName(device, sizeof(device)));
+--- a/client/gui-sdl/widget_edit.c 2010-10-05 04:29:20.907598799 +0200
++++ b/client/gui-sdl/widget_edit.c 2010-10-05 04:41:51.888846695 +0200
+@@ -30,6 +30,10 @@
+ #include "widget.h"
+ #include "widget_p.h"
+
++#ifdef KBDMOUSE
++#include KBDMOUSE
++#endif
++
+ struct UniChar {
+ struct UniChar *next;
+ struct UniChar *prev;
+@@ -730,9 +734,13 @@
+ del_chain(pEdt.pBeginTextChain);
+
+ FREESURFACE(pEdt.pBg);
+-
++
++#ifdef KBDMOUSE
++ SDL_EnableKeyRepeat(KBDMOUSE_REPEAT_DELAY, KBDMOUSE_REPEAT_INTERVAL);
++#else
+ /* disable repeate key */
+ SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
++#endif
+
+ /* disable Unicode */
+ SDL_EnableUNICODE(0);