mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -04:00
Simplify various apis in OpenTK.
This commit is contained in:
parent
12814a308b
commit
09912f3d79
@ -474,7 +474,7 @@ namespace OpenTK
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public KeyboardDevice Keyboard
|
public KeyboardDevice Keyboard
|
||||||
{
|
{
|
||||||
get { return InputDriver.Keyboard.Count > 0 ? InputDriver.Keyboard[0] : null; }
|
get { return InputDriver.Keyboard; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -484,9 +484,8 @@ namespace OpenTK
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the primary Mouse device, or null if no Mouse exists.
|
/// Gets the primary Mouse device, or null if no Mouse exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MouseDevice Mouse
|
public MouseDevice Mouse {
|
||||||
{
|
get { return InputDriver.Mouse; }
|
||||||
get { return InputDriver.Mouse.Count > 0 ? InputDriver.Mouse[0] : null; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -12,9 +12,6 @@ namespace OpenTK.Input {
|
|||||||
|
|
||||||
/// <summary> Defines a common interface for all input devices. </summary>
|
/// <summary> Defines a common interface for all input devices. </summary>
|
||||||
public interface IInputDevice {
|
public interface IInputDevice {
|
||||||
|
|
||||||
/// <summary> Gets a System.String with a unique description of this IInputDevice instance. </summary>
|
|
||||||
string Description { get; }
|
|
||||||
|
|
||||||
/// <summary> Gets an OpenTK.Input.InputDeviceType value, representing the device type of this IInputDevice instance. </summary>
|
/// <summary> Gets an OpenTK.Input.InputDeviceType value, representing the device type of this IInputDevice instance. </summary>
|
||||||
InputDeviceType DeviceType { get; }
|
InputDeviceType DeviceType { get; }
|
||||||
@ -32,10 +29,18 @@ namespace OpenTK.Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Defines the interface for an input driver. </summary>
|
/// <summary> Defines the interface for an input driver. </summary>
|
||||||
public interface IInputDriver : IKeyboardDriver, IMouseDriver, IJoystickDriver, IDisposable {
|
public interface IInputDriver : IJoystickDriver, IDisposable {
|
||||||
|
|
||||||
|
/// <summary> Gets the list of available KeyboardDevices. </summary>
|
||||||
|
KeyboardDevice Keyboard { get; }
|
||||||
|
|
||||||
|
/// <summary> Gets the list of available MouseDevices. </summary>
|
||||||
|
MouseDevice Mouse { get; }
|
||||||
|
|
||||||
/// <summary> Updates the state of the driver. </summary>
|
/// <summary> Updates the state of the driver. </summary>
|
||||||
void Poll();
|
void Poll();
|
||||||
|
|
||||||
|
Point DesktopCursorPos { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Defines the interface for JoystickDevice drivers. </summary>
|
/// <summary> Defines the interface for JoystickDevice drivers. </summary>
|
||||||
@ -44,20 +49,4 @@ namespace OpenTK.Input {
|
|||||||
/// <summary> Gets the list of available JoystickDevices. </summary>
|
/// <summary> Gets the list of available JoystickDevices. </summary>
|
||||||
IList<JoystickDevice> Joysticks { get; }
|
IList<JoystickDevice> Joysticks { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Defines the interface for KeyboardDevice drivers. </summary>
|
|
||||||
public interface IKeyboardDriver {
|
|
||||||
|
|
||||||
/// <summary> Gets the list of available KeyboardDevices. </summary>
|
|
||||||
IList<KeyboardDevice> Keyboard { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> Defines the interface for MouseDevice drivers. </summary>
|
|
||||||
public interface IMouseDriver {
|
|
||||||
|
|
||||||
/// <summary> Gets the list of available MouseDevices. </summary>
|
|
||||||
IList<MouseDevice> Mouse { get; }
|
|
||||||
|
|
||||||
Point DesktopCursorPos { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,7 @@
|
|||||||
|
|
||||||
namespace OpenTK.Input
|
namespace OpenTK.Input
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary> The available keyboard keys. </summary>
|
||||||
/// The available keyboard keys.
|
|
||||||
/// </summary>
|
|
||||||
public enum Key : int
|
public enum Key : int
|
||||||
{
|
{
|
||||||
/// <summary>A key outside the known keys.</summary>
|
/// <summary>A key outside the known keys.</summary>
|
||||||
|
@ -13,11 +13,7 @@ namespace OpenTK.Input
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class KeyboardDevice : IInputDevice
|
public sealed class KeyboardDevice : IInputDevice
|
||||||
{
|
{
|
||||||
//private IKeyboard keyboard;
|
|
||||||
private bool[] keys = new bool[(int)Key.LastKey];
|
private bool[] keys = new bool[(int)Key.LastKey];
|
||||||
private string description;
|
|
||||||
private int numKeys, numFKeys, numLeds;
|
|
||||||
private IntPtr devID;
|
|
||||||
private bool repeat;
|
private bool repeat;
|
||||||
private KeyboardKeyEventArgs args = new KeyboardKeyEventArgs();
|
private KeyboardKeyEventArgs args = new KeyboardKeyEventArgs();
|
||||||
|
|
||||||
@ -57,42 +53,6 @@ namespace OpenTK.Input
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an integer representing the number of keys on this KeyboardDevice.
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfKeys
|
|
||||||
{
|
|
||||||
get { return numKeys; }
|
|
||||||
internal set { numKeys = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an integer representing the number of function keys (F-keys) on this KeyboardDevice.
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfFunctionKeys
|
|
||||||
{
|
|
||||||
get { return numFKeys; }
|
|
||||||
internal set { numFKeys = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating the number of led indicators on this KeyboardDevice.
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfLeds
|
|
||||||
{
|
|
||||||
get { return numLeds; }
|
|
||||||
internal set { numLeds = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an IntPtr representing a device dependent ID.
|
|
||||||
/// </summary>
|
|
||||||
public IntPtr DeviceID
|
|
||||||
{
|
|
||||||
get { return devID; }
|
|
||||||
internal set { devID = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#region public bool KeyRepeat
|
#region public bool KeyRepeat
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -138,51 +98,11 @@ namespace OpenTK.Input
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region --- IInputDevice Members ---
|
public InputDeviceType DeviceType {
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a <see cref="System.String"/> which describes this instance.
|
|
||||||
/// </summary>
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
get { return description; }
|
|
||||||
internal set { description = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the <see cref="InputDeviceType"/> for this instance.
|
|
||||||
/// </summary>
|
|
||||||
public InputDeviceType DeviceType
|
|
||||||
{
|
|
||||||
get { return InputDeviceType.Keyboard; }
|
get { return InputDeviceType.Keyboard; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Public Methods ---
|
|
||||||
|
|
||||||
/// <summary>Returns the hash code for this KeyboardDevice.</summary>
|
|
||||||
/// <returns>A 32-bit signed integer hash code.</returns>
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
//return base.GetHashCode();
|
|
||||||
return (int)(numKeys ^ numFKeys ^ numLeds ^ devID.GetHashCode() ^ description.GetHashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a System.String representing this KeyboardDevice.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A System.String representing this KeyboardDevice.</returns>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
//return base.ToString();
|
|
||||||
return String.Format("ID: {0} ({1}). Keys: {2}, Function keys: {3}, Leds: {4}",
|
|
||||||
DeviceID, Description, NumberOfKeys, NumberOfFunctionKeys, NumberOfLeds);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Internal Methods ---
|
#region --- Internal Methods ---
|
||||||
|
|
||||||
#region internal void ClearKeys()
|
#region internal void ClearKeys()
|
||||||
|
@ -35,90 +35,19 @@ namespace OpenTK.Input
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class MouseDevice : IInputDevice
|
public sealed class MouseDevice : IInputDevice
|
||||||
{
|
{
|
||||||
#region --- Fields ---
|
|
||||||
|
|
||||||
string description;
|
|
||||||
IntPtr id;
|
|
||||||
int numButtons, numWheels;
|
|
||||||
readonly bool[] button_state = new bool[(int)MouseButton.LastButton];
|
readonly bool[] button_state = new bool[(int)MouseButton.LastButton];
|
||||||
float wheel, last_wheel;
|
float wheel, last_wheel;
|
||||||
Point pos = new Point(), last_pos = new Point();
|
Point pos, last_pos;
|
||||||
MouseMoveEventArgs move_args = new MouseMoveEventArgs();
|
MouseMoveEventArgs move_args = new MouseMoveEventArgs();
|
||||||
MouseButtonEventArgs button_args = new MouseButtonEventArgs();
|
MouseButtonEventArgs button_args = new MouseButtonEventArgs();
|
||||||
MouseWheelEventArgs wheel_args = new MouseWheelEventArgs();
|
MouseWheelEventArgs wheel_args = new MouseWheelEventArgs();
|
||||||
|
|
||||||
#endregion
|
public InputDeviceType DeviceType {
|
||||||
|
|
||||||
#region --- IInputDevice Members ---
|
|
||||||
|
|
||||||
#region public string Description
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a string describing this MouseDevice.
|
|
||||||
/// </summary>
|
|
||||||
public string Description
|
|
||||||
{
|
|
||||||
get { return description; }
|
|
||||||
internal set { description = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public InputDeviceType DeviceType
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets a value indicating the InputDeviceType of this InputDevice.
|
|
||||||
/// </summary>
|
|
||||||
public InputDeviceType DeviceType
|
|
||||||
{
|
|
||||||
get { return InputDeviceType.Mouse; }
|
get { return InputDeviceType.Mouse; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region --- Public Members ---
|
#region --- Public Members ---
|
||||||
|
|
||||||
#region public int NumberOfButtons
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an integer representing the number of buttons on this MouseDevice.
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfButtons
|
|
||||||
{
|
|
||||||
get { return numButtons; }
|
|
||||||
internal set { numButtons = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public int NumberOfWheels
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an integer representing the number of wheels on this MouseDevice.
|
|
||||||
/// </summary>
|
|
||||||
public int NumberOfWheels
|
|
||||||
{
|
|
||||||
get { return numWheels; }
|
|
||||||
internal set { numWheels = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public IntPtr DeviceID
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets an IntPtr representing a device dependent ID.
|
|
||||||
/// </summary>
|
|
||||||
public IntPtr DeviceID
|
|
||||||
{
|
|
||||||
get { return id; }
|
|
||||||
internal set { id = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region public int Wheel
|
#region public int Wheel
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -257,30 +186,7 @@ namespace OpenTK.Input
|
|||||||
/// Occurs when one of the mouse wheels is moved.
|
/// Occurs when one of the mouse wheels is moved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<MouseWheelEventArgs> WheelChanged = delegate { };
|
public event EventHandler<MouseWheelEventArgs> WheelChanged = delegate { };
|
||||||
|
|
||||||
#region --- Overrides ---
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Calculates the hash code for this instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public override int GetHashCode()
|
|
||||||
{
|
|
||||||
return (int)(numButtons ^ numWheels ^ id.GetHashCode() ^ description.GetHashCode());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a <see cref="System.String"/> that describes this instance.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>A <see cref="System.String"/> that describes this instance.</returns>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return String.Format("ID: {0} ({1}). Buttons: {2}, Wheels: {3}",
|
|
||||||
DeviceID, Description, NumberOfButtons, NumberOfWheels);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,6 @@
|
|||||||
<Compile Include="Platform\MacOS\CarbonBindings\MacOSKeys.cs" />
|
<Compile Include="Platform\MacOS\CarbonBindings\MacOSKeys.cs" />
|
||||||
<Compile Include="Platform\MacOS\CarbonBindings\QuartzDisplayServicesAPI.cs" />
|
<Compile Include="Platform\MacOS\CarbonBindings\QuartzDisplayServicesAPI.cs" />
|
||||||
<Compile Include="Platform\MacOS\CarbonGLNative.cs" />
|
<Compile Include="Platform\MacOS\CarbonGLNative.cs" />
|
||||||
<Compile Include="Platform\MacOS\CarbonInput.cs" />
|
|
||||||
<Compile Include="Platform\MacOS\CarbonWindowInfo.cs" />
|
<Compile Include="Platform\MacOS\CarbonWindowInfo.cs" />
|
||||||
<Compile Include="Platform\MacOS\EventInfo.cs" />
|
<Compile Include="Platform\MacOS\EventInfo.cs" />
|
||||||
<Compile Include="Platform\MacOS\MacOSException.cs" />
|
<Compile Include="Platform\MacOS\MacOSException.cs" />
|
||||||
|
@ -209,7 +209,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||||||
MouseExited = 9,
|
MouseExited = 9,
|
||||||
WheelMoved = 10,
|
WheelMoved = 10,
|
||||||
}
|
}
|
||||||
internal enum MouseButton : short
|
internal enum MacOSMouseButton : short
|
||||||
{
|
{
|
||||||
Primary = 1,
|
Primary = 1,
|
||||||
Secondary = 2,
|
Secondary = 2,
|
||||||
@ -586,190 +586,110 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||||||
#endregion
|
#endregion
|
||||||
#region --- Getting Event Parameters ---
|
#region --- Getting Event Parameters ---
|
||||||
|
|
||||||
[DllImport(carbon,EntryPoint="CreateEvent")]
|
[DllImport(carbon)]
|
||||||
static extern OSStatus _CreateEvent( IntPtr inAllocator,
|
static extern OSStatus CreateEvent( IntPtr inAllocator,
|
||||||
EventClass inClassID, UInt32 kind, EventTime when,
|
EventClass inClassID, UInt32 kind, EventTime when,
|
||||||
EventAttributes flags,out IntPtr outEvent);
|
EventAttributes flags, out IntPtr outEvent);
|
||||||
|
|
||||||
internal static IntPtr CreateWindowEvent(WindowEventKind kind)
|
internal static IntPtr CreateWindowEvent(WindowEventKind kind) {
|
||||||
{
|
|
||||||
IntPtr retval;
|
IntPtr retval;
|
||||||
|
OSStatus stat = CreateEvent(IntPtr.Zero, EventClass.Window, (uint)kind,
|
||||||
OSStatus stat = _CreateEvent(IntPtr.Zero, EventClass.Window, (uint)kind,
|
0, EventAttributes.kEventAttributeNone, out retval);
|
||||||
0, EventAttributes.kEventAttributeNone, out retval);
|
|
||||||
|
|
||||||
if (stat != OSStatus.NoError)
|
if (stat != OSStatus.NoError)
|
||||||
{
|
|
||||||
throw new MacOSException(stat);
|
throw new MacOSException(stat);
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport(carbon)]
|
[DllImport(carbon)]
|
||||||
static extern OSStatus GetEventParameter(
|
static extern OSStatus GetEventParameter(
|
||||||
IntPtr inEvent, EventParamName inName, EventParamType inDesiredType,
|
IntPtr inEvent, EventParamName inName, EventParamType inDesiredType,
|
||||||
IntPtr outActualType, uint inBufferSize, IntPtr outActualSize, IntPtr outData);
|
IntPtr outActualType, int inBufferSize, IntPtr outActualSize, IntPtr outData);
|
||||||
|
|
||||||
static internal MacOSKeyCode GetEventKeyboardKeyCode(IntPtr inEvent)
|
internal unsafe static MacOSKeyCode GetEventKeyboardKeyCode(IntPtr inEvent) {
|
||||||
{
|
int code;
|
||||||
int code;
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.KeyCode, EventParamType.typeUInt32, IntPtr.Zero,
|
||||||
|
sizeof(uint), IntPtr.Zero, (IntPtr)(void*)&code);
|
||||||
|
|
||||||
unsafe
|
if (result != OSStatus.NoError)
|
||||||
{
|
throw new MacOSException(result);
|
||||||
int* codeAddr = &code;
|
return (MacOSKeyCode)code;
|
||||||
|
}
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
internal unsafe static char GetEventKeyboardChar(IntPtr inEvent) {
|
||||||
EventParamName.KeyCode, EventParamType.typeUInt32, IntPtr.Zero,
|
char code;
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(UInt32)), IntPtr.Zero,
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
(IntPtr) codeAddr);
|
EventParamName.KeyMacCharCode, EventParamType.typeChar, IntPtr.Zero,
|
||||||
|
Marshal.SizeOf(typeof(char)), IntPtr.Zero, (IntPtr)(void*)&code);
|
||||||
|
|
||||||
if (result != OSStatus.NoError)
|
if (result != OSStatus.NoError)
|
||||||
{
|
throw new MacOSException(result);
|
||||||
throw new MacOSException(result);
|
return code;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (MacOSKeyCode)code;
|
internal unsafe static MacOSMouseButton GetEventMouseButton(IntPtr inEvent) {
|
||||||
}
|
int button;
|
||||||
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.MouseButton, EventParamType.typeMouseButton, IntPtr.Zero,
|
||||||
|
sizeof(short), IntPtr.Zero, (IntPtr)(void*)&button);
|
||||||
|
|
||||||
internal static char GetEventKeyboardChar(IntPtr inEvent)
|
if (result != OSStatus.NoError)
|
||||||
{
|
throw new MacOSException(result);
|
||||||
char code;
|
return (MacOSMouseButton)button;
|
||||||
|
}
|
||||||
unsafe
|
|
||||||
{
|
internal unsafe static int GetEventMouseWheelDelta(IntPtr inEvent) {
|
||||||
char* codeAddr = &code;
|
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.KeyMacCharCode, EventParamType.typeChar, IntPtr.Zero,
|
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(char)), IntPtr.Zero,
|
|
||||||
(IntPtr)codeAddr);
|
|
||||||
|
|
||||||
if (result != OSStatus.NoError)
|
|
||||||
{
|
|
||||||
throw new MacOSException(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
static internal MouseButton GetEventMouseButton(IntPtr inEvent)
|
|
||||||
{
|
|
||||||
int button;
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
int* btn = &button;
|
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.MouseButton, EventParamType.typeMouseButton, IntPtr.Zero,
|
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(short)), IntPtr.Zero,
|
|
||||||
(IntPtr)btn);
|
|
||||||
|
|
||||||
if (result != OSStatus.NoError)
|
|
||||||
throw new MacOSException(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (MouseButton)button;
|
|
||||||
}
|
|
||||||
static internal int GetEventMouseWheelDelta(IntPtr inEvent)
|
|
||||||
{
|
|
||||||
int delta;
|
int delta;
|
||||||
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.MouseWheelDelta, EventParamType.typeSInt32,
|
||||||
|
IntPtr.Zero, sizeof(int), IntPtr.Zero, (IntPtr)(void*)&delta);
|
||||||
|
|
||||||
unsafe
|
if (result != OSStatus.NoError)
|
||||||
{
|
throw new MacOSException(result);
|
||||||
int* d = δ
|
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.MouseWheelDelta, EventParamType.typeSInt32,
|
|
||||||
IntPtr.Zero, (uint)sizeof(int), IntPtr.Zero, (IntPtr)d);
|
|
||||||
|
|
||||||
if (result != OSStatus.NoError)
|
|
||||||
throw new MacOSException(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
static internal OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt)
|
internal unsafe static OSStatus GetEventWindowMouseLocation(IntPtr inEvent, out HIPoint pt) {
|
||||||
{
|
HIPoint point;
|
||||||
HIPoint point;
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
|
||||||
|
Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero, (IntPtr)(void*)&point);
|
||||||
|
|
||||||
unsafe
|
pt = point;
|
||||||
{
|
return result;
|
||||||
HIPoint* parm = &point;
|
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.WindowMouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
|
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero,
|
|
||||||
(IntPtr)parm);
|
|
||||||
|
|
||||||
pt = point;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static internal OSStatus GetEventWindowRef(IntPtr inEvent, out IntPtr windowRef)
|
|
||||||
{
|
|
||||||
IntPtr retval;
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
IntPtr* parm = &retval;
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.WindowRef, EventParamType.typeWindowRef, IntPtr.Zero,
|
|
||||||
(uint)sizeof(IntPtr), IntPtr.Zero, (IntPtr)parm);
|
|
||||||
|
|
||||||
windowRef = retval;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static internal OSStatus GetEventMouseLocation(IntPtr inEvent, out HIPoint pt)
|
internal unsafe static OSStatus GetEventWindowRef(IntPtr inEvent, out IntPtr windowRef) {
|
||||||
{
|
IntPtr retval;
|
||||||
HIPoint point;
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.WindowRef, EventParamType.typeWindowRef, IntPtr.Zero,
|
||||||
|
sizeof(IntPtr), IntPtr.Zero, (IntPtr)(void*)&retval);
|
||||||
|
|
||||||
unsafe
|
windowRef = retval;
|
||||||
{
|
return result;
|
||||||
HIPoint* parm = &point;
|
}
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
internal unsafe static OSStatus GetEventMouseLocation(IntPtr inEvent, out HIPoint pt) {
|
||||||
EventParamName.MouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
|
HIPoint point;
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero,
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
(IntPtr)parm);
|
EventParamName.MouseLocation, EventParamType.typeHIPoint, IntPtr.Zero,
|
||||||
|
Marshal.SizeOf(typeof(HIPoint)), IntPtr.Zero, (IntPtr)(void*)&point);
|
||||||
|
|
||||||
pt = point;
|
pt = point;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal unsafe static MacOSKeyModifiers GetEventKeyModifiers(IntPtr inEvent) {
|
||||||
|
uint code;
|
||||||
|
OSStatus result = API.GetEventParameter(inEvent,
|
||||||
|
EventParamName.KeyModifiers, EventParamType.typeUInt32, IntPtr.Zero,
|
||||||
|
sizeof(uint), IntPtr.Zero, (IntPtr)(void*)&code);
|
||||||
|
|
||||||
return result;
|
if (result != OSStatus.NoError)
|
||||||
}
|
throw new MacOSException(result);
|
||||||
|
return (MacOSKeyModifiers)code;
|
||||||
}
|
}
|
||||||
static internal MacOSKeyModifiers GetEventKeyModifiers(IntPtr inEvent)
|
|
||||||
{
|
|
||||||
uint code;
|
|
||||||
|
|
||||||
unsafe
|
|
||||||
{
|
|
||||||
uint* codeAddr = &code;
|
|
||||||
|
|
||||||
OSStatus result = API.GetEventParameter(inEvent,
|
|
||||||
EventParamName.KeyModifiers, EventParamType.typeUInt32, IntPtr.Zero,
|
|
||||||
(uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(uint)), IntPtr.Zero,
|
|
||||||
(IntPtr)codeAddr);
|
|
||||||
|
|
||||||
if (result != OSStatus.NoError)
|
|
||||||
{
|
|
||||||
throw new MacOSException(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (MacOSKeyModifiers)code;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region --- Event Handlers ---
|
#region --- Event Handlers ---
|
||||||
|
@ -32,18 +32,16 @@ using System.Diagnostics;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using OpenTK.Platform.MacOS.Carbon;
|
using OpenTK.Platform.MacOS.Carbon;
|
||||||
|
using OpenTK.Input;
|
||||||
|
|
||||||
namespace OpenTK.Platform.MacOS
|
namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
class CarbonGLNative : INativeWindow
|
class CarbonGLNative : INativeWindow, IInputDriver
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
CarbonWindowInfo window;
|
CarbonWindowInfo window;
|
||||||
CarbonInput mInputDriver;
|
|
||||||
|
|
||||||
static MacOSKeyMap Keymap = new MacOSKeyMap();
|
static MacOSKeyMap Keymap = new MacOSKeyMap();
|
||||||
|
|
||||||
IntPtr uppHandler;
|
IntPtr uppHandler;
|
||||||
|
|
||||||
string title = "OpenTK Window";
|
string title = "OpenTK Window";
|
||||||
@ -108,6 +106,7 @@ namespace OpenTK.Platform.MacOS
|
|||||||
new Rect((short)x, (short)y, (short)width, (short)height));
|
new Rect((short)x, (short)y, (short)width, (short)height));
|
||||||
|
|
||||||
mDisplayDevice = device;
|
mDisplayDevice = device;
|
||||||
|
dummy_joystick_list.Add(new JoystickDevice<object>(0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -196,8 +195,6 @@ namespace OpenTK.Platform.MacOS
|
|||||||
|
|
||||||
void ConnectEvents()
|
void ConnectEvents()
|
||||||
{
|
{
|
||||||
mInputDriver = new CarbonInput();
|
|
||||||
|
|
||||||
EventTypeSpec[] eventTypes = new EventTypeSpec[]
|
EventTypeSpec[] eventTypes = new EventTypeSpec[]
|
||||||
{
|
{
|
||||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose),
|
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose),
|
||||||
@ -369,17 +366,16 @@ namespace OpenTK.Platform.MacOS
|
|||||||
switch (evt.KeyboardEventKind)
|
switch (evt.KeyboardEventKind)
|
||||||
{
|
{
|
||||||
case KeyboardEventKind.RawKeyRepeat:
|
case KeyboardEventKind.RawKeyRepeat:
|
||||||
InputDriver.Keyboard[0].KeyRepeat = true;
|
keyboard.KeyRepeat = true;
|
||||||
goto case KeyboardEventKind.RawKeyDown;
|
goto case KeyboardEventKind.RawKeyDown;
|
||||||
|
|
||||||
case KeyboardEventKind.RawKeyDown:
|
case KeyboardEventKind.RawKeyDown:
|
||||||
OnKeyPress(mKeyPressArgs);
|
OnKeyPress(mKeyPressArgs);
|
||||||
InputDriver.Keyboard[0][Keymap[code]] = true;
|
keyboard[Keymap[code]] = true;
|
||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case KeyboardEventKind.RawKeyUp:
|
case KeyboardEventKind.RawKeyUp:
|
||||||
InputDriver.Keyboard[0][Keymap[code]] = false;
|
keyboard[Keymap[code]] = false;
|
||||||
|
|
||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case KeyboardEventKind.RawKeyModifiersChanged:
|
case KeyboardEventKind.RawKeyModifiersChanged:
|
||||||
@ -441,8 +437,8 @@ namespace OpenTK.Platform.MacOS
|
|||||||
}
|
}
|
||||||
protected OSStatus ProcessMouseEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData)
|
protected OSStatus ProcessMouseEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData)
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Assert(evt.EventClass == EventClass.Mouse);
|
Debug.Assert(evt.EventClass == EventClass.Mouse);
|
||||||
MouseButton button = MouseButton.Primary;
|
MacOSMouseButton button;
|
||||||
HIPoint pt = new HIPoint();
|
HIPoint pt = new HIPoint();
|
||||||
HIPoint screenLoc = new HIPoint();
|
HIPoint screenLoc = new HIPoint();
|
||||||
|
|
||||||
@ -484,20 +480,18 @@ namespace OpenTK.Platform.MacOS
|
|||||||
|
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case MouseButton.Primary:
|
case MacOSMouseButton.Primary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Left] = true;
|
mouse[MouseButton.Left] = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseButton.Secondary:
|
case MacOSMouseButton.Secondary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Right] = true;
|
mouse[MouseButton.Right] = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseButton.Tertiary:
|
case MacOSMouseButton.Tertiary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Middle] = true;
|
mouse[MouseButton.Middle] = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case MouseEventKind.MouseUp:
|
case MouseEventKind.MouseUp:
|
||||||
@ -505,29 +499,25 @@ namespace OpenTK.Platform.MacOS
|
|||||||
|
|
||||||
switch (button)
|
switch (button)
|
||||||
{
|
{
|
||||||
case MouseButton.Primary:
|
case MacOSMouseButton.Primary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Left] = false;
|
mouse[MouseButton.Left] = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseButton.Secondary:
|
case MacOSMouseButton.Secondary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Right] = false;
|
mouse[MouseButton.Right] = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MouseButton.Tertiary:
|
case MacOSMouseButton.Tertiary:
|
||||||
InputDriver.Mouse[0][OpenTK.Input.MouseButton.Middle] = false;
|
mouse[MouseButton.Middle] = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
button = API.GetEventMouseButton(inEvent);
|
button = API.GetEventMouseButton(inEvent);
|
||||||
|
|
||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case MouseEventKind.WheelMoved:
|
case MouseEventKind.WheelMoved:
|
||||||
|
|
||||||
int delta = API.GetEventMouseWheelDelta(inEvent) / 3;
|
int delta = API.GetEventMouseWheelDelta(inEvent) / 3;
|
||||||
|
mouse.Wheel += delta;
|
||||||
InputDriver.Mouse[0].Wheel += delta;
|
|
||||||
|
|
||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case MouseEventKind.MouseMoved:
|
case MouseEventKind.MouseMoved:
|
||||||
@ -535,32 +525,23 @@ namespace OpenTK.Platform.MacOS
|
|||||||
|
|
||||||
//Debug.Print("Mouse Location: {0}, {1}", pt.X, pt.Y);
|
//Debug.Print("Mouse Location: {0}, {1}", pt.X, pt.Y);
|
||||||
|
|
||||||
if (this.windowState == WindowState.Fullscreen)
|
if (windowState == WindowState.Fullscreen) {
|
||||||
{
|
if (mousePosInClient.X != mouse.X || mousePosInClient.Y != mouse.Y) {
|
||||||
if (mousePosInClient.X != InputDriver.Mouse[0].X ||
|
mouse.Position = mousePosInClient;
|
||||||
mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
|
||||||
{
|
|
||||||
InputDriver.Mouse[0].Position = mousePosInClient;
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// ignore clicks in the title bar
|
// ignore clicks in the title bar
|
||||||
if (pt.Y < 0)
|
if (pt.Y < 0)
|
||||||
return OSStatus.EventNotHandled;
|
return OSStatus.EventNotHandled;
|
||||||
|
|
||||||
if (mousePosInClient.X != InputDriver.Mouse[0].X ||
|
if (mousePosInClient.X != mouse.X || mousePosInClient.Y != mouse.Y) {
|
||||||
mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
mouse.Position = mousePosInClient;
|
||||||
{
|
|
||||||
InputDriver.Mouse[0].Position = mousePosInClient;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return OSStatus.EventNotHandled;
|
return OSStatus.EventNotHandled;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Debug.Print("{0}", evt);
|
Debug.Print("{0}", evt);
|
||||||
|
|
||||||
return OSStatus.EventNotHandled;
|
return OSStatus.EventNotHandled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,6 +572,7 @@ namespace OpenTK.Platform.MacOS
|
|||||||
code = API.GetEventKeyboardKeyCode(inEvent);
|
code = API.GetEventKeyboardKeyCode(inEvent);
|
||||||
charCode = API.GetEventKeyboardChar(inEvent);
|
charCode = API.GetEventKeyboardChar(inEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProcessModifierKey(IntPtr inEvent)
|
private void ProcessModifierKey(IntPtr inEvent)
|
||||||
{
|
{
|
||||||
MacOSKeyModifiers modifiers = API.GetEventKeyModifiers(inEvent);
|
MacOSKeyModifiers modifiers = API.GetEventKeyModifiers(inEvent);
|
||||||
@ -603,42 +585,35 @@ namespace OpenTK.Platform.MacOS
|
|||||||
|
|
||||||
Debug.Print("Modifiers Changed: {0}", modifiers);
|
Debug.Print("Modifiers Changed: {0}", modifiers);
|
||||||
|
|
||||||
Input.KeyboardDevice keyboard = InputDriver.Keyboard[0];
|
if (keyboard[Key.AltLeft] ^ option)
|
||||||
|
keyboard[Key.AltLeft] = option;
|
||||||
|
|
||||||
if (keyboard[OpenTK.Input.Key.AltLeft] ^ option)
|
if (keyboard[Key.ShiftLeft] ^ shift)
|
||||||
keyboard[OpenTK.Input.Key.AltLeft] = option;
|
keyboard[Key.ShiftLeft] = shift;
|
||||||
|
|
||||||
if (keyboard[OpenTK.Input.Key.ShiftLeft] ^ shift)
|
if (keyboard[Key.WinLeft] ^ command)
|
||||||
keyboard[OpenTK.Input.Key.ShiftLeft] = shift;
|
keyboard[Key.WinLeft] = command;
|
||||||
|
|
||||||
if (keyboard[OpenTK.Input.Key.WinLeft] ^ command)
|
if (keyboard[Key.ControlLeft] ^ control)
|
||||||
keyboard[OpenTK.Input.Key.WinLeft] = command;
|
keyboard[Key.ControlLeft] = control;
|
||||||
|
|
||||||
if (keyboard[OpenTK.Input.Key.ControlLeft] ^ control)
|
if (keyboard[Key.CapsLock] ^ caps)
|
||||||
keyboard[OpenTK.Input.Key.ControlLeft] = control;
|
keyboard[Key.CapsLock] = caps;
|
||||||
|
|
||||||
if (keyboard[OpenTK.Input.Key.CapsLock] ^ caps)
|
|
||||||
keyboard[OpenTK.Input.Key.CapsLock] = caps;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GetRegion()
|
Rect GetRegion() {
|
||||||
{
|
return API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion);
|
||||||
Rect retval = API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLocation(short x, short y)
|
void SetLocation(short x, short y) {
|
||||||
{
|
|
||||||
if (windowState == WindowState.Fullscreen)
|
if (windowState == WindowState.Fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
API.MoveWindow(window.WindowRef, x, y, false);
|
API.MoveWindow(window.WindowRef, x, y, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSize(short width, short height)
|
void SetSize(short width, short height) {
|
||||||
{
|
|
||||||
if (WindowState == WindowState.Fullscreen)
|
if (WindowState == WindowState.Fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -651,26 +626,21 @@ namespace OpenTK.Platform.MacOS
|
|||||||
API.SizeWindow(window.WindowRef, width, height, true);
|
API.SizeWindow(window.WindowRef, width, height, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetClientSize(short width, short height)
|
void SetClientSize(short width, short height) {
|
||||||
{
|
|
||||||
if (WindowState == WindowState.Fullscreen)
|
if (WindowState == WindowState.Fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
API.SizeWindow(window.WindowRef, width, height, true);
|
API.SizeWindow(window.WindowRef, width, height, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void OnResize()
|
protected void OnResize() {
|
||||||
{
|
|
||||||
LoadSize();
|
LoadSize();
|
||||||
|
if (Resize != null) {
|
||||||
if (Resize != null)
|
|
||||||
{
|
|
||||||
Resize(this, EventArgs.Empty);
|
Resize(this, EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSize()
|
private void LoadSize() {
|
||||||
{
|
|
||||||
if (WindowState == WindowState.Fullscreen)
|
if (WindowState == WindowState.Fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -724,15 +694,10 @@ namespace OpenTK.Platform.MacOS
|
|||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenTK.Input.IInputDriver InputDriver
|
public IInputDriver InputDriver {
|
||||||
{
|
get { return this; }
|
||||||
get
|
|
||||||
{
|
|
||||||
return mInputDriver;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Icon Icon
|
public Icon Icon
|
||||||
{
|
{
|
||||||
get { return mIcon; }
|
get { return mIcon; }
|
||||||
@ -836,28 +801,14 @@ namespace OpenTK.Platform.MacOS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Point Location
|
public Point Location {
|
||||||
{
|
get { return Bounds.Location; }
|
||||||
get
|
set { SetLocation((short)value.X, (short)value.Y); }
|
||||||
{
|
|
||||||
return Bounds.Location;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetLocation((short)value.X, (short)value.Y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size Size
|
public Size Size {
|
||||||
{
|
get { return bounds.Size; }
|
||||||
get
|
set { SetSize((short)value.Width, (short)value.Height); }
|
||||||
{
|
|
||||||
return bounds.Size;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
SetSize((short)value.Width, (short)value.Height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Width
|
public int Width
|
||||||
@ -872,28 +823,14 @@ namespace OpenTK.Platform.MacOS
|
|||||||
set { SetClientSize((short)Width, (short)value); }
|
set { SetClientSize((short)Width, (short)value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int X
|
public int X {
|
||||||
{
|
get { return ClientRectangle.X; }
|
||||||
get
|
set { Location = new Point(value, Y); }
|
||||||
{
|
|
||||||
return ClientRectangle.X;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Location = new Point(value, Y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Y
|
public int Y {
|
||||||
{
|
get { return ClientRectangle.Y; }
|
||||||
get
|
set { Location = new Point(X, value); }
|
||||||
{
|
|
||||||
return ClientRectangle.Y;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
Location = new Point(X, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle ClientRectangle
|
public Rectangle ClientRectangle
|
||||||
@ -1124,5 +1061,40 @@ namespace OpenTK.Platform.MacOS
|
|||||||
public event EventHandler<EventArgs> MouseLeave;
|
public event EventHandler<EventArgs> MouseLeave;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region IInputDriver Members
|
||||||
|
|
||||||
|
KeyboardDevice keyboard = new KeyboardDevice();
|
||||||
|
MouseDevice mouse = new MouseDevice();
|
||||||
|
List<JoystickDevice> dummy_joystick_list = new List<JoystickDevice>(1);
|
||||||
|
|
||||||
|
public void Poll() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public KeyboardDevice Keyboard {
|
||||||
|
get { return keyboard; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public MouseDevice Mouse {
|
||||||
|
get { return mouse; }
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Implement using native API, rather than through Mono.
|
||||||
|
// http://webnnel.googlecode.com/svn/trunk/lib/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/CarbonEventsCore.h
|
||||||
|
// GetPos --> GetGlobalMouse (no 64 bit support?), and HIGetMousePosition()
|
||||||
|
// https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html#//apple_ref/c/func/CGWarpMouseCursorPosition
|
||||||
|
// SetPos --> CGWarpMouseCursorPosition
|
||||||
|
// Note that: CGPoint uses float on 32 bit systems, double on 64 bit systems
|
||||||
|
// The rest of the MacOS OpenTK API will probably need to be fixed for this too...
|
||||||
|
public Point DesktopCursorPos {
|
||||||
|
get { return System.Windows.Forms.Cursor.Position; }
|
||||||
|
set { System.Windows.Forms.Cursor.Position = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<JoystickDevice> Joysticks {
|
||||||
|
get { return dummy_joystick_list; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Drawing;
|
|
||||||
using OpenTK.Input;
|
|
||||||
|
|
||||||
namespace OpenTK.Platform.MacOS
|
|
||||||
{
|
|
||||||
class CarbonInput : IInputDriver
|
|
||||||
{
|
|
||||||
List<KeyboardDevice> dummy_keyboard_list = new List<KeyboardDevice>(1);
|
|
||||||
List<MouseDevice> dummy_mice_list = new List<MouseDevice>(1);
|
|
||||||
List<JoystickDevice> dummy_joystick_list = new List<JoystickDevice>(1);
|
|
||||||
|
|
||||||
internal CarbonInput()
|
|
||||||
{
|
|
||||||
dummy_mice_list.Add(new MouseDevice());
|
|
||||||
dummy_keyboard_list.Add(new KeyboardDevice());
|
|
||||||
dummy_joystick_list.Add(new JoystickDevice<object>(0, 0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IInputDriver Members
|
|
||||||
|
|
||||||
public void Poll()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IKeyboardDriver Members
|
|
||||||
|
|
||||||
public IList<KeyboardDevice> Keyboard
|
|
||||||
{
|
|
||||||
get { return dummy_keyboard_list; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IMouseDriver Members
|
|
||||||
|
|
||||||
public IList<MouseDevice> Mouse
|
|
||||||
{
|
|
||||||
get { return dummy_mice_list; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Implement using native API, rather than through Mono.
|
|
||||||
// http://webnnel.googlecode.com/svn/trunk/lib/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/CarbonEventsCore.h
|
|
||||||
// GetPos --> GetGlobalMouse (no 64 bit support?), and HIGetMousePosition()
|
|
||||||
// https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html#//apple_ref/c/func/CGWarpMouseCursorPosition
|
|
||||||
// SetPos --> CGWarpMouseCursorPosition
|
|
||||||
// Note that: CGPoint uses float on 32 bit systems, double on 64 bit systems
|
|
||||||
// The rest of the MacOS OpenTK API will probably need to be fixed for this too...
|
|
||||||
public Point DesktopCursorPos {
|
|
||||||
get { return System.Windows.Forms.Cursor.Position; }
|
|
||||||
set { System.Windows.Forms.Cursor.Position = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IJoystickDriver Members
|
|
||||||
|
|
||||||
public IList<JoystickDevice> Joysticks
|
|
||||||
{
|
|
||||||
get { return dummy_joystick_list; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
@ -78,8 +78,6 @@ namespace OpenTK.Platform.Windows
|
|||||||
WinMMJoystick joystick_driver = new WinMMJoystick();
|
WinMMJoystick joystick_driver = new WinMMJoystick();
|
||||||
KeyboardDevice keyboard = new KeyboardDevice();
|
KeyboardDevice keyboard = new KeyboardDevice();
|
||||||
MouseDevice mouse = new MouseDevice();
|
MouseDevice mouse = new MouseDevice();
|
||||||
IList<KeyboardDevice> keyboards = new List<KeyboardDevice>(1);
|
|
||||||
IList<MouseDevice> mice = new List<MouseDevice>(1);
|
|
||||||
static readonly WinKeyMap KeyMap = new WinKeyMap();
|
static readonly WinKeyMap KeyMap = new WinKeyMap();
|
||||||
const long ExtendedBit = 1 << 24; // Used to distinguish left and right control, alt and enter keys.
|
const long ExtendedBit = 1 << 24; // Used to distinguish left and right control, alt and enter keys.
|
||||||
static readonly uint ShiftRightScanCode = Functions.MapVirtualKey(VirtualKeys.RSHIFT, 0); // Used to distinguish left and right shift keys.
|
static readonly uint ShiftRightScanCode = Functions.MapVirtualKey(VirtualKeys.RSHIFT, 0); // Used to distinguish left and right shift keys.
|
||||||
@ -112,18 +110,6 @@ namespace OpenTK.Platform.Windows
|
|||||||
CreateWindow(0, 0, ClientSize.Width, ClientSize.Height, title, options, device, window.WindowHandle), window);
|
CreateWindow(0, 0, ClientSize.Width, ClientSize.Height, title, options, device, window.WindowHandle), window);
|
||||||
|
|
||||||
exists = true;
|
exists = true;
|
||||||
|
|
||||||
keyboard.Description = "Standard Windows keyboard";
|
|
||||||
keyboard.NumberOfFunctionKeys = 12;
|
|
||||||
keyboard.NumberOfKeys = 101;
|
|
||||||
keyboard.NumberOfLeds = 3;
|
|
||||||
|
|
||||||
mouse.Description = "Standard Windows mouse";
|
|
||||||
mouse.NumberOfButtons = 3;
|
|
||||||
mouse.NumberOfWheels = 1;
|
|
||||||
|
|
||||||
keyboards.Add(keyboard);
|
|
||||||
mice.Add(mouse);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -1125,29 +1111,18 @@ namespace OpenTK.Platform.Windows
|
|||||||
|
|
||||||
#region IInputDriver Members
|
#region IInputDriver Members
|
||||||
|
|
||||||
public void Poll()
|
public void Poll() {
|
||||||
{
|
|
||||||
joystick_driver.Poll();
|
joystick_driver.Poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public KeyboardDevice Keyboard {
|
||||||
|
get { return keyboard; }
|
||||||
#region IKeyboardDriver Members
|
|
||||||
|
|
||||||
public IList<KeyboardDevice> Keyboard
|
|
||||||
{
|
|
||||||
get { return keyboards; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region IMouseDriver Members
|
|
||||||
|
|
||||||
public IList<MouseDevice> Mouse
|
|
||||||
{
|
|
||||||
get { return mice; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MouseDevice Mouse {
|
||||||
|
get { return mouse; }
|
||||||
|
}
|
||||||
|
|
||||||
public Point DesktopCursorPos {
|
public Point DesktopCursorPos {
|
||||||
get {
|
get {
|
||||||
Point pos = default( Point );
|
Point pos = default( Point );
|
||||||
@ -1158,7 +1133,7 @@ namespace OpenTK.Platform.Windows
|
|||||||
Functions.SetCursorPos( value.X, value.Y );
|
Functions.SetCursorPos( value.X, value.Y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IJoystickDriver Members
|
#region IJoystickDriver Members
|
||||||
|
@ -26,8 +26,6 @@ namespace OpenTK.Platform.X11
|
|||||||
//X11WindowInfo window;
|
//X11WindowInfo window;
|
||||||
KeyboardDevice keyboard = new KeyboardDevice();
|
KeyboardDevice keyboard = new KeyboardDevice();
|
||||||
MouseDevice mouse = new MouseDevice();
|
MouseDevice mouse = new MouseDevice();
|
||||||
List<KeyboardDevice> dummy_keyboard_list = new List<KeyboardDevice>(1);
|
|
||||||
List<MouseDevice> dummy_mice_list = new List<MouseDevice>(1);
|
|
||||||
|
|
||||||
X11KeyMap keymap = new X11KeyMap();
|
X11KeyMap keymap = new X11KeyMap();
|
||||||
int firstKeyCode, lastKeyCode; // The smallest and largest KeyCode supported by the X server.
|
int firstKeyCode, lastKeyCode; // The smallest and largest KeyCode supported by the X server.
|
||||||
@ -54,13 +52,6 @@ namespace OpenTK.Platform.X11
|
|||||||
|
|
||||||
//window = new X11WindowInfo(attach);
|
//window = new X11WindowInfo(attach);
|
||||||
X11WindowInfo window = (X11WindowInfo)attach;
|
X11WindowInfo window = (X11WindowInfo)attach;
|
||||||
|
|
||||||
// Init mouse
|
|
||||||
mouse.Description = "Default X11 mouse";
|
|
||||||
mouse.DeviceID = IntPtr.Zero;
|
|
||||||
mouse.NumberOfButtons = 5;
|
|
||||||
mouse.NumberOfWheels = 1;
|
|
||||||
dummy_mice_list.Add(mouse);
|
|
||||||
|
|
||||||
using (new XLock(window.Display))
|
using (new XLock(window.Display))
|
||||||
{
|
{
|
||||||
@ -76,12 +67,6 @@ namespace OpenTK.Platform.X11
|
|||||||
Marshal.PtrToStructure(keysym_ptr, keysyms);
|
Marshal.PtrToStructure(keysym_ptr, keysyms);
|
||||||
API.Free(keysym_ptr);
|
API.Free(keysym_ptr);
|
||||||
|
|
||||||
KeyboardDevice kb = new KeyboardDevice();
|
|
||||||
keyboard.Description = "Default X11 keyboard";
|
|
||||||
keyboard.NumberOfKeys = lastKeyCode - firstKeyCode + 1;
|
|
||||||
keyboard.DeviceID = IntPtr.Zero;
|
|
||||||
dummy_keyboard_list.Add(keyboard);
|
|
||||||
|
|
||||||
// Request that auto-repeat is only set on devices that support it physically.
|
// Request that auto-repeat is only set on devices that support it physically.
|
||||||
// This typically means that it's turned off for keyboards (which is what we want).
|
// This typically means that it's turned off for keyboards (which is what we want).
|
||||||
// We prefer this method over XAutoRepeatOff/On, because the latter needs to
|
// We prefer this method over XAutoRepeatOff/On, because the latter needs to
|
||||||
@ -212,23 +197,13 @@ namespace OpenTK.Platform.X11
|
|||||||
|
|
||||||
#region --- IInputDriver Members ---
|
#region --- IInputDriver Members ---
|
||||||
|
|
||||||
#region public IList<Keyboard> Keyboard
|
public KeyboardDevice Keyboard {
|
||||||
|
get { return keyboard; }
|
||||||
public IList<KeyboardDevice> Keyboard
|
|
||||||
{
|
|
||||||
get { return dummy_keyboard_list; }//return keyboardDriver.Keyboard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public MouseDevice Mouse {
|
||||||
|
get { return mouse; }
|
||||||
#region public IList<Mouse> Mouse
|
|
||||||
|
|
||||||
public IList<MouseDevice> Mouse
|
|
||||||
{
|
|
||||||
get { return (IList<MouseDevice>)dummy_mice_list; } //return mouseDriver.Mouse;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
// TODO: Implement using native API, rather than through Mono.
|
// TODO: Implement using native API, rather than through Mono.
|
||||||
public Point DesktopCursorPos {
|
public Point DesktopCursorPos {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user