1
0
mirror of synced 2024-12-01 01:37:23 +01:00
FFBArcadePlugin/Common Files/Game.h

98 lines
2.7 KiB
C
Raw Normal View History

2019-04-07 07:16:19 +02:00
#pragma once
#include <Windows.h>
// struct
struct EffectTriggers {
void(*Constant)(int direction, double strength);
void(*Spring)(double strength);
void(*Friction)(double strength);
void(*Sine)(UINT16 period, UINT16 fadePeriod, double strength);
void(*Rumble)(double strength, double length);
void(*LeftRight)(double smallstrength, double largestrength, double length);
void(*LeftRightDevice2)(double smallstrength, double largestrength, double length);
void(*Springi)(double strength);
};
// classes
class EffectCollection {
public:
int effect_id = 0;
int effect_left_id = 0;
int effect_right_id = 0;
int effect_friction_id = 0;
int effect_leftright_id = 0;
int effect_sine_id = 0;
int effect_spring_id = 0;
int effect_vibration_id = 0;
};
class EffectConstants {
public:
// constants
// Haptic forces are defined by the direction that generates the force
// e.g. DIRECTION_FROM_LEFT causes wheel to go right.
const int DIRECTION_FROM_LEFT = -1;
const int DIRECTION_FROM_RIGHT = 1;
};
#define VK_A 0x41
#define VK_B 0x42
#define VK_C 0x43
#define VK_D 0x44
#define VK_E 0x45
#define VK_F 0x46
#define VK_G 0x47
#define VK_H 0x48
#define VK_I 0x49
#define VK_J 0x4A
#define VK_K 0x4B
#define VK_L 0x4C
#define VK_M 0x4D
#define VK_N 0x4E
#define VK_O 0x4F
#define VK_P 0x50
#define VK_Q 0x51
#define VK_R 0x52
#define VK_S 0x53
#define VK_T 0x54
#define VK_U 0x55
#define VK_V 0x56
#define VK_W 0x57
#define VK_X 0x58
#define VK_Y 0x59
#define VK_Z 0x5A
#define SDL_HAT_CENTERED 0x00
#define SDL_HAT_UP 0x01
#define SDL_HAT_RIGHT 0x02
#define SDL_HAT_DOWN 0x04
#define SDL_HAT_LEFT 0x08
#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
class Helpers {
public:
int enableLogging = 0;
// helper functions
bool fileExists(char *filename);
// logging
void log(char *msg);
void logInt(int value);
void logInit(char *msg);
// reading memory
LPVOID GetTranslatedOffset(INT_PTR offset);
int ReadInt32(INT_PTR offset, bool isRelativeOffset);
UINT8 ReadByte(INT_PTR offset, bool isRelativeOffset);
float WriteFloat32(INT_PTR offset, float val, bool isRelativeOffset);
UINT8 WriteByte(INT_PTR offset, UINT8 val, bool isRelativeOffset);
INT_PTR WriteIntPtr(INT_PTR offset, INT_PTR val, bool isRelativeOffset);
UINT8 WriteNop(INT_PTR offset, bool isRelativeOffset);
INT_PTR ReadIntPtr(INT_PTR offset, bool isRelativeOffset);
float ReadFloat32(INT_PTR offset, bool isRelativeOffset);
};
class Game {
public:
virtual void FFBLoop(EffectConstants *constants, Helpers *helpers, EffectTriggers* triggers);
};