Fixed some bugs.
This commit is contained in:
@@ -9,10 +9,6 @@
|
||||
#include "util/memory.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
#if DOLPHIN
|
||||
#include "display/texture.h"
|
||||
#endif
|
||||
|
||||
errorret_t meshInit(
|
||||
mesh_t *mesh,
|
||||
const meshprimitivetype_t primitiveType,
|
||||
|
||||
@@ -24,12 +24,6 @@
|
||||
|
||||
#include "duskplatform.h"
|
||||
|
||||
#if PSP
|
||||
#include "duskpsp.h"
|
||||
#elif DOLPHIN
|
||||
#include "duskdolphin.h"
|
||||
#endif
|
||||
|
||||
typedef bool bool_t;
|
||||
typedef int int_t;
|
||||
typedef float float_t;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "util/math.h"
|
||||
#include "time/time.h"
|
||||
#include "debug/debug.h"
|
||||
#include "display/display.h"
|
||||
|
||||
input_t INPUT;
|
||||
|
||||
|
||||
@@ -180,4 +180,6 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
{ .name = "kp_enter", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_ENTER } },
|
||||
{ .name = "kp_equals", { .type = INPUT_BUTTON_TYPE_KEYBOARD, .scancode = SDL_SCANCODE_KP_EQUALS } },
|
||||
#endif
|
||||
|
||||
{ .name = NULL },
|
||||
};
|
||||
@@ -7,31 +7,34 @@
|
||||
|
||||
#include "input/input.h"
|
||||
#include "assert/assert.h"
|
||||
#include "display/display.h"
|
||||
|
||||
void inputUpdateSDL2(void) {
|
||||
#if INPUT_GAMEPAD == 1
|
||||
INPUT.controller = NULL;
|
||||
#ifdef DUSK_INPUT_GAMEPAD
|
||||
INPUT.platform.controller = NULL;
|
||||
|
||||
for(int32_t i = 0; i < SDL_NumJoysticks(); i++) {
|
||||
if(!SDL_IsGameController(i)) continue;
|
||||
INPUT.controller = SDL_GameControllerOpen(i);
|
||||
if(INPUT.controller) break;
|
||||
INPUT.platform.controller = SDL_GameControllerOpen(i);
|
||||
if(INPUT.platform.controller) break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if INPUT_KEYBOARD == 1
|
||||
INPUT.keyboardState = SDL_GetKeyboardState(NULL);
|
||||
#ifdef DUSK_INPUT_KEYBOARD
|
||||
INPUT.platform.keyboardState = SDL_GetKeyboardState(NULL);
|
||||
#endif
|
||||
|
||||
#if INPUT_POINTER == 1
|
||||
#ifdef DUSK_INPUT_POINTER
|
||||
int pointerX, pointerY;
|
||||
SDL_GetMouseState(&pointerX, &pointerY);
|
||||
|
||||
int windowWidth, windowHeight;
|
||||
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
|
||||
|
||||
INPUT.mouseX = (float_t)pointerX / (float_t)windowWidth;
|
||||
INPUT.mouseY = (float_t)pointerY / (float_t)windowHeight;
|
||||
INPUT.platform.mouseX = (float_t)pointerX / (float_t)windowWidth;
|
||||
INPUT.platform.mouseY = (float_t)pointerY / (float_t)windowHeight;
|
||||
INPUT.platform.scrollX = 0.0f;
|
||||
INPUT.platform.scrollY = 0.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -52,6 +55,15 @@ float_t inputButtonGetValue(const inputbutton_t button) {
|
||||
case INPUT_POINTER_AXIS_Y:
|
||||
return INPUT.platform.mouseY;
|
||||
|
||||
case INPUT_POINTER_AXIS_Z:
|
||||
return 0.0f; // Not supported in SDL2
|
||||
|
||||
case INPUT_POINTER_AXIS_WHEEL_X:
|
||||
return INPUT.platform.scrollX;
|
||||
|
||||
case INPUT_POINTER_AXIS_WHEEL_Y:
|
||||
return INPUT.platform.scrollY;
|
||||
|
||||
default:
|
||||
assertUnreachable("Unknown pointer axis");
|
||||
return 0.0f;
|
||||
|
||||
@@ -40,6 +40,7 @@ typedef struct {
|
||||
|
||||
#ifdef DUSK_INPUT_POINTER
|
||||
float_t mouseX, mouseY;
|
||||
float_t scrollX, scrollY;
|
||||
#endif
|
||||
} inputsdl2_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user