Incompatible delegate exception from Observable.FromEventPattern - system.reactive

I wrote the following handy (or so I thought) extension method for use with Rx and WPF:
public static IObservable<EventPattern<TViewModel, PropertyChangedEventArgs>>
CreatePropertyChangedObservable<TViewModel>(this TViewModel vm) where TViewModel : INotifyPropertyChanged
{
return Observable.FromEventPattern<PropertyChangedEventHandler, TViewModel, PropertyChangedEventArgs>(
h => vm.PropertyChanged += h, h => vm.PropertyChanged -= h);
}
In some projects, this works fine. But in others, I get an ArgumentException with the message "Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type" from deep within the Rx code when I try to subscribe a delegate to the returned observable. My delegate absolutely has the right signature, and the exact same code with the exact same types succeeds in one project yet fails in the other. Both projects reference the same version of the System.Reactive nuget package (4.3.1).
If I use the more weakly-typed version of FromEventPattern (without TViewModel) and then manually Select the EventPattern<PropertyChangedEventArgs> into an EventPattern<TViewModel, PropertyChangedEventArgs>, it works fine in both projects. But I shouldn't have to do that.
Am I doing something wrong, or is this a bug in Rx? The callstack for the exception is as follows:
mscorlib.dll!System.Delegate.CreateDelegate(System.Type type, object firstArgument, System.Reflection.MethodInfo method, bool throwOnBindFailure) Unknown
mscorlib.dll!System.Delegate.CreateDelegate(System.Type type, object firstArgument, System.Reflection.MethodInfo method) Unknown
System.Reactive.dll!System.Reactive.ReflectionUtils.CreateDelegate<System.ComponentModel.PropertyChangedEventHandler>(object o, System.Reflection.MethodInfo method) Line 24 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.EventProducer<System.ComponentModel.PropertyChangedEventHandler, System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>.Session.Initialize() Line 323 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.EventProducer<System.ComponentModel.PropertyChangedEventHandler, System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>.Session.Connect(System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>> observer = {System.Reactive.AnonymousSafeObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>}) Line 269 C#
System.Reactive.dll!System.Reactive.Linq.ObservableImpl.EventProducer<System.ComponentModel.PropertyChangedEventHandler, System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>.Run(System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>> observer) Line 228 C#
System.Reactive.dll!System.Reactive.BasicProducer<System.__Canon>.SubscribeRaw.AnonymousMethod__1_0((System.Reactive.BasicProducer<System.__Canon> this, System.Reactive.Disposables.SingleAssignmentDisposable runAssignable, System.IObserver<System.__Canon> observer) tuple) Line 60 C#
System.Reactive.dll!System.Reactive.Concurrency.Scheduler.ScheduleAction.AnonymousMethod__76_0(System.Reactive.Concurrency.IScheduler _, (System.Func<(System.__Canon, System.__Canon, System.__Canon), System.IDisposable> action, (System.__Canon, System.__Canon, System.__Canon) state) tuple) Line 88 C#
System.Reactive.dll!System.Reactive.Concurrency.CurrentThreadScheduler.Schedule<System.ValueTuple<System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)>>((System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)) state, System.TimeSpan dueTime, System.Func<System.Reactive.Concurrency.IScheduler, (System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)), System.IDisposable> action) Line 101 C#
System.Reactive.dll!System.Reactive.Concurrency.LocalScheduler.Schedule<System.ValueTuple<System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)>>((System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)) state, System.Func<System.Reactive.Concurrency.IScheduler, (System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable>, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>)), System.IDisposable> action) Line 32 C#
System.Reactive.dll!System.Reactive.Concurrency.Scheduler.ScheduleAction<System.ValueTuple<System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>>>(System.Reactive.Concurrency.IScheduler scheduler, (System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>) state, System.Func<(System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>, System.Reactive.Disposables.SingleAssignmentDisposable, System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>), System.IDisposable> action) Line 86 C#
System.Reactive.dll!System.Reactive.BasicProducer<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>>.SubscribeRaw(System.IObserver<System.Reactive.EventPattern<MyViewModel, System.ComponentModel.PropertyChangedEventArgs>> observer, bool enableSafeguard) Line 62 C#

Related

Unity: Could not allocate memory: System out of memory! Memorylabel Texture

