Andrew:
Aha! I was wondering how to keep track of which touch is which, did not realize you could get the id of the object as an integer and use that as a key (I've programmed in scheme forever, but learning objective-c now). I was just passing the x and y of a single touch across, and ignoring multiple touches. Thanks! I would be curious to see the code.
James:
That sounds great. I am wondering what your strategy is for exposing an objective-c object to scheme like that, as so far I have only been able to send basic data types (int, double etc) between c and scheme. Something like keeping some reference to the c object and implementing the various methods in scheme?
In particular, I would like to make a list of x,y pairs that get sent from the c event handler to the corresponding scheme function, is that possible? I imagine there could be some way to construct scheme lists from c, but not sure how that could be done at the moment. As I say, I am still learning the ropes around here.
Thanks for the replies!
- Ryan
--- On Sun, 7/12/09, James Long longster@gmail.com wrote:
From: James Long longster@gmail.com Subject: Re: [Gambit-iphone] Touch Translation To: "Andrew Andkjar" andkjar@obtech.net Cc: "Ryan Spangler" patch_work8848@yahoo.com, "gambit-iphone@iro.umontreal.ca" gambit-iphone@iro.umontreal.ca Date: Sunday, July 12, 2009, 11:54 AM
Hey Ryan,
I have not worked much on access to Touch events yet, and you're probably looking for specific FFI code as an example. Andrew, it would be great if you could share your code!
I was thinking of exposing access to the UITouch and other event objects so that you could benefit from the normal Cocoa API. When I do this, I will share this code.
Thanks, James
On Sun, Jul 12, 2009 at 1:30 PM, Andrew Andkjarandkjar@obtech.net wrote:
In the iPhone app I'm developing I am currently traversing the set of touch events in Objective-C and calling into touch-<began | moved | ended> Gambit-C callbacks I've defined that take an integer touch id and x,y coordinates. Active touches are tracked in Scheme in a hash table keyed on touch id. This has been suiting my multi-touch tracking needs so far. I'd be happy to share some code if there's interest. 'AA On Jul 11, 2009, at 6:03 PM, Ryan Spangler patch_work8848@yahoo.com wrote:
Hey all,
I was looking into porting the touch events into gambit, but I am pretty new to gambit and the c ffi specifically. The touch events are somewhat complex, taking an NSSet * and a UIEvent *. From what I can tell, the NSSet contains all current touch points (so if you have three fingers down, the NSSet contains three touch points) and the UIEvent has a history of all the touch points and where they have been since the first "touchesBegan" event, though I am not sure of the specific structure of these objects yet. I am wondering what is the best way to translate these into scheme data structures?
Thanks for any guidance on this, and I also noticed that James was talking about working on touch facilities as well. Maybe we could join forces on this? Or maybe you are already done?
- Ryan
Gambit-iphone mailing list Gambit-iphone@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-iphone
Gambit-iphone mailing list Gambit-iphone@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-iphone
Afficher les réponses par date
On Sun, Jul 12, 2009 at 5:00 PM, Ryan Spanglerpatch_work8848@yahoo.com wrote:
James:
That sounds great. I am wondering what your strategy is for exposing an objective-c object to scheme like that, as so far I have only been able to send basic data types (int, double etc) between c and scheme. Something like keeping some reference to the c object and implementing the various methods in scheme?
Yep, that's right. Since it's not a native type that can simply be converted into a Scheme type, you just pass a reference to it to the Scheme world and provide Scheme FFI functions for getting data out of the datatype (see c-define-type and c-lambda). I plan on writing my Touch FFI this week and will release it, make another blog post about it, etc.
In particular, I would like to make a list of x,y pairs that get sent from the c event handler to the corresponding scheme function, is that possible? I imagine there could be some way to construct scheme lists from c, but not sure how that could be done at the moment. As I say, I am still learning the ropes around here.
That is possible. You have to know Gambit's C API to do so, which isn't very well documented yet. You can search the gambit mailing list by googling "site:https://webmail.iro.umontreal.ca/pipermail/gambit-list/", there should be some examples in there if you are interested. I would give some examples but I don't have time to remember them myself.
I believe it would be easier to provide access to Obj-C's API which can query out this data. I've found that by exposing the raw API to Scheme, you can avoid having to write a bunch of translation code which awkwardly constructs Scheme data structures from C.
- James
2009/7/13 James Long longster@gmail.com
I believe it would be easier to provide access to Obj-C's API which
can query out this data. I've found that by exposing the raw API to Scheme, you can avoid having to write a bunch of translation code which awkwardly constructs Scheme data structures from C.
Have you look at the code for the Objective C FFIs in PLT Scheme and Chicken Scheme?
They use a general approach using the introspection facilities provided by the Objective C runtime. This reduces the pain of writing bindings considerably.
On Mon, Jul 13, 2009 at 7:14 AM, Jens Axel Søgaardjensaxel@soegaard.net wrote:
Have you look at the code for the Objective C FFIs in PLT Scheme and Chicken Scheme? They use a general approach using the introspection facilities provided by the Objective C runtime. This reduces the pain of writing bindings considerably.
I haven't looked at those FFIs, but I have seen the C API for Obj-C reflection. It it too early for me to tell what the best solution will be for interfacing Obj-C APIs. I will only be programming full-screen OpenGL apps, so I don't need complete access to all of the views, nav bars, lists, etc. I don't plan on writing a full Obj-C to Scheme bridge, but maybe that will come eventually. For that, the reflection API does look good.
For now, I plan on writing a few basic FFIs which simply wrap C functions around Obj-C calls.
Hallo,
On 7/13/09, James Long longster@gmail.com wrote:
I haven't looked at those FFIs, but I have seen the C API for Obj-C reflection. It it too early for me to tell what the best solution will be for interfacing Obj-C APIs. I will only be programming full-screen OpenGL apps, so I don't need complete access to all of the views, nav bars, lists, etc. I don't plan on writing a full Obj-C to Scheme bridge, but maybe that will come eventually. For that, the reflection API does look good.
The ObjC reflection API is very good, but unfortunately Gambit-C does not support variadic C functions. And they are needed to send messages to objects. One option is using libffi, other is write specialised methods in an as-needed basis.
Cheers,
This StackOverflow comment regarding libffi / mprotect issues on iPhone seems relevant:
"In the iPhone OS, mprotect() will fail if you try to use it to mark writable sections of memory as executable. This breaks bridges like RubyCocoa (and probably MacRuby) that use libffi to create Objective-C method handlers at runtime. I believe that this is by design because it was not always the case." - Tim Burks
http://stackoverflow.com/questions/219653/ruby-on-iphone
cheers, `AA
On Jul 13, 2009, at 12:55 PM, Alex Queiroz wrote:
Hallo,
On 7/13/09, James Long longster@gmail.com wrote:
I haven't looked at those FFIs, but I have seen the C API for Obj-C reflection. It it too early for me to tell what the best solution will be for interfacing Obj-C APIs. I will only be programming full-screen OpenGL apps, so I don't need complete access to all of the views, nav bars, lists, etc. I don't plan on writing a full Obj-C to Scheme bridge, but maybe that will come eventually. For that, the reflection API does look good.
The ObjC reflection API is very good, but unfortunately Gambit-C
does not support variadic C functions. And they are needed to send messages to objects. One option is using libffi, other is write specialised methods in an as-needed basis.
Cheers,
-alex http://www.ventonegro.org/ _______________________________________________ Gambit-iphone mailing list Gambit-iphone@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-iphone
Hey Ryan,
The relevant snippets are attached. Looking over this code I realized old touches are not removed from the table, and that touch positions are floats (as they are in their native CGPoint representation). I think the UITouch pointer cast to int is OK, but I am not sure, IIRC this technique was gleaned from Apple example code. Finally don't forget to enable multi-touch property on your view object, you can do this through Interface Builder's inspector.
On Jul 12, 2009, at 5:00 PM, Ryan Spangler wrote:
Andrew:
Aha! I was wondering how to keep track of which touch is which, did not realize you could get the id of the object as an integer and use that as a key (I've programmed in scheme forever, but learning objective-c now). I was just passing the x and y of a single touch across, and ignoring multiple touches. Thanks! I would be curious to see the code.
James:
That sounds great. I am wondering what your strategy is for exposing an objective-c object to scheme like that, as so far I have only been able to send basic data types (int, double etc) between c and scheme. Something like keeping some reference to the c object and implementing the various methods in scheme?
In particular, I would like to make a list of x,y pairs that get sent from the c event handler to the corresponding scheme function, is that possible? I imagine there could be some way to construct scheme lists from c, but not sure how that could be done at the moment. As I say, I am still learning the ropes around here.
Thanks for the replies!
- Ryan
--- On Sun, 7/12/09, James Long longster@gmail.com wrote:
From: James Long longster@gmail.com Subject: Re: [Gambit-iphone] Touch Translation To: "Andrew Andkjar" andkjar@obtech.net Cc: "Ryan Spangler" patch_work8848@yahoo.com, "gambit-iphone@iro.umontreal.ca " gambit-iphone@iro.umontreal.ca Date: Sunday, July 12, 2009, 11:54 AM
Hey Ryan,
I have not worked much on access to Touch events yet, and you're probably looking for specific FFI code as an example. Andrew, it would be great if you could share your code!
I was thinking of exposing access to the UITouch and other event objects so that you could benefit from the normal Cocoa API. When I do this, I will share this code.
Thanks, James
On Sun, Jul 12, 2009 at 1:30 PM, Andrew Andkjarandkjar@obtech.net wrote:
In the iPhone app I'm developing I am currently traversing the set
of touch
events in Objective-C and calling into touch-<began | moved | ended> Gambit-C callbacks I've defined that take an integer touch id and
x,y
coordinates. Active touches are tracked in Scheme in a hash table
keyed on
touch id. This has been suiting my multi-touch tracking needs so
far. I'd
be happy to share some code if there's interest. 'AA On Jul 11, 2009, at 6:03 PM, Ryan Spangler
patch_work8848@yahoo.com wrote:
Hey all,
I was looking into porting the touch events into gambit, but I am
pretty new
to gambit and the c ffi specifically. The touch events are somewhat complex, taking an NSSet * and a UIEvent *. From what I can tell,
the NSSet
contains all current touch points (so if you have three fingers
down, the
NSSet contains three touch points) and the UIEvent has a history
of all the
touch points and where they have been since the first
"touchesBegan" event,
though I am not sure of the specific structure of these objects
yet. I am
wondering what is the best way to translate these into scheme data structures?
Thanks for any guidance on this, and I also noticed that James was
talking
about working on touch facilities as well. Maybe we could join
forces on
this? Or maybe you are already done?
- Ryan
Gambit-iphone mailing list Gambit-iphone@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-iphone
Gambit-iphone mailing list Gambit-iphone@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-iphone
gambit-iphone@iro.umontreal.ca