Extract input

This commit is contained in:
Alexander Batalov 2022-10-05 09:23:27 +03:00
parent cce1bb223e
commit 1c73fb7240
46 changed files with 1325 additions and 1247 deletions

View File

@ -119,6 +119,8 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/grayscale.h" "src/grayscale.h"
"src/heap.cc" "src/heap.cc"
"src/heap.h" "src/heap.h"
"src/input.cc"
"src/input.h"
"src/interface.cc" "src/interface.cc"
"src/interface.h" "src/interface.h"
"src/interpreter_extra.cc" "src/interpreter_extra.cc"

View File

@ -16,6 +16,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -17,6 +17,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "graph_lib.h" #include "graph_lib.h"
#include "input.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"
#include "map.h" #include "map.h"

View File

@ -22,6 +22,7 @@
#include "game_palette.h" #include "game_palette.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -17,6 +17,7 @@
#include "game.h" #include "game.h"
#include "game_config.h" #include "game_config.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "memory.h" #include "memory.h"
#include "message.h" #include "message.h"

View File

@ -20,6 +20,7 @@
#include "game_config.h" #include "game_config.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -16,6 +16,7 @@
#include "game.h" #include "game.h"
#include "game_config.h" #include "game_config.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "light.h" #include "light.h"

File diff suppressed because it is too large Load Diff

View File

