summaryrefslogtreecommitdiff
path: root/src/lib/ecore_psl1ght
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:48:42 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-08-25 10:48:42 -0700
commitd179a5c2a95785e64015c9d69f9e0f23dfc6699e (patch)
tree2cb2120e7ce066fd4bcc3e90ccd691d71033adc5 /src/lib/ecore_psl1ght
parente6b4878a9e348b6fdf6112ba2ef359e63ccbd09c (diff)
efl: remove PS3 backend.
This backend has received no patch and maintenance from anyone who could actually test it over the last few years. After talking with KaKaRoTo it is best to remove it. If anyone want to take over its maintenance, you are welcome to revert this patch.
Diffstat (limited to 'src/lib/ecore_psl1ght')
-rw-r--r--src/lib/ecore_psl1ght/Ecore_Psl1ght.h124
-rw-r--r--src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h78
-rw-r--r--src/lib/ecore_psl1ght/ecore_psl1ght.c862
-rw-r--r--src/lib/ecore_psl1ght/ecore_psl1ght_private.h36
-rw-r--r--src/lib/ecore_psl1ght/gemutil.c281
-rw-r--r--src/lib/ecore_psl1ght/gemutil.h19
-rw-r--r--src/lib/ecore_psl1ght/moveutil.c245
-rw-r--r--src/lib/ecore_psl1ght/moveutil.h43
-rw-r--r--src/lib/ecore_psl1ght/spursutil.c62
-rw-r--r--src/lib/ecore_psl1ght/spursutil.h24
10 files changed, 0 insertions, 1774 deletions
diff --git a/src/lib/ecore_psl1ght/Ecore_Psl1ght.h b/src/lib/ecore_psl1ght/Ecore_Psl1ght.h
deleted file mode 100644
index 2eaca2903b..0000000000
--- a/src/lib/ecore_psl1ght/Ecore_Psl1ght.h
+++ /dev/null
@@ -1,124 +0,0 @@
1#ifndef _ECORE_PSL1GHT_H
2#define _ECORE_PSL1GHT_H
3
4#ifdef EAPI
5# undef EAPI
6#endif
7
8#ifdef __GNUC__
9# if __GNUC__ >= 4
10# define EAPI __attribute__ ((visibility("default")))
11# else
12# define EAPI
13# endif
14#else
15# define EAPI
16#endif
17
18/**
19 * @file
20 * @brief Ecore PSL1GHT system functions.
21 */
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27EAPI extern int ECORE_PSL1GHT_EVENT_KEY_MODIFIERS;
28EAPI extern int ECORE_PSL1GHT_EVENT_GOT_FOCUS;
29EAPI extern int ECORE_PSL1GHT_EVENT_LOST_FOCUS;
30EAPI extern int ECORE_PSL1GHT_EVENT_EXPOSE;
31EAPI extern int ECORE_PSL1GHT_EVENT_QUIT;
32
33typedef struct _Ecore_Psl1ght_Event_Key_Modifiers Ecore_Psl1ght_Event_Key_Modifiers;
34struct _Ecore_Psl1ght_Event_Key_Modifiers /** PSL1GHT Key Modifier event */
35{
36 unsigned int timestamp;
37 unsigned int modifiers;
38 int shift_changed : 1;
39 int shift : 1;
40 int alt_changed : 1;
41 int alt : 1;
42 int ctrl_changed : 1;
43 int ctrl : 1;
44 int win_changed : 1;
45 int win : 1;
46 int num_lock_changed : 1;
47 int num_lock : 1;
48 int caps_lock_changed : 1;
49 int caps_lock : 1;
50 int scroll_lock_changed : 1;
51 int scroll_lock : 1;
52};
53
54typedef struct _Ecore_Psl1ght_Event_Key_Down Ecore_Psl1ght_Event_Key_Down;
55struct _Ecore_Psl1ght_Event_Key_Down /** PSL1GHT Key Down event */
56{
57 const char *keyname; /**< The name of the key that was pressed */
58 const char *keycompose; /**< The UTF-8 string conversion if any */
59 unsigned int time;
60};
61
62typedef struct _Ecore_Psl1ght_Event_Key_Up Ecore_Psl1ght_Event_Key_Up;
63struct _Ecore_Psl1ght_Event_Key_Up /** PSL1GHT Key Up event */
64{
65 const char *keyname; /**< The name of the key that was released */
66 const char *keycompose; /**< The UTF-8 string conversion if any */
67 unsigned int time;
68};
69
70typedef struct _Ecore_Psl1ght_Event_Mouse_Button_Down Ecore_Psl1ght_Event_Mouse_Button_Down;
71struct _Ecore_Psl1ght_Event_Mouse_Button_Down /** PSL1GHT Mouse Down event */
72{
73 int button; /**< Mouse button that was pressed (1 - 32) */
74 int x; /**< Mouse co-ordinates when mouse button was pressed */
75 int y; /**< Mouse co-ordinates when mouse button was pressed */
76 int double_click : 1; /**< Set if click was a double click */
77 int triple_click : 1; /**< Set if click was a triple click */
78 unsigned int time;
79};
80
81typedef struct _Ecore_Psl1ght_Event_Mouse_Button_Up Ecore_Psl1ght_Event_Mouse_Button_Up;
82struct _Ecore_Psl1ght_Event_Mouse_Button_Up /** PSL1GHT Mouse Up event */
83{
84 int button; /**< Mouse button that was released (1 - 32) */
85 int x; /**< Mouse co-ordinates when mouse button was raised */
86 int y; /**< Mouse co-ordinates when mouse button was raised */
87 int double_click : 1; /**< Set if click was a double click */
88 int triple_click : 1; /**< Set if click was a triple click */
89 unsigned int time;
90};
91
92typedef struct _Ecore_Psl1ght_Event_Mouse_Move Ecore_Psl1ght_Event_Mouse_Move;
93struct _Ecore_Psl1ght_Event_Mouse_Move /** PSL1GHT Mouse Move event */
94{
95 int x; /**< Mouse co-ordinates where the mouse cursor moved to */
96 int y; /**< Mouse co-ordinates where the mouse cursor moved to */
97 unsigned int time;
98};
99
100typedef struct _Ecore_Psl1ght_Event_Mouse_Wheel Ecore_Psl1ght_Event_Mouse_Wheel;
101struct _Ecore_Psl1ght_Event_Mouse_Wheel /** PSL1GHT Mouse Wheel event */
102{
103 int x, y;
104 int direction; /* 0 = vertical, 1 = horizontal */
105 int wheel; /* value 1 (left/up), -1 (right/down) */
106 unsigned int time;
107};
108
109EAPI int ecore_psl1ght_init(const char *name);
110EAPI int ecore_psl1ght_shutdown(void);
111EAPI void ecore_psl1ght_resolution_set(int width, int height);
112EAPI void ecore_psl1ght_poll_events(void);
113
114EAPI void ecore_psl1ght_screen_resolution_get(int *w, int *h);
115EAPI void ecore_psl1ght_optimal_screen_resolution_get(int *w, int *h);
116
117#ifdef __cplusplus
118}
119#endif
120
121#undef EAPI
122#define EAPI
123
124#endif
diff --git a/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h b/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h
deleted file mode 100644
index e385af8a4d..0000000000
--- a/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h
+++ /dev/null
@@ -1,78 +0,0 @@
1#ifndef ECORE_PSL1GHT_KEYS_H__
2# define ECORE_PSL1GHT_KEYS_H__
3
4struct _ecore_psl1ght_keys_s
5{
6 int code;
7 const char *name;
8 const char *compose;
9};
10
11static const struct _ecore_psl1ght_keys_s keystable[] =
12{
13 { KB_RAWKEY_NO_EVENT, "0x00", "" },
14 { KB_RAWKEY_BS, "BackSpace", "\010" },
15 { KB_RAWKEY_TAB, "Tab", "\011" },
16 { KB_RAWKEY_ENTER, "Return", "\015" },
17 { KB_RAWKEY_PAUSE, "Pause", "Pause" },
18 { KB_RAWKEY_ESCAPE, "Escape", "\033" },
19 { KB_RAWKEY_SPACE, "space", " " },
20
21 /* Skip uppercase letters */
22 { KB_RAWKEY_LEFT_BRACKET_101, "bracketleft", "[" },
23 { KB_RAWKEY_BACKSLASH_101, "backslash", "\\" },
24 { KB_RAWKEY_RIGHT_BRACKET_101, "bracketright", "]" },
25 { KB_RAWKEY_ACCENT_CIRCONFLEX_106, "asciicircumm", "^" },
26 { KB_RAWKEY_DELETE, "Delete", "\177" },
27 /* End of ASCII mapped keysyms */
28
29 /* Numeric keypad */
30 { KB_RAWKEY_KPAD_0, "KP0", "0" },
31 { KB_RAWKEY_KPAD_1, "KP1", "1" },
32 { KB_RAWKEY_KPAD_2, "KP2", "2" },
33 { KB_RAWKEY_KPAD_3, "KP3", "3" },
34 { KB_RAWKEY_KPAD_4, "KP4", "4" },
35 { KB_RAWKEY_KPAD_5, "KP5", "5" },
36 { KB_RAWKEY_KPAD_6, "KP6", "6" },
37 { KB_RAWKEY_KPAD_7, "KP7", "7" },
38 { KB_RAWKEY_KPAD_8, "KP8", "8" },
39 { KB_RAWKEY_KPAD_9, "KP9", "9" },
40 { KB_RAWKEY_KPAD_PERIOD, "period", "." },
41 { KB_RAWKEY_KPAD_SLASH, "KP_Divide", "/" },
42 { KB_RAWKEY_KPAD_ASTERISK, "KP_Multiply", "*" },
43 { KB_RAWKEY_KPAD_MINUS, "KP_Minus", "-" },
44 { KB_RAWKEY_KPAD_PLUS, "KP_Plus", "+" },
45 { KB_RAWKEY_KPAD_ENTER, "KP_Enter", "\015" },
46
47 /* Arrows + Home/End pad */
48 { KB_RAWKEY_UP_ARROW, "Up", "Up" },
49 { KB_RAWKEY_DOWN_ARROW, "Down", "Down" },
50 { KB_RAWKEY_RIGHT_ARROW, "Right", "Right" },
51 { KB_RAWKEY_LEFT_ARROW, "Left", "Left" },
52 { KB_RAWKEY_INSERT, "Insert", "Insert" },
53 { KB_RAWKEY_HOME, "Home", "Home" },
54 { KB_RAWKEY_END, "End", "End" },
55 { KB_RAWKEY_PAGE_UP, "Page_Up", "Page_Up" },
56 { KB_RAWKEY_PAGE_DOWN, "Page_Down", "Page_Down" },
57
58 /* Function keys */
59 { KB_RAWKEY_F1, "F1", "F1" },
60 { KB_RAWKEY_F2, "F2", "F2" },
61 { KB_RAWKEY_F3, "F3", "F3" },
62 { KB_RAWKEY_F4, "F4", "F4" },
63 { KB_RAWKEY_F5, "F5", "F5" },
64 { KB_RAWKEY_F6, "F6", "F6" },
65 { KB_RAWKEY_F7, "F7", "F7" },
66 { KB_RAWKEY_F8, "F8", "F8" },
67 { KB_RAWKEY_F9, "F9", "F9" },
68 { KB_RAWKEY_F10, "F10", "F10" },
69 { KB_RAWKEY_F11, "F11", "F11" },
70 { KB_RAWKEY_F12, "F12", "F12" },
71
72 /* Key state modifier keys */
73 { KB_RAWKEY_KPAD_NUMLOCK, "Num_Lock", "Num_Lock" },
74 { KB_RAWKEY_CAPS_LOCK, "Caps_Lock", "Caps_Lock" },
75 { KB_RAWKEY_SCROLL_LOCK, "Scroll_Lock", "Scroll_Lock" },
76};
77
78#endif /* ECORE_PSL1GHT_KEYS_H__ */
diff --git a/src/lib/ecore_psl1ght/ecore_psl1ght.c b/src/lib/ecore_psl1ght/ecore_psl1ght.c
deleted file mode 100644
index 1a16145728..0000000000
--- a/src/lib/ecore_psl1ght/ecore_psl1ght.c
+++ /dev/null
@@ -1,862 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <sysutil/video.h>
6#include <sysutil/sysutil.h>
7#include <sysmodule/sysmodule.h>
8#include <io/pad.h>
9#include <io/mouse.h>
10#include <io/kb.h>
11#include <io/camera.h>
12#include <io/move.h>
13#include <sys/process.h>
14
15#include "moveutil.h"
16
17#include "Eina.h"
18#include "Ecore_Psl1ght.h"
19#include "Ecore_Input.h"
20#include "Ecore.h"
21#include "ecore_psl1ght_private.h"
22#include "ecore_private.h"
23#include "Ecore_Psl1ght_Keys.h"
24
25/* Allocate 1MB stack to avoid overflows */
26SYS_PROCESS_PARAM(1001, 0x100000);
27
28int _ecore_psl1ght_log_dom = -1;
29
30EAPI int ECORE_PSL1GHT_EVENT_KEY_MODIFIERS = 0;
31EAPI int ECORE_PSL1GHT_EVENT_GOT_FOCUS = 0;
32EAPI int ECORE_PSL1GHT_EVENT_LOST_FOCUS = 0;
33EAPI int ECORE_PSL1GHT_EVENT_EXPOSE = 0;
34EAPI int ECORE_PSL1GHT_EVENT_QUIT = 0;
35
36static int _ecore_psl1ght_init_count = 0;
37static int window_width = 0;
38static int window_height = 0;
39/* Mouse support */
40static int mouse_connected = FALSE;
41static u8 mouse_buttons = 0;
42static int mouse_x = 0;
43static int mouse_y = 0;
44/* Keyboard support */
45static int keyboard_connected = FALSE;
46static KbLed keyboard_leds = {{0}};
47static KbMkey keyboard_mods = {{0}};
48static u16 keyboard_old_key = 0;
49/* Pad support */
50static padData pad_data;
51static padData old_pad_data = {0};
52static int pad_old_x = 0;
53static int pad_old_o = 0;
54/* Move support */
55static int move_connected = FALSE;
56static moveContext *move_context = NULL;
57u16 move_buttons = 0;
58
59static void xmb_event_handler(u64 status, u64 param, void *user_data);
60
61/**
62 * @defgroup Ecore_Psl1ght_Library_Group PSL1GHT Library Functions
63 * @ingroup Ecore
64 *
65 * Functions used to set up and shut down the Ecore_Psl1ght functions.
66 */
67
68/**
69 * Sets up the Ecore_Psl1ght library.
70 * @param name device target name
71 * @return @c 0 on failure. Otherwise, the number of times the library has
72 * been initialised without being shut down.
73 * @ingroup Ecore_PSL1GHT_Library_Group
74 */
75EAPI int
76ecore_psl1ght_init(const char *name EINA_UNUSED)
77{
78 videoState state;
79 videoResolution resolution;
80 int ret, camera_loaded, gem_loaded;
81
82 if (++_ecore_psl1ght_init_count != 1)
83 return _ecore_psl1ght_init_count;
84 _ecore_psl1ght_log_dom = eina_log_domain_register
85 ("ecore_psl1ght", ECORE_PSL1GHT_DEFAULT_LOG_COLOR);
86 if (_ecore_psl1ght_log_dom < 0)
87 {
88 EINA_LOG_ERR("Impossible to create a log domain for the Ecore PSL1GHT module.");
89 return --_ecore_psl1ght_init_count;
90 }
91 if (!ecore_event_init())
92 {
93 eina_log_domain_unregister(_ecore_psl1ght_log_dom);
94 _ecore_psl1ght_log_dom = -1;
95 return --_ecore_psl1ght_init_count;
96 }
97
98 if (videoGetState (0, 0, &state) == 0 &&
99 videoGetResolution (state.displayMode.resolution, &resolution) == 0)
100 {
101 ecore_psl1ght_resolution_set (resolution.width, resolution.height);
102 }
103 else
104 {
105 ecore_event_shutdown();
106 eina_log_domain_unregister(_ecore_psl1ght_log_dom);
107 _ecore_psl1ght_log_dom = -1;
108 return --_ecore_psl1ght_init_count;
109 }
110
111 /* Pad support */
112 ioPadInit (7);
113 /* Mouse support */
114 ioMouseInit(2);
115 mouse_buttons = 0;
116 mouse_x = 0;
117 mouse_y = 0;
118
119 /* Keyboard support */
120 ioKbInit(2);
121 keyboard_leds._KbLedU.leds = 0;
122 keyboard_mods._KbMkeyU.mkeys = 0;
123
124 /* Initialize Move */
125 move_context = NULL;
126 move_buttons = 0;
127
128 camera_loaded = !sysModuleIsLoaded (SYSMODULE_CAMERA);
129 if (!camera_loaded)
130 ret = sysModuleLoad (SYSMODULE_CAMERA);
131 else
132 ret = 0;
133 if (ret == 0)
134 {
135 gem_loaded = !sysModuleIsLoaded (SYSMODULE_GEM);
136 if (!gem_loaded)
137 ret = sysModuleLoad (SYSMODULE_GEM);
138 if (ret == 0)
139 {
140 move_context = initMove ();
141 }
142 else {
143 if (gem_loaded)
144 sysModuleUnload (SYSMODULE_CAMERA);
145 }
146 }
147
148 sysUtilRegisterCallback (SYSUTIL_EVENT_SLOT0, xmb_event_handler, NULL);
149
150 if (ECORE_PSL1GHT_EVENT_GOT_FOCUS == 0)
151 {
152 ECORE_PSL1GHT_EVENT_GOT_FOCUS = ecore_event_type_new();
153 ECORE_PSL1GHT_EVENT_LOST_FOCUS = ecore_event_type_new();
154 ECORE_PSL1GHT_EVENT_EXPOSE = ecore_event_type_new();
155 ECORE_PSL1GHT_EVENT_KEY_MODIFIERS = ecore_event_type_new();
156 ECORE_PSL1GHT_EVENT_QUIT = ecore_event_type_new();
157 }
158
159 mouse_x = 0;
160 mouse_y = 0;
161
162 return _ecore_psl1ght_init_count;
163}
164
165/**
166 * Shuts down the Ecore_Psl1ght library.
167 * @return @c The number of times the system has been initialised without
168 * being shut down.
169 * @ingroup Ecore_PSL1GHT_Library_Group
170 */
171EAPI int
172ecore_psl1ght_shutdown(void)
173{
174 if (--_ecore_psl1ght_init_count != 0)
175 return _ecore_psl1ght_init_count;
176
177 ecore_event_shutdown();
178 eina_log_domain_unregister(_ecore_psl1ght_log_dom);
179 _ecore_psl1ght_log_dom = -1;
180
181 ecore_event_type_flush(ECORE_PSL1GHT_EVENT_GOT_FOCUS,
182 ECORE_PSL1GHT_EVENT_LOST_FOCUS,
183 ECORE_PSL1GHT_EVENT_EXPOSE,
184 ECORE_PSL1GHT_EVENT_KEY_MODIFIERS,
185 ECORE_PSL1GHT_EVENT_QUIT);
186
187 ioPadEnd();
188 ioMouseEnd();
189 ioKbEnd();
190
191 if (move_context)
192 {
193 endMove (move_context);
194 move_context = NULL;
195 sysModuleUnload (SYSMODULE_CAMERA);
196 sysModuleUnload (SYSMODULE_GEM);
197 }
198
199 sysUtilUnregisterCallback(SYSUTIL_EVENT_SLOT0);
200
201 return _ecore_psl1ght_init_count;
202}
203
204static unsigned int
205_ecore_psl1ght_get_time(void)
206{
207 return (unsigned int)((unsigned long long)
208 (ecore_time_get() * 1000.0) & 0xffffffff);
209}
210
211static unsigned int
212_ecore_psl1ght_get_modifiers(void)
213{
214 unsigned int modifiers = 0;
215
216 if (keyboard_mods._KbMkeyU._KbMkeyS.r_shift ||
217 keyboard_mods._KbMkeyU._KbMkeyS.l_shift)
218 modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
219 if (keyboard_mods._KbMkeyU._KbMkeyS.r_ctrl ||
220 keyboard_mods._KbMkeyU._KbMkeyS.l_ctrl)
221 modifiers |= ECORE_EVENT_MODIFIER_CTRL;
222 if (keyboard_mods._KbMkeyU._KbMkeyS.r_alt ||
223 keyboard_mods._KbMkeyU._KbMkeyS.l_alt)
224 modifiers |= ECORE_EVENT_MODIFIER_ALT;
225 if (keyboard_mods._KbMkeyU._KbMkeyS.r_win ||
226 keyboard_mods._KbMkeyU._KbMkeyS.l_win)
227 modifiers |= ECORE_EVENT_MODIFIER_WIN;
228
229 if (keyboard_leds._KbLedU._KbLedS.num_lock)
230 modifiers |= ECORE_EVENT_LOCK_NUM;
231 if (keyboard_leds._KbLedU._KbLedS.caps_lock)
232 modifiers |= ECORE_EVENT_LOCK_CAPS;
233 if (keyboard_leds._KbLedU._KbLedS.scroll_lock)
234 modifiers |= ECORE_EVENT_LOCK_SCROLL;
235
236 return modifiers;
237}
238
239static void
240_ecore_psl1ght_key_modifiers(KbMkey *mods, KbLed *leds)
241{
242 Ecore_Psl1ght_Event_Key_Modifiers *ev;
243 Eina_Bool emit = EINA_FALSE;
244
245 ev = malloc(sizeof(Ecore_Psl1ght_Event_Key_Modifiers));
246 if (!ev) return;
247
248 if (mods->_KbMkeyU._KbMkeyS.l_shift !=
249 keyboard_mods._KbMkeyU._KbMkeyS.l_shift ||
250 mods->_KbMkeyU._KbMkeyS.r_shift !=
251 keyboard_mods._KbMkeyU._KbMkeyS.r_shift)
252 {
253 emit = EINA_TRUE;
254 ev->shift_changed = EINA_TRUE;
255 ev->shift = mods->_KbMkeyU._KbMkeyS.r_shift |
256 mods->_KbMkeyU._KbMkeyS.l_shift;
257 }
258 if (mods->_KbMkeyU._KbMkeyS.l_ctrl !=
259 keyboard_mods._KbMkeyU._KbMkeyS.l_ctrl ||
260 mods->_KbMkeyU._KbMkeyS.r_ctrl !=
261 keyboard_mods._KbMkeyU._KbMkeyS.r_ctrl)
262 {
263 emit = EINA_TRUE;
264 ev->ctrl_changed = EINA_TRUE;
265 ev->ctrl = mods->_KbMkeyU._KbMkeyS.r_ctrl |
266 mods->_KbMkeyU._KbMkeyS.l_ctrl;
267 }
268 if (mods->_KbMkeyU._KbMkeyS.l_alt !=
269 keyboard_mods._KbMkeyU._KbMkeyS.l_alt ||
270 mods->_KbMkeyU._KbMkeyS.r_alt !=
271 keyboard_mods._KbMkeyU._KbMkeyS.r_alt)
272 {
273 emit = EINA_TRUE;
274 ev->alt_changed = EINA_TRUE;
275 ev->alt = mods->_KbMkeyU._KbMkeyS.r_alt |
276 mods->_KbMkeyU._KbMkeyS.l_alt;
277 }
278 if (mods->_KbMkeyU._KbMkeyS.l_win !=
279 keyboard_mods._KbMkeyU._KbMkeyS.l_win ||
280 mods->_KbMkeyU._KbMkeyS.r_win !=
281 keyboard_mods._KbMkeyU._KbMkeyS.r_win)
282 {
283 emit = EINA_TRUE;
284 ev->win_changed = EINA_TRUE;
285 ev->win = mods->_KbMkeyU._KbMkeyS.r_win |
286 mods->_KbMkeyU._KbMkeyS.l_win;
287 }
288 keyboard_mods = *mods;
289
290 if (leds->_KbLedU._KbLedS.num_lock !=
291 keyboard_leds._KbLedU._KbLedS.num_lock)
292 {
293 emit = EINA_TRUE;
294 ev->num_lock_changed = EINA_TRUE;
295 ev->num_lock = leds->_KbLedU._KbLedS.num_lock;
296 }
297 if (leds->_KbLedU._KbLedS.caps_lock !=
298 keyboard_leds._KbLedU._KbLedS.caps_lock)
299 {
300 emit = EINA_TRUE;
301 ev->caps_lock_changed = EINA_TRUE;
302 ev->caps_lock = leds->_KbLedU._KbLedS.caps_lock;
303 }
304 if (leds->_KbLedU._KbLedS.scroll_lock !=
305 keyboard_leds._KbLedU._KbLedS.scroll_lock)
306 {
307 emit = EINA_TRUE;
308 ev->scroll_lock_changed = EINA_TRUE;
309 ev->scroll_lock = leds->_KbLedU._KbLedS.scroll_lock;
310 }
311 keyboard_leds = *leds;
312
313 if (emit)
314 {
315 ev->timestamp = _ecore_psl1ght_get_time ();
316 ev->modifiers = _ecore_psl1ght_get_modifiers();
317 ecore_event_add(ECORE_PSL1GHT_EVENT_KEY_MODIFIERS, ev, NULL, NULL);
318 }
319 else
320 {
321 free(ev);
322 }
323}
324
325static void
326unicodeToUtf8(u16 w, char *utf8buf)
327{
328 unsigned char *utf8s = (unsigned char *)utf8buf;
329
330 if ( w < 0x0080 )
331 {
332 utf8s[0] = ( unsigned char )w;
333 utf8s[1] = 0;
334 }
335 else if ( w < 0x0800 )
336 {
337 utf8s[0] = 0xc0 | ((w) >> 6);
338 utf8s[1] = 0x80 | ((w) & 0x3f);
339 utf8s[2] = 0;
340 }
341 else {
342 utf8s[0] = 0xe0 | ((w) >> 12);
343 utf8s[1] = 0x80 | (((w) >> 6) & 0x3f);
344 utf8s[2] = 0x80 | ((w) & 0x3f);
345 utf8s[3] = 0;
346 }
347}
348
349static Ecore_Event_Key *
350_ecore_psl1ght_event_key(u16 key)
351{
352 Ecore_Event_Key *ev;
353 char utf8[4];
354 u16 utf16;
355 unsigned int i;
356
357 ev = calloc(1, sizeof(Ecore_Event_Key));
358 if (!ev) return NULL;
359
360 ev->timestamp = _ecore_psl1ght_get_time ();
361 ev->window = 0;
362 ev->event_window = 0;
363 ev->modifiers = _ecore_psl1ght_get_modifiers();
364
365 key &= ~KB_KEYPAD;
366 for (i = 0; i < sizeof(keystable) / sizeof(struct _ecore_psl1ght_keys_s); ++i)
367 if (keystable[i].code == key)
368 {
369 ev->keyname = keystable[i].name;
370 ev->key = keystable[i].name;
371 ev->string = keystable[i].compose;
372 ev->compose = keystable[i].compose;
373
374 return ev;
375 }
376
377 utf16 = ioKbCnvRawCode (KB_MAPPING_101, keyboard_mods, keyboard_leds, key);
378 unicodeToUtf8(utf16, utf8);
379 ev->keyname = ev->key = ev->string = ev->compose = strdup (utf8);
380
381 return ev;
382}
383
384static void
385_ecore_psl1ght_mouse_move(s32 x_axis, s32 y_axis)
386{
387 Ecore_Event_Mouse_Move *ev;
388
389 ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
390 if (!ev) return;
391
392 mouse_x += x_axis;
393 mouse_y += y_axis;
394 if (mouse_x < 0) mouse_x = 0;
395 if (mouse_y < 0) mouse_y = 0;
396 if (mouse_x > window_width) mouse_x = window_width;
397 if (mouse_y > window_height) mouse_y = window_height;
398
399 ev->window = 0;
400 ev->root_window = 0;
401 ev->event_window = 0;
402 ev->same_screen = 0;
403 ev->timestamp = _ecore_psl1ght_get_time ();
404 ev->modifiers = _ecore_psl1ght_get_modifiers ();
405 ev->x = ev->root.x = mouse_x;
406 ev->y = ev->root.x = mouse_y;
407
408 ev->multi.device = 0;
409 ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
410 ev->multi.pressure = ev->multi.angle = 0;
411 ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
412
413 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
414}
415
416static void
417_ecore_psl1ght_mouse_button(int button, int pressed)
418{
419 Ecore_Event_Mouse_Button *ev;
420 static unsigned int previous_timestamp = 0;
421
422 ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
423 if (!ev) return;
424
425 ev->window = 0;
426 ev->root_window = 0;
427 ev->event_window = 0;
428 ev->same_screen = 0;
429 ev->timestamp = _ecore_psl1ght_get_time ();
430 ev->modifiers = _ecore_psl1ght_get_modifiers ();
431 ev->buttons = button;
432 if (ev->timestamp - previous_timestamp <= 500)
433 ev->double_click = 1;
434 ev->triple_click = 0;
435 previous_timestamp = ev->timestamp;
436
437 ev->x = ev->root.x = mouse_x;
438 ev->y = ev->root.y = mouse_y;
439 ev->multi.device = 0;
440 ev->multi.radius = ev->multi.radius_x = ev->multi.radius_y = 0;
441 ev->multi.pressure = ev->multi.angle = 0;
442 ev->multi.x = ev->multi.y = ev->multi.root.x = ev->multi.root.y = 0;
443
444 if (pressed)
445 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
446 else
447 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
448}
449
450static void
451_ecore_psl1ght_mouse_wheel(s8 wheel, s8 tilt)
452{
453 Ecore_Event_Mouse_Wheel *ev;
454
455 ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel));
456 if (!ev) return;
457
458 ev->timestamp = _ecore_psl1ght_get_time ();
459 ev->window = 0;
460 ev->event_window = 0;
461 ev->modifiers = _ecore_psl1ght_get_modifiers ();
462 ev->direction = 0;
463 ev->z = wheel;
464
465 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
466}
467
468static void
469_ecore_psl1ght_pad_button (const char *name, int pressed)
470{
471 Ecore_Event_Key *ev = NULL;
472
473 ev = calloc(1, sizeof(Ecore_Event_Key));
474 if (!ev) return;
475
476 ev->timestamp = _ecore_psl1ght_get_time ();
477 ev->window = 0;
478 ev->event_window = 0;
479 ev->modifiers = 0;
480
481 ev->keyname = name;
482 ev->key = name;
483 ev->string = "";
484 ev->compose = "";
485
486 if (pressed)
487 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
488 else
489 ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
490}
491
492#define PAD_STICK_DEADZONE 0x20
493
494static void
495_ecore_psl1ght_poll_joypad(void)
496{
497 padInfo padinfo;
498 int i;
499
500 /**/
501 /* Check mouse events */
502 ioPadGetInfo (&padinfo);
503
504 for (i = 0; i < 4; i++) /* Ignore the move */
505 {
506 if (padinfo.status[i])
507 {
508 int analog_h, analog_v;
509
510 if (ioPadGetData (i, &pad_data) != 0)
511 continue;
512 analog_h = pad_data.ANA_L_H - 0x80;
513 analog_v = pad_data.ANA_L_V - 0x80;
514
515 if (analog_h > PAD_STICK_DEADZONE)
516 analog_h -= PAD_STICK_DEADZONE;
517 else if (analog_h < -PAD_STICK_DEADZONE)
518 analog_h += PAD_STICK_DEADZONE;
519 else
520 analog_h = 0;
521 analog_h /= 10;
522
523 if (analog_v > PAD_STICK_DEADZONE)
524 analog_v -= PAD_STICK_DEADZONE;
525 else if (analog_v < -PAD_STICK_DEADZONE)
526 analog_v += PAD_STICK_DEADZONE;
527 else
528 analog_v = 0;
529 analog_v /= 10;
530
531 if (analog_h != 0 || analog_v != 0)
532 _ecore_psl1ght_mouse_move (analog_h, analog_v);
533
534 if (old_pad_data.BTN_CROSS ^ pad_data.BTN_CROSS) {
535 _ecore_psl1ght_pad_button ("Cross", pad_data.BTN_CROSS);
536 _ecore_psl1ght_mouse_button (1, pad_data.BTN_CROSS);
537 }
538 if (old_pad_data.BTN_CIRCLE ^ pad_data.BTN_CIRCLE) {
539 _ecore_psl1ght_pad_button ("Circle", pad_data.BTN_CIRCLE);
540 _ecore_psl1ght_mouse_button (3, pad_data.BTN_CIRCLE);
541 }
542 if (old_pad_data.BTN_SQUARE ^ pad_data.BTN_SQUARE)
543 _ecore_psl1ght_pad_button ("Square", pad_data.BTN_SQUARE);
544 if (old_pad_data.BTN_TRIANGLE ^ pad_data.BTN_TRIANGLE)
545 _ecore_psl1ght_pad_button ("Triangle", pad_data.BTN_TRIANGLE);
546 if (old_pad_data.BTN_UP ^ pad_data.BTN_UP)
547 _ecore_psl1ght_pad_button ("Up", pad_data.BTN_UP);
548 if (old_pad_data.BTN_DOWN ^ pad_data.BTN_DOWN)
549 _ecore_psl1ght_pad_button ("Down", pad_data.BTN_DOWN);
550 if (old_pad_data.BTN_LEFT ^ pad_data.BTN_LEFT)
551 _ecore_psl1ght_pad_button ("Left", pad_data.BTN_LEFT);
552 if (old_pad_data.BTN_RIGHT ^ pad_data.BTN_RIGHT)
553 _ecore_psl1ght_pad_button ("Right", pad_data.BTN_RIGHT);
554 if (old_pad_data.BTN_L1 ^ pad_data.BTN_L1)
555 _ecore_psl1ght_pad_button ("L1", pad_data.BTN_L1);
556 if (old_pad_data.BTN_L2 ^ pad_data.BTN_L2)
557 _ecore_psl1ght_pad_button ("L2", pad_data.BTN_L2);
558 if (old_pad_data.BTN_L3 ^ pad_data.BTN_L3)
559 _ecore_psl1ght_pad_button ("L3", pad_data.BTN_L3);
560 if (old_pad_data.BTN_R1 ^ pad_data.BTN_R1)
561 _ecore_psl1ght_pad_button ("R1", pad_data.BTN_R1);
562 if (old_pad_data.BTN_R2 ^ pad_data.BTN_R2)
563 _ecore_psl1ght_pad_button ("R2", pad_data.BTN_R2);
564 if (old_pad_data.BTN_R3 ^ pad_data.BTN_R3)
565 _ecore_psl1ght_pad_button ("R3", pad_data.BTN_R3);
566 if (old_pad_data.BTN_START ^ pad_data.BTN_START)
567 _ecore_psl1ght_pad_button ("Start", pad_data.BTN_START);
568 if (old_pad_data.BTN_SELECT ^ pad_data.BTN_SELECT)
569 _ecore_psl1ght_pad_button ("Select", pad_data.BTN_SELECT);
570
571 old_pad_data = pad_data;
572 }
573 }
574}
575
576static void
577_ecore_psl1ght_poll_mouse(void)
578{
579 mouseInfo mouseinfo;
580 u32 i;
581
582 /**/
583 /* Check mouse events */
584 ioMouseGetInfo(&mouseinfo);
585
586 if (mouseinfo.status[0] == 1 && !mouse_connected) // Connected
587 {
588 mouse_connected = TRUE;
589 mouse_buttons = 0;
590
591 // Old events in the queue are discarded
592 ioMouseClearBuf(0);
593 }
594 else if (mouseinfo.status[0] != 1 && mouse_connected) // Disconnected
595 {
596 mouse_connected = FALSE;
597 mouse_buttons = 0;
598 }
599
600 if (mouse_connected)
601 {
602 mouseDataList datalist;
603
604 ioMouseGetDataList(0, &datalist);
605
606 for (i = 0; i < datalist.count; i++)
607 {
608 u8 old_left = mouse_buttons & 1;
609 u8 new_left = datalist.list[i].buttons & 1;
610 u8 old_right = mouse_buttons & 2;
611 u8 new_right = datalist.list[i].buttons & 2;
612 u8 old_middle = mouse_buttons & 4;
613 u8 new_middle = datalist.list[i].buttons & 4;
614
615 if (datalist.list[i].x_axis != 0 ||
616 datalist.list[i].y_axis != 0)
617 _ecore_psl1ght_mouse_move (datalist.list[i].x_axis,
618 datalist.list[i].y_axis);
619
620 if (old_left != new_left)
621 _ecore_psl1ght_mouse_button (1, new_left);
622 if (old_middle != new_middle)
623 _ecore_psl1ght_mouse_button (2, new_middle);
624 if (old_right != new_right)
625 _ecore_psl1ght_mouse_button (3, new_right);
626
627 if (datalist.list[i].wheel != 0)
628 _ecore_psl1ght_mouse_wheel (datalist.list[i].wheel,
629 datalist.list[i].tilt);
630
631 mouse_buttons = datalist.list[i].buttons;
632 }
633 }
634}
635
636static void
637_ecore_psl1ght_poll_move(void)
638{
639 u16 new_buttons;
640 static int t_pressed = 0;
641 static int calibrated = 0;
642 static float prev_x = 0;
643 static float prev_y = 0;
644 static int gyro = 0;
645 float x, y, z;
646
647 /* Check move events */
648 processMove (move_context);
649 new_buttons = move_context->state.paddata.buttons & (~move_buttons);
650 move_buttons = move_context->state.paddata.buttons;
651
652 moveGet3DPosition (move_context, &x, &y, &z);
653 //printf ("Move 3D position is : %f, %f, %f\n", x,y,z);
654
655 switch (new_buttons) {
656 case 1:
657 gyro = !gyro;
658 break;
659
660 case 4:
661 // Move button
662 //printf ("Calibrating\n");
663 gemCalibrate (0);
664 calibrated = 1;
665 break;
666
667 case 8:
668 // start button
669 _ecore_psl1ght_mouse_move ((window_width / 2) - mouse_x, (window_height / 2) - mouse_y);
670 break;
671 }
672
673 if (calibrated)
674 {
675 float x_axis, y_axis;
676
677 if (gyro)
678 {
679 gemInertialState gem_inert;
680
681 gemGetInertialState (0, 0, 0, &gem_inert);
682 x_axis = -vec_array (gem_inert.gyro, 1) * 25;
683 y_axis = -vec_array (gem_inert.gyro, 0) * 25;
684 if (abs (x_axis) > 2 || abs (y_axis) > 2)
685 _ecore_psl1ght_mouse_move (x_axis, y_axis);
686 }
687 else {
688 x_axis = (x - prev_x) * 2.5;
689 y_axis = -(y - prev_y) * 2.5;
690 prev_x = x;
691 prev_y = y;
692 _ecore_psl1ght_mouse_move (x_axis, y_axis);
693 }
694
695 if (!t_pressed && (move_buttons & 0x2))
696 _ecore_psl1ght_mouse_button (1, 1);
697 else if (t_pressed && (move_buttons & 0x2) == 0)
698 _ecore_psl1ght_mouse_button (1, 0);
699 t_pressed = move_buttons & 0x2;
700 }
701}
702
703static void
704_ecore_psl1ght_poll_keyboard(void)
705{
706 KbInfo kbInfo;
707 int i;
708
709 /* Check keyboard events */
710 ioKbGetInfo(&kbInfo);
711
712 if (kbInfo.status[0] == 1 && !keyboard_connected)
713 {
714 /* Connected */
715 keyboard_connected = true;
716
717 // Old events in the queue are discarded
718 ioKbClearBuf(0);
719 keyboard_leds._KbLedU.leds = 0;
720 keyboard_mods._KbMkeyU.mkeys = 0;
721 keyboard_old_key = 0;
722
723 // Set raw keyboard code types to get scan codes
724 ioKbSetCodeType(0, KB_CODETYPE_RAW);
725 ioKbSetReadMode(0, KB_RMODE_INPUTCHAR);
726 }
727 else if (kbInfo.status[0] != 1 && keyboard_connected)
728 {
729 /* Disconnected keyboard */
730 keyboard_connected = FALSE;
731 }
732
733 if (keyboard_connected)
734 {
735 KbData Keys;
736
737 // Read data from the keyboard buffer
738 if (ioKbRead(0, &Keys) == 0 && Keys.nb_keycode > 0)
739 {
740 Ecore_Event_Key *ev = NULL;
741
742 _ecore_psl1ght_key_modifiers (&Keys.mkey, &Keys.led);
743
744 if (Keys.nb_keycode == 0 && keyboard_old_key != 0)
745 {
746 ev = _ecore_psl1ght_event_key (keyboard_old_key);
747 if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
748 }
749 for (i = 0; i < Keys.nb_keycode; i++)
750 {
751 if (Keys.keycode[i] != keyboard_old_key)
752 {
753 if (Keys.keycode[i] != 0)
754 {
755 ev = _ecore_psl1ght_event_key (Keys.keycode[i]);
756 if (ev)
757 ecore_event_add(ECORE_EVENT_KEY_DOWN, ev,
758 NULL, NULL);
759 }
760 else
761 {
762 ev = _ecore_psl1ght_event_key (keyboard_old_key);
763 if (ev)
764 ecore_event_add(ECORE_EVENT_KEY_UP, ev,
765 NULL, NULL);
766 }
767 keyboard_old_key = Keys.keycode[0];
768 }
769 }
770 }
771 }
772}
773
774static void
775xmb_event_handler(u64 status, u64 param, void *user_data)
776{
777 //printf ("Received event %lX\n", status);
778 switch (status) {
779 case SYSUTIL_EXIT_GAME:
780 ecore_event_add(ECORE_PSL1GHT_EVENT_QUIT, NULL, NULL, NULL);
781 break;
782 case SYSUTIL_DRAW_BEGIN:
783 ecore_event_add(ECORE_PSL1GHT_EVENT_EXPOSE, NULL, NULL, NULL);
784 case SYSUTIL_MENU_OPEN:
785 ecore_event_add(ECORE_PSL1GHT_EVENT_LOST_FOCUS, NULL, NULL, NULL);
786 break;
787 case SYSUTIL_DRAW_END:
788 ecore_event_add(ECORE_PSL1GHT_EVENT_EXPOSE, NULL, NULL, NULL);
789 case SYSUTIL_MENU_CLOSE:
790 ecore_event_add(ECORE_PSL1GHT_EVENT_GOT_FOCUS, NULL, NULL, NULL);
791 break;
792 default:
793 break;
794 }
795}
796
797EAPI void
798ecore_psl1ght_poll_events(void)
799{
800 _ecore_psl1ght_poll_joypad ();
801 _ecore_psl1ght_poll_mouse ();
802 if (move_context)
803 _ecore_psl1ght_poll_move ();
804 _ecore_psl1ght_poll_keyboard ();
805
806 sysUtilCheckCallback ();
807}
808
809EAPI void
810ecore_psl1ght_resolution_set(int width, int height)
811{
812 window_width = width;
813 window_height = height;
814 if (mouse_x > window_width) mouse_x = window_width;
815 if (mouse_y > window_height) mouse_y = window_height;
816}
817
818EAPI void
819ecore_psl1ght_screen_resolution_get(int *w, int *h)
820{
821 videoState state;
822 videoResolution resolution;
823
824 /* Get the state of the display */
825 if (videoGetState (0, 0, &state) == 0 &&
826 videoGetResolution (state.displayMode.resolution, &resolution) == 0)
827 {
828 if (w) *w = resolution.width;
829 if (h) *h = resolution.height;
830 }
831 else {
832 if (w) *w = 0;
833 if (h) *h = 0;
834 }
835}
836
837EAPI void
838ecore_psl1ght_optimal_screen_resolution_get(int *w, int *h)
839{
840 videoDeviceInfo info;
841 videoResolution res;
842 int area = 720 * 480;
843 int mode_area;
844 int i;
845
846 if (w) *w = 720;
847 if (h) *h = 480;
848
849 videoGetDeviceInfo(0, 0, &info);
850
851 for (i = 0; i < info.availableModeCount; i++) {
852 videoGetResolution (info.availableModes[i].resolution, &res);
853 mode_area = res.width * res.height;
854 if (mode_area > area)
855 {
856 area = mode_area;
857 if (w) *w = res.width;
858 if (h) *h = res.height;
859 }
860 }
861}
862
diff --git a/src/lib/ecore_psl1ght/ecore_psl1ght_private.h b/src/lib/ecore_psl1ght/ecore_psl1ght_private.h
deleted file mode 100644
index b3def7955d..0000000000
--- a/src/lib/ecore_psl1ght/ecore_psl1ght_private.h
+++ /dev/null
@@ -1,36 +0,0 @@
1#ifndef _ECORE_PSL1GHT_PRIVATE_H
2# define _ECORE_PSL1GHT_PRIVATE_H
3
4extern int _ecore_psl1ght_log_dom;
5
6# ifdef ECORE_PSL1GHT_DEFAULT_LOG_COLOR
7# undef ECORE_PSL1GHT_DEFAULT_LOG_COLOR
8# endif
9# define ECORE_PSL1GHT_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
10
11# ifdef ERR
12# undef ERR
13# endif
14# define ERR(...) EINA_LOG_DOM_ERR(_ecore_psl1ght_log_dom, __VA_ARGS__)
15
16# ifdef DBG
17# undef DBG
18# endif
19# define DBG(...) EINA_LOG_DOM_DBG(_ecore_psl1ght_log_dom, __VA_ARGS__)
20
21# ifdef INF
22# undef INF
23# endif
24# define INF(...) EINA_LOG_DOM_INFO(_ecore_psl1ght_log_dom, __VA_ARGS__)
25
26# ifdef WRN
27# undef WRN
28# endif
29# define WRN(...) EINA_LOG_DOM_WARN(_ecore_psl1ght_log_dom, __VA_ARGS__)
30
31# ifdef CRI
32# undef CRI
33# endif
34# define CRI(...) EINA_LOG_DOM_CRIT(_ecore_psl1ght_log_dom, __VA_ARGS__)
35
36#endif
diff --git a/src/lib/ecore_psl1ght/gemutil.c b/src/lib/ecore_psl1ght/gemutil.c
deleted file mode 100644
index 9ccfc1c861..0000000000
--- a/src/lib/ecore_psl1ght/gemutil.c
+++ /dev/null
@@ -1,281 +0,0 @@
1#include <stdio.h>
2#include <io/move.h>
3#include <sys/memory.h>
4#include <ppu-types.h>
5#include <io/camera.h>
6#include <ppu-types.h>
7#include <spurs/spurs.h>
8#include <sys/spu.h>
9#include <sys/thread.h>
10#include <sys/systime.h>
11
12#define SPURS_DEFAULT_PREFIX_NAME "gem_spurs"
13
14u16 oldGemPad = 0;
15u16 newGemPad = 0;
16u16 newGemAnalogT = 0;
17extern cameraReadInfo camread;
18
19static inline float
20vec_array(vec_float4 vec, unsigned int idx)
21{
22 union {
23 vec_float4 vec;
24 float array[4];
25 } v;
26
27 v.vec = vec;
28
29 if (idx > 3)
30 return -1;
31 return v.array[idx];
32}
33
34int
35initMove()
36{
37 Spurs *spurs;
38 gemAttribute gem_attr;
39 u8 gem_spu_priorities[8] = { 1, 0, 0, 0, 0, 0, 0, 0 };
40 int ret;
41 int i;
42
43 spurs = initSpurs (NULL);
44
45 if (spurs == NULL)
46 goto error;
47
48 printf ("preparing GemAttribute structure with spurs\n");
49
50 initAttributeGem (&gem_attr, 1, NULL, spurs, gem_spu_priorities);
51 gem_attr->version = 2;
52 gem_attr->max = 1;
53 gem_attr->spurs = spurs;
54 gem_attr->memory = NULL;
55 gem_attr->spu_priorities[0] = 1;
56 for (i = 1; i < 8; ++i)
57 gem_attr->spu_priorities[i] = 0;
58
59 printf ("calling GemInit with GemAttribute structure version=%d max_connect=%d spurs=%X\n",
60 gem_attr.version, gem_attr.max, gem_attr.spurs);
61 ret = gemInit (&gem_attr);
62 printf ("return from GemInit %X \n", ret);
63 if (ret)
64 goto error;
65
66 ret = gemPrepareCamera (128, 0.5);
67 printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5\n",
68 ret);
69 if (ret)
70 goto error;
71 ret = gemReset (0);
72 printf ("GemReset return %X \n", ret);
73 if (ret)
74 goto error;
75 return ret;
76
77error:
78 if (spurs)
79 endSpurs (spurs);
80 return NULL;
81}
82
83int
84endMove()
85{
86 endSpurs (spurs);
87 gemEnd ();
88 return 0;
89}
90
91int
92proccessGem(int t)
93{
94 int ret;
95
96 switch (t) {
97 case 0:
98
99 ret = gemUpdateStart (camread.buffer, camread.timestamp);
100
101 if (ret != 0)
102 {
103 printf ("Return from gemUpdateStart %X\n", ret);
104 }
105 break;
106
107 case 2:
108
109 ret = gemUpdateFinish ();
110 if (ret != 0)
111 {
112 printf ("Return from gemUpdateFinish %X\n", ret);
113 }
114 break;
115
116 case 3:
117 ret = gemConvertVideoFinish ();
118 if (ret != 0)
119 {
120 printf ("Return from gemConvertVideoFinish %X\n", ret);
121 }
122 break;
123
124 default:
125 ret = -1;
126 break;
127 }
128 return ret;
129}
130
131void
132readGemPad(int num_gem)
133{
134 gemState gem_state;
135 int ret;
136 unsigned int hues[] = { 4 << 24, 4 << 24, 4 << 24, 4 << 24 };
137 ret = gemGetState (0, 0, -22000, &gem_state);
138
139 newGemPad = gem_state.paddata.buttons & (~oldGemPad);
140 newGemAnalogT = gem_state.paddata.ANA_T;
141 oldGemPad = gem_state.paddata.buttons;
142
143 switch (ret) {
144 case 2:
145 gemForceRGB (num_gem, 0.5, 0.5, 0.5);
146 break;
147
148 case 5:
149
150 gemTrackHues (hues, NULL);
151 break;
152
153 default:
154 break;
155 }
156}
157
158void
159readGemAccPosition(int num_gem)
160{
161 vec_float4 position;
162
163 gemGetAccelerometerPositionInDevice (num_gem, &position);
164
165 printf (" accelerometer device coordinates [%f,%f,%f,%f]\n",
166 vec_array (position, 0), vec_array (position, 1), vec_array (position, 2),
167 vec_array (position, 3));
168}
169
170void
171readGemInertial(int num_gem)
172{
173 gemInertialState gem_inertial_state;
174 int ret;
175
176 ret = gemGetInertialState (num_gem, 0, -22000, &gem_inertial_state);
177 printf ("gemGetInertialState return %X\n", ret);
178 printf ("counter %d temperature %f\n", gem_inertial_state.counter,
179 gem_inertial_state.temperature);
180
181 printf (" accelerometer sensor [%f,%f,%f,%f]\n",
182 vec_array (gem_inertial_state.accelerometer, 0),
183 vec_array (gem_inertial_state.accelerometer, 1),
184 vec_array (gem_inertial_state.accelerometer, 2),
185 vec_array (gem_inertial_state.accelerometer, 3));
186
187 printf (" accelerometer_bias sensor [%f,%f,%f,%f]\n",
188 vec_array (gem_inertial_state.accelerometer_bias, 0),
189 vec_array (gem_inertial_state.accelerometer_bias, 1),
190 vec_array (gem_inertial_state.accelerometer_bias, 2),
191 vec_array (gem_inertial_state.accelerometer_bias, 3));
192
193 printf (" gyro sensor [%f,%f,%f,%f]\n", vec_array (gem_inertial_state.gyro,
194 0), vec_array (gem_inertial_state.gyro, 1),
195 vec_array (gem_inertial_state.gyro, 2),
196 vec_array (gem_inertial_state.gyro, 3));
197
198 printf (" gyro_bias sensor [%f,%f,%f,%f]\n",
199 vec_array (gem_inertial_state.gyro_bias, 0),
200 vec_array (gem_inertial_state.gyro_bias, 1),
201 vec_array (gem_inertial_state.gyro_bias, 2),
202 vec_array (gem_inertial_state.gyro_bias, 3));
203}
204
205void
206readGem()
207{
208 gemState gem_state;
209 proccessGem (0);
210
211 proccessGem (2);
212
213 readGemPad (0); // This will read buttons from Move
214 switch (newGemPad) {
215 case 1:
216 printf ("Select pressed \n");
217 break;
218
219 case 2:
220 printf ("T pressed value %d\n", newGemAnalogT);
221 printf
222 ("Frame %d center of the sphere in world coordinates %f %f %f %f \n",
223 camread.frame, vec_array (gem_state.pos, 0), vec_array (gem_state.pos,
224 1), vec_array (gem_state.pos, 2), vec_array (gem_state.pos, 3));
225 break;
226
227 case 4:
228 printf ("Move pressed \n");
229 gemCalibrate (0);
230 break;
231
232 case 8:
233 printf ("Start pressed \n");
234 pos_x = 0;
235 pos_y = 0;
236 break;
237
238 case 16:
239 printf ("Triangle pressed \n");
240 getImageState ();
241 break;
242
243 case 32:
244 printf ("Circle pressed \n");
245 break;
246
247 case 64:
248 printf ("Cross pressed \n");
249 printf ("X,Y,Z position (mm) %f %f %f\n", vec_array (gem_state.pos, 0),
250 vec_array (gem_state.pos, 1), vec_array (gem_state.pos, 2));
251 readGemAccPosition (0);
252 break;
253
254 case 128:
255 printf ("Square pressed \n");
256 readGemInertial (0);
257 break;
258
259 default:
260 break;
261 }
262}
263
264void
265getImageState()
266{
267 int ret;
268
269 gemImageState imgState;
270
271 gemGetImageState (0, &imgState);
272 printf (" u [%f]\n", imgState.u);
273 printf (" v [%f]\n", imgState.v);
274 printf (" r [%f]\n", imgState.r);
275 printf (" projectionx [%f]\n", imgState.projectionx);
276 printf (" projectiony [%f]\n", imgState.projectiony);
277 printf (" distance [%f]\n", imgState.distance);
278 printf ("visible=%d r_valid=%d\n", imgState.visible, imgState.r_valid);
279 printf ("tiemestamp=%Ld\n", imgState.frame_time);
280}
281
diff --git a/src/lib/ecore_psl1ght/gemutil.h b/src/lib/ecore_psl1ght/gemutil.h
deleted file mode 100644
index ce4b544589..0000000000
--- a/src/lib/ecore_psl1ght/gemutil.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * Copyright (C) Antonio José Ramos Márquez (bigboss)
3 * Copyright (C) Youness Alaoui (KaKaRoTo)
4 */
5
6#ifndef __GEMUTIL_H__
7#define __GEMUTIL_H__
8
9#include <ppu-types.h>
10#include <spurs/spurs.h>
11#include <io/camera.h>
12#include <io/move.h>
13
14typedef struct
15{
16 Spurs *spurs;
17} moveContext;
18
19#endif /* __GEMUTIL_H__ */
diff --git a/src/lib/ecore_psl1ght/moveutil.c b/src/lib/ecore_psl1ght/moveutil.c
deleted file mode 100644
index 1dadfbc4b9..0000000000
--- a/src/lib/ecore_psl1ght/moveutil.c
+++ /dev/null
@@ -1,245 +0,0 @@
1#include <stdio.h>
2#include <io/move.h>
3#include <sys/memory.h>
4#include <ppu-types.h>
5#include <io/camera.h>
6#include <ppu-types.h>
7#include <spurs/spurs.h>
8#include <sys/thread.h>
9#include <sys/systime.h>
10
11#include "spursutil.h"
12#include "moveutil.h"
13
14u16 oldGemPad = 0;
15u16 newGemPad = 0;
16u16 newGemAnalogT = 0;
17
18static void
19endCamera(moveContext *context)
20{
21 cameraStop (0);
22
23 cameraClose (0);
24 cameraEnd ();
25
26 sysMemContainerDestroy (context->camInfo.container);
27}
28
29static int
30initCamera(moveContext *context)
31{
32 int ret;
33
34 context->camInfo.container = NULL;
35
36 ret = cameraInit ();
37 printf ("cameraInit() returned %d\n", ret);
38 if (ret == 0)
39 {
40 cameraType type = CAM_TYPE_UNKNOWN;
41
42 ret = cameraGetType (0, &type);
43 if (ret == 0 && type == CAM_TYPE_PLAYSTATION_EYE)
44 {
45 context->camInfo.format = CAM_FORM_RAW8;
46 context->camInfo.framerate = 60;
47 context->camInfo.resolution = CAM_RESO_VGA;
48 context->camInfo.info_ver = 0x0101;
49 ret = sysMemContainerCreate (&context->camInfo.container, 0x200000);
50 printf ("sysMemContainerCreate() for camera container returned %d\n", ret);
51
52 ret = cameraOpenEx (0, &context->camInfo);
53 switch (ret) {
54 case 0:
55 printf ("Found me an eye, arrr!\n");
56 printf ("cameraOpenEx returned %08X\n", ret);
57 printf ("Video dimensions: %dx%d\n", context->camInfo.width, context->camInfo.height);
58 printf ("Buffer at %08X\n", context->camInfo.buffer);
59 printf ("pbuf0 Buffer at %08X\n", context->camInfo.pbuf[0]);
60 printf ("pbuf0 Buffer at %08X\n", context->camInfo.pbuf[1]);
61 printf ("context->camInfo.info_ver %X\n", context->camInfo.info_ver);
62
63 context->camRead.buffer = context->camInfo.buffer;
64 context->camRead.version = 0x0100;
65 printf ("Setting CameraReadEx %08X buffer to cameraInfoex buffer \n",
66 context->camRead.buffer);
67 break;
68
69 default:
70 printf ("Error %X detected opening PlayStation Eye\n", ret);
71 goto error;
72 }
73 }
74 else {
75 printf ("Device detected is not a PlayStation Eye and this sample need it\n");
76 goto error;
77 }
78 }
79 else {
80 goto error;
81 }
82 return ret;
83
84error:
85 if (context->camInfo.container)
86 sysMemContainerDestroy (context->camInfo.container);
87 return ret;
88}
89
90static int
91readCamera(moveContext *context)
92{
93 int ret;
94
95 ret = cameraReadEx (0, &context->camRead);
96 switch (ret) {
97 case CAMERA_ERRO_NEED_START:
98 cameraReset (0);
99 ret = gemPrepareCamera (128, 0.5);
100 printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5 before cameraStart\n",
101 ret);
102 printf ("lets go!! It's time to look your face in Sony Bravia :P\n");
103 ret = cameraStart (0);
104 printf ("cameraStart return %d \n", ret);
105 printf ("*******************************************\n");
106 printf ("* Now make sure you have a Move connected\n");
107 printf ("* and point it towards the camera and press\n");
108 printf ("* the action button to calibrate\n");
109 printf ("*******************************************\n");
110 break;
111
112 case 0:
113 break;
114
115 default:
116 printf ("error %08X ", ret);
117 ret = 1;
118 break;
119 }
120 // printf("despues de start return %d \n",ret);
121 if (ret == 0 && context->camRead.readcount != 0)
122 {
123 return context->camRead.readcount;
124 }
125 else {
126 return 0;
127 }
128}
129
130moveContext *
131initMove()
132{
133 moveContext *context = NULL;
134 Spurs *spurs;
135 gemAttribute gem_attr;
136 int ret;
137 int i;
138
139 spurs = initSpurs ("gem_spurs");
140
141 if (spurs == NULL)
142 goto error;
143
144 printf ("preparing GemAttribute structure with spurs\n");
145
146 gem_attr.version = 2;
147 gem_attr.max = 1;
148 gem_attr.spurs = spurs;
149 gem_attr.memory = NULL;
150 gem_attr.spu_priorities[0] = 1;
151 for (i = 1; i < 8; ++i)
152 gem_attr.spu_priorities[i] = 0;
153
154 printf ("calling GemInit with GemAttribute structure version=%d max_connect=%d spurs=%X\n",
155 gem_attr.version, gem_attr.max, gem_attr.spurs);
156 ret = gemInit (&gem_attr);
157 printf ("return from GemInit %X \n", ret);
158 if (ret)
159 goto error;
160
161 ret = gemPrepareCamera (128, 0.5);
162 printf ("GemPrepareCamera return %d exposure set to 128 and quality to 0.5\n",
163 ret);
164 if (ret)
165 goto error;
166 ret = gemReset (0);
167 printf ("GemReset return %X \n", ret);
168 if (ret)
169 goto error;
170
171 context = (moveContext *)malloc (sizeof (moveContext));
172 context->spurs = spurs;
173 ret = initCamera (context);
174
175 if (ret == 0)
176 return context;
177
178error:
179 if (spurs)
180 endSpurs (spurs);
181 if (context)
182 free (context);
183 return NULL;
184}
185
186void
187endMove(moveContext *context)
188{
189 /* Stop Move */
190 gemEnd ();
191 /* Stop Camera */
192 endCamera (context);
193 /* Stop Spurs */
194 endSpurs (context->spurs);
195
196 free (context);
197}
198
199int
200processMove(moveContext *context)
201{
202 const unsigned int hues[] = { 4 << 24, 4 << 24, 4 << 24, 4 << 24 };
203 int ret = -1;
204
205 if (readCamera (context) > 0)
206 {
207 ret = gemUpdateStart (context->camRead.buffer, context->camRead.timestamp);
208 //printf ("Return from gemUpdateStart %X\n", ret);
209 if (ret == 0)
210 {
211 ret = gemUpdateFinish ();
212 //printf ("Return from gemUpdateFinish %X\n", ret);
213 if (ret == 0)
214 {
215 ret = gemGetState (0, STATE_LATEST_IMAGE_TIME, 0, &context->state);
216 switch (ret) {
217 case 2:
218 gemForceRGB (0, 0.5, 0.5, 0.5);
219 break;
220
221 case 5:
222 gemTrackHues (hues, NULL);
223 break;
224
225 default:
226 break;
227 }
228 }
229 }
230 }
231
232 return ret;
233}
234
235void
236moveGet3DPosition(moveContext *context, float *x, float *y, float *z)
237{
238 if (x)
239 *x = vec_array (context->state.pos, 0);
240 if (y)
241 *y = vec_array (context->state.pos, 1);
242 if (z)
243 *z = vec_array (context->state.pos, 2);
244}
245
diff --git a/src/lib/ecore_psl1ght/moveutil.h b/src/lib/ecore_psl1ght/moveutil.h
deleted file mode 100644
index bb4b22c09d..0000000000
--- a/src/lib/ecore_psl1ght/moveutil.h
+++ /dev/null
@@ -1,43 +0,0 @@
1/*
2 * Copyright (C) Antonio José Ramos Márquez (bigboss)
3 * Copyright (C) Youness Alaoui (KaKaRoTo)
4 */
5
6#ifndef __MOVEUTIL_H__
7#define __MOVEUTIL_H__
8
9#include <ppu-types.h>
10#include <spurs/spurs.h>
11#include <io/camera.h>
12#include <io/move.h>
13
14typedef struct
15{
16 Spurs *spurs;
17 cameraInfoEx camInfo;
18 cameraReadInfo camRead;
19 gemState state;
20} moveContext;
21
22static inline float
23vec_array(vec_float4 vec, unsigned int idx)
24{
25 union {
26 vec_float4 vec;
27 float array[4];
28 } v;
29
30 v.vec = vec;
31
32 if (idx > 3)
33 return -1;
34 return v.array[idx];
35}
36
37moveContext *initMove();
38void endMove(moveContext *context);
39void readGemState(moveContext *context);
40int processMove(moveContext *context);
41void moveGet3DPosition(moveContext *context, float *x, float *y, float *z);
42
43#endif /* __MOVEUTIL_H__ */
diff --git a/src/lib/ecore_psl1ght/spursutil.c b/src/lib/ecore_psl1ght/spursutil.c
deleted file mode 100644
index 27b5c1d635..0000000000
--- a/src/lib/ecore_psl1ght/spursutil.c
+++ /dev/null
@@ -1,62 +0,0 @@
1#include "spursutil.h"
2#include <sys/spu.h>
3
4#define SPURS_DEFAULT_PREFIX_NAME "spursutil"
5
6Spurs *
7initSpurs(const char *prefix_name)
8{
9 Spurs *spurs = NULL;
10 SpursAttribute attributeSpurs;
11 int ret;
12 int i;
13
14 ret = sysSpuInitialize (6, 0);
15 printf ("sysSpuInitialize return %d\n", ret);
16
17 /* initialize spurs */
18 printf ("Initializing spurs\n");
19 spurs = (void *)memalign (SPURS_ALIGN, sizeof (Spurs));
20 printf ("Initializing spurs attribute\n");
21
22 ret = spursAttributeInitialize (&attributeSpurs, 5, 250, 1000, true);
23 if (ret)
24 {
25 printf ("error : spursAttributeInitialize failed %x\n", ret);
26 goto error;
27 }
28
29 printf ("Setting name prefix\n");
30 if (!prefix_name)
31 prefix_name = SPURS_DEFAULT_PREFIX_NAME;
32 ret = spursAttributeSetNamePrefix (&attributeSpurs,
33 prefix_name, strlen (prefix_name));
34 if (ret)
35 {
36 printf ("error : spursAttributeInitialize failed %x\n", ret);
37 goto error;
38 }
39
40 printf ("Initializing with attribute\n");
41 ret = spursInitializeWithAttribute (spurs, &attributeSpurs);
42 if (ret)
43 {
44 printf ("error: spursInitializeWithAttribute failed %x\n", ret);
45 goto error;
46 }
47
48 return spurs;
49
50error:
51 if (spurs)
52 free (spurs);
53 return NULL;
54}
55
56void
57endSpurs(Spurs *spurs)
58{
59 spursFinalize (spurs);
60 free (spurs);
61}
62
diff --git a/src/lib/ecore_psl1ght/spursutil.h b/src/lib/ecore_psl1ght/spursutil.h
deleted file mode 100644
index 0b35030be3..0000000000
--- a/src/lib/ecore_psl1ght/spursutil.h
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * Copyright (C) Antonio José Ramos Márquez (bigboss)
3 * Copyright (C) Youness Alaoui (KaKaRoTo)
4 */
5
6#ifndef __SPURSUTIL_H__
7#define __SPURSUTIL_H__
8
9#include <ppu-types.h>
10#include <spurs/spurs.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/* Initialize spurs with a given name prefix (*/
17Spurs *initSpurs(const char *prefix_name);
18void endSpurs(Spurs *spurs);
19
20#ifdef __cplusplus
21}
22#endif
23
24#endif /* __SPURSUTIL_H__ */