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