Browse Source

tags/2021-05-28
jules 18 years ago
parent
commit
7182195672
3 changed files with 86 additions and 86 deletions
  1. +32
    -32
      build/macosx/platform_specific_code/juce_mac_Windowing.cpp
  2. +43
    -43
      extras/juce demo/src/demos/WidgetsDemo.cpp
  3. +11
    -11
      src/juce_core/misc/juce_PlatformUtilities.h

+ 32
- 32
build/macosx/platform_specific_code/juce_mac_Windowing.cpp View File

@@ -2240,8 +2240,8 @@ void Desktop::setMousePosition (int x, int y) throw()
{
// this rubbish needs to be done around the warp call, to avoid causing a
// bizarre glitch..
CGAssociateMouseAndMouseCursorPosition (false);
CGSetLocalEventsSuppressionInterval (0);
CGAssociateMouseAndMouseCursorPosition (false);
CGSetLocalEventsSuppressionInterval (0);

CGPoint pos = { x, y };
CGWarpMouseCursorPosition (pos);
@@ -3048,7 +3048,7 @@ static bool createAppleRemoteInterface (io_object_t iod, void** device) throw()
&cfPlugInInterface,
&score) == kIOReturnSuccess)
{
HRESULT hr = (*cfPlugInInterface)->QueryInterface (cfPlugInInterface,
HRESULT hr = (*cfPlugInInterface)->QueryInterface (cfPlugInInterface,
CFUUIDGetUUIDBytes (kIOHIDDeviceInterfaceID),
device);

@@ -3074,7 +3074,7 @@ bool AppleRemoteDevice::start (const bool inExclusiveMode) throw()
if (iod != 0)
{
if (createAppleRemoteInterface (iod, &device) && open (inExclusiveMode))
result = true;
result = true;
else
stop();

@@ -3096,8 +3096,8 @@ void AppleRemoteDevice::stop() throw()

if (device != 0)
{
(*(IOHIDDeviceInterface**) device)->close ((IOHIDDeviceInterface**) device);
(*(IOHIDDeviceInterface**) device)->Release ((IOHIDDeviceInterface**) device);
(*(IOHIDDeviceInterface**) device)->close ((IOHIDDeviceInterface**) device);
(*(IOHIDDeviceInterface**) device)->Release ((IOHIDDeviceInterface**) device);
device = 0;
}
}
@@ -3105,7 +3105,7 @@ void AppleRemoteDevice::stop() throw()
static void appleRemoteQueueCallback (void* const target, const IOReturn result, void*, void*)
{
if (result == kIOReturnSuccess)
((AppleRemoteDevice*) target)->handleCallbackInternal();
((AppleRemoteDevice*) target)->handleCallbackInternal();
}

bool AppleRemoteDevice::open (const bool openInExclusiveMode) throw()
@@ -3135,7 +3135,7 @@ bool AppleRemoteDevice::open (const bool openInExclusiveMode) throw()

cookies.add ((int) number);
}
CFRelease (elements);

if ((*(IOHIDDeviceInterface**) device)
@@ -3143,34 +3143,34 @@ bool AppleRemoteDevice::open (const bool openInExclusiveMode) throw()
openInExclusiveMode ? kIOHIDOptionsTypeSeizeDevice
: kIOHIDOptionsTypeNone) == KERN_SUCCESS)
{
queue = (*(IOHIDDeviceInterface**) device)->allocQueue ((IOHIDDeviceInterface**) device);
queue = (*(IOHIDDeviceInterface**) device)->allocQueue ((IOHIDDeviceInterface**) device);

if (queue != 0)
if (queue != 0)
{
(*(IOHIDQueueInterface**) queue)->create ((IOHIDQueueInterface**) queue, 0, 12);
(*(IOHIDQueueInterface**) queue)->create ((IOHIDQueueInterface**) queue, 0, 12);

for (int i = 0; i < cookies.size(); ++i)
for (int i = 0; i < cookies.size(); ++i)
{
IOHIDElementCookie cookie = (IOHIDElementCookie) cookies.getUnchecked(i);
(*(IOHIDQueueInterface**) queue)->addElement ((IOHIDQueueInterface**) queue, cookie, 0);
}
IOHIDElementCookie cookie = (IOHIDElementCookie) cookies.getUnchecked(i);
(*(IOHIDQueueInterface**) queue)->addElement ((IOHIDQueueInterface**) queue, cookie, 0);
}

CFRunLoopSourceRef eventSource;
CFRunLoopSourceRef eventSource;

if ((*(IOHIDQueueInterface**) queue)
if ((*(IOHIDQueueInterface**) queue)
->createAsyncEventSource ((IOHIDQueueInterface**) queue, &eventSource) == KERN_SUCCESS)
{
if ((*(IOHIDQueueInterface**) queue)->setEventCallout ((IOHIDQueueInterface**) queue,
if ((*(IOHIDQueueInterface**) queue)->setEventCallout ((IOHIDQueueInterface**) queue,
appleRemoteQueueCallback, this, 0) == KERN_SUCCESS)
{
CFRunLoopAddSource (CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode);
CFRunLoopAddSource (CFRunLoopGetCurrent(), eventSource, kCFRunLoopDefaultMode);

(*(IOHIDQueueInterface**) queue)->start ((IOHIDQueueInterface**) queue);
(*(IOHIDQueueInterface**) queue)->start ((IOHIDQueueInterface**) queue);

return true;
}
}
}
return true;
}
}
}
}
#endif

