X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=948f1ceb73602a5bbdfda6c0c2161be133678c15;hb=41cfe645942062496cd063eb46e17d677a76c645;hp=f2335cac639ab23a52c3e2e5e3854f5f2aba8649;hpb=f8f7840ddc57a2c31a3d6ab664b0e4e7e7ad69ce;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index f2335cac..948f1ceb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -55,10 +55,6 @@ static void HandleScreenGadgets(struct GadgetInfo *); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; -#ifdef MSDOS -extern unsigned char get_ascii(KeySym); -#endif - void DrawHeadline() { int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2; @@ -75,7 +71,7 @@ void DrawMainMenu() UnmapAllGadgets(); FadeSounds(); - XAutoRepeatOn(display); + KeyboardAutoRepeatOn(); /* needed if last screen was the playing screen, invoked from level editor */ if (level_editor_test_game) @@ -274,7 +270,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) /* needed because DrawMicroLevel() takes some time */ BackToFront(); - XSync(display, FALSE); + SyncDisplay(); DelayReached(&level_delay, 0); /* reset delay counter */ } else if (x == 1 && y >= 3 && y <= 10) @@ -814,7 +810,7 @@ void HandleHelpScreen(int button) BackToFront(); } -void HandleTypeName(int newxpos, KeySym key) +void HandleTypeName(int newxpos, Key key) { static int xpos = 0, ypos = 2; @@ -826,15 +822,15 @@ void HandleTypeName(int newxpos, KeySym key) return; } - if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) && + if (((key >= KEY_A && key <= KEY_Z) || (key >= KEY_a && key <= KEY_z)) && xpos < MAX_PLAYER_NAME_LEN) { char ascii; - if (key >= XK_A && key <= XK_Z) - ascii = 'A' + (char)(key - XK_A); + if (key >= KEY_A && key <= KEY_Z) + ascii = 'A' + (char)(key - KEY_A); else - ascii = 'a' + (char)(key - XK_a); + ascii = 'a' + (char)(key - KEY_a); setup.player_name[xpos] = ascii; setup.player_name[xpos + 1] = 0; @@ -845,14 +841,14 @@ void HandleTypeName(int newxpos, KeySym key) setup.player_name, FS_BIG, FC_YELLOW); DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); } - else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0) + else if ((key == KEY_Delete || key == KEY_BackSpace) && xpos > 0) { xpos--; setup.player_name[xpos] = 0; DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT); DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM); } - else if (key == XK_Return && xpos > 0) + else if (key == KEY_Return && xpos > 0) { DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED); DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM); @@ -927,7 +923,7 @@ static void drawChooseLevelList(int first_entry, int num_page_entries) int max_buffer_len = (SCR_FIELDX - 2) * 2; int num_leveldirs = numLevelDirInfoInGroup(leveldir_current); - XFillRectangle(display, backbuffer, gc, SX, SY, SXSIZE - 32, SYSIZE); + ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE); redraw_mask |= REDRAW_FIELD; DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN); @@ -969,7 +965,7 @@ static void drawChooseLevelInfo(int leveldir_pos) node_first = getLevelDirInfoFirstGroupEntry(leveldir_current); node = getLevelDirInfoFromPos(node_first, leveldir_pos); - XFillRectangle(display, drawto, gc, SX + 32, SY + 32, SXSIZE - 64, 32); + ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32); if (node->parent_link) DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc); @@ -1040,7 +1036,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) else x = y = 0; /* no action */ - if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */ { dy = SIGN(dy); step = num_page_entries - 1; @@ -1228,7 +1224,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) return; } - if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */ + if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */ step = MAX_LEVEL_SERIES_ON_SCREEN - 1; if (dy < 0) @@ -1618,7 +1614,7 @@ static void drawPlayerSetupInputInfo(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } custom[] = { @@ -1678,7 +1674,7 @@ static void drawPlayerSetupInputInfo(int player_nr) DrawText(SX + 3*32, SY + ypos*32, (setup.input[player_nr].use_joystick ? custom[i].text : - getKeyNameFromKeySym(*custom[i].keysym)), + getKeyNameFromKey(*custom[i].key)), FS_BIG, FC_YELLOW); } } @@ -1858,7 +1854,7 @@ void CustomizeKeyboard(int player_nr) static struct SetupKeyboardInfo custom_key; static struct { - KeySym *keysym; + Key *key; char *text; } customize_step[] = { @@ -1885,47 +1881,46 @@ void CustomizeKeyboard(int player_nr) DrawText(SX, SY + (2+2*step_nr+1)*32, "Key:", FS_BIG, FC_RED); DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32, - getKeyNameFromKeySym(*customize_step[step_nr].keysym), + getKeyNameFromKey(*customize_step[step_nr].key), FS_BIG, FC_BLUE); while(!finished) { - if (XPending(display)) /* got event from X server */ + if (PendingEvent()) /* got event */ { - XEvent event; + Event event; - XNextEvent(display, &event); + NextEvent(&event); switch(event.type) { - case KeyPress: + case EVENT_KEYPRESS: { - KeySym key = XLookupKeysym((XKeyEvent *)&event, - ((XKeyEvent *)&event)->state); + Key key = GetEventKey((KeyEvent *)&event, TRUE); - if (key == XK_Escape || (key == XK_Return && step_nr == 6)) + if (key == KEY_Escape || (key == KEY_Return && step_nr == 6)) { finished = TRUE; break; } /* press 'Enter' to keep the existing key binding */ - if (key == XK_Return || step_nr == 6) - key = *customize_step[step_nr].keysym; + if (key == KEY_Return || step_nr == 6) + key = *customize_step[step_nr].key; /* check if key already used */ for (i=0; istate)) + case EVENT_KEYPRESS: + switch(GetEventKey((KeyEvent *)&event, TRUE)) { - case XK_Return: + case KEY_Return: if (check_remaining == 0) result = 1; break; - case XK_Escape: + case KEY_Escape: result = 0; break; @@ -2082,7 +2076,7 @@ void CalibrateJoystick(int player_nr) } break; - case KeyRelease: + case EVENT_KEYRELEASE: key_joystick_mapping = 0; break; @@ -2093,11 +2087,17 @@ void CalibrateJoystick(int player_nr) } #ifndef MSDOS + +#ifdef USE_SDL_LIBRARY + joy_ctrl.x = Get_SDL_Joystick_Axis(joystick_fd, 0); + joy_ctrl.y = Get_SDL_Joystick_Axis(joystick_fd, 1); +#else if (read(joystick_fd, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) { joystick_status = JOYSTICK_OFF; goto error_out; } +#endif new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x); new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x); @@ -2205,7 +2205,18 @@ void CalibrateJoystick(int player_nr) StopAnimation(); DrawSetupInputScreen(); - while(Joystick(player_nr) & JOY_BUTTON); + + /* wait until the last pressed button was released */ + while(Joystick(player_nr) & JOY_BUTTON) + { + if (PendingEvent()) /* got event */ + { + Event event; + + NextEvent(&event); + HandleOtherEvents(&event); + } + } return; error_out: @@ -2300,7 +2311,7 @@ static struct static void CreateScreenScrollbuttons() { - Pixmap gd_pixmap = pix[PIX_MORE]; + Bitmap gd_bitmap = pix[PIX_MORE]; struct GadgetInfo *gi; unsigned long event_mask; int i; @@ -2334,8 +2345,8 @@ static void CreateScreenScrollbuttons() GDI_HEIGHT, height, GDI_TYPE, GD_TYPE_NORMAL_BUTTON, GDI_STATE, GD_BUTTON_UNPRESSED, - GDI_DESIGN_UNPRESSED, gd_pixmap, gd_x1, gd_y1, - GDI_DESIGN_PRESSED, gd_pixmap, gd_x2, gd_y2, + GDI_DESIGN_UNPRESSED, gd_bitmap, gd_x1, gd_y1, + GDI_DESIGN_PRESSED, gd_bitmap, gd_x2, gd_y2, GDI_EVENT_MASK, event_mask, GDI_CALLBACK_ACTION, HandleScreenGadgets, GDI_END); @@ -2354,7 +2365,7 @@ static void CreateScreenScrollbars() for (i=0; i