early-access version 1617

This commit is contained in:
pineappleEA
2021-04-20 21:40:33 +02:00
parent 242b6f6b49
commit f46563104f
510 changed files with 141726 additions and 62846 deletions

View File

@@ -23,7 +23,6 @@
#include "SDL_syshaptic.h"
#include "SDL_haptic_c.h"
#include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */
#include "SDL_assert.h"
/* Global for SDL_windowshaptic.c */
#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT)

View File

@@ -22,7 +22,6 @@
#ifdef SDL_HAPTIC_ANDROID
#include "SDL_assert.h"
#include "SDL_timer.h"
#include "SDL_syshaptic_c.h"
#include "../SDL_syshaptic.h"

View File

@@ -22,13 +22,12 @@
#ifdef SDL_HAPTIC_IOKIT
#include "SDL_assert.h"
#include "SDL_stdinc.h"
#include "SDL_haptic.h"
#include "../SDL_syshaptic.h"
#include "SDL_joystick.h"
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
#include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */
#include "../../joystick/darwin/SDL_iokitjoystick_c.h" /* For joystick hwdata */
#include "SDL_syshaptic_c.h"
#include <IOKit/IOKitLib.h>
@@ -599,12 +598,14 @@ SDL_SYS_HapticMouse(void)
int
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_IOKIT
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
return SDL_FALSE;
}
if (joystick->hwdata->ffservice != 0) {
return SDL_TRUE;
}
#endif
return SDL_FALSE;
}
@@ -615,6 +616,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_IOKIT
if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
return 0;
}
@@ -622,6 +624,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
joystick->hwdata->ffservice)) {
return 1;
}
#endif
return 0;
}
@@ -632,6 +635,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_IOKIT
int device_index = 0;
SDL_hapticlist_item *item;
@@ -648,6 +652,9 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
}
return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice);
#else
return -1;
#endif
}
@@ -765,6 +772,10 @@ SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes)
rglDir[2] = dir->dir[2];
}
return 0;
case SDL_HAPTIC_STEERING_AXIS:
effect->dwFlags |= FFEFF_CARTESIAN;
rglDir[0] = 0;
return 0;
default:
return SDL_SetError("Haptic: Unknown direction type.");
@@ -813,7 +824,11 @@ SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src)
envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */
/* Axes. */
dest->cAxes = haptic->naxes;
if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) {
dest->cAxes = 1;
} else {
dest->cAxes = haptic->naxes;
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {

View File

@@ -22,12 +22,12 @@
#ifdef SDL_HAPTIC_LINUX
#include "SDL_assert.h"
#include "SDL_haptic.h"
#include "../SDL_syshaptic.h"
#include "SDL_joystick.h"
#include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */
#include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */
#include "../../core/linux/SDL_evdev_capabilities.h"
#include "../../core/linux/SDL_udev.h"
#include <unistd.h> /* close */
@@ -86,8 +86,6 @@ static SDL_hapticlist_item *SDL_hapticlist = NULL;
static SDL_hapticlist_item *SDL_hapticlist_tail = NULL;
static int numhaptics = 0;
#define test_bit(nr, addr) \
(((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
#define EV_TEST(ev,f) \
if (test_bit((ev), features)) ret |= (f);
/*
@@ -512,10 +510,15 @@ SDL_SYS_HapticMouse(void)
int
SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_LINUX
if (joystick->driver != &SDL_LINUX_JoystickDriver) {
return 0;
return SDL_FALSE;
}
return EV_IsHaptic(joystick->hwdata->fd);
if (EV_IsHaptic(joystick->hwdata->fd)) {
return SDL_TRUE;
}
#endif
return SDL_FALSE;
}
@@ -525,6 +528,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick)
int
SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_LINUX
if (joystick->driver != &SDL_LINUX_JoystickDriver) {
return 0;
}
@@ -533,6 +537,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
if (SDL_strcmp(joystick->hwdata->fname, haptic->hwdata->fname) == 0) {
return 1;
}
#endif
return 0;
}
@@ -543,6 +548,7 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick)
int
SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
{
#ifdef SDL_JOYSTICK_LINUX
int device_index = 0;
int fd;
int ret;
@@ -577,6 +583,9 @@ SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick)
haptic->hwdata->fname = SDL_strdup( joystick->hwdata->fname );
return 0;
#else
return -1;
#endif
}
@@ -718,7 +727,9 @@ SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src)
*dest = (Uint16) tmp;
}
break;
case SDL_HAPTIC_STEERING_AXIS:
*dest = 0x4000;
break;
default:
return SDL_SetError("Haptic: Unsupported direction type.");
}

View File

@@ -51,10 +51,6 @@ static LPDIRECTINPUT8 dinput = NULL;
static int
DI_SetError(const char *str, HRESULT err)
{
/*
SDL_SetError("Haptic: %s - %s: %s", str,
DXGetErrorString8A(err), DXGetErrorDescription8A(err));
*/
return SDL_SetError("Haptic error %s", str);
}
@@ -87,7 +83,7 @@ SDL_DINPUT_HapticInit(void)
coinitialized = SDL_TRUE;
ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER,
&IID_IDirectInput8, (LPVOID)& dinput);
&IID_IDirectInput8, (LPVOID *) &dinput);
if (FAILED(ret)) {
SDL_SYS_HapticQuit();
return DI_SetError("CoCreateInstance", ret);
@@ -589,6 +585,10 @@ SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes)
if (naxes > 2)
rglDir[2] = dir->dir[2];
return 0;
case SDL_HAPTIC_STEERING_AXIS:
effect->dwFlags |= DIEFF_CARTESIAN;
rglDir[0] = 0;
return 0;
default:
return SDL_SetError("Haptic: Unknown direction type.");
@@ -637,7 +637,11 @@ SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest,
envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */
/* Axes. */
dest->cAxes = haptic->naxes;
if (src->constant.direction.type == SDL_HAPTIC_STEERING_AXIS) {
dest->cAxes = 1;
} else {
dest->cAxes = haptic->naxes;
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {

View File

@@ -22,7 +22,6 @@
#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
#include "SDL_assert.h"
#include "SDL_thread.h"
#include "SDL_mutex.h"
#include "SDL_timer.h"

View File

@@ -50,6 +50,7 @@ struct haptic_hwdata
/*
* Haptic system effect data.
*/
#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT
struct haptic_hweffect
{
#if SDL_HAPTIC_DINPUT
@@ -60,6 +61,7 @@ struct haptic_hweffect
XINPUT_VIBRATION vibration;
#endif
};
#endif
/*
* List of available haptic devices.

View File

@@ -26,7 +26,6 @@
#if SDL_HAPTIC_XINPUT
#include "SDL_assert.h"
#include "SDL_hints.h"
#include "SDL_timer.h"
#include "SDL_windowshaptic_c.h"