@@ -3188,19 +3188,19 @@ void AppleRemoteDevice::handleCallbackInternal()
{
IOHIDEventStruct e;

if ((*(IOHIDQueueInterface**) queue)->getNextEvent ((IOHIDQueueInterface**) queue, &e, nullTime, 0) != kIOReturnSuccess)
break;
if ((*(IOHIDQueueInterface**) queue)->getNextEvent ((IOHIDQueueInterface**) queue, &e, nullTime, 0) != kIOReturnSuccess)
break;

if ((int) e.elementCookie == 19)
if ((int) e.elementCookie == 19)
{
remoteId = e.value;
buttonPressed (switched, false);
}
remoteId = e.value;
buttonPressed (switched, false);
}
else
{
totalValues += e.value;
totalValues += e.value;
cookies [numCookies++] = (char) (pointer_sized_int) e.elementCookie;
}
}
}

cookies [numCookies++] = 0;


+ 43
- 43
extras/juce demo/src/demos/WidgetsDemo.cpp View File

@@ -1026,37 +1026,37 @@ public:
#if JUCE_MAC
//==============================================================================
/** This pops open a dialog box and waits for you to press keys on your Apple Remote,
which it describes in the box.
*/
class AppleRemoteTestWindow : public AlertWindow,
public AppleRemoteDevice
{
public:
AppleRemoteTestWindow()
: AlertWindow ("Apple Remote Control Test!",
"If you've got an Apple Remote, press some buttons now...",
AlertWindow::NoIcon)
{
addButton (T("done"), 0);
// (To open the device in non-exclusive mode, pass 'false' in here)..
if (! start (true))
setMessage ("Couldn't open the remote control device!");
}
~AppleRemoteTestWindow()
{
stop();
}
void buttonPressed (const ButtonType buttonId, const bool isDown)
{
String desc;
switch (buttonId)
{
//==============================================================================
/** This pops open a dialog box and waits for you to press keys on your Apple Remote,
which it describes in the box.
*/
class AppleRemoteTestWindow : public AlertWindow,
public AppleRemoteDevice
{
public:
AppleRemoteTestWindow()
: AlertWindow ("Apple Remote Control Test!",
"If you've got an Apple Remote, press some buttons now...",
AlertWindow::NoIcon)
{
addButton (T("done"), 0);
// (To open the device in non-exclusive mode, pass 'false' in here)..
if (! start (true))
setMessage ("Couldn't open the remote control device!");
}
~AppleRemoteTestWindow()
{
stop();
}
void buttonPressed (const ButtonType buttonId, const bool isDown)
{
String desc;
switch (buttonId)
{
case menuButton:
desc = "menu button (short)";
break;
@@ -1087,18 +1087,18 @@ public:
case playButtonSleepMode:
desc = "play (sleep mode)";
break;
case switched:
case switched:
desc = "remote switched";
break;
}
if (isDown)
desc << " -- [down]";
else
desc << " -- [up]";
setMessage (desc);
}
}
if (isDown)
desc << " -- [down]";
else
desc << " -- [up]";
setMessage (desc);
}
};
#endif
@@ -1318,8 +1318,8 @@ public:
else if (result == 140)
{
#if JUCE_MAC
AppleRemoteTestWindow test;
test.runModalLoop();
AppleRemoteTestWindow test;
test.runModalLoop();
#endif
}
else if (result >= 121 && result < 139)


+ 11
- 11
src/juce_core/misc/juce_PlatformUtilities.h View File

@@ -172,17 +172,17 @@ public:
*/
enum ButtonType
{
menuButton = 0, /**< The menu button (if it's held for a short time). */
playButton, /**< The play button. */
plusButton, /**< The plus or volume-up button. */
minusButton, /**< The minus or volume-down button. */
rightButton, /**< The right button (if it's held for a short time). */
leftButton, /**< The left button (if it's held for a short time). */
rightButton_Long, /**< The right button (if it's held for a long time). */
leftButton_Long, /**< The menu button (if it's held for a long time). */
menuButton_Long, /**< The menu button (if it's held for a long time). */
playButtonSleepMode,
switched
menuButton = 0, /**< The menu button (if it's held for a short time). */
playButton, /**< The play button. */
plusButton, /**< The plus or volume-up button. */
minusButton, /**< The minus or volume-down button. */
rightButton, /**< The right button (if it's held for a short time). */
leftButton, /**< The left button (if it's held for a short time). */
rightButton_Long, /**< The right button (if it's held for a long time). */
leftButton_Long, /**< The menu button (if it's held for a long time). */
menuButton_Long, /**< The menu button (if it's held for a long time). */
playButtonSleepMode,
switched
};
//==============================================================================


Loading…
Cancel
Save