Commit graph

246 commits

Author SHA1 Message Date
thefiddler 383cea7e82 [Mac] Fixed exception in HIDInput.Dispose()
HIDInput.Dispose() would remove elements from a DeviceCollection during
iteration. This results in an exception.

We are now using a plain for-loop instead.
2014-09-20 17:11:18 +02:00
thefiddler 8642177c30 [Mac] Use DeviceCollection
This reduces code duplication significantly.
2014-09-18 01:16:41 +02:00
thefiddler 2a6579032e [Mac] Match SDL2 element order
Joystick elements (axes, buttons, hats) are now reported in the same
order as SDL2. This fixes potential mismatches in the GamePad
configuration database.

Additionally, elements are now counted correctly (duplicate elements no
longer count towards the total.)
2014-09-18 01:16:40 +02:00
thefiddler fbedac9a16 [Mac] Fixed Joystick Hat calculations 2014-09-18 01:16:40 +02:00
thefiddler b9f7f2c242 [Mac] Sort joystick elements like SDL2
GamePad configuration database is now working correctly on Mac.
2014-09-18 01:16:40 +02:00
thefiddler 9c67265832 [Mac] Added CFGetTypeID method 2014-09-18 01:16:40 +02:00
thefiddler 4231cf2cdd [Mac] Use cookies to match HID joystick elements 2014-09-18 01:16:40 +02:00
thefiddler d4c6b2e699 [Mac] Fixed joystick Guid calculation
The result now matches the output of SDL2 as well as the entries in the
GamePad configuration database.
2014-09-18 01:16:40 +02:00
Stefanos A 94476b930e [Common] Moved axis translation to common 2014-09-11 12:51:46 +02:00
Stefanos A 178305e1c1 [Common] Added HID usage page definitions 2014-09-11 12:51:46 +02:00
thefiddler 6292ad4160 [Mac] Avoid calling finishLaunching multiple times 2014-09-11 12:21:05 +02:00
thefiddler 1080dec04d [Mac] Do not modify existing mainMenu
If an application already has a custom main menu, avoid overwriting
that in OpenTK.
2014-09-11 12:07:53 +02:00
thefiddler 6db29562cc [Mac] Release input driver before other resources
The input driver relies on the existence of a CFRunLoop. Releasing it
first ensures that a CFRunLoop is available for its complete life cycle.
2014-07-23 23:23:14 +02:00
thefiddler f799530575 [Mac] Do not use autorelease pool
Avoids a potential crash on shutdown.
2014-07-23 23:22:00 +02:00
thefiddler bb882fe700 [Mac] Correctly release mach port
The event tap is released automatically along with the mach port. Fixes
crash on shutdown.
2014-07-23 23:21:04 +02:00
thefiddler 29af70274d [Mac] Removed stored delegate list
The stored delegate list would store delegates indefinitely, causing a
memory leak. It is now the responsibility of each class to maintain
references to any callback functions it defines.
2014-07-23 21:23:25 +02:00
thefiddler 57c2f89038 [Mac] Explicitly close removed devices
Devices are now explicitly closed when they a DeviceRemoved event is
received. Additionally, exceptions are no longer allowed to escape into
unmanaged code, where they might crash the runtime.
2014-07-23 21:19:46 +02:00
thefiddler d12643cf44 [Mac] Mark callback calling convention
Callbacks are now explicitly marked as unmanaged pointers with the
correct (platform-defined) calling convention. Exceptions raised inside
these callbacks are no longer allowed to escape into unmanaged code,
where they will crash the runtime.

