mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-30 10:15:36 +01:00
improve input
This commit is contained in:
54
src/game.c
54
src/game.c
@@ -22,6 +22,7 @@
|
||||
#include "rct2.h"
|
||||
#include "game.h"
|
||||
#include "news_item.h"
|
||||
#include "osinterface.h"
|
||||
#include "peep.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
@@ -45,7 +46,7 @@ void game_update()
|
||||
int eax, tmp;
|
||||
|
||||
// 0x006E3AEC // screen_game_process_mouse_input();
|
||||
RCT2_CALLPROC_EBPSAFE(0x006E3AEC); // screen_game_process_keyboard_input();
|
||||
// RCT2_CALLPROC_EBPSAFE(0x006E3AEC); // screen_game_process_keyboard_input();
|
||||
|
||||
// do game logic
|
||||
eax = RCT2_GLOBAL(0x009DE588, uint16) / 31;
|
||||
@@ -221,26 +222,39 @@ void game_handle_input()
|
||||
static void game_get_next_input(int *x, int *y, int *state)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
*x = eax & 0xFFFF;
|
||||
*y = ebx & 0xFFFF;
|
||||
*state = ecx & 0xFF;
|
||||
return;
|
||||
|
||||
int on_tutorial = RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8);
|
||||
if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) {
|
||||
if (on_tutorial == 1) {
|
||||
|
||||
} else {
|
||||
RCT2_CALLPROC_EBPSAFE(0x00407074);
|
||||
}
|
||||
if (on_tutorial == 2) {
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
RCT2_CALLFUNC_X(0x00407074, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
if (eax == 0) {
|
||||
*x = gCursorState.x;
|
||||
*y = gCursorState.y;
|
||||
*state = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*x = RCT2_GLOBAL(eax + 0, sint32);
|
||||
*y = RCT2_GLOBAL(eax + 4, sint32);
|
||||
*state = RCT2_GLOBAL(eax + 8, sint32);
|
||||
|
||||
//int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
//RCT2_CALLFUNC_X(0x006E83C7, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
//*x = eax & 0xFFFF;
|
||||
//*y = ebx & 0xFFFF;
|
||||
//*state = ecx & 0xFF;
|
||||
//return;
|
||||
|
||||
//int on_tutorial = RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8);
|
||||
//if (RCT2_GLOBAL(0x009DE518, uint32) & (1 << 5)) {
|
||||
// if (on_tutorial == 1) {
|
||||
|
||||
// } else {
|
||||
// RCT2_CALLPROC_EBPSAFE(0x00407074);
|
||||
// }
|
||||
// if (on_tutorial == 2) {
|
||||
|
||||
// }
|
||||
|
||||
//} else {
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
@@ -49,7 +49,7 @@ void osinterface_init()
|
||||
{
|
||||
osinterface_create_window();
|
||||
|
||||
RCT2_CALLPROC(0x00404584); // dinput_init()
|
||||
// RCT2_CALLPROC(0x00404584); // dinput_init()
|
||||
}
|
||||
|
||||
static void osinterface_create_window()
|
||||
@@ -194,69 +194,70 @@ void osinterface_process_messages()
|
||||
gCursorState.right &= ~CURSOR_CHANGED;
|
||||
gCursorState.old = 0;
|
||||
|
||||
SDL_PollEvent(&e);
|
||||
switch (e.type) {
|
||||
case SDL_QUIT:
|
||||
rct2_finish();
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
osinterface_resize(e.window.data1, e.window.data2);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
RCT2_GLOBAL(0x0142406C, int) = e.motion.x;
|
||||
RCT2_GLOBAL(0x01424070, int) = e.motion.y;
|
||||
while (SDL_PollEvent(&e)) {
|
||||
switch (e.type) {
|
||||
case SDL_QUIT:
|
||||
rct2_finish();
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
|
||||
osinterface_resize(e.window.data1, e.window.data2);
|
||||
break;
|
||||
case SDL_MOUSEMOTION:
|
||||
RCT2_GLOBAL(0x0142406C, int) = e.motion.x;
|
||||
RCT2_GLOBAL(0x01424070, int) = e.motion.y;
|
||||
|
||||
gCursorState.x = e.motion.x;
|
||||
gCursorState.y = e.motion.y;
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
RCT2_GLOBAL(0x009E2D80, int) += e.wheel.y * 128;
|
||||
gCursorState.wheel = e.wheel.y;
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
RCT2_GLOBAL(0x01424318, int) = e.button.x;
|
||||
RCT2_GLOBAL(0x0142431C, int) = e.button.y;
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 1);
|
||||
gCursorState.left = CURSOR_PRESSED;
|
||||
gCursorState.old = 1;
|
||||
gCursorState.x = e.motion.x;
|
||||
gCursorState.y = e.motion.y;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
gCursorState.middle = CURSOR_PRESSED;
|
||||
case SDL_MOUSEWHEEL:
|
||||
RCT2_GLOBAL(0x009E2D80, int) += e.wheel.y * 128;
|
||||
gCursorState.wheel = e.wheel.y;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 2);
|
||||
gCursorState.right = CURSOR_PRESSED;
|
||||
gCursorState.old = 2;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
RCT2_GLOBAL(0x01424318, int) = e.button.x;
|
||||
RCT2_GLOBAL(0x0142431C, int) = e.button.y;
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 1);
|
||||
gCursorState.left = CURSOR_PRESSED;
|
||||
gCursorState.old = 1;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
gCursorState.middle = CURSOR_PRESSED;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 3);
|
||||
gCursorState.right = CURSOR_PRESSED;
|
||||
gCursorState.old = 2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
*((int*)0x01424318) = e.button.x;
|
||||
*((int*)0x0142431C) = e.button.y;
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 2);
|
||||
gCursorState.left = CURSOR_RELEASED;
|
||||
gCursorState.old = 3;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
gCursorState.middle = CURSOR_RELEASED;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 4);
|
||||
gCursorState.right = CURSOR_RELEASED;
|
||||
gCursorState.old = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
gLastKeyPressed = e.key.keysym.sym;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
*((int*)0x01424318) = e.button.x;
|
||||
*((int*)0x0142431C) = e.button.y;
|
||||
switch (e.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 3);
|
||||
gCursorState.left = CURSOR_RELEASED;
|
||||
gCursorState.old = 3;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
gCursorState.middle = CURSOR_RELEASED;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
RCT2_CALLPROC_1(0x00406C96, int, 4);
|
||||
gCursorState.right = CURSOR_RELEASED;
|
||||
gCursorState.old = 4;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
gLastKeyPressed = e.key.keysym.sym;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
gCursorState.any = gCursorState.left | gCursorState.middle | gCursorState.right;
|
||||
@@ -264,6 +265,13 @@ void osinterface_process_messages()
|
||||
// Updates the state of the keys
|
||||
int numKeys = 256;
|
||||
gKeysState = SDL_GetKeyboardState(&numKeys);
|
||||
// memcpy(0x01425C00, gKeysState, 256);
|
||||
|
||||
RCT2_GLOBAL(0x009DEA70, uint8) = 0;
|
||||
if (gKeysState[SDL_SCANCODE_LSHIFT] || gKeysState[SDL_SCANCODE_RSHIFT])
|
||||
RCT2_GLOBAL(0x009DEA70, uint8) |= 1;
|
||||
if (gKeysState[SDL_SCANCODE_LCTRL] || gKeysState[SDL_SCANCODE_RCTRL])
|
||||
RCT2_GLOBAL(0x009DEA70, uint8) |= 2;
|
||||
}
|
||||
|
||||
static void osinterface_close_window()
|
||||
|
||||
@@ -138,7 +138,7 @@ typedef struct rct_window {
|
||||
typedef enum {
|
||||
WE_CLOSE = 0,
|
||||
WE_MOUSE_UP = 1,
|
||||
WE_UNKNOWN_02 = 2, // tab switch?
|
||||
WE_RESIZE = 2,
|
||||
WE_MOUSE_DOWN = 3,
|
||||
WE_DROPDOWN = 4,
|
||||
WE_UNKNOWN_05 = 5,
|
||||
|
||||
@@ -91,11 +91,11 @@ static uint32 window_game_top_toolbar_events[] = {
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
0x0066CB25,
|
||||
0x0066CB73,
|
||||
0x0066CB4E,
|
||||
0x0066CC5B,
|
||||
0x0066CA58,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
window_game_top_toolbar_emptysub,
|
||||
|
||||
@@ -1869,7 +1869,7 @@ static void window_park_set_page(rct_window *w, int page)
|
||||
RCT2_CALLPROC_X(0x00667F8B, 0, 0, 0, 0, w, 0, 0);
|
||||
window_invalidate(w);
|
||||
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_02], 0, 0, 0, 0, w, 0, 0);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0);
|
||||
if (RCT2_GLOBAL(0x009E32E0, uint8) != 0 && w->viewport != NULL)
|
||||
w->viewport->flags |= VIEWPORT_FLAG_SOUND_ON;
|
||||
|
||||
@@ -191,7 +191,7 @@ static void window_scenarioselect_mousedown()
|
||||
w->var_4AC = widgetIndex - 4;
|
||||
w->var_494 = NULL;
|
||||
window_invalidate(w);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_UNKNOWN_02], 0, 0, 0, 0, w, 0, 0);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_RESIZE], 0, 0, 0, 0, w, 0, 0);
|
||||
RCT2_CALLPROC_X(w->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, w, 0, 0);
|
||||
window_init_scroll_widgets(w);
|
||||
window_invalidate(w);
|
||||
|
||||
Reference in New Issue
Block a user