Skip to content

Commit

Permalink
Merge pull request #61 from rzumer/applewin-input
Browse files Browse the repository at this point in the history
Update RAppleWin
  • Loading branch information
Jamiras authored Jul 17, 2019
2 parents 1acf5b2 + c293b52 commit 611cd6e
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 19 deletions.
2 changes: 1 addition & 1 deletion RA_Integration
Submodule RA_Integration updated 243 files
6 changes: 4 additions & 2 deletions RAppleWin/source/Applewin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,9 +1766,11 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
bSetFullScreen = g_bRestartFullScreen;
g_bRestartFullScreen = false;
}

#if USE_RETROACHIEVEMENTS
RA_Shutdown();
else
{
RA_Shutdown();
}
#endif

MB_Reset();
Expand Down
2 changes: 1 addition & 1 deletion RAppleWin/source/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static FULLSCREEN_SCALE_TYPE g_win_fullscreen_scale = 1;
static int g_win_fullscreen_offsetx = 0;
static int g_win_fullscreen_offsety = 0;

static bool g_bFrameActive = false;
bool g_bFrameActive = false;

// __ Prototypes __________________________________________________________________________________
void DrawCrosshairs (int x, int y);
Expand Down
1 change: 1 addition & 0 deletions RAppleWin/source/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
extern int g_nViewportCY;
extern BOOL g_bConfirmReboot; // saved PageConfig REGSAVE
extern BOOL g_bMultiMon;
extern bool g_bFrameActive;


// Emulator
Expand Down
50 changes: 35 additions & 15 deletions RAppleWin/source/RetroAchievements.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if USE_RETROACHIEVEMENTS

#include <assert.h>
#include <windows.h>

#include "RetroAchievements.h"
Expand Down Expand Up @@ -48,23 +49,27 @@ void free_file_info(FileInfo *file)

unsigned char MainRAMReader(size_t nOffs)
{
return *MemGetMainPtr(nOffs);
assert(nOffs <= 0xFFFF);
return *MemGetMainPtr((WORD)nOffs);
}

void MainRAMWriter(size_t nOffs, unsigned char nVal)
{
*MemGetMainPtr(nOffs) = nVal;
assert(nOffs <= 0xFFFF);
*MemGetMainPtr((WORD)nOffs) = nVal;
}

#if RA_ENABLE_AUXRAM
unsigned char AuxRAMReader(size_t nOffs)
{
return *MemGetAuxPtr(nOffs);
assert(nOffs <= 0xFFFF);
return *MemGetAuxPtr((WORD)nOffs);
}

void AuxRAMWriter(size_t nOffs, unsigned char nVal)
{
*MemGetAuxPtr(nOffs) = nVal;
assert(nOffs <= 0xFFFF);
*MemGetAuxPtr((WORD)nOffs) = nVal;
}
#endif

Expand Down Expand Up @@ -161,9 +166,17 @@ void RA_InitShared()

void RA_InitSystem()
{
RA_Init(g_hFrameWindow, RA_AppleWin, RAPPLEWIN_VERSION);
RA_InitShared();
RA_AttemptLogin(true);
if (is_initialized)
{
RA_UpdateHWnd(g_hFrameWindow);
}
else
{
RA_Init(g_hFrameWindow, RA_AppleWin, RAPPLEWIN_VERSION);
RA_InitShared();
RA_AttemptLogin(true);
is_initialized = true;
}

confirmed_quitting = false;
}
Expand Down Expand Up @@ -217,6 +230,9 @@ int RA_PrepareLoadNewRom(const char *file_name, FileType file_type)
loading_file.data_len = file_size;

BYTE * const file_data = (BYTE *)malloc(file_size * sizeof(BYTE));
if (!file_data)
return FALSE;

loading_file.data = file_data;
fseek(f, 0, SEEK_SET);
fread(file_data, sizeof(BYTE), file_size, f);
Expand Down Expand Up @@ -392,14 +408,18 @@ void RA_RenderOverlayFrame(HDC hdc)
int width = GetFrameBufferBorderlessWidth(), height = GetFrameBufferBorderlessHeight();
RECT window_size = { 0, 0, width, height };

ControllerInput input;
input.m_bConfirmPressed = GetKeyState(VK_RETURN) & WM_KEYDOWN;
input.m_bCancelPressed = GetKeyState(VK_BACK) & WM_KEYDOWN;
input.m_bQuitPressed = GetKeyState(VK_ESCAPE) & WM_KEYDOWN;
input.m_bLeftPressed = GetKeyState(VK_LEFT) & WM_KEYDOWN;
input.m_bRightPressed = GetKeyState(VK_RIGHT) & WM_KEYDOWN;
input.m_bUpPressed = GetKeyState(VK_UP) & WM_KEYDOWN;
input.m_bDownPressed = GetKeyState(VK_DOWN) & WM_KEYDOWN;
ControllerInput input = {};

if (g_bFrameActive) // Do not process input while out of focus
{
input.m_bConfirmPressed = GetKeyState(VK_RETURN) & WM_KEYDOWN;
input.m_bCancelPressed = GetKeyState(VK_BACK) & WM_KEYDOWN;
input.m_bQuitPressed = GetKeyState(VK_ESCAPE) & WM_KEYDOWN;
input.m_bLeftPressed = GetKeyState(VK_LEFT) & WM_KEYDOWN;
input.m_bRightPressed = GetKeyState(VK_RIGHT) & WM_KEYDOWN;
input.m_bUpPressed = GetKeyState(VK_UP) & WM_KEYDOWN;
input.m_bDownPressed = GetKeyState(VK_DOWN) & WM_KEYDOWN;
}

RA_UpdateRenderOverlay(hdc, &input, delta_time, &window_size, IsFullScreen(), g_nAppMode == MODE_PAUSED);

Expand Down

0 comments on commit 611cd6e

Please sign in to comment.