mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
Merge keyboard_event_win32.cpp with win32_common.cpp
This commit is contained in:
parent
778ee176cc
commit
46182e090b
@ -1249,7 +1249,6 @@ endif
|
|||||||
|
|
||||||
ifneq ($(findstring Win32,$(OS)),)
|
ifneq ($(findstring Win32,$(OS)),)
|
||||||
OBJ += media/rarch.o \
|
OBJ += media/rarch.o \
|
||||||
input/drivers_keyboard/keyboard_event_win32.o \
|
|
||||||
gfx/common/win32_common.o \
|
gfx/common/win32_common.o \
|
||||||
frontend/drivers/platform_win32.o
|
frontend/drivers/platform_win32.o
|
||||||
|
|
||||||
|
@ -356,6 +356,70 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
|
||||||
|
WPARAM wparam, LPARAM lparam)
|
||||||
|
{
|
||||||
|
unsigned scancode = (lparam >> 16) & 0xff;
|
||||||
|
unsigned keycode = input_keymaps_translate_keysym_to_rk(scancode);
|
||||||
|
uint16_t mod = 0;
|
||||||
|
bool keydown = true;
|
||||||
|
|
||||||
|
if (GetKeyState(VK_SHIFT) & 0x80)
|
||||||
|
mod |= RETROKMOD_SHIFT;
|
||||||
|
if (GetKeyState(VK_CONTROL) & 0x80)
|
||||||
|
mod |= RETROKMOD_CTRL;
|
||||||
|
if (GetKeyState(VK_MENU) & 0x80)
|
||||||
|
mod |= RETROKMOD_ALT;
|
||||||
|
if (GetKeyState(VK_CAPITAL) & 0x81)
|
||||||
|
mod |= RETROKMOD_CAPSLOCK;
|
||||||
|
if (GetKeyState(VK_SCROLL) & 0x81)
|
||||||
|
mod |= RETROKMOD_SCROLLOCK;
|
||||||
|
if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80)
|
||||||
|
mod |= RETROKMOD_META;
|
||||||
|
|
||||||
|
switch (message)
|
||||||
|
{
|
||||||
|
/* Seems to be hard to synchronize
|
||||||
|
* WM_CHAR and WM_KEYDOWN properly.
|
||||||
|
*/
|
||||||
|
case WM_CHAR:
|
||||||
|
input_keyboard_event(keydown, RETROK_UNKNOWN, wparam, mod,
|
||||||
|
RETRO_DEVICE_KEYBOARD);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
/* Key released? */
|
||||||
|
if (message == WM_KEYUP || message == WM_SYSKEYUP)
|
||||||
|
keydown = false;
|
||||||
|
|
||||||
|
/* DirectInput uses scancodes directly. */
|
||||||
|
input_keyboard_event(keydown, keycode, 0, mod,
|
||||||
|
RETRO_DEVICE_KEYBOARD);
|
||||||
|
|
||||||
|
if (message == WM_SYSKEYDOWN)
|
||||||
|
{
|
||||||
|
switch (wparam)
|
||||||
|
{
|
||||||
|
case VK_F10:
|
||||||
|
case VK_MENU:
|
||||||
|
case VK_RSHIFT:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DefWindowProc(hwnd, message, wparam, lparam);
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message,
|
||||||
WPARAM wparam, LPARAM lparam)
|
WPARAM wparam, LPARAM lparam)
|
||||||
{
|
{
|
||||||
|
@ -1,90 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
|
||||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
#include "../../config.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../input_config.h"
|
|
||||||
#include "../input_keymaps.h"
|
|
||||||
#include "../input_keyboard.h"
|
|
||||||
#include "../../retroarch.h"
|
|
||||||
#include "../../gfx/common/win32_common.h"
|
|
||||||
|
|
||||||
LRESULT win32_handle_keyboard_event(HWND hwnd, UINT message,
|
|
||||||
WPARAM wparam, LPARAM lparam)
|
|
||||||
{
|
|
||||||
unsigned scancode = (lparam >> 16) & 0xff;
|
|
||||||
unsigned keycode = input_keymaps_translate_keysym_to_rk(scancode);
|
|
||||||
uint16_t mod = 0;
|
|
||||||
bool keydown = true;
|
|
||||||
|
|
||||||
if (GetKeyState(VK_SHIFT) & 0x80)
|
|
||||||
mod |= RETROKMOD_SHIFT;
|
|
||||||
if (GetKeyState(VK_CONTROL) & 0x80)
|
|
||||||
mod |= RETROKMOD_CTRL;
|
|
||||||
if (GetKeyState(VK_MENU) & 0x80)
|
|
||||||
mod |= RETROKMOD_ALT;
|
|
||||||
if (GetKeyState(VK_CAPITAL) & 0x81)
|
|
||||||
mod |= RETROKMOD_CAPSLOCK;
|
|
||||||
if (GetKeyState(VK_SCROLL) & 0x81)
|
|
||||||
mod |= RETROKMOD_SCROLLOCK;
|
|
||||||
if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80)
|
|
||||||
mod |= RETROKMOD_META;
|
|
||||||
|
|
||||||
switch (message)
|
|
||||||
{
|
|
||||||
/* Seems to be hard to synchronize
|
|
||||||
* WM_CHAR and WM_KEYDOWN properly.
|
|
||||||
*/
|
|
||||||
case WM_CHAR:
|
|
||||||
input_keyboard_event(keydown, RETROK_UNKNOWN, wparam, mod,
|
|
||||||
RETRO_DEVICE_KEYBOARD);
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_KEYUP:
|
|
||||||
case WM_SYSKEYUP:
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
/* Key released? */
|
|
||||||
if (message == WM_KEYUP || message == WM_SYSKEYUP)
|
|
||||||
keydown = false;
|
|
||||||
|
|
||||||
/* DirectInput uses scancodes directly. */
|
|
||||||
input_keyboard_event(keydown, keycode, 0, mod,
|
|
||||||
RETRO_DEVICE_KEYBOARD);
|
|
||||||
|
|
||||||
if (message == WM_SYSKEYDOWN)
|
|
||||||
{
|
|
||||||
switch (wparam)
|
|
||||||
{
|
|
||||||
case VK_F10:
|
|
||||||
case VK_MENU:
|
|
||||||
case VK_RSHIFT:
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProc(hwnd, message, wparam, lparam);
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user