PS2: Add mouse cursor crosshairs too, and fix noclip

This commit is contained in:
UnknownShadow200 2024-07-10 20:26:40 +10:00
parent e7f9ab9797
commit 4eeb4cdb0d
8 changed files with 10 additions and 15 deletions

View File

@ -908,6 +908,7 @@ static cc_bool LocalPlayer_HandleFly(int key, struct InputDevice* device) {
static cc_bool LocalPlayer_HandleNoclip(int key, struct InputDevice* device) {
struct LocalPlayer* p = LocalPlayer_Get(device->index);
p->Hacks._noclipping = true;
if (p->Hacks.CanNoclip && p->Hacks.Enabled) {
if (p->Hacks.WOMStyleHacks) return true; /* don't handle this here */
@ -996,10 +997,6 @@ static void LocalPlayer_ReleaseJump(int key, struct InputDevice* device) {
LocalPlayer_Get(device->index)->Physics.Jumping = false;
}
static cc_bool LocalPlayer_TriggerNoclip(int key, struct InputDevice* device) {
LocalPlayer_Get(device->index)->Hacks._noclipping = true;
return true;
}
static void LocalPlayer_ReleaseNoclip(int key, struct InputDevice* device) {
LocalPlayer_Get(device->index)->Hacks._noclipping = false;
}
@ -1023,8 +1020,6 @@ static void LocalPlayer_HookBinds(void) {
Bind_OnTriggered[BIND_JUMP] = LocalPlayer_TriggerJump;
Bind_OnReleased[BIND_JUMP] = LocalPlayer_ReleaseJump;
Bind_OnTriggered[BIND_NOCLIP] = LocalPlayer_TriggerNoclip;
Bind_OnReleased[BIND_NOCLIP] = LocalPlayer_ReleaseNoclip;
}

View File

@ -3,6 +3,7 @@
#include "Drawer2D.h"
#include "Input.h"
#include "LBackend.h"
static cc_bool vc_hooked;
#define CURSOR_SIZE 1
#define CURSOR_EXTENT 5
@ -23,6 +24,7 @@ static void VirtualCursor_Display2D(struct Context2D* ctx) {
static void VirtualCursor_SetPosition(int x, int y) {
x = max(0, min(x, Window_Main.Width - 1));
y = max(0, min(y, Window_Main.Height - 1));
vc_hooked = true;
if (x == Pointers[0].x && y == Pointers[0].y) return;
Pointer_SetPosition(0, x, y);

View File

@ -279,7 +279,6 @@ void OnscreenKeyboard_Open(struct OpenKeyboardArgs* args) {
OnscreenTextChanged(output);
}
void OnscreenKeyboard_SetText(const cc_string* text) { }
void OnscreenKeyboard_Draw2D(Rect2D* r, struct Bitmap* bmp) { }
void OnscreenKeyboard_Draw3D(void) { }
void OnscreenKeyboard_Close(void) {

View File

@ -547,7 +547,6 @@ void OnscreenKeyboard_SetText(const cc_string* text) {
(*env)->DeleteLocalRef(env, args[0].l);
}
void OnscreenKeyboard_Draw2D(Rect2D* r, struct Bitmap* bmp) { }
void OnscreenKeyboard_Draw3D(void) { }
void OnscreenKeyboard_Close(void) {

View File

@ -14,7 +14,6 @@
#include <kos.h>
static cc_bool launcherMode;
static cc_bool vc_hooked;
#include "VirtualCursor.h"
cc_bool window_inited;
@ -204,9 +203,7 @@ static void ProcessMouseInput(float delta) {
Input_SetNonRepeatable(CCMOUSE_R, mods & MOUSE_RIGHTBUTTON);
Input_SetNonRepeatable(CCMOUSE_M, mods & MOUSE_SIDEBUTTON);
/* Start cursor at window middle */
if (!vc_hooked) {
vc_hooked = true;
Pointer_SetPosition(0, Window_Main.Width / 2, Window_Main.Height / 2);
}
VirtualCursor_SetPosition(Pointers[0].x + state->dx, Pointers[0].y + state->dy);

View File

@ -184,7 +184,6 @@ void Window_FreeFramebuffer(struct Bitmap* bmp) {
*#########################################################################################################################*/
void OnscreenKeyboard_Open(struct OpenKeyboardArgs* args) { /* TODO implement */ }
void OnscreenKeyboard_SetText(const cc_string* text) { }
void OnscreenKeyboard_Draw2D(Rect2D* r, struct Bitmap* bmp) { }
void OnscreenKeyboard_Draw3D(void) { }
void OnscreenKeyboard_Close(void) { /* TODO implement */ }

View File

@ -152,6 +152,11 @@ static void ProcessMouseInput(float delta) {
Input_SetNonRepeatable(CCMOUSE_M, mData.buttons & PS2MOUSE_BTN3);
Mouse_ScrollVWheel(mData.wheel);
if (!vc_hooked) {
Pointer_SetPosition(0, Window_Main.Width / 2, Window_Main.Height / 2);
}
VirtualCursor_SetPosition(Pointers[0].x + mData.x, Pointers[0].y + mData.y);
if (!Input.RawMode) return;
float scale = (delta * 60.0) / 2.0f;
Event_RaiseRawMove(&PointerEvents.RawMoved,

View File

@ -539,7 +539,6 @@ void OnscreenKeyboard_SetText(const cc_string* text) {
text_input.text = str;
}
void OnscreenKeyboard_Draw2D(Rect2D* r, struct Bitmap* bmp) { }
void OnscreenKeyboard_Draw3D(void) { }
void OnscreenKeyboard_Close(void) {