Additionally, the window is now only closed on the UI thread, and only
if it is actually open.
2014-07-23 21:18:34 +02:00
thefiddler a6c4a7c9b5 [Mac] Only dispose context on UI thread 2014-07-23 21:15:16 +02:00
thefiddler e5e9ae0929 [Mac]] Add NSApplication.IsUIThread property
This can be used to check whether it is safe to access UI components in
the calling thread.
2014-07-23 21:14:47 +02:00
thefiddler 050a93d4af [Mac] Resource registration moved to the facades 2014-07-23 14:36:09 +02:00
thefiddler ac2ae4a4bb [Mac] Ensure Cocoa bindings are initialized first 2014-07-23 14:35:51 +02:00
thefiddler 5d66aaa034 [Mac] Do not set callback delegates to null
This is done automatically by the GC once they are eligible for
collection.
2014-07-23 10:10:37 +02:00
thefiddler 4093b39fac [Mac] Store a reference to callback delegates
This avoids a potential crashes by the GC reclaiming the delegates
prematurely.
2014-07-23 10:10:08 +02:00
thefiddler e81d8da068 [OpenTK] Reduce duplication in GraphicsContextBase
Inheritors now take advantage of base class functionality to avoid
duplicating finalizers and warning messages.
2014-07-23 10:08:57 +02:00
thefiddler 8f03b09dad [Mac] Register platform resources for disposal 2014-07-23 09:21:28 +02:00
thefiddler 864cc84019 [Mac] Do not execute run loop prematurely
Fixes a potential crash when destroying and recreating OpenTK.Toolkit.
2014-07-23 09:20:51 +02:00
thefiddler 0a0a5d0af7 [Mac] More defensive programming
CocoaNativeWindow now checks for and reports failures to allocate
resources in its constructor. Additionally, it no longer calls UI
methods in the finalizer thread, as those methods will crash on Cocoa.
2014-07-23 09:05:01 +02:00
thefiddler 9d6b6891e6 [Mac] CursorVisible should only apply when changed
This fixes an issue where `NativeWindow.Dispose()` would move the mouse
cursor.
2014-07-22 21:02:33 +02:00
thefiddler 0c4081f6ef [Mac] Do not use Autorelease pool 2014-07-22 16:29:52 +02:00
thefiddler 5501689d37 [Mac] Added objc_disposeClassPair binding 2014-07-22 16:29:37 +02:00
thefiddler 0e40f63cf2 [Mac] Close CocoaNativeWindow in Dispose()
Also fix various memory management issues regarding the `MouseCursor`
and `Icon` properties.
2014-07-22 16:29:21 +02:00
thefiddler 7956126c8d [Mac] Retain CFRunLoop while it is in use 2014-07-22 16:20:46 +02:00
thefiddler 42e4e0b27e [Mac] Added CFRetain binding 2014-07-22 16:19:43 +02:00
thefiddler a047c08d3d [Mac] Correctly shutdown HID input driver 2014-07-22 14:28:48 +02:00
thefiddler 00b531fdef Fixed compilation warnings on Mono 3.4.0 2014-07-21 17:46:39 +02:00
thefiddler 461fbce45f Cleaned up a number of obsolete warnings 2014-07-21 16:39:58 +02:00
thefiddler c1c6b4269b Merge pull request #149 from thefiddler/mac_stability
[Mac] Improved stability for NSOpenGLPixelFormat
2014-07-15 06:06:41 +00:00
thefiddler 32958ffcce [Mac] Improved stability for NSOpenGLPixelFormat
Non-accelerated contexts are now considered iff no accelerated contexts
are available. Additionally, a GraphicsException will be thrown if
context construction fails for any reason, instead of causing a runtime
crash.
2014-07-14 12:27:28 +02:00
thefiddler 8373782fad [Mac] Fix Mouse.GetState() h-wheel
External mice will now report horizontal scrolling in the low-level
`Mouse.GetState()` API. The touchpad apparently creates an emulated
mouse device that does not report horizontal wheel scrolling events.

Touchpad support probably requires a proper multitouch implementation.
2014-06-10 17:43:31 +02:00
thefiddler 5e63c5fa5c [Mac] Add note for higher precision pixel scroll 2014-06-10 16:41:09 +02:00
thefiddler 2a4f634848 [Mac] Match win32 scrolling coordinates 2014-06-10 16:40:44 +02:00
thefiddler 5b529647c9 [Mac] Fixed NRE and initial position on 64bit 2014-05-20 01:00:54 +02:00
thefiddler c65e2a4d9e [Mac] Added NSFloat implementation 2014-05-20 00:14:57 +02:00
thefiddler 1419c1e3a0 [Mac] Explicitly retain/release CocoaWindowInfo instances 2014-05-14 18:01:08 +02:00
thefiddler 96aaef9b37 [Mac] Implemented Mouse.GetCursorState() 2014-05-12 02:20:53 +02:00
thefiddler f4a3cab0e0 [Input] Added Mouse.GetCursorPos() (WIP) 2014-05-12 02:20:52 +02:00
thefiddler d7e0373852 [Platform] Fixed keys getting stuck on focus loss
NativeWindowBase will now clear all keyboard keys when losing focus.
This prevents keys from getting stuck when refocusing the window.

[Win] Also fixed WindowState.Maximized when WindowBorder is Hidden and
the window is minimized.
2014-05-09 16:45:45 +02:00
thefiddler b1f627893b [Mac] Fixed PointTo* calculations
On HiDPI displays, the client rectangle is using a pixel-based
coordinate system, while the screen is using a point-based coordinate
system. PointToClient/PointToScreen now correctly accounts for that.
2014-05-06 09:03:13 +02:00
thefiddler 41276361fb [Mac] Report KeyDown/Up events for modifier flags 2014-05-05 09:14:14 +02:00