diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2008-07-22 15:23:12 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@iem.at> | 2015-10-14 15:08:26 +0200 |
commit | 25dcbfc009a7fbf95a4e2e8788a5cf68d2cdd7b1 (patch) | |
tree | 84e3ce3606a8db1ba3cc3b8f889ff97d45e0d91b /aka.wiiremote/aka.wiiremote.c | |
parent | 590fa42a7ca536666dd4c76a7398b011bbd886e0 (diff) |
first working version, bangs now get udpated data properly, but the various
other messages don't work, like [motion $1(, [ir $1(, etc.
To get it working, I used CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true),
which runs the CFRunLoop until just one event has been processed.
svn path=/trunk/externals/io/; revision=10206
Diffstat (limited to 'aka.wiiremote/aka.wiiremote.c')
-rw-r--r-- | aka.wiiremote/aka.wiiremote.c | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/aka.wiiremote/aka.wiiremote.c b/aka.wiiremote/aka.wiiremote.c index 0831f44..5834b63 100644 --- a/aka.wiiremote/aka.wiiremote.c +++ b/aka.wiiremote/aka.wiiremote.c @@ -10,6 +10,7 @@ #ifdef PD #include "m_pd.h" +#include "m_imp.h" #define SETSYM SETSYMBOL #define SETLONG SETFLOAT #define method t_method @@ -48,12 +49,6 @@ typedef struct _akawiiremote void *dataOut; } t_akawiiremote; -#ifdef PD -static IONotificationPortRef gNotifyPort; -static io_iterator_t gAddedIter; -static CFRunLoopRef gRunLoop; -#endif - void akawiiremote_bang(t_akawiiremote *x); void akawiiremote_address(t_akawiiremote *x, t_symbol *s); void akawiiremote_connect(t_akawiiremote *x); @@ -165,7 +160,9 @@ void akawiiremote_bang(t_akawiiremote *x) if (x->wiiremote->device == nil) return; // do nothing - +#ifdef PD + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); +#endif if (x->wiiremote->isExpansionPortAttached && x->wiiremote->isExpansionPortEnabled) { // Classic Controller @@ -544,6 +541,9 @@ void akawiiremote_clock(t_akawiiremote *x) if (x->connected == false && connection == true) // if the device is connected... { +#ifdef PD + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true); +#endif wiiremote_getstatus(x->wiiremote); x->connected = true; SETLONG(&status, 1); @@ -595,24 +595,6 @@ void *akawiiremote_new(t_symbol *s, short ac, t_atom *av) first_argument = atom_getsymbolarg(0, ac, av); if(first_argument != &s_) atom_string(av, x->address, MAXPDSTRING-1); - - IOReturn result = kIOReturnSuccess; - mach_port_t masterPort = (mach_port_t) NULL; - result = IOMasterPort (bootstrap_port, &masterPort); - if (kIOReturnSuccess != result) - pd_error(x, "[akawiiremote] IOMasterPort error with bootstrap_port, error %d", result); - else - { - // Create a notification port and add its run loop event source to our run loop - // This is how async notifications get set up. - CFRunLoopSourceRef runLoopSource; - - gNotifyPort = IONotificationPortCreate(masterPort); - runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort); - - gRunLoop = CFRunLoopGetCurrent(); - CFRunLoopAddSource(gRunLoop, runLoopSource, kCFRunLoopDefaultMode); - } #else /* Max */ t_akawiiremote *x; |