|
|
1.1 ! root 1: /* ! 2: Hatari - dlgRom.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. ! 6: */ ! 7: const char DlgMouse_fileid[] = "Previous dlgMouse.c : " __DATE__ " " __TIME__; ! 8: ! 9: #include "main.h" ! 10: #include "configuration.h" ! 11: #include "dialog.h" ! 12: #include "sdlgui.h" ! 13: #include "file.h" ! 14: #include "paths.h" ! 15: ! 16: ! 17: #define DLGMOUSE_AUTOLOCK 15 ! 18: #define DLGMOUSE_EXIT 16 ! 19: ! 20: char lin_normal[8]; ! 21: char lin_locked[8]; ! 22: char exp_normal[8]; ! 23: char exp_locked[8]; ! 24: ! 25: /* The Boot options dialog: */ ! 26: static SGOBJ mousedlg[] = ! 27: { ! 28: { SGBOX, 0, 0, 0,0, 45,24, NULL }, ! 29: { SGTEXT, 0, 0, 16,1, 13,1, "Mouse options" }, ! 30: ! 31: { SGTEXT, 0, 0, 2,4, 30,1, "Mouse motion speed adjustment:" }, ! 32: ! 33: { SGBOX, 0, 0, 1,6, 43,5, NULL }, ! 34: { SGTEXT, 0, 0, 2,7, 32,1, "Linear adjustment (0.1 to 10.0):" }, ! 35: { SGTEXT, 0, 0, 2,9, 12,1, "Normal mode:" }, ! 36: { SGEDITFIELD, 0, 0, 15,9, 5,1, lin_normal }, ! 37: { SGTEXT, 0, 0, 25,9, 12,1, "Locked mode:" }, ! 38: { SGEDITFIELD, 0, 0, 38,9, 5,1, lin_locked }, ! 39: ! 40: { SGBOX, 0, 0, 1,12, 43,5, NULL }, ! 41: { SGTEXT, 0, 0, 2,13, 38,1, "Exponential adjustment (0.50 to 1.00):" }, ! 42: { SGTEXT, 0, 0, 2,15, 12,1, "Normal mode:" }, ! 43: { SGEDITFIELD, 0, 0, 15,15, 5,1, exp_normal }, ! 44: { SGTEXT, 0, 0, 25,15, 12,1, "Locked mode:" }, ! 45: { SGEDITFIELD, 0, 0, 38,15, 5,1, exp_locked }, ! 46: ! 47: { SGCHECKBOX, 0, 0, 2,18, 21,1, "Enable auto-locking" }, ! 48: ! 49: { SGBUTTON, SG_DEFAULT, 0, 12,21, 21,1, "Back to main menu" }, ! 50: { -1, 0, 0, 0,0, 0,0, NULL } ! 51: }; ! 52: ! 53: static float read_float_string(char *s, float min, float max, int prec) ! 54: { ! 55: int i; ! 56: float result=0.0; ! 57: ! 58: for (i=0; i<8; i++) { ! 59: if (*s>=(0+'0') && *s<=(9+'0')) { ! 60: result *= 10.0; ! 61: result += (float)(*s-'0'); ! 62: s++; ! 63: } else { ! 64: if (i==0 && *s!='.' && *s!=',') /* bad input, default to 1.0 */ ! 65: result=1.0; ! 66: break; ! 67: } ! 68: } ! 69: ! 70: if (*s == '.' || *s == ',') { ! 71: s++; ! 72: for (i=1; i<=prec; i++) { ! 73: if (*s>=(0+'0') && *s<=(9+'0')) { ! 74: result += (float)(*s-'0')/pow(10.0, i); ! 75: s++; ! 76: } else { ! 77: if (result==0.0) { /* bad input, default to 1.0 */ ! 78: result=1.0; ! 79: } ! 80: break; ! 81: } ! 82: } ! 83: if (*s>=(0+'0') && *s<=(9+'0')) { ! 84: if ((*s-'0')>=5) { ! 85: result += 1.0/pow(10.0, i-1); ! 86: } ! 87: } ! 88: } ! 89: ! 90: if (result<min) ! 91: result=min; ! 92: if (result>max) ! 93: result=max; ! 94: ! 95: return result; ! 96: } ! 97: ! 98: ! 99: /*-----------------------------------------------------------------------*/ ! 100: /** ! 101: * Show and process the Mouse options dialog. ! 102: */ ! 103: void Dialog_MouseDlg(void) ! 104: { ! 105: int but; ! 106: ! 107: SDLGui_CenterDlg(mousedlg); ! 108: ! 109: /* Set up the dialog from actual values */ ! 110: ! 111: mousedlg[DLGMOUSE_AUTOLOCK].state &= ~SG_SELECTED; ! 112: if (ConfigureParams.Mouse.bEnableAutoGrab) ! 113: mousedlg[DLGMOUSE_AUTOLOCK].state |= SG_SELECTED; ! 114: ! 115: sprintf(lin_normal, "%#.1f", ConfigureParams.Mouse.fLinSpeedNormal); ! 116: sprintf(lin_locked, "%#.1f", ConfigureParams.Mouse.fLinSpeedLocked); ! 117: ! 118: sprintf(exp_normal, "%#.2f", ConfigureParams.Mouse.fExpSpeedNormal); ! 119: sprintf(exp_locked, "%#.2f", ConfigureParams.Mouse.fExpSpeedLocked); ! 120: ! 121: /* Draw and process the dialog */ ! 122: ! 123: do ! 124: { ! 125: but = SDLGui_DoDialog(mousedlg, NULL); ! 126: } ! 127: while (but != DLGMOUSE_EXIT && but != SDLGUI_QUIT ! 128: && but != SDLGUI_ERROR && !bQuitProgram); ! 129: ! 130: ! 131: /* Read values from dialog */ ! 132: ConfigureParams.Mouse.bEnableAutoGrab = mousedlg[DLGMOUSE_AUTOLOCK].state&SG_SELECTED ? true : false; ! 133: ConfigureParams.Mouse.fLinSpeedNormal = read_float_string(lin_normal, MOUSE_LIN_MIN, MOUSE_LIN_MAX, 1); ! 134: ConfigureParams.Mouse.fLinSpeedLocked = read_float_string(lin_locked, MOUSE_LIN_MIN, MOUSE_LIN_MAX, 1); ! 135: ConfigureParams.Mouse.fExpSpeedNormal = read_float_string(exp_normal, MOUSE_EXP_MIN, MOUSE_EXP_MAX, 2); ! 136: ConfigureParams.Mouse.fExpSpeedLocked = read_float_string(exp_locked, MOUSE_EXP_MIN, MOUSE_EXP_MAX, 2); ! 137: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.