1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

fixed the joystick bug (also 10.1c)

This commit is contained in:
Zeno Rogue 2017-10-16 01:22:24 +02:00
parent e06a3cc68a
commit 30c095fde8
3 changed files with 12 additions and 12 deletions

View File

@ -140,12 +140,12 @@ void initJoysticks() {
if(numsticks > 8) numsticks = 8; if(numsticks > 8) numsticks = 8;
for(int i=0; i<numsticks; i++) { for(int i=0; i<numsticks; i++) {
sticks[i] = SDL_JoystickOpen(i); sticks[i] = SDL_JoystickOpen(i);
/* printf("axes = %d, balls = %d, buttons = %d, hats = %d\n", printf("axes = %d, balls = %d, buttons = %d, hats = %d\n",
SDL_JoystickNumAxes(sticks[i]), SDL_JoystickNumAxes(sticks[i]),
SDL_JoystickNumBalls(sticks[i]), SDL_JoystickNumBalls(sticks[i]),
SDL_JoystickNumButtons(sticks[i]), SDL_JoystickNumButtons(sticks[i]),
SDL_JoystickNumHats(sticks[i]) SDL_JoystickNumHats(sticks[i])
); */ );
} }
} }
@ -496,7 +496,7 @@ void mainloopiter() {
panjoyx = panjoyy = 0; panjoyx = panjoyy = 0;
closeJoysticks(); closeJoysticks();
initJoysticks(); initJoysticks();
}*/ } */
if(ev.type == SDL_ACTIVEEVENT) { if(ev.type == SDL_ACTIVEEVENT) {
if(ev.active.state & SDL_APPINPUTFOCUS) { if(ev.active.state & SDL_APPINPUTFOCUS) {
@ -522,7 +522,7 @@ void mainloopiter() {
drawscreen(); drawscreen();
} }
#if CAP_JOY #if CAP_SDLJOY
if(ev.type == SDL_JOYAXISMOTION && normal && DEFAULTCONTROL) { if(ev.type == SDL_JOYAXISMOTION && normal && DEFAULTCONTROL) {
if(ev.jaxis.which == 0) { if(ev.jaxis.which == 0) {
if(ev.jaxis.axis == 0) if(ev.jaxis.axis == 0)

View File

@ -4550,7 +4550,7 @@ void drawMarkers() {
queuecircleat(global_pushto, .6, darkena(0xFFD500, 0, 0xFF)); queuecircleat(global_pushto, .6, darkena(0xFFD500, 0, 0xFF));
} }
#if CAP_JOY #if CAP_SDLJOY
if(joydir.d >= 0) if(joydir.d >= 0)
queuecircleat(cwt.c->mov[(joydir.d+cwt.spin) % cwt.c->type], .78 - .02 * sin(ticks/199.0), queuecircleat(cwt.c->mov[(joydir.d+cwt.spin) % cwt.c->type], .78 - .02 * sin(ticks/199.0),
darkena(0x00FF00, 0, 0xFF)); darkena(0x00FF00, 0, 0xFF));

View File

@ -139,7 +139,7 @@ string listkeys(int id) {
for(int i=0; i<512; i++) for(int i=0; i<512; i++)
if(vid.scfg.keyaction[i] == id) if(vid.scfg.keyaction[i] == id)
lk = lk + " " + SDL_GetKeyName(SDLKey(i)); lk = lk + " " + SDL_GetKeyName(SDLKey(i));
#if CAP_JOY #if CAP_SDLJOY
for(int i=0; i<numsticks; i++) for(int k=0; k<SDL_JoystickNumButtons(sticks[i]) && k<MAXBUTTON; k++) for(int i=0; i<numsticks; i++) for(int k=0; k<SDL_JoystickNumButtons(sticks[i]) && k<MAXBUTTON; k++)
if(vid.scfg.joyaction[i][k] == id) { if(vid.scfg.joyaction[i][k] == id) {
lk = lk + " " + cts('A'+i)+"-B"+its(k); lk = lk + " " + cts('A'+i)+"-B"+its(k);
@ -193,7 +193,7 @@ void showShmupConfig() {
shmupnumkeys = CMDS_PAN; shmupnumkeys = CMDS_PAN;
shmupcmdtable = pancmds; shmupcmdtable = pancmds;
} }
#if CAP_JOY #if CAP_SDLJOY
else if(sc == SCJOY) { else if(sc == SCJOY) {
dialog::init(); dialog::init();
getcstat = ' '; getcstat = ' ';
@ -255,7 +255,7 @@ void showShmupConfig() {
dialog::addBreak(100); dialog::addBreak(100);
if(vid.scfg.players > 2) if(vid.scfg.players > 2)
dialog::addItem(XLAT("configure player 3") + dsc(2), '3'); dialog::addItem(XLAT("configure player 3") + dsc(2), '3');
#if CAP_JOY #if CAP_SDLJOY
else if(vid.scfg.players == 1 && !shmupcfg && !shmupcfg && !multi::alwaysuse) else if(vid.scfg.players == 1 && !shmupcfg && !shmupcfg && !multi::alwaysuse)
dialog::addItem(XLAT("old style joystick configuration"), 'b'); dialog::addItem(XLAT("old style joystick configuration"), 'b');
#endif #endif
@ -280,7 +280,7 @@ void showShmupConfig() {
dialog::addItem(XLAT("configure panning and general keys"), 'p'); dialog::addItem(XLAT("configure panning and general keys"), 'p');
else dialog::addBreak(100); else dialog::addBreak(100);
#if CAP_JOY #if CAP_SDLJOY
if(numsticks > 0) { if(numsticks > 0) {
if(shmupcfg || multi::alwaysuse || vid.scfg.players > 1) if(shmupcfg || multi::alwaysuse || vid.scfg.players > 1)
dialog::addItem(XLAT("configure joystick axes"), 'j'); dialog::addItem(XLAT("configure joystick axes"), 'j');
@ -351,11 +351,11 @@ void handleConfig(int sym, int uni) {
else if(uni == '5') vid.scfg.subconfig = 6; else if(uni == '5') vid.scfg.subconfig = 6;
else if(uni == '6') vid.scfg.subconfig = 7; else if(uni == '6') vid.scfg.subconfig = 7;
else if(uni == '7') vid.scfg.subconfig = 8; else if(uni == '7') vid.scfg.subconfig = 8;
#if CAP_JOY #if CAP_SDLJOY
else if(uni == 'j') vid.scfg.subconfig = SCJOY; else if(uni == 'j') vid.scfg.subconfig = SCJOY;
#endif #endif
else if(uni == 'a') multi::alwaysuse = !multi::alwaysuse; else if(uni == 'a') multi::alwaysuse = !multi::alwaysuse;
#if CAP_JOY #if CAP_SDLJOY
else if(uni == 'b') pushScreen(showJoyConfig); else if(uni == 'b') pushScreen(showJoyConfig);
#endif #endif
else if(uni == 'r') else if(uni == 'r')
@ -634,7 +634,7 @@ void handleInput(int delta) {
for(int i=0; i<SDLK_LAST; i++) if(keystate[i]) for(int i=0; i<SDLK_LAST; i++) if(keystate[i])
pressaction(vid.scfg.keyaction[i]); pressaction(vid.scfg.keyaction[i]);
#if CAP_JOY #if CAP_SDLJOY
for(int j=0; j<numsticks; j++) { for(int j=0; j<numsticks; j++) {
for(int b=0; b<SDL_JoystickNumButtons(sticks[j]) && b<MAXBUTTON; b++) for(int b=0; b<SDL_JoystickNumButtons(sticks[j]) && b<MAXBUTTON; b++)