Esempio n. 1
0
// ----------------------------------------------------------------------------
// wxHIDKeyboard::BuildCookies
//
// Callback from Create() to build the HID cookies for the internal cookie
// array
// ----------------------------------------------------------------------------
void wxHIDKeyboard::BuildCookies(CFArrayRef Array)
{
    //Create internal cookie array
    InitCookies(500);

    //Begin recursing in array
    DoBuildCookies(Array);
}
Esempio n. 2
0
//---------------------------------------------------------------------------
// wxHIDJoystick::BuildCookies
// wxHIDJoystick::MakeCookies
//
// Sets up the cookies for the HID device (called from Create) - as
// mentioned 0-40 are the buttons and 40-50 are the axes.
//
// MakeCookies is just a recursive function for each array within
// BuildCookies.
//---------------------------------------------------------------------------
void wxHIDJoystick::BuildCookies(CFArrayRef Array)
{
    InitCookies(50, true);

    //
    // I wasted two hours of my life on this line :(
    // accidently removed it during some source cleaning...
    //
    MakeCookies(Array);

    //paranoid debugging stuff
#if 0
    for(int i = 0; i < 50; ++i)
        wxPrintf(wxT("\nVAL #%i:[%i]"), i, m_pCookies[i]);
#endif
}//end buildcookies
Esempio n. 3
0
void wxHIDKeyboard::BuildCookies(wxCFArray& Array)
{
    Array = CFDictionaryGetValue((CFDictionaryRef)Array[0], CFSTR(kIOHIDElementKey));
    InitCookies(500);
    int i,
        nUsage;
    bool bEOTriggered = false;
    for (i = 0; i < Array.Count(); ++i)
    {
        CFNumberGetValue(
            (CFNumberRef) CFDictionaryGetValue((CFDictionaryRef) Array[i], CFSTR(kIOHIDElementUsageKey)),
                kCFNumberLongType, &nUsage);

        //
        // OK, this is strange - basically this kind of strange -
        // Starting from 0xEO these elements (like shift) appear twice in
        // the array!  The ones at the end are bogus I guess - the funny part
        // is that besides the fact that the ones at the front have a Unit
        // and UnitExponent key with a value of 0 and a different cookie value,
        // there is no discernable difference between the two...
        //
        // Will the real shift please stand up?
        //
        // Something to spend a support request on, if I had one, LOL.
        //
        if(nUsage == 0xE0)
        {
            if(bEOTriggered)
               break;
            bEOTriggered = true;
        }
/*
        wxString msg;
        int cookie;
            CFNumberGetValue(
                (CFNumberRef) CFDictionaryGetValue    ( (CFDictionaryRef) Array[i]
                                        , CFSTR(kIOHIDElementCookieKey)
                                        ),
                kCFNumberIntType,
                &cookie
                );

        msg << wxT("KEY:") << nUsage << wxT("COOKIE:") << cookie;
        wxLogDebug(msg);
*/

        if (nUsage >= kHIDUsage_KeyboardA && nUsage <= kHIDUsage_KeyboardZ)
            AddCookie(Array[i], 'A' + (nUsage - kHIDUsage_KeyboardA) );
        else if (nUsage >= kHIDUsage_Keyboard1 && nUsage <= kHIDUsage_Keyboard9)
            AddCookie(Array[i], '1' + (nUsage - kHIDUsage_Keyboard1) );
        else if (nUsage >= kHIDUsage_KeyboardF1 && nUsage <= kHIDUsage_KeyboardF12)
            AddCookie(Array[i], WXK_F1 + (nUsage - kHIDUsage_KeyboardF1) );
        else if (nUsage >= kHIDUsage_KeyboardF13 && nUsage <= kHIDUsage_KeyboardF24)
            AddCookie(Array[i], WXK_F13 + (nUsage - kHIDUsage_KeyboardF13) );
        else if (nUsage >= kHIDUsage_Keypad1 && nUsage <= kHIDUsage_Keypad9)
            AddCookie(Array[i], WXK_NUMPAD1 + (nUsage - kHIDUsage_Keypad1) );
        else switch (nUsage)
        {
            //0's (wx & ascii go 0-9, but HID goes 1-0)
            case kHIDUsage_Keyboard0:
                AddCookie(Array[i],'0');
                break;
            case kHIDUsage_Keypad0:
                AddCookie(Array[i],WXK_NUMPAD0);
                break;

            //Basic
            case kHIDUsage_KeyboardReturnOrEnter:
                AddCookie(Array[i], WXK_RETURN);
                break;
            case kHIDUsage_KeyboardEscape:
                AddCookie(Array[i], WXK_ESCAPE);
                break;
            case kHIDUsage_KeyboardDeleteOrBackspace:
                AddCookie(Array[i], WXK_BACK);
                break;
            case kHIDUsage_KeyboardTab:
                AddCookie(Array[i], WXK_TAB);
                break;
            case kHIDUsage_KeyboardSpacebar:
                AddCookie(Array[i], WXK_SPACE);
                break;
            case kHIDUsage_KeyboardPageUp:
                AddCookie(Array[i], WXK_PRIOR);
                break;
            case kHIDUsage_KeyboardEnd:
                AddCookie(Array[i], WXK_END);
                break;
            case kHIDUsage_KeyboardPageDown:
                AddCookie(Array[i], WXK_NEXT);
                break;
            case kHIDUsage_KeyboardRightArrow:
                AddCookie(Array[i], WXK_RIGHT);
                break;
            case kHIDUsage_KeyboardLeftArrow:
                AddCookie(Array[i], WXK_LEFT);
                break;
            case kHIDUsage_KeyboardDownArrow:
                AddCookie(Array[i], WXK_DOWN);
                break;
            case kHIDUsage_KeyboardUpArrow:
                AddCookie(Array[i], WXK_UP);
                break;

            //LEDS
            case kHIDUsage_KeyboardCapsLock:
                AddCookie(Array[i],WXK_CAPITAL);
                break;
            case kHIDUsage_KeypadNumLock:
                AddCookie(Array[i],WXK_NUMLOCK);
                break;
            case kHIDUsage_KeyboardScrollLock:
                AddCookie(Array[i],WXK_SCROLL);
                break;

            //Menu keys, Shift, other specials
            case kHIDUsage_KeyboardLeftControl:
                AddCookie(Array[i],WXK_CONTROL);
                break;
            case kHIDUsage_KeyboardLeftShift:
                AddCookie(Array[i],WXK_SHIFT);
                break;
            case kHIDUsage_KeyboardLeftAlt:
                AddCookie(Array[i],WXK_ALT);
                break;
            case kHIDUsage_KeyboardLeftGUI:
                AddCookie(Array[i],WXK_MENU);
                break;
            case kHIDUsage_KeyboardRightControl:
                AddCookie(Array[i],WXK_RCONTROL);
                break;
            case kHIDUsage_KeyboardRightShift:
                AddCookie(Array[i],WXK_RSHIFT);
                break;
            case kHIDUsage_KeyboardRightAlt:
                AddCookie(Array[i],WXK_RALT);
                break;
            case kHIDUsage_KeyboardRightGUI:
                AddCookie(Array[i],WXK_RMENU);
                break;

            //Default
            default:
            //not in wx keycodes - do nothing....
            break;
        }
    }
}//end buildcookies