mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 11:06:06 -04:00
Webclient: Fix being unable to change controls in some browser versions
This was my fault for not implementing pressing buttons on mouse movement properly. Also fixes on Windows where if you pressed on a control and still held down left mouse for a bit, the game would set the control binding to LeftMouse.
This commit is contained in:
parent
155e375f94
commit
42c4e1c841
@ -245,6 +245,15 @@ void Input_Set(int key, int pressed) {
|
||||
}
|
||||
}
|
||||
|
||||
void Input_SetNonRepeatable(int key, int pressed) {
|
||||
if (pressed) {
|
||||
if (Input_Pressed[key]) return;
|
||||
Input_SetPressed(key);
|
||||
} else {
|
||||
Input_SetReleased(key);
|
||||
}
|
||||
}
|
||||
|
||||
void Input_Clear(void) {
|
||||
int i;
|
||||
for (i = 0; i < INPUT_COUNT; i++) {
|
||||
|
@ -70,6 +70,7 @@ void Input_SetPressed(int key);
|
||||
void Input_SetReleased(int key);
|
||||
/* Calls either Input_SetPressed or Input_SetReleased */
|
||||
void Input_Set(int key, int pressed);
|
||||
void Input_SetNonRepeatable(int key, int pressed);
|
||||
/* Resets all keyboard buttons to released state. (Input_SetReleased) */
|
||||
void Input_Clear(void);
|
||||
|
||||
|
12
src/Window.c
12
src/Window.c
@ -552,9 +552,9 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
/* Set before position change, in case mouse buttons changed when outside window */
|
||||
Input_Set(KEY_LMOUSE, wParam & 0x01);
|
||||
Input_Set(KEY_RMOUSE, wParam & 0x02);
|
||||
Input_Set(KEY_MMOUSE, wParam & 0x10);
|
||||
Input_SetNonRepeatable(KEY_LMOUSE, wParam & 0x01);
|
||||
Input_SetNonRepeatable(KEY_RMOUSE, wParam & 0x02);
|
||||
Input_SetNonRepeatable(KEY_MMOUSE, wParam & 0x10);
|
||||
/* TODO: do we need to set XBUTTON1/XBUTTON2 here */
|
||||
Pointer_SetPosition(0, LOWORD(lParam), HIWORD(lParam));
|
||||
break;
|
||||
@ -3187,9 +3187,9 @@ static void RescaleXY(int srcX, int srcY, int* dstX, int* dstY) {
|
||||
static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data) {
|
||||
int x, y, buttons = ev->buttons;
|
||||
/* Set before position change, in case mouse buttons changed when outside window */
|
||||
Input_Set(KEY_LMOUSE, buttons & 0x01);
|
||||
Input_Set(KEY_RMOUSE, buttons & 0x02);
|
||||
Input_Set(KEY_MMOUSE, buttons & 0x04);
|
||||
Input_SetNonRepeatable(KEY_LMOUSE, buttons & 0x01);
|
||||
Input_SetNonRepeatable(KEY_RMOUSE, buttons & 0x02);
|
||||
Input_SetNonRepeatable(KEY_MMOUSE, buttons & 0x04);
|
||||
|
||||
RescaleXY(ev->targetX, ev->targetY, &x, &y);
|
||||
Pointer_SetPosition(0, x, y);
|
||||
|
Loading…
x
Reference in New Issue
Block a user