1diff -Nur instead-3.2.0/Rules.caanoo instead-3.2.0-caanoo/Rules.caanoo
2--- instead-3.2.0/Rules.caanoo	1970-01-01 03:00:00.000000000 +0300
3+++ instead-3.2.0-caanoo/Rules.caanoo	2018-01-14 09:06:18.044628618 +0300
4@@ -0,0 +1,45 @@
5+VERSION := 3.4.1
6+
7+PREFIX  = /home/peter/Devel/GPH_SDK/tools/gcc-4.2.4-glibc-2.7-eabi
8+CC        = $(PREFIX)/bin/arm-gph-linux-gnueabi-gcc
9+STRIP     = $(PREFIX)/bin/arm-gph-linux-gnueabi-strip
10+
11+CFLAGS     += -DARM_ARCH -DGP2X_BUILD
12+CFLAGS     += -DWIZ_BUILD -DCAANOO
13+CFLAGS     += -O3 -std=c99 -msoft-float -funsigned-char -fno-common -fno-builtin -Wl,--allow-multiple-definition
14+CFLAGS     += -I../SDL-1.2.13/include `$(PREFIX)/arm-gph-linux-gnueabi/sys-root/usr/bin/sdl-config --cflags` -I$(PREFIX)/include
15+
16+DESTDIR=
17+BIN=
18+DATAPATH=.
19+STEADPATH=$(DATAPATH)/stead
20+THEMESPATH=$(DATAPATH)/themes
21+GAMESPATH=$(DATAPATH)/games
22+ICONPATH=$(DATAPATH)/icon
23+LANGPATH=$(DATAPATH)/lang
24+DOCPATH=
25+MANPATH=
26+SYSTEMSETUP=no
27+
28+ZLIB_CFLAGS=
29+ZLIB_LFLAGS=-lz
30+
31+LUA_CFLAGS=-I./caanoo/lua/
32+LUA_LFLAGS=./caanoo/lua/liblua.a
33+
34+SDL_CFLAGS=
35+SDL_LFLAGS=-lSDL -lSDL_mixer -lSDL_image -lSDL_ttf -lm -ldl -lpthread -lz
36+
37+CFLAGS	+= -g -Wall -Dunix -D_USE_UNPACK -D_LOCAL_APPDATA -D_HAVE_ICONV -D_SDL_MOD_BUG
38+
39+INSTALLD=echo "Do not install standalone version!"
40+INSTALLB=echo "Do not install standalone version!"
41+INSTALL=echo "Do not install standalone version!"
42+LN=echo "Do not install standalone version!"
43+
44+EXE=
45+PLATFORM=unix.c
46+RESOURCES=
47+RM=rm
48+AR=ar rc
49+RANLIB=ranlib
50diff -Nur instead-3.2.0/src/game.c instead-3.2.0-caanoo/src/game.c
51--- instead-3.2.0/src/game.c	2018-01-14 09:04:22.000000000 +0300
52+++ instead-3.2.0-caanoo/src/game.c	2018-01-14 09:06:18.044628618 +0300
53@@ -3300,7 +3300,7 @@
54 #else
55 		game_menu(menu_askquit);
56 #endif
57-	} else if ((alt_pressed | control_pressed) && (!is_key(ev, "q") || !is_key(ev, "f4"))) {
58+	} else if (!is_key(ev, "quit") || ((alt_pressed | control_pressed) && (!is_key(ev, "q") || !is_key(ev, "f4")))) {
59 		game_running = 0;
60 		return -1;
61 	} else if (alt_pressed &&
62diff -Nur instead-3.2.0/src/graphics.c instead-3.2.0-caanoo/src/graphics.c
63--- instead-3.2.0/src/graphics.c	2018-01-14 09:04:22.000000000 +0300
64+++ instead-3.2.0-caanoo/src/graphics.c	2018-01-14 09:07:34.697288401 +0300
65@@ -2219,18 +2219,25 @@
66 #else
67 int gfx_set_mode(int w, int h, int fs)
68 {
69+	int maxbpp = 32;
70 	int hw = (software_sw)?0:SDL_HWSURFACE;
71 	SDL_Surface *scr;
72 	game_reset_name();
73 	if (gfx_width == w && gfx_height == h && gfx_fs == fs) {
74 		return 0; /* already done */
75 	}
76+#ifdef CAANOO
77+	maxbpp = 16;
78+#endif
79 	vid_modes = NULL;
80 	gfx_fs = fs;
81 	gfx_width = w;
82 	gfx_height = h;
83 	if (!nocursor_sw)
84 		SDL_ShowCursor(SDL_DISABLE);
85+#ifdef CAANOO
86+ 	scr = SDL_SetVideoMode(gfx_width, gfx_height, maxbpp, ((gfx_fs)?SDL_HWSURFACE:0) | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
87+#else
88 #ifdef S60
89 	scr = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_ANYFORMAT | hw | ( ( fs ) ? SDL_FULLSCREEN : 0 ) );
90 #else
91@@ -2258,6 +2265,7 @@
92   #endif
93  #endif
94 #endif
95+#endif
96 	screen = GFX_IMG_REL(scr);
97 	if (scr == NULL || screen == NULL) {
98 		fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError());
99@@ -5663,7 +5671,7 @@
100 		SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
101 #endif
102 #endif
103-	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) {
104+	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) < 0) {
105 		fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
106 		return -1;
107 	}
108diff -Nur instead-3.2.0/src/input.c instead-3.2.0-caanoo/src/input.c
109--- instead-3.2.0/src/input.c	2018-01-14 09:04:22.000000000 +0300
110+++ instead-3.2.0-caanoo/src/input.c	2018-01-14 09:06:18.044628618 +0300
111@@ -30,6 +30,41 @@
112 static int m_focus = 1;
113 static int m_minimized = 0;
114
115+#ifdef CAANOO
116+static const char *joy_map(int button)
117+{
118+	switch(button) {
119+	case 2:
120+		return "left";
121+	case 6:
122+		return "right";
123+	case 0:
124+		return "up";
125+	case 4:
126+		return "down";
127+	case 15:
128+		return "space"; //y
129+	case 14:
130+		return "tab"; //x
131+	case 12:
132+		return "escape"; // a
133+	case 18:
134+	case 13:
135+		return "return"; // b
136+	case 8:
137+		return "quit";
138+	case 10:
139+		return "page up";
140+	case 11:
141+		return "page down";
142+	case 9:
143+	case 20:
144+		return "f1";
145+	}
146+	return "";
147+}
148+#endif
149+
150 int minimized(void)
151 {
152 	if (nopause_sw)
153@@ -182,6 +217,10 @@
154 #if defined(IOS) || defined(ANDROID)
155 	SDL_SetEventFilter(HandleAppEvents, NULL);
156 #endif
157+	if(SDL_NumJoysticks() > 0) {
158+		SDL_JoystickOpen(0);
159+		SDL_JoystickEventState(SDL_ENABLE);
160+	}
161 	return 0;
162 }
163
164@@ -414,6 +453,20 @@
165 	case SDL_QUIT:
166 		game_running = 0;
167 		return -1;
168+#ifdef CAANOO
169+	case SDL_JOYBUTTONDOWN:
170+		inp->type = KEY_DOWN;
171+		inp->code = event.jbutton.button;
172+		strncpy(inp->sym, joy_map(event.jbutton.button), sizeof(inp->sym));
173+		inp->sym[sizeof(inp->sym) - 1] = 0;
174+		break;
175+	case SDL_JOYBUTTONUP:
176+		inp->type = KEY_UP;
177+		inp->code = event.jbutton.button;
178+		strncpy(inp->sym, joy_map(event.jbutton.button), sizeof(inp->sym));
179+		inp->sym[sizeof(inp->sym) - 1] = 0;
180+		break;
181+#endif
182 	case SDL_KEYDOWN:	/* A key has been pressed */
183 #if SDL_VERSION_ATLEAST(2,0,0)
184 		if (event.key.repeat) {
185