mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 13:16:40 +00:00
release 0.1.0
This commit is contained in:
+62
-11
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -28,9 +28,7 @@
|
||||
#include "SDL_events.h"
|
||||
|
||||
#include "SDL_joystick.h"
|
||||
#include "SDL_assert.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_log.h"
|
||||
#include "SDL_sysjoystick_c.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
|
||||
@@ -60,7 +58,7 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa
|
||||
SDL_zerop(item);
|
||||
item->index = gamepadEvent->index;
|
||||
|
||||
item->name = SDL_strdup(gamepadEvent->id);
|
||||
item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id);
|
||||
if ( item->name == NULL ) {
|
||||
SDL_free(item);
|
||||
return 1;
|
||||
@@ -97,7 +95,7 @@ Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepa
|
||||
|
||||
++numjoysticks;
|
||||
|
||||
SDL_PrivateJoystickAdded(numjoysticks - 1);
|
||||
SDL_PrivateJoystickAdded(item->device_instance);
|
||||
|
||||
#ifdef DEBUG_JOYSTICK
|
||||
SDL_Log("Number of joysticks is %d", numjoysticks);
|
||||
@@ -189,13 +187,16 @@ EMSCRIPTEN_JoystickInit(void)
|
||||
EmscriptenGamepadEvent gamepadState;
|
||||
|
||||
numjoysticks = 0;
|
||||
numjs = emscripten_get_num_gamepads();
|
||||
|
||||
retval = emscripten_sample_gamepad_data();
|
||||
|
||||
/* Check if gamepad is supported by browser */
|
||||
if (numjs == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
|
||||
if (retval == EMSCRIPTEN_RESULT_NOT_SUPPORTED) {
|
||||
return SDL_SetError("Gamepads not supported");
|
||||
}
|
||||
|
||||
numjs = emscripten_get_num_gamepads();
|
||||
|
||||
/* handle already connected gamepads */
|
||||
if (numjs > 0) {
|
||||
for(i = 0; i < numjs; i++) {
|
||||
@@ -285,6 +286,11 @@ EMSCRIPTEN_JoystickGetDevicePlayerIndex(int device_index)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
EMSCRIPTEN_JoystickSetDevicePlayerIndex(int device_index, int player_index)
|
||||
{
|
||||
}
|
||||
|
||||
static SDL_JoystickID
|
||||
EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index)
|
||||
{
|
||||
@@ -297,7 +303,7 @@ EMSCRIPTEN_JoystickGetDeviceInstanceID(int device_index)
|
||||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
static int
|
||||
EMSCRIPTEN_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||
EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index)
|
||||
{
|
||||
SDL_joylist_item *item = JoystickByDeviceIndex(device_index);
|
||||
|
||||
@@ -329,12 +335,14 @@ EMSCRIPTEN_JoystickOpen(SDL_Joystick * joystick, int device_index)
|
||||
* and update joystick device state.
|
||||
*/
|
||||
static void
|
||||
EMSCRIPTEN_JoystickUpdate(SDL_Joystick * joystick)
|
||||
EMSCRIPTEN_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
EmscriptenGamepadEvent gamepadState;
|
||||
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
||||
int i, result, buttonState;
|
||||
|
||||
emscripten_sample_gamepad_data();
|
||||
|
||||
if (item) {
|
||||
result = emscripten_get_gamepad_status(item->index, &gamepadState);
|
||||
if( result == EMSCRIPTEN_RESULT_SUCCESS) {
|
||||
@@ -369,7 +377,7 @@ EMSCRIPTEN_JoystickUpdate(SDL_Joystick * joystick)
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
static void
|
||||
EMSCRIPTEN_JoystickClose(SDL_Joystick * joystick)
|
||||
EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata;
|
||||
if (item) {
|
||||
@@ -389,7 +397,43 @@ EMSCRIPTEN_JoystickGetDeviceGUID(int device_index)
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
|
||||
EMSCRIPTEN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static SDL_bool
|
||||
EMSCRIPTEN_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||
{
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
static Uint32
|
||||
EMSCRIPTEN_JoystickGetCapabilities(SDL_Joystick *joystick)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
|
||||
static int
|
||||
EMSCRIPTEN_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
|
||||
{
|
||||
return SDL_Unsupported();
|
||||
}
|
||||
@@ -401,13 +445,20 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver =
|
||||
EMSCRIPTEN_JoystickDetect,
|
||||
EMSCRIPTEN_JoystickGetDeviceName,
|
||||
EMSCRIPTEN_JoystickGetDevicePlayerIndex,
|
||||
EMSCRIPTEN_JoystickSetDevicePlayerIndex,
|
||||
EMSCRIPTEN_JoystickGetDeviceGUID,
|
||||
EMSCRIPTEN_JoystickGetDeviceInstanceID,
|
||||
EMSCRIPTEN_JoystickOpen,
|
||||
EMSCRIPTEN_JoystickRumble,
|
||||
EMSCRIPTEN_JoystickRumbleTriggers,
|
||||
EMSCRIPTEN_JoystickGetCapabilities,
|
||||
EMSCRIPTEN_JoystickSetLED,
|
||||
EMSCRIPTEN_JoystickSendEffect,
|
||||
EMSCRIPTEN_JoystickSetSensorsEnabled,
|
||||
EMSCRIPTEN_JoystickUpdate,
|
||||
EMSCRIPTEN_JoystickClose,
|
||||
EMSCRIPTEN_JoystickQuit,
|
||||
EMSCRIPTEN_JoystickGetGamepadMapping
|
||||
};
|
||||
|
||||
#endif /* SDL_JOYSTICK_EMSCRIPTEN */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
||||
Reference in New Issue
Block a user