- [FIX] Arreglos per al debugger - [FIX] Calcul de la posició del mouse en coordenades tenint en compte view.origin
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
#include "key.h"
|
|
#include "mini/pad/pad.h"
|
|
#include "mini/win/win.h"
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
namespace mini
|
|
{
|
|
namespace key
|
|
{
|
|
state_t state;
|
|
|
|
bool down(uint8_t i) {
|
|
return state.keys[i];
|
|
}
|
|
|
|
bool press(uint8_t i) {
|
|
if (state.just_pressed == i) {
|
|
state.just_pressed=0;
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
int press() {
|
|
return state.just_pressed;
|
|
}
|
|
|
|
bool any() {
|
|
const bool something_pressed = (state.just_pressed != 0) || (pad::state.just_pressed != -1);
|
|
state.just_pressed=0;
|
|
pad::state.just_pressed=-1;
|
|
return something_pressed;
|
|
}
|
|
|
|
void text(const bool enable) {
|
|
if (enable)
|
|
SDL_StartTextInput(win::state.window);
|
|
else
|
|
SDL_StopTextInput(win::state.window);
|
|
}
|
|
|
|
const char* utf8char() {
|
|
return state.has_text_input ? state.text_input_buffer : nullptr;
|
|
}
|
|
|
|
}
|
|
} |