* EventInfo.cs, AglContext.cs, MacOSKeyMap.cs, Application.cs,
CarbonInput.cs, CarbonGLNative.cs, MacOSException.cs,
CarbonBindings/Agl.cs, CarbonBindings/CarbonAPI.cs,
CarbonBindings/MacOSKeys.cs, CarbonBindings/SpeechChannel.cs,
CarbonBindings/CoreFoundation.cs,
CarbonBindings/QuartzDisplayServicesAPI.cs:
Normalized licensing information.
2010-11-26 12:41:45 +01:00
|
|
|
#region License
|
2009-02-22 11:43:35 +01:00
|
|
|
//
|
* EventInfo.cs, AglContext.cs, MacOSKeyMap.cs, Application.cs,
CarbonInput.cs, CarbonGLNative.cs, MacOSException.cs,
CarbonBindings/Agl.cs, CarbonBindings/CarbonAPI.cs,
CarbonBindings/MacOSKeys.cs, CarbonBindings/SpeechChannel.cs,
CarbonBindings/CoreFoundation.cs,
CarbonBindings/QuartzDisplayServicesAPI.cs:
Normalized licensing information.
2010-11-26 12:41:45 +01:00
|
|
|
// The Open Toolkit Library License
|
2009-02-22 11:43:35 +01:00
|
|
|
//
|
* EventInfo.cs, AglContext.cs, MacOSKeyMap.cs, Application.cs,
CarbonInput.cs, CarbonGLNative.cs, MacOSException.cs,
CarbonBindings/Agl.cs, CarbonBindings/CarbonAPI.cs,
CarbonBindings/MacOSKeys.cs, CarbonBindings/SpeechChannel.cs,
CarbonBindings/CoreFoundation.cs,
CarbonBindings/QuartzDisplayServicesAPI.cs:
Normalized licensing information.
2010-11-26 12:41:45 +01:00
|
|
|
// Copyright (c) 2006 - 2010 the Open Toolkit library.
|
|
|
|
//
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights to
|
|
|
|
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
// the Software, and to permit persons to whom the Software is furnished to do
|
|
|
|
// so, subject to the following conditions:
|
|
|
|
//
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
// copies or substantial portions of the Software.
|
2009-02-22 11:43:35 +01:00
|
|
|
//
|
* EventInfo.cs, AglContext.cs, MacOSKeyMap.cs, Application.cs,
CarbonInput.cs, CarbonGLNative.cs, MacOSException.cs,
CarbonBindings/Agl.cs, CarbonBindings/CarbonAPI.cs,
CarbonBindings/MacOSKeys.cs, CarbonBindings/SpeechChannel.cs,
CarbonBindings/CoreFoundation.cs,
CarbonBindings/QuartzDisplayServicesAPI.cs:
Normalized licensing information.
2010-11-26 12:41:45 +01:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
|
|
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
|
|
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
|
|
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
// OTHER DEALINGS IN THE SOFTWARE.
|
2009-02-22 11:43:35 +01:00
|
|
|
//
|
* EventInfo.cs, AglContext.cs, MacOSKeyMap.cs, Application.cs,
CarbonInput.cs, CarbonGLNative.cs, MacOSException.cs,
CarbonBindings/Agl.cs, CarbonBindings/CarbonAPI.cs,
CarbonBindings/MacOSKeys.cs, CarbonBindings/SpeechChannel.cs,
CarbonBindings/CoreFoundation.cs,
CarbonBindings/QuartzDisplayServicesAPI.cs:
Normalized licensing information.
2010-11-26 12:41:45 +01:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
// Created by Erik Ylvisaker on 3/17/08.
|
2009-02-22 11:43:35 +01:00
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
namespace OpenTK.Platform.MacOS.Carbon
|
|
|
|
{
|
2009-06-04 13:21:33 +02:00
|
|
|
internal struct EventInfo
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
|
|
|
internal EventInfo(IntPtr eventRef)
|
|
|
|
{
|
|
|
|
this._eventClass = API.GetEventClass(eventRef);
|
|
|
|
this._eventKind = API.GetEventKind(eventRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint _eventKind;
|
|
|
|
EventClass _eventClass;
|
|
|
|
|
2010-11-02 20:49:24 +01:00
|
|
|
public EventClass EventClass
|
|
|
|
{
|
|
|
|
get { return _eventClass; }
|
|
|
|
}
|
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
public WindowEventKind WindowEventKind
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (EventClass == EventClass.Window)
|
2010-11-02 20:49:24 +01:00
|
|
|
return (WindowEventKind)_eventKind;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
|
|
|
throw new InvalidCastException("Event is not a Window event.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public KeyboardEventKind KeyboardEventKind
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (EventClass == EventClass.Keyboard)
|
2010-11-02 20:49:24 +01:00
|
|
|
return (KeyboardEventKind)_eventKind;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
|
|
|
throw new InvalidCastException("Event is not a Keyboard event.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public MouseEventKind MouseEventKind
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (EventClass == EventClass.Mouse)
|
2010-11-02 20:49:24 +01:00
|
|
|
return (MouseEventKind)_eventKind;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
|
|
|
throw new InvalidCastException("Event is not an Mouse event.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public AppEventKind AppEventKind
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (EventClass == EventClass.Application)
|
2010-11-02 20:49:24 +01:00
|
|
|
return (AppEventKind)_eventKind;
|
2009-02-22 11:43:35 +01:00
|
|
|
else
|
|
|
|
throw new InvalidCastException("Event is not an Application event.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2010-11-02 20:49:24 +01:00
|
|
|
switch (EventClass)
|
2009-02-22 11:43:35 +01:00
|
|
|
{
|
2010-11-02 20:49:24 +01:00
|
|
|
case EventClass.Application:
|
|
|
|
return "Event: App " + AppEventKind.ToString();
|
|
|
|
case EventClass.Keyboard:
|
|
|
|
return "Event: Keyboard " + KeyboardEventKind.ToString();
|
|
|
|
case EventClass.Mouse:
|
|
|
|
return "Event: Mouse " + MouseEventKind.ToString();
|
|
|
|
case EventClass.Window:
|
|
|
|
return "Event: Window " + WindowEventKind.ToString();
|
2009-02-22 11:43:35 +01:00
|
|
|
}
|
2010-11-02 20:49:24 +01:00
|
|
|
|
2009-02-22 11:43:35 +01:00
|
|
|
return "Event: Unknown Class " + EventClass.ToString() + " kind: " + _eventKind.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|