|
|
1.1 root 1:
2: #include <SDL/SDL_endian.h>
3: #include <SDL/SDL_mouse.h>
4:
5: #include "main.h"
6: #include "input.h"
1.1.1.2 ! root 7: #include "../m68000.h"
1.1 root 8: #include "shortcut.h"
1.1.1.2 ! root 9: #include "configuration.h"
1.1 root 10:
11: INPUT input;
12:
1.1.1.2 ! root 13: void Call_GetMouseInput ()
1.1 root 14: {
1.1.1.2 ! root 15: short *mouse_mov, *mouse_abs;
! 16: unsigned long params;
! 17: int div;
! 18:
! 19: /* doesn't work. fix for 1x screen */
! 20: div = (ConfigureParams.Screen.ChosenDisplayMode ? 2 : 1);
! 21: params = GetReg (REG_A7);
! 22: params -= SIZE_WORD;
1.1 root 23: /* Pointer passed to struct:
24: * word mouse_motion_x
25: * word mouse_motion_y
26: * word mouse_buttons
27: */
28:
1.1.1.2 ! root 29: mouse_mov = (short*)(STRam + STMemory_ReadLong (params+SIZE_WORD));
! 30: mouse_abs = (short*)(STRam + STMemory_ReadLong (params+SIZE_WORD+SIZE_LONG));
1.1 root 31:
1.1.1.2 ! root 32: mouse_mov[0] = SDL_SwapBE16 (SDL_SwapBE16 (mouse_mov[0]) + input.motion_x);
! 33: mouse_mov[1] = SDL_SwapBE16 (SDL_SwapBE16 (mouse_mov[1]) + input.motion_y);
1.1 root 34:
1.1.1.2 ! root 35: mouse_abs[0] = SDL_SwapBE16 (input.abs_x/div);
! 36: mouse_abs[1] = SDL_SwapBE16 (input.abs_y/div);
! 37:
! 38: //if (input.mbuf_head != input.mbuf_tail) {
! 39: // mouse_mov[2] = SDL_SwapBE16 (0xf8 | input.mousebut_buf [input.mbuf_head++]);
! 40: // input.mbuf_head %= SIZE_KEYBUF;
! 41: //} else {
! 42: mouse_mov[2] = SDL_SwapBE16 (0xf8 | input.cur_mousebut_state);
! 43: //}
1.1 root 44:
45: input.motion_x = input.motion_y = 0;
46: }
47:
1.1.1.2 ! root 48: void Call_GetKeyboardEvent ()
1.1 root 49: {
50: if ((input.buf_head) != (input.buf_tail)) {
1.1.1.2 ! root 51: SetReg (REG_D0, input.key_buf [input.buf_head++]);
1.1 root 52: input.buf_head %= SIZE_KEYBUF;
53: } else {
1.1.1.2 ! root 54: SetReg (REG_D0, 0);
1.1 root 55: }
56: }
57:
58:
59:
60:
61: /* Interrupt as required */
62: void Input_Update ()
63: {
64: if ((input.buf_head != input.buf_tail) ||
65: (input.motion_x) ||
66: (input.motion_y) ||
67: (input.mbuf_head != input.mbuf_tail)) {
1.1.1.2 ! root 68: //FlagException (1);
1.1 root 69: }
70: }
71:
72: void Input_PressSTKey (unsigned char ScanCode, BOOL bPress)
73: {
74: if (!bPress) ScanCode |= 0x80;
75: input.key_buf [input.buf_tail++] = ScanCode;
76: input.buf_tail %= SIZE_KEYBUF;
77: }
78:
79: void Input_MousePress (int button)
80: {
81: if (button == SDL_BUTTON_RIGHT) input.cur_mousebut_state |= 0x1;
82: else if (button == SDL_BUTTON_LEFT) input.cur_mousebut_state |= 0x2;
83: else if (button == SDL_BUTTON_MIDDLE) {
84: /* middle mouse button toggles mouse grab */
85: ShortCut_MouseMode();
86: return;
87: } else {
88: return;
89: }
90: input.mousebut_buf [input.mbuf_tail++] = input.cur_mousebut_state;
91: input.mbuf_tail %= SIZE_MOUSEBUF;
92: }
93:
94: void Input_MouseRelease (int button)
95: {
96: if (button == SDL_BUTTON_RIGHT) input.cur_mousebut_state &= ~0x1;
97: else if (button == SDL_BUTTON_LEFT) input.cur_mousebut_state &= ~0x2;
98: else return;
99: input.mousebut_buf [input.mbuf_tail++] = input.cur_mousebut_state;
100: input.mbuf_tail %= SIZE_MOUSEBUF;
101: }
102:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.