fallout2-ce/src/dinput.cc

103 lines
1.4 KiB
C++

#include "dinput.h"
#include <SDL.h>
// 0x4E0400
bool directInputInit()
{
if (SDL_InitSubSystem(SDL_INIT_EVENTS) != 0) {
return false;
}
if (!mouseDeviceInit()) {
goto err;
}
if (!keyboardDeviceInit()) {
goto err;
}
return true;
err:
directInputFree();
return false;
}
// 0x4E0478
void directInputFree()
{
SDL_QuitSubSystem(SDL_INIT_EVENTS);
}
// 0x4E04E8
bool mouseDeviceAcquire()
{
return true;
}
// 0x4E0514
bool mouseDeviceUnacquire()
{
return true;
}
// 0x4E053C
bool mouseDeviceGetData(MouseData* mouseState)
{
Uint32 buttons = SDL_GetRelativeMouseState(&(mouseState->x), &(mouseState->y));
mouseState->buttons[0] = (buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0;
mouseState->buttons[1] = (buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;
return true;
}
// 0x4E05A8
bool keyboardDeviceAcquire()
{
return true;
}
// 0x4E05D4
bool keyboardDeviceUnacquire()
{
return true;
}
// 0x4E05FC
bool keyboardDeviceReset()
{
SDL_FlushEvents(SDL_KEYDOWN, SDL_TEXTINPUT);
return true;
}
// 0x4E0650
bool keyboardDeviceGetData(KeyboardData* keyboardData)
{
return true;
}
// 0x4E070C
bool mouseDeviceInit()
{
return SDL_SetRelativeMouseMode(SDL_TRUE) == 0;
}
// 0x4E078C
void mouseDeviceFree()
{
}
// 0x4E07B8
bool keyboardDeviceInit()
{
return true;
}
// 0x4E0874
void keyboardDeviceFree()
{
}