feat(event): wire up more mouse mode handling

This commit is contained in:
fallenoak 2023-03-16 12:25:07 -05:00
parent 2b791973b5
commit 6135d7c37b
3 changed files with 40 additions and 2 deletions

View File

@ -325,8 +325,7 @@ void ProcessInput(const int32_t param[], OSINPUT id, int32_t* shutdown, EvtConte
void CheckMouseModeState() {
if (Input::s_mouseHoldButton) {
if (Input::s_mouseHoldButton != (Input::s_mouseHoldButton & Input::s_buttonState)) {
// TODO
// EventSetMouseMode(0, 0);
EventSetMouseMode(MOUSE_MODE_NORMAL, 0);
}
}
}
@ -355,6 +354,30 @@ void ConvertPosition(int32_t clientx, int32_t clienty, float* x, float* y) {
*y = 1.0 - (static_cast<float>(clienty) / static_cast<float>(windowDim.bottom - windowDim.top));
}
void EventSetMouseMode(MOUSEMODE mode, uint32_t holdButton) {
STORM_ASSERT(mode < MOUSE_MODES);
STORM_VALIDATE(mode < MOUSE_MODES, ERROR_INVALID_PARAMETER);
auto contextId = *reinterpret_cast<uint32_t*>(PropGet(PROP_EVENTCONTEXT));
int32_t findMask;
auto context = TSingletonInstanceId<EvtContext, offsetof(EvtContext, m_id)>::s_idTable.Ptr(
contextId,
0,
&findMask
);
if (context) {
IEvtSetMouseMode(context, mode, holdButton);
if (findMask != -1) {
TSingletonInstanceId<EvtContext, offsetof(EvtContext, m_id)>::s_idTable.Unlock(
findMask & (INSTANCE_TABLE_SLOT_COUNT - 1),
findMask >= INSTANCE_TABLE_SLOT_COUNT
);
}
}
}
uint32_t GenerateMouseFlags() {
uint32_t flags = 0;
@ -454,6 +477,10 @@ int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown) {
return v4;
}
void IEvtSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdButton) {
// TODO
}
const char* KeyCodeToString(KEY key) {
static char charBuf[8];

View File

@ -16,6 +16,7 @@ namespace Input {
extern C2iVector s_currentMouse;
extern uint32_t s_mouseHoldButton;
extern MOUSEMODE s_mouseMode;
extern OS_MOUSE_MODE s_osMouseMode;
extern int32_t s_numlockState;
extern int32_t s_simulatedRightButtonClick;
extern uint32_t s_metaKeyState;
@ -38,6 +39,8 @@ MOUSEBUTTON ConvertButtonNumberToMOUSEBUTTON(int32_t buttonNumber);
void ConvertPosition(int32_t clientx, int32_t clienty, float* x, float* y);
void EventSetMouseMode(MOUSEMODE mode, uint32_t holdButton);
uint32_t GenerateMouseFlags();
const char* GetButtonName(int32_t button);
@ -46,6 +49,8 @@ void IEvtInputInitialize();
int32_t IEvtInputProcess(EvtContext* context, int32_t* shutdown);
void IEvtSetMouseMode(EvtContext* context, MOUSEMODE mode, uint32_t holdButton);
const char* KeyCodeToString(KEY key);
int32_t OsInputGet(OSINPUT* id, int32_t* param0, int32_t* param1, int32_t* param2, int32_t* param3);

View File

@ -209,6 +209,12 @@ enum OSINPUT {
OS_INPUT_SHUTDOWN = 19
};
enum OS_MOUSE_MODE {
OS_MOUSE_MODE_NORMAL = 0,
OS_MOUSE_MODE_RELATIVE = 1,
OS_MOUSE_MODES = 2,
};
struct OSEVENT {
OSINPUT id;
int32_t param[4];