feat: add flag to enable/disable mouse
This commit is contained in:
parent
efb463d62d
commit
6e975919c8
@ -1288,7 +1288,7 @@ static LRESULT CALLBACK app_internal_wndproc( HWND hwnd, UINT message, WPARAM wp
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
if( app->has_focus )
|
if( app->has_focus && ALLOW_MOUSE )
|
||||||
{
|
{
|
||||||
POINT p;
|
POINT p;
|
||||||
GetCursorPos( &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 ) );
|
app->GetRawInputDataPtr( (HRAWINPUT) lparam, RID_INPUT, &raw, &size, sizeof( RAWINPUTHEADER ) );
|
||||||
if( raw.header.dwType == RIM_TYPEMOUSE )
|
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 dx = (float) raw.data.mouse.lLastX;
|
||||||
float dy = (float) raw.data.mouse.lLastY;
|
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;
|
if( interpolation == app->interpolation ) return;
|
||||||
app->interpolation = interpolation;
|
app->interpolation = interpolation;
|
||||||
|
|
||||||
|
if( ALLOW_MOUSE ) {
|
||||||
POINT p;
|
POINT p;
|
||||||
GetCursorPos( &p );
|
GetCursorPos( &p );
|
||||||
ScreenToClient( app->hwnd, &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.x = mouse_x;
|
||||||
input_event.data.mouse_pos.y = mouse_y;
|
input_event.data.mouse_pos.y = mouse_y;
|
||||||
app_internal_add_input_event( app, &input_event );
|
app_internal_add_input_event( app, &input_event );
|
||||||
|
}
|
||||||
app_internal_opengl_interpolation( &app->gl, interpolation );
|
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 );
|
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;
|
app_input_event_t input_event;
|
||||||
input_event.type = APP_INPUT_MOUSE_MOVE;
|
input_event.type = APP_INPUT_MOUSE_MOVE;
|
||||||
@ -3219,6 +3220,7 @@ void app_interpolation( app_t* app, app_interpolation_t interpolation )
|
|||||||
int mouse_y;
|
int mouse_y;
|
||||||
SDL_GetMouseState( &mouse_x, &mouse_y );
|
SDL_GetMouseState( &mouse_x, &mouse_y );
|
||||||
|
|
||||||
|
if( ALLOW_MOUSE ) {
|
||||||
app_input_event_t input_event;
|
app_input_event_t input_event;
|
||||||
input_event.type = APP_INPUT_MOUSE_MOVE;
|
input_event.type = APP_INPUT_MOUSE_MOVE;
|
||||||
input_event.data.mouse_pos.x = mouse_x;
|
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)=>
|
canvasEvent('mousemove', (e)=>
|
||||||
{
|
{
|
||||||
|
if( ALLOW_MOUSE ) {
|
||||||
evts.push(5,
|
evts.push(5,
|
||||||
(e.offsetX * canvas.width / canvas.clientWidth )|0,
|
(e.offsetX * canvas.width / canvas.clientWidth )|0,
|
||||||
(e.offsetY * canvas.height / canvas.clientHeight)|0);
|
(e.offsetY * canvas.height / canvas.clientHeight)|0);
|
||||||
cancelEvent(e);
|
cancelEvent(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
var buttons = 0;
|
var buttons = 0;
|
||||||
canvasEvent('mousedown', (e)=>
|
canvasEvent('mousedown', (e)=>
|
||||||
@ -3788,6 +3792,7 @@ app_state_t app_yield( app_t* app )
|
|||||||
app_internal_add_input_event( app, &input_event );
|
app_internal_add_input_event( app, &input_event );
|
||||||
break;
|
break;
|
||||||
case 5: // MOUSE_MOTION x y
|
case 5: // MOUSE_MOTION x y
|
||||||
|
if( ALLOW_MOUSE ) {
|
||||||
input_event.type = APP_INPUT_MOUSE_MOVE;
|
input_event.type = APP_INPUT_MOUSE_MOVE;
|
||||||
app->pointer_x = input_event.data.mouse_pos.x = evt[1];
|
app->pointer_x = input_event.data.mouse_pos.x = evt[1];
|
||||||
app->pointer_y = input_event.data.mouse_pos.y = evt[2];
|
app->pointer_y = input_event.data.mouse_pos.y = evt[2];
|
||||||
|
|||||||
@ -11,6 +11,10 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "app_opengl.h"
|
#include "app_opengl.h"
|
||||||
|
|
||||||
|
#ifndef ALLOW_MOUSE
|
||||||
|
#define ALLOW_MOUSE 1
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct app_t app_t;
|
typedef struct app_t app_t;
|
||||||
typedef enum app_log_level_t {
|
typedef enum app_log_level_t {
|
||||||
APP_LOG_LEVEL_INFO,
|
APP_LOG_LEVEL_INFO,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user