コード例 #1
0
ファイル: Tape.cpp プロジェクト: DavidKnight247/simcoupe
bool Tape::InFEHook ()
{
    // Are we at the port read in the ROM tape edge routine?
    if (PC == 0x2053)
    {
        // Ensure the tape is playing
        Play();

        // Traps enabled and accelerating loading speed?
        if (GetOption(tapetraps) && GetOption(turbotape))
        {
            // Fetch the time until the next tape edge
            DWORD dwTime = GetEventTime(evtTapeEdge);

            // Simulate the edge code to advance to the next edge
            // Return to normal processing if C hits 255 (no edge found) or the ear bit has changed
            while (dwTime > 48 && C < 0xff && !((keyboard ^ B) & BORD_EAR_MASK))
            {
                C += 1;
                R7 += 7;
                g_dwCycleCounter += 48;
                dwTime -= 48;
                PC = 0x2051;
            }
        }
    }

    return false;
}
コード例 #2
0
ファイル: toplevel.cpp プロジェクト: Duion/Torsion
static pascal OSStatus WindowEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
    OSStatus result = eventNotHandledErr ;
    OSStatus err = noErr ;

    UInt32        attributes;
    WindowRef windowRef ;
    wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;

    GetEventParameter( event, kEventParamDirectObject, typeWindowRef, NULL,
        sizeof( WindowRef ), NULL, &windowRef );

    switch( GetEventKind( event ) )
    {
        case kEventWindowUpdate :
            if ( !wxPendingDelete.Member(toplevelWindow) )
                toplevelWindow->MacUpdate( EventTimeToTicks( GetEventTime( event ) ) ) ;
            result = noErr ;
            break ;
        case kEventWindowActivated :
                toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , true) ;
            result = noErr ;
            break ;
        case kEventWindowDeactivated :
                toplevelWindow->MacActivate( EventTimeToTicks( GetEventTime( event ) ) , false) ;
            result = noErr ;
            break ;
    	case kEventWindowShown :
    		toplevelWindow->Refresh() ;
    		result = noErr ;
    		break ;
        case kEventWindowClose :
                toplevelWindow->Close() ;
            result = noErr ;
            break ;
        case kEventWindowBoundsChanged :
            err = GetEventParameter( event, kEventParamAttributes, typeUInt32,
                        NULL, sizeof( UInt32 ), NULL, &attributes );
            if ( err == noErr )
            {
                Rect newContentRect ;

                GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL,
                    sizeof( newContentRect ), NULL, &newContentRect );

                toplevelWindow->SetSize( newContentRect.left , newContentRect.top ,
                    newContentRect.right - newContentRect.left ,
                    newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);

                result = noErr;
            }
            break ;
        case kEventWindowBoundsChanging :
            err = GetEventParameter( event, kEventParamAttributes, typeUInt32,
                        NULL, sizeof( UInt32 ), NULL, &attributes );
            if ( err == noErr )
            {
                Rect newContentRect ;

                GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL,
                    sizeof( newContentRect ), NULL, &newContentRect );

                wxSize formerSize = toplevelWindow->GetSize() ;

                if ( (attributes & kWindowBoundsChangeSizeChanged ) || 
                    ( attributes & kWindowBoundsChangeOriginChanged ) )
                    toplevelWindow->SetSize( newContentRect.left , newContentRect.top ,
                        newContentRect.right - newContentRect.left ,
                        newContentRect.bottom - newContentRect.top, wxSIZE_USE_EXISTING);
    
                int x , y , w , h ;
                toplevelWindow->GetPosition( &x , &y ) ;
                toplevelWindow->GetSize( &w , &h ) ;
                Rect adjustedRect  = { y , x , y + h , x + w } ;

                if ( !EqualRect( &newContentRect , &adjustedRect ) )
                {
                    SetEventParameter( event , kEventParamCurrentBounds , typeQDRectangle, sizeof( adjustedRect ) , &adjustedRect ) ;
                }
                
                if ( toplevelWindow->GetSize() != formerSize )
                    toplevelWindow->Update() ;
        
                result = noErr ;
            }
            break ;
        default :
            break ;
    }
    return result ;
}
コード例 #3
0
ファイル: toplevel.cpp プロジェクト: Duion/Torsion
static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
    OSStatus result = eventNotHandledErr ;

    wxWindow* focus = wxWindow::FindFocus() ;
    char charCode ;
    UInt32 keyCode ;
    UInt32 modifiers ;
    Point point ;
    UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;

    GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL,sizeof(char), NULL,&charCode );
    GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL,  sizeof(UInt32), NULL, &keyCode );
       GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
    GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
        sizeof( Point ), NULL, &point );

    UInt32 message = (keyCode << 8) + charCode;
    switch( GetEventKind( event ) )
    {
        case kEventRawKeyRepeat :
        case kEventRawKeyDown :
            {
                WXEVENTREF formerEvent = wxTheApp->MacGetCurrentEvent() ;
                WXEVENTHANDLERCALLREF formerHandler = wxTheApp->MacGetCurrentEventHandlerCallRef() ;
                wxTheApp->MacSetCurrentEvent( event , handler ) ;
                if ( (focus != NULL) && wxTheApp->MacSendKeyDownEvent(
                    focus , message , modifiers , when , point.h , point.v ) )
                {
                    result = noErr ;
                }
                wxTheApp->MacSetCurrentEvent( formerEvent , formerHandler ) ;
            }
            break ;
        case kEventRawKeyUp :
            if ( (focus != NULL) && wxTheApp->MacSendKeyUpEvent(
                focus , message , modifiers , when , point.h , point.v ) )
            {
                result = noErr ;
            }
            break ;
        case kEventRawKeyModifiersChanged :
            {
                wxKeyEvent event(wxEVT_KEY_DOWN);

                event.m_shiftDown = modifiers & shiftKey;
                event.m_controlDown = modifiers & controlKey;
                event.m_altDown = modifiers & optionKey;
                event.m_metaDown = modifiers & cmdKey;

                event.m_x = point.h;
                event.m_y = point.v;
                event.SetTimestamp(when);
                wxWindow* focus = wxWindow::FindFocus() ;
                event.SetEventObject(focus);

                if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & controlKey )
                {
                    event.m_keyCode = WXK_CONTROL ;
                    event.SetEventType( ( modifiers & controlKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
                    focus->GetEventHandler()->ProcessEvent( event ) ;
                }
                if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & shiftKey )
                {
                    event.m_keyCode = WXK_SHIFT ;
                    event.SetEventType( ( modifiers & shiftKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
                    focus->GetEventHandler()->ProcessEvent( event ) ;
                }
                if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & optionKey )
                {
                    event.m_keyCode = WXK_ALT ;
                    event.SetEventType( ( modifiers & optionKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
                    focus->GetEventHandler()->ProcessEvent( event ) ;
                }
                if ( focus && (modifiers ^ wxTheApp->s_lastModifiers ) & cmdKey )
                {
                    event.m_keyCode = WXK_COMMAND ;
                    event.SetEventType( ( modifiers & cmdKey ) ? wxEVT_KEY_DOWN : wxEVT_KEY_UP ) ;
                    focus->GetEventHandler()->ProcessEvent( event ) ;
                }
                wxTheApp->s_lastModifiers = modifiers ;
            }
             break ;
    }

    return result ;
}
コード例 #4
0
ファイル: toplevel.cpp プロジェクト: Duion/Torsion
pascal OSStatus MouseEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
    OSStatus result = eventNotHandledErr ;

    wxTopLevelWindowMac* toplevelWindow = (wxTopLevelWindowMac*) data ;
    Point point ;
    UInt32 modifiers = 0;
    EventMouseButton button = 0 ;
    UInt32 click = 0 ;

    GetEventParameter( event, kEventParamMouseLocation, typeQDPoint, NULL,
        sizeof( Point ), NULL, &point );
    GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL,
        sizeof( UInt32 ), NULL, &modifiers );
    GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
        sizeof( EventMouseButton ), NULL, &button );
    GetEventParameter( event, kEventParamClickCount, typeUInt32, NULL,
        sizeof( UInt32 ), NULL, &click );

    if ( button == 0 || GetEventKind( event ) == kEventMouseUp )
        modifiers += btnState ;

	// temporary hack to support true two button mouse
	if ( button == kEventMouseButtonSecondary )
	{
		modifiers |= controlKey ;
	}
    WindowRef window ;
    short windowPart = ::FindWindow(point, &window);

    // either we really are active or we are capturing mouse events

    if ( (IsWindowActive(window) && windowPart == inContent) || 
        (wxTheApp->s_captureWindow && wxTheApp->s_captureWindow->MacGetTopLevelWindow() == toplevelWindow) )
    {
        switch ( GetEventKind( event ) )
        {
            case kEventMouseDown :
                toplevelWindow->MacFireMouseEvent( mouseDown , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                result = noErr ;
                break ;
            case kEventMouseUp :
                toplevelWindow->MacFireMouseEvent( mouseUp , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                result = noErr ;
                break ;
            case kEventMouseMoved :
                wxTheApp->MacHandleMouseMovedEvent( point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                result = noErr ;
                break ;
            case kEventMouseDragged :
                toplevelWindow->MacFireMouseEvent( nullEvent , point.h , point.v , modifiers , EventTimeToTicks( GetEventTime( event ) ) ) ;
                result = noErr ;
                break ;
            case kEventMouseWheelMoved :
                {
                    //bClearTooltip = false;
                    EventMouseWheelAxis axis = kEventMouseWheelAxisY;
                    SInt32 delta = 0;
                    Point mouseLoc = {0, 0};
                    if (::GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis,
                                        NULL, sizeof(EventMouseWheelAxis), NULL, &axis) == noErr &&
                        ::GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger,
                                        NULL, sizeof(SInt32), NULL, &delta) == noErr &&
                        ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint,
                                        NULL, sizeof(Point), NULL, &mouseLoc) == noErr)
                    {
                        wxMouseEvent wheelEvent(wxEVT_MOUSEWHEEL);
                       
                        wheelEvent.m_x = mouseLoc.h;
                        wheelEvent.m_y = mouseLoc.v;
                       
                        wheelEvent.m_wheelRotation = delta;
                        wheelEvent.m_wheelDelta = 1;
                        wheelEvent.m_linesPerAction = 1;

                        wxWindow* currentMouseWindow = NULL;
                        wxWindow::MacGetWindowFromPoint(wxPoint(mouseLoc.h, mouseLoc.v), &currentMouseWindow);
                       
                        if (currentMouseWindow)
                        {
                            currentMouseWindow->GetEventHandler()->ProcessEvent(wheelEvent);
                            result = noErr;
                        }
                    }
                }
                break ;
            default :
                break ;
        }
    }

    return result ;


}
コード例 #5
0
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// appMouseEventHandler
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
// This event handler is installed by Carbon_InitMouse (below) to respond to
// Carbon events that affect the application as a whole. It does all the work
// of keeping track of mouse deltas and button states.
//
// Caveats: mouse deltas are only supported under X so far. Also, under Carbon 9
// pressing any mouse button returns a button value of 1, e.g. the main mouse button
//ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
static pascal OSStatus appMouseEventHandler( EventHandlerCallRef myHandler, EventRef event, void* userData ) {
#pragma unused (myHandler, userData)
    OSStatus result = eventNotHandledErr;
    EventMouseButton theButton;
    Point mouseDelta;
    SInt32 mouseWheelDelta;
    UInt32 eventKind;

    if ( !sMouseEnabled ) {
        return eventNotHandledErr;
    }

#if MAC_Q3
    // MLTE handles some mouse events, so we pass them along if the console is frontmost
    if ( ConsoleWindowIsFrontmost() ) {
        return eventNotHandledErr;
    }
#endif

    eventKind = GetEventKind( event );

    switch ( eventKind )
    {
    case kEventMouseMoved:
    case kEventMouseDragged:
    {
        EventTime evtTime = GetEventTime( event );

        result = GetEventParameter( event, kEventParamMouseDelta, typeQDPoint, NULL,
                                    sizeof( mouseDelta ), NULL, &mouseDelta );

        if ( evtTime == sMouseDeltaTime ) {
            return eventNotHandledErr;
        }

        // Clamp any overflow
        if ( (SInt32) sMouseDelta.h + (SInt32) mouseDelta.h > 32767 ) {
            sMouseDelta.h = 32767;
        } else if ( (SInt32) sMouseDelta.h + (SInt32) mouseDelta.h < -32767 ) {
            sMouseDelta.h = -32767;
        } else {
            sMouseDelta.h += mouseDelta.h;
        }

        if ( (SInt32) sMouseDelta.v + (SInt32) mouseDelta.v > 32767 ) {
            sMouseDelta.h = 32767;
        } else if ( (SInt32) sMouseDelta.v + (SInt32) mouseDelta.v < -32767 ) {
            sMouseDelta.v = -32767;
        } else {
            sMouseDelta.v += mouseDelta.v;
        }

        sMouseDeltaTime = evtTime;

        // We handled the event, eat it
        result = noErr;
        break;
    }
    case kEventMouseDown:
    {
        (void)GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
                                 sizeof( theButton ), NULL, &theButton );

        // the button # is 1-based, our array is 0-based
        theButton -= 1;

        if ( theButton < MAX_BUTTONS ) {
            EventTime evtTime = GetEventTime( event );

            if ( evtTime != sMouseTime[theButton] ) {
                sMouseButtons[theButton] = 1;
                sMouseTime[theButton] = evtTime;

                // We handled the event, eat it
                result = noErr;
            }
        }
        break;
    }
    case kEventMouseUp:
    {
        (void)GetEventParameter( event, kEventParamMouseButton, typeMouseButton, NULL,
                                 sizeof( theButton ), NULL, &theButton );

        // the button # is 1-based, our array is 0-based
        theButton -= 1;

        if ( theButton < MAX_BUTTONS ) {
            EventTime evtTime = GetEventTime( event );

            if ( evtTime != sMouseTime[theButton] ) {
                sMouseButtons[theButton] = 0;
                sMouseTime[theButton] = evtTime;

                // We handled the event, eat it
                result = noErr;
            }
        }
        break;
    }
    case kEventMouseWheelMoved:
    {
        EventTime evtTime = GetEventTime( event );

        result = GetEventParameter( event, kEventParamMouseWheelDelta, typeSInt32, NULL,
                                    sizeof( mouseWheelDelta ), NULL, &mouseWheelDelta );

        if ( evtTime == sMouseWheelDeltaTime ) {
            return eventNotHandledErr;
        }

        // Clamp any overflow. Note that the delta is already a SInt32, so we're
        // clamping very prematurely. It should never be an issue though.
        if ( sMouseWheelDelta + mouseWheelDelta > 32767 ) {
            sMouseWheelDelta = 32767;
        } else {
            sMouseWheelDelta += mouseWheelDelta;
        }

        sMouseWheelDeltaTime = evtTime;

        // We handled the event, eat it
        result = noErr;
        break;
    }
    }

    return result;
}