I know a lot of people get this issue but I have a hard time getting it fixed. Partly because this is my first Unity game.
So it is a 2d Android game using Unity 5.5.2f1 and I get the error when I try out my build. Note that this is my first build despite the game being 95% complete. I got stuck on building the APK for a while so I postponed fixing it. Building into an APK works fine but then when I run the game, after the intro screen the app crashes with the following debuglog (check note in the middle for where the crash occurs):
01-19 22:51:59.768: E/Unity(21604): Unable to find AudioPluginMsHRTF
01-19 22:51:59.769: E/Unity(21604): Unable to find
AudioPluginOculusSpatializer 01-19 22:51:59.848: D/Unity(21604):
GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor
GL_AMD_program_binary_Z400 GL_EXT_debug_label GL_EXT_debug_marker
GL_EXT_discard_framebuffer GL_EXT_robustness
GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV
GL_NV_fence GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture
GL_OES_depth24 GL_OES_EGL_image GL_OES_EGL_sync
GL_OES_EGL_image_external GL_OES_element_index_uint
GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high
GL_OES_get_program_binary GL_OES_packed_depth_stencil
GL_OES_depth_texture_cube_map GL_OES_rgb8_rgba8
GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float
GL_OES_texture_half_float GL_OES_texture_half_float_linear
GL_OES_texture_npot GL_OES_vertex_half_float
GL_OES_vertex_type_10_10_10_2 GL_OES_vertex_array_object
GL_QCOM_alpha_test GL_QCOM_binning_control GL_QCOM_driver_control
GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2
GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_EXT_sRGB
GL_EXT_sRGB_write_control GL_EXT 01-19 22:51:59.848: D/Unity(21604):
_texture_sRGB_decode GL_EXT_texture_filter_anisotropic GL_EXT_multisampled_render_to_texture GL_EXT_color_buffer_float
GL_EXT_color_buffer_half_float GL_EXT_disjoint_timer_query 01-19
22:52:00.564: W/Unity(21604): OnLevelWasLoaded was found on
GameManager 01-19 22:52:00.564: W/Unity(21604): This message has been
deprecated and will be removed in a later version of Unity. 01-19
22:52:00.564: W/Unity(21604): Add a delegate to
SceneManager.sceneLoaded instead to get notifications after scene
loading has completed 01-19 22:52:00.564: W/Unity(21604): 01-19
22:52:00.564: W/Unity(21604): (Filename: Line: 382)
when trying to transition from the scene 0 to scene 1
01-19 22:52:31.082: E/Unity(21604): Could not allocate memory: System
out of memory! 01-19 22:52:31.082: E/Unity(21604): Trying to allocate:
327716B with 16 alignment. MemoryLabel: Texture 01-19 22:52:31.082:
E/Unity(21604): Allocation happend at: Line:464 in 01-19
22:52:31.082: E/Unity(21604): Memory overview 01-19 22:52:31.082:
E/Unity(21604): [ ALLOC_DEFAULT ] used: 10185997B | peak: 10217647B |
reserved: 10604339B 01-19 22:52:31.082: E/Unity(21604): [
ALLOC_TEMP_JOB ] used: 0B | peak: 0B | reserved: 524288B 01-19
22:52:31.082: E/Unity(21604): [ ALLOC_GAMEOBJECT ] used: 665219B |
peak: 665219B | reserved: 752068B 01-19 22:52:31.082: E/Unity(21604):
[ ALLOC_GFX ] used: 48855042B | peak: 50558706B | reserved: 48861160B
01-19 22:52:31.082: E/Unity(21604): [ ALLOC_PROFILER ] used: 0B |
peak: 0B | reserved: 0B 01-19 22:52:31.082: E/Unity(21604): [
ALLOC_TEMP_THREAD ] used: 110072B | peak: 0B | reserved: 2719744B
01-19 22:52:31.082: E/Unity(21604): 01-19 22:52:31.082:
E/Unity(21604): (Filename: Line: 996)
Now I have done the following:
-Made the intro screen as light as possible (at first I didn't even have one)
-Emptied the resource folder (cut my project size in half and increased build speed but that is about it)
-OpenGLES is set to 3 (someone advised this)
(note that there are no textures larger than 1000x1000)
As I said before, this is my first project in Unity. I am not the best programmer in the worl but over the last year I managed to put this little RPG together and I am quite ready to actually finish up and release! I would really appreciate any advise anyone can give!
Cheers,
Daan
Go to File > Build Settings and make sure Scripts Only Build is unchecked.
This has fixed it for me in Unity 2018.3.7f1.

Why does my app run in the simulator but crash trying to launch on my iPhone?

I'm writing an app in Swift 3 using Xcode 8.3.2. My app runs fine in the Simulator but I get an ugly error message when I try to run it on my iPhone (iOS 10.3.1):
libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x1005203d0 <+0>: stp x26, x25, [sp, #-0x50]!
0x1005203d4 <+4>: stp x24, x23, [sp, #0x10]
0x1005203d8 <+8>: stp x22, x21, [sp, #0x20]
0x1005203dc <+12>: stp x20, x19, [sp, #0x30]
0x1005203e0 <+16>: stp x29, x30, [sp, #0x40]
0x1005203e4 <+20>: add x29, sp, #0x40 ; =0x40
0x1005203e8 <+24>: mov x19, x6
0x1005203ec <+28>: mov x20, x5
0x1005203f0 <+32>: mov x21, x4
0x1005203f4 <+36>: mov x22, x3
0x1005203f8 <+40>: mov x23, x2
0x1005203fc <+44>: mov x24, x1
0x100520400 <+48>: mov x25, x0
0x100520404 <+52>: adr x8, #0xf11fc ; protocol descriptor for Swift._DefaultCustomPlaygroundQuickLookable + 136
0x100520408 <+56>: nop
0x10052040c <+60>: add x0, x8, #0x10 ; =0x10
0x100520410 <+64>: mov w1, #0x28
0x100520414 <+68>: orr w2, wzr, #0x7
0x100520418 <+72>: bl 0x100520750 ; swift_rt_swift_allocObject
0x10052041c <+76>: mov x8, x0
0x100520420 <+80>: stp x22, x21, [x8, #0x10]
0x100520424 <+84>: strb w20, [x8, #0x20]
0x100520428 <+88>: str w19, [x8, #0x24]
0x10052042c <+92>: adr x3, #0x40440 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, file : Swift.StaticString, line : Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x100520430 <+96>: nop
0x100520434 <+100>: mov x0, x25
0x100520438 <+104>: mov x1, x24
0x10052043c <+108>: mov x2, x23
0x100520440 <+112>: mov x4, x8
0x100520444 <+116>: bl 0x1004014dc ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (#out ()), Argument Types : [#callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x100520448 <+120>: brk #0x1
I set an exception breakpoint that led me to this bit of code:
if let defaultFormula = dataManager.fetchDefaultFormula(moc) {
self.formula = defaultFormula.first! <<< Unexpectedly found nil...
}
and here is the function it's calling:
func fetchDefaultFormula(_ moc: NSManagedObjectContext) -> [Formula]? {
let defaultFormulaID = UserDefaults.formula()
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Formula")
let filterPredicate = NSPredicate(format: "uuid = [c] %#", defaultFormulaID)
fetchRequest.predicate = filterPredicate
do {
return try moc.fetch(fetchRequest) as? [Formula]
} catch {
fatalError("There was an error fetching the lifts")
}
return nil
}
The fetch request is returning 0 values so it's clear why I get the exception when I force unwrap it. However, the object property 'formula' must have a value. The first thing the app does is check to see if the default data (like the available formulas) exists in the persistent store and if it doesn't, it adds it. I've reset the Simulator and it dutifully adds them but it seems that this isn't happening on the iPhone. If there's a way for me to determine whether or not the records are being added to the store when running it on the iPhone, please enlighten me.
I've found a few SO threads in which others have experienced this cryptic error (the big, ugly one, not the unexpected nil) and I've tried all of the remedies suggested:
cleaned the project unplugged the iPhone, plugged it back in
restarted all devices
changed the Team to None and back to me
turned off Automatically manage signing and turned it back on
downloaded my current certificates
turned some flags from No to Yes in Build Settings
etc
I don't know where to go from here having exhausted all of the suggestions I've been able to find.
Any suggestions are greatly appreciated.
Well, I guess there was one thing I didn't try - uninstalling the app from my phone first, then build and run it on the phone.
So I don't really know what the root cause was, but at least this resolved the problem.

Error on iPhone but not on the simulator

Since today i was running my app on Simulator with the 6s on iOS 10, but now I am running it on the iPhone 7. It shows me the following error when i press the Save button: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x000cfba4)
My code look like this:
#IBAction func SaveAction(_ sender: AnyObject) {
let dataString = DateTextfield.text
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMM d, yyyy"
// convert string into date
let dateValue:NSDate? = dateFormatter.date(from: dataString!) as NSDate?
let nowDouble = dateValue?.timeIntervalSince1970
let hey = Int64(nowDouble!*1000) //Here is the error
let newdouble = Double(hey)
MyArray[Work]!["Date"]?.append(newdouble)
}
In the iOS simulator it works fine it saves the newdouble correctly to the dictionary named MyArray
If i run the app with Build Configuration: Debug
libswiftCore.dylib`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> Swift.Never:
0x100385174 <+0>: stp x26, x25, [sp, #-80]!
0x100385178 <+4>: stp x24, x23, [sp, #16]
0x10038517c <+8>: stp x22, x21, [sp, #32]
0x100385180 <+12>: stp x20, x19, [sp, #48]
0x100385184 <+16>: stp x29, x30, [sp, #64]
0x100385188 <+20>: add x29, sp, #64 ; =64
0x10038518c <+24>: mov x19, x6
0x100385190 <+28>: mov x20, x5
0x100385194 <+32>: mov x21, x4
0x100385198 <+36>: mov x22, x3
0x10038519c <+40>: mov x23, x2
0x1003851a0 <+44>: mov x24, x1
0x1003851a4 <+48>: mov x25, x0
0x1003851a8 <+52>: adr x8, #936952 ; protocol descriptor for Swift.CVarArg + 88
0x1003851ac <+56>: nop
0x1003851b0 <+60>: add x0, x8, #16 ; =16
0x1003851b4 <+64>: movz w1, #0x28
0x1003851b8 <+68>: orr w2, wzr, #0x7
0x1003851bc <+72>: bl 0x1003854a0 ; rt_swift_allocObject
0x1003851c0 <+76>: mov x8, x0
0x1003851c4 <+80>: stp x22, x21, [x8, #16]
0x1003851c8 <+84>: strb w20, [x8, #32]
0x1003851cc <+88>: str w19, [x8, #36]
0x1003851d0 <+92>: adr x3, #241008 ; partial apply forwarder for Swift.(_fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> Swift.Never).(closure #2)
0x1003851d4 <+96>: nop
0x1003851d8 <+100>: mov x0, x25
0x1003851dc <+104>: mov x1, x24
0x1003851e0 <+108>: mov x2, x23
0x1003851e4 <+112>: mov x4, x8
0x1003851e8 <+116>: bl 0x100278b70 ; function signature specialization <preserving fragile attribute, Arg[1] = [Closure Propagated : reabstraction thunk helper from #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> () to #callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> (#out ()), Argument Types : [#callee_owned (#unowned Swift.UnsafeBufferPointer<Swift.UInt8>) -> ()]> of generic specialization <preserving fragile attribute, ()> of Swift.StaticString.withUTF8Buffer <A> ((Swift.UnsafeBufferPointer<Swift.UInt8>) -> A) -> A
-> 0x1003851ec <+120>: brk #0x1 //Error message here

Incorporate V and H wheel to HID report

I have been working with the HID reports and I have been able to compile and run a report for keyboard, 3 button mouse, and 3 button mouse with wheel (vertical only). Right now I have been trying to use the 5 buttons with vertical and horizontal wheel.
So following this
// Input report - 5 bytes
//
// Byte | D7 D6 D5 D4 D3 D2 D1 D0
// ------+---------------------------------------------------------------------
// 0 | 0 0 0 Forward Back Middle Right Left (Buttons)
// 1 | X
// 2 | Y
// 3 | Vertical Wheel
// 4 | Horizontal (Tilt) Wheel
Now I have this report descriptor
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x01, // COLLECTION (Application)
0x09, 0x02, // USAGE (Mouse)
0xa1, 0x02, // COLLECTION (Logical)
0x09, 0x01, // USAGE (Pointer)
0xa1, 0x00, // COLLECTION (Physical)
// ------------------------------ Buttons
0x05, 0x09, // USAGE_PAGE (Button)
0x19, 0x01, // USAGE_MINIMUM (Button 1)
0x29, 0x05, // USAGE_MAXIMUM (Button 5)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x75, 0x01, // REPORT_SIZE (1)
0x95, 0x05, // REPORT_COUNT (5 Buttons)
0x81, 0x02, // INPUT (Data,Var,Abs)
// ------------------------------ Padding
0x75, 0x03, // REPORT_SIZE (8-5buttons 3)
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x03, // INPUT (Cnst,Var,Abs)
// ------------------------------ X,Y position
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x30, // USAGE (X)
0x09, 0x31, // USAGE (Y)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x02, // REPORT_COUNT (2)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Vertical wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0x15, 0x00, // LOGICAL_MINIMUM (0)
0x25, 0x01, // LOGICAL_MAXIMUM (1)
0x35, 0x01, // PHYSICAL_MINIMUM (1)
0x45, 0x04, // PHYSICAL_MAXIMUM (4)
0x75, 0x02, // REPORT_SIZE (2)
0x95, 0x01, // REPORT_COUNT (1)
0xa4, // PUSH
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Vertical wheel
0x09, 0x38, // USAGE (Wheel)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xa1, 0x02, // COLLECTION (Logical)
// ------------------------------ Horizontal wheel res multiplier
0x09, 0x48, // USAGE (Resolution Multiplier)
0xb4, // POP
0xb1, 0x02, // FEATURE (Data,Var,Abs)
// ------------------------------ Padding for Feature report
0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
0x45, 0x00, // PHYSICAL_MAXIMUM (0)
0x75, 0x04, // REPORT_SIZE (4)
0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
// ------------------------------ Horizontal wheel
0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
0x0a, 0x38, 0x02, // USAGE (AC Pan)
0x15, 0x81, // LOGICAL_MINIMUM (-127)
0x25, 0x7f, // LOGICAL_MAXIMUM (127)
0x75, 0x08, // REPORT_SIZE (8)
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
0xc0 // END_COLLECTION
Which includes the 5 buttons, vertical and horizontal. This compiles without any issue, but I'm trying to send the following information to test if its working correctly
mouseReport.buttons = 0;
mouseReport.x = 0;
mouseReport.y = 0;
mouseReport.v = 1;
mouseReport.h = 0;
But that 1 on the Vertical wheel byte makes my mouse, click and scroll randomly.
Could anyone tell me what am I missing? I'm using the exact same code, with a different report and 4 bytes, and the scroll works perfect.
Well I found the issue. I was using a struct to send the byte array and it seems that my micro controller didn't like that because it was getting bad resolution, hence why the random movement and clicks. Changing it to an array of unint8_t fixed the issue.

Problem with increment in inline ARM assembly

i have the following bit of inline ARM assembly, it works in a debug build but crashes in a release build of iphone sdk 3.1. The problem is the add instructions where i am incrementing the address of the C variables output and x by 4 bytes, this is supposed to increment by the size of a float. I think when i increment at some such stage i am overwriting something, can anyone say which is the best way to handle this
Thanks
C code that the asm is replacing, sum,output and x are all floats
for(int i = 0; i< count; i++)
sum+= output[i]* (*x++)
asm volatile(
".align 4 \n\t"
"mov r4,%3 \n\t"
"flds s0,[%0] \n\t"
"0: \n\t"
"flds s1,[%2] \n\t"
//"add %3,%3,#4 \n\t"
"flds s2,[%1] \n\t"
//"add %2,%2,#4 \n\t"
"subs r4,r4, #1 \n\t"
"fmacs s0, s1, s2 \n\t"
"bne 0b \n\t"
"fsts s0,[%0] \n\t"
:
: "r" (&sum), "r" (output), "r" (x),"r" (count)
: "r0","r4","cc", "memory",
"s0","s1","s2"
);
did you mean %1 to add 4 to and %3? adding to %3 could cause damage if that register is used again after your function.
asm volatile(
".align 4 \n\t"
"mov r4,%3 \n\t"
"flds s0,[%0] \n\t"
"0: \n\t"
"flds s1,[%2] \n\t"
"add %2,%2,#4 \n\t"
"flds s2,[%1] \n\t"
"add %1,%1,#4 \n\t"
"subs r4,r4, #1 \n\t"
"fmacs s0, s1, s2 \n\t"
"bne 0b \n\t"
"fsts s0,[%0] \n\t"
:
: "r" (&sum), "r" (output), "r" (x),"r" (count)
: "r0","r4","cc", "memory",
"s0","s1","s2"
);