les tecles de funcio ja no arriben a jinput
This commit is contained in:
@@ -14,7 +14,9 @@ namespace GlobalInputs {
|
|||||||
static bool inc_zoom_was_pressed = false;
|
static bool inc_zoom_was_pressed = false;
|
||||||
static bool fullscreen_was_pressed = false;
|
static bool fullscreen_was_pressed = false;
|
||||||
|
|
||||||
void handle() {
|
auto handle() -> bool {
|
||||||
|
bool consumed = false;
|
||||||
|
|
||||||
// Decrement zoom
|
// Decrement zoom
|
||||||
bool dec_zoom = JI_KeyPressed(Options::keys_gui.dec_zoom);
|
bool dec_zoom = JI_KeyPressed(Options::keys_gui.dec_zoom);
|
||||||
if (dec_zoom && !dec_zoom_was_pressed) {
|
if (dec_zoom && !dec_zoom_was_pressed) {
|
||||||
@@ -22,7 +24,9 @@ namespace GlobalInputs {
|
|||||||
char msg[32];
|
char msg[32];
|
||||||
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
||||||
Overlay::showNotification(msg);
|
Overlay::showNotification(msg);
|
||||||
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
if (dec_zoom) consumed = true; // Mentres estiga polsada, consumir-la
|
||||||
dec_zoom_was_pressed = dec_zoom;
|
dec_zoom_was_pressed = dec_zoom;
|
||||||
|
|
||||||
// Increment zoom
|
// Increment zoom
|
||||||
@@ -32,7 +36,9 @@ namespace GlobalInputs {
|
|||||||
char msg[32];
|
char msg[32];
|
||||||
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
snprintf(msg, sizeof(msg), "ZOOM %dx", Screen::get()->getZoom());
|
||||||
Overlay::showNotification(msg);
|
Overlay::showNotification(msg);
|
||||||
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
if (inc_zoom) consumed = true;
|
||||||
inc_zoom_was_pressed = inc_zoom;
|
inc_zoom_was_pressed = inc_zoom;
|
||||||
|
|
||||||
// Toggle fullscreen
|
// Toggle fullscreen
|
||||||
@@ -40,8 +46,12 @@ namespace GlobalInputs {
|
|||||||
if (fullscreen && !fullscreen_was_pressed) {
|
if (fullscreen && !fullscreen_was_pressed) {
|
||||||
Screen::get()->toggleFullscreen();
|
Screen::get()->toggleFullscreen();
|
||||||
Overlay::showNotification(Screen::get()->isFullscreen() ? "FULLSCREEN" : "WINDOWED");
|
Overlay::showNotification(Screen::get()->isFullscreen() ? "FULLSCREEN" : "WINDOWED");
|
||||||
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
if (fullscreen) consumed = true;
|
||||||
fullscreen_was_pressed = fullscreen;
|
fullscreen_was_pressed = fullscreen;
|
||||||
|
|
||||||
|
return consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GlobalInputs
|
} // namespace GlobalInputs
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
|
|
||||||
namespace GlobalInputs {
|
namespace GlobalInputs {
|
||||||
// Comprovar una vegada per frame, després de JI_Update()
|
// Comprovar una vegada per frame, després de JI_Update()
|
||||||
void handle();
|
// Retorna true si ha consumit alguna tecla (per suprimir-la de la capa de joc)
|
||||||
|
auto handle() -> bool;
|
||||||
} // namespace GlobalInputs
|
} // namespace GlobalInputs
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "core/input/global_inputs.hpp"
|
#include "core/input/global_inputs.hpp"
|
||||||
#include "core/jail/jgame.hpp"
|
#include "core/jail/jgame.hpp"
|
||||||
|
#include "game/options.hpp"
|
||||||
|
|
||||||
const bool* keystates; // = SDL_GetKeyboardState( NULL );
|
const bool* keystates; // = SDL_GetKeyboardState( NULL );
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
@@ -11,6 +12,13 @@ Uint8 cheat[5];
|
|||||||
bool key_pressed = false;
|
bool key_pressed = false;
|
||||||
int waitTime = 0;
|
int waitTime = 0;
|
||||||
|
|
||||||
|
// Comprova si un scancode pertany a les tecles reservades per a la GUI
|
||||||
|
static bool isGuiKey(SDL_Scancode sc) {
|
||||||
|
return sc == Options::keys_gui.dec_zoom ||
|
||||||
|
sc == Options::keys_gui.inc_zoom ||
|
||||||
|
sc == Options::keys_gui.fullscreen;
|
||||||
|
}
|
||||||
|
|
||||||
void JI_DisableKeyboard(Uint32 time) {
|
void JI_DisableKeyboard(Uint32 time) {
|
||||||
waitTime = time;
|
waitTime = time;
|
||||||
}
|
}
|
||||||
@@ -32,11 +40,15 @@ void JI_Update() {
|
|||||||
while (SDL_PollEvent(&event)) {
|
while (SDL_PollEvent(&event)) {
|
||||||
if (event.type == SDL_EVENT_QUIT) JG_QuitSignal();
|
if (event.type == SDL_EVENT_QUIT) JG_QuitSignal();
|
||||||
if (event.type == SDL_EVENT_KEY_UP) {
|
if (event.type == SDL_EVENT_KEY_UP) {
|
||||||
|
// Si és una tecla GUI, no la passem al joc legacy
|
||||||
|
if (!isGuiKey(event.key.scancode)) {
|
||||||
key_pressed = true;
|
key_pressed = true;
|
||||||
JI_moveCheats(event.key.scancode);
|
JI_moveCheats(event.key.scancode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// GlobalInputs processa les tecles GUI per polling
|
||||||
GlobalInputs::handle();
|
GlobalInputs::handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,10 @@ namespace Overlay {
|
|||||||
|
|
||||||
// --- Estat de les notificacions ---
|
// --- Estat de les notificacions ---
|
||||||
|
|
||||||
enum class Status { RISING, STAY, VANISHING, FINISHED };
|
enum class Status { RISING,
|
||||||
|
STAY,
|
||||||
|
VANISHING,
|
||||||
|
FINISHED };
|
||||||
|
|
||||||
struct Notification {
|
struct Notification {
|
||||||
std::string message;
|
std::string message;
|
||||||
@@ -119,8 +122,7 @@ namespace Overlay {
|
|||||||
|
|
||||||
// Elimina les acabades
|
// Elimina les acabades
|
||||||
notifications_.erase(
|
notifications_.erase(
|
||||||
std::remove_if(notifications_.begin(), notifications_.end(),
|
std::remove_if(notifications_.begin(), notifications_.end(), [](const Notification& n) { return n.status == Status::FINISHED; }),
|
||||||
[](const Notification& n) { return n.status == Status::FINISHED; }),
|
|
||||||
notifications_.end());
|
notifications_.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user