Annotation of frontvm/hardware/input.c, revision 1.1

1.1     ! root        1: 
        !             2: #include <SDL/SDL_endian.h>
        !             3: #include <SDL/SDL_mouse.h>
        !             4: 
        !             5: #include "main.h"
        !             6: #include "decode.h"
        !             7: #include "input.h"
        !             8: #include "m68000.h"
        !             9: #include "stMemory.h"
        !            10: #include "hatari-glue.h"
        !            11: #include "shortcut.h"
        !            12: 
        !            13: INPUT input;
        !            14: 
        !            15: void Call_GetMouseInput (unsigned long params)
        !            16: {
        !            17:        short *mouse_poop;
        !            18:        /* Pointer passed to struct:
        !            19:         *   word mouse_motion_x
        !            20:         *   word mouse_motion_y
        !            21:         *   word mouse_buttons
        !            22:         */
        !            23: 
        !            24:        mouse_poop = (short*)(STRam + STMemory_ReadLong (params+SIZE_WORD));
        !            25: 
        !            26:        mouse_poop[0] = SDL_SwapBE16 (SDL_SwapBE16 (mouse_poop[0]) + input.motion_x);
        !            27:        mouse_poop[1] = SDL_SwapBE16 (SDL_SwapBE16 (mouse_poop[1]) + input.motion_y);
        !            28:        
        !            29:        if (input.mbuf_head != input.mbuf_tail) {
        !            30:                mouse_poop[2] = SDL_SwapBE16 (0xf8 | input.mousebut_buf [input.mbuf_head++]);
        !            31:                input.mbuf_head %= SIZE_KEYBUF;
        !            32:        } else {
        !            33:                mouse_poop[2] = SDL_SwapBE16 (0xf8 | input.cur_mousebut_state);
        !            34:        }
        !            35:        
        !            36:        input.motion_x = input.motion_y = 0;
        !            37: }
        !            38: 
        !            39: void Call_GetKeyboardEvent (unsigned long params)
        !            40: {
        !            41:        if ((input.buf_head) != (input.buf_tail)) {
        !            42:                Regs[REG_D0] = input.key_buf [input.buf_head++];
        !            43:                input.buf_head %= SIZE_KEYBUF;
        !            44:        } else {
        !            45:                Regs[REG_D0] = 0;
        !            46:        }
        !            47: }
        !            48: 
        !            49: 
        !            50: 
        !            51: 
        !            52: /* Interrupt as required */
        !            53: void Input_Update ()
        !            54: {
        !            55:        if ((input.buf_head != input.buf_tail) ||
        !            56:            (input.motion_x) ||
        !            57:            (input.motion_y) ||
        !            58:            (input.mbuf_head != input.mbuf_tail)) {
        !            59:                MakeSR ();
        !            60:                
        !            61:                if ((5 > FIND_IPL) && (5 > intlev ())) {
        !            62:                        ExceptionVector = EXCEPTION_INPUT;
        !            63:                        M68000_Exception ();
        !            64:                }
        !            65:        }
        !            66: }
        !            67: 
        !            68: void Input_PressSTKey (unsigned char ScanCode, BOOL bPress)
        !            69: {
        !            70:        if (!bPress) ScanCode |= 0x80;
        !            71:        input.key_buf [input.buf_tail++] = ScanCode;
        !            72:        input.buf_tail %= SIZE_KEYBUF;
        !            73: }
        !            74: 
        !            75: void Input_MousePress (int button)
        !            76: {
        !            77:        if (button == SDL_BUTTON_RIGHT) input.cur_mousebut_state |= 0x1;
        !            78:        else if (button == SDL_BUTTON_LEFT) input.cur_mousebut_state |= 0x2;
        !            79:        else if (button == SDL_BUTTON_MIDDLE) {
        !            80:                /* middle mouse button toggles mouse grab */
        !            81:                ShortCut_MouseMode();
        !            82:                return;
        !            83:        } else {
        !            84:                return;
        !            85:        }
        !            86:        input.mousebut_buf [input.mbuf_tail++] = input.cur_mousebut_state;
        !            87:        input.mbuf_tail %= SIZE_MOUSEBUF;
        !            88: }
        !            89: 
        !            90: void Input_MouseRelease (int button)
        !            91: {
        !            92:        if (button == SDL_BUTTON_RIGHT) input.cur_mousebut_state &= ~0x1;
        !            93:        else if (button == SDL_BUTTON_LEFT) input.cur_mousebut_state &= ~0x2;
        !            94:        else return;
        !            95:        input.mousebut_buf [input.mbuf_tail++] = input.cur_mousebut_state;
        !            96:        input.mbuf_tail %= SIZE_MOUSEBUF;
        !            97: }
        !            98: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.