fix xinput stuff
This commit is contained in:
parent
e6d7d0cf23
commit
2a9d25b067
2
Makefile
2
Makefile
|
|
@ -4,5 +4,5 @@ PLATFORM = PLATOFRM_WEB_RGFW OS=linux
|
||||||
|
|
||||||
all:
|
all:
|
||||||
rm -f examples/$(EXAMPLE).exe examples/$(EXAMPLE).html examples/$(EXAMPLE).wasm examples/$(EXAMPLE).js src/rcore.o
|
rm -f examples/$(EXAMPLE).exe examples/$(EXAMPLE).html examples/$(EXAMPLE).wasm examples/$(EXAMPLE).js src/rcore.o
|
||||||
cd src && make PLATFORM=$(PLATFORM)
|
cd src && make PLATFORM=$(PLATFORM)
|
||||||
cd examples && make $(EXAMPLE) PLATFORM=$(PLATFORM)
|
cd examples && make $(EXAMPLE) PLATFORM=$(PLATFORM)
|
||||||
|
|
|
||||||
40
src/external/RGFW.h
vendored
40
src/external/RGFW.h
vendored
|
|
@ -5198,19 +5198,22 @@ static HMODULE wglinstance = NULL;
|
||||||
u32 i;
|
u32 i;
|
||||||
static const char* names[] = {
|
static const char* names[] = {
|
||||||
"xinput1_4.dll",
|
"xinput1_4.dll",
|
||||||
"xinput1_3.dll",
|
|
||||||
"xinput9_1_0.dll",
|
"xinput9_1_0.dll",
|
||||||
"xinput1_2.dll",
|
"xinput1_2.dll",
|
||||||
"xinput1_1.dll"
|
"xinput1_1.dll"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i = 0; i < sizeof(names) / sizeof(const char*); i++) {
|
for (i = 0; i < sizeof(names) / sizeof(const char*) && (XInputGetStateSRC == NULL || XInputGetStateSRC != NULL); i++) {
|
||||||
RGFW_XInput_dll = LoadLibraryA(names[i]);
|
RGFW_XInput_dll = LoadLibraryA(names[i]);
|
||||||
|
|
||||||
if (RGFW_XInput_dll) {
|
if (RGFW_XInput_dll == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (XInputGetStateSRC == NULL)
|
||||||
XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState");
|
XInputGetStateSRC = (PFN_XInputGetState)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetState");
|
||||||
|
|
||||||
|
if (XInputGetKeystrokeSRC == NULL)
|
||||||
XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke");
|
XInputGetKeystrokeSRC = (PFN_XInputGetKeystroke)(void*)GetProcAddress(RGFW_XInput_dll, "XInputGetKeystroke");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (XInputGetStateSRC == NULL)
|
if (XInputGetStateSRC == NULL)
|
||||||
|
|
@ -5655,7 +5658,9 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
RGFW_JS_LEFT, /* dpad left */
|
RGFW_JS_LEFT, /* dpad left */
|
||||||
RGFW_JS_RIGHT, /* dpad right */
|
RGFW_JS_RIGHT, /* dpad right */
|
||||||
RGFW_JS_START, /* start button */
|
RGFW_JS_START, /* start button */
|
||||||
RGFW_JS_SELECT/* select button */
|
RGFW_JS_SELECT,/* select button */
|
||||||
|
RGFW_JS_L3,
|
||||||
|
RGFW_JS_R3,
|
||||||
};
|
};
|
||||||
|
|
||||||
static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) {
|
static i32 RGFW_checkXInput(RGFW_window* win, RGFW_Event* e) {
|
||||||
|
|
@ -5672,10 +5677,10 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) {
|
if ((keystroke.Flags & XINPUT_KEYSTROKE_REPEAT) == 0 && result != ERROR_EMPTY) {
|
||||||
if (result != ERROR_SUCCESS)
|
if (result != ERROR_SUCCESS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (keystroke.VirtualKey > VK_PAD_BACK)
|
if (keystroke.VirtualKey > VK_PAD_RTHUMB_PRESS)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased
|
// RGFW_jsButtonPressed + 1 = RGFW_jsButtonReleased
|
||||||
e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
e->type = RGFW_jsButtonPressed + !(keystroke.Flags & XINPUT_KEYSTROKE_KEYDOWN);
|
||||||
e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800];
|
e->button = RGFW_xinput2RGFW[keystroke.VirtualKey - 0x5800];
|
||||||
|
|
@ -5689,6 +5694,7 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED
|
XInputGetState((DWORD) i, &state) == ERROR_DEVICE_NOT_CONNECTED
|
||||||
)
|
)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed.
|
#define INPUT_DEADZONE ( 0.24f * (float)(0x7FFF) ) // Default to 24% of the +/- 32767 range. This is a reasonable default value but can be altered if needed.
|
||||||
|
|
||||||
if ((state.Gamepad.sThumbLX < INPUT_DEADZONE &&
|
if ((state.Gamepad.sThumbLX < INPUT_DEADZONE &&
|
||||||
|
|
@ -5710,22 +5716,26 @@ RGFW_UNUSED(win); /*!< if buffer rendering is not being used */
|
||||||
}
|
}
|
||||||
|
|
||||||
e->axisesCount = 2;
|
e->axisesCount = 2;
|
||||||
RGFW_point axis1 = RGFW_POINT(state.Gamepad.sThumbLX, state.Gamepad.sThumbLY);
|
RGFW_point axis1 = RGFW_POINT(((float)state.Gamepad.sThumbLX / 32768.0f) * 100, ((float)state.Gamepad.sThumbLY / -32768.0f) * 100);
|
||||||
RGFW_point axis2 = RGFW_POINT(state.Gamepad.sThumbRX, state.Gamepad.sThumbRY);
|
RGFW_point axis2 = RGFW_POINT(((float)state.Gamepad.sThumbRX / 32768.0f) * 100, ((float)state.Gamepad.sThumbRY / -32768.0f) * 100);
|
||||||
|
|
||||||
if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y || axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) {
|
if (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y){
|
||||||
win->event.whichAxis = (axis1.x != e->axis[0].x || axis1.y != e->axis[0].y) ? 0 : 1;
|
win->event.whichAxis = 0;
|
||||||
|
|
||||||
e->type = RGFW_jsAxisMove;
|
e->type = RGFW_jsAxisMove;
|
||||||
|
|
||||||
e->axis[0] = axis1;
|
e->axis[0] = axis1;
|
||||||
e->axis[1] = axis2;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
e->axis[0] = axis1;
|
if (axis2.x != e->axis[1].x || axis2.y != e->axis[1].y) {
|
||||||
e->axis[1] = axis2;
|
win->event.whichAxis = 1;
|
||||||
|
e->type = RGFW_jsAxisMove;
|
||||||
|
e->axis[1] = axis2;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user