mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 09:39:56 +00:00
Indenting / style nits
This commit is contained in:
parent
3d931d946e
commit
689cd6322f
@ -64,13 +64,19 @@ static bool android_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
unsigned h = GET_HAT(joykey);
|
unsigned h = GET_HAT(joykey);
|
||||||
if (h > 0)
|
if (h > 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (GET_HAT_DIR(joykey))
|
switch (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
case HAT_LEFT_MASK: return android->hat_state[port_num][0] == -1;
|
case HAT_LEFT_MASK:
|
||||||
case HAT_RIGHT_MASK: return android->hat_state[port_num][0] == 1;
|
return android->hat_state[port_num][0] == -1;
|
||||||
case HAT_UP_MASK: return android->hat_state[port_num][1] == -1;
|
case HAT_RIGHT_MASK:
|
||||||
case HAT_DOWN_MASK: return android->hat_state[port_num][1] == 1;
|
return android->hat_state[port_num][0] == 1;
|
||||||
default: return false;
|
case HAT_UP_MASK:
|
||||||
|
return android->hat_state[port_num][1] == -1;
|
||||||
|
case HAT_DOWN_MASK:
|
||||||
|
return android->hat_state[port_num][1] == 1;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num],
|
return joykey < LAST_KEYCODE && get_bit(android->pad_state[port_num],
|
||||||
|
@ -35,24 +35,31 @@ struct apple_pad_connection
|
|||||||
|
|
||||||
static IOHIDManagerRef g_hid_manager;
|
static IOHIDManagerRef g_hid_manager;
|
||||||
|
|
||||||
static void apple_pad_send_control(struct apple_pad_connection* connection, uint8_t* data, size_t size)
|
static void apple_pad_send_control(struct apple_pad_connection* connection,
|
||||||
|
uint8_t* data, size_t size)
|
||||||
{
|
{
|
||||||
IOHIDDeviceSetReport(connection->device, kIOHIDReportTypeOutput, 0x01, data + 1, size - 1);
|
IOHIDDeviceSetReport(connection->device,
|
||||||
|
kIOHIDReportTypeOutput, 0x01, data + 1, size - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: I pieced this together through trial and error, any corrections are welcome
|
/* NOTE: I pieced this together through trial and error,
|
||||||
static void hid_device_input_callback(void* context, IOReturn result, void* sender, IOHIDValueRef value)
|
* any corrections are welcome. */
|
||||||
|
|
||||||
|
static void hid_device_input_callback(void* context, IOReturn result,
|
||||||
|
void* sender, IOHIDValueRef value)
|
||||||
{
|
{
|
||||||
IOHIDElementRef element;
|
IOHIDElementRef element;
|
||||||
uint32_t type, page, use;
|
uint32_t type, page, use;
|
||||||
struct apple_pad_connection* connection = (struct apple_pad_connection*)context;
|
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
||||||
|
context;
|
||||||
|
|
||||||
element = IOHIDValueGetElement(value);
|
element = IOHIDValueGetElement(value);
|
||||||
type = IOHIDElementGetType(element);
|
type = IOHIDElementGetType(element);
|
||||||
page = IOHIDElementGetUsagePage(element);
|
page = IOHIDElementGetUsagePage(element);
|
||||||
use = IOHIDElementGetUsage(element);
|
use = IOHIDElementGetUsage(element);
|
||||||
|
|
||||||
// Joystick handler: TODO: Can GamePad work the same?
|
/* Joystick handler.
|
||||||
|
* TODO: Can GamePad work the same? */
|
||||||
if (type == kIOHIDElementTypeInput_Button && page == kHIDPage_Button)
|
if (type == kIOHIDElementTypeInput_Button && page == kHIDPage_Button)
|
||||||
{
|
{
|
||||||
CFIndex state = IOHIDValueGetIntegerValue(value);
|
CFIndex state = IOHIDValueGetIntegerValue(value);
|
||||||
@ -79,7 +86,8 @@ static void hid_device_input_callback(void* context, IOReturn result, void* send
|
|||||||
state = IOHIDValueGetIntegerValue(value) - min;
|
state = IOHIDValueGetIntegerValue(value) - min;
|
||||||
|
|
||||||
val = (float)state / (float)max;
|
val = (float)state / (float)max;
|
||||||
g_current_input_data.pad_axis[connection->slot][i] = ((val * 2.0f) - 1.0f) * 32767.0f;
|
g_current_input_data.pad_axis[connection->slot][i] =
|
||||||
|
((val * 2.0f) - 1.0f) * 32767.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,12 +95,14 @@ static void hid_device_input_callback(void* context, IOReturn result, void* send
|
|||||||
|
|
||||||
static void hid_device_removed(void* context, IOReturn result, void* sender)
|
static void hid_device_removed(void* context, IOReturn result, void* sender)
|
||||||
{
|
{
|
||||||
struct apple_pad_connection* connection = (struct apple_pad_connection*)context;
|
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
||||||
|
context;
|
||||||
|
|
||||||
if (connection && connection->slot < MAX_PLAYERS)
|
if (connection && connection->slot < MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
g_current_input_data.pad_buttons[connection->slot] = 0;
|
g_current_input_data.pad_buttons[connection->slot] = 0;
|
||||||
memset(g_current_input_data.pad_axis[connection->slot], 0, sizeof(g_current_input_data.pad_axis));
|
memset(g_current_input_data.pad_axis[connection->slot],
|
||||||
|
0, sizeof(g_current_input_data.pad_axis));
|
||||||
|
|
||||||
apple_joypad_disconnect(connection->slot);
|
apple_joypad_disconnect(connection->slot);
|
||||||
free(connection);
|
free(connection);
|
||||||
@ -101,49 +111,63 @@ static void hid_device_removed(void* context, IOReturn result, void* sender)
|
|||||||
IOHIDDeviceClose(sender, kIOHIDOptionsTypeNone);
|
IOHIDDeviceClose(sender, kIOHIDOptionsTypeNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_device_report(void* context, IOReturn result, void *sender, IOHIDReportType type, uint32_t reportID, uint8_t *report, CFIndex reportLength)
|
static void hid_device_report(void* context, IOReturn result, void *sender,
|
||||||
|
IOHIDReportType type, uint32_t reportID, uint8_t *report,
|
||||||
|
CFIndex reportLength)
|
||||||
{
|
{
|
||||||
struct apple_pad_connection* connection = (struct apple_pad_connection*)context;
|
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
||||||
|
context;
|
||||||
apple_joypad_packet(connection->slot, connection->data, reportLength + 1);
|
apple_joypad_packet(connection->slot, connection->data, reportLength + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hid_manager_device_attached(void* context, IOReturn result, void* sender, IOHIDDeviceRef device)
|
static void hid_manager_device_attached(void* context, IOReturn result,
|
||||||
|
void* sender, IOHIDDeviceRef device)
|
||||||
{
|
{
|
||||||
char device_name[1024];
|
char device_name[1024];
|
||||||
CFStringRef device_name_ref;
|
CFStringRef device_name_ref;
|
||||||
struct apple_pad_connection* connection = (struct apple_pad_connection*)calloc(1, sizeof(*connection));
|
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
||||||
|
calloc(1, sizeof(*connection));
|
||||||
|
|
||||||
connection->device = device;
|
connection->device = device;
|
||||||
connection->slot = MAX_PLAYERS;
|
connection->slot = MAX_PLAYERS;
|
||||||
|
|
||||||
IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
|
IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
|
||||||
IOHIDDeviceScheduleWithRunLoop(device, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
|
IOHIDDeviceScheduleWithRunLoop(device, CFRunLoopGetCurrent(),
|
||||||
|
kCFRunLoopCommonModes);
|
||||||
IOHIDDeviceRegisterRemovalCallback(device, hid_device_removed, connection);
|
IOHIDDeviceRegisterRemovalCallback(device, hid_device_removed, connection);
|
||||||
|
|
||||||
device_name_ref = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
|
device_name_ref = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
|
||||||
CFStringGetCString(device_name_ref, device_name, sizeof(device_name), kCFStringEncodingUTF8);
|
CFStringGetCString(device_name_ref, device_name,
|
||||||
|
sizeof(device_name), kCFStringEncodingUTF8);
|
||||||
|
|
||||||
connection->slot = apple_joypad_connect(device_name, connection);
|
connection->slot = apple_joypad_connect(device_name, connection);
|
||||||
|
|
||||||
if (apple_joypad_has_interface(connection->slot))
|
if (apple_joypad_has_interface(connection->slot))
|
||||||
IOHIDDeviceRegisterInputReportCallback(device, connection->data + 1, sizeof(connection->data) - 1, hid_device_report, connection);
|
IOHIDDeviceRegisterInputReportCallback(device,
|
||||||
|
connection->data + 1, sizeof(connection->data) - 1,
|
||||||
|
hid_device_report, connection);
|
||||||
else
|
else
|
||||||
IOHIDDeviceRegisterInputValueCallback(device, hid_device_input_callback, connection);
|
IOHIDDeviceRegisterInputValueCallback(device,
|
||||||
|
hid_device_input_callback, connection);
|
||||||
|
|
||||||
if (device_name[0] != '\0')
|
if (device_name[0] != '\0')
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[connection->slot], device_name, sizeof(g_settings.input.device_names));
|
strlcpy(g_settings.input.device_names[connection->slot],
|
||||||
input_config_autoconfigure_joypad(connection->slot, device_name, apple_joypad.ident);
|
device_name, sizeof(g_settings.input.device_names));
|
||||||
|
input_config_autoconfigure_joypad(connection->slot,
|
||||||
|
device_name, apple_joypad.ident);
|
||||||
RARCH_LOG("Port %d: %s.\n", connection->slot, device_name);
|
RARCH_LOG("Port %d: %s.\n", connection->slot, device_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void append_matching_dictionary(CFMutableArrayRef array, uint32_t page, uint32_t use)
|
static void append_matching_dictionary(CFMutableArrayRef array,
|
||||||
|
uint32_t page, uint32_t use)
|
||||||
{
|
{
|
||||||
CFNumberRef pagen, usen;
|
CFNumberRef pagen, usen;
|
||||||
CFMutableDictionaryRef matcher;
|
CFMutableDictionaryRef matcher;
|
||||||
|
|
||||||
matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
matcher = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
|
||||||
|
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
|
|
||||||
pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
|
pagen = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
|
||||||
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
|
CFDictionarySetValue(matcher, CFSTR(kIOHIDDeviceUsagePageKey), pagen);
|
||||||
@ -188,7 +212,8 @@ static int32_t find_empty_slot(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t apple_joypad_connect(const char* name, struct apple_pad_connection* connection)
|
int32_t apple_joypad_connect(const char* name,
|
||||||
|
struct apple_pad_connection* connection)
|
||||||
{
|
{
|
||||||
int32_t slot;
|
int32_t slot;
|
||||||
slot = find_empty_slot();
|
slot = find_empty_slot();
|
||||||
@ -276,7 +301,8 @@ static bool apple_joypad_init(void)
|
|||||||
|
|
||||||
if (!g_hid_manager)
|
if (!g_hid_manager)
|
||||||
{
|
{
|
||||||
g_hid_manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
g_hid_manager = IOHIDManagerCreate(
|
||||||
|
kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||||
|
|
||||||
matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
|
matcher = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
|
||||||
append_matching_dictionary(matcher, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
|
append_matching_dictionary(matcher, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
|
||||||
@ -316,7 +342,8 @@ static void apple_joypad_destroy(void)
|
|||||||
if (g_hid_manager)
|
if (g_hid_manager)
|
||||||
{
|
{
|
||||||
IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone);
|
IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone);
|
||||||
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
|
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager,
|
||||||
|
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
|
||||||
|
|
||||||
CFRelease(g_hid_manager);
|
CFRelease(g_hid_manager);
|
||||||
}
|
}
|
||||||
@ -333,7 +360,8 @@ static bool apple_joypad_button(unsigned port, uint16_t joykey)
|
|||||||
if (GET_HAT_DIR(joykey))
|
if (GET_HAT_DIR(joykey))
|
||||||
return false;
|
return false;
|
||||||
// Check the button
|
// Check the button
|
||||||
return (port < MAX_PLAYERS && joykey < 32) ? (g_current_input_data.pad_buttons[port] & (1 << joykey)) != 0 : false;
|
return (port < MAX_PLAYERS && joykey < 32) ?
|
||||||
|
(g_current_input_data.pad_buttons[port] & (1 << joykey)) != 0 : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t apple_joypad_axis(unsigned port, uint32_t joyaxis)
|
static int16_t apple_joypad_axis(unsigned port, uint32_t joyaxis)
|
||||||
@ -363,7 +391,8 @@ static void apple_joypad_poll(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool apple_joypad_rumble(unsigned pad, enum retro_rumble_effect effect, uint16_t strength)
|
static bool apple_joypad_rumble(unsigned pad,
|
||||||
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
if (pad < MAX_PLAYERS && slots[pad].used && slots[pad].iface
|
if (pad < MAX_PLAYERS && slots[pad].used && slots[pad].iface
|
||||||
&& slots[pad].iface->set_rumble)
|
&& slots[pad].iface->set_rumble)
|
||||||
|
180
input/dinput.c
180
input/dinput.c
@ -29,7 +29,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
// Context has to be global as joypads also ride on this context.
|
/* Context has to be global as joypads also ride on this context. */
|
||||||
static LPDIRECTINPUT8 g_ctx;
|
static LPDIRECTINPUT8 g_ctx;
|
||||||
|
|
||||||
struct pointer_status
|
struct pointer_status
|
||||||
@ -52,7 +52,7 @@ struct dinput_input
|
|||||||
int mouse_x;
|
int mouse_x;
|
||||||
int mouse_y;
|
int mouse_y;
|
||||||
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
|
bool mouse_l, mouse_r, mouse_m, mouse_wu, mouse_wd;
|
||||||
struct pointer_status pointer_head; // dummy head for easier iteration
|
struct pointer_status pointer_head; /* dummy head for easier iteration */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dinput_joypad
|
struct dinput_joypad
|
||||||
@ -81,7 +81,7 @@ static bool dinput_init_context(void)
|
|||||||
|
|
||||||
CoInitialize(NULL);
|
CoInitialize(NULL);
|
||||||
|
|
||||||
// Who said we shouldn't have same call signature in a COM API? <_<
|
/* Who said we shouldn't have same call signature in a COM API? <_< */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
if (FAILED(DirectInput8Create(
|
if (FAILED(DirectInput8Create(
|
||||||
GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8,
|
GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8,
|
||||||
@ -165,10 +165,12 @@ static void dinput_poll(void *data)
|
|||||||
memset(di->state, 0, sizeof(di->state));
|
memset(di->state, 0, sizeof(di->state));
|
||||||
if (di->keyboard)
|
if (di->keyboard)
|
||||||
{
|
{
|
||||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->keyboard, sizeof(di->state), di->state)))
|
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||||
|
di->keyboard, sizeof(di->state), di->state)))
|
||||||
{
|
{
|
||||||
IDirectInputDevice8_Acquire(di->keyboard);
|
IDirectInputDevice8_Acquire(di->keyboard);
|
||||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->keyboard, sizeof(di->state), di->state)))
|
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||||
|
di->keyboard, sizeof(di->state), di->state)))
|
||||||
memset(di->state, 0, sizeof(di->state));
|
memset(di->state, 0, sizeof(di->state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,10 +180,12 @@ static void dinput_poll(void *data)
|
|||||||
DIMOUSESTATE2 mouse_state;
|
DIMOUSESTATE2 mouse_state;
|
||||||
memset(&mouse_state, 0, sizeof(mouse_state));
|
memset(&mouse_state, 0, sizeof(mouse_state));
|
||||||
|
|
||||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->mouse, sizeof(mouse_state), &mouse_state)))
|
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||||
|
di->mouse, sizeof(mouse_state), &mouse_state)))
|
||||||
{
|
{
|
||||||
IDirectInputDevice8_Acquire(di->mouse);
|
IDirectInputDevice8_Acquire(di->mouse);
|
||||||
if (FAILED(IDirectInputDevice8_GetDeviceState(di->mouse, sizeof(mouse_state), &mouse_state)))
|
if (FAILED(IDirectInputDevice8_GetDeviceState(
|
||||||
|
di->mouse, sizeof(mouse_state), &mouse_state)))
|
||||||
memset(&mouse_state, 0, sizeof(mouse_state));
|
memset(&mouse_state, 0, sizeof(mouse_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +197,8 @@ static void dinput_poll(void *data)
|
|||||||
di->mouse_wu = mouse_state.rgbButtons[3];
|
di->mouse_wu = mouse_state.rgbButtons[3];
|
||||||
di->mouse_wd = mouse_state.rgbButtons[4];
|
di->mouse_wd = mouse_state.rgbButtons[4];
|
||||||
|
|
||||||
// No simple way to get absolute coordinates for RETRO_DEVICE_POINTER. Just use Win32 APIs.
|
/* No simple way to get absolute coordinates
|
||||||
|
* for RETRO_DEVICE_POINTER. Just use Win32 APIs. */
|
||||||
POINT point = {0};
|
POINT point = {0};
|
||||||
GetCursorPos(&point);
|
GetCursorPos(&point);
|
||||||
ScreenToClient((HWND)driver.video_window, &point);
|
ScreenToClient((HWND)driver.video_window, &point);
|
||||||
@ -214,14 +219,16 @@ static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key)
|
|||||||
return di->state[sym] & 0x80;
|
return di->state[sym] & 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dinput_is_pressed(struct dinput_input *di, const struct retro_keybind *binds,
|
static bool dinput_is_pressed(struct dinput_input *di,
|
||||||
|
const struct retro_keybind *binds,
|
||||||
unsigned port, unsigned id)
|
unsigned port, unsigned id)
|
||||||
{
|
{
|
||||||
if (id >= RARCH_BIND_LIST_END)
|
if (id >= RARCH_BIND_LIST_END)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const struct retro_keybind *bind = &binds[id];
|
const struct retro_keybind *bind = &binds[id];
|
||||||
return dinput_keyboard_pressed(di, bind->key) || input_joypad_pressed(di->joypad, port, binds, id);
|
return dinput_keyboard_pressed(di, bind->key) ||
|
||||||
|
input_joypad_pressed(di->joypad, port, binds, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_pressed_analog(struct dinput_input *di,
|
static int16_t dinput_pressed_analog(struct dinput_input *di,
|
||||||
@ -237,14 +244,17 @@ static int16_t dinput_pressed_analog(struct dinput_input *di,
|
|||||||
if (!bind_minus->valid || !bind_plus->valid)
|
if (!bind_minus->valid || !bind_plus->valid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int16_t pressed_minus = dinput_keyboard_pressed(di, bind_minus->key) ? -0x7fff : 0;
|
int16_t pressed_minus =
|
||||||
int16_t pressed_plus = dinput_keyboard_pressed(di, bind_plus->key) ? 0x7fff : 0;
|
dinput_keyboard_pressed(di, bind_minus->key) ? -0x7fff : 0;
|
||||||
|
int16_t pressed_plus =
|
||||||
|
dinput_keyboard_pressed(di, bind_plus->key) ? 0x7fff : 0;
|
||||||
return pressed_plus + pressed_minus;
|
return pressed_plus + pressed_minus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dinput_key_pressed(void *data, int key)
|
static bool dinput_key_pressed(void *data, int key)
|
||||||
{
|
{
|
||||||
return dinput_is_pressed((struct dinput_input*)data, g_settings.input.binds[0], 0, key);
|
return dinput_is_pressed((struct dinput_input*)data,
|
||||||
|
g_settings.input.binds[0], 0, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id)
|
static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id)
|
||||||
@ -265,9 +275,9 @@ static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id)
|
|||||||
return di->mouse_m && di->mouse_r;
|
return di->mouse_m && di->mouse_r;
|
||||||
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
case RETRO_DEVICE_ID_LIGHTGUN_PAUSE:
|
||||||
return di->mouse_m && di->mouse_l;
|
return di->mouse_m && di->mouse_l;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id)
|
static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id)
|
||||||
@ -288,12 +298,13 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id)
|
|||||||
return di->mouse_wd;
|
return di->mouse_wd;
|
||||||
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
case RETRO_DEVICE_ID_MOUSE_MIDDLE:
|
||||||
return di->mouse_m;
|
return di->mouse_m;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t dinput_pointer_state(struct dinput_input *di, unsigned index, unsigned id, bool screen)
|
static int16_t dinput_pointer_state(struct dinput_input *di,
|
||||||
|
unsigned index, unsigned id, bool screen)
|
||||||
{
|
{
|
||||||
int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0;
|
int16_t res_x = 0, res_y = 0, res_screen_x = 0, res_screen_y = 0;
|
||||||
unsigned num = 0;
|
unsigned num = 0;
|
||||||
@ -303,7 +314,7 @@ static int16_t dinput_pointer_state(struct dinput_input *di, unsigned index, uns
|
|||||||
num++;
|
num++;
|
||||||
check_pos = check_pos->next;
|
check_pos = check_pos->next;
|
||||||
}
|
}
|
||||||
if (!check_pos && index > 0) // index = 0 has mouse fallback
|
if (!check_pos && index > 0) /* index = 0 has mouse fallback. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int x = check_pos ? check_pos->pointer_x : di->mouse_x;
|
int x = check_pos ? check_pos->pointer_x : di->mouse_x;
|
||||||
@ -358,7 +369,8 @@ static int16_t dinput_input_state(void *data,
|
|||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
ret = dinput_pressed_analog(di, binds[port], index, id);
|
ret = dinput_pressed_analog(di, binds[port], index, id);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = input_joypad_analog(di->joypad, port, index, id, g_settings.input.binds[port]);
|
ret = input_joypad_analog(di->joypad, port,
|
||||||
|
index, id, g_settings.input.binds[port]);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case RETRO_DEVICE_MOUSE:
|
case RETRO_DEVICE_MOUSE:
|
||||||
@ -366,7 +378,8 @@ static int16_t dinput_input_state(void *data,
|
|||||||
|
|
||||||
case RETRO_DEVICE_POINTER:
|
case RETRO_DEVICE_POINTER:
|
||||||
case RARCH_DEVICE_POINTER_SCREEN:
|
case RARCH_DEVICE_POINTER_SCREEN:
|
||||||
return dinput_pointer_state(di, index, id, device == RARCH_DEVICE_POINTER_SCREEN);
|
return dinput_pointer_state(di, index, id,
|
||||||
|
device == RARCH_DEVICE_POINTER_SCREEN);
|
||||||
|
|
||||||
case RETRO_DEVICE_LIGHTGUN:
|
case RETRO_DEVICE_LIGHTGUN:
|
||||||
return dinput_lightgun_state(di, id);
|
return dinput_lightgun_state(di, id);
|
||||||
@ -376,7 +389,7 @@ static int16_t dinput_input_state(void *data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// these are defined in later SDKs, thus ifdeffed
|
/* these are defined in later SDKs, thus ifdeffed. */
|
||||||
#ifndef WM_POINTERUPDATE
|
#ifndef WM_POINTERUPDATE
|
||||||
#define WM_POINTERUPDATE 0x0245
|
#define WM_POINTERUPDATE 0x0245
|
||||||
#endif
|
#endif
|
||||||
@ -387,10 +400,10 @@ static int16_t dinput_input_state(void *data,
|
|||||||
#define WM_POINTERUP 0x0247
|
#define WM_POINTERUP 0x0247
|
||||||
#endif
|
#endif
|
||||||
#ifndef GET_POINTERID_WPARAM
|
#ifndef GET_POINTERID_WPARAM
|
||||||
#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
|
#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// stores x/y in client coordinates
|
/* Stores x/y in client coordinates. */
|
||||||
void dinput_pointer_store_pos(struct pointer_status *pointer, WPARAM lParam)
|
void dinput_pointer_store_pos(struct pointer_status *pointer, WPARAM lParam)
|
||||||
{
|
{
|
||||||
POINT point;
|
POINT point;
|
||||||
@ -401,7 +414,8 @@ void dinput_pointer_store_pos(struct pointer_status *pointer, WPARAM lParam)
|
|||||||
pointer->pointer_y = point.y;
|
pointer->pointer_y = point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dinput_add_pointer(struct dinput_input *di, struct pointer_status *new_pointer)
|
void dinput_add_pointer(struct dinput_input *di,
|
||||||
|
struct pointer_status *new_pointer)
|
||||||
{
|
{
|
||||||
new_pointer->next = NULL;
|
new_pointer->next = NULL;
|
||||||
struct pointer_status *insert_pos = &di->pointer_head;
|
struct pointer_status *insert_pos = &di->pointer_head;
|
||||||
@ -425,7 +439,8 @@ void dinput_delete_pointer(struct dinput_input *di, int pointer_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pointer_status *dinput_find_pointer(struct dinput_input *di, int pointer_id)
|
struct pointer_status *dinput_find_pointer(struct dinput_input *di,
|
||||||
|
int pointer_id)
|
||||||
{
|
{
|
||||||
struct pointer_status *check_pos = di->pointer_head.next;
|
struct pointer_status *check_pos = di->pointer_head.next;
|
||||||
while (check_pos)
|
while (check_pos)
|
||||||
@ -454,15 +469,20 @@ extern "C"
|
|||||||
bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam)
|
bool dinput_handle_message(void *dinput, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
struct dinput_input *di = (struct dinput_input *)dinput;
|
struct dinput_input *di = (struct dinput_input *)dinput;
|
||||||
/* WM_POINTERDOWN arrives for each new touch event with a new id - add to list
|
/* WM_POINTERDOWN : Arrives for each new touch event
|
||||||
WM_POINTERUP arrives once the pointer is no longer down - remove from list
|
* with a new ID - add to list.
|
||||||
WM_POINTERUPDATE arrives for both pressed and hovering pointers - ignore hovering
|
* WM_POINTERUP : Arrives once the pointer is no
|
||||||
|
* longer down - remove from list.
|
||||||
|
* WM_POINTERUPDATE : arrives for both pressed and
|
||||||
|
* hovering pointers - ignore hovering
|
||||||
*/
|
*/
|
||||||
|
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_POINTERDOWN:
|
case WM_POINTERDOWN:
|
||||||
{
|
{
|
||||||
struct pointer_status *new_pointer = (struct pointer_status *)malloc(sizeof(struct pointer_status));
|
struct pointer_status *new_pointer =
|
||||||
|
(struct pointer_status *)malloc(sizeof(struct pointer_status));
|
||||||
new_pointer->pointer_id = GET_POINTERID_WPARAM(wParam);
|
new_pointer->pointer_id = GET_POINTERID_WPARAM(wParam);
|
||||||
dinput_pointer_store_pos(new_pointer, lParam);
|
dinput_pointer_store_pos(new_pointer, lParam);
|
||||||
dinput_add_pointer(di, new_pointer);
|
dinput_add_pointer(di, new_pointer);
|
||||||
@ -500,12 +520,14 @@ static void dinput_free(void *data)
|
|||||||
|
|
||||||
if (di)
|
if (di)
|
||||||
{
|
{
|
||||||
g_ctx = NULL; // Prevent a joypad driver to kill our context prematurely.
|
/* Prevent a joypad driver to kill our context prematurely. */
|
||||||
|
g_ctx = NULL;
|
||||||
if (di->joypad)
|
if (di->joypad)
|
||||||
di->joypad->destroy();
|
di->joypad->destroy();
|
||||||
g_ctx = hold_ctx;
|
g_ctx = hold_ctx;
|
||||||
|
|
||||||
dinput_clear_pointers(di); // clear any leftover pointers
|
/* Clear any leftover pointers. */
|
||||||
|
dinput_clear_pointers(di);
|
||||||
|
|
||||||
if (di->keyboard)
|
if (di->keyboard)
|
||||||
IDirectInputDevice8_Release(di->keyboard);
|
IDirectInputDevice8_Release(di->keyboard);
|
||||||
@ -531,7 +553,8 @@ static void dinput_grab_mouse(void *data, bool state)
|
|||||||
IDirectInputDevice8_Acquire(di->mouse);
|
IDirectInputDevice8_Acquire(di->mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool dinput_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength)
|
static bool dinput_set_rumble(void *data, unsigned port,
|
||||||
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
struct dinput_input *di = (struct dinput_input*)data;
|
struct dinput_input *di = (struct dinput_input*)data;
|
||||||
return input_joypad_set_rumble(di->joypad, port, effect, strength);
|
return input_joypad_set_rumble(di->joypad, port, effect, strength);
|
||||||
@ -573,9 +596,11 @@ const input_driver_t input_dinput = {
|
|||||||
dinput_get_joypad_driver,
|
dinput_get_joypad_driver,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep track of which pad indexes are 360 controllers
|
/* Keep track of which pad indexes are 360 controllers.
|
||||||
// not static, will be read in winxinput_joypad.c
|
* Not static, will be read in winxinput_joypad.c
|
||||||
// -1 = not xbox pad, otherwise 0..3
|
* -1 = not xbox pad, otherwise 0..3
|
||||||
|
*/
|
||||||
|
|
||||||
int g_xinput_pad_indexes[MAX_PLAYERS];
|
int g_xinput_pad_indexes[MAX_PLAYERS];
|
||||||
bool g_xinput_block_pads;
|
bool g_xinput_block_pads;
|
||||||
|
|
||||||
@ -598,11 +623,12 @@ static void dinput_joypad_destroy(void)
|
|||||||
g_joypad_cnt = 0;
|
g_joypad_cnt = 0;
|
||||||
memset(g_pads, 0, sizeof(g_pads));
|
memset(g_pads, 0, sizeof(g_pads));
|
||||||
|
|
||||||
// Can be blocked by global Dinput context.
|
/* Can be blocked by global Dinput context. */
|
||||||
dinput_destroy_context();
|
dinput_destroy_context();
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL CALLBACK enum_axes_cb(const DIDEVICEOBJECTINSTANCE *inst, void *p)
|
static BOOL CALLBACK enum_axes_cb(
|
||||||
|
const DIDEVICEOBJECTINSTANCE *inst, void *p)
|
||||||
{
|
{
|
||||||
LPDIRECTINPUTDEVICE8 joypad = (LPDIRECTINPUTDEVICE8)p;
|
LPDIRECTINPUTDEVICE8 joypad = (LPDIRECTINPUTDEVICE8)p;
|
||||||
|
|
||||||
@ -625,15 +651,20 @@ static const GUID common_xinput_guids[] = {
|
|||||||
{MAKELONG(0x045E, 0x028E),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}} // wireless 360 pad
|
{MAKELONG(0x045E, 0x028E),0x0000,0x0000,{0x00,0x00,0x50,0x49,0x44,0x56,0x49,0x44}} // wireless 360 pad
|
||||||
};
|
};
|
||||||
|
|
||||||
// Based on SDL2's implementation
|
/* Based on SDL2's implementation. */
|
||||||
static bool guid_is_xinput_device(const GUID* product_guid)
|
static bool guid_is_xinput_device(const GUID* product_guid)
|
||||||
{
|
{
|
||||||
PRAWINPUTDEVICELIST raw_devs = NULL;
|
PRAWINPUTDEVICELIST raw_devs = NULL;
|
||||||
unsigned num_raw_devs = 0;
|
unsigned num_raw_devs = 0;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
// Check for well known XInput device GUIDs, thereby removing the need for the IG_ check.
|
/* Check for well known XInput device GUIDs,
|
||||||
// This lets us skip RAWINPUT for popular devices. Also, we need to do this for the Valve Streaming Gamepad because it's virtualized and doesn't show up in the device list.
|
* thereby removing the need for the IG_ check.
|
||||||
|
* This lets us skip RAWINPUT for popular devices.
|
||||||
|
*
|
||||||
|
* Also, we need to do this for the Valve Streaming Gamepad
|
||||||
|
* because it's virtualized and doesn't show up in the device list. */
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(common_xinput_guids); ++i)
|
for (i = 0; i < ARRAY_SIZE(common_xinput_guids); ++i)
|
||||||
{
|
{
|
||||||
if (memcmp(product_guid, &common_xinput_guids[i], sizeof(GUID)) == 0)
|
if (memcmp(product_guid, &common_xinput_guids[i], sizeof(GUID)) == 0)
|
||||||
@ -643,14 +674,17 @@ static bool guid_is_xinput_device(const GUID* product_guid)
|
|||||||
/* Go through RAWINPUT (WinXP and later) to find HID devices. */
|
/* Go through RAWINPUT (WinXP and later) to find HID devices. */
|
||||||
if (!raw_devs)
|
if (!raw_devs)
|
||||||
{
|
{
|
||||||
if ((GetRawInputDeviceList(NULL, &num_raw_devs, sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) || (!num_raw_devs))
|
if ((GetRawInputDeviceList(NULL, &num_raw_devs,
|
||||||
|
sizeof(RAWINPUTDEVICELIST)) == (UINT)-1) || (!num_raw_devs))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
raw_devs = (PRAWINPUTDEVICELIST)malloc(sizeof(RAWINPUTDEVICELIST) * num_raw_devs);
|
raw_devs = (PRAWINPUTDEVICELIST)
|
||||||
|
malloc(sizeof(RAWINPUTDEVICELIST) * num_raw_devs);
|
||||||
if (!raw_devs)
|
if (!raw_devs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GetRawInputDeviceList(raw_devs, &num_raw_devs, sizeof (RAWINPUTDEVICELIST)) == (UINT)-1)
|
if (GetRawInputDeviceList(raw_devs, &num_raw_devs,
|
||||||
|
sizeof(RAWINPUTDEVICELIST)) == (UINT)-1)
|
||||||
{
|
{
|
||||||
free(raw_devs);
|
free(raw_devs);
|
||||||
raw_devs = NULL;
|
raw_devs = NULL;
|
||||||
@ -683,8 +717,9 @@ static bool guid_is_xinput_device(const GUID* product_guid)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forward declaration
|
/* Forward declaration */
|
||||||
static const char *dinput_joypad_name(unsigned pad);
|
static const char *dinput_joypad_name(unsigned pad);
|
||||||
|
|
||||||
static unsigned g_last_xinput_pad_index;
|
static unsigned g_last_xinput_pad_index;
|
||||||
|
|
||||||
static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
||||||
@ -696,17 +731,23 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
|||||||
LPDIRECTINPUTDEVICE8 *pad = &g_pads[g_joypad_cnt].joypad;
|
LPDIRECTINPUTDEVICE8 *pad = &g_pads[g_joypad_cnt].joypad;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, inst->guidInstance, pad, NULL)))
|
if (FAILED(IDirectInput8_CreateDevice(
|
||||||
|
g_ctx, inst->guidInstance, pad, NULL)))
|
||||||
#else
|
#else
|
||||||
if (FAILED(IDirectInput8_CreateDevice(g_ctx, &inst->guidInstance, pad, NULL)))
|
if (FAILED(IDirectInput8_CreateDevice(
|
||||||
|
g_ctx, &inst->guidInstance, pad, NULL)))
|
||||||
#endif
|
#endif
|
||||||
return DIENUM_CONTINUE;
|
return DIENUM_CONTINUE;
|
||||||
|
|
||||||
g_pads[g_joypad_cnt].joy_name = strdup(inst->tszProductName);
|
g_pads[g_joypad_cnt].joy_name = strdup(inst->tszProductName);
|
||||||
|
|
||||||
#ifdef HAVE_WINXINPUT
|
#ifdef HAVE_WINXINPUT
|
||||||
//bool is_xinput_pad = g_xinput_block_pads && name_is_xinput_pad(inst->tszProductName);
|
#if 0
|
||||||
bool is_xinput_pad = g_xinput_block_pads && guid_is_xinput_device(&inst->guidProduct);
|
bool is_xinput_pad = g_xinput_block_pads
|
||||||
|
&& name_is_xinput_pad(inst->tszProductName);
|
||||||
|
#endif
|
||||||
|
bool is_xinput_pad = g_xinput_block_pads
|
||||||
|
&& guid_is_xinput_device(&inst->guidProduct);
|
||||||
|
|
||||||
if (is_xinput_pad)
|
if (is_xinput_pad)
|
||||||
{
|
{
|
||||||
@ -727,8 +768,12 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
|
|||||||
if (!is_xinput_pad)
|
if (!is_xinput_pad)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[g_joypad_cnt], dinput_joypad_name(g_joypad_cnt), sizeof(g_settings.input.device_names[g_joypad_cnt]));
|
strlcpy(g_settings.input.device_names[g_joypad_cnt],
|
||||||
input_config_autoconfigure_joypad(g_joypad_cnt, dinput_joypad_name(g_joypad_cnt), dinput_joypad.ident);
|
dinput_joypad_name(g_joypad_cnt),
|
||||||
|
sizeof(g_settings.input.device_names[g_joypad_cnt]));
|
||||||
|
input_config_autoconfigure_joypad(g_joypad_cnt,
|
||||||
|
dinput_joypad_name(g_joypad_cnt),
|
||||||
|
dinput_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum_iteration_done:
|
enum_iteration_done:
|
||||||
@ -771,7 +816,9 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
{
|
{
|
||||||
unsigned hat = GET_HAT(joykey);
|
unsigned hat = GET_HAT(joykey);
|
||||||
|
|
||||||
unsigned elems = sizeof(pad->joy_state.rgdwPOV) / sizeof(pad->joy_state.rgdwPOV[0]);
|
unsigned elems = sizeof(pad->joy_state.rgdwPOV) /
|
||||||
|
sizeof(pad->joy_state.rgdwPOV[0]);
|
||||||
|
|
||||||
if (hat >= elems)
|
if (hat >= elems)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -797,7 +844,8 @@ static bool dinput_joypad_button(unsigned port_num, uint16_t joykey)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned elems = sizeof(pad->joy_state.rgbButtons) / sizeof(pad->joy_state.rgbButtons[0]);
|
unsigned elems = sizeof(pad->joy_state.rgbButtons) /
|
||||||
|
sizeof(pad->joy_state.rgbButtons[0]);
|
||||||
|
|
||||||
if (joykey < elems)
|
if (joykey < elems)
|
||||||
return pad->joy_state.rgbButtons[joykey];
|
return pad->joy_state.rgbButtons[joykey];
|
||||||
@ -834,12 +882,24 @@ static int16_t dinput_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = pad->joy_state.lX; break;
|
case 0:
|
||||||
case 1: val = pad->joy_state.lY; break;
|
val = pad->joy_state.lX;
|
||||||
case 2: val = pad->joy_state.lZ; break;
|
break;
|
||||||
case 3: val = pad->joy_state.lRx; break;
|
case 1:
|
||||||
case 4: val = pad->joy_state.lRy; break;
|
val = pad->joy_state.lY;
|
||||||
case 5: val = pad->joy_state.lRz; break;
|
break;
|
||||||
|
case 2:
|
||||||
|
val = pad->joy_state.lZ;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = pad->joy_state.lRx;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
val = pad->joy_state.lRy;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
val = pad->joy_state.lRz;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
@ -869,7 +929,7 @@ static void dinput_joypad_poll(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this fails, something *really* bad must have happened.
|
/* If this fails, something *really* bad must have happened. */
|
||||||
if (FAILED(IDirectInputDevice8_Poll(pad->joypad)))
|
if (FAILED(IDirectInputDevice8_Poll(pad->joypad)))
|
||||||
{
|
{
|
||||||
memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2));
|
memset(&pad->joy_state, 0, sizeof(DIJOYSTATE2));
|
||||||
|
@ -89,7 +89,9 @@ enum
|
|||||||
GX_WIIMOTE_2 = 46,
|
GX_WIIMOTE_2 = 46,
|
||||||
GX_WIIMOTE_PLUS = 47,
|
GX_WIIMOTE_PLUS = 47,
|
||||||
GX_WIIMOTE_MINUS = 48,
|
GX_WIIMOTE_MINUS = 48,
|
||||||
//GX_WIIMOTE_HOME = 49,
|
#if 0
|
||||||
|
GX_WIIMOTE_HOME = 49,
|
||||||
|
#endif
|
||||||
GX_WIIMOTE_UP = 50,
|
GX_WIIMOTE_UP = 50,
|
||||||
GX_WIIMOTE_DOWN = 51,
|
GX_WIIMOTE_DOWN = 51,
|
||||||
GX_WIIMOTE_LEFT = 52,
|
GX_WIIMOTE_LEFT = 52,
|
||||||
@ -101,7 +103,7 @@ enum
|
|||||||
GX_NUNCHUK_LEFT = 58,
|
GX_NUNCHUK_LEFT = 58,
|
||||||
GX_NUNCHUK_RIGHT = 59,
|
GX_NUNCHUK_RIGHT = 59,
|
||||||
#endif
|
#endif
|
||||||
GX_WIIMOTE_HOME = 49, // needed on GameCube as "fake" menu button
|
GX_WIIMOTE_HOME = 49, /* needed on GameCube as "fake" menu button. */
|
||||||
GX_QUIT_KEY = 60,
|
GX_QUIT_KEY = 60,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -250,8 +252,12 @@ static void *gx_input_init(void)
|
|||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
gx->ptype[autoconf_pad] = WPAD_EXP_GAMECUBE;
|
gx->ptype[autoconf_pad] = WPAD_EXP_GAMECUBE;
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], gx_joypad_name_static(gx, autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, gx_joypad_name_static(gx, autoconf_pad), gx->joypad->ident);
|
gx_joypad_name_static(gx, autoconf_pad),
|
||||||
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
gx_joypad_name_static(gx, autoconf_pad),
|
||||||
|
gx->joypad->ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
driver.input_data_own = true;
|
driver.input_data_own = true;
|
||||||
@ -267,8 +273,11 @@ static void handle_hotplug(void *data, unsigned port, uint32_t ptype)
|
|||||||
if (!g_settings.input.autodetect_enable)
|
if (!g_settings.input.autodetect_enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
strlcpy(g_settings.input.device_names[port], gx_joypad_name(port), sizeof(g_settings.input.device_names[port]));
|
strlcpy(g_settings.input.device_names[port],
|
||||||
input_config_autoconfigure_joypad(port, gx_joypad_name(port), gx_joypad.ident);
|
gx_joypad_name(port),
|
||||||
|
sizeof(g_settings.input.device_names[port]));
|
||||||
|
input_config_autoconfigure_joypad(port,
|
||||||
|
gx_joypad_name(port), gx_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gx_input_poll(void *data)
|
static void gx_input_poll(void *data)
|
||||||
@ -314,7 +323,7 @@ static void gx_input_poll(void *data)
|
|||||||
|
|
||||||
if (ptype != WPAD_EXP_NUNCHUK)
|
if (ptype != WPAD_EXP_NUNCHUK)
|
||||||
{
|
{
|
||||||
// rotated d-pad on Wiimote
|
/* Rotated d-pad on Wiimote. */
|
||||||
*state_cur |= (down & WPAD_BUTTON_UP) ? (1ULL << GX_WIIMOTE_LEFT) : 0;
|
*state_cur |= (down & WPAD_BUTTON_UP) ? (1ULL << GX_WIIMOTE_LEFT) : 0;
|
||||||
*state_cur |= (down & WPAD_BUTTON_DOWN) ? (1ULL << GX_WIIMOTE_RIGHT) : 0;
|
*state_cur |= (down & WPAD_BUTTON_DOWN) ? (1ULL << GX_WIIMOTE_RIGHT) : 0;
|
||||||
*state_cur |= (down & WPAD_BUTTON_LEFT) ? (1ULL << GX_WIIMOTE_DOWN) : 0;
|
*state_cur |= (down & WPAD_BUTTON_LEFT) ? (1ULL << GX_WIIMOTE_DOWN) : 0;
|
||||||
@ -375,7 +384,8 @@ static void gx_input_poll(void *data)
|
|||||||
}
|
}
|
||||||
else if (ptype == WPAD_EXP_NUNCHUK)
|
else if (ptype == WPAD_EXP_NUNCHUK)
|
||||||
{
|
{
|
||||||
// wiimote is held upright with nunchuk, do not change d-pad orientation
|
/* Wiimote is held upright with nunchuk,
|
||||||
|
* do not change d-pad orientation. */
|
||||||
*state_cur |= (down & WPAD_BUTTON_UP) ? (1ULL << GX_WIIMOTE_UP) : 0;
|
*state_cur |= (down & WPAD_BUTTON_UP) ? (1ULL << GX_WIIMOTE_UP) : 0;
|
||||||
*state_cur |= (down & WPAD_BUTTON_DOWN) ? (1ULL << GX_WIIMOTE_DOWN) : 0;
|
*state_cur |= (down & WPAD_BUTTON_DOWN) ? (1ULL << GX_WIIMOTE_DOWN) : 0;
|
||||||
*state_cur |= (down & WPAD_BUTTON_LEFT) ? (1ULL << GX_WIIMOTE_LEFT) : 0;
|
*state_cur |= (down & WPAD_BUTTON_LEFT) ? (1ULL << GX_WIIMOTE_LEFT) : 0;
|
||||||
@ -511,7 +521,8 @@ static void gx_input_poll(void *data)
|
|||||||
|
|
||||||
static bool gx_input_key_pressed(void *data, int key)
|
static bool gx_input_key_pressed(void *data, int key)
|
||||||
{
|
{
|
||||||
return (g_extern.lifecycle_state & (1ULL << key)) || input_joypad_pressed(&gx_joypad, 0, g_settings.input.binds[0], key);
|
return (g_extern.lifecycle_state & (1ULL << key)) ||
|
||||||
|
input_joypad_pressed(&gx_joypad, 0, g_settings.input.binds[0], key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t gx_input_get_capabilities(void *data)
|
static uint64_t gx_input_get_capabilities(void *data)
|
||||||
|
@ -29,7 +29,6 @@ static bool gx_joypad_init(void)
|
|||||||
ss_initialize(&dev[i]);
|
ss_initialize(&dev[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +67,18 @@ static int16_t gx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = gx->analog_state[port_num][0][0]; break;
|
case 0:
|
||||||
case 1: val = gx->analog_state[port_num][0][1]; break;
|
val = gx->analog_state[port_num][0][0];
|
||||||
case 2: val = gx->analog_state[port_num][1][0]; break;
|
break;
|
||||||
case 3: val = gx->analog_state[port_num][1][1]; break;
|
case 1:
|
||||||
|
val = gx->analog_state[port_num][0][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = gx->analog_state[port_num][1][0];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = gx->analog_state[port_num][1][1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
|
@ -36,312 +36,329 @@ static int _ss_send_attributes_payload(struct ss_device *dev);
|
|||||||
|
|
||||||
int ss_init(void)
|
int ss_init(void)
|
||||||
{
|
{
|
||||||
if (!_ss_inited)
|
if (!_ss_inited)
|
||||||
{
|
{
|
||||||
_ss_heap_id = iosCreateHeap(SS_HEAP_SIZE);
|
_ss_heap_id = iosCreateHeap(SS_HEAP_SIZE);
|
||||||
_ss_inited = 1;
|
_ss_inited = 1;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ss_initialize(struct ss_device *dev)
|
int ss_initialize(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
dev->device_id = -1;
|
dev->device_id = -1;
|
||||||
dev->fd = -1;
|
dev->fd = -1;
|
||||||
dev->connected = 0;
|
dev->connected = 0;
|
||||||
dev->enabled = 0;
|
dev->enabled = 0;
|
||||||
dev->reading = 0;
|
dev->reading = 0;
|
||||||
dev->removal_callback = NULL;
|
dev->removal_callback = NULL;
|
||||||
dev->removal_usrdata = NULL;
|
dev->removal_usrdata = NULL;
|
||||||
dev->read_callback = NULL;
|
dev->read_callback = NULL;
|
||||||
dev->read_usrdata = NULL;
|
dev->read_usrdata = NULL;
|
||||||
memset(&dev->pad, 0x0, sizeof(struct SS_GAMEPAD));
|
memset(&dev->pad, 0x0, sizeof(struct SS_GAMEPAD));
|
||||||
memset(&dev->attributes, 0x0, sizeof(struct SS_ATTRIBUTES));
|
memset(&dev->attributes, 0x0, sizeof(struct SS_ATTRIBUTES));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_open(struct ss_device *dev)
|
int ss_open(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
if (!_ss_inited) return -1;
|
usb_device_entry dev_entry[8];
|
||||||
if (dev->connected) ss_close(dev);
|
unsigned char dev_count;
|
||||||
|
if (!_ss_inited)
|
||||||
usb_device_entry dev_entry[8];
|
return -1;
|
||||||
unsigned char dev_count;
|
if (dev->connected)
|
||||||
if (USB_GetDeviceList(dev_entry, 8, USB_CLASS_HID, &dev_count) < 0) {
|
ss_close(dev);
|
||||||
return -2;
|
|
||||||
}
|
if (USB_GetDeviceList(dev_entry, 8, USB_CLASS_HID, &dev_count) < 0)
|
||||||
|
return -2;
|
||||||
int i;
|
|
||||||
for (i = 0; i < dev_count; ++i) {
|
int i;
|
||||||
|
for (i = 0; i < dev_count; ++i)
|
||||||
if ((dev_entry[i].vid == SS_VENDOR_ID) && (dev_entry[i].pid == SS_PRODUCT_ID)) {
|
{
|
||||||
|
if ((dev_entry[i].vid == SS_VENDOR_ID) &&
|
||||||
if (!_ss_dev_id_list_exists(dev_entry[i].device_id)) {
|
(dev_entry[i].pid == SS_PRODUCT_ID))
|
||||||
if (USB_OpenDevice(dev_entry[i].device_id, SS_VENDOR_ID, SS_PRODUCT_ID, &dev->fd) < 0) {
|
{
|
||||||
return -3;
|
if (!_ss_dev_id_list_exists(dev_entry[i].device_id))
|
||||||
}
|
{
|
||||||
|
if (USB_OpenDevice(dev_entry[i].device_id,
|
||||||
dev->device_id = dev_entry[i].device_id;
|
SS_VENDOR_ID, SS_PRODUCT_ID, &dev->fd) < 0)
|
||||||
dev->connected = 1;
|
return -3;
|
||||||
dev->enabled = 0;
|
|
||||||
dev->reading = 0;
|
dev->device_id = dev_entry[i].device_id;
|
||||||
|
dev->connected = 1;
|
||||||
_ss_set_operational(dev);
|
dev->enabled = 0;
|
||||||
ss_set_led(dev, _ss_dev_number);
|
dev->reading = 0;
|
||||||
|
|
||||||
_ss_dev_id_list_add(dev_entry[i].device_id);
|
_ss_set_operational(dev);
|
||||||
_ss_dev_number++;
|
ss_set_led(dev, _ss_dev_number);
|
||||||
|
|
||||||
USB_DeviceRemovalNotifyAsync(dev->fd, &_ss_removal_cb, dev);
|
_ss_dev_id_list_add(dev_entry[i].device_id);
|
||||||
return 1;
|
_ss_dev_number++;
|
||||||
}
|
|
||||||
}
|
USB_DeviceRemovalNotifyAsync(dev->fd, &_ss_removal_cb, dev);
|
||||||
}
|
return 1;
|
||||||
return -4;
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_close(struct ss_device *dev)
|
int ss_close(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
if (dev && dev->fd > 0) {
|
if (dev && dev->fd > 0)
|
||||||
USB_CloseDevice(&dev->fd);
|
USB_CloseDevice(&dev->fd);
|
||||||
}
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_is_connected(struct ss_device *dev)
|
int ss_is_connected(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
return dev->connected;
|
return dev->connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_set_read_cb(struct ss_device *dev,ss_usb_callback cb, void *usrdata)
|
int ss_set_read_cb(struct ss_device *dev,ss_usb_callback cb,
|
||||||
|
void *userdata)
|
||||||
{
|
{
|
||||||
dev->read_callback = cb;
|
dev->read_callback = cb;
|
||||||
dev->read_usrdata = usrdata;
|
dev->read_usrdata = userdata;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_set_removal_cb(struct ss_device *dev, ss_usb_callback cb, void *usrdata)
|
int ss_set_removal_cb(struct ss_device *dev, ss_usb_callback cb,
|
||||||
|
void *usrdata)
|
||||||
{
|
{
|
||||||
dev->removal_callback = cb;
|
dev->removal_callback = cb;
|
||||||
dev->removal_usrdata = usrdata;
|
dev->removal_usrdata = userdata;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_start_reading(struct ss_device *dev)
|
int ss_start_reading(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
if (dev) {
|
if (dev)
|
||||||
dev->reading = 1;
|
{
|
||||||
if (dev->enabled) {
|
dev->reading = 1;
|
||||||
_ss_read(dev);
|
if (dev->enabled)
|
||||||
}
|
_ss_read(dev);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ss_stop_reading(struct ss_device *dev)
|
int ss_stop_reading(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
if (dev) {
|
if (dev)
|
||||||
dev->reading = 0;
|
{
|
||||||
return 1;
|
dev->reading = 0;
|
||||||
}
|
return 1;
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_build_attributes_payload(struct ss_device *dev)
|
static int _ss_build_attributes_payload(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
_ss_attributes_payload[1] = dev->attributes.rumble.duration_right;
|
_ss_attributes_payload[1] = dev->attributes.rumble.duration_right;
|
||||||
_ss_attributes_payload[2] = dev->attributes.rumble.power_right;
|
_ss_attributes_payload[2] = dev->attributes.rumble.power_right;
|
||||||
_ss_attributes_payload[3] = dev->attributes.rumble.duration_left;
|
_ss_attributes_payload[3] = dev->attributes.rumble.duration_left;
|
||||||
_ss_attributes_payload[4] = dev->attributes.rumble.power_left;
|
_ss_attributes_payload[4] = dev->attributes.rumble.power_left;
|
||||||
_ss_attributes_payload[9] = _ss_led_pattern[dev->attributes.led];
|
_ss_attributes_payload[9] = _ss_led_pattern[dev->attributes.led];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_send_attributes_payload(struct ss_device *dev)
|
static int _ss_send_attributes_payload(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
if (!dev->connected) return 0;
|
if (!dev->connected)
|
||||||
_ss_build_attributes_payload(dev);
|
return 0;
|
||||||
return USB_WriteCtrlMsgAsync(dev->fd,
|
|
||||||
USB_REQTYPE_INTERFACE_SET,
|
_ss_build_attributes_payload(dev);
|
||||||
USB_REQ_SETREPORT,
|
|
||||||
(USB_REPTYPE_OUTPUT<<8) | 0x01,
|
return USB_WriteCtrlMsgAsync(dev->fd,
|
||||||
0x0,
|
USB_REQTYPE_INTERFACE_SET,
|
||||||
sizeof(_ss_attributes_payload),
|
USB_REQ_SETREPORT,
|
||||||
_ss_attributes_payload,
|
(USB_REPTYPE_OUTPUT<<8) | 0x01,
|
||||||
NULL, NULL);
|
0x0,
|
||||||
|
sizeof(_ss_attributes_payload),
|
||||||
|
_ss_attributes_payload,
|
||||||
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int ss_set_led(struct ss_device *dev, int led)
|
inline int ss_set_led(struct ss_device *dev, int led)
|
||||||
{
|
{
|
||||||
dev->attributes.led = led;
|
dev->attributes.led = led;
|
||||||
return _ss_send_attributes_payload(dev);
|
return _ss_send_attributes_payload(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int ss_set_rumble(struct ss_device *dev, uint8_t duration_right, uint8_t power_right, uint8_t duration_left, uint8_t power_left)
|
inline int ss_set_rumble(struct ss_device *dev, uint8_t duration_right,
|
||||||
|
uint8_t power_right, uint8_t duration_left, uint8_t power_left)
|
||||||
{
|
{
|
||||||
dev->attributes.rumble.duration_right = duration_right;
|
dev->attributes.rumble.duration_right = duration_right;
|
||||||
dev->attributes.rumble.power_right = power_right;
|
dev->attributes.rumble.power_right = power_right;
|
||||||
dev->attributes.rumble.duration_left = duration_left;
|
dev->attributes.rumble.duration_left = duration_left;
|
||||||
dev->attributes.rumble.power_left = power_left;
|
dev->attributes.rumble.power_left = power_left;
|
||||||
return _ss_send_attributes_payload(dev);
|
return _ss_send_attributes_payload(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_get_bd_address(struct ss_device *dev, uint8_t *mac)
|
int ss_get_bd_address(struct ss_device *dev, uint8_t *mac)
|
||||||
{
|
{
|
||||||
uint8_t ATTRIBUTE_ALIGN(32) msg[17];
|
uint8_t ATTRIBUTE_ALIGN(32) msg[17];
|
||||||
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
||||||
USB_REQTYPE_INTERFACE_GET,
|
USB_REQTYPE_INTERFACE_GET,
|
||||||
USB_REQ_GETREPORT,
|
USB_REQ_GETREPORT,
|
||||||
(USB_REPTYPE_FEATURE<<8) | 0xf2,
|
(USB_REPTYPE_FEATURE<<8) | 0xf2,
|
||||||
0,
|
0,
|
||||||
sizeof(msg),
|
sizeof(msg),
|
||||||
msg,
|
msg,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
mac[0] = msg[4];
|
mac[0] = msg[4];
|
||||||
mac[1] = msg[5];
|
mac[1] = msg[5];
|
||||||
mac[2] = msg[6];
|
mac[2] = msg[6];
|
||||||
mac[3] = msg[7];
|
mac[3] = msg[7];
|
||||||
mac[4] = msg[8];
|
mac[4] = msg[8];
|
||||||
mac[5] = msg[9];
|
mac[5] = msg[9];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_get_mac(struct ss_device *dev, uint8_t *mac)
|
int ss_get_mac(struct ss_device *dev, uint8_t *mac)
|
||||||
{
|
{
|
||||||
uint8_t ATTRIBUTE_ALIGN(32) msg[8];
|
uint8_t ATTRIBUTE_ALIGN(32) msg[8];
|
||||||
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
||||||
USB_REQTYPE_INTERFACE_GET,
|
USB_REQTYPE_INTERFACE_GET,
|
||||||
USB_REQ_GETREPORT,
|
USB_REQ_GETREPORT,
|
||||||
(USB_REPTYPE_FEATURE<<8) | 0xf5,
|
(USB_REPTYPE_FEATURE<<8) | 0xf5,
|
||||||
0,
|
0,
|
||||||
sizeof(msg),
|
sizeof(msg),
|
||||||
msg,
|
msg,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
mac[0] = msg[2];
|
mac[0] = msg[2];
|
||||||
mac[1] = msg[3];
|
mac[1] = msg[3];
|
||||||
mac[2] = msg[4];
|
mac[2] = msg[4];
|
||||||
mac[3] = msg[5];
|
mac[3] = msg[5];
|
||||||
mac[4] = msg[6];
|
mac[4] = msg[6];
|
||||||
mac[5] = msg[7];
|
mac[5] = msg[7];
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ss_set_mac(struct ss_device *dev, const uint8_t *mac)
|
int ss_set_mac(struct ss_device *dev, const uint8_t *mac)
|
||||||
{
|
{
|
||||||
uint8_t ATTRIBUTE_ALIGN(32) msg[] = {0x01, 0x00, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]};
|
uint8_t ATTRIBUTE_ALIGN(32) msg[] = {0x01, 0x00, mac[0], mac[1],
|
||||||
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
mac[2], mac[3], mac[4], mac[5]};
|
||||||
USB_REQTYPE_INTERFACE_SET,
|
int ret = USB_WriteCtrlMsgAsync(dev->fd,
|
||||||
USB_REQ_SETREPORT,
|
USB_REQTYPE_INTERFACE_SET,
|
||||||
(USB_REPTYPE_FEATURE<<8) | 0xf5,
|
USB_REQ_SETREPORT,
|
||||||
0,
|
(USB_REPTYPE_FEATURE<<8) | 0xf5,
|
||||||
sizeof(msg),
|
0,
|
||||||
msg,
|
sizeof(msg),
|
||||||
NULL, NULL);
|
msg,
|
||||||
return ret;
|
NULL, NULL);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _ss_read(struct ss_device *dev)
|
static int _ss_read(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
return USB_WriteCtrlMsgAsync(
|
return USB_WriteCtrlMsgAsync(
|
||||||
dev->fd,
|
dev->fd,
|
||||||
USB_REQTYPE_INTERFACE_GET,
|
USB_REQTYPE_INTERFACE_GET,
|
||||||
USB_REQ_GETREPORT,
|
USB_REQ_GETREPORT,
|
||||||
(USB_REPTYPE_INPUT<<8) | 0x01,
|
(USB_REPTYPE_INPUT<<8) | 0x01,
|
||||||
0x0,
|
0x0,
|
||||||
SS_PAYLOAD_SIZE,
|
SS_PAYLOAD_SIZE,
|
||||||
&dev->pad,
|
&dev->pad,
|
||||||
&_ss_read_cb,
|
&_ss_read_cb,
|
||||||
dev);
|
dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_removal_cb(int result, void *usrdata)
|
static int _ss_removal_cb(int result, void *usrdata)
|
||||||
{
|
{
|
||||||
struct ss_device *dev = (struct ss_device*)usrdata;
|
struct ss_device *dev = (struct ss_device*)usrdata;
|
||||||
if (dev->device_id > 0) {
|
if (dev->device_id > 0)
|
||||||
_ss_dev_id_list_remove(dev->device_id);
|
{
|
||||||
_ss_dev_number--;
|
_ss_dev_id_list_remove(dev->device_id);
|
||||||
if (dev->removal_callback)
|
_ss_dev_number--;
|
||||||
dev->removal_callback(dev->removal_usrdata);
|
if (dev->removal_callback)
|
||||||
ss_initialize(dev);
|
dev->removal_callback(dev->removal_usrdata);
|
||||||
return 1;
|
ss_initialize(dev);
|
||||||
}
|
return 1;
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_set_operational(struct ss_device *dev)
|
static int _ss_set_operational(struct ss_device *dev)
|
||||||
{
|
{
|
||||||
uint8_t ATTRIBUTE_ALIGN(32) buf[17];
|
uint8_t ATTRIBUTE_ALIGN(32) buf[17];
|
||||||
return USB_WriteCtrlMsgAsync(
|
return USB_WriteCtrlMsgAsync(
|
||||||
dev->fd,
|
dev->fd,
|
||||||
USB_REQTYPE_INTERFACE_GET,
|
USB_REQTYPE_INTERFACE_GET,
|
||||||
USB_REQ_GETREPORT,
|
USB_REQ_GETREPORT,
|
||||||
(USB_REPTYPE_FEATURE<<8) | 0xf2,
|
(USB_REPTYPE_FEATURE<<8) | 0xf2,
|
||||||
0x0,
|
0x0,
|
||||||
17,
|
17,
|
||||||
buf,
|
buf,
|
||||||
&_ss_operational_cb,
|
&_ss_operational_cb,
|
||||||
dev);
|
dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_read_cb(int result, void *usrdata)
|
static int _ss_read_cb(int result, void *userdata)
|
||||||
{
|
{
|
||||||
if (usrdata) {
|
if (userdata)
|
||||||
struct ss_device *dev = (struct ss_device*)usrdata;
|
{
|
||||||
if (dev->reading) {
|
struct ss_device *dev = (struct ss_device*)userdata;
|
||||||
_ss_read(dev);
|
if (dev->reading)
|
||||||
if (dev->read_callback)
|
{
|
||||||
|
_ss_read(dev);
|
||||||
|
if (dev->read_callback)
|
||||||
dev->read_callback(dev->read_usrdata);
|
dev->read_callback(dev->read_usrdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_operational_cb(int result, void *usrdata)
|
static int _ss_operational_cb(int result, void *userdata)
|
||||||
{
|
{
|
||||||
struct ss_device *dev = (struct ss_device*)usrdata;
|
struct ss_device *dev = (struct ss_device*)userdata;
|
||||||
dev->enabled = 1;
|
dev->enabled = 1;
|
||||||
if (dev->reading) {
|
if (dev->reading)
|
||||||
_ss_read(dev);
|
_ss_read(dev);
|
||||||
}
|
return 1;
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int _ss_dev_id_list_exists(int id)
|
static int _ss_dev_id_list_exists(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SS_MAX_DEV; ++i) {
|
for (i = 0; i < SS_MAX_DEV; ++i)
|
||||||
if (_ss_dev_id_list[i] == id) return 1;
|
{
|
||||||
}
|
if (_ss_dev_id_list[i] == id)
|
||||||
return 0;
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_dev_id_list_add(int id)
|
static int _ss_dev_id_list_add(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SS_MAX_DEV; ++i) {
|
for (i = 0; i < SS_MAX_DEV; ++i)
|
||||||
if (_ss_dev_id_list[i] == 0) {
|
{
|
||||||
_ss_dev_id_list[i] = id;
|
if (_ss_dev_id_list[i] == 0)
|
||||||
return 1;
|
{
|
||||||
}
|
_ss_dev_id_list[i] = id;
|
||||||
}
|
return 1;
|
||||||
return 0;
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _ss_dev_id_list_remove(int id)
|
static int _ss_dev_id_list_remove(int id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < SS_MAX_DEV; ++i) {
|
for (i = 0; i < SS_MAX_DEV; ++i)
|
||||||
if (_ss_dev_id_list[i] == id) {
|
{
|
||||||
_ss_dev_id_list[i] = 0;
|
if (_ss_dev_id_list[i] == id)
|
||||||
return 1;
|
{
|
||||||
}
|
_ss_dev_id_list[i] = 0;
|
||||||
}
|
return 1;
|
||||||
return 0;
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -122,20 +122,34 @@ struct ss_device {
|
|||||||
|
|
||||||
|
|
||||||
int ss_init(void);
|
int ss_init(void);
|
||||||
|
|
||||||
int ss_initialize(struct ss_device *dev);
|
int ss_initialize(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_open(struct ss_device *dev);
|
int ss_open(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_close(struct ss_device *dev);
|
int ss_close(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_is_connected(struct ss_device *dev);
|
int ss_is_connected(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_set_read_cb(struct ss_device *dev, ss_usb_callback cb, void *usrdata);
|
int ss_set_read_cb(struct ss_device *dev,
|
||||||
int ss_set_removal_cb(struct ss_device *dev, ss_usb_callback cb, void *usrdata);
|
ss_usb_callback cb, void *usrdata);
|
||||||
|
|
||||||
|
int ss_set_removal_cb(struct ss_device *dev,
|
||||||
|
ss_usb_callback cb, void *usrdata);
|
||||||
|
|
||||||
int ss_start_reading(struct ss_device *dev);
|
int ss_start_reading(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_stop_reading(struct ss_device *dev);
|
int ss_stop_reading(struct ss_device *dev);
|
||||||
|
|
||||||
int ss_set_led(struct ss_device *dev, int led);
|
int ss_set_led(struct ss_device *dev, int led);
|
||||||
int ss_set_rumble(struct ss_device *dev, uint8_t duration_right, uint8_t power_right, uint8_t duration_left, uint8_t power_left);
|
|
||||||
|
int ss_set_rumble(struct ss_device *dev, uint8_t duration_right,
|
||||||
|
uint8_t power_right, uint8_t duration_left, uint8_t power_left);
|
||||||
|
|
||||||
int ss_get_bd_address(struct ss_device *dev, uint8_t *mac);
|
int ss_get_bd_address(struct ss_device *dev, uint8_t *mac);
|
||||||
|
|
||||||
int ss_get_paired_mac(struct ss_device *dev, uint8_t *mac);
|
int ss_get_paired_mac(struct ss_device *dev, uint8_t *mac);
|
||||||
|
|
||||||
int ss_set_paired_mac(struct ss_device *dev, const uint8_t *mac);
|
int ss_set_paired_mac(struct ss_device *dev, const uint8_t *mac);
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,9 +275,9 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
|
|||||||
int scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff;
|
int scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff;
|
||||||
int scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff;
|
int scaled_screen_y = (2 * mouse_y * 0x7fff) / (int)vp.full_height - 0x7fff;
|
||||||
if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff)
|
if (scaled_screen_x < -0x7fff || scaled_screen_x > 0x7fff)
|
||||||
scaled_screen_x = -0x8000; // OOB
|
scaled_screen_x = -0x8000; /* OOB */
|
||||||
if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff)
|
if (scaled_screen_y < -0x7fff || scaled_screen_y > 0x7fff)
|
||||||
scaled_screen_y = -0x8000; // OOB
|
scaled_screen_y = -0x8000; /* OOB */
|
||||||
|
|
||||||
mouse_x -= vp.x;
|
mouse_x -= vp.x;
|
||||||
mouse_y -= vp.y;
|
mouse_y -= vp.y;
|
||||||
@ -285,9 +285,9 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y,
|
|||||||
int scaled_x = (2 * mouse_x * 0x7fff) / (int)vp.width - 0x7fff;
|
int scaled_x = (2 * mouse_x * 0x7fff) / (int)vp.width - 0x7fff;
|
||||||
int scaled_y = (2 * mouse_y * 0x7fff) / (int)vp.height - 0x7fff;
|
int scaled_y = (2 * mouse_y * 0x7fff) / (int)vp.height - 0x7fff;
|
||||||
if (scaled_x < -0x7fff || scaled_x > 0x7fff)
|
if (scaled_x < -0x7fff || scaled_x > 0x7fff)
|
||||||
scaled_x = -0x8000; // OOB
|
scaled_x = -0x8000; /* OOB */
|
||||||
if (scaled_y < -0x7fff || scaled_y > 0x7fff)
|
if (scaled_y < -0x7fff || scaled_y > 0x7fff)
|
||||||
scaled_y = -0x8000; // OOB
|
scaled_y = -0x8000; /* OOB */
|
||||||
|
|
||||||
*res_x = scaled_x;
|
*res_x = scaled_x;
|
||||||
*res_y = scaled_y;
|
*res_y = scaled_y;
|
||||||
@ -1193,7 +1193,8 @@ const struct input_key_map input_config_key_map[] = {
|
|||||||
{ "rctrl", RETROK_RCTRL },
|
{ "rctrl", RETROK_RCTRL },
|
||||||
{ "ralt", RETROK_RALT },
|
{ "ralt", RETROK_RALT },
|
||||||
|
|
||||||
/* Keys not referenced in any keyboard mapping (except perhaps apple_key_map_hidusage) */
|
/* Keys not referenced in any keyboard mapping
|
||||||
|
* (except perhaps apple_key_map_hidusage) */
|
||||||
{ "caret", RETROK_CARET },
|
{ "caret", RETROK_CARET },
|
||||||
{ "underscore", RETROK_UNDERSCORE },
|
{ "underscore", RETROK_UNDERSCORE },
|
||||||
{ "exclaim", RETROK_EXCLAIM },
|
{ "exclaim", RETROK_EXCLAIM },
|
||||||
@ -1450,8 +1451,10 @@ void input_config_autoconfigure_joypad(unsigned index,
|
|||||||
/* First internal */
|
/* First internal */
|
||||||
for (i = 0; input_builtin_autoconfs[i]; i++)
|
for (i = 0; input_builtin_autoconfs[i]; i++)
|
||||||
{
|
{
|
||||||
config_file_t *conf = config_file_new_from_string(input_builtin_autoconfs[i]);
|
config_file_t *conf = (config_file_t*)
|
||||||
bool success = input_try_autoconfigure_joypad_from_conf(conf, index, name, driver, block_osd_spam);
|
config_file_new_from_string(input_builtin_autoconfs[i]);
|
||||||
|
bool success = input_try_autoconfigure_joypad_from_conf(conf,
|
||||||
|
index, name, driver, block_osd_spam);
|
||||||
config_file_free(conf);
|
config_file_free(conf);
|
||||||
if (success)
|
if (success)
|
||||||
break;
|
break;
|
||||||
|
@ -54,7 +54,8 @@ void input_keyboard_line_free(input_keyboard_line_t *state);
|
|||||||
void input_keyboard_event(bool down, unsigned code, uint32_t character,
|
void input_keyboard_event(bool down, unsigned code, uint32_t character,
|
||||||
uint16_t mod);
|
uint16_t mod);
|
||||||
|
|
||||||
const char **input_keyboard_start_line(void *userdata, input_keyboard_line_complete_t cb);
|
const char **input_keyboard_start_line(void *userdata,
|
||||||
|
input_keyboard_line_complete_t cb);
|
||||||
|
|
||||||
/* Wait for keys to be pressed (used for binding keys in the menu).
|
/* Wait for keys to be pressed (used for binding keys in the menu).
|
||||||
* Callback returns false when all polling is done. */
|
* Callback returns false when all polling is done. */
|
||||||
|
@ -26,7 +26,9 @@ static void nullinput_input_poll(void *data)
|
|||||||
(void)data;
|
(void)data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t nullinput_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
|
static int16_t nullinput_input_state(void *data,
|
||||||
|
const struct retro_keybind **retro_keybinds, unsigned port,
|
||||||
|
unsigned device, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
(void)retro_keybinds;
|
(void)retro_keybinds;
|
||||||
@ -60,7 +62,8 @@ static uint64_t nullinput_get_capabilities(void *data)
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nullinput_set_sensor_state(void *data, unsigned port, enum retro_sensor_action action, unsigned event_rate)
|
static bool nullinput_set_sensor_state(void *data,
|
||||||
|
unsigned port, enum retro_sensor_action action, unsigned event_rate)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,12 @@ static bool ps3_joypad_init(void)
|
|||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], "SixAxis Controller", sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, ps3_joypad_name(autoconf_pad), ps3_joypad.ident);
|
"SixAxis Controller",
|
||||||
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
ps3_joypad_name(autoconf_pad),
|
||||||
|
ps3_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -68,10 +72,18 @@ static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = ps3->analog_state[port_num][0][0]; break;
|
case 0:
|
||||||
case 1: val = ps3->analog_state[port_num][0][1]; break;
|
val = ps3->analog_state[port_num][0][0];
|
||||||
case 2: val = ps3->analog_state[port_num][1][0]; break;
|
break;
|
||||||
case 3: val = ps3->analog_state[port_num][1][1]; break;
|
case 1:
|
||||||
|
val = ps3->analog_state[port_num][0][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = ps3->analog_state[port_num][1][0];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = ps3->analog_state[port_num][1][1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
|
@ -60,7 +60,8 @@ static void psp_input_poll(void *data)
|
|||||||
#endif
|
#endif
|
||||||
(void)ret;
|
(void)ret;
|
||||||
|
|
||||||
psp->analog_state[0][0][0] = psp->analog_state[0][0][1] = psp->analog_state[0][1][0] = psp->analog_state[0][1][1] = 0;
|
psp->analog_state[0][0][0] = psp->analog_state[0][0][1] =
|
||||||
|
psp->analog_state[0][1][0] = psp->analog_state[0][1][1] = 0;
|
||||||
psp->pad_state = 0;
|
psp->pad_state = 0;
|
||||||
psp->pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
psp->pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_LEFT) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
||||||
psp->pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
psp->pad_state |= (STATE_BUTTON(state_tmp) & PSP_CTRL_DOWN) ? (1ULL << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
||||||
@ -146,7 +147,8 @@ static void* psp_input_initialize(void)
|
|||||||
static bool psp_input_key_pressed(void *data, int key)
|
static bool psp_input_key_pressed(void *data, int key)
|
||||||
{
|
{
|
||||||
psp_input_t *psp = (psp_input_t*)data;
|
psp_input_t *psp = (psp_input_t*)data;
|
||||||
return (g_extern.lifecycle_state & (1ULL << key)) || input_joypad_pressed(psp->joypad, 0, g_settings.input.binds[0], key);
|
return (g_extern.lifecycle_state & (1ULL << key)) ||
|
||||||
|
input_joypad_pressed(psp->joypad, 0, g_settings.input.binds[0], key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t psp_input_get_capabilities(void *data)
|
static uint64_t psp_input_get_capabilities(void *data)
|
||||||
|
@ -25,8 +25,12 @@ static bool psp_joypad_init(void)
|
|||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PADS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], psp_joypad_name(autoconf_pad), sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, psp_joypad_name(autoconf_pad), psp_joypad.ident);
|
psp_joypad_name(autoconf_pad),
|
||||||
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
psp_joypad_name(autoconf_pad),
|
||||||
|
psp_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -67,10 +71,18 @@ static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = psp->analog_state[port_num][0][0]; break;
|
case 0:
|
||||||
case 1: val = psp->analog_state[port_num][0][1]; break;
|
val = psp->analog_state[port_num][0][0];
|
||||||
case 2: val = psp->analog_state[port_num][1][0]; break;
|
break;
|
||||||
case 3: val = psp->analog_state[port_num][1][1]; break;
|
case 1:
|
||||||
|
val = psp->analog_state[port_num][0][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = psp->analog_state[port_num][1][0];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = psp->analog_state[port_num][1][1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
|
@ -67,7 +67,9 @@ typedef struct qnx_input
|
|||||||
unsigned pointer_count;
|
unsigned pointer_count;
|
||||||
|
|
||||||
int touch_map[MAX_TOUCH];
|
int touch_map[MAX_TOUCH];
|
||||||
/*The first pointer_count indices of touch_map will be a valid, active index in pointer array.
|
/*
|
||||||
|
* The first pointer_count indices of touch_map will be a valid,
|
||||||
|
* active index in pointer array.
|
||||||
* Saves us from searching through pointer array when polling state.
|
* Saves us from searching through pointer array when polling state.
|
||||||
*/
|
*/
|
||||||
input_device_t *port_device[MAX_PADS];
|
input_device_t *port_device[MAX_PADS];
|
||||||
@ -77,11 +79,14 @@ typedef struct qnx_input
|
|||||||
uint64_t pad_state[MAX_PADS];
|
uint64_t pad_state[MAX_PADS];
|
||||||
} qnx_input_t;
|
} qnx_input_t;
|
||||||
|
|
||||||
static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller, int port);
|
static void qnx_input_autodetect_gamepad(void *data,
|
||||||
|
input_device_t* controller, int port);
|
||||||
|
|
||||||
static void initController(void *data, input_device_t* controller);
|
static void initController(void *data, input_device_t* controller);
|
||||||
|
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
static void process_gamepad_event(void *data, screen_event_t screen_event, int type)
|
static void process_gamepad_event(void *data,
|
||||||
|
screen_event_t screen_event, int type)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
screen_device_t device;
|
screen_device_t device;
|
||||||
@ -90,7 +95,8 @@ static void process_gamepad_event(void *data, screen_event_t screen_event, int t
|
|||||||
qnx_input_t *qnx = (qnx_input_t*)data;
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
||||||
(void)type;
|
(void)type;
|
||||||
|
|
||||||
screen_get_event_property_pv(screen_event, SCREEN_PROPERTY_DEVICE, (void**)&device);
|
screen_get_event_property_pv(screen_event,
|
||||||
|
SCREEN_PROPERTY_DEVICE, (void**)&device);
|
||||||
|
|
||||||
for (i = 0; i < MAX_PADS; ++i)
|
for (i = 0; i < MAX_PADS; ++i)
|
||||||
{
|
{
|
||||||
@ -104,25 +110,30 @@ static void process_gamepad_event(void *data, screen_event_t screen_event, int t
|
|||||||
if (!controller)
|
if (!controller)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Store the controller's new state.
|
/* Store the controller's new state. */
|
||||||
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons);
|
screen_get_event_property_iv(screen_event,
|
||||||
|
SCREEN_PROPERTY_BUTTONS, &controller->buttons);
|
||||||
|
|
||||||
uint64_t *state_cur = (uint64_t*)&qnx->pad_state[controller->port];
|
uint64_t *state_cur = (uint64_t*)&qnx->pad_state[controller->port];
|
||||||
//int i;
|
|
||||||
|
|
||||||
*state_cur = 0;
|
*state_cur = 0;
|
||||||
for (i = 0; i < 20; i++)
|
for (i = 0; i < 20; i++)
|
||||||
*state_cur |= (controller->buttons & (1 << i) ? (1 << i) : 0);
|
*state_cur |= (controller->buttons & (1 << i) ? (1 << i) : 0);
|
||||||
|
|
||||||
if (controller->analogCount > 0)
|
if (controller->analogCount > 0)
|
||||||
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0);
|
screen_get_event_property_iv(screen_event,
|
||||||
|
SCREEN_PROPERTY_ANALOG0, controller->analog0);
|
||||||
|
|
||||||
if (controller->analogCount == 2)
|
if (controller->analogCount == 2)
|
||||||
screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1);
|
screen_get_event_property_iv(screen_event,
|
||||||
|
SCREEN_PROPERTY_ANALOG1, controller->analog1);
|
||||||
|
|
||||||
//Only player 1
|
/* Only player 1
|
||||||
//TODO: Am I missing something? Is there a better way?
|
* TODO: Am I missing something? Is there a better way?
|
||||||
if((controller->port == 0) && (controller->buttons & g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey))
|
*/
|
||||||
|
if((controller->port == 0) &&
|
||||||
|
(controller->buttons &
|
||||||
|
g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey))
|
||||||
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,25 +147,34 @@ static void loadController(void *data, input_device_t* controller)
|
|||||||
if (!qnx)
|
if (!qnx)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Query libscreen for information about this device.
|
/* Query libscreen for information about this device. */
|
||||||
screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_TYPE, &controller->type);
|
screen_get_device_property_iv(controller->handle,
|
||||||
screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_ID_STRING, sizeof(controller->id), controller->id);
|
SCREEN_PROPERTY_TYPE, &controller->type);
|
||||||
screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_VENDOR, sizeof(controller->id), controller->vendor);
|
screen_get_device_property_cv(controller->handle,
|
||||||
screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_PRODUCT, sizeof(controller->id), controller->product);
|
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);
|
||||||
|
|
||||||
if (controller->type == SCREEN_EVENT_GAMEPAD || controller->type == SCREEN_EVENT_JOYSTICK)
|
if (controller->type == SCREEN_EVENT_GAMEPAD ||
|
||||||
|
controller->type == SCREEN_EVENT_JOYSTICK)
|
||||||
{
|
{
|
||||||
screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount);
|
screen_get_device_property_iv(controller->handle,
|
||||||
|
SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount);
|
||||||
|
|
||||||
// Check for the existence of analog sticks.
|
/* Check for the existence of analog sticks. */
|
||||||
if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0))
|
if (!screen_get_device_property_iv(controller->handle,
|
||||||
|
SCREEN_PROPERTY_ANALOG0, controller->analog0))
|
||||||
++controller->analogCount;
|
++controller->analogCount;
|
||||||
|
|
||||||
if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1))
|
if (!screen_get_device_property_iv(controller->handle,
|
||||||
|
SCREEN_PROPERTY_ANALOG1, controller->analog1))
|
||||||
++controller->analogCount;
|
++controller->analogCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Screen service will map supported controllers, we still might need to adjust.
|
/* Screen service will map supported controllers,
|
||||||
|
* we still might need to adjust. */
|
||||||
qnx_input_autodetect_gamepad(qnx, controller, controller->port);
|
qnx_input_autodetect_gamepad(qnx, controller, controller->port);
|
||||||
|
|
||||||
if (controller->type == SCREEN_EVENT_GAMEPAD)
|
if (controller->type == SCREEN_EVENT_GAMEPAD)
|
||||||
@ -175,7 +195,7 @@ extern screen_context_t screen_ctx;
|
|||||||
|
|
||||||
static void discoverControllers(void *data)
|
static void discoverControllers(void *data)
|
||||||
{
|
{
|
||||||
// Get an array of all available devices.
|
/* Get an array of all available devices. */
|
||||||
int deviceCount;
|
int deviceCount;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
screen_event_t *event;
|
screen_event_t *event;
|
||||||
@ -183,11 +203,14 @@ static void discoverControllers(void *data)
|
|||||||
|
|
||||||
(void)event;
|
(void)event;
|
||||||
|
|
||||||
screen_get_context_property_iv(screen_ctx, SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount);
|
screen_get_context_property_iv(screen_ctx,
|
||||||
screen_device_t* devices_found = (screen_device_t*)calloc(deviceCount, sizeof(screen_device_t));
|
SCREEN_PROPERTY_DEVICE_COUNT, &deviceCount);
|
||||||
screen_get_context_property_pv(screen_ctx, SCREEN_PROPERTY_DEVICES, (void**)devices_found);
|
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.
|
/* Scan the list for gamepad and joystick devices. */
|
||||||
for(i = 0; i < qnx->pads_connected; ++i)
|
for(i = 0; i < qnx->pads_connected; ++i)
|
||||||
initController(qnx, &qnx->devices[i]);
|
initController(qnx, &qnx->devices[i]);
|
||||||
|
|
||||||
@ -196,9 +219,13 @@ static void discoverControllers(void *data)
|
|||||||
for (i = 0; i < deviceCount; i++)
|
for (i = 0; i < deviceCount; i++)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
screen_get_device_property_iv(devices_found[i], SCREEN_PROPERTY_TYPE, &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)
|
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].handle = devices_found[i];
|
||||||
qnx->devices[qnx->pads_connected].index = qnx->pads_connected;
|
qnx->devices[qnx->pads_connected].index = qnx->pads_connected;
|
||||||
@ -219,7 +246,7 @@ static void initController(void *data, input_device_t* controller)
|
|||||||
|
|
||||||
if (qnx)
|
if (qnx)
|
||||||
{
|
{
|
||||||
// Initialize controller values.
|
/* Initialize controller values. */
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
controller->handle = 0;
|
controller->handle = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -227,8 +254,12 @@ static void initController(void *data, input_device_t* controller)
|
|||||||
controller->analogCount = 0;
|
controller->analogCount = 0;
|
||||||
controller->buttonCount = 0;
|
controller->buttonCount = 0;
|
||||||
controller->buttons = 0;
|
controller->buttons = 0;
|
||||||
controller->analog0[0] = controller->analog0[1] = controller->analog0[2] = 0;
|
controller->analog0[0] = 0;
|
||||||
controller->analog1[0] = controller->analog1[1] = controller->analog1[2] = 0;
|
controller->analog0[1] = 0;
|
||||||
|
controller->analog0[2] = 0;
|
||||||
|
controller->analog1[0] = 0;
|
||||||
|
controller->analog1[1] = 0;
|
||||||
|
controller->analog1[2] = 0;
|
||||||
controller->port = -1;
|
controller->port = -1;
|
||||||
controller->device = -1;
|
controller->device = -1;
|
||||||
controller->index = -1;
|
controller->index = -1;
|
||||||
@ -237,7 +268,8 @@ static void initController(void *data, input_device_t* controller)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller, int port)
|
static void qnx_input_autodetect_gamepad(void *data,
|
||||||
|
input_device_t* controller, int port)
|
||||||
{
|
{
|
||||||
char name_buf[256];
|
char name_buf[256];
|
||||||
qnx_input_t *qnx = (qnx_input_t*)data;
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
||||||
@ -247,11 +279,13 @@ static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller,
|
|||||||
|
|
||||||
name_buf[0] = '\0';
|
name_buf[0] = '\0';
|
||||||
|
|
||||||
//ID: A-BBBB-CCCC-D.D
|
/* ID: A-BBBB-CCCC-D.D
|
||||||
//A is the device's index in the array returned by screen_get_context_property_pv()
|
* A is the device's index in the array
|
||||||
//BBBB is the device's Vendor ID (in hexadecimal)
|
* returned by screen_get_context_property_pv()
|
||||||
//CCCC is the device's Product ID (also in hexadecimal)
|
* BBBB is the device's Vendor ID (in hexadecimal)
|
||||||
//D.D is the device's version number
|
* CCCC is the device's Product ID (also in hexadecimal)
|
||||||
|
* D.D is the device's version number
|
||||||
|
*/
|
||||||
if (controller)
|
if (controller)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
@ -269,7 +303,8 @@ static void qnx_input_autodetect_gamepad(void *data, input_device_t* controller,
|
|||||||
|
|
||||||
if (name_buf[0] != '\0')
|
if (name_buf[0] != '\0')
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[port], name_buf, sizeof(g_settings.input.device_names[port]));
|
strlcpy(g_settings.input.device_names[port],
|
||||||
|
name_buf, sizeof(g_settings.input.device_names[port]));
|
||||||
input_config_autoconfigure_joypad(port, name_buf, qnx->joypad);
|
input_config_autoconfigure_joypad(port, name_buf, qnx->joypad);
|
||||||
|
|
||||||
controller->port = port;
|
controller->port = port;
|
||||||
@ -293,18 +328,24 @@ static void process_keyboard_event(void *data, screen_event_t event, int type)
|
|||||||
scan = 0;
|
scan = 0;
|
||||||
cap = 0;
|
cap = 0;
|
||||||
|
|
||||||
//Get Keyboard state
|
/* Get Keyboard state. */
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SYM, &sym);
|
screen_get_event_property_iv(event,
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
|
SCREEN_PROPERTY_KEY_SYM, &sym);
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
screen_get_event_property_iv(event,
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_SCAN, &scan);
|
SCREEN_PROPERTY_KEY_MODIFIERS, &modifiers);
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_KEY_CAP, &cap);
|
screen_get_event_property_iv(event,
|
||||||
|
SCREEN_PROPERTY_KEY_FLAGS, &flags);
|
||||||
|
screen_get_event_property_iv(event,
|
||||||
|
SCREEN_PROPERTY_KEY_SCAN, &scan);
|
||||||
|
screen_get_event_property_iv(event,
|
||||||
|
SCREEN_PROPERTY_KEY_CAP, &cap);
|
||||||
|
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
//Find device that pressed the key
|
/* Find device that pressed the key. */
|
||||||
screen_device_t device;
|
screen_device_t device;
|
||||||
|
|
||||||
screen_get_event_property_pv(event, SCREEN_PROPERTY_DEVICE, (void**)&device);
|
screen_get_event_property_pv(event,
|
||||||
|
SCREEN_PROPERTY_DEVICE, (void**)&device);
|
||||||
|
|
||||||
for (i = 0; i < MAX_PADS; ++i)
|
for (i = 0; i < MAX_PADS; ++i)
|
||||||
{
|
{
|
||||||
@ -329,7 +370,9 @@ static void process_keyboard_event(void *data, screen_event_t event, int type)
|
|||||||
|
|
||||||
for (b = 0; b < RARCH_FIRST_CUSTOM_BIND; ++b)
|
for (b = 0; b < RARCH_FIRST_CUSTOM_BIND; ++b)
|
||||||
{
|
{
|
||||||
if ((unsigned int)g_settings.input.binds[controller->port][b].joykey == (unsigned int)(sym & 0xFF))
|
if ((unsigned int)
|
||||||
|
g_settings.input.binds[controller->port][b].joykey
|
||||||
|
== (unsigned int)(sym & 0xFF))
|
||||||
{
|
{
|
||||||
if (flags & KEY_DOWN)
|
if (flags & KEY_DOWN)
|
||||||
{
|
{
|
||||||
@ -341,8 +384,10 @@ static void process_keyboard_event(void *data, screen_event_t event, int type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Am I missing something? Is there a better way?
|
/* TODO: Am I missing something? Is there a better way? */
|
||||||
if((controller->port == 0) && ((unsigned int)g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey == (unsigned int)(sym&0xFF)))
|
if((controller->port == 0) && ((unsigned int)
|
||||||
|
g_settings.input.binds[0][RARCH_MENU_TOGGLE].joykey
|
||||||
|
== (unsigned int)(sym&0xFF)))
|
||||||
{
|
{
|
||||||
if (flags & KEY_DOWN)
|
if (flags & KEY_DOWN)
|
||||||
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
||||||
@ -355,13 +400,15 @@ static void process_touch_event(void *data, screen_event_t event, int type)
|
|||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
qnx_input_t *qnx = (qnx_input_t*)data;
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
||||||
|
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_TOUCH_ID, (int*)&contact_id);
|
screen_get_event_property_iv(event,
|
||||||
screen_get_event_property_iv(event, SCREEN_PROPERTY_SOURCE_POSITION, pos);
|
SCREEN_PROPERTY_TOUCH_ID, (int*)&contact_id);
|
||||||
|
screen_get_event_property_iv(event,
|
||||||
|
SCREEN_PROPERTY_SOURCE_POSITION, pos);
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case SCREEN_EVENT_MTOUCH_TOUCH:
|
case SCREEN_EVENT_MTOUCH_TOUCH:
|
||||||
//Find a free touch struct
|
/* Find a free touch struct. */
|
||||||
for(i = 0; i < MAX_TOUCH; ++i)
|
for(i = 0; i < MAX_TOUCH; ++i)
|
||||||
{
|
{
|
||||||
if(qnx->pointer[i].contact_id == -1)
|
if(qnx->pointer[i].contact_id == -1)
|
||||||
@ -370,25 +417,34 @@ static void process_touch_event(void *data, screen_event_t event, int type)
|
|||||||
input_translate_coord_viewport(pos[0], pos[1],
|
input_translate_coord_viewport(pos[0], pos[1],
|
||||||
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
||||||
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
||||||
//Add this pointer to the map to signal it's valid
|
|
||||||
|
/* Add this pointer to the map to signal it's valid. */
|
||||||
qnx->pointer[i].map = qnx->pointer_count;
|
qnx->pointer[i].map = qnx->pointer_count;
|
||||||
qnx->touch_map[qnx->pointer_count] = i;
|
qnx->touch_map[qnx->pointer_count] = i;
|
||||||
qnx->pointer_count++;
|
qnx->pointer_count++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
#if 0
|
||||||
//printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1], qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4], qnx->touch_map[5]);fflush(stdout);
|
printf("New Touch: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);
|
||||||
|
fflush(stdout);
|
||||||
|
printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1],
|
||||||
|
qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4],
|
||||||
|
qnx->touch_map[5]);
|
||||||
|
fflush(stdout);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCREEN_EVENT_MTOUCH_RELEASE:
|
case SCREEN_EVENT_MTOUCH_RELEASE:
|
||||||
for(i = 0; i < MAX_TOUCH; ++i)
|
for(i = 0; i < MAX_TOUCH; ++i)
|
||||||
{
|
{
|
||||||
if(qnx->pointer[i].contact_id == contact_id)
|
if(qnx->pointer[i].contact_id == contact_id)
|
||||||
{
|
{
|
||||||
//Invalidate the finger
|
/* Invalidate the finger. */
|
||||||
qnx->pointer[i].contact_id = -1;
|
qnx->pointer[i].contact_id = -1;
|
||||||
|
|
||||||
//Remove pointer from map and shift remaining valid ones to the front
|
/* Remove pointer from map and shift
|
||||||
|
* remaining valid ones to the front. */
|
||||||
qnx->touch_map[qnx->pointer[i].map] = -1;
|
qnx->touch_map[qnx->pointer[i].map] = -1;
|
||||||
for(j = qnx->pointer[i].map; j < qnx->pointer_count; ++j)
|
for(j = qnx->pointer[i].map; j < qnx->pointer_count; ++j)
|
||||||
{
|
{
|
||||||
@ -400,19 +456,29 @@ static void process_touch_event(void *data, screen_event_t event, int type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
#if 0
|
||||||
//printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1], qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4], qnx->touch_map[5]);fflush(stdout);
|
printf("Release: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);
|
||||||
|
fflush(stdout);
|
||||||
|
printf("Map: %d %d %d %d %d %d\n", qnx->touch_map[0], qnx->touch_map[1],
|
||||||
|
qnx->touch_map[2], qnx->touch_map[3], qnx->touch_map[4],
|
||||||
|
qnx->touch_map[5]);
|
||||||
|
fflush(stdout);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCREEN_EVENT_MTOUCH_MOVE:
|
case SCREEN_EVENT_MTOUCH_MOVE:
|
||||||
//Find the finger we're tracking and update
|
/* Find the finger we're tracking and update. */
|
||||||
for(i = 0; i < qnx->pointer_count; ++i)
|
for(i = 0; i < qnx->pointer_count; ++i)
|
||||||
{
|
{
|
||||||
if(qnx->pointer[i].contact_id == contact_id)
|
if(qnx->pointer[i].contact_id == contact_id)
|
||||||
{
|
{
|
||||||
gl_t *gl = (gl_t*)driver.video_data;
|
gl_t *gl = (gl_t*)driver.video_data;
|
||||||
|
|
||||||
//During a move, we can go ~30 pixel into the bezel which gives negative
|
/*During a move, we can go ~30 pixel into the
|
||||||
//numbers or numbers larger than the screen res. Normalize.
|
* bezel which gives negative numbers or
|
||||||
|
* numbers larger than the screen resolution.
|
||||||
|
*
|
||||||
|
* Normalize. */
|
||||||
if(pos[0] < 0)
|
if(pos[0] < 0)
|
||||||
pos[0] = 0;
|
pos[0] = 0;
|
||||||
if(pos[0] > gl->full_x)
|
if(pos[0] > gl->full_x)
|
||||||
@ -426,7 +492,11 @@ static void process_touch_event(void *data, screen_event_t event, int type)
|
|||||||
input_translate_coord_viewport(pos[0], pos[1],
|
input_translate_coord_viewport(pos[0], pos[1],
|
||||||
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
&qnx->pointer[i].x, &qnx->pointer[i].y,
|
||||||
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
&qnx->pointer[i].full_x, &qnx->pointer[i].full_y);
|
||||||
//printf("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1], contact_id);fflush(stdout);
|
#if 0
|
||||||
|
printf("Move: x:%d, y:%d, id:%d\n", pos[0], pos[1],
|
||||||
|
contact_id);
|
||||||
|
fflush(stdout);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,7 +529,7 @@ static void handle_screen_event(void *data, bps_event_t *event)
|
|||||||
break;
|
break;
|
||||||
case SCREEN_EVENT_DEVICE:
|
case SCREEN_EVENT_DEVICE:
|
||||||
{
|
{
|
||||||
// A device was attached or removed.
|
/* A device was attached or removed. */
|
||||||
screen_device_t device;
|
screen_device_t device;
|
||||||
int attached, type, i;
|
int attached, type, i;
|
||||||
|
|
||||||
@ -472,7 +542,11 @@ static void handle_screen_event(void *data, bps_event_t *event)
|
|||||||
screen_get_device_property_iv(device,
|
screen_get_device_property_iv(device,
|
||||||
SCREEN_PROPERTY_TYPE, &type);
|
SCREEN_PROPERTY_TYPE, &type);
|
||||||
|
|
||||||
if (attached && (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK || type == SCREEN_EVENT_KEYBOARD))
|
if (attached && (
|
||||||
|
type == SCREEN_EVENT_GAMEPAD ||
|
||||||
|
type == SCREEN_EVENT_JOYSTICK ||
|
||||||
|
type == SCREEN_EVENT_KEYBOARD)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
for (i = 0; i < MAX_PADS; ++i)
|
for (i = 0; i < MAX_PADS; ++i)
|
||||||
{
|
{
|
||||||
@ -490,7 +564,8 @@ static void handle_screen_event(void *data, bps_event_t *event)
|
|||||||
{
|
{
|
||||||
if (device == qnx->devices[i].handle)
|
if (device == qnx->devices[i].handle)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Device %s: Disconnected.\n", qnx->devices[i].id);
|
RARCH_LOG("Device %s: Disconnected.\n",
|
||||||
|
qnx->devices[i].id);
|
||||||
initController(data, &qnx->devices[i]);
|
initController(data, &qnx->devices[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -519,7 +594,7 @@ static void handle_navigator_event(void *data, bps_event_t *event)
|
|||||||
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
g_extern.lifecycle_state ^= (1ULL << RARCH_MENU_TOGGLE);
|
||||||
break;
|
break;
|
||||||
case NAVIGATOR_EXIT:
|
case NAVIGATOR_EXIT:
|
||||||
//Catch this in thumbnail loop
|
/* Catch this in thumbnail loop. */
|
||||||
break;
|
break;
|
||||||
case NAVIGATOR_WINDOW_STATE:
|
case NAVIGATOR_WINDOW_STATE:
|
||||||
state = navigator_event_get_window_state(event);
|
state = navigator_event_get_window_state(event);
|
||||||
@ -529,7 +604,7 @@ static void handle_navigator_event(void *data, bps_event_t *event)
|
|||||||
case NAVIGATOR_WINDOW_THUMBNAIL:
|
case NAVIGATOR_WINDOW_THUMBNAIL:
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
//Block until we get a resume or exit event
|
/* Block until we get a resume or exit event. */
|
||||||
rc = bps_get_event(&event_pause, -1);
|
rc = bps_get_event(&event_pause, -1);
|
||||||
|
|
||||||
if(bps_event_get_code(event_pause) == NAVIGATOR_WINDOW_STATE)
|
if(bps_event_get_code(event_pause) == NAVIGATOR_WINDOW_STATE)
|
||||||
@ -556,7 +631,6 @@ static void handle_navigator_event(void *data, bps_event_t *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//External Functions
|
|
||||||
static void *qnx_input_init(void)
|
static void *qnx_input_init(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@ -579,11 +653,12 @@ static void *qnx_input_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
//Find currently connected gamepads
|
/* Find currently connected gamepads. */
|
||||||
discoverControllers(qnx);
|
discoverControllers(qnx);
|
||||||
#else
|
#else
|
||||||
//Initialize Playbook keyboard
|
/* Initialize Playbook keyboard. */
|
||||||
strlcpy(qnx->devices[0].id, "0A5C-8502", sizeof(qnx->devices[0].id));
|
strlcpy(qnx->devices[0].id, "0A5C-8502",
|
||||||
|
sizeof(qnx->devices[0].id));
|
||||||
qnx_input_autodetect_gamepad(qnx, &qnx->devices[0], 0);
|
qnx_input_autodetect_gamepad(qnx, &qnx->devices[0], 0);
|
||||||
qnx->pads_connected = 1;
|
qnx->pads_connected = 1;
|
||||||
#endif
|
#endif
|
||||||
@ -594,7 +669,7 @@ static void *qnx_input_init(void)
|
|||||||
static void qnx_input_poll(void *data)
|
static void qnx_input_poll(void *data)
|
||||||
{
|
{
|
||||||
(void)data;
|
(void)data;
|
||||||
//Request and process all available BPS events
|
/* Request and process all available BPS events. */
|
||||||
|
|
||||||
int rc, domain;
|
int rc, domain;
|
||||||
|
|
||||||
@ -620,19 +695,23 @@ static void qnx_input_poll(void *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_keybinds, unsigned port, unsigned device, unsigned index, unsigned id)
|
static int16_t qnx_input_state(void *data,
|
||||||
|
const struct retro_keybind **retro_keybinds,
|
||||||
|
unsigned port, unsigned device, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
qnx_input_t *qnx = (qnx_input_t*)data;
|
qnx_input_t *qnx = (qnx_input_t*)data;
|
||||||
|
|
||||||
switch (device)
|
switch (device)
|
||||||
{
|
{
|
||||||
case RETRO_DEVICE_JOYPAD:
|
case RETRO_DEVICE_JOYPAD:
|
||||||
return input_joypad_pressed(qnx->joypad, port, (unsigned int)g_settings.input.binds[port], id);
|
return input_joypad_pressed(qnx->joypad, port,
|
||||||
|
(unsigned int)g_settings.input.binds[port], id);
|
||||||
#ifdef HAVE_BB10
|
#ifdef HAVE_BB10
|
||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
//Need to return [-0x8000, 0x7fff]
|
/* Need to return [-0x8000, 0x7fff].
|
||||||
//Gamepad API gives us [-128, 127] with (0,0) center
|
* Gamepad API gives us [-128, 127] with (0,0) center
|
||||||
//Untested
|
* Untested
|
||||||
|
*/
|
||||||
if(qnx->port_device[port])
|
if(qnx->port_device[port])
|
||||||
{
|
{
|
||||||
switch ((index << 1) | id)
|
switch ((index << 1) | id)
|
||||||
@ -659,7 +738,10 @@ static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_ke
|
|||||||
case RETRO_DEVICE_ID_POINTER_Y:
|
case RETRO_DEVICE_ID_POINTER_Y:
|
||||||
return qnx->pointer[qnx->touch_map[index]].full_y;
|
return qnx->pointer[qnx->touch_map[index]].full_y;
|
||||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||||
return (index < qnx->pointer_count) && (qnx->pointer[index].full_x != -0x8000) && (qnx->pointer[index].full_y != -0x8000);
|
return (
|
||||||
|
index < qnx->pointer_count)
|
||||||
|
&& (qnx->pointer[index].full_x != -0x8000)
|
||||||
|
&& (qnx->pointer[index].full_y != -0x8000);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -672,7 +754,10 @@ static int16_t qnx_input_state(void *data, const struct retro_keybind **retro_ke
|
|||||||
case RETRO_DEVICE_ID_POINTER_Y:
|
case RETRO_DEVICE_ID_POINTER_Y:
|
||||||
return qnx->pointer[qnx->touch_map[index]].y;
|
return qnx->pointer[qnx->touch_map[index]].y;
|
||||||
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
case RETRO_DEVICE_ID_POINTER_PRESSED:
|
||||||
return (index < qnx->pointer_count) && (qnx->pointer[index].x != -0x8000) && (qnx->pointer[index].y != -0x8000);
|
return (
|
||||||
|
index < qnx->pointer_count)
|
||||||
|
&& (qnx->pointer[index].x != -0x8000)
|
||||||
|
&& (qnx->pointer[index].y != -0x8000);
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,10 @@ static bool qnx_joypad_init(void)
|
|||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], "None", sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad], "None",
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, qnx_joypad_name(autoconf_pad), qnx_joypad.ident);
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
qnx_joypad_name(autoconf_pad), qnx_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -69,10 +71,18 @@ static int16_t qnx_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = qnx->analog_state[port_num][0][0]; break;
|
case 0:
|
||||||
case 1: val = qnx->analog_state[port_num][0][1]; break;
|
val = qnx->analog_state[port_num][0][0];
|
||||||
case 2: val = qnx->analog_state[port_num][1][0]; break;
|
break;
|
||||||
case 3: val = qnx->analog_state[port_num][1][1]; break;
|
case 1:
|
||||||
|
val = qnx->analog_state[port_num][0][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = qnx->analog_state[port_num][1][0];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = qnx->analog_state[port_num][1][1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
|
103
input/wiimote.c
103
input/wiimote.c
@ -48,10 +48,18 @@
|
|||||||
#include "wiimote.h"
|
#include "wiimote.h"
|
||||||
|
|
||||||
int wiimote_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
|
int wiimote_send(struct wiimote_t* wm, byte report_type, byte* msg, int len);
|
||||||
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len);
|
|
||||||
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len);
|
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr,
|
||||||
|
unsigned short len);
|
||||||
|
|
||||||
|
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr,
|
||||||
|
byte* data, byte len);
|
||||||
|
|
||||||
void wiimote_set_leds(struct wiimote_t* wm, int leds);
|
void wiimote_set_leds(struct wiimote_t* wm, int leds);
|
||||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len);
|
|
||||||
|
int classic_ctrl_handshake(struct wiimote_t* wm,
|
||||||
|
struct classic_ctrl_t* cc, byte* data, unsigned short len);
|
||||||
|
|
||||||
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg);
|
void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,7 +102,8 @@ void wiimote_data_report(struct wiimote_t* wm, byte type)
|
|||||||
* @param wm Pointer to a wiimote_t structure.
|
* @param wm Pointer to a wiimote_t structure.
|
||||||
* @param leds What LEDs to enable.
|
* @param leds What LEDs to enable.
|
||||||
*
|
*
|
||||||
* \a leds is a bitwise or of WIIMOTE_LED_1, WIIMOTE_LED_2, WIIMOTE_LED_3, or WIIMOTE_LED_4.
|
* \a leds is a bitwise or of WIIMOTE_LED_1, WIIMOTE_LED_2,
|
||||||
|
* WIIMOTE_LED_3, or WIIMOTE_LED_4.
|
||||||
*/
|
*/
|
||||||
void wiimote_set_leds(struct wiimote_t* wm, int leds)
|
void wiimote_set_leds(struct wiimote_t* wm, int leds)
|
||||||
{
|
{
|
||||||
@ -159,7 +168,8 @@ void wiimote_handle_expansion(struct wiimote_t* wm, byte* msg)
|
|||||||
* The handshake will be concluded when the wiimote responds
|
* The handshake will be concluded when the wiimote responds
|
||||||
* with this data.
|
* with this data.
|
||||||
*/
|
*/
|
||||||
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned short len)
|
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data,
|
||||||
|
unsigned short len)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!wm) return 0;
|
if (!wm) return 0;
|
||||||
@ -171,8 +181,11 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
#endif
|
#endif
|
||||||
switch (wm->handshake_state)
|
switch (wm->handshake_state)
|
||||||
{
|
{
|
||||||
case 0://no ha habido nunca handshake, debemos forzar un mensaje de staus para ver que pasa.
|
case 0:
|
||||||
{
|
{
|
||||||
|
/* no ha habido nunca handshake, debemos forzar un
|
||||||
|
* mensaje de staus para ver que pasa. */
|
||||||
|
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
wiimote_set_leds(wm, WIIMOTE_LED_NONE);
|
wiimote_set_leds(wm, WIIMOTE_LED_NONE);
|
||||||
|
|
||||||
@ -182,19 +195,23 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
wm->handshake_state=1;
|
wm->handshake_state=1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case 1://estamos haciendo handshake o bien se necesita iniciar un nuevo handshake ya que se inserta(quita una expansion.
|
case 1:
|
||||||
{
|
{
|
||||||
|
/* estamos haciendo handshake o bien se necesita iniciar un
|
||||||
|
* nuevo handshake ya que se inserta(quita una expansion. */
|
||||||
int attachment = 0;
|
int attachment = 0;
|
||||||
|
|
||||||
if(event != WM_RPT_CTRL_STATUS)
|
if(event != WM_RPT_CTRL_STATUS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* is an attachment connected to the expansion port? */
|
/* is an attachment connected to the expansion port? */
|
||||||
if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT)
|
if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) ==
|
||||||
|
WM_CTRL_STATUS_BYTE1_ATTACHMENT)
|
||||||
attachment = 1;
|
attachment = 1;
|
||||||
|
|
||||||
#ifdef WIIMOTE_DBG
|
#ifdef WIIMOTE_DBG
|
||||||
printf("attachment %d %d\n",attachment,WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP));
|
printf("attachment %d %d\n",attachment,
|
||||||
|
WIIMOTE_IS_SET(wm, WIIMOTE_STATE_EXP));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* expansion port */
|
/* expansion port */
|
||||||
@ -213,25 +230,33 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
printf("rehandshake\n");
|
printf("rehandshake\n");
|
||||||
#endif
|
#endif
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);//forzamos un handshake por si venimos de un hanshake completo
|
/* forzamos un handshake por si venimos
|
||||||
|
* de un hanshake completo. */
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte buf;
|
byte buf;
|
||||||
//Old way. initialize the extension was by writing the single encryption byte 0x00 to 0x(4)A40040
|
/*Old way. initialize the extension was by writing the
|
||||||
//buf = 0x00;
|
* single encryption byte 0x00 to 0x(4)A40040. */
|
||||||
//wiimote_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1);
|
#if 0
|
||||||
|
buf = 0x00;
|
||||||
|
wiimote_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
//NEW WAY 0x55 to 0x(4)A400F0, then writing 0x00 to 0x(4)A400FB. (support clones)
|
/* NEW WAY 0x55 to 0x(4)A400F0, then writing
|
||||||
|
* 0x00 to 0x(4)A400FB. (support clones) */
|
||||||
buf = 0x55;
|
buf = 0x55;
|
||||||
wiimote_write_data(wm, 0x04A400F0, &buf, 1);
|
wiimote_write_data(wm, 0x04A400F0, &buf, 1);
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
buf = 0x00;
|
buf = 0x00;
|
||||||
wiimote_write_data(wm, 0x04A400FB, &buf, 1);
|
wiimote_write_data(wm, 0x04A400FB, &buf, 1);
|
||||||
|
|
||||||
//check extension type!
|
/* check extension type! */
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
wiimote_read_data(wm, WM_EXP_MEM_CALIBR+220, 4);
|
wiimote_read_data(wm, WM_EXP_MEM_CALIBR+220, 4);
|
||||||
//wiimote_read_data(wm, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
#if 0
|
||||||
|
wiimote_read_data(wm, WM_EXP_MEM_CALIBR, EXP_HANDSHAKE_LEN);
|
||||||
|
#endif
|
||||||
|
|
||||||
wm->handshake_state = 4;
|
wm->handshake_state = 4;
|
||||||
return 0;
|
return 0;
|
||||||
@ -249,7 +274,9 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
printf("rehandshake\n");
|
printf("rehandshake\n");
|
||||||
#endif
|
#endif
|
||||||
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE);
|
||||||
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);//forzamos un handshake por si venimos de un hanshake completo
|
/* forzamos un handshake por si venimos
|
||||||
|
* de un hanshake completo. */
|
||||||
|
WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +288,9 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case 2://find handshake no expansion
|
case 2:
|
||||||
{
|
{
|
||||||
|
/* find handshake no expansion. */
|
||||||
#ifdef WIIMOTE_DBG
|
#ifdef WIIMOTE_DBG
|
||||||
printf("Finalizado HANDSHAKE SIN EXPANSION\n");
|
printf("Finalizado HANDSHAKE SIN EXPANSION\n");
|
||||||
#endif
|
#endif
|
||||||
@ -270,8 +298,9 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
wm->handshake_state = 6;
|
wm->handshake_state = 6;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case 3://find handshake expansion
|
case 3:
|
||||||
{
|
{
|
||||||
|
/* Find handshake expansion. */
|
||||||
#ifdef WIIMOTE_DBG
|
#ifdef WIIMOTE_DBG
|
||||||
printf("Finalizado HANDSHAKE CON EXPANSION\n");
|
printf("Finalizado HANDSHAKE CON EXPANSION\n");
|
||||||
#endif
|
#endif
|
||||||
@ -289,17 +318,20 @@ int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned sh
|
|||||||
#ifdef WIIMOTE_DBG
|
#ifdef WIIMOTE_DBG
|
||||||
printf("Expansion id=0x%04x\n",id);
|
printf("Expansion id=0x%04x\n",id);
|
||||||
#endif
|
#endif
|
||||||
|
/*EXP_ID_CODE_CLASSIC_CONTROLLER*/
|
||||||
if(id!=/*EXP_ID_CODE_CLASSIC_CONTROLLER*/0xa4200101)
|
if(id != 0xa4200101)
|
||||||
{
|
{
|
||||||
wm->handshake_state = 2;
|
wm->handshake_state = 2;
|
||||||
//WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP);
|
#if 0
|
||||||
|
WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_EXP);
|
||||||
|
#endif
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
wiimote_read_data(wm, WM_EXP_MEM_CALIBR, 16);//pedimos datos de calibracion del JOY!
|
/* pedimos datos de calibracion del JOY! */
|
||||||
|
wiimote_read_data(wm, WM_EXP_MEM_CALIBR, 16);
|
||||||
wm->handshake_state = 5;
|
wm->handshake_state = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,13 +416,14 @@ int wiimote_send(struct wiimote_t* wm, byte report_type, byte* msg, int len)
|
|||||||
* to a pending list and be sent out when the previous
|
* to a pending list and be sent out when the previous
|
||||||
* finishes.
|
* finishes.
|
||||||
*/
|
*/
|
||||||
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short len)
|
int wiimote_read_data(struct wiimote_t* wm, unsigned int addr,
|
||||||
|
unsigned short len)
|
||||||
{
|
{
|
||||||
//No puden ser mas de 16 lo leido o vendra en trozos!
|
/* No puden ser mas de 16 lo leido o vendra en trozos! */
|
||||||
|
|
||||||
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
if (!wm || !WIIMOTE_IS_CONNECTED(wm))
|
||||||
return 0;
|
return 0;
|
||||||
if (!len /*|| len > 16*/)
|
if (!len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
byte buf[6];
|
byte buf[6];
|
||||||
@ -417,7 +450,8 @@ int wiimote_read_data(struct wiimote_t* wm, unsigned int addr, unsigned short le
|
|||||||
* @param data The data to be written to the memory location.
|
* @param data The data to be written to the memory location.
|
||||||
* @param len The length of the block to be written.
|
* @param len The length of the block to be written.
|
||||||
*/
|
*/
|
||||||
int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len)
|
int wiimote_write_data(struct wiimote_t* wm,
|
||||||
|
unsigned int addr, byte* data, byte len)
|
||||||
{
|
{
|
||||||
byte buf[21] = {0}; /* the payload is always 23 */
|
byte buf[21] = {0}; /* the payload is always 23 */
|
||||||
|
|
||||||
@ -449,10 +483,8 @@ int wiimote_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int classic_ctrl_handshake(struct wiimote_t* wm,
|
||||||
/////////////////////// CLASSIC /////////////////
|
struct classic_ctrl_t* cc, byte* data, unsigned short len)
|
||||||
|
|
||||||
int classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, byte* data, unsigned short len)
|
|
||||||
{
|
{
|
||||||
memset(cc, 0, sizeof(*cc));
|
memset(cc, 0, sizeof(*cc));
|
||||||
wm->exp.type = EXP_CLASSIC;
|
wm->exp.type = EXP_CLASSIC;
|
||||||
@ -479,9 +511,11 @@ static void process_axis(struct axis_t* axis, byte raw)
|
|||||||
axis->raw_value = raw;
|
axis->raw_value = raw;
|
||||||
|
|
||||||
if (raw < axis->center)
|
if (raw < axis->center)
|
||||||
axis->value = -normalize_and_interpolate(axis->center, axis->min, raw);
|
axis->value = -normalize_and_interpolate(
|
||||||
|
axis->center, axis->min, raw);
|
||||||
else if (raw > axis->center)
|
else if (raw > axis->center)
|
||||||
axis->value = normalize_and_interpolate(axis->center, axis->max, raw);
|
axis->value = normalize_and_interpolate(
|
||||||
|
axis->center, axis->max, raw);
|
||||||
else
|
else
|
||||||
axis->value = 0;
|
axis->value = 0;
|
||||||
}
|
}
|
||||||
@ -491,6 +525,7 @@ void classic_ctrl_event(struct classic_ctrl_t* cc, byte* msg)
|
|||||||
cc->btns = ~BIG_ENDIAN_SHORT(*(short*)(msg + 4)) & CLASSIC_CTRL_BUTTON_ALL;
|
cc->btns = ~BIG_ENDIAN_SHORT(*(short*)(msg + 4)) & CLASSIC_CTRL_BUTTON_ALL;
|
||||||
process_axis(&cc->ljs.x, (msg[0] & 0x3F));
|
process_axis(&cc->ljs.x, (msg[0] & 0x3F));
|
||||||
process_axis(&cc->ljs.y, (msg[1] & 0x3F));
|
process_axis(&cc->ljs.y, (msg[1] & 0x3F));
|
||||||
process_axis(&cc->rjs.x, ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7));
|
process_axis(&cc->rjs.x, ((msg[0] & 0xC0) >> 3) |
|
||||||
|
((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7));
|
||||||
process_axis(&cc->rjs.y, (msg[2] & 0x1F));
|
process_axis(&cc->rjs.y, (msg[2] & 0x1F));
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,9 @@ extern "C" {
|
|||||||
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
|
#define WIIMOTE_TOGGLE_STATE(wm, s) ((wm->state & (s)) ? WIIMOTE_DISABLE_STATE(wm, s) : WIIMOTE_ENABLE_STATE(wm, s))
|
||||||
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
#define WIIMOTE_IS_CONNECTED(wm) (WIIMOTE_IS_SET(wm, WIIMOTE_STATE_CONNECTED))
|
||||||
|
|
||||||
int wiimote_handshake(struct wiimote_t* wm, byte event, byte* data, unsigned short len);
|
int wiimote_handshake(struct wiimote_t* wm,
|
||||||
|
byte event, byte* data, unsigned short len);
|
||||||
|
|
||||||
void wiimote_status(struct wiimote_t* wm);
|
void wiimote_status(struct wiimote_t* wm);
|
||||||
void wiimote_data_report(struct wiimote_t* wm, byte type);
|
void wiimote_data_report(struct wiimote_t* wm, byte type);
|
||||||
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg);
|
void wiimote_pressed_buttons(struct wiimote_t* wm, byte* msg);
|
||||||
|
@ -291,24 +291,26 @@ static bool winxinput_joypad_button (unsigned port_num, uint16_t joykey)
|
|||||||
if (!(g_winxinput_states[xplayer].connected))
|
if (!(g_winxinput_states[xplayer].connected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//return false;
|
|
||||||
|
|
||||||
uint16_t btn_word = g_winxinput_states[xplayer].xstate.Gamepad.wButtons;
|
uint16_t btn_word = g_winxinput_states[xplayer].xstate.Gamepad.wButtons;
|
||||||
|
|
||||||
if (GET_HAT_DIR(joykey))
|
if (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
switch (GET_HAT_DIR(joykey))
|
switch (GET_HAT_DIR(joykey))
|
||||||
{
|
{
|
||||||
case HAT_UP_MASK: return btn_word & XINPUT_GAMEPAD_DPAD_UP;
|
case HAT_UP_MASK:
|
||||||
case HAT_DOWN_MASK: return btn_word & XINPUT_GAMEPAD_DPAD_DOWN;
|
return btn_word & XINPUT_GAMEPAD_DPAD_UP;
|
||||||
case HAT_LEFT_MASK: return btn_word & XINPUT_GAMEPAD_DPAD_LEFT;
|
case HAT_DOWN_MASK:
|
||||||
case HAT_RIGHT_MASK: return btn_word & XINPUT_GAMEPAD_DPAD_RIGHT;
|
return btn_word & XINPUT_GAMEPAD_DPAD_DOWN;
|
||||||
|
case HAT_LEFT_MASK:
|
||||||
|
return btn_word & XINPUT_GAMEPAD_DPAD_LEFT;
|
||||||
|
case HAT_RIGHT_MASK:
|
||||||
|
return btn_word & XINPUT_GAMEPAD_DPAD_RIGHT;
|
||||||
}
|
}
|
||||||
return false; // hat requested and no hat button down
|
return false; /* hat requested and no hat button down. */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// non-hat button
|
/* non-hat button. */
|
||||||
unsigned num_buttons = g_winxinput_guide_button_supported ? 11 : 10;
|
unsigned num_buttons = g_winxinput_guide_button_supported ? 11 : 10;
|
||||||
|
|
||||||
if (joykey < num_buttons)
|
if (joykey < num_buttons)
|
||||||
@ -336,7 +338,8 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
|||||||
bool is_neg = false;
|
bool is_neg = false;
|
||||||
bool is_pos = false;
|
bool is_pos = false;
|
||||||
|
|
||||||
if (AXIS_NEG_GET(joyaxis) <= 3) // triggers (axes 4,5) cannot be negative
|
/* triggers (axes 4,5) cannot be negative */
|
||||||
|
if (AXIS_NEG_GET(joyaxis) <= 3)
|
||||||
{
|
{
|
||||||
axis = AXIS_NEG_GET(joyaxis);
|
axis = AXIS_NEG_GET(joyaxis);
|
||||||
is_neg = true;
|
is_neg = true;
|
||||||
@ -351,13 +354,24 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = pad->sThumbLX; break;
|
case 0:
|
||||||
case 1: val = pad->sThumbLY; break;
|
val = pad->sThumbLX;
|
||||||
case 2: val = pad->sThumbRX; break;
|
break;
|
||||||
case 3: val = pad->sThumbRY; break;
|
case 1:
|
||||||
|
val = pad->sThumbLY;
|
||||||
case 4: val = pad->bLeftTrigger * 32767 / 255; break; // map 0..255 to 0..32767
|
break;
|
||||||
case 5: val = pad->bRightTrigger * 32767 / 255; break;
|
case 2:
|
||||||
|
val = pad->sThumbRX;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = pad->sThumbRY;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
val = pad->bLeftTrigger * 32767 / 255;
|
||||||
|
break; /* map 0..255 to 0..32767 */
|
||||||
|
case 5:
|
||||||
|
val = pad->bRightTrigger * 32767 / 255;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
@ -365,7 +379,7 @@ static int16_t winxinput_joypad_axis (unsigned port_num, uint32_t joyaxis)
|
|||||||
else if (is_pos && val < 0)
|
else if (is_pos && val < 0)
|
||||||
val = 0;
|
val = 0;
|
||||||
|
|
||||||
// Clamp to avoid overflow error
|
/* Clamp to avoid overflow error. */
|
||||||
if (val == -32768)
|
if (val == -32768)
|
||||||
val = -32767;
|
val = -32767;
|
||||||
|
|
||||||
@ -376,14 +390,23 @@ static void winxinput_joypad_poll(void)
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < 4; ++i)
|
for (i = 0; i < 4; ++i)
|
||||||
|
{
|
||||||
if (g_winxinput_states[i].connected)
|
if (g_winxinput_states[i].connected)
|
||||||
if (g_XInputGetStateEx(i, &(g_winxinput_states[i].xstate)) == ERROR_DEVICE_NOT_CONNECTED)
|
{
|
||||||
|
if (g_XInputGetStateEx(i,
|
||||||
|
&(g_winxinput_states[i].xstate))
|
||||||
|
== ERROR_DEVICE_NOT_CONNECTED)
|
||||||
|
{
|
||||||
g_winxinput_states[i].connected = false;
|
g_winxinput_states[i].connected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dinput_joypad.poll();
|
dinput_joypad.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool winxinput_joypad_rumble(unsigned pad, enum retro_rumble_effect effect, uint16_t strength)
|
static bool winxinput_joypad_rumble(unsigned pad,
|
||||||
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
int xplayer = pad_index_to_xplayer_index(pad);
|
int xplayer = pad_index_to_xplayer_index(pad);
|
||||||
if (xplayer == -1)
|
if (xplayer == -1)
|
||||||
@ -393,14 +416,14 @@ static bool winxinput_joypad_rumble(unsigned pad, enum retro_rumble_effect effec
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Consider the low frequency (left) motor the "strong" one. */
|
||||||
// Consider the low frequency (left) motor the "strong" one.
|
|
||||||
if (effect == RETRO_RUMBLE_STRONG)
|
if (effect == RETRO_RUMBLE_STRONG)
|
||||||
g_xinput_rumble_states[xplayer].wLeftMotorSpeed = strength;
|
g_xinput_rumble_states[xplayer].wLeftMotorSpeed = strength;
|
||||||
else if (effect == RETRO_RUMBLE_WEAK)
|
else if (effect == RETRO_RUMBLE_WEAK)
|
||||||
g_xinput_rumble_states[xplayer].wRightMotorSpeed = strength;
|
g_xinput_rumble_states[xplayer].wRightMotorSpeed = strength;
|
||||||
|
|
||||||
return g_XInputSetState(xplayer, &g_xinput_rumble_states[xplayer]) == ERROR_SUCCESS;
|
return g_XInputSetState(xplayer, &g_xinput_rumble_states[xplayer])
|
||||||
|
== ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rarch_joypad_driver_t winxinput_joypad = {
|
const rarch_joypad_driver_t winxinput_joypad = {
|
||||||
|
@ -53,7 +53,7 @@ static void *x_input_init(void)
|
|||||||
if (!x11)
|
if (!x11)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// Borrow the active X window ...
|
/* Borrow the active X window ... */
|
||||||
x11->display = (Display*)driver.video_display;
|
x11->display = (Display*)driver.video_display;
|
||||||
x11->win = (Window)driver.video_window;
|
x11->win = (Window)driver.video_window;
|
||||||
|
|
||||||
@ -74,7 +74,8 @@ static bool x_key_pressed(x11_input_t *x11, int key)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool x_is_pressed(x11_input_t *x11, const struct retro_keybind *binds, unsigned id)
|
static bool x_is_pressed(x11_input_t *x11,
|
||||||
|
const struct retro_keybind *binds, unsigned id)
|
||||||
{
|
{
|
||||||
if (id < RARCH_BIND_LIST_END)
|
if (id < RARCH_BIND_LIST_END)
|
||||||
{
|
{
|
||||||
@ -84,7 +85,8 @@ static bool x_is_pressed(x11_input_t *x11, const struct retro_keybind *binds, un
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t x_pressed_analog(x11_input_t *x11, const struct retro_keybind *binds, unsigned index, unsigned id)
|
static int16_t x_pressed_analog(x11_input_t *x11,
|
||||||
|
const struct retro_keybind *binds, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
unsigned id_minus = 0;
|
unsigned id_minus = 0;
|
||||||
unsigned id_plus = 0;
|
unsigned id_plus = 0;
|
||||||
@ -125,7 +127,8 @@ static int16_t x_mouse_state(x11_input_t *x11, unsigned id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t x_pointer_state(x11_input_t *x11, unsigned index, unsigned id, bool screen)
|
static int16_t x_pointer_state(x11_input_t *x11,
|
||||||
|
unsigned index, unsigned id, bool screen)
|
||||||
{
|
{
|
||||||
if (index != 0)
|
if (index != 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -184,7 +187,9 @@ static int16_t x_lightgun_state(x11_input_t *x11, unsigned id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int16_t x_input_state(void *data, const struct retro_keybind **binds, unsigned port, unsigned device, unsigned index, unsigned id)
|
static int16_t x_input_state(void *data,
|
||||||
|
const struct retro_keybind **binds, unsigned port,
|
||||||
|
unsigned device, unsigned index, unsigned id)
|
||||||
{
|
{
|
||||||
x11_input_t *x11 = (x11_input_t*)data;
|
x11_input_t *x11 = (x11_input_t*)data;
|
||||||
int16_t ret;
|
int16_t ret;
|
||||||
@ -201,7 +206,8 @@ static int16_t x_input_state(void *data, const struct retro_keybind **binds, uns
|
|||||||
case RETRO_DEVICE_ANALOG:
|
case RETRO_DEVICE_ANALOG:
|
||||||
ret = x_pressed_analog(x11, binds[port], index, id);
|
ret = x_pressed_analog(x11, binds[port], index, id);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = input_joypad_analog(x11->joypad, port, index, id, binds[port]);
|
ret = input_joypad_analog(x11->joypad, port, index,
|
||||||
|
id, binds[port]);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
case RETRO_DEVICE_MOUSE:
|
case RETRO_DEVICE_MOUSE:
|
||||||
@ -209,7 +215,8 @@ static int16_t x_input_state(void *data, const struct retro_keybind **binds, uns
|
|||||||
|
|
||||||
case RETRO_DEVICE_POINTER:
|
case RETRO_DEVICE_POINTER:
|
||||||
case RARCH_DEVICE_POINTER_SCREEN:
|
case RARCH_DEVICE_POINTER_SCREEN:
|
||||||
return x_pointer_state(x11, index, id, device == RARCH_DEVICE_POINTER_SCREEN);
|
return x_pointer_state(x11, index, id,
|
||||||
|
device == RARCH_DEVICE_POINTER_SCREEN);
|
||||||
|
|
||||||
case RETRO_DEVICE_LIGHTGUN:
|
case RETRO_DEVICE_LIGHTGUN:
|
||||||
return x_lightgun_state(x11, id);
|
return x_lightgun_state(x11, id);
|
||||||
@ -253,7 +260,7 @@ static void x_input_poll_mouse(x11_input_t *x11)
|
|||||||
x11->mouse_wu = mask & Button4Mask;
|
x11->mouse_wu = mask & Button4Mask;
|
||||||
x11->mouse_wd = mask & Button5Mask;
|
x11->mouse_wd = mask & Button5Mask;
|
||||||
|
|
||||||
// Somewhat hacky, but seem to do the job.
|
/* Somewhat hacky, but seem to do the job. */
|
||||||
if (x11->grab_mouse && driver.video->focus(driver.video_data))
|
if (x11->grab_mouse && driver.video->focus(driver.video_data))
|
||||||
{
|
{
|
||||||
struct rarch_viewport vp = {0};
|
struct rarch_viewport vp = {0};
|
||||||
@ -295,7 +302,8 @@ static void x_grab_mouse(void *data, bool state)
|
|||||||
x11->grab_mouse = state;
|
x11->grab_mouse = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool x_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength)
|
static bool x_set_rumble(void *data, unsigned port,
|
||||||
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
x11_input_t *x11 = (x11_input_t*)data;
|
x11_input_t *x11 = (x11_input_t*)data;
|
||||||
return input_joypad_set_rumble(x11->joypad, port, effect, strength);
|
return input_joypad_set_rumble(x11->joypad, port, effect, strength);
|
||||||
|
@ -46,7 +46,9 @@ static void xdk_input_poll(void *data)
|
|||||||
|
|
||||||
#if defined(_XBOX1)
|
#if defined(_XBOX1)
|
||||||
unsigned int dwInsertions, dwRemovals;
|
unsigned int dwInsertions, dwRemovals;
|
||||||
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD, reinterpret_cast<PDWORD>(&dwInsertions), reinterpret_cast<PDWORD>(&dwRemovals));
|
XGetDeviceChanges(XDEVICE_TYPE_GAMEPAD,
|
||||||
|
reinterpret_cast<PDWORD>(&dwInsertions),
|
||||||
|
reinterpret_cast<PDWORD>(&dwRemovals));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (unsigned port = 0; port < MAX_PADS; port++)
|
for (unsigned port = 0; port < MAX_PADS; port++)
|
||||||
@ -54,13 +56,15 @@ static void xdk_input_poll(void *data)
|
|||||||
#ifdef _XBOX1
|
#ifdef _XBOX1
|
||||||
XINPUT_CAPABILITIES caps[MAX_PADS];
|
XINPUT_CAPABILITIES caps[MAX_PADS];
|
||||||
(void)caps;
|
(void)caps;
|
||||||
// handle removed devices
|
|
||||||
|
/* handle removed devices. */
|
||||||
xdk->bRemoved[port] = (dwRemovals & (1 << port)) ? true : false;
|
xdk->bRemoved[port] = (dwRemovals & (1 << port)) ? true : false;
|
||||||
|
|
||||||
if(xdk->bRemoved[port])
|
if(xdk->bRemoved[port])
|
||||||
{
|
{
|
||||||
// if the controller was removed after XGetDeviceChanges but before
|
/* if the controller was removed after
|
||||||
// XInputOpen, the device handle will be NULL
|
* XGetDeviceChanges but before
|
||||||
|
* XInputOpen, the device handle will be NULL. */
|
||||||
if(xdk->gamepads[port])
|
if(xdk->gamepads[port])
|
||||||
XInputClose(xdk->gamepads[port]);
|
XInputClose(xdk->gamepads[port]);
|
||||||
|
|
||||||
@ -68,7 +72,7 @@ static void xdk_input_poll(void *data)
|
|||||||
xdk->pad_state[port] = 0;
|
xdk->pad_state[port] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle inserted devices
|
/* handle inserted devices. */
|
||||||
xdk->bInserted[port] = (dwInsertions & (1 << port)) ? true : false;
|
xdk->bInserted[port] = (dwInsertions & (1 << port)) ? true : false;
|
||||||
|
|
||||||
if(xdk->bInserted[port])
|
if(xdk->bInserted[port])
|
||||||
@ -78,14 +82,16 @@ static void xdk_input_poll(void *data)
|
|||||||
m_pollingParameters.fInterruptOut = TRUE;
|
m_pollingParameters.fInterruptOut = TRUE;
|
||||||
m_pollingParameters.bInputInterval = 8;
|
m_pollingParameters.bInputInterval = 8;
|
||||||
m_pollingParameters.bOutputInterval = 8;
|
m_pollingParameters.bOutputInterval = 8;
|
||||||
xdk->gamepads[port] = XInputOpen(XDEVICE_TYPE_GAMEPAD, port, XDEVICE_NO_SLOT, NULL);
|
xdk->gamepads[port] = XInputOpen(XDEVICE_TYPE_GAMEPAD, port,
|
||||||
|
XDEVICE_NO_SLOT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xdk->gamepads[port])
|
if (!xdk->gamepads[port])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// if the controller is removed after XGetDeviceChanges but before
|
/* if the controller is removed after
|
||||||
// XInputOpen, the device handle will be NULL
|
* XGetDeviceChanges but before XInputOpen,
|
||||||
|
* the device handle will be NULL. */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XINPUT_STATE state_tmp;
|
XINPUT_STATE state_tmp;
|
||||||
@ -194,7 +200,7 @@ static void *xdk_input_init(void)
|
|||||||
|
|
||||||
xdk->dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD);
|
xdk->dwDeviceMask = XGetDevices(XDEVICE_TYPE_GAMEPAD);
|
||||||
|
|
||||||
//Check the device status
|
/* Check the device status. */
|
||||||
switch(XGetDeviceEnumerationStatus())
|
switch(XGetDeviceEnumerationStatus())
|
||||||
{
|
{
|
||||||
case XDEVICE_ENUMERATION_IDLE:
|
case XDEVICE_ENUMERATION_IDLE:
|
||||||
@ -215,7 +221,8 @@ static void *xdk_input_init(void)
|
|||||||
static bool xdk_input_key_pressed(void *data, int key)
|
static bool xdk_input_key_pressed(void *data, int key)
|
||||||
{
|
{
|
||||||
xdk_input_t *xdk = (xdk_input_t*)data;
|
xdk_input_t *xdk = (xdk_input_t*)data;
|
||||||
return (g_extern.lifecycle_state & (1ULL << key)) || input_joypad_pressed(xdk->joypad, 0, g_settings.input.binds[0], key);
|
return (g_extern.lifecycle_state & (1ULL << key)) ||
|
||||||
|
input_joypad_pressed(xdk->joypad, 0, g_settings.input.binds[0], key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t xdk_input_get_capabilities(void *data)
|
static uint64_t xdk_input_get_capabilities(void *data)
|
||||||
@ -228,9 +235,11 @@ static uint64_t xdk_input_get_capabilities(void *data)
|
|||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - are we sure about treating low frequency motor as the "strong" motor? Does it apply for Xbox too?
|
/* FIXME - are we sure about treating low frequency motor as the
|
||||||
|
* "strong" motor? Does it apply for Xbox too? */
|
||||||
|
|
||||||
static bool xdk_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength)
|
static bool xdk_input_set_rumble(void *data, unsigned port,
|
||||||
|
enum retro_rumble_effect effect, uint16_t strength)
|
||||||
{
|
{
|
||||||
xdk_input_t *xdk = (xdk_input_t*)data;
|
xdk_input_t *xdk = (xdk_input_t*)data;
|
||||||
(void)xdk;
|
(void)xdk;
|
||||||
|
@ -33,8 +33,11 @@ static bool xdk_joypad_init(void)
|
|||||||
|
|
||||||
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
for (autoconf_pad = 0; autoconf_pad < MAX_PLAYERS; autoconf_pad++)
|
||||||
{
|
{
|
||||||
strlcpy(g_settings.input.device_names[autoconf_pad], "XInput Controller", sizeof(g_settings.input.device_names[autoconf_pad]));
|
strlcpy(g_settings.input.device_names[autoconf_pad],
|
||||||
input_config_autoconfigure_joypad(autoconf_pad, xdk_joypad_name(autoconf_pad), xdk_joypad.ident);
|
"XInput Controller",
|
||||||
|
sizeof(g_settings.input.device_names[autoconf_pad]));
|
||||||
|
input_config_autoconfigure_joypad(autoconf_pad,
|
||||||
|
xdk_joypad_name(autoconf_pad), xdk_joypad.ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -75,10 +78,18 @@ static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
|||||||
|
|
||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case 0: val = xdk->analog_state[port_num][0][0]; break;
|
case 0:
|
||||||
case 1: val = xdk->analog_state[port_num][0][1]; break;
|
val = xdk->analog_state[port_num][0][0];
|
||||||
case 2: val = xdk->analog_state[port_num][1][0]; break;
|
break;
|
||||||
case 3: val = xdk->analog_state[port_num][1][1]; break;
|
case 1:
|
||||||
|
val = xdk->analog_state[port_num][0][1];
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
val = xdk->analog_state[port_num][1][0];
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
val = xdk->analog_state[port_num][1][1];
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_neg && val > 0)
|
if (is_neg && val > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user