|
|
1.1 root 1: /*
2: Hatari - keymap.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: Here we process a key press and the remapping of the scancodes.
8: */
9: const char Keymap_fileid[] = "Hatari keymap.c : " __DATE__ " " __TIME__;
10:
11: #include <ctype.h>
12: #include "main.h"
13: #include "keymap.h"
14: #include "configuration.h"
15: #include "file.h"
16: #include "shortcut.h"
17: #include "str.h"
18: #include "screen.h"
19: #include "debugui.h"
20: #include "log.h"
1.1.1.4 ! root 21: #include "kms.h"
1.1.1.2 root 22:
23: #include "SDL.h"
24:
25:
1.1.1.4 ! root 26: #define LOG_KEYMAP_LEVEL LOG_WARN
1.1.1.3 root 27:
1.1.1.4 ! root 28: Uint8 modifiers = 0;
! 29: bool capslock = false;
1.1.1.2 root 30:
31:
32: void Keymap_Init(void) {
1.1.1.4 ! root 33:
! 34: }
! 35:
! 36:
! 37: /* This function translates the scancodes provided by SDL to
! 38: * NeXT scancode values.
! 39: */
! 40:
! 41: Uint8 Keymap_GetKeyFromScancode(SDL_Scancode sdlscancode) {
! 42: Log_Printf(LOG_KEYMAP_LEVEL, "[Keymap] Scancode: %i (%s)\n", sdlscancode, SDL_GetScancodeName(sdlscancode));
! 43:
! 44: switch (sdlscancode) {
! 45: case SDL_SCANCODE_ESCAPE: return 0x49;
! 46: case SDL_SCANCODE_1: return 0x4a;
! 47: case SDL_SCANCODE_2: return 0x4b;
! 48: case SDL_SCANCODE_3: return 0x4c;
! 49: case SDL_SCANCODE_4: return 0x4d;
! 50: case SDL_SCANCODE_5: return 0x50;
! 51: case SDL_SCANCODE_6: return 0x4f;
! 52: case SDL_SCANCODE_7: return 0x4e;
! 53: case SDL_SCANCODE_8: return 0x1e;
! 54: case SDL_SCANCODE_9: return 0x1f;
! 55: case SDL_SCANCODE_0: return 0x20;
! 56: case SDL_SCANCODE_MINUS: return 0x1d;
! 57: case SDL_SCANCODE_EQUALS: return 0x1c;
! 58: case SDL_SCANCODE_BACKSPACE: return 0x1b;
1.1.1.3 root 59:
1.1.1.4 ! root 60: case SDL_SCANCODE_TAB: return 0x41;
! 61: case SDL_SCANCODE_Q: return 0x42;
! 62: case SDL_SCANCODE_W: return 0x43;
! 63: case SDL_SCANCODE_E: return 0x44;
! 64: case SDL_SCANCODE_R: return 0x45;
! 65: case SDL_SCANCODE_T: return 0x48;
! 66: case SDL_SCANCODE_Y: return 0x47;
! 67: case SDL_SCANCODE_U: return 0x46;
! 68: case SDL_SCANCODE_I: return 0x06;
! 69: case SDL_SCANCODE_O: return 0x07;
! 70: case SDL_SCANCODE_P: return 0x08;
! 71: case SDL_SCANCODE_LEFTBRACKET: return 0x05;
! 72: case SDL_SCANCODE_RIGHTBRACKET: return 0x04;
! 73: case SDL_SCANCODE_BACKSLASH: return 0x03;
! 74:
! 75: case SDL_SCANCODE_A: return 0x39;
! 76: case SDL_SCANCODE_S: return 0x3a;
! 77: case SDL_SCANCODE_D: return 0x3b;
! 78: case SDL_SCANCODE_F: return 0x3c;
! 79: case SDL_SCANCODE_G: return 0x3d;
! 80: case SDL_SCANCODE_H: return 0x40;
! 81: case SDL_SCANCODE_J: return 0x3f;
! 82: case SDL_SCANCODE_K: return 0x3e;
! 83: case SDL_SCANCODE_L: return 0x2d;
! 84: case SDL_SCANCODE_SEMICOLON: return 0x2c;
! 85: case SDL_SCANCODE_APOSTROPHE: return 0x2b;
! 86: case SDL_SCANCODE_RETURN: return 0x2a;
1.1.1.3 root 87:
1.1.1.4 ! root 88: case SDL_SCANCODE_Z: return 0x31;
! 89: case SDL_SCANCODE_X: return 0x32;
! 90: case SDL_SCANCODE_C: return 0x33;
! 91: case SDL_SCANCODE_V: return 0x34;
! 92: case SDL_SCANCODE_B: return 0x35;
! 93: case SDL_SCANCODE_N: return 0x37;
! 94: case SDL_SCANCODE_M: return 0x36;
! 95: case SDL_SCANCODE_COMMA: return 0x2e;
! 96: case SDL_SCANCODE_PERIOD: return 0x2f;
! 97: case SDL_SCANCODE_SLASH: return 0x30;
! 98: case SDL_SCANCODE_SPACE: return 0x38;
1.1.1.3 root 99:
1.1.1.4 ! root 100: case SDL_SCANCODE_GRAVE:
! 101: case SDL_SCANCODE_NUMLOCKCLEAR: return 0x26;
! 102: case SDL_SCANCODE_KP_EQUALS: return 0x27;
! 103: case SDL_SCANCODE_KP_DIVIDE: return 0x28;
! 104: case SDL_SCANCODE_KP_MULTIPLY: return 0x25;
! 105: case SDL_SCANCODE_KP_7: return 0x21;
! 106: case SDL_SCANCODE_KP_8: return 0x22;
! 107: case SDL_SCANCODE_KP_9: return 0x23;
! 108: case SDL_SCANCODE_KP_MINUS: return 0x24;
! 109: case SDL_SCANCODE_KP_4: return 0x12;
! 110: case SDL_SCANCODE_KP_5: return 0x18;
! 111: case SDL_SCANCODE_KP_6: return 0x13;
! 112: case SDL_SCANCODE_KP_PLUS: return 0x15;
! 113: case SDL_SCANCODE_KP_1: return 0x11;
! 114: case SDL_SCANCODE_KP_2: return 0x17;
! 115: case SDL_SCANCODE_KP_3: return 0x14;
! 116: case SDL_SCANCODE_KP_0: return 0x0b;
! 117: case SDL_SCANCODE_KP_PERIOD: return 0x0c;
! 118: case SDL_SCANCODE_KP_ENTER: return 0x0d;
1.1.1.3 root 119:
1.1.1.4 ! root 120: case SDL_SCANCODE_LEFT: return 0x09;
! 121: case SDL_SCANCODE_RIGHT: return 0x10;
! 122: case SDL_SCANCODE_UP: return 0x16;
! 123: case SDL_SCANCODE_DOWN: return 0x0f;
1.1.1.3 root 124:
1.1.1.4 ! root 125: /* Special keys */
! 126: case SDL_SCANCODE_F10:
! 127: case SDL_SCANCODE_DELETE: return 0x58; /* Power */
! 128: case SDL_SCANCODE_F5:
! 129: case SDL_SCANCODE_END: return 0x02; /* Sound down */
! 130: case SDL_SCANCODE_F6:
! 131: case SDL_SCANCODE_HOME: return 0x1a; /* Sound up */
! 132: case SDL_SCANCODE_F1:
! 133: case SDL_SCANCODE_PAGEDOWN: return 0x01; /* Brightness down */
! 134: case SDL_SCANCODE_F2:
! 135: case SDL_SCANCODE_PAGEUP: return 0x19; /* Brightness up */
1.1.1.3 root 136:
1.1.1.4 ! root 137: default: return 0x00;
1.1.1.3 root 138: }
1.1.1.2 root 139: }
140:
141:
1.1.1.4 ! root 142: /* These functions translate the scancodes provided by SDL to
! 143: * NeXT modifier bits.
! 144: */
1.1.1.2 root 145:
1.1.1.4 ! root 146: Uint8 Keymap_Keydown_GetModFromScancode(SDL_Scancode sdlscancode) {
! 147: switch (sdlscancode) {
! 148: case SDL_SCANCODE_LCTRL:
! 149: case SDL_SCANCODE_RCTRL:
! 150: modifiers|=0x01;
1.1.1.2 root 151: break;
1.1.1.4 ! root 152: case SDL_SCANCODE_LSHIFT:
! 153: modifiers|=0x02;
1.1.1.2 root 154: break;
1.1.1.4 ! root 155: case SDL_SCANCODE_RSHIFT:
! 156: modifiers|=0x04;
1.1.1.2 root 157: break;
1.1.1.4 ! root 158: case SDL_SCANCODE_LGUI:
! 159: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x20:0x08;
1.1.1.2 root 160: break;
1.1.1.4 ! root 161: case SDL_SCANCODE_RGUI:
! 162: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x40:0x10;
1.1.1.2 root 163: break;
1.1.1.4 ! root 164: case SDL_SCANCODE_LALT:
! 165: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x08:0x20;
1.1.1.2 root 166: break;
1.1.1.4 ! root 167: case SDL_SCANCODE_RALT:
! 168: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x10:0x40;
1.1.1.2 root 169: break;
1.1.1.4 ! root 170: case SDL_SCANCODE_CAPSLOCK:
! 171: capslock=capslock?false:true;
1.1.1.2 root 172: break;
1.1.1.4 ! root 173: default:
1.1.1.2 root 174: break;
1.1.1.4 ! root 175: }
! 176:
! 177: return modifiers|(capslock?0x02:0x00);
! 178: }
! 179:
! 180: Uint8 Keymap_Keyup_GetModFromScancode(SDL_Scancode sdlscancode) {
! 181:
! 182: switch (sdlscancode) {
! 183: case SDL_SCANCODE_LCTRL:
! 184: case SDL_SCANCODE_RCTRL:
! 185: modifiers&=~0x01;
1.1.1.2 root 186: break;
1.1.1.4 ! root 187: case SDL_SCANCODE_LSHIFT:
! 188: modifiers&=~0x02;
1.1.1.2 root 189: break;
1.1.1.4 ! root 190: case SDL_SCANCODE_RSHIFT:
! 191: modifiers&=~0x04;
1.1.1.2 root 192: break;
1.1.1.4 ! root 193: case SDL_SCANCODE_LGUI:
! 194: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x20:0x08);
1.1.1.2 root 195: break;
1.1.1.4 ! root 196: case SDL_SCANCODE_RGUI:
! 197: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x40:0x10);
1.1.1.2 root 198: break;
1.1.1.4 ! root 199: case SDL_SCANCODE_LALT:
! 200: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x08:0x20);
1.1.1.2 root 201: break;
1.1.1.4 ! root 202: case SDL_SCANCODE_RALT:
! 203: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x10:0x40);
1.1.1.2 root 204: break;
1.1.1.4 ! root 205: case SDL_SCANCODE_CAPSLOCK:
! 206: //capslock=false;
1.1.1.2 root 207: break;
1.1.1.4 ! root 208: default:
1.1.1.2 root 209: break;
1.1.1.4 ! root 210: }
! 211:
! 212: return modifiers|(capslock?0x02:0x00);
! 213: }
! 214:
! 215:
! 216: /* This function translates the key symbols provided by SDL to
! 217: * NeXT scancode values.
! 218: */
! 219:
! 220: Uint8 Keymap_GetKeyFromSymbol(SDL_Keycode sdlkey) {
! 221: Log_Printf(LOG_KEYMAP_LEVEL, "[Keymap] Symkey: %s\n", SDL_GetKeyName(sdlkey));
! 222:
! 223: switch (sdlkey) {
! 224: case SDLK_BACKSLASH: return 0x03;
! 225: case SDLK_RIGHTBRACKET: return 0x04;
! 226: case SDLK_LEFTBRACKET: return 0x05;
! 227: case SDLK_i: return 0x06;
! 228: case SDLK_o: return 0x07;
! 229: case SDLK_p: return 0x08;
! 230: case SDLK_LEFT: return 0x09;
! 231: case SDLK_KP_0: return 0x0B;
! 232: case SDLK_KP_PERIOD: return 0x0C;
! 233: case SDLK_KP_ENTER: return 0x0D;
! 234: case SDLK_DOWN: return 0x0F;
! 235: case SDLK_RIGHT: return 0x10;
! 236: case SDLK_KP_1: return 0x11;
! 237: case SDLK_KP_4: return 0x12;
! 238: case SDLK_KP_6: return 0x13;
! 239: case SDLK_KP_3: return 0x14;
! 240: case SDLK_KP_PLUS: return 0x15;
! 241: case SDLK_UP: return 0x16;
! 242: case SDLK_KP_2: return 0x17;
! 243: case SDLK_KP_5: return 0x18;
! 244: case SDLK_BACKSPACE: return 0x1B;
! 245: case SDLK_EQUALS: return 0x1C;
! 246: case SDLK_MINUS: return 0x1D;
! 247: case SDLK_8: return 0x1E;
! 248: case SDLK_9: return 0x1F;
! 249: case SDLK_0: return 0x20;
! 250: case SDLK_KP_7: return 0x21;
! 251: case SDLK_KP_8: return 0x22;
! 252: case SDLK_KP_9: return 0x23;
! 253: case SDLK_KP_MINUS: return 0x24;
! 254: case SDLK_KP_MULTIPLY: return 0x25;
! 255: case SDLK_BACKQUOTE: return 0x26;
! 256: case SDLK_KP_EQUALS: return 0x27;
! 257: case SDLK_KP_DIVIDE: return 0x28;
! 258: case SDLK_RETURN: return 0x2A;
! 259: case SDLK_QUOTE: return 0x2B;
! 260: case SDLK_SEMICOLON: return 0x2C;
! 261: case SDLK_l: return 0x2D;
! 262: case SDLK_COMMA: return 0x2E;
! 263: case SDLK_PERIOD: return 0x2F;
! 264: case SDLK_SLASH: return 0x30;
! 265: case SDLK_z: return 0x31;
! 266: case SDLK_x: return 0x32;
! 267: case SDLK_c: return 0x33;
! 268: case SDLK_v: return 0x34;
! 269: case SDLK_b: return 0x35;
! 270: case SDLK_m: return 0x36;
! 271: case SDLK_n: return 0x37;
! 272: case SDLK_SPACE: return 0x38;
! 273: case SDLK_a: return 0x39;
! 274: case SDLK_s: return 0x3A;
! 275: case SDLK_d: return 0x3B;
! 276: case SDLK_f: return 0x3C;
! 277: case SDLK_g: return 0x3D;
! 278: case SDLK_k: return 0x3E;
! 279: case SDLK_j: return 0x3F;
! 280: case SDLK_h: return 0x40;
! 281: case SDLK_TAB: return 0x41;
! 282: case SDLK_q: return 0x42;
! 283: case SDLK_w: return 0x43;
! 284: case SDLK_e: return 0x44;
! 285: case SDLK_r: return 0x45;
! 286: case SDLK_u: return 0x46;
! 287: case SDLK_y: return 0x47;
! 288: case SDLK_t: return 0x48;
! 289: case SDLK_ESCAPE: return 0x49;
! 290: case SDLK_1: return 0x4A;
! 291: case SDLK_2: return 0x4B;
! 292: case SDLK_3: return 0x4C;
! 293: case SDLK_4: return 0x4D;
! 294: case SDLK_7: return 0x4E;
! 295: case SDLK_6: return 0x4F;
! 296: case SDLK_5: return 0x50;
! 297:
! 298: /* Special Keys */
! 299: case SDLK_F10:
! 300: case SDLK_DELETE: return 0x58; /* Power */
! 301: case SDLK_F5:
! 302: case SDLK_END: return 0x02; /* Sound down */
! 303: case SDLK_F6:
! 304: case SDLK_HOME: return 0x1a; /* Sound up */
! 305: case SDLK_F1:
! 306: case SDLK_PAGEDOWN: return 0x01; /* Brightness down */
! 307: case SDLK_F2:
! 308: case SDLK_PAGEUP: return 0x19; /* Brightness up */
1.1.1.2 root 309:
1.1.1.4 ! root 310:
! 311: default: return 0x00;
1.1.1.2 root 312: break;
1.1.1.4 ! root 313: }
! 314: }
! 315:
! 316:
! 317: /* These functions translate the key symbols provided by SDL to
! 318: * NeXT modifier bits.
! 319: */
! 320:
! 321: Uint8 Keymap_Keydown_GetModFromSymbol(SDL_Keycode sdl_modifier) {
! 322:
! 323: switch (sdl_modifier) {
! 324: case SDLK_LCTRL:
! 325: case SDLK_RCTRL:
! 326: modifiers|=0x01;
1.1.1.2 root 327: break;
1.1.1.4 ! root 328: case SDLK_LSHIFT:
! 329: modifiers|=0x02;
1.1.1.2 root 330: break;
1.1.1.4 ! root 331: case SDLK_RSHIFT:
! 332: modifiers|=0x04;
1.1.1.2 root 333: break;
1.1.1.4 ! root 334: case SDLK_LGUI:
! 335: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x20:0x08;
1.1.1.2 root 336: break;
1.1.1.4 ! root 337: case SDLK_RGUI:
! 338: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x40:0x10;
1.1.1.2 root 339: break;
1.1.1.4 ! root 340: case SDLK_LALT:
! 341: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x08:0x20;
1.1.1.2 root 342: break;
1.1.1.4 ! root 343: case SDLK_RALT:
! 344: modifiers|=ConfigureParams.Keyboard.bSwapCmdAlt?0x10:0x40;
1.1.1.2 root 345: break;
1.1.1.4 ! root 346: case SDLK_CAPSLOCK:
! 347: capslock=capslock?false:true;
! 348: break;
! 349: default:
1.1.1.2 root 350: break;
351: }
1.1.1.4 ! root 352:
! 353: return modifiers|(capslock?0x02:0x00);
1.1.1.2 root 354: }
355:
1.1.1.4 ! root 356: Uint8 Keymap_Keyup_GetModFromSymbol(SDL_Keycode sdl_modifier) {
! 357:
! 358: switch (sdl_modifier) {
! 359: case SDLK_LCTRL:
! 360: case SDLK_RCTRL:
! 361: modifiers&=~0x01;
1.1.1.2 root 362: break;
1.1.1.4 ! root 363: case SDLK_LSHIFT:
! 364: modifiers&=~0x02;
1.1.1.2 root 365: break;
1.1.1.4 ! root 366: case SDLK_RSHIFT:
! 367: modifiers&=~0x04;
1.1.1.2 root 368: break;
1.1.1.4 ! root 369: case SDLK_LGUI:
! 370: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x20:0x08);
1.1.1.2 root 371: break;
1.1.1.4 ! root 372: case SDLK_RGUI:
! 373: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x40:0x10);
1.1.1.2 root 374: break;
1.1.1.4 ! root 375: case SDLK_LALT:
! 376: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x08:0x20);
1.1.1.2 root 377: break;
1.1.1.4 ! root 378: case SDLK_RALT:
! 379: modifiers&=~(ConfigureParams.Keyboard.bSwapCmdAlt?0x10:0x40);
1.1.1.2 root 380: break;
1.1.1.4 ! root 381: case SDLK_CAPSLOCK:
! 382: //capslock=false;
1.1.1.2 root 383: break;
1.1.1.4 ! root 384: default:
1.1.1.2 root 385: break;
386: }
1.1.1.4 ! root 387:
! 388: return modifiers|(capslock?0x02:0x00);
1.1.1.2 root 389: }
1.1 root 390:
391:
392: /*-----------------------------------------------------------------------*/
393: /**
1.1.1.4 ! root 394: * User pressed key down
1.1 root 395: */
1.1.1.4 ! root 396: void Keymap_KeyDown(SDL_Keysym *sdlkey)
1.1 root 397: {
1.1.1.4 ! root 398: Uint8 next_mod, next_key;
1.1 root 399:
1.1.1.4 ! root 400: if (ShortCut_CheckKeys(sdlkey->mod, sdlkey->sym, 1)) { // Check if we pressed a shortcut
! 401: ShortCut_ActKey();
! 402: return;
! 403: }
! 404:
! 405: if (ConfigureParams.Keyboard.nKeymapType==KEYMAP_SYMBOLIC) {
! 406: next_key = Keymap_GetKeyFromSymbol(sdlkey->sym);
! 407: next_mod = Keymap_Keydown_GetModFromSymbol(sdlkey->sym);
! 408: } else {
! 409: next_key = Keymap_GetKeyFromScancode(sdlkey->scancode);
! 410: next_mod = Keymap_Keydown_GetModFromScancode(sdlkey->scancode);
! 411: }
! 412:
! 413: Log_Printf(LOG_KEYMAP_LEVEL, "[Keymap] NeXT Keycode: $%02x, Modifiers: $%02x\n", next_key, next_mod);
! 414:
! 415: kms_keydown(next_mod, next_key);
1.1 root 416: }
417:
418:
419: /*-----------------------------------------------------------------------*/
420: /**
421: * User released key
422: */
1.1.1.4 ! root 423: void Keymap_KeyUp(SDL_Keysym *sdlkey)
1.1 root 424: {
1.1.1.4 ! root 425: Uint8 next_mod, next_key;
1.1 root 426:
1.1.1.4 ! root 427: if (ShortCut_CheckKeys(sdlkey->mod, sdlkey->sym, 0))
1.1 root 428: return;
1.1.1.4 ! root 429:
! 430: if (ConfigureParams.Keyboard.nKeymapType==KEYMAP_SYMBOLIC) {
! 431: next_key = Keymap_GetKeyFromSymbol(sdlkey->sym);
! 432: next_mod = Keymap_Keyup_GetModFromSymbol(sdlkey->sym);
! 433: } else {
! 434: next_key = Keymap_GetKeyFromScancode(sdlkey->scancode);
! 435: next_mod = Keymap_Keyup_GetModFromScancode(sdlkey->scancode);
! 436: }
! 437:
! 438: Log_Printf(LOG_KEYMAP_LEVEL, "[Keymap] NeXT Keycode: $%02x, Modifiers: $%02x\n", next_key, next_mod);
! 439:
! 440: kms_keyup(next_mod, next_key);
1.1 root 441: }
442:
443: /*-----------------------------------------------------------------------*/
444: /**
445: * Simulate press or release of a key corresponding to given character
446: */
447: void Keymap_SimulateCharacter(char asckey, bool press)
448: {
1.1.1.4 ! root 449: SDL_Keysym sdlkey;
1.1 root 450:
451: sdlkey.mod = KMOD_NONE;
452: sdlkey.scancode = 0;
453: if (isupper(asckey)) {
454: if (press) {
455: sdlkey.sym = SDLK_LSHIFT;
456: Keymap_KeyDown(&sdlkey);
457: }
458: sdlkey.sym = tolower(asckey);
459: sdlkey.mod = KMOD_LSHIFT;
460: } else {
461: sdlkey.sym = asckey;
462: }
463: if (press) {
464: Keymap_KeyDown(&sdlkey);
465: } else {
466: Keymap_KeyUp(&sdlkey);
467: if (isupper(asckey)) {
468: sdlkey.sym = SDLK_LSHIFT;
469: Keymap_KeyUp(&sdlkey);
470: }
471: }
472: }
1.1.1.4 ! root 473:
! 474:
! 475: /*-----------------------------------------------------------------------*/
! 476: /**
! 477: * User moved mouse
! 478: */
! 479: void Keymap_MouseMove(int dx, int dy, float lin, float exp)
! 480: {
! 481: static bool s_left=false;
! 482: static bool s_up=false;
! 483: static float s_fdx=0.0;
! 484: static float s_fdy=0.0;
! 485:
! 486: bool left=false;
! 487: bool up=false;
! 488: float fdx;
! 489: float fdy;
! 490:
! 491: if ((dx!=0) || (dy!=0)) {
! 492: /* Remove the sign */
! 493: if (dx<0) {
! 494: dx=-dx;
! 495: left=true;
! 496: }
! 497: if (dy<0) {
! 498: dy=-dy;
! 499: up=true;
! 500: }
! 501:
! 502: /* Exponential adjustmend */
! 503: fdx = pow(dx, exp);
! 504: fdy = pow(dy, exp);
! 505:
! 506: /* Linear adjustment */
! 507: fdx *= lin;
! 508: fdy *= lin;
! 509:
! 510: /* Add residuals */
! 511: if (left==s_left) {
! 512: s_fdx+=fdx;
! 513: } else {
! 514: s_fdx=fdx;
! 515: s_left=left;
! 516: }
! 517: if (up==s_up) {
! 518: s_fdy+=fdy;
! 519: } else {
! 520: s_fdy=fdy;
! 521: s_up=up;
! 522: }
! 523:
! 524: /* Convert to integer and save residuals */
! 525: dx=s_fdx;
! 526: s_fdx-=dx;
! 527: dy=s_fdy;
! 528: s_fdy-=dy;
! 529: //printf("adjusted: dx=%i, dy=%i\n",dx,dy);
! 530: kms_mouse_move(dx, left, dy, up);
! 531: }
! 532: }
! 533:
! 534: /*-----------------------------------------------------------------------*/
! 535: /**
! 536: * User pressed mouse button
! 537: */
! 538: void Keymap_MouseDown(bool left)
! 539: {
! 540: kms_mouse_button(left,true);
! 541: }
! 542:
! 543: /*-----------------------------------------------------------------------*/
! 544: /**
! 545: * User released mouse button
! 546: */
! 547: void Keymap_MouseUp(bool left)
! 548: {
! 549: kms_mouse_button(left,false);
! 550: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.