summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-11-05 17:49:43 +0000
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>2011-11-05 17:49:43 +0000
commit798a3e739c8dbb34c0d66bd29224df33977f26fe (patch)
treef5d75be576614d95c55f4caf09d3cbf07b54fffd
parent336c043d87dbcb92b72c2d988cdcb2f264ca52b6 (diff)
Expedite: Add support for the PSL1GHT engine
SVN revision: 64780
-rw-r--r--configure.ac7
-rw-r--r--src/bin/Makefile.am5
-rw-r--r--src/bin/engine_psl1ght.c284
-rw-r--r--src/bin/engine_psl1ght.h8
-rw-r--r--src/bin/main.c3
-rw-r--r--src/bin/main.h3
6 files changed, 310 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 8c715a2..6a5fdcd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,6 +76,9 @@ AC_SUBST(d3d_libs)
76# Software SDL 76# Software SDL
77EXPEDITE_CHECK_ENGINE([software-sdl], [Software SDL], "yes") 77EXPEDITE_CHECK_ENGINE([software-sdl], [Software SDL], "yes")
78 78
79# PSL1GHT
80EXPEDITE_CHECK_ENGINE([psl1ght], [PSL1GHT], "yes")
81
79# GL SDL 82# GL SDL
80EXPEDITE_CHECK_ENGINE([opengl-sdl], [OpenGL SDL], "yes") 83EXPEDITE_CHECK_ENGINE([opengl-sdl], [OpenGL SDL], "yes")
81 84
@@ -177,6 +180,9 @@ if test "x$have_software_sdl" = "xyes" -o "x$have_gl_sdl" = "xyes"; then
177fi 180fi
178AM_CONDITIONAL(BUILD_SDL, test "x$have_sdl" = "xyes") 181AM_CONDITIONAL(BUILD_SDL, test "x$have_sdl" = "xyes")
179 182
183# PSL1GHT
184AM_CONDITIONAL(BUILD_PSL1GHT, test "x$have_psl1ght" = "xyes")
185
180# DirectFB 186# DirectFB
181 187
182if test "x$have_directfb" = "xyes"; then 188if test "x$have_directfb" = "xyes"; then
@@ -267,6 +273,7 @@ echo " Open GL SDL..................: ${have_opengl_sdl}"
267echo " Open GL Cocoa................: ${have_opengl_cocoa}" 273echo " Open GL Cocoa................: ${have_opengl_cocoa}"
268echo " FB...........................: ${have_fb}" 274echo " FB...........................: ${have_fb}"
269echo " DirectFB.....................: ${have_directfb}" 275echo " DirectFB.....................: ${have_directfb}"
276echo " PSL1GHT......................: ${have_psl1ght}"
270echo " Software X11 16 bits.........: ${have_software_16_x11}" 277echo " Software X11 16 bits.........: ${have_software_16_x11}"
271echo " Software DirectDraw 16 bits..: ${have_software_16_ddraw}" 278echo " Software DirectDraw 16 bits..: ${have_software_16_ddraw}"
272echo " Software WinCE 16 bits.......: ${have_software_16_wince}" 279echo " Software WinCE 16 bits.......: ${have_software_16_wince}"
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index ba7cc04..4364810 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -197,6 +197,11 @@ expedite_SOURCES += \
197engine_gl_sdl.c engine_gl_sdl.h 197engine_gl_sdl.c engine_gl_sdl.h
198endif 198endif
199 199
200if BUILD_PSL1GHT
201expedite_SOURCES += \
202engine_psl1ght.c
203endif
204
200if BUILD_FB 205if BUILD_FB
201expedite_SOURCES += \ 206expedite_SOURCES += \
202engine_fb.c engine_fb.h 207engine_fb.c engine_fb.h
diff --git a/src/bin/engine_psl1ght.c b/src/bin/engine_psl1ght.c
new file mode 100644
index 0000000..2661a6c
--- /dev/null
+++ b/src/bin/engine_psl1ght.c
@@ -0,0 +1,284 @@
1#include "main.h"
2
3#include <Evas_Engine_PSL1GHT.h>
4#include <io/mouse.h>
5#include <io/kb.h>
6
7static int window_width = 0;
8static int window_height = 0;
9
10Eina_Bool
11engine_psl1ght_args(const char *engine, int width, int height)
12{
13 Evas_Engine_Info_PSL1GHT *einfo;
14
15 evas_output_method_set(evas, evas_render_method_lookup("psl1ght"));
16 einfo = (Evas_Engine_Info_PSL1GHT *)evas_engine_info_get(evas);
17 if (!einfo)
18 {
19 printf("Evas does not support the PSL1GHT Engine\n");
20 return EINA_FALSE;
21 }
22
23 if (!evas_engine_info_set(evas, (Evas_Engine_Info *)einfo))
24 {
25 printf("Evas can not setup the informations of the PSL1GHT Engine\n");
26 return EINA_FALSE;
27 }
28
29 window_width = width;
30 window_height = height;
31 ioMouseInit(1);
32 ioKbInit(1);
33 return EINA_TRUE;
34}
35
36void
37engine_psl1ght_loop(void)
38{
39 mouseInfo mouseinfo;
40 static int mouse_connected = FALSE;
41 static u8 mouse_buttons = 0;
42 static int mouse_x = 0;
43 static int mouse_y = 0;
44 KbInfo kbInfo;
45 static int keyboard_connected = FALSE;
46 static KbLed keyboard_leds = {{0}};
47 static KbMkey keyboard_mods = {{0}};
48 static u16 keyboard_old_key = 0;
49 int i;
50
51 /* Check mouse events */
52 ioMouseGetInfo(&mouseinfo);
53
54 if (mouseinfo.status[0] == 1 && !mouse_connected) // Connected
55 {
56 mouse_connected = TRUE;
57 mouse_buttons = 0;
58
59 // Old events in the queue are discarded
60 ioMouseClearBuf(0);
61 }
62 else if (mouseinfo.status[0] != 1 && mouse_connected) // Disconnected
63 {
64 mouse_connected = FALSE;
65 mouse_buttons = 0;
66 }
67
68 if (mouse_connected)
69 {
70 mouseDataList datalist;
71
72 ioMouseGetDataList(0, &datalist);
73
74 for (i = 0; i < datalist.count; i++) {
75 u8 old_left = mouse_buttons & 1;
76 u8 new_left = datalist.list[i].buttons & 1;
77 u8 old_right = mouse_buttons & 2;
78 u8 new_right = datalist.list[i].buttons & 2;
79 u8 old_middle = mouse_buttons & 4;
80 u8 new_middle = datalist.list[i].buttons & 4;
81
82 mouse_x += datalist.list[i].x_axis;
83 mouse_y += datalist.list[i].y_axis;
84 if (mouse_x < 0) mouse_x = 0;
85 if (mouse_y < 0) mouse_y = 0;
86 if (mouse_x > window_width) mouse_x = window_width;
87 if (mouse_y > window_height) mouse_x = window_height;
88
89 evas_event_feed_mouse_move(evas, mouse_x, mouse_y, 0, NULL);
90
91 if (old_left != new_left)
92 {
93 if (new_left)
94 evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
95 else
96 evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, NULL);
97 }
98 if (old_right != new_right)
99 {
100 if (new_right)
101 evas_event_feed_mouse_down(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
102 else
103 evas_event_feed_mouse_up(evas, 3, EVAS_BUTTON_NONE, 0, NULL);
104 }
105 if (old_middle != new_middle)
106 {
107 if (new_middle)
108 evas_event_feed_mouse_down(evas, 2, EVAS_BUTTON_NONE, 0, NULL);
109 else
110 evas_event_feed_mouse_up(evas, 2, EVAS_BUTTON_NONE, 0, NULL);
111 }
112 mouse_buttons = datalist.list[i].buttons;
113 }
114 }
115
116 /* Check keyboard events */
117 ioKbGetInfo(&kbInfo);
118
119 if (kbInfo.status[0] == 1 && !keyboard_connected)
120 {
121 /* Connected */
122 keyboard_connected = true;
123
124 // Old events in the queue are discarded
125 ioKbClearBuf(0);
126 keyboard_leds._KbLedU.leds = 0;
127 keyboard_mods._KbMkeyU.mkeys = 0;
128 keyboard_old_key = 0;
129
130 // Set raw keyboard code types to get scan codes
131 ioKbSetCodeType(0, KB_CODETYPE_ASCII);
132 ioKbSetReadMode(0, KB_RMODE_INPUTCHAR);
133 }
134 else if (kbInfo.status[0] != 1 && keyboard_connected)
135 {
136 /* Disconnected keyboard */
137 keyboard_connected = FALSE;
138 }
139
140 if (keyboard_connected)
141 {
142 KbData Keys;
143
144 // Read data from the keyboard buffer
145 if (ioKbRead(0, &Keys) == 0 && Keys.nb_keycode > 0)
146 {
147 if (Keys.mkey._KbMkeyU._KbMkeyS.l_shift !=
148 keyboard_mods._KbMkeyU._KbMkeyS.l_shift ||
149 Keys.mkey._KbMkeyU._KbMkeyS.r_shift !=
150 keyboard_mods._KbMkeyU._KbMkeyS.r_shift)
151 {
152 if (Keys.mkey._KbMkeyU._KbMkeyS.r_shift ||
153 Keys.mkey._KbMkeyU._KbMkeyS.l_shift)
154 evas_key_modifier_on(evas, "Shift");
155 else
156 evas_key_modifier_off(evas, "Shift");
157 }
158 if (Keys.mkey._KbMkeyU._KbMkeyS.l_ctrl !=
159 keyboard_mods._KbMkeyU._KbMkeyS.l_ctrl ||
160 Keys.mkey._KbMkeyU._KbMkeyS.r_ctrl !=
161 keyboard_mods._KbMkeyU._KbMkeyS.r_ctrl)
162 {
163 if (Keys.mkey._KbMkeyU._KbMkeyS.r_ctrl ||
164 Keys.mkey._KbMkeyU._KbMkeyS.l_ctrl)
165 evas_key_modifier_on(evas, "Control");
166 else
167 evas_key_modifier_off(evas, "Control");
168 }
169 if (Keys.mkey._KbMkeyU._KbMkeyS.l_alt !=
170 keyboard_mods._KbMkeyU._KbMkeyS.l_alt ||
171 Keys.mkey._KbMkeyU._KbMkeyS.r_alt !=
172 keyboard_mods._KbMkeyU._KbMkeyS.r_alt)
173 {
174 if (Keys.mkey._KbMkeyU._KbMkeyS.r_alt ||
175 Keys.mkey._KbMkeyU._KbMkeyS.l_alt)
176 evas_key_modifier_on(evas, "Alt");
177 else
178 evas_key_modifier_off(evas, "Alt");
179 }
180 if (Keys.mkey._KbMkeyU._KbMkeyS.l_win !=
181 keyboard_mods._KbMkeyU._KbMkeyS.l_win ||
182 Keys.mkey._KbMkeyU._KbMkeyS.r_win !=
183 keyboard_mods._KbMkeyU._KbMkeyS.r_win)
184 {
185 if (Keys.mkey._KbMkeyU._KbMkeyS.r_win ||
186 Keys.mkey._KbMkeyU._KbMkeyS.l_win)
187 evas_key_modifier_on(evas, "Super");
188 else
189 evas_key_modifier_off(evas, "Super");
190 }
191 keyboard_mods = Keys.mkey;
192
193 if (Keys.led._KbLedU._KbLedS.num_lock !=
194 keyboard_leds._KbLedU._KbLedS.num_lock)
195 {
196 if (Keys.led._KbLedU._KbLedS.num_lock)
197 evas_key_lock_on(evas, "Num_Lock");
198 else
199 evas_key_lock_on(evas, "Num_Lock");
200 }
201 if (Keys.led._KbLedU._KbLedS.caps_lock !=
202 keyboard_leds._KbLedU._KbLedS.caps_lock)
203 {
204 if (Keys.led._KbLedU._KbLedS.caps_lock)
205 evas_key_lock_on(evas, "Caps_Lock");
206 else
207 evas_key_lock_on(evas, "Caps_Lock");
208 }
209 if (Keys.led._KbLedU._KbLedS.scroll_lock !=
210 keyboard_leds._KbLedU._KbLedS.scroll_lock)
211 {
212 if (Keys.led._KbLedU._KbLedS.scroll_lock)
213 evas_key_lock_on(evas, "Scroll_Lock");
214 else
215 evas_key_lock_on(evas, "Scroll_Lock");
216 }
217 keyboard_leds = Keys.led;
218
219 for (i = 0; i < Keys.nb_keycode; i++) {
220 if (Keys.keycode[i] != keyboard_old_key)
221 {
222 u16 key = Keys.keycode[i];
223 char *key_str = NULL;
224
225 if (key == 0)
226 key = keyboard_old_key;
227 key_str = (char *)&key;
228
229 printf ("Key %d is %X\n", i, key);
230 key &= ~KB_KEYPAD;
231 if (key & KB_RAWDAT)
232 {
233 key &= 0xFF;
234 if (key == KB_RAWKEY_ESCAPE)
235 key_str = "Escape";
236 else if (key == KB_RAWKEY_ENTER)
237 key_str = "Return";
238 else if (key == KB_RAWKEY_UP_ARROW)
239 key_str = "Up";
240 else if (key == KB_RAWKEY_DOWN_ARROW)
241 key_str = "Down";
242 else if (key == KB_RAWKEY_LEFT_ARROW)
243 key_str = "Left";
244 else if (key == KB_RAWKEY_RIGHT_ARROW)
245 key_str = "Right";
246 else
247 key_str = NULL;
248 }
249 else {
250 if (key == 0x0A)
251 key_str = "Return";
252 else {
253 key_str[0] = key_str[1];
254 key_str[1] = 0;
255 }
256 }
257 if (key_str)
258 {
259 if (Keys.keycode[i] != 0)
260 {
261 printf ("Key %s pressed\n", key_str);
262 evas_event_feed_key_up(evas, key_str, key_str, NULL, NULL, 0, NULL);
263 }
264 else {
265 evas_event_feed_key_down(evas, key_str, key_str, NULL, NULL, 0, NULL);
266 printf ("Key %s released\n", key_str);
267 }
268 }
269 keyboard_old_key = Keys.keycode[0];
270 }
271 }
272 }
273 }
274 return;
275}
276
277void
278engine_psl1ght_shutdown(void)
279{
280 ioMouseEnd();
281 ioKbEnd();
282 return;
283}
284
diff --git a/src/bin/engine_psl1ght.h b/src/bin/engine_psl1ght.h
new file mode 100644
index 0000000..69610c5
--- /dev/null
+++ b/src/bin/engine_psl1ght.h
@@ -0,0 +1,8 @@
1#ifndef ENGINE_SOFTWARE_PSL1GHT_H
2#define ENGINE_SOFTWARE_PSL1GHT_H
3
4Eina_Bool engine_psl1ght_args(const char *engine, int width, int height);
5void engine_psl1ght_loop(void);
6void engine_psl1ght_shutdown(void);
7
8#endif
diff --git a/src/bin/main.c b/src/bin/main.c
index 29c23d4..ba0bd8d 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -1174,6 +1174,9 @@ static const Expedite_Engine engines[] = {
1174#if HAVE_EVAS_OPENGL_COCOA 1174#if HAVE_EVAS_OPENGL_COCOA
1175 { "gl-cocoa", engine_gl_cocoa_args, engine_gl_cocoa_loop, engine_gl_cocoa_shutdown }, 1175 { "gl-cocoa", engine_gl_cocoa_args, engine_gl_cocoa_loop, engine_gl_cocoa_shutdown },
1176#endif 1176#endif
1177#if HAVE_EVAS_PSL1GHT
1178 { "psl1ght", engine_psl1ght_args, engine_psl1ght_loop, engine_psl1ght_shutdown },
1179#endif
1177#if HAVE_EVAS_SOFTWARE_16_X11 1180#if HAVE_EVAS_SOFTWARE_16_X11
1178 { "x11-16",engine_software_16_x11_args, engine_software_16_x11_loop, engine_software_16_x11_shutdown }, 1181 { "x11-16",engine_software_16_x11_args, engine_software_16_x11_loop, engine_software_16_x11_shutdown },
1179#endif 1182#endif
diff --git a/src/bin/main.h b/src/bin/main.h
index c0f1348..882c88b 100644
--- a/src/bin/main.h
+++ b/src/bin/main.h
@@ -64,6 +64,9 @@
64#if HAVE_EVAS_OPENGL_COCOA 64#if HAVE_EVAS_OPENGL_COCOA
65#include "engine_gl_cocoa.h" 65#include "engine_gl_cocoa.h"
66#endif 66#endif
67#if HAVE_EVAS_PSL1GHT
68#include "engine_psl1ght.h"
69#endif
67#if HAVE_EVAS_SOFTWARE_16_X11 70#if HAVE_EVAS_SOFTWARE_16_X11
68#include "engine_software_16_x11.h" 71#include "engine_software_16_x11.h"
69#endif 72#endif