summaryrefslogtreecommitdiff
path: root/src/lib/ecore_input
diff options
context:
space:
mode:
authorShinwoo Kim <cinoo.kim@samsung.com>2017-02-01 16:33:52 +0900
committerShinwoo Kim <cinoo.kim@samsung.com>2017-02-01 16:35:08 +0900
commit5c9617c2cfda6dfffc26c90b212581013786262f (patch)
tree37c90454103497dea651532a24ff14ebffde027b /src/lib/ecore_input
parent1d60f42e63930a26272df0b025cabc5c93dd0c73 (diff)
ecore_input: support Xbox One joystick
Add joystick mapper for Microsoft X-Box One pad (Covert Forces)
Diffstat (limited to 'src/lib/ecore_input')
-rw-r--r--src/lib/ecore_input/ecore_input_joystick.c111
1 files changed, 108 insertions, 3 deletions
diff --git a/src/lib/ecore_input/ecore_input_joystick.c b/src/lib/ecore_input/ecore_input_joystick.c
index 7913a0ef7f..33ce129f3a 100644
--- a/src/lib/ecore_input/ecore_input_joystick.c
+++ b/src/lib/ecore_input/ecore_input_joystick.c
@@ -23,7 +23,8 @@ static int _ecore_input_joystick_init_count = 0;
23#ifdef HAVE_EEZE 23#ifdef HAVE_EEZE
24 24
25typedef void (*Joystick_Mapper)(struct js_event *event, Ecore_Event_Joystick *e); 25typedef void (*Joystick_Mapper)(struct js_event *event, Ecore_Event_Joystick *e);
26static void _joystick_xiinput_mapper(struct js_event *event, Ecore_Event_Joystick *e); 26static void _joystick_xbox360_mapper(struct js_event *event, Ecore_Event_Joystick *e);
27static void _joystick_xboxone_mapper(struct js_event *event, Ecore_Event_Joystick *e);
27static void _joystick_ps4_mapper(struct js_event *event, Ecore_Event_Joystick *e); 28static void _joystick_ps4_mapper(struct js_event *event, Ecore_Event_Joystick *e);
28 29
29struct _Joystick_Info 30struct _Joystick_Info
@@ -41,7 +42,8 @@ struct _Joystick_Mapping_Info
41 const char *product; 42 const char *product;
42 Joystick_Mapper mapper; 43 Joystick_Mapper mapper;
43} Joystick_Mapping_Info[] = { 44} Joystick_Mapping_Info[] = {
44 {"045e", "028e", _joystick_xiinput_mapper}, /* Microsoft X-Box 360 pad */ 45 {"045e", "028e", _joystick_xbox360_mapper}, /* Microsoft X-Box 360 pad */
46 {"045e", "02dd", _joystick_xboxone_mapper}, /* Microsoft X-Box One pad (Covert Forces) */
45 {"054c", "05c4", _joystick_ps4_mapper} /* Sony Computer Entertainment Wireless Controller */ 47 {"054c", "05c4", _joystick_ps4_mapper} /* Sony Computer Entertainment Wireless Controller */
46}; 48};
47 49
@@ -169,7 +171,7 @@ _joystick_ps4_mapper(struct js_event *event, Ecore_Event_Joystick *e)
169} 171}
170 172
171static void 173static void
172_joystick_xiinput_mapper(struct js_event *event, Ecore_Event_Joystick *e) 174_joystick_xbox360_mapper(struct js_event *event, Ecore_Event_Joystick *e)
173{ 175{
174 if (event->type == JS_EVENT_BUTTON) 176 if (event->type == JS_EVENT_BUTTON)
175 { 177 {
@@ -272,6 +274,109 @@ _joystick_xiinput_mapper(struct js_event *event, Ecore_Event_Joystick *e)
272} 274}
273 275
274static void 276static void
277_joystick_xboxone_mapper(struct js_event *event, Ecore_Event_Joystick *e)
278{
279 if (event->type == JS_EVENT_BUTTON)
280 {
281 e->type = ECORE_EVENT_JOYSTICK_EVENT_TYPE_BUTTON;
282 e->button.value = event->value;
283 switch (event->number)
284 {
285 case 0:
286 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_FACE_0;
287 break;
288
289 case 1:
290 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_FACE_1;
291 break;
292
293 case 2:
294 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_FACE_2;
295 break;
296
297 case 3:
298 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_FACE_3;
299 break;
300
301 case 4:
302 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_LEFT_SHOULDER;
303 break;
304
305 case 5:
306 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_RIGHT_SHOULDER;
307 break;
308
309 case 6:
310 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_META;
311 break;
312
313 case 7:
314 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_SELECT;
315 break;
316
317 case 8:
318 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_START;
319 break;
320
321 case 9:
322 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_LEFT_ANALOG_STICK;
323 break;
324
325 case 10:
326 e->button.index = ECORE_EVENT_JOYSTICK_BUTTON_RIGHT_ANALOG_STICK;
327 break;
328
329 default:
330 ERR("Unsupported joystick event: %d", event->number);
331 break;
332 }
333 }
334 else
335 {
336 e->type = ECORE_EVENT_JOYSTICK_EVENT_TYPE_AXIS;
337 e->axis.value = event->value / 32767.0f;;
338 switch (event->number)
339 {
340 case 0:
341 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_LEFT_ANALOG_HOR;
342 break;
343
344 case 1:
345 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_LEFT_ANALOG_VER;
346 break;
347
348 case 2:
349 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_LEFT_SHOULDER;
350 break;
351
352 case 3:
353 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_RIGHT_ANALOG_HOR;
354 break;
355
356 case 4:
357 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_RIGHT_ANALOG_VER;
358 break;
359
360 case 5:
361 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_RIGHT_SHOULDER;
362 break;
363
364 case 6:
365 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_HAT_X;
366 break;
367
368 case 7:
369 e->axis.index = ECORE_EVENT_JOYSTICK_AXIS_HAT_Y;
370 break;
371
372 default:
373 ERR("Unsupported joystick event: %d", event->number);
374 break;
375 }
376 }
377}
378
379static void
275_joystick_event_add(struct js_event *event, Joystick_Info *ji) 380_joystick_event_add(struct js_event *event, Joystick_Info *ji)
276{ 381{
277 Ecore_Event_Joystick *e; 382 Ecore_Event_Joystick *e;