static void *qnx_input_init(const char *joypad_driver) { int i; qnx_input_t *qnx = (qnx_input_t*)calloc(1, sizeof(*qnx)); if (!qnx) return NULL; input_keymaps_init_keyboard_lut(rarch_key_map_qnx); for (i = 0; i < MAX_TOUCH; ++i) { qnx->pointer[i].contact_id = -1; qnx->touch_map[i] = -1; } qnx->joypad = input_joypad_init_driver(joypad_driver, qnx); for (i = 0; i < MAX_PADS; ++i) { qnx_init_controller(qnx, &qnx->devices[i]); } #ifdef HAVE_BB10 qnx_discover_controllers(qnx); #else /* Initialize Playbook keyboard. */ strlcpy(qnx->devices[0].id, "0A5C-8502", sizeof(qnx->devices[0].id)); qnx_input_autodetect_gamepad(qnx, &qnx->devices[0]); qnx->pads_connected = 1; #endif return qnx; }
/* Find currently connected gamepads. */ static void qnx_discover_controllers(qnx_input_t *qnx) { /* Get an array of all available devices. */ int deviceCount; unsigned i; screen_get_context_property_iv(screen_ctx, SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount); screen_device_t* devices_found = (screen_device_t*) calloc(deviceCount, sizeof(screen_device_t)); screen_get_context_property_pv(screen_ctx, SCREEN_PROPERTY_DEVICES, (void**)devices_found); /* Scan the list for gamepad and joystick devices. */ for(i = 0; i < qnx->pads_connected; ++i) { qnx_init_controller(qnx, &qnx->devices[i]); } qnx->pads_connected = 0; for (i = 0; i < deviceCount; i++) { int type; screen_get_device_property_iv( devices_found[i], SCREEN_PROPERTY_TYPE, &type); if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD) { qnx->devices[qnx->pads_connected].handle = devices_found[i]; qnx->devices[qnx->pads_connected].index = qnx->pads_connected; qnx_handle_device(qnx, &qnx->devices[qnx->pads_connected]); if (qnx->pads_connected == MAX_PADS) break; } } free(devices_found); }
static void *qnx_input_init(void) { int i; settings_t *settings = config_get_ptr(); qnx_input_t *qnx = (qnx_input_t*)calloc(1, sizeof(*qnx)); if (!qnx) return NULL; for (i = 0; i < MAX_TOUCH; ++i) { qnx->pointer[i].contact_id = -1; qnx->touch_map[i] = -1; } qnx->joypad = input_joypad_init_driver( settings->input.joypad_driver, qnx); for (i = 0; i < MAX_PADS; ++i) { qnx_init_controller(qnx, &qnx->devices[i]); qnx->port_device[i] = 0; } #ifdef HAVE_BB10 qnx_discover_controllers(qnx); #else /* Initialize Playbook keyboard. */ strlcpy(qnx->devices[0].id, "0A5C-8502", sizeof(qnx->devices[0].id)); qnx_input_autodetect_gamepad(qnx, &qnx->devices[0], 0); qnx->pads_connected = 1; #endif return qnx; }
static void qnx_handle_screen_event(qnx_input_t *qnx, bps_event_t *event) { int type; screen_event_t screen_event = screen_event_get_event(event); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &type); switch(type) { case SCREEN_EVENT_MTOUCH_TOUCH: case SCREEN_EVENT_MTOUCH_RELEASE: case SCREEN_EVENT_MTOUCH_MOVE: qnx_process_touch_event(qnx, screen_event, type); break; case SCREEN_EVENT_KEYBOARD: qnx_process_keyboard_event(qnx, screen_event, type); break; #ifdef HAVE_BB10 case SCREEN_EVENT_GAMEPAD: case SCREEN_EVENT_JOYSTICK: qnx_process_gamepad_event(qnx, screen_event, type); break; case SCREEN_EVENT_DEVICE: { /* A device was attached or removed. */ screen_device_t device; int attached, type, i; screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device); screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ATTACHED, &attached); if (attached) screen_get_device_property_iv(device, SCREEN_PROPERTY_TYPE, &type); if (attached && ( type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD) ) { for (i = 0; i < MAX_PADS; ++i) { if (!qnx->devices[i].handle) { qnx->devices[i].handle = device; qnx_handle_device(qnx, &qnx->devices[i]); break; } } } else { for (i = 0; i < MAX_PADS; ++i) { if (device == qnx->devices[i].handle) { RARCH_LOG("Device %s: Disconnected.\n", qnx->devices[i].id); qnx_init_controller(qnx, &qnx->devices[i]); break; } } } } break; #endif default: break; } }