diff --git a/driver.h b/driver.h index f7827dde4c..181b088939 100644 --- a/driver.h +++ b/driver.h @@ -271,6 +271,7 @@ enum input_devices #elif defined(__BLACKBERRY_QNX__) DEVICE_NONE, DEVICE_WIIMOTE, + DEVICE_KEYBOARD, DEVICE_UNKNOWN, #endif DEVICE_LAST diff --git a/playbook/qnx_input.c b/playbook/qnx_input.c index 9039d10605..a00db4e84e 100644 --- a/playbook/qnx_input.c +++ b/playbook/qnx_input.c @@ -34,6 +34,7 @@ static unsigned touch_count; //Internal helper functions #ifdef HAVE_BB10 +#include static unsigned pads_connected; typedef struct { @@ -136,6 +137,10 @@ static void qnx_input_autodetect_gamepad(Gamepad_t* controller) { device = DEVICE_WIIMOTE; } + else if (strstr(controller->id, "0A5C-8502")) + { + device = DEVICE_KEYBOARD; + } else if (controller->id) { device = DEVICE_UNKNOWN; @@ -159,17 +164,21 @@ static void loadController(Gamepad_t* controller) screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_ID_STRING, sizeof(controller->id), controller->id); screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_VENDOR, sizeof(controller->id), controller->vendor); screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_PRODUCT, sizeof(controller->id), controller->product); - screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount); - // Check for the existence of analog sticks. - if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0)) + if (controller->type == SCREEN_EVENT_GAMEPAD || controller->type == SCREEN_EVENT_JOYSTICK) { - ++controller->analogCount; - } + screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount); - if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1)) - { - ++controller->analogCount; + // Check for the existence of analog sticks. + if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0)) + { + ++controller->analogCount; + } + + if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1)) + { + ++controller->analogCount; + } } //Screen service will map supported controllers, we still might need to adjust. @@ -179,10 +188,14 @@ static void loadController(Gamepad_t* controller) { RARCH_LOG("Gamepad Device Connected:\n"); } - else + else if (controller->type == SCREEN_EVENT_JOYSTICK) { RARCH_LOG("Joystick Device Connected:\n"); } + else if (controller->type == SCREEN_EVENT_KEYBOARD) + { + RARCH_LOG("Keyboard Device Connected:\n"); + } RARCH_LOG("\tID: %s\n", controller->id); RARCH_LOG("\tVendor: %s\n", controller->vendor); @@ -207,7 +220,7 @@ static void discoverControllers() int type; screen_get_device_property_iv(devices_found[i], SCREEN_PROPERTY_TYPE, &type); - if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK) + if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD) { devices[pads_connected].handle = devices_found[i]; loadController(&devices[pads_connected]); @@ -222,8 +235,58 @@ static void discoverControllers() free(devices_found); } -#endif + +static void process_keyboard_event(screen_event_t event, int type) +{ + //Get Keyboard state + int sym = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym); + int modifiers = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers); + int flags = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags); + int scan = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan); + int cap = 0; + screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap); + + //Find device that pressed the key + screen_device_t device; + screen_get_event_property_pv(event, SCREEN_PROPERTY_DEVICE, (void**)&device); + + Gamepad_t* controller = NULL; + int i; + for (i = 0; i < MAX_PADS; ++i) + { + if (device == devices[i].handle) + { + controller = &devices[i]; + break; + } + } + + if (!controller) + return; + + int b; + for (b = 0; b < RARCH_FIRST_CUSTOM_BIND; ++b) + { + if ((unsigned int)g_settings.input.binds[i][b].joykey == (unsigned int)(sym&0xFF)) + { + if (flags & KEY_DOWN) + { + controller->buttons |= 1 << b; + } + else + { + controller->buttons &= ~(1<