Merge branch 'master' into jgrpp
# Conflicts: # src/autoreplace_gui.cpp # src/build_vehicle_gui.cpp # src/cheat_gui.cpp # src/company_gui.cpp # src/debug.cpp # src/engine_gui.h # src/error_gui.cpp # src/group_gui.cpp # src/industry_cmd.cpp # src/industry_gui.cpp # src/misc_gui.cpp # src/network/network_gui.cpp # src/newgrf.cpp # src/newgrf_debug_gui.cpp # src/newgrf_gui.cpp # src/order_gui.cpp # src/rail_gui.cpp # src/road_gui.cpp # src/saveload/saveload.cpp # src/screenshot_gui.cpp # src/sound/win32_s.cpp # src/statusbar_gui.cpp # src/strgen/strgen.cpp # src/table/newgrf_debug_data.h # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_gui.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/viewport.cpp
This commit is contained in:
@@ -250,8 +250,8 @@ struct AllegroVkMapping {
|
||||
uint8_t map_to;
|
||||
};
|
||||
|
||||
#define AS(x, z) {x, 0, z}
|
||||
#define AM(x, y, z, w) {x, y - x, z}
|
||||
#define AS(x, z) {x, 1, z}
|
||||
#define AM(x, y, z, w) {x, y - x + 1, z}
|
||||
|
||||
static const AllegroVkMapping _vk_mapping[] = {
|
||||
/* Pageup stuff + up/down */
|
||||
@@ -311,12 +311,11 @@ static uint32_t ConvertAllegroKeyIntoMy(char32_t *character)
|
||||
int scancode;
|
||||
int unicode = ureadkey(&scancode);
|
||||
|
||||
const AllegroVkMapping *map;
|
||||
uint key = 0;
|
||||
|
||||
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
|
||||
if ((uint)(scancode - map->vk_from) <= map->vk_count) {
|
||||
key = scancode - map->vk_from + map->map_to;
|
||||
for (const auto &map : _vk_mapping) {
|
||||
if (IsInsideBS(scancode, map.vk_from, map.vk_count)) {
|
||||
key = scancode - map.vk_from + map.map_to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ struct SDLVkMapping {
|
||||
const bool unprintable;
|
||||
|
||||
constexpr SDLVkMapping(SDL_Keycode vk_first, SDL_Keycode vk_last, uint8_t map_first, [[maybe_unused]] uint8_t map_last, bool unprintable)
|
||||
: vk_from(vk_first), vk_count(vk_last - vk_first), map_to(map_first), unprintable(unprintable)
|
||||
: vk_from(vk_first), vk_count(vk_last - vk_first + 1), map_to(map_first), unprintable(unprintable)
|
||||
{
|
||||
assert((vk_last - vk_first) == (map_last - map_first));
|
||||
}
|
||||
@@ -600,14 +600,13 @@ static constexpr SDLVkMapping _vk_mapping[] = {
|
||||
|
||||
static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, char32_t *character)
|
||||
{
|
||||
const SDLVkMapping *map;
|
||||
uint key = 0;
|
||||
bool unprintable = false;
|
||||
|
||||
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
|
||||
if ((uint)(sym->sym - map->vk_from) <= map->vk_count) {
|
||||
key = sym->sym - map->vk_from + map->map_to;
|
||||
unprintable = map->unprintable;
|
||||
for (const auto &map : _vk_mapping) {
|
||||
if (IsInsideBS(sym->sym, map.vk_from, map.vk_count)) {
|
||||
key = sym->sym - map.vk_from + map.map_to;
|
||||
unprintable = map.unprintable;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -640,12 +639,11 @@ static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, char32_t *character)
|
||||
*/
|
||||
static uint ConvertSdlKeycodeIntoMy(SDL_Keycode kc)
|
||||
{
|
||||
const SDLVkMapping *map;
|
||||
uint key = 0;
|
||||
|
||||
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
|
||||
if ((uint)(kc - map->vk_from) <= map->vk_count) {
|
||||
key = kc - map->vk_from + map->map_to;
|
||||
for (const auto &map : _vk_mapping) {
|
||||
if (IsInsideBS(kc, map.vk_from, map.vk_count)) {
|
||||
key = kc - map.vk_from + map.map_to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ struct SDLVkMapping {
|
||||
const uint8_t map_to;
|
||||
|
||||
constexpr SDLVkMapping(SDL_Keycode vk_first, SDL_Keycode vk_last, uint8_t map_first, [[maybe_unused]] uint8_t map_last)
|
||||
: vk_from(vk_first), vk_count(vk_last - vk_first), map_to(map_first)
|
||||
: vk_from(vk_first), vk_count(vk_last - vk_first + 1), map_to(map_first)
|
||||
{
|
||||
assert((vk_last - vk_first) == (map_last - map_first));
|
||||
}
|
||||
@@ -447,12 +447,11 @@ static constexpr SDLVkMapping _vk_mapping[] = {
|
||||
|
||||
static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, char32_t *character)
|
||||
{
|
||||
const SDLVkMapping *map;
|
||||
uint key = 0;
|
||||
|
||||
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
|
||||
if ((uint)(sym->sym - map->vk_from) <= map->vk_count) {
|
||||
key = sym->sym - map->vk_from + map->map_to;
|
||||
for (const auto &map : _vk_mapping) {
|
||||
if (IsInsideBS(sym->sym, map.vk_from, map.vk_count)) {
|
||||
key = sym->sym - map.vk_from + map.map_to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,8 +62,8 @@ struct Win32VkMapping {
|
||||
uint8_t map_to;
|
||||
};
|
||||
|
||||
#define AS(x, z) {x, 0, z}
|
||||
#define AM(x, y, z, w) {x, y - x, z}
|
||||
#define AS(x, z) {x, 1, z}
|
||||
#define AM(x, y, z, w) {x, y - x + 1, z}
|
||||
|
||||
static const Win32VkMapping _vk_mapping[] = {
|
||||
/* Pageup stuff + up/down */
|
||||
@@ -108,12 +108,11 @@ static const Win32VkMapping _vk_mapping[] = {
|
||||
|
||||
static uint MapWindowsKey(uint sym)
|
||||
{
|
||||
const Win32VkMapping *map;
|
||||
uint key = 0;
|
||||
|
||||
for (map = _vk_mapping; map != endof(_vk_mapping); ++map) {
|
||||
if ((uint)(sym - map->vk_from) <= map->vk_count) {
|
||||
key = sym - map->vk_from + map->map_to;
|
||||
for (const auto &map : _vk_mapping) {
|
||||
if (IsInsideBS(sym, map.vk_from, map.vk_count)) {
|
||||
key = sym - map.vk_from + map.map_to;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user