Skip to content

Commit

Permalink
switch-next: Make it build with USE_SDL1
Browse files Browse the repository at this point in the history
  • Loading branch information
glebm authored and AJenbo committed Sep 30, 2019
1 parent 1803973 commit 0e7070a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SourceX/DiabloUI/diabloui.cpp
Expand Up @@ -223,6 +223,7 @@ bool UiFocusNavigation(SDL_Event *event)
{
if (event->type == SDL_QUIT)
exit(0);
#ifndef USE_SDL1
if (event->type == SDL_CONTROLLERBUTTONDOWN) {
if (event->cbutton.which == 0) {
switch (event->cbutton.button) {
Expand All @@ -244,6 +245,7 @@ bool UiFocusNavigation(SDL_Event *event)
}
}
}
#endif

switch (event->type) {
case SDL_KEYUP:
Expand Down
2 changes: 2 additions & 0 deletions SourceX/DiabloUI/title.cpp
Expand Up @@ -35,7 +35,9 @@ BOOL UiTitleDialog(int a1)

while (SDL_PollEvent(&event)) {
switch (event.type) {
#ifndef USE_SDL1
case SDL_CONTROLLERBUTTONDOWN:
#endif
case SDL_KEYDOWN: /* To match the original uncomment this
if (event.key.keysym.sym == SDLK_UP
|| event.key.keysym.sym == SDLK_UP
Expand Down
2 changes: 2 additions & 0 deletions SourceX/miniwin/misc.cpp
Expand Up @@ -173,9 +173,11 @@ HWND CreateWindowExA(
if (SDL_JoystickOpen(0) == NULL) {
SDL_Log(SDL_GetError());
}
#ifndef USE_SDL1
if (SDL_GameControllerOpen(0) == NULL) {
SDL_Log(SDL_GetError());
}
#endif

int upscale = 1;
DvlIntSetting("upscale", &upscale);
Expand Down
10 changes: 10 additions & 0 deletions SourceX/miniwin/misc_msg.cpp
Expand Up @@ -207,6 +207,7 @@ static int translate_sdl_key(SDL_Keysym key)
}
}

#ifndef USE_SDL1
static int translate_controller_button_to_key(uint8_t sdlControllerButton)
{
switch (sdlControllerButton) {
Expand Down Expand Up @@ -240,6 +241,7 @@ static int translate_controller_button_to_key(uint8_t sdlControllerButton)
return 0;
}
}
#endif


static WPARAM keystate_for_mouse(WPARAM ret)
Expand All @@ -260,7 +262,9 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
// update joystick, touch mouse (and docking the Switch) at maximally 60 fps
currentTime = SDL_GetTicks();
if ((currentTime - lastTime) > 15) {
#ifndef USE_SDL1
finish_simulated_mouse_clicks(MouseX, MouseY);
#endif
HandleJoystickAxes();
#ifdef SWITCH
HandleDocking();
Expand Down Expand Up @@ -300,10 +304,13 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
lpMsg->lParam = 0;
lpMsg->wParam = 0;

#ifndef USE_SDL1
handle_touch(&e, MouseX, MouseY);
#endif
if (movie_playing) {
// allow plus button or mouse click to skip movie, no other input
switch (e.type) {
#ifndef USE_SDL1
case SDL_CONTROLLERBUTTONDOWN:
case SDL_CONTROLLERBUTTONUP:
switch(e.cbutton.button) {
Expand All @@ -318,6 +325,7 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
break;
}
break;
#endif
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
if (e.button.button == SDL_BUTTON_LEFT) {
Expand All @@ -342,6 +350,7 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
return true;
}
switch (e.type) {
#ifndef USE_SDL1
case SDL_CONTROLLERAXISMOTION:
switch (e.caxis.axis) {
case SDL_CONTROLLER_AXIS_LEFTX:
Expand Down Expand Up @@ -436,6 +445,7 @@ WINBOOL PeekMessageA(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilter
break;
}
break;
#endif
#ifdef SWITCH
// additional digital buttons that only exist on Switch:
case SDL_JOYBUTTONDOWN:
Expand Down

0 comments on commit 0e7070a

Please sign in to comment.