@ -4,67 +4,15 @@
#include <SDL.h> #include <SDL.h>
#include "db.h" #include "db.h"
#include "dinput.h"
#include "geometry.h" #include "geometry.h"
#include "window.h" #include "window.h"
namespace fallout { namespace fallout {
typedef struct STRUCT_6ABF50 {
// Time when appropriate key was pressed down or -1 if it's up.
int tick;
int repeatCount;
} STRUCT_6ABF50;
typedef struct InputEvent {
// This is either logical key or input event id, which can be either
// character code pressed or some other numbers used throughout the
// game interface.
int logicalKey;
int mouseX;
int mouseY;
} InputEvent;
typedef void(IdleFunc)();
typedef void(FocusFunc)(bool focus);
typedef void(TickerProc)();
typedef struct TickerListNode {
int flags;
TickerProc* proc;
struct TickerListNode* next;
} TickerListNode;
typedef int(PauseHandler)();
typedef int(ScreenshotHandler)(int width, int height, unsigned char* buffer, unsigned char* palette);
extern IdleFunc* _idle_func;
extern FocusFunc* _focus_func;
extern int gKeyboardKeyRepeatRate;
extern int gKeyboardKeyRepeatDelay;
extern bool _keyboard_hooked;
extern void (*_update_palette_func)(); extern void (*_update_palette_func)();
extern bool gMmxEnabled; extern bool gMmxEnabled;
extern bool gMmxProbed; extern bool gMmxProbed;
extern int gNormalizedQwertyKeys[SDL_NUM_SCANCODES];
extern InputEvent gInputEventQueue[40];
extern STRUCT_6ABF50 _GNW95_key_time_stamps[SDL_NUM_SCANCODES];
extern int _input_mx;
extern int _input_my;
extern bool gPaused;
extern int gScreenshotKeyCode;
extern int _using_msec_timer;
extern int gPauseKeyCode;
extern ScreenshotHandler* gScreenshotHandler;
extern int gInputEventQueueReadIndex;
extern unsigned char* gScreenshotBuffer;
extern PauseHandler* gPauseHandler;
extern int gInputEventQueueWriteIndex;
extern bool gRunLoopDisabled;
extern TickerListNode* gTickerListHead;
extern unsigned int gTickerLastTimestamp;
extern unsigned short gSixteenBppPalette[256]; extern unsigned short gSixteenBppPalette[256];
extern Rect _scr_size; extern Rect _scr_size;
extern int gRedMask; extern int gRedMask;
@ -84,45 +32,6 @@ extern SDL_Renderer* gSdlRenderer;
extern SDL_Texture* gSdlTexture; extern SDL_Texture* gSdlTexture;
extern SDL_Surface* gSdlTextureSurface; extern SDL_Surface* gSdlTextureSurface;
int coreInit(int a1);
void coreExit();
int _get_input();
void _process_bk();
void enqueueInputEvent(int a1);
int dequeueInputEvent();
void inputEventQueueReset();
void tickersExecute();
void tickersAdd(TickerProc* fn);
void tickersRemove(TickerProc* fn);
void tickersEnable();
void tickersDisable();
void pauseGame();
int pauseHandlerDefaultImpl();
void pauseHandlerConfigure(int keyCode, PauseHandler* fn);
void takeScreenshot();
void screenshotBlitter(unsigned char* src, int src_pitch, int a3, int x, int y, int width, int height, int dest_x, int dest_y);
int screenshotHandlerDefaultImpl(int width, int height, unsigned char* data, unsigned char* palette);
void screenshotHandlerConfigure(int keyCode, ScreenshotHandler* handler);
unsigned int _get_time();
void coreDelayProcessingEvents(unsigned int ms);
void coreDelay(unsigned int ms);
unsigned int getTicksSince(unsigned int a1);
unsigned int getTicksBetween(unsigned int a1, unsigned int a2);
unsigned int _get_bk_time();
void inputSetKeyboardKeyRepeatRate(int value);
int inputGetKeyboardKeyRepeatRate();
void inputSetKeyboardKeyRepeatDelay(int value);
int inputGetKeyboardKeyRepeatDelay();
void inputSetFocusFunc(FocusFunc* func);
FocusFunc* inputGetFocusFunc();
void inputSetIdleFunc(IdleFunc* func);
IdleFunc* inputGetIdleFunc();
void buildNormalizedQwertyKeys();
int _GNW95_input_init();
void _GNW95_process_message();
void _GNW95_clear_time_stamps();
void _GNW95_process_key(KeyboardData* data);
void _GNW95_lost_focus();
void mmxSetEnabled(bool a1); void mmxSetEnabled(bool a1);
int _init_mode_320_200(); int _init_mode_320_200();
int _init_mode_320_400(); int _init_mode_320_400();
@ -152,6 +61,7 @@ void _GNW95_zero_vid_mem();
int screenGetWidth(); int screenGetWidth();
int screenGetHeight(); int screenGetHeight();
int screenGetVisibleHeight(); int screenGetVisibleHeight();
void handleWindowSizeChanged();
} // namespace fallout } // namespace fallout

View File

@ -10,6 +10,7 @@
#include "debug.h" #include "debug.h"
#include "draw.h" #include "draw.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "message.h" #include "message.h"
#include "mouse.h" #include "mouse.h"

View File

@ -3,6 +3,7 @@
#include "color.h" #include "color.h"
#include "core.h" #include "core.h"
#include "game_config.h" #include "game_config.h"
#include "input.h"
#include "palette.h" #include "palette.h"
namespace fallout { namespace fallout {

View File

@ -13,6 +13,7 @@
#include "draw.h" #include "draw.h"
#include "game.h" #include "game.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "message.h" #include "message.h"
#include "mouse.h" #include "mouse.h"

View File

@ -12,6 +12,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "memory.h" #include "memory.h"
#include "sfall_config.h" #include "sfall_config.h"

View File

@ -13,6 +13,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "kb.h" #include "kb.h"
#include "map.h" #include "map.h"

View File

@ -20,6 +20,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "map.h" #include "map.h"
#include "memory.h" #include "memory.h"
#include "mouse.h" #include "mouse.h"

View File

@ -35,6 +35,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "inventory.h" #include "inventory.h"
#include "item.h" #include "item.h"

View File

@ -20,6 +20,7 @@
#include "game.h" #include "game.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -15,6 +15,7 @@
#include "game.h" #include "game.h"
#include "game_config.h" #include "game_config.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -11,6 +11,7 @@
#include "game_config.h" #include "game_config.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "mouse.h" #include "mouse.h"
#include "movie.h" #include "movie.h"
#include "movie_effect.h" #include "movie_effect.h"

View File

@ -10,6 +10,7 @@
#include "core.h" #include "core.h"
#include "debug.h" #include "debug.h"
#include "game_config.h" #include "game_config.h"
#include "input.h"
#include "item.h" #include "item.h"
#include "map.h" #include "map.h"
#include "memory.h" #include "memory.h"

1174
src/input.cc Normal file

File diff suppressed because it is too large Load Diff

101
src/input.h Normal file
View File

@ -0,0 +1,101 @@
#ifndef FALLOUT_INPUT_H_
#define FALLOUT_INPUT_H_
#include "dinput.h"
namespace fallout {
typedef struct STRUCT_6ABF50 {
// Time when appropriate key was pressed down or -1 if it's up.
int tick;
int repeatCount;
} STRUCT_6ABF50;
typedef struct InputEvent {
// This is either logical key or input event id, which can be either
// character code pressed or some other numbers used throughout the
// game interface.
int logicalKey;
int mouseX;
int mouseY;
} InputEvent;
typedef void(IdleFunc)();
typedef void(FocusFunc)(bool focus);
typedef void(TickerProc)();
typedef struct TickerListNode {
int flags;
TickerProc* proc;
struct TickerListNode* next;
} TickerListNode;
typedef int(PauseHandler)();
typedef int(ScreenshotHandler)(int width, int height, unsigned char* buffer, unsigned char* palette);
extern IdleFunc* _idle_func;
extern FocusFunc* _focus_func;
extern int gKeyboardKeyRepeatRate;
extern int gKeyboardKeyRepeatDelay;
extern bool _keyboard_hooked;
extern int gNormalizedQwertyKeys[SDL_NUM_SCANCODES];
extern InputEvent gInputEventQueue[40];
extern STRUCT_6ABF50 _GNW95_key_time_stamps[SDL_NUM_SCANCODES];
extern int _input_mx;
extern int _input_my;
extern bool gPaused;
extern int gScreenshotKeyCode;
extern int _using_msec_timer;
extern int gPauseKeyCode;
extern ScreenshotHandler* gScreenshotHandler;
extern int gInputEventQueueReadIndex;
extern unsigned char* gScreenshotBuffer;
extern PauseHandler* gPauseHandler;
extern int gInputEventQueueWriteIndex;
extern bool gRunLoopDisabled;
extern TickerListNode* gTickerListHead;
extern unsigned int gTickerLastTimestamp;
int coreInit(int a1);
void coreExit();
int _get_input();
void _process_bk();
void enqueueInputEvent(int a1);
int dequeueInputEvent();
void inputEventQueueReset();
void tickersExecute();
void tickersAdd(TickerProc* fn);
void tickersRemove(TickerProc* fn);
void tickersEnable();
void tickersDisable();
void pauseGame();
int pauseHandlerDefaultImpl();
void pauseHandlerConfigure(int keyCode, PauseHandler* fn);
void takeScreenshot();
void screenshotBlitter(unsigned char* src, int src_pitch, int a3, int x, int y, int width, int height, int dest_x, int dest_y);
int screenshotHandlerDefaultImpl(int width, int height, unsigned char* data, unsigned char* palette);
void screenshotHandlerConfigure(int keyCode, ScreenshotHandler* handler);
unsigned int _get_time();
void coreDelayProcessingEvents(unsigned int ms);
void coreDelay(unsigned int ms);
unsigned int getTicksSince(unsigned int a1);
unsigned int getTicksBetween(unsigned int a1, unsigned int a2);
unsigned int _get_bk_time();
void inputSetKeyboardKeyRepeatRate(int value);
int inputGetKeyboardKeyRepeatRate();
void inputSetKeyboardKeyRepeatDelay(int value);
int inputGetKeyboardKeyRepeatDelay();
void inputSetFocusFunc(FocusFunc* func);
FocusFunc* inputGetFocusFunc();
void inputSetIdleFunc(IdleFunc* func);
IdleFunc* inputGetIdleFunc();
void buildNormalizedQwertyKeys();
int _GNW95_input_init();
void _GNW95_process_message();
void _GNW95_clear_time_stamps();
void _GNW95_process_key(KeyboardData* data);
void _GNW95_lost_focus();
} // namespace fallout
#endif /* FALLOUT_INPUT_H_ */

View File

@ -20,6 +20,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"
#include "memory.h" #include "memory.h"

View File

@ -11,6 +11,7 @@
#include "db.h" #include "db.h"
#include "debug.h" #include "debug.h"
#include "export.h" #include "export.h"
#include "input.h"
#include "interpreter_lib.h" #include "interpreter_lib.h"
#include "memory_manager.h" #include "memory_manager.h"
#include "platform_compat.h" #include "platform_compat.h"

View File

@ -5,6 +5,7 @@
#include "datafile.h" #include "datafile.h"
#include "debug.h" #include "debug.h"
#include "dialog.h" #include "dialog.h"
#include "input.h"
#include "interpreter_extra.h" #include "interpreter_extra.h"
#include "memory_manager.h" #include "memory_manager.h"
#include "mouse_manager.h" #include "mouse_manager.h"

View File

@ -23,6 +23,7 @@
#include "game_dialog.h" #include "game_dialog.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -3,6 +3,7 @@
#include <string.h> #include <string.h>
#include "core.h" #include "core.h"
#include "input.h"
#include "vcr.h" #include "vcr.h"
namespace fallout { namespace fallout {

View File

@ -8,6 +8,7 @@
#include "db.h" #include "db.h"
#include "debug.h" #include "debug.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "platform_compat.h" #include "platform_compat.h"
#include "sound.h" #include "sound.h"

View File

@ -28,6 +28,7 @@
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"

View File

@ -21,6 +21,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "loadsave.h" #include "loadsave.h"
#include "map.h" #include "map.h"

View File

@ -22,6 +22,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "light.h" #include "light.h"

View File

@ -3,6 +3,7 @@
#include "color.h" #include "color.h"
#include "core.h" #include "core.h"
#include "dinput.h" #include "dinput.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "kb.h" #include "kb.h"
#include "vcr.h" #include "vcr.h"

View File

@ -6,6 +6,7 @@
#include "datafile.h" #include "datafile.h"
#include "db.h" #include "db.h"
#include "debug.h" #include "debug.h"
#include "input.h"
#include "memory_manager.h" #include "memory_manager.h"
#include "mouse.h" #include "mouse.h"
#include "platform_compat.h" #include "platform_compat.h"

View File

@ -11,6 +11,7 @@
#include "draw.h" #include "draw.h"
#include "game_config.h" #include "game_config.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "memory_manager.h" #include "memory_manager.h"
#include "movie_effect.h" #include "movie_effect.h"
#include "movie_lib.h" #include "movie_lib.h"

View File

@ -20,6 +20,7 @@
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "grayscale.h" #include "grayscale.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "loadsave.h" #include "loadsave.h"
#include "memory.h" #include "memory.h"

View File

@ -7,6 +7,7 @@
#include "cycle.h" #include "cycle.h"
#include "debug.h" #include "debug.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
namespace fallout { namespace fallout {

View File

@ -21,6 +21,7 @@
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "kb.h" #include "kb.h"
#include "map.h" #include "map.h"

View File

@ -21,6 +21,7 @@
#include "game_dialog.h" #include "game_dialog.h"
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "message.h" #include "message.h"
#include "object.h" #include "object.h"

View File

@ -6,6 +6,7 @@
#include "db.h" #include "db.h"
#include "game.h" #include "game.h"
#include "game_config.h" #include "game_config.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "mouse.h" #include "mouse.h"
#include "platform_compat.h" #include "platform_compat.h"

View File

@ -13,6 +13,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "kb.h" #include "kb.h"
#include "map.h" #include "map.h"

View File

@ -6,6 +6,7 @@
#include "debug.h" #include "debug.h"
#include "draw.h" #include "draw.h"
#include "game_config.h" #include "game_config.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "object.h" #include "object.h"
#include "text_font.h" #include "text_font.h"

View File

@ -3,6 +3,7 @@
#include <stdlib.h> #include <stdlib.h>
#include "core.h" #include "core.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "memory.h" #include "memory.h"
#include "mouse.h" #include "mouse.h"

View File

@ -9,6 +9,7 @@
#include "datafile.h" #include "datafile.h"
#include "draw.h" #include "draw.h"
#include "game.h" #include "game.h"
#include "input.h"
#include "interpreter_lib.h" #include "interpreter_lib.h"
#include "kb.h" #include "kb.h"
#include "memory_manager.h" #include "memory_manager.h"

View File

@ -10,6 +10,7 @@
#include "core.h" #include "core.h"
#include "debug.h" #include "debug.h"
#include "draw.h" #include "draw.h"
#include "input.h"
#include "memory.h" #include "memory.h"
#include "mouse.h" #include "mouse.h"
#include "palette.h" #include "palette.h"

View File

@ -8,6 +8,7 @@
#include "color.h" #include "color.h"
#include "core.h" #include "core.h"
#include "draw.h" #include "draw.h"
#include "input.h"
#include "kb.h" #include "kb.h"
#include "memory.h" #include "memory.h"
#include "mouse.h" #include "mouse.h"

View File

@ -25,6 +25,7 @@
#include "game_mouse.h" #include "game_mouse.h"
#include "game_movie.h" #include "game_movie.h"
#include "game_sound.h" #include "game_sound.h"
#include "input.h"
#include "interface.h" #include "interface.h"
#include "item.h" #include "item.h"
#include "kb.h" #include "kb.h"