Posted: 2nd Jun 2022 19:25
I know I should post this on Raspberry Pi forum but I'm not sure if anyone reads it anymore

I've been trying to implement a first person camera and I couldn't seem to get it working correctly even when
I hide the cursor using SetRawMouseVisible(0).

Looking at the Tier 2 code (Line : 4302 LinuxCore.cpp)

The original code is:
+ Code Snippet
void agk::SetRawMouseVisible( int visible )
//****
{
  if ( !g_pWindow ) return;
  glfwSetInputMode( g_pWindow, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN );
}


Change GLFW_CURSOR_HIDDEN to GLFW_CURSOR_DISABLED seems to solve the issue.

Working version:
+ Code Snippet
void agk::SetRawMouseVisible( int visible )
//****
{
  if ( !g_pWindow ) return;
  glfwSetInputMode( g_pWindow, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED );
}


When I build a new version of AppGameKit on the Pi4 and use the following code I get the desired first person camera.

+ Code Snippet
  mouseY = agk::GetRawMouseX()*0.1; 
  mouseX = agk::GetRawMouseY()*0.1; 
  
  agk::SetCameraRotation(1, mouseX, mouseY, 0.0);


Is this a problem on any other platform? Can anyone confirm this?
Posted: 2nd Jun 2022 19:52
i know nothing about linux but a quick search for glfwSetInputMode provided THIS:
LFW_CURSOR_DISABLED hides and grabs the cursor, providing virtual and unlimited cursor movement. This is useful for implementing for example 3D camera controls.

where GLFW_CURSOR_DISABLED appears ideal behavior for MouseLook considering it seems to automatically park the cursor vs having to reposition it each frame as i do in this example so that i can retrieve MouseX/Y delta values.

with that, i can't say that there is anything wrong with the original code since i believe it's doing what it's supposed to do while i also can't say that i've seen your method of MouseLook before:
+ Code Snippet
mouseY = agk::GetRawMouseX()*0.1; 
mouseX = agk::GetRawMouseY()*0.1; 
 
agk::SetCameraRotation(1, mouseX, mouseY, 0.0);

otherwise, i have seen the method i've used in the heightmap snippet a thousand times on the forums (and why i picked up the practice and, perhaps, suggest that you do?).

meanwhile, if there's an equivalent to GLFW_CURSOR_DISABLED on all OSs then i'd love to see the command added.

/2?
Posted: 2nd Jun 2022 22:02
I have tried the method you use before and it works but I wanted to come up with an even easier way.

Changing GLFW_CURSOR_HIDDEN to GLFW_CURSOR_DISABLED seems to work on Linux / Raspberry Pi but I also
see they use this method with HTML5 so will probably need the same change.

I suppose it's not a problem if the current solution works for everyone but I always like to keep things simple.

What do you think Virtual Nomad is it worth asking for an update for the Linux and HTML5 version of AppGameKit?
Posted: 3rd Jun 2022 1:31
asking rarely hurts but you want GLFW_CURSOR_DISABLED behavior as a new command like SetRawMouseDisabled() and not change SetRawMouseVisible(), right?

otherwise, providing the ability to disable the mouse completely sounds like opening a gateway to/from hell for irresponsible coders

meanwhile, i'd rather have GetRawMouseWheelDelta() was. it was a glaring omission when migrating from DBPro which had it natively, i believe).

alas, it's a few lines of code to replicate and i'd much rather have some other features and/or bug fixes...
Posted: 6th Jun 2022 15:52
When doing a mouse look, doesn't one have to use the mouse delta from screen center, rather than just the mouse x/y?
With a delta, RotateCameraLocal/Global/X/Y might be easier than SetCameraRotation.

+ Code Snippet
centerX = agk::GetDeviceWidth() / 2;
centerY = agk::GetDeviceHeight() / 2;
mouseY = (agk::GetRawMouseX() - centerX) * 0.1; 
mouseX = (agk::GetRawMouseY() - centerY) * 0.1; 
agk::RotateCameraLocalX(1, mouseX);
agk::RotateCameraGlobalY(1, mouseY);
agk::SetRawMousePosition(centerX, centerY);


SetRawMouseVisible's behavior shouldn't be changed. Maybe I want to hide the OS mouse and render my own at the mouse position.
I think CaptureRawMouse is a better name than SetRawMouseDisabled.
Posted: 6th Jun 2022 20:28
I think CaptureRawMouse should be added to Tier 1 and Tier 2 as using glfwSetInputMode( g_pWindow, GLFW_CURSOR, visible ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_DISABLED );
makes things much easier for an FPS camera as it hides the cursor and 'captures' the mouse.

I don't know what is better but I think;

mouseY = agk::GetRawMouseX()*0.1;
mouseX = agk::GetRawMouseY()*0.1;
agk::SetCameraRotation(1, mouseX, mouseY, 0.0);


looks like a nice easy solution for a product like AppGameKit, it's also quite smooth (atleast on the Raspberry Pi )

Added to my version of Tier2, seems to work!