feat: add flag to enable/disable mouse

This commit is contained in:
☙◦ The Tablet ❀ GamerGirlandCo ◦❧ 2026-01-20 15:32:41 -05:00
parent efb463d62d
commit 6e975919c8
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
2 changed files with 16 additions and 7 deletions

View File

@ -1288,7 +1288,7 @@ static LRESULT CALLBACK app_internal_wndproc( HWND hwnd, UINT message, WPARAM wp
break;
case WM_MOUSEMOVE:
if( app->has_focus )
if( app->has_focus && ALLOW_MOUSE )
{
POINT p;
GetCursorPos( &p );
@ -1312,7 +1312,7 @@ static LRESULT CALLBACK app_internal_wndproc( HWND hwnd, UINT message, WPARAM wp
app->GetRawInputDataPtr( (HRAWINPUT) lparam, RID_INPUT, &raw, &size, sizeof( RAWINPUTHEADER ) );
if( raw.header.dwType == RIM_TYPEMOUSE )
{
if( ( raw.data.mouse.usFlags & 1 ) == MOUSE_MOVE_RELATIVE)
if( ( raw.data.mouse.usFlags & 1 ) == MOUSE_MOVE_RELATIVE && ALLOW_MOUSE )
{
float dx = (float) raw.data.mouse.lLastX;
float dy = (float) raw.data.mouse.lLastY;
@ -2249,6 +2249,7 @@ void app_interpolation( app_t* app, app_interpolation_t interpolation )
if( interpolation == app->interpolation ) return;
app->interpolation = interpolation;
if( ALLOW_MOUSE ) {
POINT p;
GetCursorPos( &p );
ScreenToClient( app->hwnd, &p );
@ -2260,7 +2261,7 @@ void app_interpolation( app_t* app, app_interpolation_t interpolation )
input_event.data.mouse_pos.x = mouse_x;
input_event.data.mouse_pos.y = mouse_y;
app_internal_add_input_event( app, &input_event );
}
app_internal_opengl_interpolation( &app->gl, interpolation );
}
@ -3064,7 +3065,7 @@ app_state_t app_yield( app_t* app )
app_internal_add_input_event( app, &input_event );
}
}
else if( e.type == SDL_MOUSEMOTION )
else if( e.type == SDL_MOUSEMOTION && ALLOW_MOUSE )
{
app_input_event_t input_event;
input_event.type = APP_INPUT_MOUSE_MOVE;
@ -3219,6 +3220,7 @@ void app_interpolation( app_t* app, app_interpolation_t interpolation )
int mouse_y;
SDL_GetMouseState( &mouse_x, &mouse_y );
if( ALLOW_MOUSE ) {
app_input_event_t input_event;
input_event.type = APP_INPUT_MOUSE_MOVE;
input_event.data.mouse_pos.x = mouse_x;
@ -3546,10 +3548,12 @@ void, app_js_setup_canvas, (int* out_width, int* out_height),
});
canvasEvent('mousemove', (e)=>
{
if( ALLOW_MOUSE ) {
evts.push(5,
(e.offsetX * canvas.width / canvas.clientWidth )|0,
(e.offsetY * canvas.height / canvas.clientHeight)|0);
cancelEvent(e);
}
});
var buttons = 0;
canvasEvent('mousedown', (e)=>
@ -3788,6 +3792,7 @@ app_state_t app_yield( app_t* app )
app_internal_add_input_event( app, &input_event );
break;
case 5: // MOUSE_MOTION x y
if( ALLOW_MOUSE ) {
input_event.type = APP_INPUT_MOUSE_MOVE;
app->pointer_x = input_event.data.mouse_pos.x = evt[1];
app->pointer_y = input_event.data.mouse_pos.y = evt[2];

View File

@ -11,6 +11,10 @@
#endif
#include "app_opengl.h"
#ifndef ALLOW_MOUSE
#define ALLOW_MOUSE 1
#endif
typedef struct app_t app_t;
typedef enum app_log_level_t {
APP_LOG_LEVEL_INFO,