1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-12-18 20:08:06 +00:00

accept new controller controls in various menus

This commit is contained in:
Zeno Rogue
2025-12-11 20:14:42 +01:00
parent d4dafbaa6a
commit 88e778f3fe
4 changed files with 25 additions and 28 deletions

View File

@@ -1095,7 +1095,6 @@ EX void initConfig() {
if(deck) {
centered_menus = true;
lands_per_page = 18;
defaultjoy = false;
dialog::onscreen_keyboard = true;
dialog::dialog_font_scale = 3;
dialog::display_keys = 3;

View File

@@ -610,9 +610,9 @@ EX void handleKeyNormal(int sym, int uni) {
if(DEFAULTCONTROL && !game_keys_scroll) {
if(sym == '.' || sym == 's') movepcto(-1, 1);
if((sym == SDLK_DELETE || sym == SDLK_KP_PERIOD || sym == 'g') && uni != 'G' && uni != 'G'-64)
if((sym == SDLK_DELETE || sym == SDLK_KP_PERIOD || sym == 'g' || is_joy_index(sym, deck::key_g)) && uni != 'G' && uni != 'G'-64)
movepcto(MD_DROP, 1);
if(sym == 't' && uni != 'T' && uni != 'T'-64 && canmove) {
if((sym == 't' || is_joy_index(sym, deck::key_t)) && uni != 'T' && uni != 'T'-64 && canmove) {
cell *target = GDIM == 3 ? mouseover : centerover;
if(playermoved && items[itStrongWind]) {
cell *c = whirlwind::jumpDestination(cwt.at);
@@ -622,8 +622,8 @@ EX void handleKeyNormal(int sym, int uni) {
else targetRangedOrb(target, roKeyboard);
sym = 0; uni = 0;
}
if(sym == 'f') bow::switch_fire_mode();
if(sym == '`') {
if(sym == 'f' || is_joy_index(sym, deck::key_f)) bow::switch_fire_mode();
if(sym == '`' || is_joy_index(sym, deck::enter)) {
flashMessages();
movepcto(joydir);
joy_ignore_next = true;
@@ -649,7 +649,7 @@ EX void handleKeyNormal(int sym, int uni) {
keybd_subdir *= -1;
}
if(sym == SDLK_ESCAPE) {
if(sym == SDLK_ESCAPE || is_joy_index(sym, deck::escape)) {
if(bow::fire_mode)
bow::switch_fire_mode();
else if(viewdists)
@@ -964,6 +964,12 @@ EX void mainloopiter() {
hiliteclick = keystate[SDLK_LALT] | keystate[SDLK_RALT];
#endif
if(defaultjoy) for(int i=0; i<numsticks; i++) {
if(SDL_JoystickGetButton(sticks[i], deck::key_control)) lctrlclick = true;
if(SDL_JoystickGetButton(sticks[i], deck::key_alt)) hiliteclick = true;
if(SDL_JoystickGetButton(sticks[i], deck::key_shift)) lshiftclick = true;
}
anyshiftclick = lshiftclick | rshiftclick;
anyctrlclick = lctrlclick | rctrlclick;
@@ -1217,16 +1223,8 @@ EX void handle_event(SDL_Event& ev) {
if(ev.jhat.value == SDL_HAT_RIGHT) sym = SDLK_RIGHT;
}
else if(ev.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN && normal && DEFAULTCONTROL && defaultjoy) {
flashMessages();
movepcto(joydir);
joy_ignore_next = true;
joytime = -1;
checkjoy();
}
else if(ev.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN && !normal && defaultjoy) {
sym = uni = SDLK_RETURN;
else if(ev.type == SDL_EVENT_JOYSTICK_BUTTON_DOWN && defaultjoy) {
sym = uni = PSEUDOKEY_JOY + 128 * ev.jbutton.which + ev.jbutton.button;
}
#endif

View File

@@ -981,7 +981,7 @@ EX namespace dialog {
highlight_text = "//missing";
return;
}
if(uni == '\n' || uni == '\r' || DIRECTIONKEY == SDLK_KP5 || uni == '`') {
if(uni == '\n' || uni == '\r' || DIRECTIONKEY == SDLK_KP5 || uni == '`' || is_joy_index(sym, deck::enter) || is_joy_index(sym, deck::alt_enter)) {
for(int i=0; i<isize(items); i++)
if(isitem(items[i]))
if(is_highlight(items[i])) {
@@ -1000,14 +1000,14 @@ EX namespace dialog {
list_skip += 30;
highlight_text = "//missing";
}
if(DKEY == SDLK_PAGEDOWN) {
if(DKEY == SDLK_PAGEDOWN || is_joy_index(sym, deck::key_pagedown)) {
uni = sym = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i])) {
set_highlight(items[i]);
}
}
if(DKEY == SDLK_PAGEUP) {
if(DKEY == SDLK_PAGEUP || is_joy_index(sym, deck::key_pageup)) {
uni = sym = 0;
for(int i=0; i<isize(items); i++)
if(isitem(items[i])) {
@@ -1078,7 +1078,7 @@ EX namespace dialog {
if(x > 255) x = 255;
part(color, uni - 'A') = x;
}
else if(uni == ' ' || uni == '\n' || uni == '\r') {
else if(uni == ' ' || uni == '\n' || uni == '\r' || is_joy_index(sym, deck::enter) || is_joy_index(sym, deck::alt_enter)) {
bool inHistory = false;
for(int i=0; i<10; i++) if(colorhistory[i] == (color << shift))
inHistory = true;
@@ -1867,14 +1867,14 @@ EX namespace dialog {
string& s(*cfileptr);
int i = isize(s) - (editext?0:4);
if(sym == SDLK_ESCAPE) {
if(sym == SDLK_ESCAPE || is_joy_index(sym, deck::escape)) {
popScreen();
}
else if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER) {
else if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER || is_joy_index(sym, deck::enter)) {
bool ac = file_action();
if(ac) closed = true;
}
else if(sym == SDLK_BACKSPACE && i) {
else if((sym == SDLK_BACKSPACE || is_joy_index(sym, deck::space) || is_joy_index(sym, deck::key_pageup)) && i) {
int len = utfsize_before(s, i);
s.erase(i-len, len);
highlight_text = "//missing";
@@ -1999,10 +1999,10 @@ EX namespace dialog {
string u2;
if(DKEY == SDLK_LEFT) editpos -= utfsize_before(es, editpos);
else if(DKEY == SDLK_RIGHT) editpos += utfsize(es[editpos]);
else if(uni == '\t') {
else if(uni == '\t' || is_joy_index(sym, deck::key_t) || is_joy_index(sym, deck::key_pagedown)) {
es = ""; editpos = 0;
}
else if(uni == 8) {
else if(uni == 8 || is_joy_index(sym, deck::key_f) || is_joy_index(sym, deck::key_pageup)) {
if(editpos == 0) return true;
int len = utfsize_before(es, editpos);
es.replace(editpos-len, len, "");

View File

@@ -290,10 +290,10 @@ EX bool handleKeyTour(int sym, int uni) {
dialog::key_actions[sym]();
return true;
}
if(sym == SDLK_PAGEDOWN) return next_slide();
if((sym == SDLK_RETURN || sym == SDLK_KP_ENTER) && (!inhelp || (flags & QUICKSKIP)))
if(sym == SDLK_PAGEDOWN || is_joy_index(sym, deck::key_pagedown)) return next_slide();
if((sym == SDLK_RETURN || sym == SDLK_KP_ENTER || is_joy_index(sym, deck::alt_enter)) && (!inhelp || (flags & QUICKSKIP)))
return next_slide();
if(sym == SDLK_BACKSPACE || sym == SDLK_PAGEUP) {
if(sym == SDLK_BACKSPACE || sym == SDLK_PAGEUP || is_joy_index(sym, deck::key_pageup)) {
if(gamestack::pushed()) {
gamestack::pop();
if(!(flags & QUICKGEO)) return true;