repo_id
stringlengths
27
162
file_path
stringlengths
42
195
content
stringlengths
4
5.16M
__index_level_0__
int64
0
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\android\SDL_android.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_stdinc.h" #include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_log.h" #include "SDL_main.h" #ifdef __ANDROID__ #include "SDL_system.h" #include "SDL_android.h" #include "keyinfotable.h" #include "../../events/SDL_events_c.h" #include "../../video/android/SDL_androidkeyboard.h" #include "../../video/android/SDL_androidmouse.h" #include "../../video/android/SDL_androidtouch.h" #include "../../video/android/SDL_androidvideo.h" #include "../../video/android/SDL_androidwindow.h" #include "../../joystick/android/SDL_sysjoystick_c.h" #include "../../haptic/android/SDL_syshaptic_c.h" #include <android/log.h> #include <pthread.h> #include <sys/types.h> #include <unistd.h> #include <dlfcn.h> /* #define LOG_TAG "SDL_android" */ /* #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__) */ /* #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) */ #define LOGI(...) do {} while (0) #define LOGE(...) do {} while (0) #define SDL_JAVA_PREFIX org_libsdl_app #define CONCAT1(prefix, class, function) CONCAT2(prefix, class, function) #define CONCAT2(prefix, class, function) Java_ ## prefix ## _ ## class ## _ ## function #define SDL_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLActivity, function) #define SDL_JAVA_AUDIO_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLAudioManager, function) #define SDL_JAVA_CONTROLLER_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, SDLControllerManager, function) #define SDL_JAVA_INTERFACE_INPUT_CONNECTION(function) CONCAT1(SDL_JAVA_PREFIX, SDLInputConnection, function) /* Java class SDLActivity */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)( JNIEnv* mEnv, jclass cls); JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)( JNIEnv* env, jclass cls, jstring library, jstring function, jobject array); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEnv* env, jclass jcls, jstring filename); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv* env, jclass jcls, jint surfaceWidth, jint surfaceHeight, jint deviceWidth, jint deviceHeight, jint format, jfloat rate); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)( JNIEnv* env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)( JNIEnv* env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( JNIEnv* env, jclass jcls, jint keycode); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( JNIEnv* env, jclass jcls, jint keycode); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( JNIEnv* env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( JNIEnv* env, jclass jcls, jint touch_device_id_in, jint pointer_finger_id_in, jint action, jfloat x, jfloat y, jfloat p); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( JNIEnv* env, jclass jcls, jint button, jint action, jfloat x, jfloat y, jboolean relative); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( JNIEnv* env, jclass jcls, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( JNIEnv* env, jclass jcls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( JNIEnv* env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( JNIEnv* env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( JNIEnv* env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( JNIEnv* env, jclass cls); JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( JNIEnv* env, jclass cls, jstring name); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( JNIEnv* env, jclass cls, jstring name, jstring value); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeEnvironmentVariablesSet)( JNIEnv* env, jclass cls); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEnv* env, jclass cls, jint orientation); /* Java class SDLInputConnection */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( JNIEnv* env, jclass cls, jstring text, jint newCursorPosition); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)( JNIEnv* env, jclass cls, jstring text, jint newCursorPosition); /* Java class SDLAudioManager */ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)( JNIEnv *env, jclass jcls); /* Java class SDLControllerManager */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)( JNIEnv *env, jclass jcls); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( JNIEnv* env, jclass jcls, jint device_id, jint keycode); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( JNIEnv* env, jclass jcls, jint device_id, jint keycode); JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( JNIEnv* env, jclass jcls, jint device_id, jint axis, jfloat value); JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( JNIEnv* env, jclass jcls, jint device_id, jint hat_id, jint x, jint y); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( JNIEnv* env, jclass jcls, jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id, jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( JNIEnv* env, jclass jcls, jint device_id); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( JNIEnv* env, jclass jcls, jint device_id, jstring device_name); JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( JNIEnv* env, jclass jcls, jint device_id); /* Uncomment this to log messages entering and exiting methods in this file */ /* #define DEBUG_JNI */ static void Android_JNI_ThreadDestroyed(void*); /******************************************************************************* This file links the Java side of Android with libsdl *******************************************************************************/ #include <jni.h> /******************************************************************************* Globals *******************************************************************************/ static pthread_key_t mThreadKey; static JavaVM* mJavaVM; /* Main activity */ static jclass mActivityClass; /* method signatures */ static jmethodID midGetNativeSurface; static jmethodID midSetActivityTitle; static jmethodID midSetWindowStyle; static jmethodID midSetOrientation; static jmethodID midGetContext; static jmethodID midIsTablet; static jmethodID midIsAndroidTV; static jmethodID midIsChromebook; static jmethodID midIsDeXMode; static jmethodID midManualBackButton; static jmethodID midInputGetInputDeviceIds; static jmethodID midSendMessage; static jmethodID midShowTextInput; static jmethodID midIsScreenKeyboardShown; static jmethodID midClipboardSetText; static jmethodID midClipboardGetText; static jmethodID midClipboardHasText; static jmethodID midOpenAPKExpansionInputStream; static jmethodID midGetManifestEnvironmentVariables; static jmethodID midGetDisplayDPI; static jmethodID midCreateCustomCursor; static jmethodID midSetCustomCursor; static jmethodID midSetSystemCursor; static jmethodID midSupportsRelativeMouse; static jmethodID midSetRelativeMouseEnabled; /* audio manager */ static jclass mAudioManagerClass; /* method signatures */ static jmethodID midAudioOpen; static jmethodID midAudioWriteShortBuffer; static jmethodID midAudioWriteByteBuffer; static jmethodID midAudioClose; static jmethodID midCaptureOpen; static jmethodID midCaptureReadShortBuffer; static jmethodID midCaptureReadByteBuffer; static jmethodID midCaptureClose; /* controller manager */ static jclass mControllerManagerClass; /* method signatures */ static jmethodID midPollInputDevices; static jmethodID midPollHapticDevices; static jmethodID midHapticRun; static jmethodID midHapticStop; /* static fields */ static jfieldID fidSeparateMouseAndTouch; /* Accelerometer data storage */ static float fLastAccelerometer[3]; static SDL_bool bHasNewData; static SDL_bool bHasEnvironmentVariables = SDL_FALSE; /******************************************************************************* Functions called by JNI *******************************************************************************/ /* Library init */ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEnv *env; mJavaVM = vm; LOGI("JNI_OnLoad called"); if ((*mJavaVM)->GetEnv(mJavaVM, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { LOGE("Failed to get the environment using GetEnv()"); return -1; } /* * Create mThreadKey so we can keep track of the JNIEnv assigned to each thread * Refer to http://developer.android.com/guide/practices/design/jni.html for the rationale behind this */ if (pthread_key_create(&mThreadKey, Android_JNI_ThreadDestroyed) != 0) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Error initializing pthread key"); } Android_JNI_SetupThread(); return JNI_VERSION_1_4; } void checkJNIReady() { if (!mActivityClass || !mAudioManagerClass || !mControllerManagerClass) { // We aren't fully initialized, let's just return. return; } SDL_SetMainReady(); } /* Activity initialization -- called before SDL_main() to initialize JNI bindings */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeSetupJNI()"); Android_JNI_SetupThread(); mActivityClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls)); midGetNativeSurface = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getNativeSurface","()Landroid/view/Surface;"); midSetActivityTitle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setActivityTitle","(Ljava/lang/String;)Z"); midSetWindowStyle = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setWindowStyle","(Z)V"); midSetOrientation = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setOrientation","(IIZLjava/lang/String;)V"); midGetContext = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getContext","()Landroid/content/Context;"); midIsTablet = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isTablet", "()Z"); midIsAndroidTV = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isAndroidTV","()Z"); midIsChromebook = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isChromebook", "()Z"); midIsDeXMode = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isDeXMode", "()Z"); midManualBackButton = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "manualBackButton", "()V"); midInputGetInputDeviceIds = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "inputGetInputDeviceIds", "(I)[I"); midSendMessage = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "sendMessage", "(II)Z"); midShowTextInput = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "showTextInput", "(IIII)Z"); midIsScreenKeyboardShown = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "isScreenKeyboardShown","()Z"); midClipboardSetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "clipboardSetText", "(Ljava/lang/String;)V"); midClipboardGetText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "clipboardGetText", "()Ljava/lang/String;"); midClipboardHasText = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "clipboardHasText", "()Z"); midOpenAPKExpansionInputStream = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "openAPKExpansionInputStream", "(Ljava/lang/String;)Ljava/io/InputStream;"); midGetManifestEnvironmentVariables = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getManifestEnvironmentVariables", "()Z"); midGetDisplayDPI = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "getDisplayDPI", "()Landroid/util/DisplayMetrics;"); midCreateCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "createCustomCursor", "([IIIII)I"); midSetCustomCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setCustomCursor", "(I)Z"); midSetSystemCursor = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setSystemCursor", "(I)Z"); midSupportsRelativeMouse = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "supportsRelativeMouse", "()Z"); midSetRelativeMouseEnabled = (*mEnv)->GetStaticMethodID(mEnv, mActivityClass, "setRelativeMouseEnabled", "(Z)Z"); if (!midGetNativeSurface || !midSetActivityTitle || !midSetWindowStyle || !midSetOrientation || !midGetContext || !midIsTablet || !midIsAndroidTV || !midInputGetInputDeviceIds || !midSendMessage || !midShowTextInput || !midIsScreenKeyboardShown || !midClipboardSetText || !midClipboardGetText || !midClipboardHasText || !midOpenAPKExpansionInputStream || !midGetManifestEnvironmentVariables || !midGetDisplayDPI || !midCreateCustomCursor || !midSetCustomCursor || !midSetSystemCursor || !midSupportsRelativeMouse || !midSetRelativeMouseEnabled || !midIsChromebook || !midIsDeXMode || !midManualBackButton) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLActivity.java?"); } fidSeparateMouseAndTouch = (*mEnv)->GetStaticFieldID(mEnv, mActivityClass, "mSeparateMouseAndTouch", "Z"); if (!fidSeparateMouseAndTouch) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java static fields, do you have the latest version of SDLActivity.java?"); } checkJNIReady(); } /* Audio initialization -- called before SDL_main() to initialize JNI bindings */ JNIEXPORT void JNICALL SDL_JAVA_AUDIO_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "AUDIO nativeSetupJNI()"); Android_JNI_SetupThread(); mAudioManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls)); midAudioOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "audioOpen", "(IZZI)I"); midAudioWriteShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "audioWriteShortBuffer", "([S)V"); midAudioWriteByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "audioWriteByteBuffer", "([B)V"); midAudioClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "audioClose", "()V"); midCaptureOpen = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "captureOpen", "(IZZI)I"); midCaptureReadShortBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "captureReadShortBuffer", "([SZ)I"); midCaptureReadByteBuffer = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "captureReadByteBuffer", "([BZ)I"); midCaptureClose = (*mEnv)->GetStaticMethodID(mEnv, mAudioManagerClass, "captureClose", "()V"); if (!midAudioOpen || !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioClose || !midCaptureOpen || !midCaptureReadShortBuffer || !midCaptureReadByteBuffer || !midCaptureClose) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLAudioManager.java?"); } checkJNIReady(); } /* Controller initialization -- called before SDL_main() to initialize JNI bindings */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeSetupJNI)(JNIEnv* mEnv, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "CONTROLLER nativeSetupJNI()"); Android_JNI_SetupThread(); mControllerManagerClass = (jclass)((*mEnv)->NewGlobalRef(mEnv, cls)); midPollInputDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass, "pollInputDevices", "()V"); midPollHapticDevices = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass, "pollHapticDevices", "()V"); midHapticRun = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass, "hapticRun", "(II)V"); midHapticStop = (*mEnv)->GetStaticMethodID(mEnv, mControllerManagerClass, "hapticStop", "(I)V"); if (!midPollInputDevices || !midPollHapticDevices || !midHapticRun || !midHapticStop) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Missing some Java callbacks, do you have the latest version of SDLControllerManager.java?"); } checkJNIReady(); } /* SDL main function prototype */ typedef int (*SDL_main_func)(int argc, char *argv[]); /* Start up the SDL app */ JNIEXPORT int JNICALL SDL_JAVA_INTERFACE(nativeRunMain)(JNIEnv* env, jclass cls, jstring library, jstring function, jobject array) { int status = -1; const char *library_file; void *library_handle; __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeRunMain()"); library_file = (*env)->GetStringUTFChars(env, library, NULL); library_handle = dlopen(library_file, RTLD_GLOBAL); if (library_handle) { const char *function_name; SDL_main_func SDL_main; function_name = (*env)->GetStringUTFChars(env, function, NULL); SDL_main = (SDL_main_func)dlsym(library_handle, function_name); if (SDL_main) { int i; int argc; int len; char **argv; /* Prepare the arguments. */ len = (*env)->GetArrayLength(env, array); argv = SDL_stack_alloc(char*, 1 + len + 1); argc = 0; /* Use the name "app_process" so PHYSFS_platformCalcBaseDir() works. https://bitbucket.org/MartinFelis/love-android-sdl2/issue/23/release-build-crash-on-start */ argv[argc++] = SDL_strdup("app_process"); for (i = 0; i < len; ++i) { const char* utf; char* arg = NULL; jstring string = (*env)->GetObjectArrayElement(env, array, i); if (string) { utf = (*env)->GetStringUTFChars(env, string, 0); if (utf) { arg = SDL_strdup(utf); (*env)->ReleaseStringUTFChars(env, string, utf); } (*env)->DeleteLocalRef(env, string); } if (!arg) { arg = SDL_strdup(""); } argv[argc++] = arg; } argv[argc] = NULL; /* Run the application. */ status = SDL_main(argc, argv); /* Release the arguments. */ for (i = 0; i < argc; ++i) { SDL_free(argv[i]); } SDL_stack_free(argv); } else { __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't find function %s in library %s", function_name, library_file); } (*env)->ReleaseStringUTFChars(env, function, function_name); dlclose(library_handle); } else { __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't load library %s", library_file); } (*env)->ReleaseStringUTFChars(env, library, library_file); /* Do not issue an exit or the whole application will terminate instead of just the SDL thread */ /* exit(status); */ return status; } /* Drop file */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEnv* env, jclass jcls, jstring filename) { const char *path = (*env)->GetStringUTFChars(env, filename, NULL); SDL_SendDropFile(NULL, path); (*env)->ReleaseStringUTFChars(env, filename, path); SDL_SendDropComplete(NULL); } /* Resize */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv* env, jclass jcls, jint surfaceWidth, jint surfaceHeight, jint deviceWidth, jint deviceHeight, jint format, jfloat rate) { Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate); } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeOrientationChanged)( JNIEnv *env, jclass jcls, jint orientation) { SDL_VideoDisplay *display = SDL_GetDisplay(0); SDL_SendDisplayEvent(display, SDL_DISPLAYEVENT_ORIENTATION, orientation); } /* Paddown */ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadDown)( JNIEnv* env, jclass jcls, jint device_id, jint keycode) { return Android_OnPadDown(device_id, keycode); } /* Padup */ JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativePadUp)( JNIEnv* env, jclass jcls, jint device_id, jint keycode) { return Android_OnPadUp(device_id, keycode); } /* Joy */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeJoy)( JNIEnv* env, jclass jcls, jint device_id, jint axis, jfloat value) { Android_OnJoy(device_id, axis, value); } /* POV Hat */ JNIEXPORT void JNICALL SDL_JAVA_CONTROLLER_INTERFACE(onNativeHat)( JNIEnv* env, jclass jcls, jint device_id, jint hat_id, jint x, jint y) { Android_OnHat(device_id, hat_id, x, y); } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddJoystick)( JNIEnv* env, jclass jcls, jint device_id, jstring device_name, jstring device_desc, jint vendor_id, jint product_id, jboolean is_accelerometer, jint button_mask, jint naxes, jint nhats, jint nballs) { int retval; const char *name = (*env)->GetStringUTFChars(env, device_name, NULL); const char *desc = (*env)->GetStringUTFChars(env, device_desc, NULL); retval = Android_AddJoystick(device_id, name, desc, vendor_id, product_id, is_accelerometer ? SDL_TRUE : SDL_FALSE, button_mask, naxes, nhats, nballs); (*env)->ReleaseStringUTFChars(env, device_name, name); (*env)->ReleaseStringUTFChars(env, device_desc, desc); return retval; } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveJoystick)( JNIEnv* env, jclass jcls, jint device_id) { return Android_RemoveJoystick(device_id); } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeAddHaptic)( JNIEnv* env, jclass jcls, jint device_id, jstring device_name) { int retval; const char *name = (*env)->GetStringUTFChars(env, device_name, NULL); retval = Android_AddHaptic(device_id, name); (*env)->ReleaseStringUTFChars(env, device_name, name); return retval; } JNIEXPORT jint JNICALL SDL_JAVA_CONTROLLER_INTERFACE(nativeRemoveHaptic)( JNIEnv* env, jclass jcls, jint device_id) { return Android_RemoveHaptic(device_id); } /* Surface Created */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv* env, jclass jcls) { SDL_WindowData *data; SDL_VideoDevice *_this; if (Android_Window == NULL || Android_Window->driverdata == NULL ) { return; } _this = SDL_GetVideoDevice(); data = (SDL_WindowData *) Android_Window->driverdata; /* If the surface has been previously destroyed by onNativeSurfaceDestroyed, recreate it here */ if (data->egl_surface == EGL_NO_SURFACE) { if(data->native_window) { ANativeWindow_release(data->native_window); } data->native_window = Android_JNI_GetNativeWindow(); data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType) data->native_window); } /* GL Context handling is done in the event loop because this function is run from the Java thread */ } /* Surface Destroyed */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv* env, jclass jcls) { /* We have to clear the current context and destroy the egl surface here * Otherwise there's BAD_NATIVE_WINDOW errors coming from eglCreateWindowSurface on resume * Ref: http://stackoverflow.com/questions/8762589/eglcreatewindowsurface-on-ics-and-switching-from-2d-to-3d */ SDL_WindowData *data; SDL_VideoDevice *_this; if (Android_Window == NULL || Android_Window->driverdata == NULL ) { return; } _this = SDL_GetVideoDevice(); data = (SDL_WindowData *) Android_Window->driverdata; if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_MakeCurrent(_this, NULL, NULL); SDL_EGL_DestroySurface(_this, data->egl_surface); data->egl_surface = EGL_NO_SURFACE; } /* GL Context handling is done in the event loop because this function is run from the Java thread */ } /* Keydown */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyDown)( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyDown(keycode); } /* Keyup */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)( JNIEnv* env, jclass jcls, jint keycode) { Android_OnKeyUp(keycode); } /* Keyboard Focus Lost */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)( JNIEnv* env, jclass jcls) { /* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */ SDL_StopTextInput(); } /* Touch */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeTouch)( JNIEnv* env, jclass jcls, jint touch_device_id_in, jint pointer_finger_id_in, jint action, jfloat x, jfloat y, jfloat p) { Android_OnTouch(touch_device_id_in, pointer_finger_id_in, action, x, y, p); } /* Mouse */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeMouse)( JNIEnv* env, jclass jcls, jint button, jint action, jfloat x, jfloat y, jboolean relative) { Android_OnMouse(button, action, x, y, relative); } /* Accelerometer */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeAccel)( JNIEnv* env, jclass jcls, jfloat x, jfloat y, jfloat z) { fLastAccelerometer[0] = x; fLastAccelerometer[1] = y; fLastAccelerometer[2] = z; bHasNewData = SDL_TRUE; } /* Clipboard */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeClipboardChanged)( JNIEnv* env, jclass jcls) { SDL_SendClipboardUpdate(); } /* Low memory */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeLowMemory)( JNIEnv* env, jclass cls) { SDL_SendAppEvent(SDL_APP_LOWMEMORY); } /* Quit */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeQuit)( JNIEnv* env, jclass cls) { /* Discard previous events. The user should have handled state storage * in SDL_APP_WILLENTERBACKGROUND. After nativeQuit() is called, no * events other than SDL_QUIT and SDL_APP_TERMINATING should fire */ SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); /* Inject a SDL_QUIT event */ SDL_SendQuit(); SDL_SendAppEvent(SDL_APP_TERMINATING); /* Resume the event loop so that the app can catch SDL_QUIT which * should now be the top event in the event queue. */ if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem); } /* Pause */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativePause)( JNIEnv* env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativePause()"); if (Android_Window) { SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); SDL_SendAppEvent(SDL_APP_WILLENTERBACKGROUND); SDL_SendAppEvent(SDL_APP_DIDENTERBACKGROUND); /* *After* sending the relevant events, signal the pause semaphore * so the event loop knows to pause and (optionally) block itself */ if (!SDL_SemValue(Android_PauseSem)) SDL_SemPost(Android_PauseSem); } } /* Resume */ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeResume)( JNIEnv* env, jclass cls) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "nativeResume()"); if (Android_Window) { SDL_SendAppEvent(SDL_APP_WILLENTERFOREGROUND); SDL_SendAppEvent(SDL_APP_DIDENTERFOREGROUND); SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); SDL_SendWindowEvent(Android_Window, SDL_WINDOWEVENT_RESTORED, 0, 0); /* Signal the resume semaphore so the event loop knows to resume and restore the GL Context * We can't restore the GL Context here because it needs to be done on the SDL main thread * and this function will be called from the Java thread instead. */ if (!SDL_SemValue(Android_ResumeSem)) SDL_SemPost(Android_ResumeSem); } } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeCommitText)( JNIEnv* env, jclass cls, jstring text, jint newCursorPosition) { const char *utftext = (*env)->GetStringUTFChars(env, text, NULL); SDL_SendKeyboardText(utftext); (*env)->ReleaseStringUTFChars(env, text, utftext); } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancodeForUnichar)( JNIEnv* env, jclass cls, jchar chUnicode) { SDL_Scancode code = SDL_SCANCODE_UNKNOWN; uint16_t mod = 0; // We do not care about bigger than 127. if (chUnicode < 127) { AndroidKeyInfo info = unicharToAndroidKeyInfoTable[chUnicode]; code = info.code; mod = info.mod; } if (mod & KMOD_SHIFT) { /* If character uses shift, press shift down */ SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); } /* send a keydown and keyup even for the character */ SDL_SendKeyboardKey(SDL_PRESSED, code); SDL_SendKeyboardKey(SDL_RELEASED, code); if (mod & KMOD_SHIFT) { /* If character uses shift, press shift back up */ SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); } } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)( JNIEnv* env, jclass cls, jstring text, jint newCursorPosition) { const char *utftext = (*env)->GetStringUTFChars(env, text, NULL); SDL_SendEditingText(utftext, 0, 0); (*env)->ReleaseStringUTFChars(env, text, utftext); } JNIEXPORT jstring JNICALL SDL_JAVA_INTERFACE(nativeGetHint)( JNIEnv* env, jclass cls, jstring name) { const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *hint = SDL_GetHint(utfname); jstring result = (*env)->NewStringUTF(env, hint); (*env)->ReleaseStringUTFChars(env, name, utfname); return result; } JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetenv)( JNIEnv* env, jclass cls, jstring name, jstring value) { const char *utfname = (*env)->GetStringUTFChars(env, name, NULL); const char *utfvalue = (*env)->GetStringUTFChars(env, value, NULL); SDL_setenv(utfname, utfvalue, 1); (*env)->ReleaseStringUTFChars(env, name, utfname); (*env)->ReleaseStringUTFChars(env, value, utfvalue); } /******************************************************************************* Functions called by SDL into Java *******************************************************************************/ static int s_active = 0; struct LocalReferenceHolder { JNIEnv *m_env; const char *m_func; }; static struct LocalReferenceHolder LocalReferenceHolder_Setup(const char *func) { struct LocalReferenceHolder refholder; refholder.m_env = NULL; refholder.m_func = func; #ifdef DEBUG_JNI SDL_Log("Entering function %s", func); #endif return refholder; } static SDL_bool LocalReferenceHolder_Init(struct LocalReferenceHolder *refholder, JNIEnv *env) { const int capacity = 16; if ((*env)->PushLocalFrame(env, capacity) < 0) { SDL_SetError("Failed to allocate enough JVM local references"); return SDL_FALSE; } ++s_active; refholder->m_env = env; return SDL_TRUE; } static void LocalReferenceHolder_Cleanup(struct LocalReferenceHolder *refholder) { #ifdef DEBUG_JNI SDL_Log("Leaving function %s", refholder->m_func); #endif if (refholder->m_env) { JNIEnv* env = refholder->m_env; (*env)->PopLocalFrame(env, NULL); --s_active; } } static SDL_bool LocalReferenceHolder_IsActive(void) { return s_active > 0; } ANativeWindow* Android_JNI_GetNativeWindow(void) { ANativeWindow* anw; jobject s; JNIEnv *env = Android_JNI_GetEnv(); s = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetNativeSurface); anw = ANativeWindow_fromSurface(env, s); (*env)->DeleteLocalRef(env, s); return anw; } void Android_JNI_SetActivityTitle(const char *title) { JNIEnv *mEnv = Android_JNI_GetEnv(); jstring jtitle = (jstring)((*mEnv)->NewStringUTF(mEnv, title)); (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetActivityTitle, jtitle); (*mEnv)->DeleteLocalRef(mEnv, jtitle); } void Android_JNI_SetWindowStyle(SDL_bool fullscreen) { JNIEnv *mEnv = Android_JNI_GetEnv(); (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetWindowStyle, fullscreen ? 1 : 0); } void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint) { JNIEnv *mEnv = Android_JNI_GetEnv(); jstring jhint = (jstring)((*mEnv)->NewStringUTF(mEnv, (hint ? hint : ""))); (*mEnv)->CallStaticVoidMethod(mEnv, mActivityClass, midSetOrientation, w, h, (resizable? 1 : 0), jhint); (*mEnv)->DeleteLocalRef(mEnv, jhint); } SDL_bool Android_JNI_GetAccelerometerValues(float values[3]) { int i; SDL_bool retval = SDL_FALSE; if (bHasNewData) { for (i = 0; i < 3; ++i) { values[i] = fLastAccelerometer[i]; } bHasNewData = SDL_FALSE; retval = SDL_TRUE; } return retval; } static void Android_JNI_ThreadDestroyed(void* value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ JNIEnv *env = (JNIEnv*) value; if (env != NULL) { (*mJavaVM)->DetachCurrentThread(mJavaVM); pthread_setspecific(mThreadKey, NULL); } } JNIEnv* Android_JNI_GetEnv(void) { /* From http://developer.android.com/guide/practices/jni.html * All threads are Linux threads, scheduled by the kernel. * They're usually started from managed code (using Thread.start), but they can also be created elsewhere and then * attached to the JavaVM. For example, a thread started with pthread_create can be attached with the * JNI AttachCurrentThread or AttachCurrentThreadAsDaemon functions. Until a thread is attached, it has no JNIEnv, * and cannot make JNI calls. * Attaching a natively-created thread causes a java.lang.Thread object to be constructed and added to the "main" * ThreadGroup, making it visible to the debugger. Calling AttachCurrentThread on an already-attached thread * is a no-op. * Note: You can call this function any number of times for the same thread, there's no harm in it */ JNIEnv *env; int status = (*mJavaVM)->AttachCurrentThread(mJavaVM, &env, NULL); if(status < 0) { LOGE("failed to attach current thread"); return 0; } /* From http://developer.android.com/guide/practices/jni.html * Threads attached through JNI must call DetachCurrentThread before they exit. If coding this directly is awkward, * in Android 2.0 (Eclair) and higher you can use pthread_key_create to define a destructor function that will be * called before the thread exits, and call DetachCurrentThread from there. (Use that key with pthread_setspecific * to store the JNIEnv in thread-local-storage; that way it'll be passed into your destructor as the argument.) * Note: The destructor is not called unless the stored value is != NULL * Note: You can call this function any number of times for the same thread, there's no harm in it * (except for some lost CPU cycles) */ pthread_setspecific(mThreadKey, (void*) env); return env; } int Android_JNI_SetupThread(void) { Android_JNI_GetEnv(); return 1; } /* * Audio support */ static jboolean audioBuffer16Bit = JNI_FALSE; static jobject audioBuffer = NULL; static void* audioBufferPinned = NULL; static jboolean captureBuffer16Bit = JNI_FALSE; static jobject captureBuffer = NULL; int Android_JNI_OpenAudioDevice(int iscapture, int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames) { jboolean isStereo; int numBufferFrames; jobject jbufobj = NULL; jboolean isCopy; JNIEnv *env = Android_JNI_GetEnv(); if (!env) { LOGE("callback_handler: failed to attach current thread"); } Android_JNI_SetupThread(); isStereo = channelCount > 1; if (iscapture) { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for capture"); captureBuffer16Bit = is16Bit; if ((*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureOpen, sampleRate, is16Bit, isStereo, desiredBufferFrames) != 0) { /* Error during audio initialization */ __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: error on AudioRecord initialization!"); return 0; } } else { __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output"); audioBuffer16Bit = is16Bit; if ((*env)->CallStaticIntMethod(env, mAudioManagerClass, midAudioOpen, sampleRate, is16Bit, isStereo, desiredBufferFrames) != 0) { /* Error during audio initialization */ __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: error on AudioTrack initialization!"); return 0; } } /* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */ if (is16Bit) { jshortArray audioBufferLocal = (*env)->NewShortArray(env, desiredBufferFrames * (isStereo ? 2 : 1)); if (audioBufferLocal) { jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); (*env)->DeleteLocalRef(env, audioBufferLocal); } } else { jbyteArray audioBufferLocal = (*env)->NewByteArray(env, desiredBufferFrames * (isStereo ? 2 : 1)); if (audioBufferLocal) { jbufobj = (*env)->NewGlobalRef(env, audioBufferLocal); (*env)->DeleteLocalRef(env, audioBufferLocal); } } if (jbufobj == NULL) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer!"); return 0; } if (iscapture) { captureBuffer = jbufobj; } else { audioBuffer = jbufobj; } isCopy = JNI_FALSE; if (is16Bit) { if (iscapture) { numBufferFrames = (*env)->GetArrayLength(env, (jshortArray)captureBuffer); } else { audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy); numBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer); } } else { if (iscapture) { numBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer); } else { audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy); numBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer); } } if (isStereo) { numBufferFrames /= 2; } return numBufferFrames; } int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi) { JNIEnv *env = Android_JNI_GetEnv(); jobject jDisplayObj = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetDisplayDPI); jclass jDisplayClass = (*env)->GetObjectClass(env, jDisplayObj); jfieldID fidXdpi = (*env)->GetFieldID(env, jDisplayClass, "xdpi", "F"); jfieldID fidYdpi = (*env)->GetFieldID(env, jDisplayClass, "ydpi", "F"); jfieldID fidDdpi = (*env)->GetFieldID(env, jDisplayClass, "densityDpi", "I"); float nativeXdpi = (*env)->GetFloatField(env, jDisplayObj, fidXdpi); float nativeYdpi = (*env)->GetFloatField(env, jDisplayObj, fidYdpi); int nativeDdpi = (*env)->GetIntField(env, jDisplayObj, fidDdpi); (*env)->DeleteLocalRef(env, jDisplayObj); (*env)->DeleteLocalRef(env, jDisplayClass); if (ddpi) { *ddpi = (float)nativeDdpi; } if (xdpi) { *xdpi = nativeXdpi; } if (ydpi) { *ydpi = nativeYdpi; } return 0; } void * Android_JNI_GetAudioBuffer(void) { return audioBufferPinned; } void Android_JNI_WriteAudioBuffer(void) { JNIEnv *mAudioEnv = Android_JNI_GetEnv(); if (audioBuffer16Bit) { (*mAudioEnv)->ReleaseShortArrayElements(mAudioEnv, (jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT); (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer); } else { (*mAudioEnv)->ReleaseByteArrayElements(mAudioEnv, (jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT); (*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer); } /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */ } int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen) { JNIEnv *env = Android_JNI_GetEnv(); jboolean isCopy = JNI_FALSE; jint br; if (captureBuffer16Bit) { SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == (buflen / 2)); br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_TRUE); if (br > 0) { jshort *ptr = (*env)->GetShortArrayElements(env, (jshortArray)captureBuffer, &isCopy); br *= 2; SDL_memcpy(buffer, ptr, br); (*env)->ReleaseShortArrayElements(env, (jshortArray)captureBuffer, (jshort *)ptr, JNI_ABORT); } } else { SDL_assert((*env)->GetArrayLength(env, (jshortArray)captureBuffer) == buflen); br = (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_TRUE); if (br > 0) { jbyte *ptr = (*env)->GetByteArrayElements(env, (jbyteArray)captureBuffer, &isCopy); SDL_memcpy(buffer, ptr, br); (*env)->ReleaseByteArrayElements(env, (jbyteArray)captureBuffer, (jbyte *)ptr, JNI_ABORT); } } return (int) br; } void Android_JNI_FlushCapturedAudio(void) { JNIEnv *env = Android_JNI_GetEnv(); #if 0 /* !!! FIXME: this needs API 23, or it'll do blocking reads and never end. */ if (captureBuffer16Bit) { const jint len = (*env)->GetArrayLength(env, (jshortArray)captureBuffer); while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE) == len) { /* spin */ } } else { const jint len = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer); while ((*env)->CallStaticIntMethod(env, mActivityClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_FALSE) == len) { /* spin */ } } #else if (captureBuffer16Bit) { (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadShortBuffer, (jshortArray)captureBuffer, JNI_FALSE); } else { (*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureReadByteBuffer, (jbyteArray)captureBuffer, JNI_FALSE); } #endif } void Android_JNI_CloseAudioDevice(const int iscapture) { JNIEnv *env = Android_JNI_GetEnv(); if (iscapture) { (*env)->CallStaticVoidMethod(env, mAudioManagerClass, midCaptureClose); if (captureBuffer) { (*env)->DeleteGlobalRef(env, captureBuffer); captureBuffer = NULL; } } else { (*env)->CallStaticVoidMethod(env, mAudioManagerClass, midAudioClose); if (audioBuffer) { (*env)->DeleteGlobalRef(env, audioBuffer); audioBuffer = NULL; audioBufferPinned = NULL; } } } /* Test for an exception and call SDL_SetError with its detail if one occurs */ /* If the parameter silent is truthy then SDL_SetError() will not be called. */ static SDL_bool Android_JNI_ExceptionOccurred(SDL_bool silent) { JNIEnv *mEnv = Android_JNI_GetEnv(); jthrowable exception; SDL_assert(LocalReferenceHolder_IsActive()); exception = (*mEnv)->ExceptionOccurred(mEnv); if (exception != NULL) { jmethodID mid; /* Until this happens most JNI operations have undefined behaviour */ (*mEnv)->ExceptionClear(mEnv); if (!silent) { jclass exceptionClass = (*mEnv)->GetObjectClass(mEnv, exception); jclass classClass = (*mEnv)->FindClass(mEnv, "java/lang/Class"); jstring exceptionName; const char* exceptionNameUTF8; jstring exceptionMessage; mid = (*mEnv)->GetMethodID(mEnv, classClass, "getName", "()Ljava/lang/String;"); exceptionName = (jstring)(*mEnv)->CallObjectMethod(mEnv, exceptionClass, mid); exceptionNameUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionName, 0); mid = (*mEnv)->GetMethodID(mEnv, exceptionClass, "getMessage", "()Ljava/lang/String;"); exceptionMessage = (jstring)(*mEnv)->CallObjectMethod(mEnv, exception, mid); if (exceptionMessage != NULL) { const char* exceptionMessageUTF8 = (*mEnv)->GetStringUTFChars(mEnv, exceptionMessage, 0); SDL_SetError("%s: %s", exceptionNameUTF8, exceptionMessageUTF8); (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionMessage, exceptionMessageUTF8); } else { SDL_SetError("%s", exceptionNameUTF8); } (*mEnv)->ReleaseStringUTFChars(mEnv, exceptionName, exceptionNameUTF8); } return SDL_TRUE; } return SDL_FALSE; } static int Internal_Android_JNI_FileOpen(SDL_RWops* ctx) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); int result = 0; jmethodID mid; jobject context; jobject assetManager; jobject inputStream; jclass channels; jobject readableByteChannel; jstring fileNameJString; jobject fd; jclass fdCls; jfieldID descriptor; JNIEnv *mEnv = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, mEnv)) { goto failure; } fileNameJString = (jstring)ctx->hidden.androidio.fileNameRef; ctx->hidden.androidio.position = 0; /* context = SDLActivity.getContext(); */ context = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midGetContext); /* assetManager = context.getAssets(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, context), "getAssets", "()Landroid/content/res/AssetManager;"); assetManager = (*mEnv)->CallObjectMethod(mEnv, context, mid); /* First let's try opening the file to obtain an AssetFileDescriptor. * This method reads the files directly from the APKs using standard *nix calls */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "openFd", "(Ljava/lang/String;)Landroid/content/res/AssetFileDescriptor;"); inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString); if (Android_JNI_ExceptionOccurred(SDL_TRUE)) { goto fallback; } mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getStartOffset", "()J"); ctx->hidden.androidio.offset = (*mEnv)->CallLongMethod(mEnv, inputStream, mid); if (Android_JNI_ExceptionOccurred(SDL_TRUE)) { goto fallback; } mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getDeclaredLength", "()J"); ctx->hidden.androidio.size = (*mEnv)->CallLongMethod(mEnv, inputStream, mid); if (Android_JNI_ExceptionOccurred(SDL_TRUE)) { goto fallback; } mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "getFileDescriptor", "()Ljava/io/FileDescriptor;"); fd = (*mEnv)->CallObjectMethod(mEnv, inputStream, mid); fdCls = (*mEnv)->GetObjectClass(mEnv, fd); descriptor = (*mEnv)->GetFieldID(mEnv, fdCls, "descriptor", "I"); ctx->hidden.androidio.fd = (*mEnv)->GetIntField(mEnv, fd, descriptor); ctx->hidden.androidio.assetFileDescriptorRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); /* Seek to the correct offset in the file. */ lseek(ctx->hidden.androidio.fd, (off_t)ctx->hidden.androidio.offset, SEEK_SET); if (0) { fallback: /* Disabled log message because of spam on the Nexus 7 */ /* __android_log_print(ANDROID_LOG_DEBUG, "SDL", "Falling back to legacy InputStream method for opening file"); */ /* Try the old method using InputStream */ ctx->hidden.androidio.assetFileDescriptorRef = NULL; /* inputStream = assetManager.open(<filename>); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, assetManager), "open", "(Ljava/lang/String;I)Ljava/io/InputStream;"); inputStream = (*mEnv)->CallObjectMethod(mEnv, assetManager, mid, fileNameJString, 1 /* ACCESS_RANDOM */); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { /* Try fallback to APK expansion files */ inputStream = (*mEnv)->CallStaticObjectMethod(mEnv, mActivityClass, midOpenAPKExpansionInputStream, fileNameJString); /* Exception is checked first because it always needs to be cleared. * If no exception occurred then the last SDL error message is kept. */ if (Android_JNI_ExceptionOccurred(SDL_FALSE) || !inputStream) { goto failure; } } ctx->hidden.androidio.inputStreamRef = (*mEnv)->NewGlobalRef(mEnv, inputStream); /* Despite all the visible documentation on [Asset]InputStream claiming * that the .available() method is not guaranteed to return the entire file * size, comments in <sdk>/samples/<ver>/ApiDemos/src/com/example/ ... * android/apis/content/ReadAsset.java imply that Android's * AssetInputStream.available() /will/ always return the total file size */ /* size = inputStream.available(); */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "available", "()I"); ctx->hidden.androidio.size = (long)(*mEnv)->CallIntMethod(mEnv, inputStream, mid); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { goto failure; } /* readableByteChannel = Channels.newChannel(inputStream); */ channels = (*mEnv)->FindClass(mEnv, "java/nio/channels/Channels"); mid = (*mEnv)->GetStaticMethodID(mEnv, channels, "newChannel", "(Ljava/io/InputStream;)Ljava/nio/channels/ReadableByteChannel;"); readableByteChannel = (*mEnv)->CallStaticObjectMethod( mEnv, channels, mid, inputStream); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { goto failure; } ctx->hidden.androidio.readableByteChannelRef = (*mEnv)->NewGlobalRef(mEnv, readableByteChannel); /* Store .read id for reading purposes */ mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, readableByteChannel), "read", "(Ljava/nio/ByteBuffer;)I"); ctx->hidden.androidio.readMethod = mid; } if (0) { failure: result = -1; (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef); if(ctx->hidden.androidio.inputStreamRef != NULL) { (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef); } if(ctx->hidden.androidio.readableByteChannelRef != NULL) { (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef); } if(ctx->hidden.androidio.assetFileDescriptorRef != NULL) { (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef); } } LocalReferenceHolder_Cleanup(&refs); return result; } int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); JNIEnv *mEnv = Android_JNI_GetEnv(); int retval; jstring fileNameJString; if (!LocalReferenceHolder_Init(&refs, mEnv)) { LocalReferenceHolder_Cleanup(&refs); return -1; } if (!ctx) { LocalReferenceHolder_Cleanup(&refs); return -1; } fileNameJString = (*mEnv)->NewStringUTF(mEnv, fileName); ctx->hidden.androidio.fileNameRef = (*mEnv)->NewGlobalRef(mEnv, fileNameJString); ctx->hidden.androidio.inputStreamRef = NULL; ctx->hidden.androidio.readableByteChannelRef = NULL; ctx->hidden.androidio.readMethod = NULL; ctx->hidden.androidio.assetFileDescriptorRef = NULL; retval = Internal_Android_JNI_FileOpen(ctx); LocalReferenceHolder_Cleanup(&refs); return retval; } size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, size_t size, size_t maxnum) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); if (ctx->hidden.androidio.assetFileDescriptorRef) { size_t bytesMax = size * maxnum; size_t result; if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && ctx->hidden.androidio.position + bytesMax > ctx->hidden.androidio.size) { bytesMax = ctx->hidden.androidio.size - ctx->hidden.androidio.position; } result = read(ctx->hidden.androidio.fd, buffer, bytesMax ); if (result > 0) { ctx->hidden.androidio.position += result; LocalReferenceHolder_Cleanup(&refs); return result / size; } LocalReferenceHolder_Cleanup(&refs); return 0; } else { jlong bytesRemaining = (jlong) (size * maxnum); jlong bytesMax = (jlong) (ctx->hidden.androidio.size - ctx->hidden.androidio.position); int bytesRead = 0; JNIEnv *mEnv; jobject readableByteChannel; jmethodID readMethod; jobject byteBuffer; /* Don't read more bytes than those that remain in the file, otherwise we get an exception */ if (bytesRemaining > bytesMax) bytesRemaining = bytesMax; mEnv = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, mEnv)) { LocalReferenceHolder_Cleanup(&refs); return 0; } readableByteChannel = (jobject)ctx->hidden.androidio.readableByteChannelRef; readMethod = (jmethodID)ctx->hidden.androidio.readMethod; byteBuffer = (*mEnv)->NewDirectByteBuffer(mEnv, buffer, bytesRemaining); while (bytesRemaining > 0) { /* result = readableByteChannel.read(...); */ int result = (*mEnv)->CallIntMethod(mEnv, readableByteChannel, readMethod, byteBuffer); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { LocalReferenceHolder_Cleanup(&refs); return 0; } if (result < 0) { break; } bytesRemaining -= result; bytesRead += result; ctx->hidden.androidio.position += result; } LocalReferenceHolder_Cleanup(&refs); return bytesRead / size; } } size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, size_t size, size_t num) { SDL_SetError("Cannot write to Android package filesystem"); return 0; } static int Internal_Android_JNI_FileClose(SDL_RWops* ctx, SDL_bool release) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); int result = 0; JNIEnv *mEnv = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, mEnv)) { LocalReferenceHolder_Cleanup(&refs); return SDL_SetError("Failed to allocate enough JVM local references"); } if (ctx) { if (release) { (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.fileNameRef); } if (ctx->hidden.androidio.assetFileDescriptorRef) { jobject inputStream = (jobject)ctx->hidden.androidio.assetFileDescriptorRef; jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "close", "()V"); (*mEnv)->CallVoidMethod(mEnv, inputStream, mid); (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.assetFileDescriptorRef); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { result = -1; } } else { jobject inputStream = (jobject)ctx->hidden.androidio.inputStreamRef; /* inputStream.close(); */ jmethodID mid = (*mEnv)->GetMethodID(mEnv, (*mEnv)->GetObjectClass(mEnv, inputStream), "close", "()V"); (*mEnv)->CallVoidMethod(mEnv, inputStream, mid); (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.inputStreamRef); (*mEnv)->DeleteGlobalRef(mEnv, (jobject)ctx->hidden.androidio.readableByteChannelRef); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { result = -1; } } if (release) { SDL_FreeRW(ctx); } } LocalReferenceHolder_Cleanup(&refs); return result; } Sint64 Android_JNI_FileSize(SDL_RWops* ctx) { return ctx->hidden.androidio.size; } Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence) { if (ctx->hidden.androidio.assetFileDescriptorRef) { off_t ret; switch (whence) { case RW_SEEK_SET: if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_CUR: offset += ctx->hidden.androidio.position; if (ctx->hidden.androidio.size != -1 /* UNKNOWN_LENGTH */ && offset > ctx->hidden.androidio.size) offset = ctx->hidden.androidio.size; offset += ctx->hidden.androidio.offset; break; case RW_SEEK_END: offset = ctx->hidden.androidio.offset + ctx->hidden.androidio.size + offset; break; default: return SDL_SetError("Unknown value for 'whence'"); } whence = SEEK_SET; ret = lseek(ctx->hidden.androidio.fd, (off_t)offset, SEEK_SET); if (ret == -1) return -1; ctx->hidden.androidio.position = ret - ctx->hidden.androidio.offset; } else { Sint64 newPosition; Sint64 movement; switch (whence) { case RW_SEEK_SET: newPosition = offset; break; case RW_SEEK_CUR: newPosition = ctx->hidden.androidio.position + offset; break; case RW_SEEK_END: newPosition = ctx->hidden.androidio.size + offset; break; default: return SDL_SetError("Unknown value for 'whence'"); } /* Validate the new position */ if (newPosition < 0) { return SDL_Error(SDL_EFSEEK); } if (newPosition > ctx->hidden.androidio.size) { newPosition = ctx->hidden.androidio.size; } movement = newPosition - ctx->hidden.androidio.position; if (movement > 0) { unsigned char buffer[4096]; /* The easy case where we're seeking forwards */ while (movement > 0) { Sint64 amount = sizeof (buffer); size_t result; if (amount > movement) { amount = movement; } result = Android_JNI_FileRead(ctx, buffer, 1, amount); if (result <= 0) { /* Failed to read/skip the required amount, so fail */ return -1; } movement -= result; } } else if (movement < 0) { /* We can't seek backwards so we have to reopen the file and seek */ /* forwards which obviously isn't very efficient */ Internal_Android_JNI_FileClose(ctx, SDL_FALSE); Internal_Android_JNI_FileOpen(ctx); Android_JNI_FileSeek(ctx, newPosition, RW_SEEK_SET); } } return ctx->hidden.androidio.position; } int Android_JNI_FileClose(SDL_RWops* ctx) { return Internal_Android_JNI_FileClose(ctx, SDL_TRUE); } int Android_JNI_SetClipboardText(const char* text) { JNIEnv* env = Android_JNI_GetEnv(); jstring string = (*env)->NewStringUTF(env, text); (*env)->CallStaticVoidMethod(env, mActivityClass, midClipboardSetText, string); (*env)->DeleteLocalRef(env, string); return 0; } char* Android_JNI_GetClipboardText(void) { JNIEnv* env = Android_JNI_GetEnv(); char* text = NULL; jstring string; string = (*env)->CallStaticObjectMethod(env, mActivityClass, midClipboardGetText); if (string) { const char* utf = (*env)->GetStringUTFChars(env, string, 0); if (utf) { text = SDL_strdup(utf); (*env)->ReleaseStringUTFChars(env, string, utf); } (*env)->DeleteLocalRef(env, string); } return (text == NULL) ? SDL_strdup("") : text; } SDL_bool Android_JNI_HasClipboardText(void) { JNIEnv* env = Android_JNI_GetEnv(); jboolean retval = (*env)->CallStaticBooleanMethod(env, mActivityClass, midClipboardHasText); return (retval == JNI_TRUE) ? SDL_TRUE : SDL_FALSE; } /* returns 0 on success or -1 on error (others undefined then) * returns truthy or falsy value in plugged, charged and battery * returns the value in seconds and percent or -1 if not available */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); JNIEnv* env = Android_JNI_GetEnv(); jmethodID mid; jobject context; jstring action; jclass cls; jobject filter; jobject intent; jstring iname; jmethodID imid; jstring bname; jmethodID bmid; if (!LocalReferenceHolder_Init(&refs, env)) { LocalReferenceHolder_Cleanup(&refs); return -1; } /* context = SDLActivity.getContext(); */ context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); action = (*env)->NewStringUTF(env, "android.intent.action.BATTERY_CHANGED"); cls = (*env)->FindClass(env, "android/content/IntentFilter"); mid = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;)V"); filter = (*env)->NewObject(env, cls, mid, action); (*env)->DeleteLocalRef(env, action); mid = (*env)->GetMethodID(env, mActivityClass, "registerReceiver", "(Landroid/content/BroadcastReceiver;Landroid/content/IntentFilter;)Landroid/content/Intent;"); intent = (*env)->CallObjectMethod(env, context, mid, NULL, filter); (*env)->DeleteLocalRef(env, filter); cls = (*env)->GetObjectClass(env, intent); imid = (*env)->GetMethodID(env, cls, "getIntExtra", "(Ljava/lang/String;I)I"); /* Watch out for C89 scoping rules because of the macro */ #define GET_INT_EXTRA(var, key) \ int var; \ iname = (*env)->NewStringUTF(env, key); \ var = (*env)->CallIntMethod(env, intent, imid, iname, -1); \ (*env)->DeleteLocalRef(env, iname); bmid = (*env)->GetMethodID(env, cls, "getBooleanExtra", "(Ljava/lang/String;Z)Z"); /* Watch out for C89 scoping rules because of the macro */ #define GET_BOOL_EXTRA(var, key) \ int var; \ bname = (*env)->NewStringUTF(env, key); \ var = (*env)->CallBooleanMethod(env, intent, bmid, bname, JNI_FALSE); \ (*env)->DeleteLocalRef(env, bname); if (plugged) { /* Watch out for C89 scoping rules because of the macro */ GET_INT_EXTRA(plug, "plugged") /* == BatteryManager.EXTRA_PLUGGED (API 5) */ if (plug == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } /* 1 == BatteryManager.BATTERY_PLUGGED_AC */ /* 2 == BatteryManager.BATTERY_PLUGGED_USB */ *plugged = (0 < plug) ? 1 : 0; } if (charged) { /* Watch out for C89 scoping rules because of the macro */ GET_INT_EXTRA(status, "status") /* == BatteryManager.EXTRA_STATUS (API 5) */ if (status == -1) { LocalReferenceHolder_Cleanup(&refs); return -1; } /* 5 == BatteryManager.BATTERY_STATUS_FULL */ *charged = (status == 5) ? 1 : 0; } if (battery) { GET_BOOL_EXTRA(present, "present") /* == BatteryManager.EXTRA_PRESENT (API 5) */ *battery = present ? 1 : 0; } if (seconds) { *seconds = -1; /* not possible */ } if (percent) { int level; int scale; /* Watch out for C89 scoping rules because of the macro */ { GET_INT_EXTRA(level_temp, "level") /* == BatteryManager.EXTRA_LEVEL (API 5) */ level = level_temp; } /* Watch out for C89 scoping rules because of the macro */ { GET_INT_EXTRA(scale_temp, "scale") /* == BatteryManager.EXTRA_SCALE (API 5) */ scale = scale_temp; } if ((level == -1) || (scale == -1)) { LocalReferenceHolder_Cleanup(&refs); return -1; } *percent = level * 100 / scale; } (*env)->DeleteLocalRef(env, intent); LocalReferenceHolder_Cleanup(&refs); return 0; } /* returns number of found touch devices as return value and ids in parameter ids */ int Android_JNI_GetTouchDeviceIds(int **ids) { JNIEnv *env = Android_JNI_GetEnv(); jint sources = 4098; /* == InputDevice.SOURCE_TOUCHSCREEN */ jintArray array = (jintArray) (*env)->CallStaticObjectMethod(env, mActivityClass, midInputGetInputDeviceIds, sources); int number = 0; *ids = NULL; if (array) { number = (int) (*env)->GetArrayLength(env, array); if (0 < number) { jint* elements = (*env)->GetIntArrayElements(env, array, NULL); if (elements) { int i; *ids = SDL_malloc(number * sizeof (**ids)); for (i = 0; i < number; ++i) { /* not assuming sizeof (jint) == sizeof (int) */ (*ids)[i] = elements[i]; } (*env)->ReleaseIntArrayElements(env, array, elements, JNI_ABORT); } } (*env)->DeleteLocalRef(env, array); } return number; } /* sets the mSeparateMouseAndTouch field */ void Android_JNI_SetSeparateMouseAndTouch(SDL_bool new_value) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->SetStaticBooleanField(env, mActivityClass, fidSeparateMouseAndTouch, new_value ? JNI_TRUE : JNI_FALSE); } void Android_JNI_PollInputDevices(void) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midPollInputDevices); } void Android_JNI_PollHapticDevices(void) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midPollHapticDevices); } void Android_JNI_HapticRun(int device_id, int length) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticRun, device_id, length); } void Android_JNI_HapticStop(int device_id) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticVoidMethod(env, mControllerManagerClass, midHapticStop, device_id); } /* See SDLActivity.java for constants. */ #define COMMAND_SET_KEEP_SCREEN_ON 5 /* sends message to be handled on the UI event dispatch thread */ int Android_JNI_SendMessage(int command, int param) { JNIEnv *env = Android_JNI_GetEnv(); jboolean success; success = (*env)->CallStaticBooleanMethod(env, mActivityClass, midSendMessage, command, param); return success ? 0 : -1; } void Android_JNI_SuspendScreenSaver(SDL_bool suspend) { Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1); } void Android_JNI_ShowTextInput(SDL_Rect *inputRect) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticBooleanMethod(env, mActivityClass, midShowTextInput, inputRect->x, inputRect->y, inputRect->w, inputRect->h ); } void Android_JNI_HideTextInput(void) { /* has to match Activity constant */ const int COMMAND_TEXTEDIT_HIDE = 3; Android_JNI_SendMessage(COMMAND_TEXTEDIT_HIDE, 0); } SDL_bool Android_JNI_IsScreenKeyboardShown() { JNIEnv *mEnv = Android_JNI_GetEnv(); jboolean is_shown = 0; is_shown = (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midIsScreenKeyboardShown); return is_shown; } int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { JNIEnv *env; jclass clazz; jmethodID mid; jobject context; jstring title; jstring message; jintArray button_flags; jintArray button_ids; jobjectArray button_texts; jintArray colors; jobject text; jint temp; int i; env = Android_JNI_GetEnv(); /* convert parameters */ clazz = (*env)->FindClass(env, "java/lang/String"); title = (*env)->NewStringUTF(env, messageboxdata->title); message = (*env)->NewStringUTF(env, messageboxdata->message); button_flags = (*env)->NewIntArray(env, messageboxdata->numbuttons); button_ids = (*env)->NewIntArray(env, messageboxdata->numbuttons); button_texts = (*env)->NewObjectArray(env, messageboxdata->numbuttons, clazz, NULL); for (i = 0; i < messageboxdata->numbuttons; ++i) { temp = messageboxdata->buttons[i].flags; (*env)->SetIntArrayRegion(env, button_flags, i, 1, &temp); temp = messageboxdata->buttons[i].buttonid; (*env)->SetIntArrayRegion(env, button_ids, i, 1, &temp); text = (*env)->NewStringUTF(env, messageboxdata->buttons[i].text); (*env)->SetObjectArrayElement(env, button_texts, i, text); (*env)->DeleteLocalRef(env, text); } if (messageboxdata->colorScheme) { colors = (*env)->NewIntArray(env, SDL_MESSAGEBOX_COLOR_MAX); for (i = 0; i < SDL_MESSAGEBOX_COLOR_MAX; ++i) { temp = (0xFF << 24) | (messageboxdata->colorScheme->colors[i].r << 16) | (messageboxdata->colorScheme->colors[i].g << 8) | (messageboxdata->colorScheme->colors[i].b << 0); (*env)->SetIntArrayRegion(env, colors, i, 1, &temp); } } else { colors = NULL; } (*env)->DeleteLocalRef(env, clazz); /* context = SDLActivity.getContext(); */ context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); clazz = (*env)->GetObjectClass(env, context); mid = (*env)->GetMethodID(env, clazz, "messageboxShowMessageBox", "(ILjava/lang/String;Ljava/lang/String;[I[I[Ljava/lang/String;[I)I"); *buttonid = (*env)->CallIntMethod(env, context, mid, messageboxdata->flags, title, message, button_flags, button_ids, button_texts, colors); (*env)->DeleteLocalRef(env, context); (*env)->DeleteLocalRef(env, clazz); /* delete parameters */ (*env)->DeleteLocalRef(env, title); (*env)->DeleteLocalRef(env, message); (*env)->DeleteLocalRef(env, button_flags); (*env)->DeleteLocalRef(env, button_ids); (*env)->DeleteLocalRef(env, button_texts); (*env)->DeleteLocalRef(env, colors); return 0; } /* ////////////////////////////////////////////////////////////////////////////// // // Functions exposed to SDL applications in SDL_system.h ////////////////////////////////////////////////////////////////////////////// */ void *SDL_AndroidGetJNIEnv(void) { return Android_JNI_GetEnv(); } void *SDL_AndroidGetActivity(void) { /* See SDL_system.h for caveats on using this function. */ JNIEnv *env = Android_JNI_GetEnv(); if (!env) { return NULL; } /* return SDLActivity.getContext(); */ return (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); } SDL_bool SDL_IsAndroidTablet(void) { JNIEnv *env = Android_JNI_GetEnv(); return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsTablet); } SDL_bool SDL_IsAndroidTV(void) { JNIEnv *env = Android_JNI_GetEnv(); return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsAndroidTV); } SDL_bool SDL_IsChromebook(void) { JNIEnv *env = Android_JNI_GetEnv(); return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsChromebook); } SDL_bool SDL_IsDeXMode(void) { JNIEnv *env = Android_JNI_GetEnv(); return (*env)->CallStaticBooleanMethod(env, mActivityClass, midIsDeXMode); } void SDL_AndroidBackButton(void) { JNIEnv *env = Android_JNI_GetEnv(); return (*env)->CallStaticVoidMethod(env, mActivityClass, midManualBackButton); } const char * SDL_AndroidGetInternalStoragePath(void) { static char *s_AndroidInternalFilesPath = NULL; if (!s_AndroidInternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; jobject fileObject; jstring pathString; const char *path; JNIEnv *env = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, env)) { LocalReferenceHolder_Cleanup(&refs); return NULL; } /* context = SDLActivity.getContext(); */ context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); if (!context) { SDL_SetError("Couldn't get Android context!"); LocalReferenceHolder_Cleanup(&refs); return NULL; } /* fileObj = context.getFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getFilesDir", "()Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid); if (!fileObject) { SDL_SetError("Couldn't get internal directory"); LocalReferenceHolder_Cleanup(&refs); return NULL; } /* path = fileObject.getCanonicalPath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getCanonicalPath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); if (Android_JNI_ExceptionOccurred(SDL_FALSE)) { LocalReferenceHolder_Cleanup(&refs); return NULL; } path = (*env)->GetStringUTFChars(env, pathString, NULL); s_AndroidInternalFilesPath = SDL_strdup(path); (*env)->ReleaseStringUTFChars(env, pathString, path); LocalReferenceHolder_Cleanup(&refs); } return s_AndroidInternalFilesPath; } int SDL_AndroidGetExternalStorageState(void) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jclass cls; jstring stateString; const char *state; int stateFlags; JNIEnv *env = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, env)) { LocalReferenceHolder_Cleanup(&refs); return 0; } cls = (*env)->FindClass(env, "android/os/Environment"); mid = (*env)->GetStaticMethodID(env, cls, "getExternalStorageState", "()Ljava/lang/String;"); stateString = (jstring)(*env)->CallStaticObjectMethod(env, cls, mid); state = (*env)->GetStringUTFChars(env, stateString, NULL); /* Print an info message so people debugging know the storage state */ __android_log_print(ANDROID_LOG_INFO, "SDL", "external storage state: %s", state); if (SDL_strcmp(state, "mounted") == 0) { stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ | SDL_ANDROID_EXTERNAL_STORAGE_WRITE; } else if (SDL_strcmp(state, "mounted_ro") == 0) { stateFlags = SDL_ANDROID_EXTERNAL_STORAGE_READ; } else { stateFlags = 0; } (*env)->ReleaseStringUTFChars(env, stateString, state); LocalReferenceHolder_Cleanup(&refs); return stateFlags; } const char * SDL_AndroidGetExternalStoragePath(void) { static char *s_AndroidExternalFilesPath = NULL; if (!s_AndroidExternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; jobject fileObject; jstring pathString; const char *path; JNIEnv *env = Android_JNI_GetEnv(); if (!LocalReferenceHolder_Init(&refs, env)) { LocalReferenceHolder_Cleanup(&refs); return NULL; } /* context = SDLActivity.getContext(); */ context = (*env)->CallStaticObjectMethod(env, mActivityClass, midGetContext); /* fileObj = context.getExternalFilesDir(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, context), "getExternalFilesDir", "(Ljava/lang/String;)Ljava/io/File;"); fileObject = (*env)->CallObjectMethod(env, context, mid, NULL); if (!fileObject) { SDL_SetError("Couldn't get external directory"); LocalReferenceHolder_Cleanup(&refs); return NULL; } /* path = fileObject.getAbsolutePath(); */ mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env, fileObject), "getAbsolutePath", "()Ljava/lang/String;"); pathString = (jstring)(*env)->CallObjectMethod(env, fileObject, mid); path = (*env)->GetStringUTFChars(env, pathString, NULL); s_AndroidExternalFilesPath = SDL_strdup(path); (*env)->ReleaseStringUTFChars(env, pathString, path); LocalReferenceHolder_Cleanup(&refs); } return s_AndroidExternalFilesPath; } void Android_JNI_GetManifestEnvironmentVariables(void) { if (!mActivityClass || !midGetManifestEnvironmentVariables) { __android_log_print(ANDROID_LOG_WARN, "SDL", "Request to get environment variables before JNI is ready"); return; } if (!bHasEnvironmentVariables) { JNIEnv *env = Android_JNI_GetEnv(); SDL_bool ret = (*env)->CallStaticBooleanMethod(env, mActivityClass, midGetManifestEnvironmentVariables); if (ret) { bHasEnvironmentVariables = SDL_TRUE; } } } int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y) { JNIEnv *mEnv = Android_JNI_GetEnv(); int custom_cursor = 0; jintArray pixels; pixels = (*mEnv)->NewIntArray(mEnv, surface->w * surface->h); if (pixels) { (*mEnv)->SetIntArrayRegion(mEnv, pixels, 0, surface->w * surface->h, (int *)surface->pixels); custom_cursor = (*mEnv)->CallStaticIntMethod(mEnv, mActivityClass, midCreateCustomCursor, pixels, surface->w, surface->h, hot_x, hot_y); (*mEnv)->DeleteLocalRef(mEnv, pixels); } else { SDL_OutOfMemory(); } return custom_cursor; } SDL_bool Android_JNI_SetCustomCursor(int cursorID) { JNIEnv *mEnv = Android_JNI_GetEnv(); return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetCustomCursor, cursorID); } SDL_bool Android_JNI_SetSystemCursor(int cursorID) { JNIEnv *mEnv = Android_JNI_GetEnv(); return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetSystemCursor, cursorID); } SDL_bool Android_JNI_SupportsRelativeMouse() { JNIEnv *mEnv = Android_JNI_GetEnv(); return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSupportsRelativeMouse); } SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled) { JNIEnv *mEnv = Android_JNI_GetEnv(); return (*mEnv)->CallStaticBooleanMethod(mEnv, mActivityClass, midSetRelativeMouseEnabled, (enabled == 1)); } #endif /* __ANDROID__ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\android\SDL_android.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ extern "C" { /* *INDENT-ON* */ #endif #include <EGL/eglplatform.h> #include <android/native_window_jni.h> #include "SDL_rect.h" /* Interface from the SDL library into the Android Java activity */ extern void Android_JNI_SetActivityTitle(const char *title); extern void Android_JNI_SetWindowStyle(SDL_bool fullscreen); extern void Android_JNI_SetOrientation(int w, int h, int resizable, const char *hint); extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); extern void Android_JNI_HideTextInput(void); extern SDL_bool Android_JNI_IsScreenKeyboardShown(void); extern ANativeWindow* Android_JNI_GetNativeWindow(void); extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi); /* Audio support */ extern int Android_JNI_OpenAudioDevice(int iscapture, int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames); extern void* Android_JNI_GetAudioBuffer(void); extern void Android_JNI_WriteAudioBuffer(void); extern int Android_JNI_CaptureAudioBuffer(void *buffer, int buflen); extern void Android_JNI_FlushCapturedAudio(void); extern void Android_JNI_CloseAudioDevice(const int iscapture); #include "SDL_rwops.h" int Android_JNI_FileOpen(SDL_RWops* ctx, const char* fileName, const char* mode); Sint64 Android_JNI_FileSize(SDL_RWops* ctx); Sint64 Android_JNI_FileSeek(SDL_RWops* ctx, Sint64 offset, int whence); size_t Android_JNI_FileRead(SDL_RWops* ctx, void* buffer, size_t size, size_t maxnum); size_t Android_JNI_FileWrite(SDL_RWops* ctx, const void* buffer, size_t size, size_t num); int Android_JNI_FileClose(SDL_RWops* ctx); /* Environment support */ void Android_JNI_GetManifestEnvironmentVariables(void); /* Clipboard support */ int Android_JNI_SetClipboardText(const char* text); char* Android_JNI_GetClipboardText(void); SDL_bool Android_JNI_HasClipboardText(void); /* Power support */ int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent); /* Joystick support */ void Android_JNI_PollInputDevices(void); /* Haptic support */ void Android_JNI_PollHapticDevices(void); void Android_JNI_HapticRun(int device_id, int length); void Android_JNI_HapticStop(int device_id); /* Video */ void Android_JNI_SuspendScreenSaver(SDL_bool suspend); /* Touch support */ int Android_JNI_GetTouchDeviceIds(int **ids); void Android_JNI_SetSeparateMouseAndTouch(SDL_bool new_value); /* Threads */ #include <jni.h> JNIEnv *Android_JNI_GetEnv(void); int Android_JNI_SetupThread(void); /* Generic messages */ int Android_JNI_SendMessage(int command, int param); /* Init */ JNIEXPORT void JNICALL SDL_Android_Init(JNIEnv* mEnv, jclass cls); /* MessageBox */ #include "SDL_messagebox.h" int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); /* Cursor support */ int Android_JNI_CreateCustomCursor(SDL_Surface *surface, int hot_x, int hot_y); SDL_bool Android_JNI_SetCustomCursor(int cursorID); SDL_bool Android_JNI_SetSystemCursor(int cursorID); /* Relative mouse support */ SDL_bool Android_JNI_SupportsRelativeMouse(); SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_dbus.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_dbus.h" #if SDL_USE_LIBDBUS /* we never link directly to libdbus. */ #include "SDL_loadso.h" static const char *dbus_library = "libdbus-1.so.3"; static void *dbus_handle = NULL; static unsigned int screensaver_cookie = 0; static SDL_DBusContext dbus; static int LoadDBUSSyms(void) { #define SDL_DBUS_SYM2(x, y) \ if (!(dbus.x = SDL_LoadFunction(dbus_handle, #y))) return -1 #define SDL_DBUS_SYM(x) \ SDL_DBUS_SYM2(x, dbus_##x) SDL_DBUS_SYM(bus_get_private); SDL_DBUS_SYM(bus_register); SDL_DBUS_SYM(bus_add_match); SDL_DBUS_SYM(connection_open_private); SDL_DBUS_SYM(connection_set_exit_on_disconnect); SDL_DBUS_SYM(connection_get_is_connected); SDL_DBUS_SYM(connection_add_filter); SDL_DBUS_SYM(connection_try_register_object_path); SDL_DBUS_SYM(connection_send); SDL_DBUS_SYM(connection_send_with_reply_and_block); SDL_DBUS_SYM(connection_close); SDL_DBUS_SYM(connection_unref); SDL_DBUS_SYM(connection_flush); SDL_DBUS_SYM(connection_read_write); SDL_DBUS_SYM(connection_dispatch); SDL_DBUS_SYM(message_is_signal); SDL_DBUS_SYM(message_new_method_call); SDL_DBUS_SYM(message_append_args); SDL_DBUS_SYM(message_append_args_valist); SDL_DBUS_SYM(message_get_args); SDL_DBUS_SYM(message_get_args_valist); SDL_DBUS_SYM(message_iter_init); SDL_DBUS_SYM(message_iter_next); SDL_DBUS_SYM(message_iter_get_basic); SDL_DBUS_SYM(message_iter_get_arg_type); SDL_DBUS_SYM(message_iter_recurse); SDL_DBUS_SYM(message_unref); SDL_DBUS_SYM(error_init); SDL_DBUS_SYM(error_is_set); SDL_DBUS_SYM(error_free); SDL_DBUS_SYM(get_local_machine_id); SDL_DBUS_SYM(free); SDL_DBUS_SYM(free_string_array); SDL_DBUS_SYM(shutdown); #undef SDL_DBUS_SYM #undef SDL_DBUS_SYM2 return 0; } static void UnloadDBUSLibrary(void) { if (dbus_handle != NULL) { SDL_UnloadObject(dbus_handle); dbus_handle = NULL; } } static int LoadDBUSLibrary(void) { int retval = 0; if (dbus_handle == NULL) { dbus_handle = SDL_LoadObject(dbus_library); if (dbus_handle == NULL) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { retval = LoadDBUSSyms(); if (retval < 0) { UnloadDBUSLibrary(); } } } return retval; } void SDL_DBus_Init(void) { if (!dbus.session_conn && LoadDBUSLibrary() != -1) { DBusError err; dbus.error_init(&err); dbus.session_conn = dbus.bus_get_private(DBUS_BUS_SESSION, &err); if (!dbus.error_is_set(&err)) { dbus.system_conn = dbus.bus_get_private(DBUS_BUS_SYSTEM, &err); } if (dbus.error_is_set(&err)) { dbus.error_free(&err); SDL_DBus_Quit(); return; /* oh well */ } dbus.connection_set_exit_on_disconnect(dbus.system_conn, 0); dbus.connection_set_exit_on_disconnect(dbus.session_conn, 0); } } void SDL_DBus_Quit(void) { if (dbus.system_conn) { dbus.connection_close(dbus.system_conn); dbus.connection_unref(dbus.system_conn); } if (dbus.session_conn) { dbus.connection_close(dbus.session_conn); dbus.connection_unref(dbus.session_conn); } /* Don't do this - bug 3950 dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it. */ #if 0 if (dbus.shutdown) { dbus.shutdown(); } #endif SDL_zero(dbus); UnloadDBUSLibrary(); } SDL_DBusContext * SDL_DBus_GetContext(void) { if(!dbus_handle || !dbus.session_conn){ SDL_DBus_Init(); } if(dbus_handle && dbus.session_conn){ return &dbus; } else { return NULL; } } static SDL_bool SDL_DBus_CallMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) { SDL_bool retval = SDL_FALSE; if (conn) { DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method); if (msg) { int firstarg; va_list ap_reply; va_copy(ap_reply, ap); /* copy the arg list so we don't compete with D-Bus for it */ firstarg = va_arg(ap, int); if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) { DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL); if (reply) { /* skip any input args, get to output args. */ while ((firstarg = va_arg(ap_reply, int)) != DBUS_TYPE_INVALID) { /* we assume D-Bus already validated all this. */ { void *dumpptr = va_arg(ap_reply, void*); (void) dumpptr; } if (firstarg == DBUS_TYPE_ARRAY) { { const int dumpint = va_arg(ap_reply, int); (void) dumpint; } } } firstarg = va_arg(ap_reply, int); if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_get_args_valist(reply, NULL, firstarg, ap_reply)) { retval = SDL_TRUE; } dbus.message_unref(reply); } } va_end(ap_reply); dbus.message_unref(msg); } } return retval; } SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...) { SDL_bool retval; va_list ap; va_start(ap, method); retval = SDL_DBus_CallMethodInternal(conn, node, path, interface, method, ap); va_end(ap); return retval; } SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...) { SDL_bool retval; va_list ap; va_start(ap, method); retval = SDL_DBus_CallMethodInternal(dbus.session_conn, node, path, interface, method, ap); va_end(ap); return retval; } static SDL_bool SDL_DBus_CallVoidMethodInternal(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, va_list ap) { SDL_bool retval = SDL_FALSE; if (conn) { DBusMessage *msg = dbus.message_new_method_call(node, path, interface, method); if (msg) { int firstarg = va_arg(ap, int); if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) { if (dbus.connection_send(conn, msg, NULL)) { dbus.connection_flush(conn); retval = SDL_TRUE; } } dbus.message_unref(msg); } } return retval; } SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...) { SDL_bool retval; va_list ap; va_start(ap, method); retval = SDL_DBus_CallVoidMethodInternal(conn, node, path, interface, method, ap); va_end(ap); return retval; } SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...) { SDL_bool retval; va_list ap; va_start(ap, method); retval = SDL_DBus_CallVoidMethodInternal(dbus.session_conn, node, path, interface, method, ap); va_end(ap); return retval; } SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result) { SDL_bool retval = SDL_FALSE; if (conn) { DBusMessage *msg = dbus.message_new_method_call(node, path, "org.freedesktop.DBus.Properties", "Get"); if (msg) { if (dbus.message_append_args(msg, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID)) { DBusMessage *reply = dbus.connection_send_with_reply_and_block(conn, msg, 300, NULL); if (reply) { DBusMessageIter iter, sub; dbus.message_iter_init(reply, &iter); if (dbus.message_iter_get_arg_type(&iter) == DBUS_TYPE_VARIANT) { dbus.message_iter_recurse(&iter, &sub); if (dbus.message_iter_get_arg_type(&sub) == expectedtype) { dbus.message_iter_get_basic(&sub, result); retval = SDL_TRUE; } } dbus.message_unref(reply); } } dbus.message_unref(msg); } } return retval; } SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result) { return SDL_DBus_QueryPropertyOnConnection(dbus.session_conn, node, path, interface, property, expectedtype, result); } void SDL_DBus_ScreensaverTickle(void) { SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); } SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) { if ( (inhibit && (screensaver_cookie != 0)) || (!inhibit && (screensaver_cookie == 0)) ) { return SDL_TRUE; } else { const char *node = "org.freedesktop.ScreenSaver"; const char *path = "/org/freedesktop/ScreenSaver"; const char *interface = "org.freedesktop.ScreenSaver"; if (inhibit) { const char *app = "My SDL application"; const char *reason = "Playing a game"; if (!SDL_DBus_CallMethod(node, path, interface, "Inhibit", DBUS_TYPE_STRING, &app, DBUS_TYPE_STRING, &reason, DBUS_TYPE_INVALID, DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) { return SDL_FALSE; } return (screensaver_cookie != 0) ? SDL_TRUE : SDL_FALSE; } else { if (!SDL_DBus_CallVoidMethod(node, path, interface, "UnInhibit", DBUS_TYPE_UINT32, &screensaver_cookie, DBUS_TYPE_INVALID)) { return SDL_FALSE; } screensaver_cookie = 0; } } return SDL_TRUE; } #endif /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_dbus.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_dbus_h_ #define SDL_dbus_h_ #ifdef HAVE_DBUS_DBUS_H #define SDL_USE_LIBDBUS 1 #include "SDL_stdinc.h" #include <dbus/dbus.h> typedef struct SDL_DBusContext { DBusConnection *session_conn; DBusConnection *system_conn; DBusConnection *(*bus_get_private)(DBusBusType, DBusError *); dbus_bool_t (*bus_register)(DBusConnection *, DBusError *); void (*bus_add_match)(DBusConnection *, const char *, DBusError *); DBusConnection * (*connection_open_private)(const char *, DBusError *); void (*connection_set_exit_on_disconnect)(DBusConnection *, dbus_bool_t); dbus_bool_t (*connection_get_is_connected)(DBusConnection *); dbus_bool_t (*connection_add_filter)(DBusConnection *, DBusHandleMessageFunction, void *, DBusFreeFunction); dbus_bool_t (*connection_try_register_object_path)(DBusConnection *, const char *, const DBusObjectPathVTable *, void *, DBusError *); dbus_bool_t (*connection_send)(DBusConnection *, DBusMessage *, dbus_uint32_t *); DBusMessage *(*connection_send_with_reply_and_block)(DBusConnection *, DBusMessage *, int, DBusError *); void (*connection_close)(DBusConnection *); void (*connection_unref)(DBusConnection *); void (*connection_flush)(DBusConnection *); dbus_bool_t (*connection_read_write)(DBusConnection *, int); DBusDispatchStatus (*connection_dispatch)(DBusConnection *); dbus_bool_t (*message_is_signal)(DBusMessage *, const char *, const char *); DBusMessage *(*message_new_method_call)(const char *, const char *, const char *, const char *); dbus_bool_t (*message_append_args)(DBusMessage *, int, ...); dbus_bool_t (*message_append_args_valist)(DBusMessage *, int, va_list); dbus_bool_t (*message_get_args)(DBusMessage *, DBusError *, int, ...); dbus_bool_t (*message_get_args_valist)(DBusMessage *, DBusError *, int, va_list); dbus_bool_t (*message_iter_init)(DBusMessage *, DBusMessageIter *); dbus_bool_t (*message_iter_next)(DBusMessageIter *); void (*message_iter_get_basic)(DBusMessageIter *, void *); int (*message_iter_get_arg_type)(DBusMessageIter *); void (*message_iter_recurse)(DBusMessageIter *, DBusMessageIter *); void (*message_unref)(DBusMessage *); void (*error_init)(DBusError *); dbus_bool_t (*error_is_set)(const DBusError *); void (*error_free)(DBusError *); char *(*get_local_machine_id)(void); void (*free)(void *); void (*free_string_array)(char **); void (*shutdown)(void); } SDL_DBusContext; extern void SDL_DBus_Init(void); extern void SDL_DBus_Quit(void); extern SDL_DBusContext * SDL_DBus_GetContext(void); /* These use the built-in Session connection. */ extern SDL_bool SDL_DBus_CallMethod(const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_CallVoidMethod(const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result); /* These use whatever connection you like. */ extern SDL_bool SDL_DBus_CallMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_CallVoidMethodOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *method, ...); extern SDL_bool SDL_DBus_QueryPropertyOnConnection(DBusConnection *conn, const char *node, const char *path, const char *interface, const char *property, const int expectedtype, void *result); extern void SDL_DBus_ScreensaverTickle(void); extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit); #endif /* HAVE_DBUS_DBUS_H */ #endif /* SDL_dbus_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_INPUT_LINUXEV /* This is based on the linux joystick driver */ /* References: https://www.kernel.org/doc/Documentation/input/input.txt * https://www.kernel.org/doc/Documentation/input/event-codes.txt * /usr/include/linux/input.h * The evtest application is also useful to debug the protocol */ #include "SDL_evdev.h" #include "SDL_evdev_kbd.h" #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/input.h> #include "SDL.h" #include "SDL_assert.h" #include "SDL_endian.h" #include "SDL_scancode.h" #include "../../events/SDL_events_c.h" #include "../../events/scancodes_linux.h" /* adds linux_scancode_table */ #include "../../core/linux/SDL_udev.h" /* These are not defined in older Linux kernel headers */ #ifndef SYN_DROPPED #define SYN_DROPPED 3 #endif #ifndef ABS_MT_SLOT #define ABS_MT_SLOT 0x2f #define ABS_MT_POSITION_X 0x35 #define ABS_MT_POSITION_Y 0x36 #define ABS_MT_TRACKING_ID 0x39 #endif typedef struct SDL_evdevlist_item { char *path; int fd; /* TODO: use this for every device, not just touchscreen */ int out_of_sync; /* TODO: expand on this to have data for every possible class (mouse, keyboard, touchpad, etc.). Also there's probably some things in here we can pull out to the SDL_evdevlist_item i.e. name */ int is_touchscreen; struct { char* name; int min_x, max_x, range_x; int min_y, max_y, range_y; int max_slots; int current_slot; struct { enum { EVDEV_TOUCH_SLOTDELTA_NONE = 0, EVDEV_TOUCH_SLOTDELTA_DOWN, EVDEV_TOUCH_SLOTDELTA_UP, EVDEV_TOUCH_SLOTDELTA_MOVE } delta; int tracking_id; int x, y; } * slots; } * touchscreen_data; struct SDL_evdevlist_item *next; } SDL_evdevlist_item; typedef struct SDL_EVDEV_PrivateData { int ref_count; int num_devices; SDL_evdevlist_item *first; SDL_evdevlist_item *last; SDL_EVDEV_keyboard_state *kbd; } SDL_EVDEV_PrivateData; #undef _THIS #define _THIS SDL_EVDEV_PrivateData *_this static _THIS = NULL; static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode); static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); static int SDL_EVDEV_device_removed(const char *dev_path); #if SDL_USE_LIBUDEV static int SDL_EVDEV_device_added(const char *dev_path, int udev_class); static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *dev_path); #endif /* SDL_USE_LIBUDEV */ static Uint8 EVDEV_MouseButtons[] = { SDL_BUTTON_LEFT, /* BTN_LEFT 0x110 */ SDL_BUTTON_RIGHT, /* BTN_RIGHT 0x111 */ SDL_BUTTON_MIDDLE, /* BTN_MIDDLE 0x112 */ SDL_BUTTON_X1, /* BTN_SIDE 0x113 */ SDL_BUTTON_X2, /* BTN_EXTRA 0x114 */ SDL_BUTTON_X2 + 1, /* BTN_FORWARD 0x115 */ SDL_BUTTON_X2 + 2, /* BTN_BACK 0x116 */ SDL_BUTTON_X2 + 3 /* BTN_TASK 0x117 */ }; int SDL_EVDEV_Init(void) { if (_this == NULL) { _this = (SDL_EVDEV_PrivateData*)SDL_calloc(1, sizeof(*_this)); if (_this == NULL) { return SDL_OutOfMemory(); } #if SDL_USE_LIBUDEV if (SDL_UDEV_Init() < 0) { SDL_free(_this); _this = NULL; return -1; } /* Set up the udev callback */ if (SDL_UDEV_AddCallback(SDL_EVDEV_udev_callback) < 0) { SDL_UDEV_Quit(); SDL_free(_this); _this = NULL; return -1; } /* Force a scan to build the initial device list */ SDL_UDEV_Scan(); #else /* TODO: Scan the devices manually, like a caveman */ #endif /* SDL_USE_LIBUDEV */ _this->kbd = SDL_EVDEV_kbd_init(); } _this->ref_count += 1; return 0; } void SDL_EVDEV_Quit(void) { if (_this == NULL) { return; } _this->ref_count -= 1; if (_this->ref_count < 1) { #if SDL_USE_LIBUDEV SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback); SDL_UDEV_Quit(); #endif /* SDL_USE_LIBUDEV */ SDL_EVDEV_kbd_quit(_this->kbd); /* Remove existing devices */ while(_this->first != NULL) { SDL_EVDEV_device_removed(_this->first->path); } SDL_assert(_this->first == NULL); SDL_assert(_this->last == NULL); SDL_assert(_this->num_devices == 0); SDL_free(_this); _this = NULL; } } #if SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char* dev_path) { if (dev_path == NULL) { return; } switch(udev_event) { case SDL_UDEV_DEVICEADDED: if (!(udev_class & (SDL_UDEV_DEVICE_MOUSE | SDL_UDEV_DEVICE_KEYBOARD | SDL_UDEV_DEVICE_TOUCHSCREEN))) return; SDL_EVDEV_device_added(dev_path, udev_class); break; case SDL_UDEV_DEVICEREMOVED: SDL_EVDEV_device_removed(dev_path); break; default: break; } } #endif /* SDL_USE_LIBUDEV */ void SDL_EVDEV_Poll(void) { struct input_event events[32]; int i, j, len; SDL_evdevlist_item *item; SDL_Scancode scan_code; int mouse_button; SDL_Mouse *mouse; float norm_x, norm_y; if (!_this) { return; } #if SDL_USE_LIBUDEV SDL_UDEV_Poll(); #endif mouse = SDL_GetMouse(); for (item = _this->first; item != NULL; item = item->next) { while ((len = read(item->fd, events, (sizeof events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { /* special handling for touchscreen, that should eventually be used for all devices */ if (item->out_of_sync && item->is_touchscreen && events[i].type == EV_SYN && events[i].code != SYN_REPORT) { break; } switch (events[i].type) { case EV_KEY: if (events[i].code >= BTN_MOUSE && events[i].code < BTN_MOUSE + SDL_arraysize(EVDEV_MouseButtons)) { mouse_button = events[i].code - BTN_MOUSE; if (events[i].value == 0) { SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, EVDEV_MouseButtons[mouse_button]); } else if (events[i].value == 1) { SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, EVDEV_MouseButtons[mouse_button]); } break; } /* Probably keyboard */ scan_code = SDL_EVDEV_translate_keycode(events[i].code); if (scan_code != SDL_SCANCODE_UNKNOWN) { if (events[i].value == 0) { SDL_SendKeyboardKey(SDL_RELEASED, scan_code); } else if (events[i].value == 1 || events[i].value == 2 /* key repeated */) { SDL_SendKeyboardKey(SDL_PRESSED, scan_code); } } SDL_EVDEV_kbd_keycode(_this->kbd, events[i].code, events[i].value); break; case EV_ABS: switch(events[i].code) { case ABS_MT_SLOT: if (!item->is_touchscreen) /* FIXME: temp hack */ break; item->touchscreen_data->current_slot = events[i].value; break; case ABS_MT_TRACKING_ID: if (!item->is_touchscreen) /* FIXME: temp hack */ break; if (events[i].value >= 0) { item->touchscreen_data->slots[item->touchscreen_data->current_slot].tracking_id = events[i].value; item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_DOWN; } else { item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_UP; } break; case ABS_MT_POSITION_X: if (!item->is_touchscreen) /* FIXME: temp hack */ break; item->touchscreen_data->slots[item->touchscreen_data->current_slot].x = events[i].value; if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) { item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE; } break; case ABS_MT_POSITION_Y: if (!item->is_touchscreen) /* FIXME: temp hack */ break; item->touchscreen_data->slots[item->touchscreen_data->current_slot].y = events[i].value; if (item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta == EVDEV_TOUCH_SLOTDELTA_NONE) { item->touchscreen_data->slots[item->touchscreen_data->current_slot].delta = EVDEV_TOUCH_SLOTDELTA_MOVE; } break; case ABS_X: if (item->is_touchscreen) /* FIXME: temp hack */ break; SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, events[i].value, mouse->y); break; case ABS_Y: if (item->is_touchscreen) /* FIXME: temp hack */ break; SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_FALSE, mouse->x, events[i].value); break; default: break; } break; case EV_REL: switch(events[i].code) { case REL_X: SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, events[i].value, 0); break; case REL_Y: SDL_SendMouseMotion(mouse->focus, mouse->mouseID, SDL_TRUE, 0, events[i].value); break; case REL_WHEEL: SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, events[i].value, SDL_MOUSEWHEEL_NORMAL); break; case REL_HWHEEL: SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL); break; default: break; } break; case EV_SYN: switch (events[i].code) { case SYN_REPORT: if (!item->is_touchscreen) /* FIXME: temp hack */ break; for(j = 0; j < item->touchscreen_data->max_slots; j++) { norm_x = (float)(item->touchscreen_data->slots[j].x - item->touchscreen_data->min_x) / (float)item->touchscreen_data->range_x; norm_y = (float)(item->touchscreen_data->slots[j].y - item->touchscreen_data->min_y) / (float)item->touchscreen_data->range_y; switch(item->touchscreen_data->slots[j].delta) { case EVDEV_TOUCH_SLOTDELTA_DOWN: SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, SDL_TRUE, norm_x, norm_y, 1.0f); item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE; break; case EVDEV_TOUCH_SLOTDELTA_UP: SDL_SendTouch(item->fd, item->touchscreen_data->slots[j].tracking_id, SDL_FALSE, norm_x, norm_y, 1.0f); item->touchscreen_data->slots[j].tracking_id = -1; item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE; break; case EVDEV_TOUCH_SLOTDELTA_MOVE: SDL_SendTouchMotion(item->fd, item->touchscreen_data->slots[j].tracking_id, norm_x, norm_y, 1.0f); item->touchscreen_data->slots[j].delta = EVDEV_TOUCH_SLOTDELTA_NONE; break; default: break; } } if (item->out_of_sync) item->out_of_sync = 0; break; case SYN_DROPPED: if (item->is_touchscreen) item->out_of_sync = 1; SDL_EVDEV_sync_device(item); break; default: break; } break; } } } } } static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; if (keycode < SDL_arraysize(linux_scancode_table)) scancode = linux_scancode_table[keycode]; if (scancode == SDL_SCANCODE_UNKNOWN) { SDL_Log("The key you just pressed is not recognized by SDL. To help " "get this fixed, please report this to the SDL forums/mailing list " "<https://discourse.libsdl.org/> EVDEV KeyCode %d", keycode); } return scancode; } #ifdef SDL_USE_LIBUDEV static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item* item) { int ret, i; char name[64]; struct input_absinfo abs_info; if (!item->is_touchscreen) return 0; item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data)); if (item->touchscreen_data == NULL) return SDL_OutOfMemory(); ret = ioctl(item->fd, EVIOCGNAME(sizeof(name)), name); if (ret < 0) { SDL_free(item->touchscreen_data); return SDL_SetError("Failed to get evdev touchscreen name"); } item->touchscreen_data->name = SDL_strdup(name); if (item->touchscreen_data->name == NULL) { SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); } ret = ioctl(item->fd, EVIOCGABS(ABS_MT_POSITION_X), &abs_info); if (ret < 0) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_SetError("Failed to get evdev touchscreen limits"); } item->touchscreen_data->min_x = abs_info.minimum; item->touchscreen_data->max_x = abs_info.maximum; item->touchscreen_data->range_x = abs_info.maximum - abs_info.minimum; ret = ioctl(item->fd, EVIOCGABS(ABS_MT_POSITION_Y), &abs_info); if (ret < 0) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_SetError("Failed to get evdev touchscreen limits"); } item->touchscreen_data->min_y = abs_info.minimum; item->touchscreen_data->max_y = abs_info.maximum; item->touchscreen_data->range_y = abs_info.maximum - abs_info.minimum; ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info); if (ret < 0) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_SetError("Failed to get evdev touchscreen limits"); } item->touchscreen_data->max_slots = abs_info.maximum + 1; item->touchscreen_data->slots = SDL_calloc( item->touchscreen_data->max_slots, sizeof(*item->touchscreen_data->slots)); if (item->touchscreen_data->slots == NULL) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); } for(i = 0; i < item->touchscreen_data->max_slots; i++) { item->touchscreen_data->slots[i].tracking_id = -1; } ret = SDL_AddTouch(item->fd, /* I guess our fd is unique enough */ item->touchscreen_data->name); if (ret < 0) { SDL_free(item->touchscreen_data->slots); SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return ret; } return 0; } #endif /* SDL_USE_LIBUDEV */ static void SDL_EVDEV_destroy_touchscreen(SDL_evdevlist_item* item) { if (!item->is_touchscreen) return; SDL_DelTouch(item->fd); SDL_free(item->touchscreen_data->slots); SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); } static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) { #ifdef EVIOCGMTSLOTS int i, ret; struct input_absinfo abs_info; /* * struct input_mt_request_layout { * __u32 code; * __s32 values[num_slots]; * }; * * this is the structure we're trying to emulate */ __u32* mt_req_code; __s32* mt_req_values; size_t mt_req_size; /* TODO: sync devices other than touchscreen */ if (!item->is_touchscreen) return; mt_req_size = sizeof(*mt_req_code) + sizeof(*mt_req_values) * item->touchscreen_data->max_slots; mt_req_code = SDL_calloc(1, mt_req_size); if (mt_req_code == NULL) { return; } mt_req_values = (__s32*)mt_req_code + 1; *mt_req_code = ABS_MT_TRACKING_ID; ret = ioctl(item->fd, EVIOCGMTSLOTS(mt_req_size), mt_req_code); if (ret < 0) { SDL_free(mt_req_code); return; } for(i = 0; i < item->touchscreen_data->max_slots; i++) { /* * This doesn't account for the very edge case of the user removing their * finger and replacing it on the screen during the time we're out of sync, * which'll mean that we're not going from down -> up or up -> down, we're * going from down -> down but with a different tracking id, meaning we'd * have to tell SDL of the two events, but since we wait till SYN_REPORT in * SDL_EVDEV_Poll to tell SDL, the current structure of this code doesn't * allow it. Lets just pray to God it doesn't happen. */ if (item->touchscreen_data->slots[i].tracking_id < 0 && mt_req_values[i] >= 0) { item->touchscreen_data->slots[i].tracking_id = mt_req_values[i]; item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_DOWN; } else if (item->touchscreen_data->slots[i].tracking_id >= 0 && mt_req_values[i] < 0) { item->touchscreen_data->slots[i].tracking_id = -1; item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_UP; } } *mt_req_code = ABS_MT_POSITION_X; ret = ioctl(item->fd, EVIOCGMTSLOTS(mt_req_size), mt_req_code); if (ret < 0) { SDL_free(mt_req_code); return; } for(i = 0; i < item->touchscreen_data->max_slots; i++) { if (item->touchscreen_data->slots[i].tracking_id >= 0 && item->touchscreen_data->slots[i].x != mt_req_values[i]) { item->touchscreen_data->slots[i].x = mt_req_values[i]; if (item->touchscreen_data->slots[i].delta == EVDEV_TOUCH_SLOTDELTA_NONE) { item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_MOVE; } } } *mt_req_code = ABS_MT_POSITION_Y; ret = ioctl(item->fd, EVIOCGMTSLOTS(mt_req_size), mt_req_code); if (ret < 0) { SDL_free(mt_req_code); return; } for(i = 0; i < item->touchscreen_data->max_slots; i++) { if (item->touchscreen_data->slots[i].tracking_id >= 0 && item->touchscreen_data->slots[i].y != mt_req_values[i]) { item->touchscreen_data->slots[i].y = mt_req_values[i]; if (item->touchscreen_data->slots[i].delta == EVDEV_TOUCH_SLOTDELTA_NONE) { item->touchscreen_data->slots[i].delta = EVDEV_TOUCH_SLOTDELTA_MOVE; } } } ret = ioctl(item->fd, EVIOCGABS(ABS_MT_SLOT), &abs_info); if (ret < 0) { SDL_free(mt_req_code); return; } item->touchscreen_data->current_slot = abs_info.value; SDL_free(mt_req_code); #endif /* EVIOCGMTSLOTS */ } #if SDL_USE_LIBUDEV static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) { int ret; SDL_evdevlist_item *item; /* Check to make sure it's not already in list. */ for (item = _this->first; item != NULL; item = item->next) { if (SDL_strcmp(dev_path, item->path) == 0) { return -1; /* already have this one */ } } item = (SDL_evdevlist_item *) SDL_calloc(1, sizeof (SDL_evdevlist_item)); if (item == NULL) { return SDL_OutOfMemory(); } item->fd = open(dev_path, O_RDONLY | O_NONBLOCK); if (item->fd < 0) { SDL_free(item); return SDL_SetError("Unable to open %s", dev_path); } item->path = SDL_strdup(dev_path); if (item->path == NULL) { close(item->fd); SDL_free(item); return SDL_OutOfMemory(); } if (udev_class & SDL_UDEV_DEVICE_TOUCHSCREEN) { item->is_touchscreen = 1; if ((ret = SDL_EVDEV_init_touchscreen(item)) < 0) { close(item->fd); SDL_free(item); return ret; } } if (_this->last == NULL) { _this->first = _this->last = item; } else { _this->last->next = item; _this->last = item; } SDL_EVDEV_sync_device(item); return _this->num_devices++; } #endif /* SDL_USE_LIBUDEV */ static int SDL_EVDEV_device_removed(const char *dev_path) { SDL_evdevlist_item *item; SDL_evdevlist_item *prev = NULL; for (item = _this->first; item != NULL; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(dev_path, item->path) == 0) { if (prev != NULL) { prev->next = item->next; } else { SDL_assert(_this->first == item); _this->first = item->next; } if (item == _this->last) { _this->last = prev; } if (item->is_touchscreen) { SDL_EVDEV_destroy_touchscreen(item); } close(item->fd); SDL_free(item->path); SDL_free(item); _this->num_devices--; return 0; } prev = item; } return -1; } #endif /* SDL_INPUT_LINUXEV */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_evdev_h_ #define SDL_evdev_h_ #ifdef SDL_INPUT_LINUXEV #include "SDL_events.h" extern int SDL_EVDEV_Init(void); extern void SDL_EVDEV_Quit(void); extern void SDL_EVDEV_Poll(void); #endif /* SDL_INPUT_LINUXEV */ #endif /* SDL_evdev_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev_kbd.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_evdev_kbd.h" #include "SDL_hints.h" #ifdef SDL_INPUT_LINUXKD /* This logic is adapted from drivers/tty/vt/keyboard.c in the Linux kernel source */ #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <linux/kd.h> #include <linux/keyboard.h> #include <linux/vt.h> #include <linux/tiocl.h> /* for TIOCL_GETSHIFTSTATE */ #include <signal.h> #include "../../events/SDL_events_c.h" #include "SDL_evdev_kbd_default_accents.h" #include "SDL_evdev_kbd_default_keymap.h" /* These are not defined in older Linux kernel headers */ #ifndef K_UNICODE #define K_UNICODE 0x03 #endif #ifndef K_OFF #define K_OFF 0x04 #endif /* * Handler Tables. */ #define K_HANDLERS\ k_self, k_fn, k_spec, k_pad,\ k_dead, k_cons, k_cur, k_shift,\ k_meta, k_ascii, k_lock, k_lowercase,\ k_slock, k_dead2, k_brl, k_ignore typedef void (k_handler_fn)(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag); static k_handler_fn K_HANDLERS; static k_handler_fn *k_handler[16] = { K_HANDLERS }; typedef void (fn_handler_fn)(SDL_EVDEV_keyboard_state *kbd); static void fn_enter(SDL_EVDEV_keyboard_state *kbd); static void fn_caps_toggle(SDL_EVDEV_keyboard_state *kbd); static void fn_caps_on(SDL_EVDEV_keyboard_state *kbd); static void fn_num(SDL_EVDEV_keyboard_state *kbd); static void fn_compose(SDL_EVDEV_keyboard_state *kbd); static fn_handler_fn *fn_handler[] = { NULL, fn_enter, NULL, NULL, NULL, NULL, NULL, fn_caps_toggle, fn_num, NULL, NULL, NULL, NULL, fn_caps_on, fn_compose, NULL, NULL, NULL, NULL, fn_num }; /* * Keyboard State */ struct SDL_EVDEV_keyboard_state { int console_fd; int old_kbd_mode; unsigned short **key_maps; unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ SDL_bool dead_key_next; int npadch; /* -1 or number assembled on pad */ struct kbdiacrs *accents; unsigned int diacr; SDL_bool rep; /* flag telling character repeat */ unsigned char lockstate; unsigned char slockstate; unsigned char ledflagstate; char shift_state; char text[128]; unsigned int text_len; }; #ifdef DUMP_ACCENTS static void SDL_EVDEV_dump_accents(SDL_EVDEV_keyboard_state *kbd) { unsigned int i; printf("static struct kbdiacrs default_accents = {\n"); printf(" %d,\n", kbd->accents->kb_cnt); printf(" {\n"); for (i = 0; i < kbd->accents->kb_cnt; ++i) { struct kbdiacr *diacr = &kbd->accents->kbdiacr[i]; printf(" { 0x%.2x, 0x%.2x, 0x%.2x },\n", diacr->diacr, diacr->base, diacr->result); } while (i < 256) { printf(" { 0x00, 0x00, 0x00 },\n"); ++i; } printf(" }\n"); printf("};\n"); } #endif /* DUMP_ACCENTS */ #ifdef DUMP_KEYMAP static void SDL_EVDEV_dump_keymap(SDL_EVDEV_keyboard_state *kbd) { int i, j; for (i = 0; i < MAX_NR_KEYMAPS; ++i) { if (kbd->key_maps[i]) { printf("static unsigned short default_key_map_%d[NR_KEYS] = {", i); for (j = 0; j < NR_KEYS; ++j) { if ((j%8) == 0) { printf("\n "); } printf("0x%.4x, ", kbd->key_maps[i][j]); } printf("\n};\n"); } } printf("\n"); printf("static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = {\n"); for (i = 0; i < MAX_NR_KEYMAPS; ++i) { if (kbd->key_maps[i]) { printf(" default_key_map_%d,\n", i); } else { printf(" NULL,\n"); } } printf("};\n"); } #endif /* DUMP_KEYMAP */ static int SDL_EVDEV_kbd_load_keymaps(SDL_EVDEV_keyboard_state *kbd) { int i, j; kbd->key_maps = (unsigned short **)SDL_calloc(MAX_NR_KEYMAPS, sizeof(unsigned short *)); if (!kbd->key_maps) { return -1; } for (i = 0; i < MAX_NR_KEYMAPS; ++i) { struct kbentry kbe; kbe.kb_table = i; kbe.kb_index = 0; if (ioctl(kbd->console_fd, KDGKBENT, &kbe) < 0) { return -1; } if (kbe.kb_value == K_NOSUCHMAP) { continue; } kbd->key_maps[i] = (unsigned short *)SDL_malloc(NR_KEYS * sizeof(unsigned short)); if (!kbd->key_maps[i]) { return -1; } for (j = 0; j < NR_KEYS; ++j) { kbe.kb_table = i; kbe.kb_index = j; if (ioctl(kbd->console_fd, KDGKBENT, &kbe) < 0) { return -1; } kbd->key_maps[i][j] = (kbe.kb_value ^ 0xf000); } } return 0; } static SDL_EVDEV_keyboard_state * kbd_cleanup_state = NULL; static int kbd_cleanup_sigactions_installed = 0; static int kbd_cleanup_atexit_installed = 0; static struct sigaction old_sigaction[NSIG] = { 0 }; static int fatal_signals[] = { /* Handlers for SIGTERM and SIGINT are installed in SDL_QuitInit. */ SIGHUP, SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGPIPE, SIGBUS, SIGSYS }; static void kbd_cleanup(void) { SDL_EVDEV_keyboard_state* kbd = kbd_cleanup_state; if (kbd == NULL) { return; } kbd_cleanup_state = NULL; fprintf(stderr, "(SDL restoring keyboard) "); ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode); } void SDL_EVDEV_kbd_reraise_signal(int sig) { raise(sig); } siginfo_t* SDL_EVDEV_kdb_cleanup_siginfo = NULL; void* SDL_EVDEV_kdb_cleanup_ucontext = NULL; static void kbd_cleanup_signal_action(int signum, siginfo_t* info, void* ucontext) { struct sigaction* old_action_p = &(old_sigaction[signum]); sigset_t sigset; /* Restore original signal handler before going any further. */ sigaction(signum, old_action_p, NULL); /* Unmask current signal. */ sigemptyset(&sigset); sigaddset(&sigset, signum); sigprocmask(SIG_UNBLOCK, &sigset, NULL); /* Save original signal info and context for archeologists. */ SDL_EVDEV_kdb_cleanup_siginfo = info; SDL_EVDEV_kdb_cleanup_ucontext = ucontext; /* Restore keyboard. */ kbd_cleanup(); /* Reraise signal. */ SDL_EVDEV_kbd_reraise_signal(signum); } static void kbd_unregister_emerg_cleanup() { int tabidx, signum; kbd_cleanup_state = NULL; if (!kbd_cleanup_sigactions_installed) { return; } kbd_cleanup_sigactions_installed = 0; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { struct sigaction* old_action_p; struct sigaction cur_action; signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); /* Examine current signal action */ if (sigaction(signum, NULL, &cur_action)) continue; /* Check if action installed and not modifed */ if (!(cur_action.sa_flags & SA_SIGINFO) || cur_action.sa_sigaction != &kbd_cleanup_signal_action) continue; /* Restore original action */ sigaction(signum, old_action_p, NULL); } } static void kbd_cleanup_atexit(void) { /* Restore keyboard. */ kbd_cleanup(); /* Try to restore signal handlers in case shared library is being unloaded */ kbd_unregister_emerg_cleanup(); } static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state * kbd) { int tabidx, signum; if (kbd_cleanup_state != NULL) { return; } kbd_cleanup_state = kbd; if (!kbd_cleanup_atexit_installed) { /* Since glibc 2.2.3, atexit() (and on_exit(3)) can be used within a shared library to establish * functions that are called when the shared library is unloaded. * -- man atexit(3) */ atexit(kbd_cleanup_atexit); kbd_cleanup_atexit_installed = 1; } if (kbd_cleanup_sigactions_installed) { return; } kbd_cleanup_sigactions_installed = 1; for (tabidx = 0; tabidx < sizeof(fatal_signals) / sizeof(fatal_signals[0]); ++tabidx) { struct sigaction* old_action_p; struct sigaction new_action; signum = fatal_signals[tabidx]; old_action_p = &(old_sigaction[signum]); if (sigaction(signum, NULL, old_action_p)) continue; /* Skip SIGHUP and SIGPIPE if handler is already installed * - assume the handler will do the cleanup */ if ((signum == SIGHUP || signum == SIGPIPE) && (old_action_p->sa_handler != SIG_DFL || (void (*)(int))old_action_p->sa_sigaction != SIG_DFL)) continue; new_action = *old_action_p; new_action.sa_flags |= SA_SIGINFO; new_action.sa_sigaction = &kbd_cleanup_signal_action; sigaction(signum, &new_action, NULL); } } SDL_EVDEV_keyboard_state * SDL_EVDEV_kbd_init(void) { SDL_EVDEV_keyboard_state *kbd; int i; char flag_state; char shift_state[2] = {TIOCL_GETSHIFTSTATE, 0}; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd)); if (!kbd) { return NULL; } kbd->npadch = -1; /* This might fail if we're not connected to a tty (e.g. on the Steam Link) */ kbd->console_fd = open("/dev/tty", O_RDONLY); if (ioctl(kbd->console_fd, TIOCLINUX, shift_state) == 0) { kbd->shift_state = *shift_state; } if (ioctl(kbd->console_fd, KDGKBLED, &flag_state) == 0) { kbd->ledflagstate = flag_state; } kbd->accents = &default_accents; if (ioctl(kbd->console_fd, KDGKBDIACR, kbd->accents) < 0) { /* No worries, we'll use the default accent table */ } kbd->key_maps = default_key_maps; if (ioctl(kbd->console_fd, KDGKBMODE, &kbd->old_kbd_mode) == 0) { /* Set the keyboard in UNICODE mode and load the keymaps */ ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE); if (SDL_EVDEV_kbd_load_keymaps(kbd) < 0) { for (i = 0; i < MAX_NR_KEYMAPS; ++i) { if (kbd->key_maps[i]) { SDL_free(kbd->key_maps[i]); } } SDL_free(kbd->key_maps); kbd->key_maps = default_key_maps; } /* Allow inhibiting keyboard mute with env. variable for debugging etc. */ if (getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) { /* Mute the keyboard so keystrokes only generate evdev events * and do not leak through to the console */ ioctl(kbd->console_fd, KDSKBMODE, K_OFF); /* Make sure to restore keyboard if application fails to call * SDL_Quit before exit or fatal signal is raised. */ if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { kbd_register_emerg_cleanup(kbd); } } } #ifdef DUMP_ACCENTS SDL_EVDEV_dump_accents(kbd); #endif #ifdef DUMP_KEYMAP SDL_EVDEV_dump_keymap(kbd); #endif return kbd; } void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { if (!kbd) { return; } kbd_unregister_emerg_cleanup(); if (kbd->console_fd >= 0) { /* Restore the original keyboard mode */ ioctl(kbd->console_fd, KDSKBMODE, kbd->old_kbd_mode); close(kbd->console_fd); kbd->console_fd = -1; } if (kbd->key_maps && kbd->key_maps != default_key_maps) { int i; for (i = 0; i < MAX_NR_KEYMAPS; ++i) { if (kbd->key_maps[i]) { SDL_free(kbd->key_maps[i]); } } SDL_free(kbd->key_maps); } SDL_free(kbd); } /* * Helper Functions. */ static void put_queue(SDL_EVDEV_keyboard_state *kbd, uint c) { /* c is already part of a UTF-8 sequence and safe to add as a character */ if (kbd->text_len < (sizeof(kbd->text)-1)) { kbd->text[kbd->text_len++] = (char)c; } } static void put_utf8(SDL_EVDEV_keyboard_state *kbd, uint c) { if (c < 0x80) /* 0******* */ put_queue(kbd, c); else if (c < 0x800) { /* 110***** 10****** */ put_queue(kbd, 0xc0 | (c >> 6)); put_queue(kbd, 0x80 | (c & 0x3f)); } else if (c < 0x10000) { if (c >= 0xD800 && c < 0xE000) return; if (c == 0xFFFF) return; /* 1110**** 10****** 10****** */ put_queue(kbd, 0xe0 | (c >> 12)); put_queue(kbd, 0x80 | ((c >> 6) & 0x3f)); put_queue(kbd, 0x80 | (c & 0x3f)); } else if (c < 0x110000) { /* 11110*** 10****** 10****** 10****** */ put_queue(kbd, 0xf0 | (c >> 18)); put_queue(kbd, 0x80 | ((c >> 12) & 0x3f)); put_queue(kbd, 0x80 | ((c >> 6) & 0x3f)); put_queue(kbd, 0x80 | (c & 0x3f)); } } /* * We have a combining character DIACR here, followed by the character CH. * If the combination occurs in the table, return the corresponding value. * Otherwise, if CH is a space or equals DIACR, return DIACR. * Otherwise, conclude that DIACR was not combining after all, * queue it and return CH. */ static unsigned int handle_diacr(SDL_EVDEV_keyboard_state *kbd, unsigned int ch) { unsigned int d = kbd->diacr; unsigned int i; kbd->diacr = 0; for (i = 0; i < kbd->accents->kb_cnt; i++) { if (kbd->accents->kbdiacr[i].diacr == d && kbd->accents->kbdiacr[i].base == ch) { return kbd->accents->kbdiacr[i].result; } } if (ch == ' ' || ch == d) return d; put_utf8(kbd, d); return ch; } static int vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag) { return ((kbd->ledflagstate >> flag) & 1); } static void set_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag) { kbd->ledflagstate |= 1 << flag; } static void clr_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag) { kbd->ledflagstate &= ~(1 << flag); } static void chg_vc_kbd_lock(SDL_EVDEV_keyboard_state *kbd, int flag) { kbd->lockstate ^= 1 << flag; } static void chg_vc_kbd_slock(SDL_EVDEV_keyboard_state *kbd, int flag) { kbd->slockstate ^= 1 << flag; } static void chg_vc_kbd_led(SDL_EVDEV_keyboard_state *kbd, int flag) { kbd->ledflagstate ^= 1 << flag; } /* * Special function handlers */ static void fn_enter(SDL_EVDEV_keyboard_state *kbd) { if (kbd->diacr) { put_utf8(kbd, kbd->diacr); kbd->diacr = 0; } } static void fn_caps_toggle(SDL_EVDEV_keyboard_state *kbd) { if (kbd->rep) return; chg_vc_kbd_led(kbd, K_CAPSLOCK); } static void fn_caps_on(SDL_EVDEV_keyboard_state *kbd) { if (kbd->rep) return; set_vc_kbd_led(kbd, K_CAPSLOCK); } static void fn_num(SDL_EVDEV_keyboard_state *kbd) { if (!kbd->rep) chg_vc_kbd_led(kbd, K_NUMLOCK); } static void fn_compose(SDL_EVDEV_keyboard_state *kbd) { kbd->dead_key_next = SDL_TRUE; } /* * Special key handlers */ static void k_ignore(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_spec(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { if (up_flag) return; if (value >= SDL_arraysize(fn_handler)) return; if (fn_handler[value]) fn_handler[value](kbd); } static void k_lowercase(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_self(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { if (up_flag) return; /* no action, if this is a key release */ if (kbd->diacr) value = handle_diacr(kbd, value); if (kbd->dead_key_next) { kbd->dead_key_next = SDL_FALSE; kbd->diacr = value; return; } put_utf8(kbd, value); } static void k_deadunicode(SDL_EVDEV_keyboard_state *kbd, unsigned int value, char up_flag) { if (up_flag) return; kbd->diacr = (kbd->diacr ? handle_diacr(kbd, value) : value); } static void k_dead(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { const unsigned char ret_diacr[NR_DEAD] = {'`', '\'', '^', '~', '"', ',' }; k_deadunicode(kbd, ret_diacr[value], up_flag); } static void k_dead2(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { k_deadunicode(kbd, value, up_flag); } static void k_cons(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_fn(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_cur(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_pad(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { static const char pad_chars[] = "0123456789+-*/\015,.?()#"; if (up_flag) return; /* no action, if this is a key release */ if (!vc_kbd_led(kbd, K_NUMLOCK)) { /* unprintable action */ return; } put_queue(kbd, pad_chars[value]); } static void k_shift(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { int old_state = kbd->shift_state; if (kbd->rep) return; /* * Mimic typewriter: * a CapsShift key acts like Shift but undoes CapsLock */ if (value == KVAL(K_CAPSSHIFT)) { value = KVAL(K_SHIFT); if (!up_flag) clr_vc_kbd_led(kbd, K_CAPSLOCK); } if (up_flag) { /* * handle the case that two shift or control * keys are depressed simultaneously */ if (kbd->shift_down[value]) kbd->shift_down[value]--; } else kbd->shift_down[value]++; if (kbd->shift_down[value]) kbd->shift_state |= (1 << value); else kbd->shift_state &= ~(1 << value); /* kludge */ if (up_flag && kbd->shift_state != old_state && kbd->npadch != -1) { put_utf8(kbd, kbd->npadch); kbd->npadch = -1; } } static void k_meta(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } static void k_ascii(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { int base; if (up_flag) return; if (value < 10) { /* decimal input of code, while Alt depressed */ base = 10; } else { /* hexadecimal input of code, while AltGr depressed */ value -= 10; base = 16; } if (kbd->npadch == -1) kbd->npadch = value; else kbd->npadch = kbd->npadch * base + value; } static void k_lock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { if (up_flag || kbd->rep) return; chg_vc_kbd_lock(kbd, value); } static void k_slock(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { k_shift(kbd, value, up_flag); if (up_flag || kbd->rep) return; chg_vc_kbd_slock(kbd, value); /* try to make Alt, oops, AltGr and such work */ if (!kbd->key_maps[kbd->lockstate ^ kbd->slockstate]) { kbd->slockstate = 0; chg_vc_kbd_slock(kbd, value); } } static void k_brl(SDL_EVDEV_keyboard_state *kbd, unsigned char value, char up_flag) { } void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, int down) { unsigned char shift_final; unsigned char type; unsigned short *key_map; unsigned short keysym; if (!kbd) { return; } kbd->rep = (down == 2); shift_final = (kbd->shift_state | kbd->slockstate) ^ kbd->lockstate; key_map = kbd->key_maps[shift_final]; if (!key_map) { /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */ kbd->shift_state = 0; kbd->slockstate = 0; kbd->lockstate = 0; return; } if (keycode < NR_KEYS) { keysym = key_map[keycode]; } else { return; } type = KTYP(keysym); if (type < 0xf0) { if (down) { put_utf8(kbd, keysym); } } else { type -= 0xf0; /* if type is KT_LETTER then it can be affected by Caps Lock */ if (type == KT_LETTER) { type = KT_LATIN; if (vc_kbd_led(kbd, K_CAPSLOCK)) { key_map = kbd->key_maps[shift_final ^ (1 << KG_SHIFT)]; if (key_map) { keysym = key_map[keycode]; } } } (*k_handler[type])(kbd, keysym & 0xff, !down); if (type != KT_SLOCK) { kbd->slockstate = 0; } } if (kbd->text_len > 0) { kbd->text[kbd->text_len] = '\0'; SDL_SendKeyboardText(kbd->text); kbd->text_len = 0; } } #else /* !SDL_INPUT_LINUXKD */ SDL_EVDEV_keyboard_state * SDL_EVDEV_kbd_init(void) { return NULL; } void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) { } void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) { } #endif /* SDL_INPUT_LINUXKD */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev_kbd.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ struct SDL_EVDEV_keyboard_state; typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state; extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void); extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down); extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev_kbd_default_accents.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ static struct kbdiacrs default_accents = { 68, { { 0x60, 0x41, 0xc0 }, { 0x60, 0x61, 0xe0 }, { 0x27, 0x41, 0xc1 }, { 0x27, 0x61, 0xe1 }, { 0x5e, 0x41, 0xc2 }, { 0x5e, 0x61, 0xe2 }, { 0x7e, 0x41, 0xc3 }, { 0x7e, 0x61, 0xe3 }, { 0x22, 0x41, 0xc4 }, { 0x22, 0x61, 0xe4 }, { 0x4f, 0x41, 0xc5 }, { 0x6f, 0x61, 0xe5 }, { 0x30, 0x41, 0xc5 }, { 0x30, 0x61, 0xe5 }, { 0x41, 0x41, 0xc5 }, { 0x61, 0x61, 0xe5 }, { 0x41, 0x45, 0xc6 }, { 0x61, 0x65, 0xe6 }, { 0x2c, 0x43, 0xc7 }, { 0x2c, 0x63, 0xe7 }, { 0x60, 0x45, 0xc8 }, { 0x60, 0x65, 0xe8 }, { 0x27, 0x45, 0xc9 }, { 0x27, 0x65, 0xe9 }, { 0x5e, 0x45, 0xca }, { 0x5e, 0x65, 0xea }, { 0x22, 0x45, 0xcb }, { 0x22, 0x65, 0xeb }, { 0x60, 0x49, 0xcc }, { 0x60, 0x69, 0xec }, { 0x27, 0x49, 0xcd }, { 0x27, 0x69, 0xed }, { 0x5e, 0x49, 0xce }, { 0x5e, 0x69, 0xee }, { 0x22, 0x49, 0xcf }, { 0x22, 0x69, 0xef }, { 0x2d, 0x44, 0xd0 }, { 0x2d, 0x64, 0xf0 }, { 0x7e, 0x4e, 0xd1 }, { 0x7e, 0x6e, 0xf1 }, { 0x60, 0x4f, 0xd2 }, { 0x60, 0x6f, 0xf2 }, { 0x27, 0x4f, 0xd3 }, { 0x27, 0x6f, 0xf3 }, { 0x5e, 0x4f, 0xd4 }, { 0x5e, 0x6f, 0xf4 }, { 0x7e, 0x4f, 0xd5 }, { 0x7e, 0x6f, 0xf5 }, { 0x22, 0x4f, 0xd6 }, { 0x22, 0x6f, 0xf6 }, { 0x2f, 0x4f, 0xd8 }, { 0x2f, 0x6f, 0xf8 }, { 0x60, 0x55, 0xd9 }, { 0x60, 0x75, 0xf9 }, { 0x27, 0x55, 0xda }, { 0x27, 0x75, 0xfa }, { 0x5e, 0x55, 0xdb }, { 0x5e, 0x75, 0xfb }, { 0x22, 0x55, 0xdc }, { 0x22, 0x75, 0xfc }, { 0x27, 0x59, 0xdd }, { 0x27, 0x79, 0xfd }, { 0x54, 0x48, 0xde }, { 0x74, 0x68, 0xfe }, { 0x73, 0x73, 0xdf }, { 0x22, 0x79, 0xff }, { 0x73, 0x7a, 0xdf }, { 0x69, 0x6a, 0xff }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0x00 }, } }; /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_evdev_kbd_default_keymap.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ static unsigned short default_key_map_0[NR_KEYS] = { 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_1[NR_KEYS] = { 0xf200, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_2[NR_KEYS] = { 0xf200, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_3[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; #ifdef INCLUDE_EXTENDED_KEYMAP static unsigned short default_key_map_4[NR_KEYS] = { 0xf200, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_5[NR_KEYS] = { 0xf200, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_6[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_7[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_8[NR_KEYS] = { 0xf200, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_9[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_10[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_11[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_12[NR_KEYS] = { 0xf200, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf11a, 0xf10c, 0xf10d, 0xf11b, 0xf11c, 0xf110, 0xf311, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, }; static unsigned short default_key_map_13[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_14[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_15[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_16[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_17[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_18[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_19[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_20[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_21[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_22[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_23[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_24[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_25[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_26[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_27[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_28[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_29[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_30[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_31[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_32[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_33[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_34[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_35[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_36[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_37[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_38[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_39[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_40[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_41[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_42[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_43[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_44[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_45[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_46[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_47[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_48[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_49[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_50[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_51[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_52[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_53[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_54[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_55[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_56[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_57[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_58[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_59[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_60[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_61[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_62[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_63[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_64[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_65[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_66[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_67[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_68[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_69[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_70[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_71[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_72[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_73[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_74[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_75[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_76[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_77[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_78[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_79[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_80[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_81[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_82[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_83[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_84[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_85[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_86[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_87[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_88[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_89[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_90[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_91[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_92[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_93[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_94[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_95[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_96[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_97[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_98[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_99[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_100[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_101[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_102[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_103[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_104[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_105[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_106[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_107[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_108[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_109[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_110[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_111[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_112[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_113[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf10c, 0xf10d, 0xf10e, 0xf10f, 0xf110, 0xf111, 0xf112, 0xf113, 0xf11e, 0xf11f, 0xf208, 0xf203, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf03e, 0xf120, 0xf121, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf200, 0xf703, 0xf205, 0xf114, 0xf603, 0xf20b, 0xf601, 0xf602, 0xf117, 0xf600, 0xf20a, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_114[NR_KEYS] = { 0xf27e, 0xf01b, 0xf031, 0xf032, 0xf033, 0xf034, 0xf035, 0xf036, 0xf037, 0xf038, 0xf039, 0xf030, 0xf02d, 0xf03d, 0xf07f, 0xf009, 0xfb51, 0xfb57, 0xfb45, 0xfb52, 0xfb54, 0xfb59, 0xfb55, 0xfb49, 0xfb4f, 0xfb50, 0xf05b, 0xf05d, 0xf201, 0xf702, 0xfb41, 0xfb53, 0xfb44, 0xfb46, 0xfb47, 0xfb48, 0xfb4a, 0xfb4b, 0xfb4c, 0xf03b, 0xf027, 0xf060, 0xf700, 0xf05c, 0xfb5a, 0xfb58, 0xfb43, 0xfb56, 0xfb42, 0xfb4e, 0xfb4d, 0xf02c, 0xf02e, 0xf02f, 0xf700, 0xf916, 0xf703, 0xf020, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf202, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf07c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_115[NR_KEYS] = { 0xf27e, 0xf01b, 0xf021, 0xf040, 0xf023, 0xf024, 0xf025, 0xf05e, 0xf026, 0xf02a, 0xf028, 0xf029, 0xf05f, 0xf02b, 0xf07f, 0xf009, 0xfb71, 0xfb77, 0xfb65, 0xfb72, 0xfb74, 0xfb79, 0xfb75, 0xfb69, 0xfb6f, 0xfb70, 0xf07b, 0xf07d, 0xf201, 0xf702, 0xfb61, 0xfb73, 0xfb64, 0xfb66, 0xfb67, 0xfb68, 0xfb6a, 0xfb6b, 0xfb6c, 0xf03a, 0xf022, 0xf07e, 0xf700, 0xf07c, 0xfb7a, 0xfb78, 0xfb63, 0xfb76, 0xfb62, 0xfb6e, 0xfb6d, 0xf03c, 0xf03e, 0xf03f, 0xf700, 0xf30c, 0xf703, 0xf020, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0x00a6, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_116[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf122, 0xf123, 0xf124, 0xf125, 0xf126, 0xf127, 0xf128, 0xf129, 0xf12a, 0xf12b, 0xf208, 0xf204, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf12c, 0xf12d, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_117[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf12e, 0xf12f, 0xf130, 0xf131, 0xf132, 0xf133, 0xf134, 0xf135, 0xf136, 0xf137, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf138, 0xf139, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_118[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf000, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf01c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_119[NR_KEYS] = { 0xf27e, 0xf01b, 0xf200, 0xf000, 0xf200, 0xf200, 0xf200, 0xf01e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf01f, 0xf200, 0xf008, 0xf009, 0xf011, 0xf017, 0xf005, 0xf012, 0xf014, 0xf019, 0xf015, 0xf009, 0xf00f, 0xf010, 0xf01b, 0xf01d, 0xf00d, 0xf702, 0xf001, 0xf013, 0xf004, 0xf006, 0xf007, 0xf008, 0xf00a, 0xf00b, 0xf00c, 0xf200, 0xf200, 0xf01e, 0xf700, 0xf01c, 0xf01a, 0xf018, 0xf003, 0xf016, 0xf002, 0xf00e, 0xf201, 0xf200, 0xf20e, 0xf07f, 0xf700, 0xf30c, 0xf703, 0xf000, 0xfa06, 0xf518, 0xf519, 0xf51a, 0xf51b, 0xf51c, 0xf51d, 0xf51e, 0xf51f, 0xf520, 0xf521, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf01c, 0xf522, 0xf523, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf01c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf205, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_120[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf202, 0xf907, 0xf908, 0xf909, 0xf30b, 0xf904, 0xf905, 0xf906, 0xf30a, 0xf901, 0xf902, 0xf903, 0xf900, 0xf310, 0xf206, 0xf200, 0xf83c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf212, 0xf118, 0xf210, 0xf211, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_121[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf916, 0xf703, 0xf820, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf914, 0xf209, 0xf911, 0xf912, 0xf913, 0xf917, 0xf90e, 0xf90f, 0xf910, 0xf918, 0xf90b, 0xf90c, 0xf90d, 0xf90a, 0xf310, 0xf206, 0xf200, 0xf83e, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf919, 0xf702, 0xf915, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_122[NR_KEYS] = { 0xf27e, 0xf81b, 0xf831, 0xf832, 0xf833, 0xf834, 0xf835, 0xf836, 0xf837, 0xf838, 0xf839, 0xf830, 0xf82d, 0xf83d, 0xf87f, 0xf809, 0xf871, 0xf877, 0xf865, 0xf872, 0xf874, 0xf879, 0xf875, 0xf869, 0xf86f, 0xf870, 0xf85b, 0xf85d, 0xf80d, 0xf702, 0xf861, 0xf873, 0xf864, 0xf866, 0xf867, 0xf868, 0xf86a, 0xf86b, 0xf86c, 0xf83b, 0xf827, 0xf860, 0xf700, 0xf85c, 0xf87a, 0xf878, 0xf863, 0xf876, 0xf862, 0xf86e, 0xf86d, 0xf82c, 0xf82e, 0xf82f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_123[NR_KEYS] = { 0xf27e, 0xf81b, 0xf821, 0xf840, 0xf823, 0xf824, 0xf825, 0xf85e, 0xf826, 0xf82a, 0xf828, 0xf829, 0xf85f, 0xf82b, 0xf87f, 0xf809, 0xf851, 0xf857, 0xf845, 0xf852, 0xf854, 0xf859, 0xf855, 0xf849, 0xf84f, 0xf850, 0xf87b, 0xf87d, 0xf80d, 0xf702, 0xf841, 0xf853, 0xf844, 0xf846, 0xf847, 0xf848, 0xf84a, 0xf84b, 0xf84c, 0xf83a, 0xf822, 0xf87e, 0xf700, 0xf87c, 0xf85a, 0xf858, 0xf843, 0xf856, 0xf842, 0xf84e, 0xf84d, 0xf83c, 0xf83e, 0xf83f, 0xf700, 0xf30c, 0xf703, 0xf820, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf87c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf206, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_124[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf500, 0xf501, 0xf502, 0xf503, 0xf504, 0xf505, 0xf506, 0xf507, 0xf508, 0xf509, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf50a, 0xf50b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_125[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf50c, 0xf50d, 0xf50e, 0xf50f, 0xf510, 0xf511, 0xf512, 0xf513, 0xf514, 0xf515, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf516, 0xf517, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_126[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf800, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf20c, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf20c, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; static unsigned short default_key_map_127[NR_KEYS] = { 0xf27e, 0xf81b, 0xf200, 0xf800, 0xf200, 0xf200, 0xf200, 0xf81e, 0xf200, 0xf200, 0xf200, 0xf200, 0xf81f, 0xf200, 0xf808, 0xf809, 0xf811, 0xf817, 0xf805, 0xf812, 0xf814, 0xf819, 0xf815, 0xf809, 0xf80f, 0xf810, 0xf81b, 0xf81d, 0xf80d, 0xf702, 0xf801, 0xf813, 0xf804, 0xf806, 0xf807, 0xf808, 0xf80a, 0xf80b, 0xf80c, 0xf200, 0xf200, 0xf81e, 0xf700, 0xf81c, 0xf81a, 0xf818, 0xf803, 0xf816, 0xf802, 0xf80e, 0xf80d, 0xf200, 0xf20e, 0xf87f, 0xf700, 0xf30c, 0xf703, 0xf800, 0xfa06, 0xf100, 0xf101, 0xf102, 0xf103, 0xf104, 0xf105, 0xf106, 0xf107, 0xf108, 0xf109, 0xf208, 0xf209, 0xf307, 0xf308, 0xf309, 0xf30b, 0xf304, 0xf305, 0xf306, 0xf30a, 0xf301, 0xf302, 0xf303, 0xf300, 0xf310, 0xf206, 0xf200, 0xf81c, 0xf10a, 0xf10b, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf30e, 0xf702, 0xf30d, 0xf81c, 0xf703, 0xf205, 0xf114, 0xf603, 0xf118, 0xf601, 0xf602, 0xf117, 0xf600, 0xf119, 0xf115, 0xf116, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf11d, 0xf200, 0xf310, 0xf200, 0xf200, 0xf200, 0xf703, 0xf703, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, }; #endif /* INCLUDE_EXTENDED_KEYMAP */ static unsigned short *default_key_maps[MAX_NR_KEYMAPS] = { default_key_map_0, default_key_map_1, default_key_map_2, default_key_map_3, #ifdef INCLUDE_EXTENDED_KEYMAP default_key_map_4, default_key_map_5, default_key_map_6, default_key_map_7, default_key_map_8, default_key_map_9, default_key_map_10, default_key_map_11, default_key_map_12, default_key_map_13, default_key_map_14, default_key_map_15, default_key_map_16, default_key_map_17, default_key_map_18, default_key_map_19, default_key_map_20, default_key_map_21, default_key_map_22, default_key_map_23, default_key_map_24, default_key_map_25, default_key_map_26, default_key_map_27, default_key_map_28, default_key_map_29, default_key_map_30, default_key_map_31, default_key_map_32, default_key_map_33, default_key_map_34, default_key_map_35, default_key_map_36, default_key_map_37, default_key_map_38, default_key_map_39, default_key_map_40, default_key_map_41, default_key_map_42, default_key_map_43, default_key_map_44, default_key_map_45, default_key_map_46, default_key_map_47, default_key_map_48, default_key_map_49, default_key_map_50, default_key_map_51, default_key_map_52, default_key_map_53, default_key_map_54, default_key_map_55, default_key_map_56, default_key_map_57, default_key_map_58, default_key_map_59, default_key_map_60, default_key_map_61, default_key_map_62, default_key_map_63, default_key_map_64, default_key_map_65, default_key_map_66, default_key_map_67, default_key_map_68, default_key_map_69, default_key_map_70, default_key_map_71, default_key_map_72, default_key_map_73, default_key_map_74, default_key_map_75, default_key_map_76, default_key_map_77, default_key_map_78, default_key_map_79, default_key_map_80, default_key_map_81, default_key_map_82, default_key_map_83, default_key_map_84, default_key_map_85, default_key_map_86, default_key_map_87, default_key_map_88, default_key_map_89, default_key_map_90, default_key_map_91, default_key_map_92, default_key_map_93, default_key_map_94, default_key_map_95, default_key_map_96, default_key_map_97, default_key_map_98, default_key_map_99, default_key_map_100, default_key_map_101, default_key_map_102, default_key_map_103, default_key_map_104, default_key_map_105, default_key_map_106, default_key_map_107, default_key_map_108, default_key_map_109, default_key_map_110, default_key_map_111, default_key_map_112, default_key_map_113, default_key_map_114, default_key_map_115, default_key_map_116, default_key_map_117, default_key_map_118, default_key_map_119, default_key_map_120, default_key_map_121, default_key_map_122, default_key_map_123, default_key_map_124, default_key_map_125, default_key_map_126, default_key_map_127, #else /* !INCLUDE_EXTENDED_KEYMAP */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, #endif /* INCLUDE_EXTENDED_KEYMAP */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, }; /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_fcitx.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef HAVE_FCITX_FRONTEND_H #include <fcitx/frontend.h> #include <unistd.h> #include "SDL_fcitx.h" #include "SDL_keycode.h" #include "SDL_keyboard.h" #include "../../events/SDL_keyboard_c.h" #include "SDL_dbus.h" #include "SDL_syswm.h" #if SDL_VIDEO_DRIVER_X11 # include "../../video/x11/SDL_x11video.h" #endif #include "SDL_hints.h" #define FCITX_DBUS_SERVICE "org.fcitx.Fcitx" #define FCITX_IM_DBUS_PATH "/inputmethod" #define FCITX_IC_DBUS_PATH "/inputcontext_%d" #define FCITX_IM_DBUS_INTERFACE "org.fcitx.Fcitx.InputMethod" #define FCITX_IC_DBUS_INTERFACE "org.fcitx.Fcitx.InputContext" #define IC_NAME_MAX 64 #define DBUS_TIMEOUT 500 typedef struct _FcitxClient { SDL_DBusContext *dbus; char servicename[IC_NAME_MAX]; char icname[IC_NAME_MAX]; int id; SDL_Rect cursor_rect; } FcitxClient; static FcitxClient fcitx_client; static int GetDisplayNumber() { const char *display = SDL_getenv("DISPLAY"); const char *p = NULL; int number = 0; if (display == NULL) return 0; display = SDL_strchr(display, ':'); if (display == NULL) return 0; display++; p = SDL_strchr(display, '.'); if (p == NULL && display != NULL) { number = SDL_strtod(display, NULL); } else { char *buffer = SDL_strdup(display); buffer[p - display] = '\0'; number = SDL_strtod(buffer, NULL); SDL_free(buffer); } return number; } static char* GetAppName() { #if defined(__LINUX__) || defined(__FREEBSD__) char *spot; char procfile[1024]; char linkfile[1024]; int linksize; #if defined(__LINUX__) SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/exe", getpid()); #elif defined(__FREEBSD__) SDL_snprintf(procfile, sizeof(procfile), "/proc/%d/file", getpid()); #endif linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); if (linksize > 0) { linkfile[linksize] = '\0'; spot = SDL_strrchr(linkfile, '/'); if (spot) { return SDL_strdup(spot + 1); } else { return SDL_strdup(linkfile); } } #endif /* __LINUX__ || __FREEBSD__ */ return SDL_strdup("SDL_App"); } static DBusHandlerResult DBus_MessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) { SDL_DBusContext *dbus = (SDL_DBusContext *)data; if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "CommitString")) { DBusMessageIter iter; const char *text = NULL; dbus->message_iter_init(msg, &iter); dbus->message_iter_get_basic(&iter, &text); if (text) SDL_SendKeyboardText(text); return DBUS_HANDLER_RESULT_HANDLED; } if (dbus->message_is_signal(msg, FCITX_IC_DBUS_INTERFACE, "UpdatePreedit")) { DBusMessageIter iter; const char *text; dbus->message_iter_init(msg, &iter); dbus->message_iter_get_basic(&iter, &text); if (text && *text) { char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; size_t text_bytes = SDL_strlen(text), i = 0; size_t cursor = 0; while (i < text_bytes) { const size_t sz = SDL_utf8strlcpy(buf, text + i, sizeof(buf)); const size_t chars = SDL_utf8strlen(buf); SDL_SendEditingText(buf, cursor, chars); i += sz; cursor += chars; } } SDL_Fcitx_UpdateTextRect(NULL); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static void FcitxClientICCallMethod(FcitxClient *client, const char *method) { SDL_DBus_CallVoidMethod(client->servicename, client->icname, FCITX_IC_DBUS_INTERFACE, method, DBUS_TYPE_INVALID); } static void SDLCALL Fcitx_SetCapabilities(void *data, const char *name, const char *old_val, const char *internal_editing) { FcitxClient *client = (FcitxClient *)data; Uint32 caps = CAPACITY_NONE; if (!(internal_editing && *internal_editing == '1')) { caps |= CAPACITY_PREEDIT; } SDL_DBus_CallVoidMethod(client->servicename, client->icname, FCITX_IC_DBUS_INTERFACE, "SetCapacity", DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID); } static SDL_bool FcitxClientCreateIC(FcitxClient *client) { char *appname = GetAppName(); pid_t pid = getpid(); int id = -1; Uint32 enable, arg1, arg2, arg3, arg4; if (!SDL_DBus_CallMethod(client->servicename, FCITX_IM_DBUS_PATH, FCITX_IM_DBUS_INTERFACE, "CreateICv3", DBUS_TYPE_STRING, &appname, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID, DBUS_TYPE_INT32, &id, DBUS_TYPE_BOOLEAN, &enable, DBUS_TYPE_UINT32, &arg1, DBUS_TYPE_UINT32, &arg2, DBUS_TYPE_UINT32, &arg3, DBUS_TYPE_UINT32, &arg4, DBUS_TYPE_INVALID)) { id = -1; /* just in case. */ } SDL_free(appname); if (id >= 0) { SDL_DBusContext *dbus = client->dbus; client->id = id; SDL_snprintf(client->icname, IC_NAME_MAX, FCITX_IC_DBUS_PATH, client->id); dbus->bus_add_match(dbus->session_conn, "type='signal', interface='org.fcitx.Fcitx.InputContext'", NULL); dbus->connection_add_filter(dbus->session_conn, &DBus_MessageFilter, dbus, NULL); dbus->connection_flush(dbus->session_conn); SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, Fcitx_SetCapabilities, client); return SDL_TRUE; } return SDL_FALSE; } static Uint32 Fcitx_ModState(void) { Uint32 fcitx_mods = 0; SDL_Keymod sdl_mods = SDL_GetModState(); if (sdl_mods & KMOD_SHIFT) fcitx_mods |= FcitxKeyState_Shift; if (sdl_mods & KMOD_CAPS) fcitx_mods |= FcitxKeyState_CapsLock; if (sdl_mods & KMOD_CTRL) fcitx_mods |= FcitxKeyState_Ctrl; if (sdl_mods & KMOD_ALT) fcitx_mods |= FcitxKeyState_Alt; if (sdl_mods & KMOD_NUM) fcitx_mods |= FcitxKeyState_NumLock; if (sdl_mods & KMOD_LGUI) fcitx_mods |= FcitxKeyState_Super; if (sdl_mods & KMOD_RGUI) fcitx_mods |= FcitxKeyState_Meta; return fcitx_mods; } SDL_bool SDL_Fcitx_Init() { fcitx_client.dbus = SDL_DBus_GetContext(); fcitx_client.cursor_rect.x = -1; fcitx_client.cursor_rect.y = -1; fcitx_client.cursor_rect.w = 0; fcitx_client.cursor_rect.h = 0; SDL_snprintf(fcitx_client.servicename, IC_NAME_MAX, "%s-%d", FCITX_DBUS_SERVICE, GetDisplayNumber()); return FcitxClientCreateIC(&fcitx_client); } void SDL_Fcitx_Quit() { FcitxClientICCallMethod(&fcitx_client, "DestroyIC"); } void SDL_Fcitx_SetFocus(SDL_bool focused) { if (focused) { FcitxClientICCallMethod(&fcitx_client, "FocusIn"); } else { FcitxClientICCallMethod(&fcitx_client, "FocusOut"); } } void SDL_Fcitx_Reset(void) { FcitxClientICCallMethod(&fcitx_client, "Reset"); FcitxClientICCallMethod(&fcitx_client, "CloseIC"); } SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode) { Uint32 state = Fcitx_ModState(); Uint32 handled = SDL_FALSE; int type = FCITX_PRESS_KEY; Uint32 event_time = 0; if (SDL_DBus_CallMethod(fcitx_client.servicename, fcitx_client.icname, FCITX_IC_DBUS_INTERFACE, "ProcessKeyEvent", DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &state, DBUS_TYPE_INT32, &type, DBUS_TYPE_UINT32, &event_time, DBUS_TYPE_INVALID, DBUS_TYPE_INT32, &handled, DBUS_TYPE_INVALID)) { if (handled) { SDL_Fcitx_UpdateTextRect(NULL); return SDL_TRUE; } } return SDL_FALSE; } void SDL_Fcitx_UpdateTextRect(SDL_Rect *rect) { SDL_Window *focused_win = NULL; SDL_SysWMinfo info; int x = 0, y = 0; SDL_Rect *cursor = &fcitx_client.cursor_rect; if (rect) { SDL_memcpy(cursor, rect, sizeof(SDL_Rect)); } focused_win = SDL_GetKeyboardFocus(); if (!focused_win) { return ; } SDL_VERSION(&info.version); if (!SDL_GetWindowWMInfo(focused_win, &info)) { return; } SDL_GetWindowPosition(focused_win, &x, &y); #if SDL_VIDEO_DRIVER_X11 if (info.subsystem == SDL_SYSWM_X11) { SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; Display *x_disp = info.info.x11.display; Window x_win = info.info.x11.window; int x_screen = displaydata->screen; Window unused; X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); } #endif if (cursor->x == -1 && cursor->y == -1 && cursor->w == 0 && cursor->h == 0) { /* move to bottom left */ int w = 0, h = 0; SDL_GetWindowSize(focused_win, &w, &h); cursor->x = 0; cursor->y = h; } x += cursor->x; y += cursor->y; SDL_DBus_CallVoidMethod(fcitx_client.servicename, fcitx_client.icname, FCITX_IC_DBUS_INTERFACE, "SetCursorRect", DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &cursor->w, DBUS_TYPE_INT32, &cursor->h, DBUS_TYPE_INVALID); } void SDL_Fcitx_PumpEvents(void) { SDL_DBusContext *dbus = fcitx_client.dbus; DBusConnection *conn = dbus->session_conn; dbus->connection_read_write(conn, 0); while (dbus->connection_dispatch(conn) == DBUS_DISPATCH_DATA_REMAINS) { /* Do nothing, actual work happens in DBus_MessageFilter */ usleep(10); } } #endif /* HAVE_FCITX_FRONTEND_H */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_fcitx.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_fcitx_h_ #define SDL_fcitx_h_ #include "../../SDL_internal.h" #include "SDL_stdinc.h" #include "SDL_rect.h" extern SDL_bool SDL_Fcitx_Init(void); extern void SDL_Fcitx_Quit(void); extern void SDL_Fcitx_SetFocus(SDL_bool focused); extern void SDL_Fcitx_Reset(void); extern SDL_bool SDL_Fcitx_ProcessKeyEvent(Uint32 keysym, Uint32 keycode); extern void SDL_Fcitx_UpdateTextRect(SDL_Rect *rect); extern void SDL_Fcitx_PumpEvents(void); #endif /* SDL_fcitx_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_ibus.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef HAVE_IBUS_IBUS_H #include "SDL.h" #include "SDL_syswm.h" #include "SDL_ibus.h" #include "SDL_dbus.h" #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" #if SDL_VIDEO_DRIVER_X11 #include "../../video/x11/SDL_x11video.h" #endif #include <sys/inotify.h> #include <unistd.h> #include <fcntl.h> static const char IBUS_SERVICE[] = "org.freedesktop.IBus"; static const char IBUS_PATH[] = "/org/freedesktop/IBus"; static const char IBUS_INTERFACE[] = "org.freedesktop.IBus"; static const char IBUS_INPUT_INTERFACE[] = "org.freedesktop.IBus.InputContext"; static char *input_ctx_path = NULL; static SDL_Rect ibus_cursor_rect = { 0, 0, 0, 0 }; static DBusConnection *ibus_conn = NULL; static char *ibus_addr_file = NULL; static int inotify_fd = -1, inotify_wd = -1; static Uint32 IBus_ModState(void) { Uint32 ibus_mods = 0; SDL_Keymod sdl_mods = SDL_GetModState(); /* Not sure about MOD3, MOD4 and HYPER mappings */ if (sdl_mods & KMOD_LSHIFT) ibus_mods |= IBUS_SHIFT_MASK; if (sdl_mods & KMOD_CAPS) ibus_mods |= IBUS_LOCK_MASK; if (sdl_mods & KMOD_LCTRL) ibus_mods |= IBUS_CONTROL_MASK; if (sdl_mods & KMOD_LALT) ibus_mods |= IBUS_MOD1_MASK; if (sdl_mods & KMOD_NUM) ibus_mods |= IBUS_MOD2_MASK; if (sdl_mods & KMOD_MODE) ibus_mods |= IBUS_MOD5_MASK; if (sdl_mods & KMOD_LGUI) ibus_mods |= IBUS_SUPER_MASK; if (sdl_mods & KMOD_RGUI) ibus_mods |= IBUS_META_MASK; return ibus_mods; } static const char * IBus_GetVariantText(DBusConnection *conn, DBusMessageIter *iter, SDL_DBusContext *dbus) { /* The text we need is nested weirdly, use dbus-monitor to see the structure better */ const char *text = NULL; const char *struct_id = NULL; DBusMessageIter sub1, sub2; if (dbus->message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT) { return NULL; } dbus->message_iter_recurse(iter, &sub1); if (dbus->message_iter_get_arg_type(&sub1) != DBUS_TYPE_STRUCT) { return NULL; } dbus->message_iter_recurse(&sub1, &sub2); if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_STRING) { return NULL; } dbus->message_iter_get_basic(&sub2, &struct_id); if (!struct_id || SDL_strncmp(struct_id, "IBusText", sizeof("IBusText")) != 0) { return NULL; } dbus->message_iter_next(&sub2); dbus->message_iter_next(&sub2); if (dbus->message_iter_get_arg_type(&sub2) != DBUS_TYPE_STRING) { return NULL; } dbus->message_iter_get_basic(&sub2, &text); return text; } static DBusHandlerResult IBus_MessageHandler(DBusConnection *conn, DBusMessage *msg, void *user_data) { SDL_DBusContext *dbus = (SDL_DBusContext *)user_data; if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "CommitText")) { DBusMessageIter iter; const char *text; dbus->message_iter_init(msg, &iter); text = IBus_GetVariantText(conn, &iter, dbus); if (text && *text) { char buf[SDL_TEXTINPUTEVENT_TEXT_SIZE]; size_t text_bytes = SDL_strlen(text), i = 0; while (i < text_bytes) { size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); SDL_SendKeyboardText(buf); i += sz; } } return DBUS_HANDLER_RESULT_HANDLED; } if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "UpdatePreeditText")) { DBusMessageIter iter; const char *text; dbus->message_iter_init(msg, &iter); text = IBus_GetVariantText(conn, &iter, dbus); if (text) { char buf[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; size_t text_bytes = SDL_strlen(text), i = 0; size_t cursor = 0; do { const size_t sz = SDL_utf8strlcpy(buf, text+i, sizeof(buf)); const size_t chars = SDL_utf8strlen(buf); SDL_SendEditingText(buf, cursor, chars); i += sz; cursor += chars; } while (i < text_bytes); } SDL_IBus_UpdateTextRect(NULL); return DBUS_HANDLER_RESULT_HANDLED; } if (dbus->message_is_signal(msg, IBUS_INPUT_INTERFACE, "HidePreeditText")) { SDL_SendEditingText("", 0, 0); return DBUS_HANDLER_RESULT_HANDLED; } return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } static char * IBus_ReadAddressFromFile(const char *file_path) { char addr_buf[1024]; SDL_bool success = SDL_FALSE; FILE *addr_file; addr_file = fopen(file_path, "r"); if (!addr_file) { return NULL; } while (fgets(addr_buf, sizeof(addr_buf), addr_file)) { if (SDL_strncmp(addr_buf, "IBUS_ADDRESS=", sizeof("IBUS_ADDRESS=")-1) == 0) { size_t sz = SDL_strlen(addr_buf); if (addr_buf[sz-1] == '\n') addr_buf[sz-1] = 0; if (addr_buf[sz-2] == '\r') addr_buf[sz-2] = 0; success = SDL_TRUE; break; } } fclose(addr_file); if (success) { return SDL_strdup(addr_buf + (sizeof("IBUS_ADDRESS=") - 1)); } else { return NULL; } } static char * IBus_GetDBusAddressFilename(void) { SDL_DBusContext *dbus; const char *disp_env; char config_dir[PATH_MAX]; char *display = NULL; const char *addr; const char *conf_env; char *key; char file_path[PATH_MAX]; const char *host; char *disp_num, *screen_num; if (ibus_addr_file) { return SDL_strdup(ibus_addr_file); } dbus = SDL_DBus_GetContext(); if (!dbus) { return NULL; } /* Use this environment variable if it exists. */ addr = SDL_getenv("IBUS_ADDRESS"); if (addr && *addr) { return SDL_strdup(addr); } /* Otherwise, we have to get the hostname, display, machine id, config dir and look up the address from a filepath using all those bits, eek. */ disp_env = SDL_getenv("DISPLAY"); if (!disp_env || !*disp_env) { display = SDL_strdup(":0.0"); } else { display = SDL_strdup(disp_env); } host = display; disp_num = SDL_strrchr(display, ':'); screen_num = SDL_strrchr(display, '.'); if (!disp_num) { SDL_free(display); return NULL; } *disp_num = 0; disp_num++; if (screen_num) { *screen_num = 0; } if (!*host) { host = "unix"; } SDL_memset(config_dir, 0, sizeof(config_dir)); conf_env = SDL_getenv("XDG_CONFIG_HOME"); if (conf_env && *conf_env) { SDL_strlcpy(config_dir, conf_env, sizeof(config_dir)); } else { const char *home_env = SDL_getenv("HOME"); if (!home_env || !*home_env) { SDL_free(display); return NULL; } SDL_snprintf(config_dir, sizeof(config_dir), "%s/.config", home_env); } key = dbus->get_local_machine_id(); SDL_memset(file_path, 0, sizeof(file_path)); SDL_snprintf(file_path, sizeof(file_path), "%s/ibus/bus/%s-%s-%s", config_dir, key, host, disp_num); dbus->free(key); SDL_free(display); return SDL_strdup(file_path); } static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus); static void SDLCALL IBus_SetCapabilities(void *data, const char *name, const char *old_val, const char *internal_editing) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (IBus_CheckConnection(dbus)) { Uint32 caps = IBUS_CAP_FOCUS; if (!(internal_editing && *internal_editing == '1')) { caps |= IBUS_CAP_PREEDIT_TEXT; } SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, "SetCapabilities", DBUS_TYPE_UINT32, &caps, DBUS_TYPE_INVALID); } } static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char* addr) { const char *client_name = "SDL2_Application"; const char *path = NULL; SDL_bool result = SDL_FALSE; DBusObjectPathVTable ibus_vtable; SDL_zero(ibus_vtable); ibus_vtable.message_function = &IBus_MessageHandler; ibus_conn = dbus->connection_open_private(addr, NULL); if (!ibus_conn) { return SDL_FALSE; } dbus->connection_flush(ibus_conn); if (!dbus->bus_register(ibus_conn, NULL)) { ibus_conn = NULL; return SDL_FALSE; } dbus->connection_flush(ibus_conn); if (SDL_DBus_CallMethodOnConnection(ibus_conn, IBUS_SERVICE, IBUS_PATH, IBUS_INTERFACE, "CreateInputContext", DBUS_TYPE_STRING, &client_name, DBUS_TYPE_INVALID, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) { SDL_free(input_ctx_path); input_ctx_path = SDL_strdup(path); SDL_AddHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL); dbus->bus_add_match(ibus_conn, "type='signal',interface='org.freedesktop.IBus.InputContext'", NULL); dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL); dbus->connection_flush(ibus_conn); result = SDL_TRUE; } SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL); SDL_IBus_UpdateTextRect(NULL); return result; } static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) { if (!dbus) return SDL_FALSE; if (ibus_conn && dbus->connection_get_is_connected(ibus_conn)) { return SDL_TRUE; } if (inotify_fd > 0 && inotify_wd > 0) { char buf[1024]; ssize_t readsize = read(inotify_fd, buf, sizeof(buf)); if (readsize > 0) { char *p; SDL_bool file_updated = SDL_FALSE; for (p = buf; p < buf + readsize; /**/) { struct inotify_event *event = (struct inotify_event*) p; if (event->len > 0) { char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/'); if (!addr_file_no_path) return SDL_FALSE; if (SDL_strcmp(addr_file_no_path + 1, event->name) == 0) { file_updated = SDL_TRUE; break; } } p += sizeof(struct inotify_event) + event->len; } if (file_updated) { char *addr = IBus_ReadAddressFromFile(ibus_addr_file); if (addr) { SDL_bool result = IBus_SetupConnection(dbus, addr); SDL_free(addr); return result; } } } } return SDL_FALSE; } SDL_bool SDL_IBus_Init(void) { SDL_bool result = SDL_FALSE; SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (dbus) { char *addr_file = IBus_GetDBusAddressFilename(); char *addr; char *addr_file_dir; if (!addr_file) { return SDL_FALSE; } /* !!! FIXME: if ibus_addr_file != NULL, this will overwrite it and leak (twice!) */ ibus_addr_file = SDL_strdup(addr_file); addr = IBus_ReadAddressFromFile(addr_file); if (!addr) { SDL_free(addr_file); return SDL_FALSE; } if (inotify_fd < 0) { inotify_fd = inotify_init(); fcntl(inotify_fd, F_SETFL, O_NONBLOCK); } addr_file_dir = SDL_strrchr(addr_file, '/'); if (addr_file_dir) { *addr_file_dir = 0; } inotify_wd = inotify_add_watch(inotify_fd, addr_file, IN_CREATE | IN_MODIFY); SDL_free(addr_file); if (addr) { result = IBus_SetupConnection(dbus, addr); SDL_free(addr); } } return result; } void SDL_IBus_Quit(void) { SDL_DBusContext *dbus; if (input_ctx_path) { SDL_free(input_ctx_path); input_ctx_path = NULL; } if (ibus_addr_file) { SDL_free(ibus_addr_file); ibus_addr_file = NULL; } dbus = SDL_DBus_GetContext(); if (dbus && ibus_conn) { dbus->connection_close(ibus_conn); dbus->connection_unref(ibus_conn); } if (inotify_fd > 0 && inotify_wd > 0) { inotify_rm_watch(inotify_fd, inotify_wd); inotify_wd = -1; } SDL_DelHintCallback(SDL_HINT_IME_INTERNAL_EDITING, IBus_SetCapabilities, NULL); SDL_memset(&ibus_cursor_rect, 0, sizeof(ibus_cursor_rect)); } static void IBus_SimpleMessage(const char *method) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (IBus_CheckConnection(dbus)) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, method, DBUS_TYPE_INVALID); } } void SDL_IBus_SetFocus(SDL_bool focused) { const char *method = focused ? "FocusIn" : "FocusOut"; IBus_SimpleMessage(method); } void SDL_IBus_Reset(void) { IBus_SimpleMessage("Reset"); } SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode) { Uint32 result = 0; SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (IBus_CheckConnection(dbus)) { Uint32 mods = IBus_ModState(); if (!SDL_DBus_CallMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, "ProcessKeyEvent", DBUS_TYPE_UINT32, &keysym, DBUS_TYPE_UINT32, &keycode, DBUS_TYPE_UINT32, &mods, DBUS_TYPE_INVALID, DBUS_TYPE_BOOLEAN, &result, DBUS_TYPE_INVALID)) { result = 0; } } SDL_IBus_UpdateTextRect(NULL); return result ? SDL_TRUE : SDL_FALSE; } void SDL_IBus_UpdateTextRect(SDL_Rect *rect) { SDL_Window *focused_win; SDL_SysWMinfo info; int x = 0, y = 0; SDL_DBusContext *dbus; if (rect) { SDL_memcpy(&ibus_cursor_rect, rect, sizeof(ibus_cursor_rect)); } focused_win = SDL_GetKeyboardFocus(); if (!focused_win) { return; } SDL_VERSION(&info.version); if (!SDL_GetWindowWMInfo(focused_win, &info)) { return; } SDL_GetWindowPosition(focused_win, &x, &y); #if SDL_VIDEO_DRIVER_X11 if (info.subsystem == SDL_SYSWM_X11) { SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; Display *x_disp = info.info.x11.display; Window x_win = info.info.x11.window; int x_screen = displaydata->screen; Window unused; X11_XTranslateCoordinates(x_disp, x_win, RootWindow(x_disp, x_screen), 0, 0, &x, &y, &unused); } #endif x += ibus_cursor_rect.x; y += ibus_cursor_rect.y; dbus = SDL_DBus_GetContext(); if (IBus_CheckConnection(dbus)) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, "SetCursorLocation", DBUS_TYPE_INT32, &x, DBUS_TYPE_INT32, &y, DBUS_TYPE_INT32, &ibus_cursor_rect.w, DBUS_TYPE_INT32, &ibus_cursor_rect.h, DBUS_TYPE_INVALID); } } void SDL_IBus_PumpEvents(void) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); if (IBus_CheckConnection(dbus)) { dbus->connection_read_write(ibus_conn, 0); while (dbus->connection_dispatch(ibus_conn) == DBUS_DISPATCH_DATA_REMAINS) { /* Do nothing, actual work happens in IBus_MessageHandler */ } } } #endif /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_ibus.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_ibus_h_ #define SDL_ibus_h_ #ifdef HAVE_IBUS_IBUS_H #define SDL_USE_IBUS 1 #include "SDL_stdinc.h" #include <ibus-1.0/ibus.h> extern SDL_bool SDL_IBus_Init(void); extern void SDL_IBus_Quit(void); /* Lets the IBus server know about changes in window focus */ extern void SDL_IBus_SetFocus(SDL_bool focused); /* Closes the candidate list and resets any text currently being edited */ extern void SDL_IBus_Reset(void); /* Sends a keypress event to IBus, returns SDL_TRUE if IBus used this event to update its candidate list or change input methods. PumpEvents should be called some time after this, to recieve the TextInput / TextEditing event back. */ extern SDL_bool SDL_IBus_ProcessKeyEvent(Uint32 keysym, Uint32 keycode); /* Update the position of IBus' candidate list. If rect is NULL then this will just reposition it relative to the focused window's new position. */ extern void SDL_IBus_UpdateTextRect(SDL_Rect *window_relative_rect); /* Checks DBus for new IBus events, and calls SDL_SendKeyboardText / SDL_SendEditingText for each event it finds */ extern void SDL_IBus_PumpEvents(void); #endif /* HAVE_IBUS_IBUS_H */ #endif /* SDL_ibus_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_ime.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_ime.h" #include "SDL_ibus.h" #include "SDL_fcitx.h" typedef SDL_bool (*_SDL_IME_Init)(); typedef void (*_SDL_IME_Quit)(); typedef void (*_SDL_IME_SetFocus)(SDL_bool); typedef void (*_SDL_IME_Reset)(); typedef SDL_bool (*_SDL_IME_ProcessKeyEvent)(Uint32, Uint32); typedef void (*_SDL_IME_UpdateTextRect)(SDL_Rect *); typedef void (*_SDL_IME_PumpEvents)(); static _SDL_IME_Init SDL_IME_Init_Real = NULL; static _SDL_IME_Quit SDL_IME_Quit_Real = NULL; static _SDL_IME_SetFocus SDL_IME_SetFocus_Real = NULL; static _SDL_IME_Reset SDL_IME_Reset_Real = NULL; static _SDL_IME_ProcessKeyEvent SDL_IME_ProcessKeyEvent_Real = NULL; static _SDL_IME_UpdateTextRect SDL_IME_UpdateTextRect_Real = NULL; static _SDL_IME_PumpEvents SDL_IME_PumpEvents_Real = NULL; static void InitIME() { static SDL_bool inited = SDL_FALSE; #ifdef HAVE_FCITX_FRONTEND_H const char *im_module = SDL_getenv("SDL_IM_MODULE"); const char *xmodifiers = SDL_getenv("XMODIFIERS"); #endif if (inited == SDL_TRUE) return; inited = SDL_TRUE; /* See if fcitx IME support is being requested */ #ifdef HAVE_FCITX_FRONTEND_H if (!SDL_IME_Init_Real && ((im_module && SDL_strcmp(im_module, "fcitx") == 0) || (!im_module && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) { SDL_IME_Init_Real = SDL_Fcitx_Init; SDL_IME_Quit_Real = SDL_Fcitx_Quit; SDL_IME_SetFocus_Real = SDL_Fcitx_SetFocus; SDL_IME_Reset_Real = SDL_Fcitx_Reset; SDL_IME_ProcessKeyEvent_Real = SDL_Fcitx_ProcessKeyEvent; SDL_IME_UpdateTextRect_Real = SDL_Fcitx_UpdateTextRect; SDL_IME_PumpEvents_Real = SDL_Fcitx_PumpEvents; } #endif /* HAVE_FCITX_FRONTEND_H */ /* default to IBus */ #ifdef HAVE_IBUS_IBUS_H if (!SDL_IME_Init_Real) { SDL_IME_Init_Real = SDL_IBus_Init; SDL_IME_Quit_Real = SDL_IBus_Quit; SDL_IME_SetFocus_Real = SDL_IBus_SetFocus; SDL_IME_Reset_Real = SDL_IBus_Reset; SDL_IME_ProcessKeyEvent_Real = SDL_IBus_ProcessKeyEvent; SDL_IME_UpdateTextRect_Real = SDL_IBus_UpdateTextRect; SDL_IME_PumpEvents_Real = SDL_IBus_PumpEvents; } #endif /* HAVE_IBUS_IBUS_H */ } SDL_bool SDL_IME_Init(void) { InitIME(); if (SDL_IME_Init_Real) { if (SDL_IME_Init_Real()) { return SDL_TRUE; } /* uhoh, the IME implementation's init failed! Disable IME support. */ SDL_IME_Init_Real = NULL; SDL_IME_Quit_Real = NULL; SDL_IME_SetFocus_Real = NULL; SDL_IME_Reset_Real = NULL; SDL_IME_ProcessKeyEvent_Real = NULL; SDL_IME_UpdateTextRect_Real = NULL; SDL_IME_PumpEvents_Real = NULL; } return SDL_FALSE; } void SDL_IME_Quit(void) { if (SDL_IME_Quit_Real) SDL_IME_Quit_Real(); } void SDL_IME_SetFocus(SDL_bool focused) { if (SDL_IME_SetFocus_Real) SDL_IME_SetFocus_Real(focused); } void SDL_IME_Reset(void) { if (SDL_IME_Reset_Real) SDL_IME_Reset_Real(); } SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode) { if (SDL_IME_ProcessKeyEvent_Real) return SDL_IME_ProcessKeyEvent_Real(keysym, keycode); return SDL_FALSE; } void SDL_IME_UpdateTextRect(SDL_Rect *rect) { if (SDL_IME_UpdateTextRect_Real) SDL_IME_UpdateTextRect_Real(rect); } void SDL_IME_PumpEvents() { if (SDL_IME_PumpEvents_Real) SDL_IME_PumpEvents_Real(); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_ime.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_ime_h_ #define SDL_ime_h_ #include "../../SDL_internal.h" #include "SDL_stdinc.h" #include "SDL_rect.h" extern SDL_bool SDL_IME_Init(void); extern void SDL_IME_Quit(void); extern void SDL_IME_SetFocus(SDL_bool focused); extern void SDL_IME_Reset(void); extern SDL_bool SDL_IME_ProcessKeyEvent(Uint32 keysym, Uint32 keycode); extern void SDL_IME_UpdateTextRect(SDL_Rect *rect); extern void SDL_IME_PumpEvents(void); #endif /* SDL_ime_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_udev.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * To list the properties of a device, try something like: * udevadm info -a -n snd/hwC0D0 (for a sound card) * udevadm info --query=all -n input/event3 (for a keyboard, mouse, etc) * udevadm info --query=property -n input/event2 */ #include "SDL_udev.h" #ifdef SDL_USE_LIBUDEV #include <linux/input.h> #include "SDL_assert.h" #include "SDL_loadso.h" #include "SDL_timer.h" #include "../unix/SDL_poll.h" static const char *SDL_UDEV_LIBS[] = { "libudev.so.1", "libudev.so.0" }; #define _THIS SDL_UDEV_PrivateData *_this static _THIS = NULL; static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr); static int SDL_UDEV_load_syms(void); static SDL_bool SDL_UDEV_hotplug_update_available(void); static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); if (*addr == NULL) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return SDL_FALSE; } return SDL_TRUE; } static int SDL_UDEV_load_syms(void) { /* cast funcs to char* first, to please GCC's strict aliasing rules. */ #define SDL_UDEV_SYM(x) \ if (!SDL_UDEV_load_sym(#x, (void **) (char *) & _this->syms.x)) return -1 SDL_UDEV_SYM(udev_device_get_action); SDL_UDEV_SYM(udev_device_get_devnode); SDL_UDEV_SYM(udev_device_get_subsystem); SDL_UDEV_SYM(udev_device_get_parent_with_subsystem_devtype); SDL_UDEV_SYM(udev_device_get_property_value); SDL_UDEV_SYM(udev_device_get_sysattr_value); SDL_UDEV_SYM(udev_device_new_from_syspath); SDL_UDEV_SYM(udev_device_unref); SDL_UDEV_SYM(udev_enumerate_add_match_property); SDL_UDEV_SYM(udev_enumerate_add_match_subsystem); SDL_UDEV_SYM(udev_enumerate_get_list_entry); SDL_UDEV_SYM(udev_enumerate_new); SDL_UDEV_SYM(udev_enumerate_scan_devices); SDL_UDEV_SYM(udev_enumerate_unref); SDL_UDEV_SYM(udev_list_entry_get_name); SDL_UDEV_SYM(udev_list_entry_get_next); SDL_UDEV_SYM(udev_monitor_enable_receiving); SDL_UDEV_SYM(udev_monitor_filter_add_match_subsystem_devtype); SDL_UDEV_SYM(udev_monitor_get_fd); SDL_UDEV_SYM(udev_monitor_new_from_netlink); SDL_UDEV_SYM(udev_monitor_receive_device); SDL_UDEV_SYM(udev_monitor_unref); SDL_UDEV_SYM(udev_new); SDL_UDEV_SYM(udev_unref); SDL_UDEV_SYM(udev_device_new_from_devnum); SDL_UDEV_SYM(udev_device_get_devnum); #undef SDL_UDEV_SYM return 0; } static SDL_bool SDL_UDEV_hotplug_update_available(void) { if (_this->udev_mon != NULL) { const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); if (SDL_IOReady(fd, SDL_FALSE, 0)) { return SDL_TRUE; } } return SDL_FALSE; } int SDL_UDEV_Init(void) { int retval = 0; if (_this == NULL) { _this = (SDL_UDEV_PrivateData *) SDL_calloc(1, sizeof(*_this)); if(_this == NULL) { return SDL_OutOfMemory(); } retval = SDL_UDEV_LoadLibrary(); if (retval < 0) { SDL_UDEV_Quit(); return retval; } /* Set up udev monitoring * Listen for input devices (mouse, keyboard, joystick, etc) and sound devices */ _this->udev = _this->syms.udev_new(); if (_this->udev == NULL) { SDL_UDEV_Quit(); return SDL_SetError("udev_new() failed"); } _this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev"); if (_this->udev_mon == NULL) { SDL_UDEV_Quit(); return SDL_SetError("udev_monitor_new_from_netlink() failed"); } _this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "input", NULL); _this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL); _this->syms.udev_monitor_enable_receiving(_this->udev_mon); /* Do an initial scan of existing devices */ SDL_UDEV_Scan(); } _this->ref_count += 1; return retval; } void SDL_UDEV_Quit(void) { SDL_UDEV_CallbackList *item; if (_this == NULL) { return; } _this->ref_count -= 1; if (_this->ref_count < 1) { if (_this->udev_mon != NULL) { _this->syms.udev_monitor_unref(_this->udev_mon); _this->udev_mon = NULL; } if (_this->udev != NULL) { _this->syms.udev_unref(_this->udev); _this->udev = NULL; } /* Remove existing devices */ while (_this->first != NULL) { item = _this->first; _this->first = _this->first->next; SDL_free(item); } SDL_UDEV_UnloadLibrary(); SDL_free(_this); _this = NULL; } } void SDL_UDEV_Scan(void) { struct udev_enumerate *enumerate = NULL; struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; if (_this == NULL) { return; } enumerate = _this->syms.udev_enumerate_new(_this->udev); if (enumerate == NULL) { SDL_UDEV_Quit(); SDL_SetError("udev_enumerate_new() failed"); return; } _this->syms.udev_enumerate_add_match_subsystem(enumerate, "input"); _this->syms.udev_enumerate_add_match_subsystem(enumerate, "sound"); _this->syms.udev_enumerate_scan_devices(enumerate); devs = _this->syms.udev_enumerate_get_list_entry(enumerate); for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); if (dev != NULL) { device_event(SDL_UDEV_DEVICEADDED, dev); _this->syms.udev_device_unref(dev); } } _this->syms.udev_enumerate_unref(enumerate); } void SDL_UDEV_UnloadLibrary(void) { if (_this == NULL) { return; } if (_this->udev_handle != NULL) { SDL_UnloadObject(_this->udev_handle); _this->udev_handle = NULL; } } int SDL_UDEV_LoadLibrary(void) { int retval = 0, i; if (_this == NULL) { return SDL_SetError("UDEV not initialized"); } /* See if there is a udev library already loaded */ if (SDL_UDEV_load_syms() == 0) { return 0; } #ifdef SDL_UDEV_DYNAMIC /* Check for the build environment's libudev first */ if (_this->udev_handle == NULL) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC); if (_this->udev_handle != NULL) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); } } } #endif if (_this->udev_handle == NULL) { for( i = 0 ; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); if (_this->udev_handle != NULL) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); } else { break; } } } if (_this->udev_handle == NULL) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } } return retval; } #define BITS_PER_LONG (sizeof(unsigned long) * 8) #define NBITS(x) ((((x)-1)/BITS_PER_LONG)+1) #define OFF(x) ((x)%BITS_PER_LONG) #define LONG(x) ((x)/BITS_PER_LONG) #define test_bit(bit, array) ((array[LONG(bit)] >> OFF(bit)) & 1) static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len) { const char *value; char text[4096]; char *word; int i; unsigned long v; SDL_memset(bitmask, 0, bitmask_len*sizeof(*bitmask)); value = _this->syms.udev_device_get_sysattr_value(pdev, attr); if (!value) { return; } SDL_strlcpy(text, value, sizeof(text)); i = 0; while ((word = SDL_strrchr(text, ' ')) != NULL) { v = SDL_strtoul(word+1, NULL, 16); if (i < bitmask_len) { bitmask[i] = v; } ++i; *word = '\0'; } v = SDL_strtoul(text, NULL, 16); if (i < bitmask_len) { bitmask[i] = v; } } static int guess_device_class(struct udev_device *dev) { int devclass = 0; struct udev_device *pdev; unsigned long bitmask_ev[NBITS(EV_MAX)]; unsigned long bitmask_abs[NBITS(ABS_MAX)]; unsigned long bitmask_key[NBITS(KEY_MAX)]; unsigned long bitmask_rel[NBITS(REL_MAX)]; unsigned long keyboard_mask; /* walk up the parental chain until we find the real input device; the * argument is very likely a subdevice of this, like eventN */ pdev = dev; while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) { pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL); } if (!pdev) { return 0; } get_caps(dev, pdev, "capabilities/ev", bitmask_ev, SDL_arraysize(bitmask_ev)); get_caps(dev, pdev, "capabilities/abs", bitmask_abs, SDL_arraysize(bitmask_abs)); get_caps(dev, pdev, "capabilities/rel", bitmask_rel, SDL_arraysize(bitmask_rel)); get_caps(dev, pdev, "capabilities/key", bitmask_key, SDL_arraysize(bitmask_key)); if (test_bit(EV_ABS, bitmask_ev) && test_bit(ABS_X, bitmask_abs) && test_bit(ABS_Y, bitmask_abs)) { if (test_bit(BTN_STYLUS, bitmask_key) || test_bit(BTN_TOOL_PEN, bitmask_key)) { ; /* ID_INPUT_TABLET */ } else if (test_bit(BTN_TOOL_FINGER, bitmask_key) && !test_bit(BTN_TOOL_PEN, bitmask_key)) { ; /* ID_INPUT_TOUCHPAD */ } else if (test_bit(BTN_MOUSE, bitmask_key)) { devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */ } else if (test_bit(BTN_TOUCH, bitmask_key)) { /* TODO: better determining between touchscreen and multitouch touchpad, see https://github.com/systemd/systemd/blob/master/src/udev/udev-builtin-input_id.c */ devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; /* ID_INPUT_TOUCHSCREEN */ } if (test_bit(BTN_TRIGGER, bitmask_key) || test_bit(BTN_A, bitmask_key) || test_bit(BTN_1, bitmask_key) || test_bit(ABS_RX, bitmask_abs) || test_bit(ABS_RY, bitmask_abs) || test_bit(ABS_RZ, bitmask_abs) || test_bit(ABS_THROTTLE, bitmask_abs) || test_bit(ABS_RUDDER, bitmask_abs) || test_bit(ABS_WHEEL, bitmask_abs) || test_bit(ABS_GAS, bitmask_abs) || test_bit(ABS_BRAKE, bitmask_abs)) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; /* ID_INPUT_JOYSTICK */ } } if (test_bit(EV_REL, bitmask_ev) && test_bit(REL_X, bitmask_rel) && test_bit(REL_Y, bitmask_rel) && test_bit(BTN_MOUSE, bitmask_key)) { devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */ } /* the first 32 bits are ESC, numbers, and Q to D; if we have any of * those, consider it a keyboard device; do not test KEY_RESERVED, though */ keyboard_mask = 0xFFFFFFFE; if ((bitmask_key[0] & keyboard_mask) != 0) devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEYBOARD */ return devclass; } static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) { const char *subsystem; const char *val = NULL; int devclass = 0; const char *path; SDL_UDEV_CallbackList *item; path = _this->syms.udev_device_get_devnode(dev); if (path == NULL) { return; } subsystem = _this->syms.udev_device_get_subsystem(dev); if (SDL_strcmp(subsystem, "sound") == 0) { devclass = SDL_UDEV_DEVICE_SOUND; } else if (SDL_strcmp(subsystem, "input") == 0) { /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); if (val != NULL && SDL_strcmp(val, "1") == 0 ) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); if (val != NULL && SDL_strcmp(val, "1") == 0 ) { devclass |= SDL_UDEV_DEVICE_MOUSE; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"); if (val != NULL && SDL_strcmp(val, "1") == 0 ) { devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; } /* The undocumented rule is: - All devices with keys get ID_INPUT_KEY - From this subset, if they have ESC, numbers, and Q to D, it also gets ID_INPUT_KEYBOARD Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183 */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY"); if (val != NULL && SDL_strcmp(val, "1") == 0 ) { devclass |= SDL_UDEV_DEVICE_KEYBOARD; } if (devclass == 0) { /* Fall back to old style input classes */ val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS"); if (val != NULL) { if (SDL_strcmp(val, "joystick") == 0) { devclass = SDL_UDEV_DEVICE_JOYSTICK; } else if (SDL_strcmp(val, "mouse") == 0) { devclass = SDL_UDEV_DEVICE_MOUSE; } else if (SDL_strcmp(val, "kbd") == 0) { devclass = SDL_UDEV_DEVICE_KEYBOARD; } else { return; } } else { /* We could be linked with libudev on a system that doesn't have udev running */ devclass = guess_device_class(dev); } } } else { return; } /* Process callbacks */ for (item = _this->first; item != NULL; item = item->next) { item->callback(type, devclass, path); } } void SDL_UDEV_Poll(void) { struct udev_device *dev = NULL; const char *action = NULL; if (_this == NULL) { return; } while (SDL_UDEV_hotplug_update_available()) { dev = _this->syms.udev_monitor_receive_device(_this->udev_mon); if (dev == NULL) { break; } action = _this->syms.udev_device_get_action(dev); if (SDL_strcmp(action, "add") == 0) { /* Wait for the device to finish initialization */ SDL_Delay(100); device_event(SDL_UDEV_DEVICEADDED, dev); } else if (SDL_strcmp(action, "remove") == 0) { device_event(SDL_UDEV_DEVICEREMOVED, dev); } _this->syms.udev_device_unref(dev); } } int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; item = (SDL_UDEV_CallbackList *) SDL_calloc(1, sizeof (SDL_UDEV_CallbackList)); if (item == NULL) { return SDL_OutOfMemory(); } item->callback = cb; if (_this->last == NULL) { _this->first = _this->last = item; } else { _this->last->next = item; _this->last = item; } return 1; } void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; SDL_UDEV_CallbackList *prev = NULL; for (item = _this->first; item != NULL; item = item->next) { /* found it, remove it. */ if (item->callback == cb) { if (prev != NULL) { prev->next = item->next; } else { SDL_assert(_this->first == item); _this->first = item->next; } if (item == _this->last) { _this->last = prev; } SDL_free(item); return; } prev = item; } } const SDL_UDEV_Symbols * SDL_UDEV_GetUdevSyms(void) { if (SDL_UDEV_Init() < 0) { SDL_SetError("Could not initialize UDEV"); return NULL; } return &_this->syms; } void SDL_UDEV_ReleaseUdevSyms(void) { SDL_UDEV_Quit(); } #endif /* SDL_USE_LIBUDEV */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\linux\SDL_udev.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_udev_h_ #define SDL_udev_h_ #if HAVE_LIBUDEV_H #ifndef SDL_USE_LIBUDEV #define SDL_USE_LIBUDEV 1 #endif #include "SDL_loadso.h" #include "SDL_events.h" #include <libudev.h> #include <sys/time.h> #include <sys/types.h> /** * \brief Device type */ typedef enum { SDL_UDEV_DEVICEADDED = 1, SDL_UDEV_DEVICEREMOVED } SDL_UDEV_deviceevent; /* A device can be any combination of these classes */ typedef enum { SDL_UDEV_DEVICE_UNKNOWN = 0x0000, SDL_UDEV_DEVICE_MOUSE = 0x0001, SDL_UDEV_DEVICE_KEYBOARD = 0x0002, SDL_UDEV_DEVICE_JOYSTICK = 0x0004, SDL_UDEV_DEVICE_SOUND = 0x0008, SDL_UDEV_DEVICE_TOUCHSCREEN = 0x0010 } SDL_UDEV_deviceclass; typedef void (*SDL_UDEV_Callback)(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); typedef struct SDL_UDEV_CallbackList { SDL_UDEV_Callback callback; struct SDL_UDEV_CallbackList *next; } SDL_UDEV_CallbackList; typedef struct SDL_UDEV_Symbols { const char *(*udev_device_get_action)(struct udev_device *); const char *(*udev_device_get_devnode)(struct udev_device *); const char *(*udev_device_get_subsystem)(struct udev_device *); struct udev_device *(*udev_device_get_parent_with_subsystem_devtype)(struct udev_device *udev_device, const char *subsystem, const char *devtype); const char *(*udev_device_get_property_value)(struct udev_device *, const char *); const char *(*udev_device_get_sysattr_value)(struct udev_device *udev_device, const char *sysattr); struct udev_device *(*udev_device_new_from_syspath)(struct udev *, const char *); void (*udev_device_unref)(struct udev_device *); int (*udev_enumerate_add_match_property)(struct udev_enumerate *, const char *, const char *); int (*udev_enumerate_add_match_subsystem)(struct udev_enumerate *, const char *); struct udev_list_entry *(*udev_enumerate_get_list_entry)(struct udev_enumerate *); struct udev_enumerate *(*udev_enumerate_new)(struct udev *); int (*udev_enumerate_scan_devices)(struct udev_enumerate *); void (*udev_enumerate_unref)(struct udev_enumerate *); const char *(*udev_list_entry_get_name)(struct udev_list_entry *); struct udev_list_entry *(*udev_list_entry_get_next)(struct udev_list_entry *); int (*udev_monitor_enable_receiving)(struct udev_monitor *); int (*udev_monitor_filter_add_match_subsystem_devtype)(struct udev_monitor *, const char *, const char *); int (*udev_monitor_get_fd)(struct udev_monitor *); struct udev_monitor *(*udev_monitor_new_from_netlink)(struct udev *, const char *); struct udev_device *(*udev_monitor_receive_device)(struct udev_monitor *); void (*udev_monitor_unref)(struct udev_monitor *); struct udev *(*udev_new)(void); void (*udev_unref)(struct udev *); struct udev_device * (*udev_device_new_from_devnum)(struct udev *udev, char type, dev_t devnum); dev_t (*udev_device_get_devnum) (struct udev_device *udev_device); } SDL_UDEV_Symbols; typedef struct SDL_UDEV_PrivateData { const char *udev_library; void *udev_handle; struct udev *udev; struct udev_monitor *udev_mon; int ref_count; SDL_UDEV_CallbackList *first, *last; /* Function pointers */ SDL_UDEV_Symbols syms; } SDL_UDEV_PrivateData; extern int SDL_UDEV_Init(void); extern void SDL_UDEV_Quit(void); extern void SDL_UDEV_UnloadLibrary(void); extern int SDL_UDEV_LoadLibrary(void); extern void SDL_UDEV_Poll(void); extern void SDL_UDEV_Scan(void); extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb); extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); extern void SDL_UDEV_ReleaseUdevSyms(void); #endif /* HAVE_LIBUDEV_H */ #endif /* SDL_udev_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\unix\SDL_poll.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_assert.h" #include "SDL_poll.h" #ifdef HAVE_POLL #include <poll.h> #else #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #endif #include <errno.h> int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS) { int result; /* Note: We don't bother to account for elapsed time if we get EINTR */ do { #ifdef HAVE_POLL struct pollfd info; info.fd = fd; if (forWrite) { info.events = POLLOUT; } else { info.events = POLLIN | POLLPRI; } result = poll(&info, 1, timeoutMS); #else fd_set rfdset, *rfdp = NULL; fd_set wfdset, *wfdp = NULL; struct timeval tv, *tvp = NULL; /* If this assert triggers we'll corrupt memory here */ SDL_assert(fd >= 0 && fd < FD_SETSIZE); if (forWrite) { FD_ZERO(&wfdset); FD_SET(fd, &wfdset); wfdp = &wfdset; } else { FD_ZERO(&rfdset); FD_SET(fd, &rfdset); rfdp = &rfdset; } if (timeoutMS >= 0) { tv.tv_sec = timeoutMS / 1000; tv.tv_usec = (timeoutMS % 1000) * 1000; tvp = &tv; } result = select(fd + 1, rfdp, wfdp, NULL, tvp); #endif /* HAVE_POLL */ } while ( result < 0 && errno == EINTR ); return result; } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\unix\SDL_poll.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_poll_h_ #define SDL_poll_h_ #include "SDL_stdinc.h" extern int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS); #endif /* SDL_poll_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\windows\SDL_directx.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_directx_h_ #define SDL_directx_h_ /* Include all of the DirectX 8.0 headers and adds any necessary tweaks */ #include "SDL_windows.h" #include <mmsystem.h> #ifndef WIN32 #define WIN32 #endif #undef WINNT /* Far pointers don't exist in 32-bit code */ #ifndef FAR #define FAR #endif /* Error codes not yet included in Win32 API header files */ #ifndef MAKE_HRESULT #define MAKE_HRESULT(sev,fac,code) \ ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code)))) #endif #ifndef S_OK #define S_OK (HRESULT)0x00000000L #endif #ifndef SUCCEEDED #define SUCCEEDED(x) ((HRESULT)(x) >= 0) #endif #ifndef FAILED #define FAILED(x) ((HRESULT)(x)<0) #endif #ifndef E_FAIL #define E_FAIL (HRESULT)0x80000008L #endif #ifndef E_NOINTERFACE #define E_NOINTERFACE (HRESULT)0x80004002L #endif #ifndef E_OUTOFMEMORY #define E_OUTOFMEMORY (HRESULT)0x8007000EL #endif #ifndef E_INVALIDARG #define E_INVALIDARG (HRESULT)0x80070057L #endif #ifndef E_NOTIMPL #define E_NOTIMPL (HRESULT)0x80004001L #endif #ifndef REGDB_E_CLASSNOTREG #define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L #endif /* Severity codes */ #ifndef SEVERITY_ERROR #define SEVERITY_ERROR 1 #endif /* Error facility codes */ #ifndef FACILITY_WIN32 #define FACILITY_WIN32 7 #endif #ifndef FIELD_OFFSET #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field)) #endif /* DirectX headers (if it isn't included, I haven't tested it yet) */ /* We need these defines to mark what version of DirectX API we use */ #define DIRECTDRAW_VERSION 0x0700 #define DIRECTSOUND_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0800 /* Need version 7 for force feedback. Need version 8 so IDirectInput8_EnumDevices doesn't leak like a sieve... */ #ifdef HAVE_DDRAW_H #include <ddraw.h> #endif #ifdef HAVE_DSOUND_H #include <dsound.h> #endif #ifdef HAVE_DINPUT_H #include <dinput.h> #else typedef struct { int unused; } DIDEVICEINSTANCE; #endif #endif /* SDL_directx_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\windows\SDL_windows.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if defined(__WIN32__) || defined(__WINRT__) #include "SDL_windows.h" #include "SDL_error.h" #include "SDL_assert.h" #include <objbase.h> /* for CoInitialize/CoUninitialize (Win32 only) */ #ifndef _WIN32_WINNT_VISTA #define _WIN32_WINNT_VISTA 0x0600 #endif #ifndef _WIN32_WINNT_WIN7 #define _WIN32_WINNT_WIN7 0x0601 #endif /* Sets an error message based on an HRESULT */ int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr) { TCHAR buffer[1024]; char *message; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0, buffer, SDL_arraysize(buffer), NULL); message = WIN_StringToUTF8(buffer); SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); SDL_free(message); return -1; } /* Sets an error message based on GetLastError() */ int WIN_SetError(const char *prefix) { return WIN_SetErrorFromHRESULT(prefix, GetLastError()); } HRESULT WIN_CoInitialize(void) { /* SDL handles any threading model, so initialize with the default, which is compatible with OLE and if that doesn't work, try multi-threaded mode. If you need multi-threaded mode, call CoInitializeEx() before SDL_Init() */ #ifdef __WINRT__ /* DLudwig: On WinRT, it is assumed that COM was initialized in main(). CoInitializeEx is available (not CoInitialize though), however on WinRT, main() is typically declared with the [MTAThread] attribute, which, AFAIK, should initialize COM. */ return S_OK; #else HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if (hr == RPC_E_CHANGED_MODE) { hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); } /* S_FALSE means success, but someone else already initialized. */ /* You still need to call CoUninitialize in this case! */ if (hr == S_FALSE) { return S_OK; } return hr; #endif } void WIN_CoUninitialize(void) { #ifndef __WINRT__ CoUninitialize(); #endif } #ifndef __WINRT__ static BOOL IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) { OSVERSIONINFOEXW osvi; DWORDLONG const dwlConditionMask = VerSetConditionMask( VerSetConditionMask( VerSetConditionMask( 0, VER_MAJORVERSION, VER_GREATER_EQUAL ), VER_MINORVERSION, VER_GREATER_EQUAL ), VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL ); SDL_zero(osvi); osvi.dwOSVersionInfoSize = sizeof(osvi); osvi.dwMajorVersion = wMajorVersion; osvi.dwMinorVersion = wMinorVersion; osvi.wServicePackMajor = wServicePackMajor; return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; } #endif BOOL WIN_IsWindowsVistaOrGreater(void) { #ifdef __WINRT__ return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_VISTA), LOBYTE(_WIN32_WINNT_VISTA), 0); #endif } BOOL WIN_IsWindows7OrGreater(void) { #ifdef __WINRT__ return TRUE; #else return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN7), LOBYTE(_WIN32_WINNT_WIN7), 0); #endif } /* WAVExxxCAPS gives you 31 bytes for the device name, and just truncates if it's longer. However, since WinXP, you can use the WAVExxxCAPS2 structure, which will give you a name GUID. The full name is in the Windows Registry under that GUID, located here: HKLM\System\CurrentControlSet\Control\MediaCategories Note that drivers can report GUID_NULL for the name GUID, in which case, Windows makes a best effort to fill in those 31 bytes in the usual place. This info summarized from MSDN: http://web.archive.org/web/20131027093034/http://msdn.microsoft.com/en-us/library/windows/hardware/ff536382(v=vs.85).aspx Always look this up in the registry if possible, because the strings are different! At least on Win10, I see "Yeti Stereo Microphone" in the Registry, and a unhelpful "Microphone(Yeti Stereo Microph" in winmm. Sigh. (Also, DirectSound shouldn't be limited to 32 chars, but its device enum has the same problem.) WASAPI doesn't need this. This is just for DirectSound/WinMM. */ char * WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) { #if __WINRT__ return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP, go with what we've got. */ #else static const GUID nullguid = { 0 }; const unsigned char *ptr; char keystr[128]; WCHAR *strw = NULL; SDL_bool rc; HKEY hkey; DWORD len = 0; char *retval = NULL; if (WIN_IsEqualGUID(guid, &nullguid)) { return WIN_StringToUTF8(name); /* No GUID, go with what we've got. */ } ptr = (const unsigned char *) guid; SDL_snprintf(keystr, sizeof (keystr), "System\\CurrentControlSet\\Control\\MediaCategories\\{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}", ptr[3], ptr[2], ptr[1], ptr[0], ptr[5], ptr[4], ptr[7], ptr[6], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15]); strw = WIN_UTF8ToString(keystr); rc = (RegOpenKeyExW(HKEY_LOCAL_MACHINE, strw, 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS); SDL_free(strw); if (!rc) { return WIN_StringToUTF8(name); /* oh well. */ } rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, NULL, &len) == ERROR_SUCCESS); if (!rc) { RegCloseKey(hkey); return WIN_StringToUTF8(name); /* oh well. */ } strw = (WCHAR *) SDL_malloc(len + sizeof (WCHAR)); if (!strw) { RegCloseKey(hkey); return WIN_StringToUTF8(name); /* oh well. */ } rc = (RegQueryValueExW(hkey, L"Name", NULL, NULL, (LPBYTE) strw, &len) == ERROR_SUCCESS); RegCloseKey(hkey); if (!rc) { SDL_free(strw); return WIN_StringToUTF8(name); /* oh well. */ } strw[len / 2] = 0; /* make sure it's null-terminated. */ retval = WIN_StringToUTF8(strw); SDL_free(strw); return retval ? retval : WIN_StringToUTF8(name); #endif /* if __WINRT__ / else */ } BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b) { return (SDL_memcmp(a, b, sizeof (*a)) == 0); } BOOL WIN_IsEqualIID(REFIID a, REFIID b) { return (SDL_memcmp(a, b, sizeof (*a)) == 0); } #endif /* __WIN32__ || __WINRT__ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\windows\SDL_windows.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* This is an include file for windows.h with the SDL build settings */ #ifndef _INCLUDED_WINDOWS_H #define _INCLUDED_WINDOWS_H #if defined(__WIN32__) #define WIN32_LEAN_AND_MEAN #define STRICT #ifndef UNICODE #define UNICODE 1 #endif #undef _WIN32_WINNT #define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */ #endif #include <windows.h> #include <basetyps.h> /* for REFIID with broken mingw.org headers */ /* Routines to convert from UTF8 to native Windows text */ #if UNICODE #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) #define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) #else /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ #define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) #define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) #endif /* Sets an error message based on a given HRESULT */ extern int WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr); /* Sets an error message based on GetLastError(). Always return -1. */ extern int WIN_SetError(const char *prefix); /* Wrap up the oddities of CoInitialize() into a common function. */ extern HRESULT WIN_CoInitialize(void); extern void WIN_CoUninitialize(void); /* Returns SDL_TRUE if we're running on Windows Vista and newer */ extern BOOL WIN_IsWindowsVistaOrGreater(void); /* Returns SDL_TRUE if we're running on Windows 7 and newer */ extern BOOL WIN_IsWindows7OrGreater(void); /* You need to SDL_free() the result of this call. */ extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); /* Checks to see if two GUID are the same. */ extern BOOL WIN_IsEqualGUID(const GUID * a, const GUID * b); extern BOOL WIN_IsEqualIID(REFIID a, REFIID b); #endif /* _INCLUDED_WINDOWS_H */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\windows\SDL_xinput.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_assert.h" #include "SDL_xinput.h" #ifdef HAVE_XINPUT_H XInputGetState_t SDL_XInputGetState = NULL; XInputSetState_t SDL_XInputSetState = NULL; XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL; XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL; DWORD SDL_XInputVersion = 0; static HANDLE s_pXInputDLL = 0; static int s_XInputDLLRefCount = 0; #ifdef __WINRT__ int WIN_LoadXInputDLL(void) { /* Getting handles to system dlls (via LoadLibrary and its variants) is not * supported on WinRT, thus, pointers to XInput's functions can't be * retrieved via GetProcAddress. * * When on WinRT, assume that XInput is already loaded, and directly map * its XInput.h-declared functions to the SDL_XInput* set of function * pointers. * * Side-note: XInputGetStateEx is not available for use in WinRT. * This seems to mean that support for the guide button is not available * in WinRT, unfortunately. */ SDL_XInputGetState = (XInputGetState_t)XInputGetState; SDL_XInputSetState = (XInputSetState_t)XInputSetState; SDL_XInputGetCapabilities = (XInputGetCapabilities_t)XInputGetCapabilities; SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)XInputGetBatteryInformation; /* XInput 1.4 ships with Windows 8 and 8.1: */ SDL_XInputVersion = (1 << 16) | 4; return 0; } void WIN_UnloadXInputDLL(void) { } #else /* !__WINRT__ */ int WIN_LoadXInputDLL(void) { DWORD version = 0; if (s_pXInputDLL) { SDL_assert(s_XInputDLLRefCount > 0); s_XInputDLLRefCount++; return 0; /* already loaded */ } version = (1 << 16) | 4; s_pXInputDLL = LoadLibrary(L"XInput1_4.dll"); /* 1.4 Ships with Windows 8. */ if (!s_pXInputDLL) { version = (1 << 16) | 3; s_pXInputDLL = LoadLibrary(L"XInput1_3.dll"); /* 1.3 can be installed as a redistributable component. */ } if (!s_pXInputDLL) { s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll"); } if (!s_pXInputDLL) { /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) */ s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll"); } if (!s_pXInputDLL) { return -1; } SDL_assert(s_XInputDLLRefCount == 0); SDL_XInputVersion = version; s_XInputDLLRefCount = 1; /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */ SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, (LPCSTR)100); if (!SDL_XInputGetState) { SDL_XInputGetState = (XInputGetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetState"); } SDL_XInputSetState = (XInputSetState_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputSetState"); SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress((HMODULE)s_pXInputDLL, "XInputGetCapabilities"); SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress( (HMODULE)s_pXInputDLL, "XInputGetBatteryInformation" ); if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) { WIN_UnloadXInputDLL(); return -1; } return 0; } void WIN_UnloadXInputDLL(void) { if (s_pXInputDLL) { SDL_assert(s_XInputDLLRefCount > 0); if (--s_XInputDLLRefCount == 0) { FreeLibrary(s_pXInputDLL); s_pXInputDLL = NULL; } } else { SDL_assert(s_XInputDLLRefCount == 0); } } #endif /* __WINRT__ */ #endif /* HAVE_XINPUT_H */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\windows\SDL_xinput.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_xinput_h_ #define SDL_xinput_h_ #ifdef HAVE_XINPUT_H #include "SDL_windows.h" #include <xinput.h> #ifndef XUSER_MAX_COUNT #define XUSER_MAX_COUNT 4 #endif #ifndef XUSER_INDEX_ANY #define XUSER_INDEX_ANY 0x000000FF #endif #ifndef XINPUT_CAPS_FFB_SUPPORTED #define XINPUT_CAPS_FFB_SUPPORTED 0x0001 #endif #ifndef XINPUT_DEVSUBTYPE_UNKNOWN #define XINPUT_DEVSUBTYPE_UNKNOWN 0x00 #endif #ifndef XINPUT_DEVSUBTYPE_GAMEPAD #define XINPUT_DEVSUBTYPE_GAMEPAD 0x01 #endif #ifndef XINPUT_DEVSUBTYPE_WHEEL #define XINPUT_DEVSUBTYPE_WHEEL 0x02 #endif #ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03 #endif #ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04 #endif #ifndef XINPUT_DEVSUBTYPE_DANCE_PAD #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05 #endif #ifndef XINPUT_DEVSUBTYPE_GUITAR #define XINPUT_DEVSUBTYPE_GUITAR 0x06 #endif #ifndef XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE #define XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE 0x07 #endif #ifndef XINPUT_DEVSUBTYPE_DRUM_KIT #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08 #endif #ifndef XINPUT_DEVSUBTYPE_GUITAR_BASS #define XINPUT_DEVSUBTYPE_GUITAR_BASS 0x0B #endif #ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13 #endif #ifndef XINPUT_GAMEPAD_GUIDE #define XINPUT_GAMEPAD_GUIDE 0x0400 #endif #ifndef BATTERY_DEVTYPE_GAMEPAD #define BATTERY_DEVTYPE_GAMEPAD 0x00 #endif #ifndef BATTERY_TYPE_WIRED #define BATTERY_TYPE_WIRED 0x01 #endif #ifndef BATTERY_TYPE_UNKNOWN #define BATTERY_TYPE_UNKNOWN 0xFF #endif #ifndef BATTERY_LEVEL_EMPTY #define BATTERY_LEVEL_EMPTY 0x00 #endif #ifndef BATTERY_LEVEL_LOW #define BATTERY_LEVEL_LOW 0x01 #endif #ifndef BATTERY_LEVEL_MEDIUM #define BATTERY_LEVEL_MEDIUM 0x02 #endif #ifndef BATTERY_LEVEL_FULL #define BATTERY_LEVEL_FULL 0x03 #endif /* typedef's for XInput structs we use */ #ifndef HAVE_XINPUT_GAMEPAD_EX typedef struct { WORD wButtons; BYTE bLeftTrigger; BYTE bRightTrigger; SHORT sThumbLX; SHORT sThumbLY; SHORT sThumbRX; SHORT sThumbRY; DWORD dwPaddingReserved; } XINPUT_GAMEPAD_EX; #endif #ifndef HAVE_XINPUT_STATE_EX typedef struct { DWORD dwPacketNumber; XINPUT_GAMEPAD_EX Gamepad; } XINPUT_STATE_EX; #endif typedef struct { BYTE BatteryType; BYTE BatteryLevel; } XINPUT_BATTERY_INFORMATION_EX; /* Forward decl's for XInput API's we load dynamically and use if available */ typedef DWORD (WINAPI *XInputGetState_t) ( DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ XINPUT_STATE_EX* pState /* [out] Receives the current state */ ); typedef DWORD (WINAPI *XInputSetState_t) ( DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ XINPUT_VIBRATION* pVibration /* [in, out] The vibration information to send to the controller */ ); typedef DWORD (WINAPI *XInputGetCapabilities_t) ( DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ DWORD dwFlags, /* [in] Input flags that identify the device type */ XINPUT_CAPABILITIES* pCapabilities /* [out] Receives the capabilities */ ); typedef DWORD (WINAPI *XInputGetBatteryInformation_t) ( DWORD dwUserIndex, BYTE devType, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation ); extern int WIN_LoadXInputDLL(void); extern void WIN_UnloadXInputDLL(void); extern XInputGetState_t SDL_XInputGetState; extern XInputSetState_t SDL_XInputSetState; extern XInputGetCapabilities_t SDL_XInputGetCapabilities; extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation; extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ #define XINPUTGETSTATE SDL_XInputGetState #define XINPUTSETSTATE SDL_XInputSetState #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities #define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation #endif /* HAVE_XINPUT_H */ #endif /* SDL_xinput_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\winrt\SDL_winrtapp_common.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_winrtapp_common_h_ #define SDL_winrtapp_common_h_ /* A pointer to the app's C-style main() function (which is a different function than the WinRT app's actual entry point). */ extern int (*WINRT_SDLAppEntryPoint)(int, char **); #endif // SDL_winrtapp_common_h_
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\winrt\SDL_winrtapp_direct3d.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include <Windows.h> extern int SDL_WinRTInitNonXAMLApp(int (*mainFunction)(int, char **)); ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFrameworkView { public: SDL_WinRTApp(); // IFrameworkView Methods. virtual void Initialize(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView); virtual void SetWindow(Windows::UI::Core::CoreWindow^ window); virtual void Load(Platform::String^ entryPoint); virtual void Run(); virtual void Uninitialize(); internal: // SDL-specific methods void PumpEvents(); protected: bool ShouldWaitForAppResumeEvents(); // Event Handlers. #if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) // for Windows 8/8.1/RT apps... (and not Phone apps) void OnSettingsPaneCommandsRequested( Windows::UI::ApplicationSettings::SettingsPane ^p, Windows::UI::ApplicationSettings::SettingsPaneCommandsRequestedEventArgs ^args); #endif // if (WINAPI_FAMILY == WINAPI_FAMILY_APP) && (NTDDI_VERSION < NTDDI_WIN10) #if NTDDI_VERSION > NTDDI_WIN8 void OnOrientationChanged(Windows::Graphics::Display::DisplayInformation^ sender, Platform::Object^ args); #else void OnOrientationChanged(Platform::Object^ sender); #endif void OnWindowSizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ args); void OnLogicalDpiChanged(Platform::Object^ sender); void OnAppActivated(Windows::ApplicationModel::Core::CoreApplicationView^ applicationView, Windows::ApplicationModel::Activation::IActivatedEventArgs^ args); void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ args); void OnResuming(Platform::Object^ sender, Platform::Object^ args); void OnExiting(Platform::Object^ sender, Platform::Object^ args); void OnWindowActivated(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowActivatedEventArgs^ args); void OnWindowClosed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CoreWindowEventArgs^ args); void OnVisibilityChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::VisibilityChangedEventArgs^ args); void OnPointerPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnPointerReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnPointerWheelChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnPointerMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnPointerEntered(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnPointerExited(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args); void OnMouseMoved(Windows::Devices::Input::MouseDevice^ mouseDevice, Windows::Devices::Input::MouseEventArgs^ args); void OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); void OnKeyUp(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args); void OnCharacterReceived(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::CharacterReceivedEventArgs^ args); #if NTDDI_VERSION >= NTDDI_WIN10 void OnBackButtonPressed(Platform::Object^ sender, Windows::UI::Core::BackRequestedEventArgs^ args); #elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP void OnBackButtonPressed(Platform::Object^ sender, Windows::Phone::UI::Input::BackPressedEventArgs^ args); #endif #if NTDDI_VERSION >= NTDDI_WIN10 void OnGamepadAdded(Platform::Object ^sender, Windows::Gaming::Input::Gamepad ^gamepad); #endif private: bool m_windowClosed; bool m_windowVisible; }; extern SDL_WinRTApp ^ SDL_WinRTGlobalApp;
0
D://workCode//uploadProject\awtk\3rd\SDL\src\core
D://workCode//uploadProject\awtk\3rd\SDL\src\core\winrt\SDL_winrtapp_xaml.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_winrtapp_xaml_h_ #define SDL_winrtapp_xaml_h_ #include "SDL_stdinc.h" #ifdef __cplusplus extern SDL_bool WINRT_XAMLWasEnabled; extern int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void * backgroundPanelAsIInspectable); #endif // ifdef __cplusplus #endif // SDL_winrtapp_xaml_h_
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\cpuinfo\SDL_cpuinfo.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifdef TEST_MAIN #include "SDL_config.h" #else #include "../SDL_internal.h" #endif #if defined(__WIN32__) #include "../core/windows/SDL_windows.h" #endif #if defined(__OS2__) #define INCL_DOS #include <os2.h> #ifndef QSV_NUMPROCESSORS #define QSV_NUMPROCESSORS 26 #endif #endif /* CPU feature detection for SDL */ #include "SDL_cpuinfo.h" #include "SDL_assert.h" #ifdef HAVE_SYSCONF #include <unistd.h> #endif #ifdef HAVE_SYSCTLBYNAME #include <sys/types.h> #include <sys/sysctl.h> #endif #if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__)) #include <sys/sysctl.h> /* For AltiVec check */ #elif defined(__OpenBSD__) && defined(__powerpc__) #include <sys/param.h> #include <sys/sysctl.h> /* For AltiVec check */ #include <machine/cpu.h> #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP #include <signal.h> #include <setjmp.h> #endif #if defined(__QNXNTO__) #include <sys/syspage.h> #endif #if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) /*#include <asm/hwcap.h>*/ #ifndef AT_HWCAP #define AT_HWCAP 16 #endif #ifndef HWCAP_NEON #define HWCAP_NEON (1 << 12) #endif #if defined HAVE_GETAUXVAL #include <sys/auxv.h> #else #include <fcntl.h> #endif #endif #define CPU_HAS_RDTSC (1 << 0) #define CPU_HAS_ALTIVEC (1 << 1) #define CPU_HAS_MMX (1 << 2) #define CPU_HAS_3DNOW (1 << 3) #define CPU_HAS_SSE (1 << 4) #define CPU_HAS_SSE2 (1 << 5) #define CPU_HAS_SSE3 (1 << 6) #define CPU_HAS_SSE41 (1 << 7) #define CPU_HAS_SSE42 (1 << 8) #define CPU_HAS_AVX (1 << 9) #define CPU_HAS_AVX2 (1 << 10) #define CPU_HAS_NEON (1 << 11) #define CPU_HAS_AVX512F (1 << 12) #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ /* This is the brute force way of detecting instruction sets... the idea is borrowed from the libmpeg2 library - thanks! */ static jmp_buf jmpbuf; static void illegal_instruction(int sig) { longjmp(jmpbuf, 1); } #endif /* HAVE_SETJMP */ static int CPU_haveCPUID(void) { int has_CPUID = 0; /* *INDENT-OFF* */ #ifndef SDL_CPUINFO_DISABLED #if defined(__GNUC__) && defined(i386) __asm__ ( " pushfl # Get original EFLAGS \n" " popl %%eax \n" " movl %%eax,%%ecx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushl %%eax # Save new EFLAGS value on stack \n" " popfl # Replace current EFLAGS value \n" " pushfl # Get new EFLAGS \n" " popl %%eax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n" : "=m" (has_CPUID) : : "%eax", "%ecx" ); #elif defined(__GNUC__) && defined(__x86_64__) /* Technically, if this is being compiled under __x86_64__ then it has CPUid by definition. But it's nice to be able to prove it. :) */ __asm__ ( " pushfq # Get original EFLAGS \n" " popq %%rax \n" " movq %%rax,%%rcx \n" " xorl $0x200000,%%eax # Flip ID bit in EFLAGS \n" " pushq %%rax # Save new EFLAGS value on stack \n" " popfq # Replace current EFLAGS value \n" " pushfq # Get new EFLAGS \n" " popq %%rax # Store new EFLAGS in EAX \n" " xorl %%ecx,%%eax # Can not toggle ID bit, \n" " jz 1f # Processor=80486 \n" " movl $1,%0 # We have CPUID support \n" "1: \n" : "=m" (has_CPUID) : : "%rax", "%rcx" ); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { pushfd ; Get original EFLAGS pop eax mov ecx, eax xor eax, 200000h ; Flip ID bit in EFLAGS push eax ; Save new EFLAGS value on stack popfd ; Replace current EFLAGS value pushfd ; Get new EFLAGS pop eax ; Store new EFLAGS in EAX xor eax, ecx ; Can not toggle ID bit, jz done ; Processor=80486 mov has_CPUID,1 ; We have CPUID support done: } #elif defined(_MSC_VER) && defined(_M_X64) has_CPUID = 1; #elif defined(__sun) && defined(__i386) __asm ( " pushfl \n" " popl %eax \n" " movl %eax,%ecx \n" " xorl $0x200000,%eax \n" " pushl %eax \n" " popfl \n" " pushfl \n" " popl %eax \n" " xorl %ecx,%eax \n" " jz 1f \n" " movl $1,-8(%ebp) \n" "1: \n" ); #elif defined(__sun) && defined(__amd64) __asm ( " pushfq \n" " popq %rax \n" " movq %rax,%rcx \n" " xorl $0x200000,%eax \n" " pushq %rax \n" " popfq \n" " pushfq \n" " popq %rax \n" " xorl %ecx,%eax \n" " jz 1f \n" " movl $1,-8(%rbp) \n" "1: \n" ); #endif #endif /* *INDENT-ON* */ return has_CPUID; } #if defined(__GNUC__) && defined(i386) #define cpuid(func, a, b, c, d) \ __asm__ __volatile__ ( \ " pushl %%ebx \n" \ " xorl %%ecx,%%ecx \n" \ " cpuid \n" \ " movl %%ebx, %%esi \n" \ " popl %%ebx \n" : \ "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) #elif defined(__GNUC__) && defined(__x86_64__) #define cpuid(func, a, b, c, d) \ __asm__ __volatile__ ( \ " pushq %%rbx \n" \ " xorq %%rcx,%%rcx \n" \ " cpuid \n" \ " movq %%rbx, %%rsi \n" \ " popq %%rbx \n" : \ "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) #define cpuid(func, a, b, c, d) \ __asm { \ __asm mov eax, func \ __asm xor ecx, ecx \ __asm cpuid \ __asm mov a, eax \ __asm mov b, ebx \ __asm mov c, ecx \ __asm mov d, edx \ } #elif defined(_MSC_VER) && defined(_M_X64) #define cpuid(func, a, b, c, d) \ { \ int CPUInfo[4]; \ __cpuid(CPUInfo, func); \ a = CPUInfo[0]; \ b = CPUInfo[1]; \ c = CPUInfo[2]; \ d = CPUInfo[3]; \ } #else #define cpuid(func, a, b, c, d) \ do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0) #endif static int CPU_CPUIDFeatures[4]; static int CPU_CPUIDMaxFunction = 0; static SDL_bool CPU_OSSavesYMM = SDL_FALSE; static SDL_bool CPU_OSSavesZMM = SDL_FALSE; static void CPU_calcCPUIDFeatures(void) { static SDL_bool checked = SDL_FALSE; if (!checked) { checked = SDL_TRUE; if (CPU_haveCPUID()) { int a, b, c, d; cpuid(0, a, b, c, d); CPU_CPUIDMaxFunction = a; if (CPU_CPUIDMaxFunction >= 1) { cpuid(1, a, b, c, d); CPU_CPUIDFeatures[0] = a; CPU_CPUIDFeatures[1] = b; CPU_CPUIDFeatures[2] = c; CPU_CPUIDFeatures[3] = d; /* Check to make sure we can call xgetbv */ if (c & 0x08000000) { /* Call xgetbv to see if YMM (etc) register state is saved */ #if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) __asm__(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx"); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ a = (int)_xgetbv(0); #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__) __asm { xor ecx, ecx _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0 mov a, eax } #endif CPU_OSSavesYMM = ((a & 6) == 6) ? SDL_TRUE : SDL_FALSE; CPU_OSSavesZMM = (CPU_OSSavesYMM && ((a & 0xe0) == 0xe0)) ? SDL_TRUE : SDL_FALSE; } } } } } static int CPU_haveAltiVec(void) { volatile int altivec = 0; #ifndef SDL_CPUINFO_DISABLED #if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__)) #ifdef __OpenBSD__ int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC }; #else int selectors[2] = { CTL_HW, HW_VECTORUNIT }; #endif int hasVectorUnit = 0; size_t length = sizeof(hasVectorUnit); int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); if (0 == error) altivec = (hasVectorUnit != 0); #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP void (*handler) (int sig); handler = signal(SIGILL, illegal_instruction); if (setjmp(jmpbuf) == 0) { asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1)); altivec = 1; } signal(SIGILL, handler); #endif #endif return altivec; } #if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL) static int readProcAuxvForNeon(void) { int neon = 0; int kv[2]; const int fd = open("/proc/self/auxv", O_RDONLY); if (fd != -1) { while (read(fd, kv, sizeof (kv)) == sizeof (kv)) { if (kv[0] == AT_HWCAP) { neon = ((kv[1] & HWCAP_NEON) == HWCAP_NEON); break; } } close(fd); } return neon; } #endif static int CPU_haveNEON(void) { /* The way you detect NEON is a privileged instruction on ARM, so you have query the OS kernel in a platform-specific way. :/ */ #if defined(SDL_CPUINFO_DISABLED) || !defined(__ARM_ARCH) return 0; /* disabled or not an ARM CPU at all. */ #elif __ARM_ARCH >= 8 return 1; /* ARMv8 always has non-optional NEON support. */ #elif defined(__APPLE__) && (__ARM_ARCH >= 7) /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */ return 1; /* all Apple ARMv7 chips and later have NEON. */ #elif defined(__APPLE__) return 0; /* assume anything else from Apple doesn't have NEON. */ #elif defined(__QNXNTO__) return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON; #elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL) return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON); #elif (defined(__LINUX__) || defined(__ANDROID__)) return readProcAuxvForNeon(); /* Android offers a static library for this, but it just parses /proc/self/auxv */ #elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM) /* All WinRT ARM devices are required to support NEON, but just in case. */ return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0; #else #warning SDL_HasNEON is not implemented for this ARM platform. Write me. return 0; #endif } static int CPU_have3DNow(void) { if (CPU_CPUIDMaxFunction > 0) { /* that is, do we have CPUID at all? */ int a, b, c, d; cpuid(0x80000000, a, b, c, d); if (a >= 0x80000001) { cpuid(0x80000001, a, b, c, d); return (d & 0x80000000); } } return 0; } #define CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010) #define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) #define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) #define CPU_haveSSE2() (CPU_CPUIDFeatures[3] & 0x04000000) #define CPU_haveSSE3() (CPU_CPUIDFeatures[2] & 0x00000001) #define CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000) #define CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000) #define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) static int CPU_haveAVX2(void) { if (CPU_OSSavesYMM && (CPU_CPUIDMaxFunction >= 7)) { int a, b, c, d; (void) a; (void) b; (void) c; (void) d; /* compiler warnings... */ cpuid(7, a, b, c, d); return (b & 0x00000020); } return 0; } static int CPU_haveAVX512F(void) { if (CPU_OSSavesZMM && (CPU_CPUIDMaxFunction >= 7)) { int a, b, c, d; (void) a; (void) b; (void) c; (void) d; /* compiler warnings... */ cpuid(7, a, b, c, d); return (b & 0x00010000); } return 0; } static int SDL_CPUCount = 0; int SDL_GetCPUCount(void) { if (!SDL_CPUCount) { #ifndef SDL_CPUINFO_DISABLED #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) if (SDL_CPUCount <= 0) { SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN); } #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_CPUCount <= 0) { size_t size = sizeof(SDL_CPUCount); sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0); } #endif #ifdef __WIN32__ if (SDL_CPUCount <= 0) { SYSTEM_INFO info; GetSystemInfo(&info); SDL_CPUCount = info.dwNumberOfProcessors; } #endif #ifdef __OS2__ if (SDL_CPUCount <= 0) { DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS, &SDL_CPUCount, sizeof(SDL_CPUCount) ); } #endif #endif /* There has to be at least 1, right? :) */ if (SDL_CPUCount <= 0) { SDL_CPUCount = 1; } } return SDL_CPUCount; } /* Oh, such a sweet sweet trick, just not very useful. :) */ static const char * SDL_GetCPUType(void) { static char SDL_CPUType[13]; if (!SDL_CPUType[0]) { int i = 0; CPU_calcCPUIDFeatures(); if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ int a, b, c, d; cpuid(0x00000000, a, b, c, d); (void) a; SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUType[i++] = (char)(b & 0xff); SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUType[i++] = (char)(d & 0xff); SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUType[i++] = (char)(c & 0xff); } if (!SDL_CPUType[0]) { SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType)); } } return SDL_CPUType; } #ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ static const char * SDL_GetCPUName(void) { static char SDL_CPUName[48]; if (!SDL_CPUName[0]) { int i = 0; int a, b, c, d; CPU_calcCPUIDFeatures(); if (CPU_CPUIDMaxFunction > 0) { /* do we have CPUID at all? */ cpuid(0x80000000, a, b, c, d); if (a >= 0x80000004) { cpuid(0x80000002, a, b, c, d); SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; cpuid(0x80000003, a, b, c, d); SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; cpuid(0x80000004, a, b, c, d); SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; } } if (!SDL_CPUName[0]) { SDL_strlcpy(SDL_CPUName, "Unknown", sizeof(SDL_CPUName)); } } return SDL_CPUName; } #endif int SDL_GetCPUCacheLineSize(void) { const char *cpuType = SDL_GetCPUType(); int a, b, c, d; (void) a; (void) b; (void) c; (void) d; if (SDL_strcmp(cpuType, "GenuineIntel") == 0) { cpuid(0x00000001, a, b, c, d); return (((b >> 8) & 0xff) * 8); } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) { cpuid(0x80000005, a, b, c, d); return (c & 0xff); } else { /* Just make a guess here... */ return SDL_CACHELINE_SIZE; } } static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; static Uint32 SDL_SIMDAlignment = 0xFFFFFFFF; static Uint32 SDL_GetCPUFeatures(void) { if (SDL_CPUFeatures == 0xFFFFFFFF) { CPU_calcCPUIDFeatures(); SDL_CPUFeatures = 0; SDL_SIMDAlignment = 4; /* a good safe base value */ if (CPU_haveRDTSC()) { SDL_CPUFeatures |= CPU_HAS_RDTSC; } if (CPU_haveAltiVec()) { SDL_CPUFeatures |= CPU_HAS_ALTIVEC; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveMMX()) { SDL_CPUFeatures |= CPU_HAS_MMX; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 8); } if (CPU_have3DNow()) { SDL_CPUFeatures |= CPU_HAS_3DNOW; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 8); } if (CPU_haveSSE()) { SDL_CPUFeatures |= CPU_HAS_SSE; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveSSE2()) { SDL_CPUFeatures |= CPU_HAS_SSE2; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveSSE3()) { SDL_CPUFeatures |= CPU_HAS_SSE3; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveSSE41()) { SDL_CPUFeatures |= CPU_HAS_SSE41; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveSSE42()) { SDL_CPUFeatures |= CPU_HAS_SSE42; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } if (CPU_haveAVX()) { SDL_CPUFeatures |= CPU_HAS_AVX; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 32); } if (CPU_haveAVX2()) { SDL_CPUFeatures |= CPU_HAS_AVX2; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 32); } if (CPU_haveAVX512F()) { SDL_CPUFeatures |= CPU_HAS_AVX512F; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 64); } if (CPU_haveNEON()) { SDL_CPUFeatures |= CPU_HAS_NEON; SDL_SIMDAlignment = SDL_max(SDL_SIMDAlignment, 16); } } return SDL_CPUFeatures; } #define CPU_FEATURE_AVAILABLE(f) ((SDL_GetCPUFeatures() & f) ? SDL_TRUE : SDL_FALSE) SDL_bool SDL_HasRDTSC(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_RDTSC); } SDL_bool SDL_HasAltiVec(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_ALTIVEC); } SDL_bool SDL_HasMMX(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_MMX); } SDL_bool SDL_Has3DNow(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_3DNOW); } SDL_bool SDL_HasSSE(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE); } SDL_bool SDL_HasSSE2(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE2); } SDL_bool SDL_HasSSE3(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE3); } SDL_bool SDL_HasSSE41(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE41); } SDL_bool SDL_HasSSE42(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE42); } SDL_bool SDL_HasAVX(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_AVX); } SDL_bool SDL_HasAVX2(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_AVX2); } SDL_bool SDL_HasAVX512F(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_AVX512F); } SDL_bool SDL_HasNEON(void) { return CPU_FEATURE_AVAILABLE(CPU_HAS_NEON); } static int SDL_SystemRAM = 0; int SDL_GetSystemRAM(void) { if (!SDL_SystemRAM) { #ifndef SDL_CPUINFO_DISABLED #if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE) if (SDL_SystemRAM <= 0) { SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024)); } #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) #ifdef HW_REALMEM int mib[2] = {CTL_HW, HW_REALMEM}; #else /* might only report up to 2 GiB */ int mib[2] = {CTL_HW, HW_PHYSMEM}; #endif /* HW_REALMEM */ #else int mib[2] = {CTL_HW, HW_MEMSIZE}; #endif /* __FreeBSD__ || __FreeBSD_kernel__ */ Uint64 memsize = 0; size_t len = sizeof(memsize); if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) { SDL_SystemRAM = (int)(memsize / (1024*1024)); } } #endif #ifdef __WIN32__ if (SDL_SystemRAM <= 0) { MEMORYSTATUSEX stat; stat.dwLength = sizeof(stat); if (GlobalMemoryStatusEx(&stat)) { SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024)); } } #endif #ifdef __OS2__ if (SDL_SystemRAM <= 0) { Uint32 sysram = 0; DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM, &sysram, 4); SDL_SystemRAM = (int) (sysram / 0x100000U); } #endif #endif } return SDL_SystemRAM; } size_t SDL_SIMDGetAlignment(void) { if (SDL_SIMDAlignment == 0xFFFFFFFF) { SDL_GetCPUFeatures(); /* make sure this has been calculated */ } SDL_assert(SDL_SIMDAlignment != 0); return SDL_SIMDAlignment; } void * SDL_SIMDAlloc(const size_t len) { const size_t alignment = SDL_SIMDGetAlignment(); const size_t padding = alignment - (len % alignment); const size_t padded = (padding != alignment) ? (len + padding) : len; Uint8 *retval = NULL; Uint8 *ptr = (Uint8 *) SDL_malloc(padded + alignment + sizeof (void *)); if (ptr) { /* store the actual malloc pointer right before our aligned pointer. */ retval = ptr + sizeof (void *); retval += alignment - (((size_t) retval) % alignment); *(((void **) retval) - 1) = ptr; } return retval; } void SDL_SIMDFree(void *ptr) { if (ptr) { void **realptr = (void **) ptr; realptr--; SDL_free(*(((void **) ptr) - 1)); } } #ifdef TEST_MAIN #include <stdio.h> int main() { printf("CPU count: %d\n", SDL_GetCPUCount()); printf("CPU type: %s\n", SDL_GetCPUType()); printf("CPU name: %s\n", SDL_GetCPUName()); printf("CacheLine size: %d\n", SDL_GetCPUCacheLineSize()); printf("RDTSC: %d\n", SDL_HasRDTSC()); printf("Altivec: %d\n", SDL_HasAltiVec()); printf("MMX: %d\n", SDL_HasMMX()); printf("3DNow: %d\n", SDL_Has3DNow()); printf("SSE: %d\n", SDL_HasSSE()); printf("SSE2: %d\n", SDL_HasSSE2()); printf("SSE3: %d\n", SDL_HasSSE3()); printf("SSE4.1: %d\n", SDL_HasSSE41()); printf("SSE4.2: %d\n", SDL_HasSSE42()); printf("AVX: %d\n", SDL_HasAVX()); printf("AVX2: %d\n", SDL_HasAVX2()); printf("AVX-512F: %d\n", SDL_HasAVX512F()); printf("NEON: %d\n", SDL_HasNEON()); printf("RAM: %d MB\n", SDL_GetSystemRAM()); return 0; } #endif /* TEST_MAIN */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\cpuinfo\SDL_simd.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SDL.h" #include "../SDL_internal.h" /** * \brief Report the alignment this system needs for SIMD allocations. * * This will return the minimum number of bytes to which a pointer must be * aligned to be compatible with SIMD instructions on the current machine. * For example, if the machine supports SSE only, it will return 16, but if * it supports AVX-512F, it'll return 64 (etc). This only reports values for * instruction sets SDL knows about, so if your SDL build doesn't have * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. * Plan accordingly. */ extern size_t SDL_SIMDGetAlignment(void); /** * \brief Allocate memory in a SIMD-friendly way. * * This will allocate a block of memory that is suitable for use with SIMD * instructions. Specifically, it will be properly aligned and padded for * the system's supported vector instructions. * * The memory returned will be padded such that it is safe to read or write * an incomplete vector at the end of the memory block. This can be useful * so you don't have to drop back to a scalar fallback at the end of your * SIMD processing loop to deal with the final elements without overflowing * the allocated buffer. * * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() * or delete[], etc. * * Note that SDL will only deal with SIMD instruction sets it is aware of; * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't * know that AVX-512 wants 64. To be clear: if you can't decide to use an * instruction set with an SDL_Has*() function, don't use that instruction * set with memory allocated through here. * * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't * out of memory. * * \param len The length, in bytes, of the block to allocated. The actual * allocated block might be larger due to padding, etc. * \return Pointer to newly-allocated block, NULL if out of memory. * * \sa SDL_SIMDAlignment * \sa SDL_SIMDFree */ extern void * SDL_SIMDAlloc(const size_t len); /** * \brief Deallocate memory obtained from SDL_SIMDAlloc * * It is not valid to use this function on a pointer from anything but * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, * SDL_malloc, memalign, new[], etc. * * However, SDL_SIMDFree(NULL) is a legal no-op. * * \sa SDL_SIMDAlloc */ extern void SDL_SIMDFree(void *ptr); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\dynapi\SDL_dynapi.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "SDL_dynapi.h" #if SDL_DYNAMIC_API #if defined(__OS2__) #define INCL_DOS #define INCL_DOSERRORS #include <dos.h> #endif #include "SDL.h" /* These headers have system specific definitions, so aren't included above */ #include "SDL_syswm.h" #include "SDL_vulkan.h" /* This is the version of the dynamic API. This doesn't match the SDL version and should not change until there's been a major revamp in API/ABI. So 2.0.5 adds functions over 2.0.4? This number doesn't change; the sizeof (jump_table) changes instead. But 2.1.0 changes how a function works in an incompatible way or removes a function? This number changes, since sizeof (jump_table) isn't sufficient anymore. It's likely we'll forget to bump every time we add a function, so this is the failsafe switch for major API change decisions. Respect it and use it sparingly. */ #define SDL_DYNAPI_VERSION 1 static void SDL_InitDynamicAPI(void); /* BE CAREFUL CALLING ANY SDL CODE IN HERE, IT WILL BLOW UP. Even self-contained stuff might call SDL_Error and break everything. */ /* behold, the macro salsa! */ /* !!! FIXME: ...disabled...until we write it. :) */ #define DISABLE_JUMP_MAGIC 1 #if DISABLE_JUMP_MAGIC /* Can't use the macro for varargs nonsense. This is atrocious. */ #define SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, logname, prio) \ _static void SDLCALL SDL_Log##logname##name(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ va_list ap; initcall; va_start(ap, fmt); \ jump_table.SDL_LogMessageV(category, SDL_LOG_PRIORITY_##prio, fmt, ap); \ va_end(ap); \ } #define SDL_DYNAPI_VARARGS(_static, name, initcall) \ _static int SDLCALL SDL_SetError##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ char buf[512]; /* !!! FIXME: dynamic allocation */ \ va_list ap; initcall; va_start(ap, fmt); \ jump_table.SDL_vsnprintf(buf, sizeof (buf), fmt, ap); \ va_end(ap); \ return jump_table.SDL_SetError("%s", buf); \ } \ _static int SDLCALL SDL_sscanf##name(const char *buf, SDL_SCANF_FORMAT_STRING const char *fmt, ...) { \ int retval; va_list ap; initcall; va_start(ap, fmt); \ retval = jump_table.SDL_vsscanf(buf, fmt, ap); \ va_end(ap); \ return retval; \ } \ _static int SDLCALL SDL_snprintf##name(SDL_OUT_Z_CAP(maxlen) char *buf, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ int retval; va_list ap; initcall; va_start(ap, fmt); \ retval = jump_table.SDL_vsnprintf(buf, maxlen, fmt, ap); \ va_end(ap); \ return retval; \ } \ _static void SDLCALL SDL_Log##name(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ va_list ap; initcall; va_start(ap, fmt); \ jump_table.SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); \ va_end(ap); \ } \ _static void SDLCALL SDL_LogMessage##name(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { \ va_list ap; initcall; va_start(ap, fmt); \ jump_table.SDL_LogMessageV(category, priority, fmt, ap); \ va_end(ap); \ } \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Verbose, VERBOSE) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Debug, DEBUG) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Info, INFO) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Warn, WARN) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Error, ERROR) \ SDL_DYNAPI_VARARGS_LOGFN(_static, name, initcall, Critical, CRITICAL) #endif /* Typedefs for function pointers for jump table, and predeclare funcs */ /* The DEFAULT funcs will init jump table and then call real function. */ /* The REAL funcs are the actual functions, name-mangled to not clash. */ #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ typedef rc (SDLCALL *SDL_DYNAPIFN_##fn) params; \ static rc SDLCALL fn##_DEFAULT params; \ extern rc SDLCALL fn##_REAL params; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC /* The jump table! */ typedef struct { #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) SDL_DYNAPIFN_##fn fn; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC } SDL_DYNAPI_jump_table; /* Predeclare the default functions for initializing the jump table. */ #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) static rc SDLCALL fn##_DEFAULT params; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC /* The actual jump table. */ static SDL_DYNAPI_jump_table jump_table = { #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) fn##_DEFAULT, #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC }; /* Default functions init the function table then call right thing. */ #if DISABLE_JUMP_MAGIC #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ static rc SDLCALL fn##_DEFAULT params { \ SDL_InitDynamicAPI(); \ ret jump_table.fn args; \ } #define SDL_DYNAPI_PROC_NO_VARARGS 1 #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI()) #else /* !!! FIXME: need the jump magic. */ #error Write me. #endif /* Public API functions to jump into the jump table. */ #if DISABLE_JUMP_MAGIC #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ rc SDLCALL fn params { ret jump_table.fn args; } #define SDL_DYNAPI_PROC_NO_VARARGS 1 #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_VARARGS(,,) #else /* !!! FIXME: need the jump magic. */ #error Write me. #endif /* we make this a static function so we can call the correct one without the system's dynamic linker resolving to the wrong version of this. */ static Sint32 initialize_jumptable(Uint32 apiver, void *table, Uint32 tablesize) { SDL_DYNAPI_jump_table *output_jump_table = (SDL_DYNAPI_jump_table *) table; if (apiver != SDL_DYNAPI_VERSION) { /* !!! FIXME: can maybe handle older versions? */ return -1; /* not compatible. */ } else if (tablesize > sizeof (jump_table)) { return -1; /* newer version of SDL with functions we can't provide. */ } /* Init our jump table first. */ #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) jump_table.fn = fn##_REAL; #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC /* Then the external table... */ if (output_jump_table != &jump_table) { jump_table.SDL_memcpy(output_jump_table, &jump_table, tablesize); } /* Safe to call SDL functions now; jump table is initialized! */ return 0; /* success! */ } /* Here's the exported entry point that fills in the jump table. */ /* Use specific types when an "int" might suffice to keep this sane. */ typedef Sint32 (SDLCALL *SDL_DYNAPI_ENTRYFN)(Uint32 apiver, void *table, Uint32 tablesize); extern DECLSPEC Sint32 SDLCALL SDL_DYNAPI_entry(Uint32, void *, Uint32); Sint32 SDL_DYNAPI_entry(Uint32 apiver, void *table, Uint32 tablesize) { return initialize_jumptable(apiver, table, tablesize); } /* Obviously we can't use SDL_LoadObject() to load SDL. :) */ /* Also obviously, we never close the loaded library. */ #if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 #endif #include <windows.h> static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { HANDLE lib = LoadLibraryA(fname); void *retval = NULL; if (lib) { retval = GetProcAddress(lib, sym); if (retval == NULL) { FreeLibrary(lib); } } return retval; } #elif defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__QNX__) #include <dlfcn.h> static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL); void *retval = NULL; if (lib != NULL) { retval = dlsym(lib, sym); if (retval == NULL) { dlclose(lib); } } return retval; } #elif defined(__OS2__) static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { HMODULE hmodule; PFN retval = NULL; char error[256]; if (DosLoadModule(&error, sizeof(error), fname, &hmodule) == NO_ERROR) { if (DosQueryProcAddr(hmodule, 0, sym, &retval) != NO_ERROR) { DosFreeModule(hmodule); } } return (void *) retval; } #else #error Please define your platform. #endif static void SDL_InitDynamicAPILocked(void) { const char *libname = SDL_getenv_REAL("SDL_DYNAMIC_API"); SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */ if (libname) { entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry"); if (!entry) { /* !!! FIXME: fail to startup here instead? */ /* !!! FIXME: definitely warn user. */ /* Just fill in the function pointers from this library. */ } } if (!entry || (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0)) { /* !!! FIXME: fail to startup here instead? */ /* !!! FIXME: definitely warn user. */ /* Just fill in the function pointers from this library. */ if (!entry) { if (!initialize_jumptable(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table))) { /* !!! FIXME: now we're screwed. Should definitely abort now. */ } } } /* we intentionally never close the newly-loaded lib, of course. */ } static void SDL_InitDynamicAPI(void) { /* So the theory is that every function in the jump table defaults to * calling this function, and then replaces itself with a version that * doesn't call this function anymore. But it's possible that, in an * extreme corner case, you can have a second thread hit this function * while the jump table is being initialized by the first. * In this case, a spinlock is really painful compared to what spinlocks * _should_ be used for, but this would only happen once, and should be * insanely rare, as you would have to spin a thread outside of SDL (as * SDL_CreateThread() would also call this function before building the * new thread). */ static SDL_bool already_initialized = SDL_FALSE; /* SDL_AtomicLock calls SDL mutex functions to emulate if SDL_ATOMIC_DISABLED, which we can't do here, so in such a configuration, you're on your own. */ #if !SDL_ATOMIC_DISABLED static SDL_SpinLock lock = 0; SDL_AtomicLock_REAL(&lock); #endif if (!already_initialized) { SDL_InitDynamicAPILocked(); already_initialized = SDL_TRUE; } #if !SDL_ATOMIC_DISABLED SDL_AtomicUnlock_REAL(&lock); #endif } #endif /* SDL_DYNAMIC_API */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\dynapi\SDL_dynapi.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef SDL_dynapi_h_ #define SDL_dynapi_h_ /* IMPORTANT: This is the master switch to disabling the dynamic API. We made it so you have to hand-edit an internal source file in SDL to turn it off; you can do it if you want it badly enough, but hopefully you won't want to. You should understand the ramifications of turning this off: it makes it hard to update your SDL in the field, and impossible if you've statically linked SDL into your app. Understand that platforms change, and if we can't drop in an updated SDL, your application can definitely break some time in the future, even if it's fine today. To be sure, as new system-level video and audio APIs are introduced, an updated SDL can transparently take advantage of them, but your program will not without this feature. Think hard before turning it off. */ #ifdef SDL_DYNAMIC_API /* Tried to force it on the command line? */ #error Nope, you have to edit this file to force this off. #endif #ifdef __APPLE__ #include "TargetConditionals.h" #endif #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* probably not useful on iOS. */ #define SDL_DYNAMIC_API 0 #elif defined(__native_client__) && __native_client__ /* probably not useful on NACL. */ #define SDL_DYNAMIC_API 0 #elif defined(__EMSCRIPTEN__) && __EMSCRIPTEN__ /* probably not useful on Emscripten. */ #define SDL_DYNAMIC_API 0 #elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ #define SDL_DYNAMIC_API 0 #elif defined(__PSP__) && __PSP__ #define SDL_DYNAMIC_API 0 #elif defined(__clang_analyzer__) #define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ #endif /* everyone else. This is where we turn on the API if nothing forced it off. */ #ifndef SDL_DYNAMIC_API #define SDL_DYNAMIC_API 1 #endif #endif /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\dynapi\SDL_dynapi_overrides.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* vi: set ts=4 sw=4 expandtab: */ /* DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl. */ #if !SDL_DYNAMIC_API #error You should not be here. #endif #define SDL_SetError SDL_SetError_REAL #define SDL_Log SDL_Log_REAL #define SDL_LogVerbose SDL_LogVerbose_REAL #define SDL_LogDebug SDL_LogDebug_REAL #define SDL_LogInfo SDL_LogInfo_REAL #define SDL_LogWarn SDL_LogWarn_REAL #define SDL_LogError SDL_LogError_REAL #define SDL_LogCritical SDL_LogCritical_REAL #define SDL_LogMessage SDL_LogMessage_REAL #define SDL_sscanf SDL_sscanf_REAL #define SDL_snprintf SDL_snprintf_REAL #define SDL_CreateThread SDL_CreateThread_REAL #define SDL_RWFromFP SDL_RWFromFP_REAL #define SDL_RegisterApp SDL_RegisterApp_REAL #define SDL_UnregisterApp SDL_UnregisterApp_REAL #define SDL_Direct3D9GetAdapterIndex SDL_Direct3D9GetAdapterIndex_REAL #define SDL_RenderGetD3D9Device SDL_RenderGetD3D9Device_REAL #define SDL_iPhoneSetAnimationCallback SDL_iPhoneSetAnimationCallback_REAL #define SDL_iPhoneSetEventPump SDL_iPhoneSetEventPump_REAL #define SDL_AndroidGetJNIEnv SDL_AndroidGetJNIEnv_REAL #define SDL_AndroidGetActivity SDL_AndroidGetActivity_REAL #define SDL_AndroidGetInternalStoragePath SDL_AndroidGetInternalStoragePath_REAL #define SDL_AndroidGetExternalStorageState SDL_AndroidGetExternalStorageState_REAL #define SDL_AndroidGetExternalStoragePath SDL_AndroidGetExternalStoragePath_REAL #define SDL_Init SDL_Init_REAL #define SDL_InitSubSystem SDL_InitSubSystem_REAL #define SDL_QuitSubSystem SDL_QuitSubSystem_REAL #define SDL_WasInit SDL_WasInit_REAL #define SDL_Quit SDL_Quit_REAL #define SDL_ReportAssertion SDL_ReportAssertion_REAL #define SDL_SetAssertionHandler SDL_SetAssertionHandler_REAL #define SDL_GetAssertionReport SDL_GetAssertionReport_REAL #define SDL_ResetAssertionReport SDL_ResetAssertionReport_REAL #define SDL_AtomicTryLock SDL_AtomicTryLock_REAL #define SDL_AtomicLock SDL_AtomicLock_REAL #define SDL_AtomicUnlock SDL_AtomicUnlock_REAL #define SDL_AtomicCAS SDL_AtomicCAS_REAL #define SDL_AtomicSet SDL_AtomicSet_REAL #define SDL_AtomicGet SDL_AtomicGet_REAL #define SDL_AtomicAdd SDL_AtomicAdd_REAL #define SDL_AtomicCASPtr SDL_AtomicCASPtr_REAL #define SDL_AtomicSetPtr SDL_AtomicSetPtr_REAL #define SDL_AtomicGetPtr SDL_AtomicGetPtr_REAL #define SDL_GetNumAudioDrivers SDL_GetNumAudioDrivers_REAL #define SDL_GetAudioDriver SDL_GetAudioDriver_REAL #define SDL_AudioInit SDL_AudioInit_REAL #define SDL_AudioQuit SDL_AudioQuit_REAL #define SDL_GetCurrentAudioDriver SDL_GetCurrentAudioDriver_REAL #define SDL_OpenAudio SDL_OpenAudio_REAL #define SDL_GetNumAudioDevices SDL_GetNumAudioDevices_REAL #define SDL_GetAudioDeviceName SDL_GetAudioDeviceName_REAL #define SDL_OpenAudioDevice SDL_OpenAudioDevice_REAL #define SDL_GetAudioStatus SDL_GetAudioStatus_REAL #define SDL_GetAudioDeviceStatus SDL_GetAudioDeviceStatus_REAL #define SDL_PauseAudio SDL_PauseAudio_REAL #define SDL_PauseAudioDevice SDL_PauseAudioDevice_REAL #define SDL_LoadWAV_RW SDL_LoadWAV_RW_REAL #define SDL_FreeWAV SDL_FreeWAV_REAL #define SDL_BuildAudioCVT SDL_BuildAudioCVT_REAL #define SDL_ConvertAudio SDL_ConvertAudio_REAL #define SDL_MixAudio SDL_MixAudio_REAL #define SDL_MixAudioFormat SDL_MixAudioFormat_REAL #define SDL_LockAudio SDL_LockAudio_REAL #define SDL_LockAudioDevice SDL_LockAudioDevice_REAL #define SDL_UnlockAudio SDL_UnlockAudio_REAL #define SDL_UnlockAudioDevice SDL_UnlockAudioDevice_REAL #define SDL_CloseAudio SDL_CloseAudio_REAL #define SDL_CloseAudioDevice SDL_CloseAudioDevice_REAL #define SDL_SetClipboardText SDL_SetClipboardText_REAL #define SDL_GetClipboardText SDL_GetClipboardText_REAL #define SDL_HasClipboardText SDL_HasClipboardText_REAL #define SDL_GetCPUCount SDL_GetCPUCount_REAL #define SDL_GetCPUCacheLineSize SDL_GetCPUCacheLineSize_REAL #define SDL_HasRDTSC SDL_HasRDTSC_REAL #define SDL_HasAltiVec SDL_HasAltiVec_REAL #define SDL_HasMMX SDL_HasMMX_REAL #define SDL_Has3DNow SDL_Has3DNow_REAL #define SDL_HasSSE SDL_HasSSE_REAL #define SDL_HasSSE2 SDL_HasSSE2_REAL #define SDL_HasSSE3 SDL_HasSSE3_REAL #define SDL_HasSSE41 SDL_HasSSE41_REAL #define SDL_HasSSE42 SDL_HasSSE42_REAL #define SDL_GetSystemRAM SDL_GetSystemRAM_REAL #define SDL_GetError SDL_GetError_REAL #define SDL_ClearError SDL_ClearError_REAL #define SDL_Error SDL_Error_REAL #define SDL_PumpEvents SDL_PumpEvents_REAL #define SDL_PeepEvents SDL_PeepEvents_REAL #define SDL_HasEvent SDL_HasEvent_REAL #define SDL_HasEvents SDL_HasEvents_REAL #define SDL_FlushEvent SDL_FlushEvent_REAL #define SDL_FlushEvents SDL_FlushEvents_REAL #define SDL_PollEvent SDL_PollEvent_REAL #define SDL_WaitEvent SDL_WaitEvent_REAL #define SDL_WaitEventTimeout SDL_WaitEventTimeout_REAL #define SDL_PushEvent SDL_PushEvent_REAL #define SDL_SetEventFilter SDL_SetEventFilter_REAL #define SDL_GetEventFilter SDL_GetEventFilter_REAL #define SDL_AddEventWatch SDL_AddEventWatch_REAL #define SDL_DelEventWatch SDL_DelEventWatch_REAL #define SDL_FilterEvents SDL_FilterEvents_REAL #define SDL_EventState SDL_EventState_REAL #define SDL_RegisterEvents SDL_RegisterEvents_REAL #define SDL_GetBasePath SDL_GetBasePath_REAL #define SDL_GetPrefPath SDL_GetPrefPath_REAL #define SDL_GameControllerAddMapping SDL_GameControllerAddMapping_REAL #define SDL_GameControllerMappingForGUID SDL_GameControllerMappingForGUID_REAL #define SDL_GameControllerMapping SDL_GameControllerMapping_REAL #define SDL_IsGameController SDL_IsGameController_REAL #define SDL_GameControllerNameForIndex SDL_GameControllerNameForIndex_REAL #define SDL_GameControllerOpen SDL_GameControllerOpen_REAL #define SDL_GameControllerName SDL_GameControllerName_REAL #define SDL_GameControllerGetAttached SDL_GameControllerGetAttached_REAL #define SDL_GameControllerGetJoystick SDL_GameControllerGetJoystick_REAL #define SDL_GameControllerEventState SDL_GameControllerEventState_REAL #define SDL_GameControllerUpdate SDL_GameControllerUpdate_REAL #define SDL_GameControllerGetAxisFromString SDL_GameControllerGetAxisFromString_REAL #define SDL_GameControllerGetStringForAxis SDL_GameControllerGetStringForAxis_REAL #define SDL_GameControllerGetBindForAxis SDL_GameControllerGetBindForAxis_REAL #define SDL_GameControllerGetAxis SDL_GameControllerGetAxis_REAL #define SDL_GameControllerGetButtonFromString SDL_GameControllerGetButtonFromString_REAL #define SDL_GameControllerGetStringForButton SDL_GameControllerGetStringForButton_REAL #define SDL_GameControllerGetBindForButton SDL_GameControllerGetBindForButton_REAL #define SDL_GameControllerGetButton SDL_GameControllerGetButton_REAL #define SDL_GameControllerClose SDL_GameControllerClose_REAL #define SDL_RecordGesture SDL_RecordGesture_REAL #define SDL_SaveAllDollarTemplates SDL_SaveAllDollarTemplates_REAL #define SDL_SaveDollarTemplate SDL_SaveDollarTemplate_REAL #define SDL_LoadDollarTemplates SDL_LoadDollarTemplates_REAL #define SDL_NumHaptics SDL_NumHaptics_REAL #define SDL_HapticName SDL_HapticName_REAL #define SDL_HapticOpen SDL_HapticOpen_REAL #define SDL_HapticOpened SDL_HapticOpened_REAL #define SDL_HapticIndex SDL_HapticIndex_REAL #define SDL_MouseIsHaptic SDL_MouseIsHaptic_REAL #define SDL_HapticOpenFromMouse SDL_HapticOpenFromMouse_REAL #define SDL_JoystickIsHaptic SDL_JoystickIsHaptic_REAL #define SDL_HapticOpenFromJoystick SDL_HapticOpenFromJoystick_REAL #define SDL_HapticClose SDL_HapticClose_REAL #define SDL_HapticNumEffects SDL_HapticNumEffects_REAL #define SDL_HapticNumEffectsPlaying SDL_HapticNumEffectsPlaying_REAL #define SDL_HapticQuery SDL_HapticQuery_REAL #define SDL_HapticNumAxes SDL_HapticNumAxes_REAL #define SDL_HapticEffectSupported SDL_HapticEffectSupported_REAL #define SDL_HapticNewEffect SDL_HapticNewEffect_REAL #define SDL_HapticUpdateEffect SDL_HapticUpdateEffect_REAL #define SDL_HapticRunEffect SDL_HapticRunEffect_REAL #define SDL_HapticStopEffect SDL_HapticStopEffect_REAL #define SDL_HapticDestroyEffect SDL_HapticDestroyEffect_REAL #define SDL_HapticGetEffectStatus SDL_HapticGetEffectStatus_REAL #define SDL_HapticSetGain SDL_HapticSetGain_REAL #define SDL_HapticSetAutocenter SDL_HapticSetAutocenter_REAL #define SDL_HapticPause SDL_HapticPause_REAL #define SDL_HapticUnpause SDL_HapticUnpause_REAL #define SDL_HapticStopAll SDL_HapticStopAll_REAL #define SDL_HapticRumbleSupported SDL_HapticRumbleSupported_REAL #define SDL_HapticRumbleInit SDL_HapticRumbleInit_REAL #define SDL_HapticRumblePlay SDL_HapticRumblePlay_REAL #define SDL_HapticRumbleStop SDL_HapticRumbleStop_REAL #define SDL_SetHintWithPriority SDL_SetHintWithPriority_REAL #define SDL_SetHint SDL_SetHint_REAL #define SDL_GetHint SDL_GetHint_REAL #define SDL_AddHintCallback SDL_AddHintCallback_REAL #define SDL_DelHintCallback SDL_DelHintCallback_REAL #define SDL_ClearHints SDL_ClearHints_REAL #define SDL_NumJoysticks SDL_NumJoysticks_REAL #define SDL_JoystickNameForIndex SDL_JoystickNameForIndex_REAL #define SDL_JoystickOpen SDL_JoystickOpen_REAL #define SDL_JoystickName SDL_JoystickName_REAL #define SDL_JoystickGetDeviceGUID SDL_JoystickGetDeviceGUID_REAL #define SDL_JoystickGetGUID SDL_JoystickGetGUID_REAL #define SDL_JoystickGetGUIDString SDL_JoystickGetGUIDString_REAL #define SDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString_REAL #define SDL_JoystickGetAttached SDL_JoystickGetAttached_REAL #define SDL_JoystickInstanceID SDL_JoystickInstanceID_REAL #define SDL_JoystickNumAxes SDL_JoystickNumAxes_REAL #define SDL_JoystickNumBalls SDL_JoystickNumBalls_REAL #define SDL_JoystickNumHats SDL_JoystickNumHats_REAL #define SDL_JoystickNumButtons SDL_JoystickNumButtons_REAL #define SDL_JoystickUpdate SDL_JoystickUpdate_REAL #define SDL_JoystickEventState SDL_JoystickEventState_REAL #define SDL_JoystickGetAxis SDL_JoystickGetAxis_REAL #define SDL_JoystickGetHat SDL_JoystickGetHat_REAL #define SDL_JoystickGetBall SDL_JoystickGetBall_REAL #define SDL_JoystickGetButton SDL_JoystickGetButton_REAL #define SDL_JoystickClose SDL_JoystickClose_REAL #define SDL_GetKeyboardFocus SDL_GetKeyboardFocus_REAL #define SDL_GetKeyboardState SDL_GetKeyboardState_REAL #define SDL_GetModState SDL_GetModState_REAL #define SDL_SetModState SDL_SetModState_REAL #define SDL_GetKeyFromScancode SDL_GetKeyFromScancode_REAL #define SDL_GetScancodeFromKey SDL_GetScancodeFromKey_REAL #define SDL_GetScancodeName SDL_GetScancodeName_REAL #define SDL_GetScancodeFromName SDL_GetScancodeFromName_REAL #define SDL_GetKeyName SDL_GetKeyName_REAL #define SDL_GetKeyFromName SDL_GetKeyFromName_REAL #define SDL_StartTextInput SDL_StartTextInput_REAL #define SDL_IsTextInputActive SDL_IsTextInputActive_REAL #define SDL_StopTextInput SDL_StopTextInput_REAL #define SDL_SetTextInputRect SDL_SetTextInputRect_REAL #define SDL_HasScreenKeyboardSupport SDL_HasScreenKeyboardSupport_REAL #define SDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown_REAL #define SDL_LoadObject SDL_LoadObject_REAL #define SDL_LoadFunction SDL_LoadFunction_REAL #define SDL_UnloadObject SDL_UnloadObject_REAL #define SDL_LogSetAllPriority SDL_LogSetAllPriority_REAL #define SDL_LogSetPriority SDL_LogSetPriority_REAL #define SDL_LogGetPriority SDL_LogGetPriority_REAL #define SDL_LogResetPriorities SDL_LogResetPriorities_REAL #define SDL_LogMessageV SDL_LogMessageV_REAL #define SDL_LogGetOutputFunction SDL_LogGetOutputFunction_REAL #define SDL_LogSetOutputFunction SDL_LogSetOutputFunction_REAL #define SDL_SetMainReady SDL_SetMainReady_REAL #define SDL_ShowMessageBox SDL_ShowMessageBox_REAL #define SDL_ShowSimpleMessageBox SDL_ShowSimpleMessageBox_REAL #define SDL_GetMouseFocus SDL_GetMouseFocus_REAL #define SDL_GetMouseState SDL_GetMouseState_REAL #define SDL_GetRelativeMouseState SDL_GetRelativeMouseState_REAL #define SDL_WarpMouseInWindow SDL_WarpMouseInWindow_REAL #define SDL_SetRelativeMouseMode SDL_SetRelativeMouseMode_REAL #define SDL_GetRelativeMouseMode SDL_GetRelativeMouseMode_REAL #define SDL_CreateCursor SDL_CreateCursor_REAL #define SDL_CreateColorCursor SDL_CreateColorCursor_REAL #define SDL_CreateSystemCursor SDL_CreateSystemCursor_REAL #define SDL_SetCursor SDL_SetCursor_REAL #define SDL_GetCursor SDL_GetCursor_REAL #define SDL_GetDefaultCursor SDL_GetDefaultCursor_REAL #define SDL_FreeCursor SDL_FreeCursor_REAL #define SDL_ShowCursor SDL_ShowCursor_REAL #define SDL_CreateMutex SDL_CreateMutex_REAL #define SDL_LockMutex SDL_LockMutex_REAL #define SDL_TryLockMutex SDL_TryLockMutex_REAL #define SDL_UnlockMutex SDL_UnlockMutex_REAL #define SDL_DestroyMutex SDL_DestroyMutex_REAL #define SDL_CreateSemaphore SDL_CreateSemaphore_REAL #define SDL_DestroySemaphore SDL_DestroySemaphore_REAL #define SDL_SemWait SDL_SemWait_REAL #define SDL_SemTryWait SDL_SemTryWait_REAL #define SDL_SemWaitTimeout SDL_SemWaitTimeout_REAL #define SDL_SemPost SDL_SemPost_REAL #define SDL_SemValue SDL_SemValue_REAL #define SDL_CreateCond SDL_CreateCond_REAL #define SDL_DestroyCond SDL_DestroyCond_REAL #define SDL_CondSignal SDL_CondSignal_REAL #define SDL_CondBroadcast SDL_CondBroadcast_REAL #define SDL_CondWait SDL_CondWait_REAL #define SDL_CondWaitTimeout SDL_CondWaitTimeout_REAL #define SDL_GetPixelFormatName SDL_GetPixelFormatName_REAL #define SDL_PixelFormatEnumToMasks SDL_PixelFormatEnumToMasks_REAL #define SDL_MasksToPixelFormatEnum SDL_MasksToPixelFormatEnum_REAL #define SDL_AllocFormat SDL_AllocFormat_REAL #define SDL_FreeFormat SDL_FreeFormat_REAL #define SDL_AllocPalette SDL_AllocPalette_REAL #define SDL_SetPixelFormatPalette SDL_SetPixelFormatPalette_REAL #define SDL_SetPaletteColors SDL_SetPaletteColors_REAL #define SDL_FreePalette SDL_FreePalette_REAL #define SDL_MapRGB SDL_MapRGB_REAL #define SDL_MapRGBA SDL_MapRGBA_REAL #define SDL_GetRGB SDL_GetRGB_REAL #define SDL_GetRGBA SDL_GetRGBA_REAL #define SDL_CalculateGammaRamp SDL_CalculateGammaRamp_REAL #define SDL_GetPlatform SDL_GetPlatform_REAL #define SDL_GetPowerInfo SDL_GetPowerInfo_REAL #define SDL_HasIntersection SDL_HasIntersection_REAL #define SDL_IntersectRect SDL_IntersectRect_REAL #define SDL_UnionRect SDL_UnionRect_REAL #define SDL_EnclosePoints SDL_EnclosePoints_REAL #define SDL_IntersectRectAndLine SDL_IntersectRectAndLine_REAL #define SDL_GetNumRenderDrivers SDL_GetNumRenderDrivers_REAL #define SDL_GetRenderDriverInfo SDL_GetRenderDriverInfo_REAL #define SDL_CreateWindowAndRenderer SDL_CreateWindowAndRenderer_REAL #define SDL_CreateRenderer SDL_CreateRenderer_REAL #define SDL_CreateSoftwareRenderer SDL_CreateSoftwareRenderer_REAL #define SDL_GetRenderer SDL_GetRenderer_REAL #define SDL_GetRendererInfo SDL_GetRendererInfo_REAL #define SDL_GetRendererOutputSize SDL_GetRendererOutputSize_REAL #define SDL_CreateTexture SDL_CreateTexture_REAL #define SDL_CreateTextureFromSurface SDL_CreateTextureFromSurface_REAL #define SDL_QueryTexture SDL_QueryTexture_REAL #define SDL_SetTextureColorMod SDL_SetTextureColorMod_REAL #define SDL_GetTextureColorMod SDL_GetTextureColorMod_REAL #define SDL_SetTextureAlphaMod SDL_SetTextureAlphaMod_REAL #define SDL_GetTextureAlphaMod SDL_GetTextureAlphaMod_REAL #define SDL_SetTextureBlendMode SDL_SetTextureBlendMode_REAL #define SDL_GetTextureBlendMode SDL_GetTextureBlendMode_REAL #define SDL_UpdateTexture SDL_UpdateTexture_REAL #define SDL_UpdateYUVTexture SDL_UpdateYUVTexture_REAL #define SDL_LockTexture SDL_LockTexture_REAL #define SDL_UnlockTexture SDL_UnlockTexture_REAL #define SDL_RenderTargetSupported SDL_RenderTargetSupported_REAL #define SDL_SetRenderTarget SDL_SetRenderTarget_REAL #define SDL_GetRenderTarget SDL_GetRenderTarget_REAL #define SDL_RenderSetLogicalSize SDL_RenderSetLogicalSize_REAL #define SDL_RenderGetLogicalSize SDL_RenderGetLogicalSize_REAL #define SDL_RenderSetViewport SDL_RenderSetViewport_REAL #define SDL_RenderGetViewport SDL_RenderGetViewport_REAL #define SDL_RenderSetClipRect SDL_RenderSetClipRect_REAL #define SDL_RenderGetClipRect SDL_RenderGetClipRect_REAL #define SDL_RenderSetScale SDL_RenderSetScale_REAL #define SDL_RenderGetScale SDL_RenderGetScale_REAL #define SDL_SetRenderDrawColor SDL_SetRenderDrawColor_REAL #define SDL_GetRenderDrawColor SDL_GetRenderDrawColor_REAL #define SDL_SetRenderDrawBlendMode SDL_SetRenderDrawBlendMode_REAL #define SDL_GetRenderDrawBlendMode SDL_GetRenderDrawBlendMode_REAL #define SDL_RenderClear SDL_RenderClear_REAL #define SDL_RenderDrawPoint SDL_RenderDrawPoint_REAL #define SDL_RenderDrawPoints SDL_RenderDrawPoints_REAL #define SDL_RenderDrawLine SDL_RenderDrawLine_REAL #define SDL_RenderDrawLines SDL_RenderDrawLines_REAL #define SDL_RenderDrawRect SDL_RenderDrawRect_REAL #define SDL_RenderDrawRects SDL_RenderDrawRects_REAL #define SDL_RenderFillRect SDL_RenderFillRect_REAL #define SDL_RenderFillRects SDL_RenderFillRects_REAL #define SDL_RenderCopy SDL_RenderCopy_REAL #define SDL_RenderCopyEx SDL_RenderCopyEx_REAL #define SDL_RenderReadPixels SDL_RenderReadPixels_REAL #define SDL_RenderPresent SDL_RenderPresent_REAL #define SDL_DestroyTexture SDL_DestroyTexture_REAL #define SDL_DestroyRenderer SDL_DestroyRenderer_REAL #define SDL_GL_BindTexture SDL_GL_BindTexture_REAL #define SDL_GL_UnbindTexture SDL_GL_UnbindTexture_REAL #define SDL_RWFromFile SDL_RWFromFile_REAL #define SDL_RWFromMem SDL_RWFromMem_REAL #define SDL_RWFromConstMem SDL_RWFromConstMem_REAL #define SDL_AllocRW SDL_AllocRW_REAL #define SDL_FreeRW SDL_FreeRW_REAL #define SDL_ReadU8 SDL_ReadU8_REAL #define SDL_ReadLE16 SDL_ReadLE16_REAL #define SDL_ReadBE16 SDL_ReadBE16_REAL #define SDL_ReadLE32 SDL_ReadLE32_REAL #define SDL_ReadBE32 SDL_ReadBE32_REAL #define SDL_ReadLE64 SDL_ReadLE64_REAL #define SDL_ReadBE64 SDL_ReadBE64_REAL #define SDL_WriteU8 SDL_WriteU8_REAL #define SDL_WriteLE16 SDL_WriteLE16_REAL #define SDL_WriteBE16 SDL_WriteBE16_REAL #define SDL_WriteLE32 SDL_WriteLE32_REAL #define SDL_WriteBE32 SDL_WriteBE32_REAL #define SDL_WriteLE64 SDL_WriteLE64_REAL #define SDL_WriteBE64 SDL_WriteBE64_REAL #define SDL_CreateShapedWindow SDL_CreateShapedWindow_REAL #define SDL_IsShapedWindow SDL_IsShapedWindow_REAL #define SDL_SetWindowShape SDL_SetWindowShape_REAL #define SDL_GetShapedWindowMode SDL_GetShapedWindowMode_REAL #define SDL_malloc SDL_malloc_REAL #define SDL_calloc SDL_calloc_REAL #define SDL_realloc SDL_realloc_REAL #define SDL_free SDL_free_REAL #define SDL_getenv SDL_getenv_REAL #define SDL_setenv SDL_setenv_REAL #define SDL_qsort SDL_qsort_REAL #define SDL_abs SDL_abs_REAL #define SDL_isdigit SDL_isdigit_REAL #define SDL_isspace SDL_isspace_REAL #define SDL_toupper SDL_toupper_REAL #define SDL_tolower SDL_tolower_REAL #define SDL_memset SDL_memset_REAL #define SDL_memcpy SDL_memcpy_REAL #define SDL_memmove SDL_memmove_REAL #define SDL_memcmp SDL_memcmp_REAL #define SDL_wcslen SDL_wcslen_REAL #define SDL_wcslcpy SDL_wcslcpy_REAL #define SDL_wcslcat SDL_wcslcat_REAL #define SDL_strlen SDL_strlen_REAL #define SDL_strlcpy SDL_strlcpy_REAL #define SDL_utf8strlcpy SDL_utf8strlcpy_REAL #define SDL_strlcat SDL_strlcat_REAL #define SDL_strdup SDL_strdup_REAL #define SDL_strrev SDL_strrev_REAL #define SDL_strupr SDL_strupr_REAL #define SDL_strlwr SDL_strlwr_REAL #define SDL_strchr SDL_strchr_REAL #define SDL_strrchr SDL_strrchr_REAL #define SDL_strstr SDL_strstr_REAL #define SDL_itoa SDL_itoa_REAL #define SDL_uitoa SDL_uitoa_REAL #define SDL_ltoa SDL_ltoa_REAL #define SDL_ultoa SDL_ultoa_REAL #define SDL_lltoa SDL_lltoa_REAL #define SDL_ulltoa SDL_ulltoa_REAL #define SDL_atoi SDL_atoi_REAL #define SDL_atof SDL_atof_REAL #define SDL_strtol SDL_strtol_REAL #define SDL_strtoul SDL_strtoul_REAL #define SDL_strtoll SDL_strtoll_REAL #define SDL_strtoull SDL_strtoull_REAL #define SDL_strtod SDL_strtod_REAL #define SDL_strcmp SDL_strcmp_REAL #define SDL_strncmp SDL_strncmp_REAL #define SDL_strcasecmp SDL_strcasecmp_REAL #define SDL_strncasecmp SDL_strncasecmp_REAL #define SDL_vsnprintf SDL_vsnprintf_REAL #define SDL_acos SDL_acos_REAL #define SDL_asin SDL_asin_REAL #define SDL_atan SDL_atan_REAL #define SDL_atan2 SDL_atan2_REAL #define SDL_ceil SDL_ceil_REAL #define SDL_copysign SDL_copysign_REAL #define SDL_cos SDL_cos_REAL #define SDL_cosf SDL_cosf_REAL #define SDL_fabs SDL_fabs_REAL #define SDL_floor SDL_floor_REAL #define SDL_log SDL_log_REAL #define SDL_pow SDL_pow_REAL #define SDL_scalbn SDL_scalbn_REAL #define SDL_sin SDL_sin_REAL #define SDL_sinf SDL_sinf_REAL #define SDL_sqrt SDL_sqrt_REAL #define SDL_iconv_open SDL_iconv_open_REAL #define SDL_iconv_close SDL_iconv_close_REAL #define SDL_iconv SDL_iconv_REAL #define SDL_iconv_string SDL_iconv_string_REAL #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL #define SDL_CreateRGBSurface SDL_CreateRGBSurface_REAL #define SDL_CreateRGBSurfaceFrom SDL_CreateRGBSurfaceFrom_REAL #define SDL_FreeSurface SDL_FreeSurface_REAL #define SDL_SetSurfacePalette SDL_SetSurfacePalette_REAL #define SDL_LockSurface SDL_LockSurface_REAL #define SDL_UnlockSurface SDL_UnlockSurface_REAL #define SDL_LoadBMP_RW SDL_LoadBMP_RW_REAL #define SDL_SaveBMP_RW SDL_SaveBMP_RW_REAL #define SDL_SetSurfaceRLE SDL_SetSurfaceRLE_REAL #define SDL_SetColorKey SDL_SetColorKey_REAL #define SDL_GetColorKey SDL_GetColorKey_REAL #define SDL_SetSurfaceColorMod SDL_SetSurfaceColorMod_REAL #define SDL_GetSurfaceColorMod SDL_GetSurfaceColorMod_REAL #define SDL_SetSurfaceAlphaMod SDL_SetSurfaceAlphaMod_REAL #define SDL_GetSurfaceAlphaMod SDL_GetSurfaceAlphaMod_REAL #define SDL_SetSurfaceBlendMode SDL_SetSurfaceBlendMode_REAL #define SDL_GetSurfaceBlendMode SDL_GetSurfaceBlendMode_REAL #define SDL_SetClipRect SDL_SetClipRect_REAL #define SDL_GetClipRect SDL_GetClipRect_REAL #define SDL_ConvertSurface SDL_ConvertSurface_REAL #define SDL_ConvertSurfaceFormat SDL_ConvertSurfaceFormat_REAL #define SDL_ConvertPixels SDL_ConvertPixels_REAL #define SDL_FillRect SDL_FillRect_REAL #define SDL_FillRects SDL_FillRects_REAL #define SDL_UpperBlit SDL_UpperBlit_REAL #define SDL_LowerBlit SDL_LowerBlit_REAL #define SDL_SoftStretch SDL_SoftStretch_REAL #define SDL_UpperBlitScaled SDL_UpperBlitScaled_REAL #define SDL_LowerBlitScaled SDL_LowerBlitScaled_REAL #define SDL_GetWindowWMInfo SDL_GetWindowWMInfo_REAL #define SDL_GetThreadName SDL_GetThreadName_REAL #define SDL_ThreadID SDL_ThreadID_REAL #define SDL_GetThreadID SDL_GetThreadID_REAL #define SDL_SetThreadPriority SDL_SetThreadPriority_REAL #define SDL_WaitThread SDL_WaitThread_REAL #define SDL_DetachThread SDL_DetachThread_REAL #define SDL_TLSCreate SDL_TLSCreate_REAL #define SDL_TLSGet SDL_TLSGet_REAL #define SDL_TLSSet SDL_TLSSet_REAL #define SDL_GetTicks SDL_GetTicks_REAL #define SDL_GetPerformanceCounter SDL_GetPerformanceCounter_REAL #define SDL_GetPerformanceFrequency SDL_GetPerformanceFrequency_REAL #define SDL_Delay SDL_Delay_REAL #define SDL_AddTimer SDL_AddTimer_REAL #define SDL_RemoveTimer SDL_RemoveTimer_REAL #define SDL_GetNumTouchDevices SDL_GetNumTouchDevices_REAL #define SDL_GetTouchDevice SDL_GetTouchDevice_REAL #define SDL_GetNumTouchFingers SDL_GetNumTouchFingers_REAL #define SDL_GetTouchFinger SDL_GetTouchFinger_REAL #define SDL_GetVersion SDL_GetVersion_REAL #define SDL_GetRevision SDL_GetRevision_REAL #define SDL_GetRevisionNumber SDL_GetRevisionNumber_REAL #define SDL_GetNumVideoDrivers SDL_GetNumVideoDrivers_REAL #define SDL_GetVideoDriver SDL_GetVideoDriver_REAL #define SDL_VideoInit SDL_VideoInit_REAL #define SDL_VideoQuit SDL_VideoQuit_REAL #define SDL_GetCurrentVideoDriver SDL_GetCurrentVideoDriver_REAL #define SDL_GetNumVideoDisplays SDL_GetNumVideoDisplays_REAL #define SDL_GetDisplayName SDL_GetDisplayName_REAL #define SDL_GetDisplayBounds SDL_GetDisplayBounds_REAL #define SDL_GetDisplayDPI SDL_GetDisplayDPI_REAL #define SDL_GetNumDisplayModes SDL_GetNumDisplayModes_REAL #define SDL_GetDisplayMode SDL_GetDisplayMode_REAL #define SDL_GetDesktopDisplayMode SDL_GetDesktopDisplayMode_REAL #define SDL_GetCurrentDisplayMode SDL_GetCurrentDisplayMode_REAL #define SDL_GetClosestDisplayMode SDL_GetClosestDisplayMode_REAL #define SDL_GetWindowDisplayIndex SDL_GetWindowDisplayIndex_REAL #define SDL_SetWindowDisplayMode SDL_SetWindowDisplayMode_REAL #define SDL_GetWindowDisplayMode SDL_GetWindowDisplayMode_REAL #define SDL_GetWindowPixelFormat SDL_GetWindowPixelFormat_REAL #define SDL_CreateWindow SDL_CreateWindow_REAL #define SDL_CreateWindowFrom SDL_CreateWindowFrom_REAL #define SDL_GetWindowDpiRatio SDL_GetWindowDpiRatio_REAL #define SDL_GetWindowID SDL_GetWindowID_REAL #define SDL_GetWindowFromID SDL_GetWindowFromID_REAL #define SDL_GetWindowFlags SDL_GetWindowFlags_REAL #define SDL_SetWindowTitle SDL_SetWindowTitle_REAL #define SDL_GetWindowTitle SDL_GetWindowTitle_REAL #define SDL_SetWindowIcon SDL_SetWindowIcon_REAL #define SDL_SetWindowData SDL_SetWindowData_REAL #define SDL_GetWindowData SDL_GetWindowData_REAL #define SDL_SetWindowPosition SDL_SetWindowPosition_REAL #define SDL_GetWindowPosition SDL_GetWindowPosition_REAL #define SDL_SetWindowSize SDL_SetWindowSize_REAL #define SDL_GetWindowSize SDL_GetWindowSize_REAL #define SDL_SetWindowMinimumSize SDL_SetWindowMinimumSize_REAL #define SDL_GetWindowMinimumSize SDL_GetWindowMinimumSize_REAL #define SDL_SetWindowMaximumSize SDL_SetWindowMaximumSize_REAL #define SDL_GetWindowMaximumSize SDL_GetWindowMaximumSize_REAL #define SDL_SetWindowBordered SDL_SetWindowBordered_REAL #define SDL_ShowWindow SDL_ShowWindow_REAL #define SDL_HideWindow SDL_HideWindow_REAL #define SDL_RaiseWindow SDL_RaiseWindow_REAL #define SDL_MaximizeWindow SDL_MaximizeWindow_REAL #define SDL_MinimizeWindow SDL_MinimizeWindow_REAL #define SDL_RestoreWindow SDL_RestoreWindow_REAL #define SDL_SetWindowFullscreen SDL_SetWindowFullscreen_REAL #define SDL_GetWindowSurface SDL_GetWindowSurface_REAL #define SDL_UpdateWindowSurface SDL_UpdateWindowSurface_REAL #define SDL_UpdateWindowSurfaceRects SDL_UpdateWindowSurfaceRects_REAL #define SDL_SetWindowGrab SDL_SetWindowGrab_REAL #define SDL_GetWindowGrab SDL_GetWindowGrab_REAL #define SDL_SetWindowBrightness SDL_SetWindowBrightness_REAL #define SDL_GetWindowBrightness SDL_GetWindowBrightness_REAL #define SDL_SetWindowGammaRamp SDL_SetWindowGammaRamp_REAL #define SDL_GetWindowGammaRamp SDL_GetWindowGammaRamp_REAL #define SDL_DestroyWindow SDL_DestroyWindow_REAL #define SDL_IsScreenSaverEnabled SDL_IsScreenSaverEnabled_REAL #define SDL_EnableScreenSaver SDL_EnableScreenSaver_REAL #define SDL_DisableScreenSaver SDL_DisableScreenSaver_REAL #define SDL_GL_LoadLibrary SDL_GL_LoadLibrary_REAL #define SDL_GL_GetProcAddress SDL_GL_GetProcAddress_REAL #define SDL_GL_UnloadLibrary SDL_GL_UnloadLibrary_REAL #define SDL_GL_ExtensionSupported SDL_GL_ExtensionSupported_REAL #define SDL_GL_SetAttribute SDL_GL_SetAttribute_REAL #define SDL_GL_GetAttribute SDL_GL_GetAttribute_REAL #define SDL_GL_CreateContext SDL_GL_CreateContext_REAL #define SDL_GL_MakeCurrent SDL_GL_MakeCurrent_REAL #define SDL_GL_GetCurrentWindow SDL_GL_GetCurrentWindow_REAL #define SDL_GL_GetCurrentContext SDL_GL_GetCurrentContext_REAL #define SDL_GL_GetDrawableSize SDL_GL_GetDrawableSize_REAL #define SDL_GL_SetSwapInterval SDL_GL_SetSwapInterval_REAL #define SDL_GL_GetSwapInterval SDL_GL_GetSwapInterval_REAL #define SDL_GL_SwapWindow SDL_GL_SwapWindow_REAL #define SDL_GL_DeleteContext SDL_GL_DeleteContext_REAL #define SDL_vsscanf SDL_vsscanf_REAL #define SDL_GameControllerAddMappingsFromRW SDL_GameControllerAddMappingsFromRW_REAL #define SDL_GL_ResetAttributes SDL_GL_ResetAttributes_REAL #define SDL_HasAVX SDL_HasAVX_REAL #define SDL_GetDefaultAssertionHandler SDL_GetDefaultAssertionHandler_REAL #define SDL_GetAssertionHandler SDL_GetAssertionHandler_REAL #define SDL_DXGIGetOutputInfo SDL_DXGIGetOutputInfo_REAL #define SDL_RenderIsClipEnabled SDL_RenderIsClipEnabled_REAL #define SDL_WinRTRunApp SDL_WinRTRunApp_REAL #define SDL_WarpMouseGlobal SDL_WarpMouseGlobal_REAL #define SDL_WinRTGetFSPathUNICODE SDL_WinRTGetFSPathUNICODE_REAL #define SDL_WinRTGetFSPathUTF8 SDL_WinRTGetFSPathUTF8_REAL #define SDL_WinRTRunApp SDL_WinRTRunApp_REAL #define SDL_sqrtf SDL_sqrtf_REAL #define SDL_tan SDL_tan_REAL #define SDL_tanf SDL_tanf_REAL #define SDL_CaptureMouse SDL_CaptureMouse_REAL #define SDL_SetWindowHitTest SDL_SetWindowHitTest_REAL #define SDL_GetGlobalMouseState SDL_GetGlobalMouseState_REAL #define SDL_HasAVX2 SDL_HasAVX2_REAL #define SDL_QueueAudio SDL_QueueAudio_REAL #define SDL_GetQueuedAudioSize SDL_GetQueuedAudioSize_REAL #define SDL_ClearQueuedAudio SDL_ClearQueuedAudio_REAL #define SDL_GetGrabbedWindow SDL_GetGrabbedWindow_REAL #define SDL_SetWindowsMessageHook SDL_SetWindowsMessageHook_REAL #define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_REAL #define SDL_GameControllerFromInstanceID SDL_GameControllerFromInstanceID_REAL #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_REAL #define SDL_GetDisplayUsableBounds SDL_GetDisplayUsableBounds_REAL #define SDL_GetWindowBordersSize SDL_GetWindowBordersSize_REAL #define SDL_SetWindowOpacity SDL_SetWindowOpacity_REAL #define SDL_GetWindowOpacity SDL_GetWindowOpacity_REAL #define SDL_SetWindowInputFocus SDL_SetWindowInputFocus_REAL #define SDL_SetWindowModalFor SDL_SetWindowModalFor_REAL #define SDL_RenderSetIntegerScale SDL_RenderSetIntegerScale_REAL #define SDL_RenderGetIntegerScale SDL_RenderGetIntegerScale_REAL #define SDL_DequeueAudio SDL_DequeueAudio_REAL #define SDL_SetWindowResizable SDL_SetWindowResizable_REAL #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL #define SDL_GetHintBoolean SDL_GetHintBoolean_REAL #define SDL_JoystickGetDeviceVendor SDL_JoystickGetDeviceVendor_REAL #define SDL_JoystickGetDeviceProduct SDL_JoystickGetDeviceProduct_REAL #define SDL_JoystickGetDeviceProductVersion SDL_JoystickGetDeviceProductVersion_REAL #define SDL_JoystickGetVendor SDL_JoystickGetVendor_REAL #define SDL_JoystickGetProduct SDL_JoystickGetProduct_REAL #define SDL_JoystickGetProductVersion SDL_JoystickGetProductVersion_REAL #define SDL_GameControllerGetVendor SDL_GameControllerGetVendor_REAL #define SDL_GameControllerGetProduct SDL_GameControllerGetProduct_REAL #define SDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion_REAL #define SDL_HasNEON SDL_HasNEON_REAL #define SDL_GameControllerNumMappings SDL_GameControllerNumMappings_REAL #define SDL_GameControllerMappingForIndex SDL_GameControllerMappingForIndex_REAL #define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_REAL #define SDL_JoystickGetDeviceType SDL_JoystickGetDeviceType_REAL #define SDL_JoystickGetType SDL_JoystickGetType_REAL #define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL #define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL #define SDL_JoystickGetDeviceInstanceID SDL_JoystickGetDeviceInstanceID_REAL #define SDL_utf8strlen SDL_utf8strlen_REAL #define SDL_LoadFile_RW SDL_LoadFile_RW_REAL #define SDL_wcscmp SDL_wcscmp_REAL #define SDL_ComposeCustomBlendMode SDL_ComposeCustomBlendMode_REAL #define SDL_DuplicateSurface SDL_DuplicateSurface_REAL #define SDL_Vulkan_LoadLibrary SDL_Vulkan_LoadLibrary_REAL #define SDL_Vulkan_GetVkGetInstanceProcAddr SDL_Vulkan_GetVkGetInstanceProcAddr_REAL #define SDL_Vulkan_UnloadLibrary SDL_Vulkan_UnloadLibrary_REAL #define SDL_Vulkan_GetInstanceExtensions SDL_Vulkan_GetInstanceExtensions_REAL #define SDL_Vulkan_CreateSurface SDL_Vulkan_CreateSurface_REAL #define SDL_Vulkan_GetDrawableSize SDL_Vulkan_GetDrawableSize_REAL #define SDL_LockJoysticks SDL_LockJoysticks_REAL #define SDL_UnlockJoysticks SDL_UnlockJoysticks_REAL #define SDL_GetMemoryFunctions SDL_GetMemoryFunctions_REAL #define SDL_SetMemoryFunctions SDL_SetMemoryFunctions_REAL #define SDL_GetNumAllocations SDL_GetNumAllocations_REAL #define SDL_NewAudioStream SDL_NewAudioStream_REAL #define SDL_AudioStreamPut SDL_AudioStreamPut_REAL #define SDL_AudioStreamGet SDL_AudioStreamGet_REAL #define SDL_AudioStreamClear SDL_AudioStreamClear_REAL #define SDL_AudioStreamAvailable SDL_AudioStreamAvailable_REAL #define SDL_FreeAudioStream SDL_FreeAudioStream_REAL #define SDL_AudioStreamFlush SDL_AudioStreamFlush_REAL #define SDL_acosf SDL_acosf_REAL #define SDL_asinf SDL_asinf_REAL #define SDL_atanf SDL_atanf_REAL #define SDL_atan2f SDL_atan2f_REAL #define SDL_ceilf SDL_ceilf_REAL #define SDL_copysignf SDL_copysignf_REAL #define SDL_fabsf SDL_fabsf_REAL #define SDL_floorf SDL_floorf_REAL #define SDL_logf SDL_logf_REAL #define SDL_powf SDL_powf_REAL #define SDL_scalbnf SDL_scalbnf_REAL #define SDL_fmod SDL_fmod_REAL #define SDL_fmodf SDL_fmodf_REAL #define SDL_SetYUVConversionMode SDL_SetYUVConversionMode_REAL #define SDL_GetYUVConversionMode SDL_GetYUVConversionMode_REAL #define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL #define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_REAL #define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_REAL #define SDL_IsAndroidTV SDL_IsAndroidTV_REAL #define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_REAL #define SDL_log10 SDL_log10_REAL #define SDL_log10f SDL_log10f_REAL #define SDL_GameControllerMappingForDeviceIndex SDL_GameControllerMappingForDeviceIndex_REAL #define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_REAL #define SDL_HasAVX512F SDL_HasAVX512F_REAL #define SDL_IsChromebook SDL_IsChromebook_REAL #define SDL_IsDeXMode SDL_IsDeXMode_REAL #define SDL_AndroidBackButton SDL_AndroidBackButton_REAL #define SDL_exp SDL_exp_REAL #define SDL_expf SDL_expf_REAL #define SDL_wcsdup SDL_wcsdup_REAL #define SDL_GameControllerRumble SDL_GameControllerRumble_REAL #define SDL_JoystickRumble SDL_JoystickRumble_REAL #define SDL_NumSensors SDL_NumSensors_REAL #define SDL_SensorGetDeviceName SDL_SensorGetDeviceName_REAL #define SDL_SensorGetDeviceType SDL_SensorGetDeviceType_REAL #define SDL_SensorGetDeviceNonPortableType SDL_SensorGetDeviceNonPortableType_REAL #define SDL_SensorGetDeviceInstanceID SDL_SensorGetDeviceInstanceID_REAL #define SDL_SensorOpen SDL_SensorOpen_REAL #define SDL_SensorFromInstanceID SDL_SensorFromInstanceID_REAL #define SDL_SensorGetName SDL_SensorGetName_REAL #define SDL_SensorGetType SDL_SensorGetType_REAL #define SDL_SensorGetNonPortableType SDL_SensorGetNonPortableType_REAL #define SDL_SensorGetInstanceID SDL_SensorGetInstanceID_REAL #define SDL_SensorGetData SDL_SensorGetData_REAL #define SDL_SensorClose SDL_SensorClose_REAL #define SDL_SensorUpdate SDL_SensorUpdate_REAL #define SDL_IsTablet SDL_IsTablet_REAL #define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL #define SDL_HasColorKey SDL_HasColorKey_REAL
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\dynapi\SDL_dynapi_procs.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* vi: set ts=4 sw=4 expandtab: */ /* DO NOT EDIT THIS FILE BY HAND. It is autogenerated by gendynapi.pl. NEVER REARRANGE THIS FILE, THE ORDER IS ABI LAW. Changing this file means bumping SDL_DYNAPI_VERSION. You can safely add new items to the end of the file, though. Also, this file gets included multiple times, don't add #pragma once, etc. */ /* direct jump magic can use these, the rest needs special code. */ #if !SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_PROC(int,SDL_SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return) SDL_DYNAPI_PROC(void,SDL_Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),) SDL_DYNAPI_PROC(void,SDL_LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogDebug,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogInfo,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogWarn,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogError,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogCritical,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogMessage,(int a, SDL_LogPriority b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),) SDL_DYNAPI_PROC(int,SDL_sscanf,(const char *a, SDL_SCANF_FORMAT_STRING const char *b, ...),(a,b),return) SDL_DYNAPI_PROC(int,SDL_snprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, SDL_PRINTF_FORMAT_STRING const char *c, ...),(a,b,c),return) #endif #ifdef SDL_CreateThread #undef SDL_CreateThread #endif #if defined(__WIN32__) && !defined(HAVE_LIBC) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return) #elif defined(__OS2__) SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c, pfnSDL_CurrentBeginThread d, pfnSDL_CurrentEndThread e),(a,b,c,d,e),return) #else SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c),(a,b,c),return) #endif #ifdef HAVE_STDIO_H SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(FILE *a, SDL_bool b),(a,b),return) #else SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFP,(void *a, SDL_bool b),(a,b),return) #endif #ifdef __WIN32__ SDL_DYNAPI_PROC(int,SDL_RegisterApp,(char *a, Uint32 b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_UnregisterApp,(void),(),) SDL_DYNAPI_PROC(int,SDL_Direct3D9GetAdapterIndex,(int a),(a),return) SDL_DYNAPI_PROC(IDirect3DDevice9*,SDL_RenderGetD3D9Device,(SDL_Renderer *a),(a),return) #endif #ifdef __IPHONEOS__ SDL_DYNAPI_PROC(int,SDL_iPhoneSetAnimationCallback,(SDL_Window *a, int b, void c, void *d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_iPhoneSetEventPump,(SDL_bool a),(a),) #endif #ifdef __ANDROID__ SDL_DYNAPI_PROC(void*,SDL_AndroidGetJNIEnv,(void),(),return) SDL_DYNAPI_PROC(void*,SDL_AndroidGetActivity,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_AndroidGetInternalStoragePath,(void),(),return) SDL_DYNAPI_PROC(int,SDL_AndroidGetExternalStorageState,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_AndroidGetExternalStoragePath,(void),(),return) #endif SDL_DYNAPI_PROC(int,SDL_Init,(Uint32 a),(a),return) SDL_DYNAPI_PROC(int,SDL_InitSubSystem,(Uint32 a),(a),return) SDL_DYNAPI_PROC(void,SDL_QuitSubSystem,(Uint32 a),(a),) SDL_DYNAPI_PROC(Uint32,SDL_WasInit,(Uint32 a),(a),return) SDL_DYNAPI_PROC(void,SDL_Quit,(void),(),) SDL_DYNAPI_PROC(SDL_assert_state,SDL_ReportAssertion,(SDL_assert_data *a, const char *b, const char *c, int d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_SetAssertionHandler,(SDL_AssertionHandler a, void *b),(a,b),) SDL_DYNAPI_PROC(const SDL_assert_data*,SDL_GetAssertionReport,(void),(),return) SDL_DYNAPI_PROC(void,SDL_ResetAssertionReport,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicTryLock,(SDL_SpinLock *a),(a),return) SDL_DYNAPI_PROC(void,SDL_AtomicLock,(SDL_SpinLock *a),(a),) SDL_DYNAPI_PROC(void,SDL_AtomicUnlock,(SDL_SpinLock *a),(a),) SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCAS,(SDL_atomic_t *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_AtomicSet,(SDL_atomic_t *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_AtomicGet,(SDL_atomic_t *a),(a),return) SDL_DYNAPI_PROC(int,SDL_AtomicAdd,(SDL_atomic_t *a, int b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_AtomicCASPtr,(void **a, void *b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_AtomicSetPtr,(void **a, void *b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_AtomicGetPtr,(void **a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetNumAudioDrivers,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_GetAudioDriver,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_AudioInit,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_AudioQuit,(void),(),) SDL_DYNAPI_PROC(const char*,SDL_GetCurrentAudioDriver,(void),(),return) SDL_DYNAPI_PROC(int,SDL_OpenAudio,(SDL_AudioSpec *a, SDL_AudioSpec *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetNumAudioDevices,(int a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetAudioDeviceName,(int a, int b),(a,b),return) SDL_DYNAPI_PROC(SDL_AudioDeviceID,SDL_OpenAudioDevice,(const char *a, int b, const SDL_AudioSpec *c, SDL_AudioSpec *d, int e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_AudioStatus,SDL_GetAudioStatus,(void),(),return) SDL_DYNAPI_PROC(SDL_AudioStatus,SDL_GetAudioDeviceStatus,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(void,SDL_PauseAudio,(int a),(a),) SDL_DYNAPI_PROC(void,SDL_PauseAudioDevice,(SDL_AudioDeviceID a, int b),(a,b),) SDL_DYNAPI_PROC(SDL_AudioSpec*,SDL_LoadWAV_RW,(SDL_RWops *a, int b, SDL_AudioSpec *c, Uint8 **d, Uint32 *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(void,SDL_FreeWAV,(Uint8 *a),(a),) SDL_DYNAPI_PROC(int,SDL_BuildAudioCVT,(SDL_AudioCVT *a, SDL_AudioFormat b, Uint8 c, int d, SDL_AudioFormat e, Uint8 f, int g),(a,b,c,d,e,f,g),return) SDL_DYNAPI_PROC(int,SDL_ConvertAudio,(SDL_AudioCVT *a),(a),return) SDL_DYNAPI_PROC(void,SDL_MixAudio,(Uint8 *a, const Uint8 *b, Uint32 c, int d),(a,b,c,d),) SDL_DYNAPI_PROC(void,SDL_MixAudioFormat,(Uint8 *a, const Uint8 *b, SDL_AudioFormat c, Uint32 d, int e),(a,b,c,d,e),) SDL_DYNAPI_PROC(void,SDL_LockAudio,(void),(),) SDL_DYNAPI_PROC(void,SDL_LockAudioDevice,(SDL_AudioDeviceID a),(a),) SDL_DYNAPI_PROC(void,SDL_UnlockAudio,(void),(),) SDL_DYNAPI_PROC(void,SDL_UnlockAudioDevice,(SDL_AudioDeviceID a),(a),) SDL_DYNAPI_PROC(void,SDL_CloseAudio,(void),(),) SDL_DYNAPI_PROC(void,SDL_CloseAudioDevice,(SDL_AudioDeviceID a),(a),) SDL_DYNAPI_PROC(int,SDL_SetClipboardText,(const char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasClipboardText,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetCPUCount,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetCPUCacheLineSize,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasRDTSC,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasAltiVec,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasMMX,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_Has3DNow,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE2,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE3,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE41,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasSSE42,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetSystemRAM,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_GetError,(void),(),return) SDL_DYNAPI_PROC(void,SDL_ClearError,(void),(),) SDL_DYNAPI_PROC(int,SDL_Error,(SDL_errorcode a),(a),return) SDL_DYNAPI_PROC(void,SDL_PumpEvents,(void),(),) SDL_DYNAPI_PROC(int,SDL_PeepEvents,(SDL_Event *a, int b, SDL_eventaction c, Uint32 d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasEvent,(Uint32 a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasEvents,(Uint32 a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_FlushEvent,(Uint32 a),(a),) SDL_DYNAPI_PROC(void,SDL_FlushEvents,(Uint32 a, Uint32 b),(a,b),) SDL_DYNAPI_PROC(int,SDL_PollEvent,(SDL_Event *a),(a),return) SDL_DYNAPI_PROC(int,SDL_WaitEvent,(SDL_Event *a),(a),return) SDL_DYNAPI_PROC(int,SDL_WaitEventTimeout,(SDL_Event *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_PushEvent,(SDL_Event *a),(a),return) SDL_DYNAPI_PROC(void,SDL_SetEventFilter,(SDL_EventFilter a, void *b),(a,b),) SDL_DYNAPI_PROC(SDL_bool,SDL_GetEventFilter,(SDL_EventFilter *a, void **b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_AddEventWatch,(SDL_EventFilter a, void *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_DelEventWatch,(SDL_EventFilter a, void *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_FilterEvents,(SDL_EventFilter a, void *b),(a,b),) SDL_DYNAPI_PROC(Uint8,SDL_EventState,(Uint32 a, int b),(a,b),return) SDL_DYNAPI_PROC(Uint32,SDL_RegisterEvents,(int a),(a),return) SDL_DYNAPI_PROC(char*,SDL_GetBasePath,(void),(),return) SDL_DYNAPI_PROC(char*,SDL_GetPrefPath,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GameControllerAddMapping,(const char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_GameControllerMappingForGUID,(SDL_JoystickGUID a),(a),return) SDL_DYNAPI_PROC(char*,SDL_GameControllerMapping,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsGameController,(int a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GameControllerNameForIndex,(int a),(a),return) SDL_DYNAPI_PROC(SDL_GameController*,SDL_GameControllerOpen,(int a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GameControllerName,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GameControllerGetAttached,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GameControllerGetJoystick,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GameControllerEventState,(int a),(a),return) SDL_DYNAPI_PROC(void,SDL_GameControllerUpdate,(void),(),) SDL_DYNAPI_PROC(SDL_GameControllerAxis,SDL_GameControllerGetAxisFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GameControllerGetStringForAxis,(SDL_GameControllerAxis a),(a),return) SDL_DYNAPI_PROC(SDL_GameControllerButtonBind,SDL_GameControllerGetBindForAxis,(SDL_GameController *a, SDL_GameControllerAxis b),(a,b),return) SDL_DYNAPI_PROC(Sint16,SDL_GameControllerGetAxis,(SDL_GameController *a, SDL_GameControllerAxis b),(a,b),return) SDL_DYNAPI_PROC(SDL_GameControllerButton,SDL_GameControllerGetButtonFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GameControllerGetStringForButton,(SDL_GameControllerButton a),(a),return) SDL_DYNAPI_PROC(SDL_GameControllerButtonBind,SDL_GameControllerGetBindForButton,(SDL_GameController *a, SDL_GameControllerButton b),(a,b),return) SDL_DYNAPI_PROC(Uint8,SDL_GameControllerGetButton,(SDL_GameController *a, SDL_GameControllerButton b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_GameControllerClose,(SDL_GameController *a),(a),) SDL_DYNAPI_PROC(int,SDL_RecordGesture,(SDL_TouchID a),(a),return) SDL_DYNAPI_PROC(int,SDL_SaveAllDollarTemplates,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SaveDollarTemplate,(SDL_GestureID a, SDL_RWops *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_LoadDollarTemplates,(SDL_TouchID a, SDL_RWops *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_NumHaptics,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_HapticName,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Haptic*,SDL_HapticOpen,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticOpened,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticIndex,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_MouseIsHaptic,(void),(),return) SDL_DYNAPI_PROC(SDL_Haptic*,SDL_HapticOpenFromMouse,(void),(),return) SDL_DYNAPI_PROC(int,SDL_JoystickIsHaptic,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_Haptic*,SDL_HapticOpenFromJoystick,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(void,SDL_HapticClose,(SDL_Haptic *a),(a),) SDL_DYNAPI_PROC(int,SDL_HapticNumEffects,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticNumEffectsPlaying,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(unsigned int,SDL_HapticQuery,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticNumAxes,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticEffectSupported,(SDL_Haptic *a, SDL_HapticEffect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_HapticNewEffect,(SDL_Haptic *a, SDL_HapticEffect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_HapticUpdateEffect,(SDL_Haptic *a, int b, SDL_HapticEffect *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_HapticRunEffect,(SDL_Haptic *a, int b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_HapticStopEffect,(SDL_Haptic *a, int b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_HapticDestroyEffect,(SDL_Haptic *a, int b),(a,b),) SDL_DYNAPI_PROC(int,SDL_HapticGetEffectStatus,(SDL_Haptic *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_HapticSetGain,(SDL_Haptic *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_HapticSetAutocenter,(SDL_Haptic *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_HapticPause,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticUnpause,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticStopAll,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticRumbleSupported,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticRumbleInit,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(int,SDL_HapticRumblePlay,(SDL_Haptic *a, float b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_HapticRumbleStop,(SDL_Haptic *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SetHintWithPriority,(const char *a, const char *b, SDL_HintPriority c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SetHint,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(const char*,SDL_GetHint,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_AddHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_DelHintCallback,(const char *a, SDL_HintCallback b, void *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_ClearHints,(void),(),) SDL_DYNAPI_PROC(int,SDL_NumJoysticks,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_JoystickNameForIndex,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_JoystickOpen,(int a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_JoystickName,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_JoystickGetDeviceGUID,(int a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_JoystickGetGUID,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(void,SDL_JoystickGetGUIDString,(SDL_JoystickGUID a, char *b, int c),(a,b,c),) SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_JoystickGetGUIDFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickGetAttached,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickID,SDL_JoystickInstanceID,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(int,SDL_JoystickNumAxes,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(int,SDL_JoystickNumBalls,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(int,SDL_JoystickNumHats,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(int,SDL_JoystickNumButtons,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(void,SDL_JoystickUpdate,(void),(),) SDL_DYNAPI_PROC(int,SDL_JoystickEventState,(int a),(a),return) SDL_DYNAPI_PROC(Sint16,SDL_JoystickGetAxis,(SDL_Joystick *a, int b),(a,b),return) SDL_DYNAPI_PROC(Uint8,SDL_JoystickGetHat,(SDL_Joystick *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_JoystickGetBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return) SDL_DYNAPI_PROC(Uint8,SDL_JoystickGetButton,(SDL_Joystick *a, int b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_JoystickClose,(SDL_Joystick *a),(a),) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetKeyboardFocus,(void),(),return) SDL_DYNAPI_PROC(const Uint8*,SDL_GetKeyboardState,(int *a),(a),return) SDL_DYNAPI_PROC(SDL_Keymod,SDL_GetModState,(void),(),return) SDL_DYNAPI_PROC(void,SDL_SetModState,(SDL_Keymod a),(a),) SDL_DYNAPI_PROC(SDL_Keycode,SDL_GetKeyFromScancode,(SDL_Scancode a),(a),return) SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromKey,(SDL_Keycode a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetScancodeName,(SDL_Scancode a),(a),return) SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromName,(const char *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetKeyName,(SDL_Keycode a),(a),return) SDL_DYNAPI_PROC(SDL_Keycode,SDL_GetKeyFromName,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_StartTextInput,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_IsTextInputActive,(void),(),return) SDL_DYNAPI_PROC(void,SDL_StopTextInput,(void),(),) SDL_DYNAPI_PROC(void,SDL_SetTextInputRect,(SDL_Rect *a),(a),) SDL_DYNAPI_PROC(SDL_bool,SDL_HasScreenKeyboardSupport,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsScreenKeyboardShown,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_LoadObject,(const char *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_LoadFunction,(void *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_UnloadObject,(void *a),(a),) SDL_DYNAPI_PROC(void,SDL_LogSetAllPriority,(SDL_LogPriority a),(a),) SDL_DYNAPI_PROC(void,SDL_LogSetPriority,(int a, SDL_LogPriority b),(a,b),) SDL_DYNAPI_PROC(SDL_LogPriority,SDL_LogGetPriority,(int a),(a),return) SDL_DYNAPI_PROC(void,SDL_LogResetPriorities,(void),(),) SDL_DYNAPI_PROC(void,SDL_LogMessageV,(int a, SDL_LogPriority b, const char *c, va_list d),(a,b,c,d),) SDL_DYNAPI_PROC(void,SDL_LogGetOutputFunction,(SDL_LogOutputFunction *a, void **b),(a,b),) SDL_DYNAPI_PROC(void,SDL_LogSetOutputFunction,(SDL_LogOutputFunction a, void *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_SetMainReady,(void),(),) SDL_DYNAPI_PROC(int,SDL_ShowMessageBox,(const SDL_MessageBoxData *a, int *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_ShowSimpleMessageBox,(Uint32 a, const char *b, const char *c, SDL_Window *d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetMouseFocus,(void),(),return) SDL_DYNAPI_PROC(Uint32,SDL_GetMouseState,(int *a, int *b),(a,b),return) SDL_DYNAPI_PROC(Uint32,SDL_GetRelativeMouseState,(int *a, int *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_WarpMouseInWindow,(SDL_Window *a, int b, int c),(a,b,c),) SDL_DYNAPI_PROC(int,SDL_SetRelativeMouseMode,(SDL_bool a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetRelativeMouseMode,(void),(),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateCursor,(const Uint8 *a, const Uint8 *b, int c, int d, int e, int f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateColorCursor,(SDL_Surface *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_CreateSystemCursor,(SDL_SystemCursor a),(a),return) SDL_DYNAPI_PROC(void,SDL_SetCursor,(SDL_Cursor *a),(a),) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetCursor,(void),(),return) SDL_DYNAPI_PROC(SDL_Cursor*,SDL_GetDefaultCursor,(void),(),return) SDL_DYNAPI_PROC(void,SDL_FreeCursor,(SDL_Cursor *a),(a),) SDL_DYNAPI_PROC(int,SDL_ShowCursor,(int a),(a),return) SDL_DYNAPI_PROC(SDL_mutex*,SDL_CreateMutex,(void),(),return) SDL_DYNAPI_PROC(int,SDL_LockMutex,(SDL_mutex *a),(a),return) SDL_DYNAPI_PROC(int,SDL_TryLockMutex,(SDL_mutex *a),(a),return) SDL_DYNAPI_PROC(int,SDL_UnlockMutex,(SDL_mutex *a),(a),return) SDL_DYNAPI_PROC(void,SDL_DestroyMutex,(SDL_mutex *a),(a),) SDL_DYNAPI_PROC(SDL_sem*,SDL_CreateSemaphore,(Uint32 a),(a),return) SDL_DYNAPI_PROC(void,SDL_DestroySemaphore,(SDL_sem *a),(a),) SDL_DYNAPI_PROC(int,SDL_SemWait,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SemTryWait,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SemWaitTimeout,(SDL_sem *a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SemPost,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_SemValue,(SDL_sem *a),(a),return) SDL_DYNAPI_PROC(SDL_cond*,SDL_CreateCond,(void),(),return) SDL_DYNAPI_PROC(void,SDL_DestroyCond,(SDL_cond *a),(a),) SDL_DYNAPI_PROC(int,SDL_CondSignal,(SDL_cond *a),(a),return) SDL_DYNAPI_PROC(int,SDL_CondBroadcast,(SDL_cond *a),(a),return) SDL_DYNAPI_PROC(int,SDL_CondWait,(SDL_cond *a, SDL_mutex *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_CondWaitTimeout,(SDL_cond *a, SDL_mutex *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(const char*,SDL_GetPixelFormatName,(Uint32 a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_PixelFormatEnumToMasks,(Uint32 a, int *b, Uint32 *c, Uint32 *d, Uint32 *e, Uint32 *f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(Uint32,SDL_MasksToPixelFormatEnum,(int a, Uint32 b, Uint32 c, Uint32 d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_AllocFormat,(Uint32 a),(a),return) SDL_DYNAPI_PROC(void,SDL_FreeFormat,(SDL_PixelFormat *a),(a),) SDL_DYNAPI_PROC(SDL_Palette*,SDL_AllocPalette,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetPixelFormatPalette,(SDL_PixelFormat *a, SDL_Palette *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetPaletteColors,(SDL_Palette *a, const SDL_Color *b, int c, int d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_FreePalette,(SDL_Palette *a),(a),) SDL_DYNAPI_PROC(Uint32,SDL_MapRGB,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return) SDL_DYNAPI_PROC(Uint32,SDL_MapRGBA,(const SDL_PixelFormat *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(void,SDL_GetRGB,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),) SDL_DYNAPI_PROC(void,SDL_GetRGBA,(Uint32 a, const SDL_PixelFormat *b, Uint8 *c, Uint8 *d, Uint8 *e, Uint8 *f),(a,b,c,d,e,f),) SDL_DYNAPI_PROC(void,SDL_CalculateGammaRamp,(float a, Uint16 *b),(a,b),) SDL_DYNAPI_PROC(const char*,SDL_GetPlatform,(void),(),return) SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetPowerInfo,(int *a, int *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasIntersection,(const SDL_Rect *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectRect,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_UnionRect,(const SDL_Rect *a, const SDL_Rect *b, SDL_Rect *c),(a,b,c),) SDL_DYNAPI_PROC(SDL_bool,SDL_EnclosePoints,(const SDL_Point *a, int b, const SDL_Rect *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IntersectRectAndLine,(const SDL_Rect *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_GetNumRenderDrivers,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetRenderDriverInfo,(int a, SDL_RendererInfo *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_CreateWindowAndRenderer,(int a, int b, Uint32 c, SDL_Window **d, SDL_Renderer **e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, int b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetRenderer,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetRendererInfo,(SDL_Renderer *a, SDL_RendererInfo *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetRendererOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTexture,(SDL_Renderer *a, Uint32 b, int c, int d, int e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Texture*,SDL_CreateTextureFromSurface,(SDL_Renderer *a, SDL_Surface *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_QueryTexture,(SDL_Texture *a, Uint32 *b, int *c, int *d, int *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_SetTextureColorMod,(SDL_Texture *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_GetTextureColorMod,(SDL_Texture *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_SetTextureAlphaMod,(SDL_Texture *a, Uint8 b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetTextureAlphaMod,(SDL_Texture *a, Uint8 *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetTextureBlendMode,(SDL_Texture *a, SDL_BlendMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_UpdateTexture,(SDL_Texture *a, const SDL_Rect *b, const void *c, int d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_UpdateYUVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f, const Uint8 *g, int h),(a,b,c,d,e,f,g,h),return) SDL_DYNAPI_PROC(int,SDL_LockTexture,(SDL_Texture *a, const SDL_Rect *b, void **c, int *d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_UnlockTexture,(SDL_Texture *a),(a),) SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTargetSupported,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetRenderTarget,(SDL_Renderer *a, SDL_Texture *b),(a,b),return) SDL_DYNAPI_PROC(SDL_Texture*,SDL_GetRenderTarget,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(int,SDL_RenderSetLogicalSize,(SDL_Renderer *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_RenderGetLogicalSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(int,SDL_RenderSetViewport,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_RenderGetViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),) SDL_DYNAPI_PROC(int,SDL_RenderSetClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_RenderGetClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),) SDL_DYNAPI_PROC(int,SDL_RenderSetScale,(SDL_Renderer *a, float b, float c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_RenderGetScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),) SDL_DYNAPI_PROC(int,SDL_SetRenderDrawColor,(SDL_Renderer *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_GetRenderDrawColor,(SDL_Renderer *a, Uint8 *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_SetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_RenderClear,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawPoint,(SDL_Renderer *a, int b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawPoints,(SDL_Renderer *a, const SDL_Point *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawLine,(SDL_Renderer *a, int b, int c, int d, int e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawLines,(SDL_Renderer *a, const SDL_Point *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_RenderDrawRects,(SDL_Renderer *a, const SDL_Rect *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_RenderFillRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_RenderFillRects,(SDL_Renderer *a, const SDL_Rect *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_RenderCopy,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_RenderCopyEx,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_Rect *d, const double e, const SDL_Point *f, const SDL_RendererFlip g),(a,b,c,d,e,f,g),return) SDL_DYNAPI_PROC(int,SDL_RenderReadPixels,(SDL_Renderer *a, const SDL_Rect *b, Uint32 c, void *d, int e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(void,SDL_RenderPresent,(SDL_Renderer *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyTexture,(SDL_Texture *a),(a),) SDL_DYNAPI_PROC(void,SDL_DestroyRenderer,(SDL_Renderer *a),(a),) SDL_DYNAPI_PROC(int,SDL_GL_BindTexture,(SDL_Texture *a, float *b, float *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GL_UnbindTexture,(SDL_Texture *a),(a),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromFile,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromMem,(void *a, int b),(a,b),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_RWFromConstMem,(const void *a, int b),(a,b),return) SDL_DYNAPI_PROC(SDL_RWops*,SDL_AllocRW,(void),(),return) SDL_DYNAPI_PROC(void,SDL_FreeRW,(SDL_RWops *a),(a),) SDL_DYNAPI_PROC(Uint8,SDL_ReadU8,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_ReadLE16,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_ReadBE16,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_ReadLE32,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_ReadBE32,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint64,SDL_ReadLE64,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(Uint64,SDL_ReadBE64,(SDL_RWops *a),(a),return) SDL_DYNAPI_PROC(size_t,SDL_WriteU8,(SDL_RWops *a, Uint8 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteLE16,(SDL_RWops *a, Uint16 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteBE16,(SDL_RWops *a, Uint16 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteLE32,(SDL_RWops *a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteBE32,(SDL_RWops *a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteLE64,(SDL_RWops *a, Uint64 b),(a,b),return) SDL_DYNAPI_PROC(size_t,SDL_WriteBE64,(SDL_RWops *a, Uint64 b),(a,b),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateShapedWindow,(const char *a, unsigned int b, unsigned int c, unsigned int d, unsigned int e, Uint32 f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsShapedWindow,(const SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowShape,(SDL_Window *a, SDL_Surface *b, SDL_WindowShapeMode *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GetShapedWindowMode,(SDL_Window *a, SDL_WindowShapeMode *b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_malloc,(size_t a),(a),return) SDL_DYNAPI_PROC(void*,SDL_calloc,(size_t a, size_t b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_realloc,(void *a, size_t b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_free,(void *a),(a),) SDL_DYNAPI_PROC(char*,SDL_getenv,(const char *a),(a),return) SDL_DYNAPI_PROC(int,SDL_setenv,(const char *a, const char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_qsort,(void *a, size_t b, size_t c, int (*d)(const void *, const void *)),(a,b,c,d),) SDL_DYNAPI_PROC(int,SDL_abs,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_isdigit,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_isspace,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_toupper,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_tolower,(int a),(a),return) SDL_DYNAPI_PROC(void*,SDL_memset,(SDL_OUT_BYTECAP(c) void *a, int b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_memcpy,(SDL_OUT_BYTECAP(c) void *a, SDL_IN_BYTECAP(c) const void *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_memmove,(SDL_OUT_BYTECAP(c) void *a, SDL_IN_BYTECAP(c) const void *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_memcmp,(const void *a, const void *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(size_t,SDL_wcslen,(const wchar_t *a),(a),return) SDL_DYNAPI_PROC(size_t,SDL_wcslcpy,(SDL_OUT_Z_CAP(c) wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(size_t,SDL_wcslcat,(SDL_INOUT_Z_CAP(c) wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(size_t,SDL_strlen,(const char *a),(a),return) SDL_DYNAPI_PROC(size_t,SDL_strlcpy,(SDL_OUT_Z_CAP(c) char *a, const char *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(size_t,SDL_utf8strlcpy,(SDL_OUT_Z_CAP(c) char *a, const char *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(size_t,SDL_strlcat,(SDL_INOUT_Z_CAP(c) char *a, const char *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_strdup,(const char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_strrev,(char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_strupr,(char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_strlwr,(char *a),(a),return) SDL_DYNAPI_PROC(char*,SDL_strchr,(const char *a, int b),(a,b),return) SDL_DYNAPI_PROC(char*,SDL_strrchr,(const char *a, int b),(a,b),return) SDL_DYNAPI_PROC(char*,SDL_strstr,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(char*,SDL_itoa,(int a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_uitoa,(unsigned int a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_ltoa,(long a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_ultoa,(unsigned long a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_lltoa,(Sint64 a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(char*,SDL_ulltoa,(Uint64 a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_atoi,(const char *a),(a),return) SDL_DYNAPI_PROC(double,SDL_atof,(const char *a),(a),return) SDL_DYNAPI_PROC(long,SDL_strtol,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(unsigned long,SDL_strtoul,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(Sint64,SDL_strtoll,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(Uint64,SDL_strtoull,(const char *a, char **b, int c),(a,b,c),return) SDL_DYNAPI_PROC(double,SDL_strtod,(const char *a, char **b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_strcmp,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_strncmp,(const char *a, const char *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_strcasecmp,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_strncasecmp,(const char *a, const char *b, size_t c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_vsnprintf,(SDL_OUT_Z_CAP(b) char *a, size_t b, const char *c, va_list d),(a,b,c,d),return) SDL_DYNAPI_PROC(double,SDL_acos,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_asin,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_atan,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_atan2,(double a, double b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_ceil,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_copysign,(double a, double b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_cos,(double a),(a),return) SDL_DYNAPI_PROC(float,SDL_cosf,(float a),(a),return) SDL_DYNAPI_PROC(double,SDL_fabs,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_floor,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_log,(double a),(a),return) SDL_DYNAPI_PROC(double,SDL_pow,(double a, double b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_scalbn,(double a, int b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_sin,(double a),(a),return) SDL_DYNAPI_PROC(float,SDL_sinf,(float a),(a),return) SDL_DYNAPI_PROC(double,SDL_sqrt,(double a),(a),return) SDL_DYNAPI_PROC(SDL_iconv_t,SDL_iconv_open,(const char *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_iconv_close,(SDL_iconv_t a),(a),return) SDL_DYNAPI_PROC(size_t,SDL_iconv,(SDL_iconv_t a, const char **b, size_t *c, char **d, size_t *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(char*,SDL_iconv_string,(const char *a, const char *b, const char *c, size_t d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurface,(Uint32 a, int b, int c, int d, Uint32 e, Uint32 f, Uint32 g, Uint32 h),(a,b,c,d,e,f,g,h),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceFrom,(void *a, int b, int c, int d, int e, Uint32 f, Uint32 g, Uint32 h, Uint32 i),(a,b,c,d,e,f,g,h,i),return) SDL_DYNAPI_PROC(void,SDL_FreeSurface,(SDL_Surface *a),(a),) SDL_DYNAPI_PROC(int,SDL_SetSurfacePalette,(SDL_Surface *a, SDL_Palette *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_LockSurface,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(void,SDL_UnlockSurface,(SDL_Surface *a),(a),) SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadBMP_RW,(SDL_RWops *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SaveBMP_RW,(SDL_Surface *a, SDL_RWops *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_SetSurfaceRLE,(SDL_Surface *a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetColorKey,(SDL_Surface *a, int b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GetColorKey,(SDL_Surface *a, Uint32 *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetSurfaceColorMod,(SDL_Surface *a, Uint8 b, Uint8 c, Uint8 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceColorMod,(SDL_Surface *a, Uint8 *b, Uint8 *c, Uint8 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_SetSurfaceAlphaMod,(SDL_Surface *a, Uint8 b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceAlphaMod,(SDL_Surface *a, Uint8 *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetSurfaceBlendMode,(SDL_Surface *a, SDL_BlendMode *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_SetClipRect,(SDL_Surface *a, const SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_GetClipRect,(SDL_Surface *a, SDL_Rect *b),(a,b),) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurface,(SDL_Surface *a, const SDL_PixelFormat *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_ConvertSurfaceFormat,(SDL_Surface *a, Uint32 b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_ConvertPixels,(int a, int b, Uint32 c, const void *d, int e, Uint32 f, void *g, int h),(a,b,c,d,e,f,g,h),return) SDL_DYNAPI_PROC(int,SDL_FillRect,(SDL_Surface *a, const SDL_Rect *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_FillRects,(SDL_Surface *a, const SDL_Rect *b, int c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_UpperBlit,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_LowerBlit,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_SoftStretch,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_UpperBlitScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_LowerBlitScaled,(SDL_Surface *a, SDL_Rect *b, SDL_Surface *c, SDL_Rect *d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowWMInfo,(SDL_Window *a, SDL_SysWMinfo *b),(a,b),return) SDL_DYNAPI_PROC(const char*,SDL_GetThreadName,(SDL_Thread *a),(a),return) SDL_DYNAPI_PROC(SDL_threadID,SDL_ThreadID,(void),(),return) SDL_DYNAPI_PROC(SDL_threadID,SDL_GetThreadID,(SDL_Thread *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetThreadPriority,(SDL_ThreadPriority a),(a),return) SDL_DYNAPI_PROC(void,SDL_WaitThread,(SDL_Thread *a, int *b),(a,b),) SDL_DYNAPI_PROC(void,SDL_DetachThread,(SDL_Thread *a),(a),) SDL_DYNAPI_PROC(SDL_TLSID,SDL_TLSCreate,(void),(),return) SDL_DYNAPI_PROC(void*,SDL_TLSGet,(SDL_TLSID a),(a),return) SDL_DYNAPI_PROC(int,SDL_TLSSet,(SDL_TLSID a, const void *b, void (*c)(void*)),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetTicks,(void),(),return) SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceCounter,(void),(),return) SDL_DYNAPI_PROC(Uint64,SDL_GetPerformanceFrequency,(void),(),return) SDL_DYNAPI_PROC(void,SDL_Delay,(Uint32 a),(a),) SDL_DYNAPI_PROC(SDL_TimerID,SDL_AddTimer,(Uint32 a, SDL_TimerCallback b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_RemoveTimer,(SDL_TimerID a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetNumTouchDevices,(void),(),return) SDL_DYNAPI_PROC(SDL_TouchID,SDL_GetTouchDevice,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetNumTouchFingers,(SDL_TouchID a),(a),return) SDL_DYNAPI_PROC(SDL_Finger*,SDL_GetTouchFinger,(SDL_TouchID a, int b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_GetVersion,(SDL_version *a),(a),) SDL_DYNAPI_PROC(const char*,SDL_GetRevision,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetRevisionNumber,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetNumVideoDrivers,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_GetVideoDriver,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_VideoInit,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_VideoQuit,(void),(),) SDL_DYNAPI_PROC(const char*,SDL_GetCurrentVideoDriver,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GetNumVideoDisplays,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_GetDisplayName,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetDisplayBounds,(int a, SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetNumDisplayModes,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetDisplayMode,(int a, int b, SDL_DisplayMode *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GetDesktopDisplayMode,(int a, SDL_DisplayMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetCurrentDisplayMode,(int a, SDL_DisplayMode *b),(a,b),return) SDL_DYNAPI_PROC(SDL_DisplayMode*,SDL_GetClosestDisplayMode,(int a, const SDL_DisplayMode *b, SDL_DisplayMode *c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GetWindowDisplayIndex,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowDisplayMode,(SDL_Window *a, const SDL_DisplayMode *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetWindowDisplayMode,(SDL_Window *a, SDL_DisplayMode *b),(a,b),return) SDL_DYNAPI_PROC(Uint32,SDL_GetWindowPixelFormat,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindow,(const char *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_CreateWindowFrom,(const void *a),(a),return) SDL_DYNAPI_PROC(float, SDL_GetWindowDpiRatio, (SDL_Window *a), (a), return) SDL_DYNAPI_PROC(Uint32,SDL_GetWindowID,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetWindowFromID,(Uint32 a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_GetWindowFlags,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(void,SDL_SetWindowTitle,(SDL_Window *a, const char *b),(a,b),) SDL_DYNAPI_PROC(const char*,SDL_GetWindowTitle,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(void,SDL_SetWindowIcon,(SDL_Window *a, SDL_Surface *b),(a,b),) SDL_DYNAPI_PROC(void*,SDL_SetWindowData,(SDL_Window *a, const char *b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(void*,SDL_GetWindowData,(SDL_Window *a, const char *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_SetWindowPosition,(SDL_Window *a, int b, int c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_GetWindowPosition,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_SetWindowSize,(SDL_Window *a, int b, int c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_GetWindowSize,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_SetWindowMinimumSize,(SDL_Window *a, int b, int c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_GetWindowMinimumSize,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_SetWindowMaximumSize,(SDL_Window *a, int b, int c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_GetWindowMaximumSize,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_SetWindowBordered,(SDL_Window *a, SDL_bool b),(a,b),) SDL_DYNAPI_PROC(void,SDL_ShowWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_HideWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_RaiseWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_MaximizeWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_MinimizeWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_RestoreWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(int,SDL_SetWindowFullscreen,(SDL_Window *a, Uint32 b),(a,b),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_GetWindowSurface,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurface,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_UpdateWindowSurfaceRects,(SDL_Window *a, const SDL_Rect *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_SetWindowGrab,(SDL_Window *a, SDL_bool b),(a,b),) SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowGrab,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowBrightness,(SDL_Window *a, float b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_GetWindowBrightness,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowGammaRamp,(SDL_Window *a, const Uint16 *b, const Uint16 *c, const Uint16 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_GetWindowGammaRamp,(SDL_Window *a, Uint16 *b, Uint16 *c, Uint16 *d),(a,b,c,d),return) SDL_DYNAPI_PROC(void,SDL_DestroyWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(SDL_bool,SDL_IsScreenSaverEnabled,(void),(),return) SDL_DYNAPI_PROC(void,SDL_EnableScreenSaver,(void),(),) SDL_DYNAPI_PROC(void,SDL_DisableScreenSaver,(void),(),) SDL_DYNAPI_PROC(int,SDL_GL_LoadLibrary,(const char *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_GL_GetProcAddress,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_GL_ExtensionSupported,(const char *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GL_SetAttribute,(SDL_GLattr a, int b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GL_GetAttribute,(SDL_GLattr a, int *b),(a,b),return) SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_CreateContext,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GL_MakeCurrent,(SDL_Window *a, SDL_GLContext b),(a,b),return) SDL_DYNAPI_PROC(SDL_Window*,SDL_GL_GetCurrentWindow,(void),(),return) SDL_DYNAPI_PROC(SDL_GLContext,SDL_GL_GetCurrentContext,(void),(),return) SDL_DYNAPI_PROC(void,SDL_GL_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(int,SDL_GL_SetSwapInterval,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_GL_GetSwapInterval,(void),(),return) SDL_DYNAPI_PROC(void,SDL_GL_SwapWindow,(SDL_Window *a),(a),) SDL_DYNAPI_PROC(void,SDL_GL_DeleteContext,(SDL_GLContext a),(a),) SDL_DYNAPI_PROC(int,SDL_vsscanf,(const char *a, const char *b, va_list c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_GameControllerAddMappingsFromRW,(SDL_RWops *a, int b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_GL_ResetAttributes,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX,(void),(),return) SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetDefaultAssertionHandler,(void),(),return) SDL_DYNAPI_PROC(SDL_AssertionHandler,SDL_GetAssertionHandler,(void **a),(a),return) #ifdef __WIN32__ SDL_DYNAPI_PROC(SDL_bool,SDL_DXGIGetOutputInfo,(int a,int *b, int *c),(a,b,c),return) #endif SDL_DYNAPI_PROC(SDL_bool,SDL_RenderIsClipEnabled,(SDL_Renderer *a),(a),return) #ifdef __WINRT__ SDL_DYNAPI_PROC(int,SDL_WinRTRunApp,(int a, char **b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(const wchar_t*,SDL_WinRTGetFSPathUNICODE,(SDL_WinRT_Path a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_WinRTGetFSPathUTF8,(SDL_WinRT_Path a),(a),return) #endif SDL_DYNAPI_PROC(int,SDL_WarpMouseGlobal,(int a, int b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_sqrtf,(float a),(a),return) SDL_DYNAPI_PROC(double,SDL_tan,(double a),(a),return) SDL_DYNAPI_PROC(float,SDL_tanf,(float a),(a),return) SDL_DYNAPI_PROC(int,SDL_CaptureMouse,(SDL_bool a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowHitTest,(SDL_Window *a, SDL_HitTest b, void *c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetGlobalMouseState,(int *a, int *b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX2,(void),(),return) SDL_DYNAPI_PROC(int,SDL_QueueAudio,(SDL_AudioDeviceID a, const void *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(Uint32,SDL_GetQueuedAudioSize,(SDL_AudioDeviceID a),(a),return) SDL_DYNAPI_PROC(void,SDL_ClearQueuedAudio,(SDL_AudioDeviceID a),(a),) SDL_DYNAPI_PROC(SDL_Window*,SDL_GetGrabbedWindow,(void),(),return) #ifdef __WIN32__ SDL_DYNAPI_PROC(void,SDL_SetWindowsMessageHook,(SDL_WindowsMessageHook a, void *b),(a,b),) #endif SDL_DYNAPI_PROC(int,SDL_GetDisplayDPI,(int a, float *b, float *c, float *d),(a,b,c,d),return) SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_JoystickCurrentPowerLevel,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_GameController*,SDL_GameControllerFromInstanceID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_JoystickFromInstanceID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(int,SDL_GetDisplayUsableBounds,(int a, SDL_Rect *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetWindowBordersSize,(SDL_Window *a, int *b, int *c, int *d, int *e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(int,SDL_SetWindowOpacity,(SDL_Window *a, float b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_GetWindowOpacity,(SDL_Window *a, float *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_SetWindowInputFocus,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SetWindowModalFor,(SDL_Window *a, SDL_Window *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_RenderSetIntegerScale,(SDL_Renderer *a, SDL_bool b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_RenderGetIntegerScale,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(Uint32,SDL_DequeueAudio,(SDL_AudioDeviceID a, void *b, Uint32 c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceVendor,(int a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProductVersion,(int a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetVendor,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProduct,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProductVersion,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetVendor,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProduct,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProductVersion,(SDL_GameController *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasNEON,(void),(),return) SDL_DYNAPI_PROC(int,SDL_GameControllerNumMappings,(void),(),return) SDL_DYNAPI_PROC(char*,SDL_GameControllerMappingForIndex,(int a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_JoystickGetAxisInitialState,(SDL_Joystick *a, int b, Sint16 *c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_JoystickType,SDL_JoystickGetDeviceType,(int a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickType,SDL_JoystickGetType,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(void,SDL_MemoryBarrierReleaseFunction,(void),(),) SDL_DYNAPI_PROC(void,SDL_MemoryBarrierAcquireFunction,(void),(),) SDL_DYNAPI_PROC(SDL_JoystickID,SDL_JoystickGetDeviceInstanceID,(int a),(a),return) SDL_DYNAPI_PROC(size_t,SDL_utf8strlen,(const char *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_LoadFile_RW,(SDL_RWops *a, size_t *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_wcscmp,(const wchar_t *a, const wchar_t *b),(a,b),return) SDL_DYNAPI_PROC(SDL_BlendMode,SDL_ComposeCustomBlendMode,(SDL_BlendFactor a, SDL_BlendFactor b, SDL_BlendOperation c, SDL_BlendFactor d, SDL_BlendFactor e, SDL_BlendOperation f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(SDL_Surface*,SDL_DuplicateSurface,(SDL_Surface *a),(a),return) SDL_DYNAPI_PROC(int,SDL_Vulkan_LoadLibrary,(const char *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_Vulkan_GetVkGetInstanceProcAddr,(void),(),return) SDL_DYNAPI_PROC(void,SDL_Vulkan_UnloadLibrary,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_GetInstanceExtensions,(SDL_Window *a, unsigned int *b, const char **c),(a,b,c),return) SDL_DYNAPI_PROC(SDL_bool,SDL_Vulkan_CreateSurface,(SDL_Window *a, VkInstance b, VkSurfaceKHR *c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_Vulkan_GetDrawableSize,(SDL_Window *a, int *b, int *c),(a,b,c),) SDL_DYNAPI_PROC(void,SDL_LockJoysticks,(void),(),) SDL_DYNAPI_PROC(void,SDL_UnlockJoysticks,(void),(),) SDL_DYNAPI_PROC(void,SDL_GetMemoryFunctions,(SDL_malloc_func *a, SDL_calloc_func *b, SDL_realloc_func *c, SDL_free_func *d),(a,b,c,d),) SDL_DYNAPI_PROC(int,SDL_SetMemoryFunctions,(SDL_malloc_func a, SDL_calloc_func b, SDL_realloc_func c, SDL_free_func d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_GetNumAllocations,(void),(),return) SDL_DYNAPI_PROC(SDL_AudioStream*,SDL_NewAudioStream,(const SDL_AudioFormat a, const Uint8 b, const int c, const SDL_AudioFormat d, const Uint8 e, const int f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(int,SDL_AudioStreamPut,(SDL_AudioStream *a, const void *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(int,SDL_AudioStreamGet,(SDL_AudioStream *a, void *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_AudioStreamClear,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(int,SDL_AudioStreamAvailable,(SDL_AudioStream *a),(a),return) SDL_DYNAPI_PROC(void,SDL_FreeAudioStream,(SDL_AudioStream *a),(a),) SDL_DYNAPI_PROC(int,SDL_AudioStreamFlush,(SDL_AudioStream *a),(a),return) SDL_DYNAPI_PROC(float,SDL_acosf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_asinf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_atanf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_atan2f,(float a, float b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_ceilf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_copysignf,(float a, float b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_fabsf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_floorf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_logf,(float a),(a),return) SDL_DYNAPI_PROC(float,SDL_powf,(float a, float b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_scalbnf,(float a, int b),(a,b),return) SDL_DYNAPI_PROC(double,SDL_fmod,(double a, double b),(a,b),return) SDL_DYNAPI_PROC(float,SDL_fmodf,(float a, float b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_SetYUVConversionMode,(SDL_YUV_CONVERSION_MODE a),(a),) SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionMode,(void),(),return) SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return) SDL_DYNAPI_PROC(void*,SDL_RenderGetMetalLayer,(SDL_Renderer *a),(a),return) SDL_DYNAPI_PROC(void*,SDL_RenderGetMetalCommandEncoder,(SDL_Renderer *a),(a),return) #ifdef __WINRT__ SDL_DYNAPI_PROC(SDL_WinRT_DeviceFamily,SDL_WinRTGetDeviceFamily,(void),(),return) #endif #ifdef __ANDROID__ SDL_DYNAPI_PROC(SDL_bool,SDL_IsAndroidTV,(void),(),return) #endif SDL_DYNAPI_PROC(double,SDL_log10,(double a),(a),return) SDL_DYNAPI_PROC(float,SDL_log10f,(float a),(a),return) SDL_DYNAPI_PROC(char*,SDL_GameControllerMappingForDeviceIndex,(int a),(a),return) #ifdef __LINUX__ SDL_DYNAPI_PROC(int,SDL_LinuxSetThreadPriority,(Sint64 a, int b),(a,b),return) #endif SDL_DYNAPI_PROC(SDL_bool,SDL_HasAVX512F,(void),(),return) #ifdef __ANDROID__ SDL_DYNAPI_PROC(SDL_bool,SDL_IsChromebook,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_IsDeXMode,(void),(),return) SDL_DYNAPI_PROC(void,SDL_AndroidBackButton,(void),(),return) #endif SDL_DYNAPI_PROC(double,SDL_exp,(double a),(a),return) SDL_DYNAPI_PROC(float,SDL_expf,(float a),(a),return) SDL_DYNAPI_PROC(wchar_t*,SDL_wcsdup,(const wchar_t *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GameControllerRumble,(SDL_GameController *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_JoystickRumble,(SDL_Joystick *a, Uint16 b, Uint16 c, Uint32 d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_NumSensors,(void),(),return) SDL_DYNAPI_PROC(const char*,SDL_SensorGetDeviceName,(int a),(a),return) SDL_DYNAPI_PROC(SDL_SensorType,SDL_SensorGetDeviceType,(int a),(a),return) SDL_DYNAPI_PROC(int,SDL_SensorGetDeviceNonPortableType,(int a),(a),return) SDL_DYNAPI_PROC(SDL_SensorID,SDL_SensorGetDeviceInstanceID,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Sensor*,SDL_SensorOpen,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Sensor*,SDL_SensorFromInstanceID,(SDL_SensorID a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_SensorGetName,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(SDL_SensorType,SDL_SensorGetType,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SensorGetNonPortableType,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(SDL_SensorID,SDL_SensorGetInstanceID,(SDL_Sensor *a),(a),return) SDL_DYNAPI_PROC(int,SDL_SensorGetData,(SDL_Sensor *a, float *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(void,SDL_SensorClose,(SDL_Sensor *a),(a),) SDL_DYNAPI_PROC(void,SDL_SensorUpdate,(void),(),) SDL_DYNAPI_PROC(SDL_bool,SDL_IsTablet,(void),(),return) SDL_DYNAPI_PROC(SDL_DisplayOrientation,SDL_GetDisplayOrientation,(int a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_HasColorKey,(SDL_Surface *a),(a),return)
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\blank_cursor.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * A default blank 8x8 cursor */ #define BLANK_CWIDTH 8 #define BLANK_CHEIGHT 8 #define BLANK_CHOTX 0 #define BLANK_CHOTY 0 static const unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; static const unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\scancodes_darwin.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* Mac virtual key code to SDL scancode mapping table Sources: - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html> - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c> - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard */ /* *INDENT-OFF* */ static const SDL_Scancode darwin_scancode_table[] = { /* 0 */ SDL_SCANCODE_A, /* 1 */ SDL_SCANCODE_S, /* 2 */ SDL_SCANCODE_D, /* 3 */ SDL_SCANCODE_F, /* 4 */ SDL_SCANCODE_H, /* 5 */ SDL_SCANCODE_G, /* 6 */ SDL_SCANCODE_Z, /* 7 */ SDL_SCANCODE_X, /* 8 */ SDL_SCANCODE_C, /* 9 */ SDL_SCANCODE_V, /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */ /* 11 */ SDL_SCANCODE_B, /* 12 */ SDL_SCANCODE_Q, /* 13 */ SDL_SCANCODE_W, /* 14 */ SDL_SCANCODE_E, /* 15 */ SDL_SCANCODE_R, /* 16 */ SDL_SCANCODE_Y, /* 17 */ SDL_SCANCODE_T, /* 18 */ SDL_SCANCODE_1, /* 19 */ SDL_SCANCODE_2, /* 20 */ SDL_SCANCODE_3, /* 21 */ SDL_SCANCODE_4, /* 22 */ SDL_SCANCODE_6, /* 23 */ SDL_SCANCODE_5, /* 24 */ SDL_SCANCODE_EQUALS, /* 25 */ SDL_SCANCODE_9, /* 26 */ SDL_SCANCODE_7, /* 27 */ SDL_SCANCODE_MINUS, /* 28 */ SDL_SCANCODE_8, /* 29 */ SDL_SCANCODE_0, /* 30 */ SDL_SCANCODE_RIGHTBRACKET, /* 31 */ SDL_SCANCODE_O, /* 32 */ SDL_SCANCODE_U, /* 33 */ SDL_SCANCODE_LEFTBRACKET, /* 34 */ SDL_SCANCODE_I, /* 35 */ SDL_SCANCODE_P, /* 36 */ SDL_SCANCODE_RETURN, /* 37 */ SDL_SCANCODE_L, /* 38 */ SDL_SCANCODE_J, /* 39 */ SDL_SCANCODE_APOSTROPHE, /* 40 */ SDL_SCANCODE_K, /* 41 */ SDL_SCANCODE_SEMICOLON, /* 42 */ SDL_SCANCODE_BACKSLASH, /* 43 */ SDL_SCANCODE_COMMA, /* 44 */ SDL_SCANCODE_SLASH, /* 45 */ SDL_SCANCODE_N, /* 46 */ SDL_SCANCODE_M, /* 47 */ SDL_SCANCODE_PERIOD, /* 48 */ SDL_SCANCODE_TAB, /* 49 */ SDL_SCANCODE_SPACE, /* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */ /* 51 */ SDL_SCANCODE_BACKSPACE, /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */ /* 53 */ SDL_SCANCODE_ESCAPE, /* 54 */ SDL_SCANCODE_RGUI, /* 55 */ SDL_SCANCODE_LGUI, /* 56 */ SDL_SCANCODE_LSHIFT, /* 57 */ SDL_SCANCODE_CAPSLOCK, /* 58 */ SDL_SCANCODE_LALT, /* 59 */ SDL_SCANCODE_LCTRL, /* 60 */ SDL_SCANCODE_RSHIFT, /* 61 */ SDL_SCANCODE_RALT, /* 62 */ SDL_SCANCODE_RCTRL, /* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */ /* 64 */ SDL_SCANCODE_F17, /* 65 */ SDL_SCANCODE_KP_PERIOD, /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 67 */ SDL_SCANCODE_KP_MULTIPLY, /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 69 */ SDL_SCANCODE_KP_PLUS, /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 72 */ SDL_SCANCODE_VOLUMEUP, /* 73 */ SDL_SCANCODE_VOLUMEDOWN, /* 74 */ SDL_SCANCODE_MUTE, /* 75 */ SDL_SCANCODE_KP_DIVIDE, /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */ /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 78 */ SDL_SCANCODE_KP_MINUS, /* 79 */ SDL_SCANCODE_F18, /* 80 */ SDL_SCANCODE_F19, /* 81 */ SDL_SCANCODE_KP_EQUALS, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_1, /* 84 */ SDL_SCANCODE_KP_2, /* 85 */ SDL_SCANCODE_KP_3, /* 86 */ SDL_SCANCODE_KP_4, /* 87 */ SDL_SCANCODE_KP_5, /* 88 */ SDL_SCANCODE_KP_6, /* 89 */ SDL_SCANCODE_KP_7, /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 91 */ SDL_SCANCODE_KP_8, /* 92 */ SDL_SCANCODE_KP_9, /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */ /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */ /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */ /* 96 */ SDL_SCANCODE_F5, /* 97 */ SDL_SCANCODE_F6, /* 98 */ SDL_SCANCODE_F7, /* 99 */ SDL_SCANCODE_F3, /* 100 */ SDL_SCANCODE_F8, /* 101 */ SDL_SCANCODE_F9, /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */ /* 103 */ SDL_SCANCODE_F11, /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */ /* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */ /* 106 */ SDL_SCANCODE_F16, /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */ /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 109 */ SDL_SCANCODE_F10, /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */ /* 111 */ SDL_SCANCODE_F12, /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */ /* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */ /* 115 */ SDL_SCANCODE_HOME, /* 116 */ SDL_SCANCODE_PAGEUP, /* 117 */ SDL_SCANCODE_DELETE, /* 118 */ SDL_SCANCODE_F4, /* 119 */ SDL_SCANCODE_END, /* 120 */ SDL_SCANCODE_F2, /* 121 */ SDL_SCANCODE_PAGEDOWN, /* 122 */ SDL_SCANCODE_F1, /* 123 */ SDL_SCANCODE_LEFT, /* 124 */ SDL_SCANCODE_RIGHT, /* 125 */ SDL_SCANCODE_DOWN, /* 126 */ SDL_SCANCODE_UP, /* 127 */ SDL_SCANCODE_POWER }; /* *INDENT-ON* */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\scancodes_linux.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" /* Linux virtual key code to SDL_Keycode mapping table Sources: - Linux kernel source input.h */ /* *INDENT-OFF* */ static SDL_Scancode const linux_scancode_table[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, /* 3 */ SDL_SCANCODE_2, /* 4 */ SDL_SCANCODE_3, /* 5 */ SDL_SCANCODE_4, /* 6 */ SDL_SCANCODE_5, /* 7 */ SDL_SCANCODE_6, /* 8 */ SDL_SCANCODE_7, /* 9 */ SDL_SCANCODE_8, /* 10 */ SDL_SCANCODE_9, /* 11 */ SDL_SCANCODE_0, /* 12 */ SDL_SCANCODE_MINUS, /* 13 */ SDL_SCANCODE_EQUALS, /* 14 */ SDL_SCANCODE_BACKSPACE, /* 15 */ SDL_SCANCODE_TAB, /* 16 */ SDL_SCANCODE_Q, /* 17 */ SDL_SCANCODE_W, /* 18 */ SDL_SCANCODE_E, /* 19 */ SDL_SCANCODE_R, /* 20 */ SDL_SCANCODE_T, /* 21 */ SDL_SCANCODE_Y, /* 22 */ SDL_SCANCODE_U, /* 23 */ SDL_SCANCODE_I, /* 24 */ SDL_SCANCODE_O, /* 25 */ SDL_SCANCODE_P, /* 26 */ SDL_SCANCODE_LEFTBRACKET, /* 27 */ SDL_SCANCODE_RIGHTBRACKET, /* 28 */ SDL_SCANCODE_RETURN, /* 29 */ SDL_SCANCODE_LCTRL, /* 30 */ SDL_SCANCODE_A, /* 31 */ SDL_SCANCODE_S, /* 32 */ SDL_SCANCODE_D, /* 33 */ SDL_SCANCODE_F, /* 34 */ SDL_SCANCODE_G, /* 35 */ SDL_SCANCODE_H, /* 36 */ SDL_SCANCODE_J, /* 37 */ SDL_SCANCODE_K, /* 38 */ SDL_SCANCODE_L, /* 39 */ SDL_SCANCODE_SEMICOLON, /* 40 */ SDL_SCANCODE_APOSTROPHE, /* 41 */ SDL_SCANCODE_GRAVE, /* 42 */ SDL_SCANCODE_LSHIFT, /* 43 */ SDL_SCANCODE_BACKSLASH, /* 44 */ SDL_SCANCODE_Z, /* 45 */ SDL_SCANCODE_X, /* 46 */ SDL_SCANCODE_C, /* 47 */ SDL_SCANCODE_V, /* 48 */ SDL_SCANCODE_B, /* 49 */ SDL_SCANCODE_N, /* 50 */ SDL_SCANCODE_M, /* 51 */ SDL_SCANCODE_COMMA, /* 52 */ SDL_SCANCODE_PERIOD, /* 53 */ SDL_SCANCODE_SLASH, /* 54 */ SDL_SCANCODE_RSHIFT, /* 55 */ SDL_SCANCODE_KP_MULTIPLY, /* 56 */ SDL_SCANCODE_LALT, /* 57 */ SDL_SCANCODE_SPACE, /* 58 */ SDL_SCANCODE_CAPSLOCK, /* 59 */ SDL_SCANCODE_F1, /* 60 */ SDL_SCANCODE_F2, /* 61 */ SDL_SCANCODE_F3, /* 62 */ SDL_SCANCODE_F4, /* 63 */ SDL_SCANCODE_F5, /* 64 */ SDL_SCANCODE_F6, /* 65 */ SDL_SCANCODE_F7, /* 66 */ SDL_SCANCODE_F8, /* 67 */ SDL_SCANCODE_F9, /* 68 */ SDL_SCANCODE_F10, /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 70 */ SDL_SCANCODE_SCROLLLOCK, /* 71 */ SDL_SCANCODE_KP_7, /* 72 */ SDL_SCANCODE_KP_8, /* 73 */ SDL_SCANCODE_KP_9, /* 74 */ SDL_SCANCODE_KP_MINUS, /* 75 */ SDL_SCANCODE_KP_4, /* 76 */ SDL_SCANCODE_KP_5, /* 77 */ SDL_SCANCODE_KP_6, /* 78 */ SDL_SCANCODE_KP_PLUS, /* 79 */ SDL_SCANCODE_KP_1, /* 80 */ SDL_SCANCODE_KP_2, /* 81 */ SDL_SCANCODE_KP_3, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_PERIOD, 0, /* 85 */ SDL_SCANCODE_LANG5, /* KEY_ZENKAKUHANKAKU */ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* KEY_102ND */ /* 87 */ SDL_SCANCODE_F11, /* 88 */ SDL_SCANCODE_F12, /* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* KEY_RO */ /* 90 */ SDL_SCANCODE_LANG3, /* KEY_KATAKANA */ /* 91 */ SDL_SCANCODE_LANG4, /* KEY_HIRAGANA */ /* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* KEY_HENKAN */ /* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* KEY_KATAKANAHIRAGANA */ /* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_MUHENKAN */ /* 95 */ SDL_SCANCODE_INTERNATIONAL5, /* KEY_KPJPCOMMA */ /* 96 */ SDL_SCANCODE_KP_ENTER, /* 97 */ SDL_SCANCODE_RCTRL, /* 98 */ SDL_SCANCODE_KP_DIVIDE, /* 99 */ SDL_SCANCODE_SYSREQ, /* 100 */ SDL_SCANCODE_RALT, /* 101 */ SDL_SCANCODE_UNKNOWN, /* KEY_LINEFEED */ /* 102 */ SDL_SCANCODE_HOME, /* 103 */ SDL_SCANCODE_UP, /* 104 */ SDL_SCANCODE_PAGEUP, /* 105 */ SDL_SCANCODE_LEFT, /* 106 */ SDL_SCANCODE_RIGHT, /* 107 */ SDL_SCANCODE_END, /* 108 */ SDL_SCANCODE_DOWN, /* 109 */ SDL_SCANCODE_PAGEDOWN, /* 110 */ SDL_SCANCODE_INSERT, /* 111 */ SDL_SCANCODE_DELETE, /* 112 */ SDL_SCANCODE_UNKNOWN, /* KEY_MACRO */ /* 113 */ SDL_SCANCODE_MUTE, /* 114 */ SDL_SCANCODE_VOLUMEDOWN, /* 115 */ SDL_SCANCODE_VOLUMEUP, /* 116 */ SDL_SCANCODE_POWER, /* 117 */ SDL_SCANCODE_KP_EQUALS, /* 118 */ SDL_SCANCODE_KP_PLUSMINUS, /* 119 */ SDL_SCANCODE_PAUSE, 0, /* 121 */ SDL_SCANCODE_KP_COMMA, /* 122 */ SDL_SCANCODE_LANG1, /* KEY_HANGUEL */ /* 123 */ SDL_SCANCODE_LANG2, /* KEY_HANJA */ /* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* KEY_YEN */ /* 125 */ SDL_SCANCODE_LGUI, /* 126 */ SDL_SCANCODE_RGUI, /* 127 */ SDL_SCANCODE_APPLICATION, /* KEY_COMPOSE */ /* 128 */ SDL_SCANCODE_STOP, /* 129 */ SDL_SCANCODE_AGAIN, /* 130 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROPS */ /* 131 */ SDL_SCANCODE_UNDO, /* 132 */ SDL_SCANCODE_UNKNOWN, /* KEY_FRONT */ /* 133 */ SDL_SCANCODE_COPY, /* 134 */ SDL_SCANCODE_UNKNOWN, /* KEY_OPEN */ /* 135 */ SDL_SCANCODE_PASTE, /* 136 */ SDL_SCANCODE_FIND, /* 137 */ SDL_SCANCODE_CUT, /* 138 */ SDL_SCANCODE_HELP, /* 139 */ SDL_SCANCODE_MENU, /* 140 */ SDL_SCANCODE_CALCULATOR, /* 141 */ SDL_SCANCODE_UNKNOWN, /* KEY_SETUP */ /* 142 */ SDL_SCANCODE_SLEEP, /* 143 */ SDL_SCANCODE_UNKNOWN, /* KEY_WAKEUP */ /* 144 */ SDL_SCANCODE_UNKNOWN, /* KEY_FILE */ /* 145 */ SDL_SCANCODE_UNKNOWN, /* KEY_SENDFILE */ /* 146 */ SDL_SCANCODE_UNKNOWN, /* KEY_DELETEFILE */ /* 147 */ SDL_SCANCODE_UNKNOWN, /* KEY_XFER */ /* 148 */ SDL_SCANCODE_APP1, /* KEY_PROG1 */ /* 149 */ SDL_SCANCODE_APP2, /* KEY_PROG2 */ /* 150 */ SDL_SCANCODE_WWW, /* KEY_WWW */ /* 151 */ SDL_SCANCODE_UNKNOWN, /* KEY_MSDOS */ /* 152 */ SDL_SCANCODE_UNKNOWN, /* KEY_COFFEE */ /* 153 */ SDL_SCANCODE_UNKNOWN, /* KEY_DIRECTION */ /* 154 */ SDL_SCANCODE_UNKNOWN, /* KEY_CYCLEWINDOWS */ /* 155 */ SDL_SCANCODE_MAIL, /* 156 */ SDL_SCANCODE_AC_BOOKMARKS, /* 157 */ SDL_SCANCODE_COMPUTER, /* 158 */ SDL_SCANCODE_AC_BACK, /* 159 */ SDL_SCANCODE_AC_FORWARD, /* 160 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSECD */ /* 161 */ SDL_SCANCODE_EJECT, /* KEY_EJECTCD */ /* 162 */ SDL_SCANCODE_UNKNOWN, /* KEY_EJECTCLOSECD */ /* 163 */ SDL_SCANCODE_AUDIONEXT, /* KEY_NEXTSONG */ /* 164 */ SDL_SCANCODE_AUDIOPLAY, /* KEY_PLAYPAUSE */ /* 165 */ SDL_SCANCODE_AUDIOPREV, /* KEY_PREVIOUSSONG */ /* 166 */ SDL_SCANCODE_AUDIOSTOP, /* KEY_STOPCD */ /* 167 */ SDL_SCANCODE_UNKNOWN, /* KEY_RECORD */ /* 168 */ SDL_SCANCODE_AUDIOREWIND, /* KEY_REWIND */ /* 169 */ SDL_SCANCODE_UNKNOWN, /* KEY_PHONE */ /* 170 */ SDL_SCANCODE_UNKNOWN, /* KEY_ISO */ /* 171 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONFIG */ /* 172 */ SDL_SCANCODE_AC_HOME, /* 173 */ SDL_SCANCODE_AC_REFRESH, /* 174 */ SDL_SCANCODE_UNKNOWN, /* KEY_EXIT */ /* 175 */ SDL_SCANCODE_UNKNOWN, /* KEY_MOVE */ /* 176 */ SDL_SCANCODE_UNKNOWN, /* KEY_EDIT */ /* 177 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLUP */ /* 178 */ SDL_SCANCODE_UNKNOWN, /* KEY_SCROLLDOWN */ /* 179 */ SDL_SCANCODE_KP_LEFTPAREN, /* 180 */ SDL_SCANCODE_KP_RIGHTPAREN, /* 181 */ SDL_SCANCODE_UNKNOWN, /* KEY_NEW */ /* 182 */ SDL_SCANCODE_UNKNOWN, /* KEY_REDO */ /* 183 */ SDL_SCANCODE_F13, /* 184 */ SDL_SCANCODE_F14, /* 185 */ SDL_SCANCODE_F15, /* 186 */ SDL_SCANCODE_F16, /* 187 */ SDL_SCANCODE_F17, /* 188 */ SDL_SCANCODE_F18, /* 189 */ SDL_SCANCODE_F19, /* 190 */ SDL_SCANCODE_F20, /* 191 */ SDL_SCANCODE_F21, /* 192 */ SDL_SCANCODE_F22, /* 193 */ SDL_SCANCODE_F23, /* 194 */ SDL_SCANCODE_F24, 0, 0, 0, 0, 0, /* 200 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAYCD */ /* 201 */ SDL_SCANCODE_UNKNOWN, /* KEY_PAUSECD */ /* 202 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG3 */ /* 203 */ SDL_SCANCODE_UNKNOWN, /* KEY_PROG4 */ 0, /* 205 */ SDL_SCANCODE_UNKNOWN, /* KEY_SUSPEND */ /* 206 */ SDL_SCANCODE_UNKNOWN, /* KEY_CLOSE */ /* 207 */ SDL_SCANCODE_UNKNOWN, /* KEY_PLAY */ /* 208 */ SDL_SCANCODE_AUDIOFASTFORWARD, /* KEY_FASTFORWARD */ /* 209 */ SDL_SCANCODE_UNKNOWN, /* KEY_BASSBOOST */ /* 210 */ SDL_SCANCODE_UNKNOWN, /* KEY_PRINT */ /* 211 */ SDL_SCANCODE_UNKNOWN, /* KEY_HP */ /* 212 */ SDL_SCANCODE_UNKNOWN, /* KEY_CAMERA */ /* 213 */ SDL_SCANCODE_UNKNOWN, /* KEY_SOUND */ /* 214 */ SDL_SCANCODE_UNKNOWN, /* KEY_QUESTION */ /* 215 */ SDL_SCANCODE_UNKNOWN, /* KEY_EMAIL */ /* 216 */ SDL_SCANCODE_UNKNOWN, /* KEY_CHAT */ /* 217 */ SDL_SCANCODE_AC_SEARCH, /* 218 */ SDL_SCANCODE_UNKNOWN, /* KEY_CONNECT */ /* 219 */ SDL_SCANCODE_UNKNOWN, /* KEY_FINANCE */ /* 220 */ SDL_SCANCODE_UNKNOWN, /* KEY_SPORT */ /* 221 */ SDL_SCANCODE_UNKNOWN, /* KEY_SHOP */ /* 222 */ SDL_SCANCODE_ALTERASE, /* 223 */ SDL_SCANCODE_CANCEL, /* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* 225 */ SDL_SCANCODE_BRIGHTNESSUP, /* 226 */ SDL_SCANCODE_UNKNOWN, /* KEY_MEDIA */ /* 227 */ SDL_SCANCODE_DISPLAYSWITCH, /* KEY_SWITCHVIDEOMODE */ /* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE, /* 229 */ SDL_SCANCODE_KBDILLUMDOWN, /* 230 */ SDL_SCANCODE_KBDILLUMUP, /* 231 */ SDL_SCANCODE_UNKNOWN, /* KEY_SEND */ /* 232 */ SDL_SCANCODE_UNKNOWN, /* KEY_REPLY */ /* 233 */ SDL_SCANCODE_UNKNOWN, /* KEY_FORWARDMAIL */ /* 234 */ SDL_SCANCODE_UNKNOWN, /* KEY_SAVE */ /* 235 */ SDL_SCANCODE_UNKNOWN, /* KEY_DOCUMENTS */ /* 236 */ SDL_SCANCODE_UNKNOWN, /* KEY_BATTERY */ }; /* *INDENT-ON* */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\scancodes_windows.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" /* Windows scancode to SDL scancode mapping table */ /* derived from Microsoft scan code document, http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc */ /* *INDENT-OFF* */ static const SDL_Scancode windows_scancode_table[] = { /* 0 1 2 3 4 5 6 7 */ /* 8 9 A B C D E F */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_1, SDL_SCANCODE_2, SDL_SCANCODE_3, SDL_SCANCODE_4, SDL_SCANCODE_5, SDL_SCANCODE_6, /* 0 */ SDL_SCANCODE_7, SDL_SCANCODE_8, SDL_SCANCODE_9, SDL_SCANCODE_0, SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, SDL_SCANCODE_BACKSPACE, SDL_SCANCODE_TAB, /* 0 */ SDL_SCANCODE_Q, SDL_SCANCODE_W, SDL_SCANCODE_E, SDL_SCANCODE_R, SDL_SCANCODE_T, SDL_SCANCODE_Y, SDL_SCANCODE_U, SDL_SCANCODE_I, /* 1 */ SDL_SCANCODE_O, SDL_SCANCODE_P, SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_RETURN, SDL_SCANCODE_LCTRL, SDL_SCANCODE_A, SDL_SCANCODE_S, /* 1 */ SDL_SCANCODE_D, SDL_SCANCODE_F, SDL_SCANCODE_G, SDL_SCANCODE_H, SDL_SCANCODE_J, SDL_SCANCODE_K, SDL_SCANCODE_L, SDL_SCANCODE_SEMICOLON, /* 2 */ SDL_SCANCODE_APOSTROPHE, SDL_SCANCODE_GRAVE, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_Z, SDL_SCANCODE_X, SDL_SCANCODE_C, SDL_SCANCODE_V, /* 2 */ SDL_SCANCODE_B, SDL_SCANCODE_N, SDL_SCANCODE_M, SDL_SCANCODE_COMMA, SDL_SCANCODE_PERIOD, SDL_SCANCODE_SLASH, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_PRINTSCREEN,/* 3 */ SDL_SCANCODE_LALT, SDL_SCANCODE_SPACE, SDL_SCANCODE_CAPSLOCK, SDL_SCANCODE_F1, SDL_SCANCODE_F2, SDL_SCANCODE_F3, SDL_SCANCODE_F4, SDL_SCANCODE_F5, /* 3 */ SDL_SCANCODE_F6, SDL_SCANCODE_F7, SDL_SCANCODE_F8, SDL_SCANCODE_F9, SDL_SCANCODE_F10, SDL_SCANCODE_NUMLOCKCLEAR, SDL_SCANCODE_SCROLLLOCK, SDL_SCANCODE_HOME, /* 4 */ SDL_SCANCODE_UP, SDL_SCANCODE_PAGEUP, SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_LEFT, SDL_SCANCODE_KP_5, SDL_SCANCODE_RIGHT, SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_END, /* 4 */ SDL_SCANCODE_DOWN, SDL_SCANCODE_PAGEDOWN, SDL_SCANCODE_INSERT, SDL_SCANCODE_DELETE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_NONUSBACKSLASH,SDL_SCANCODE_F11, /* 5 */ SDL_SCANCODE_F12, SDL_SCANCODE_PAUSE, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_LGUI, SDL_SCANCODE_RGUI, SDL_SCANCODE_APPLICATION, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 5 */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_F13, SDL_SCANCODE_F14, SDL_SCANCODE_F15, SDL_SCANCODE_F16, /* 6 */ SDL_SCANCODE_F17, SDL_SCANCODE_F18, SDL_SCANCODE_F19, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 6 */ SDL_SCANCODE_INTERNATIONAL2, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL1, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, /* 7 */ SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL4, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL5, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL3, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */ }; /* *INDENT-ON* */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\scancodes_xfree86.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" /* XFree86 key code to SDL scancode mapping table Sources: - atKeyNames.h from XFree86 source code */ /* *INDENT-OFF* */ static const SDL_Scancode xfree86_scancode_table[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, /* 3 */ SDL_SCANCODE_2, /* 4 */ SDL_SCANCODE_3, /* 5 */ SDL_SCANCODE_4, /* 6 */ SDL_SCANCODE_5, /* 7 */ SDL_SCANCODE_6, /* 8 */ SDL_SCANCODE_7, /* 9 */ SDL_SCANCODE_8, /* 10 */ SDL_SCANCODE_9, /* 11 */ SDL_SCANCODE_0, /* 12 */ SDL_SCANCODE_MINUS, /* 13 */ SDL_SCANCODE_EQUALS, /* 14 */ SDL_SCANCODE_BACKSPACE, /* 15 */ SDL_SCANCODE_TAB, /* 16 */ SDL_SCANCODE_Q, /* 17 */ SDL_SCANCODE_W, /* 18 */ SDL_SCANCODE_E, /* 19 */ SDL_SCANCODE_R, /* 20 */ SDL_SCANCODE_T, /* 21 */ SDL_SCANCODE_Y, /* 22 */ SDL_SCANCODE_U, /* 23 */ SDL_SCANCODE_I, /* 24 */ SDL_SCANCODE_O, /* 25 */ SDL_SCANCODE_P, /* 26 */ SDL_SCANCODE_LEFTBRACKET, /* 27 */ SDL_SCANCODE_RIGHTBRACKET, /* 28 */ SDL_SCANCODE_RETURN, /* 29 */ SDL_SCANCODE_LCTRL, /* 30 */ SDL_SCANCODE_A, /* 31 */ SDL_SCANCODE_S, /* 32 */ SDL_SCANCODE_D, /* 33 */ SDL_SCANCODE_F, /* 34 */ SDL_SCANCODE_G, /* 35 */ SDL_SCANCODE_H, /* 36 */ SDL_SCANCODE_J, /* 37 */ SDL_SCANCODE_K, /* 38 */ SDL_SCANCODE_L, /* 39 */ SDL_SCANCODE_SEMICOLON, /* 40 */ SDL_SCANCODE_APOSTROPHE, /* 41 */ SDL_SCANCODE_GRAVE, /* 42 */ SDL_SCANCODE_LSHIFT, /* 43 */ SDL_SCANCODE_BACKSLASH, /* 44 */ SDL_SCANCODE_Z, /* 45 */ SDL_SCANCODE_X, /* 46 */ SDL_SCANCODE_C, /* 47 */ SDL_SCANCODE_V, /* 48 */ SDL_SCANCODE_B, /* 49 */ SDL_SCANCODE_N, /* 50 */ SDL_SCANCODE_M, /* 51 */ SDL_SCANCODE_COMMA, /* 52 */ SDL_SCANCODE_PERIOD, /* 53 */ SDL_SCANCODE_SLASH, /* 54 */ SDL_SCANCODE_RSHIFT, /* 55 */ SDL_SCANCODE_KP_MULTIPLY, /* 56 */ SDL_SCANCODE_LALT, /* 57 */ SDL_SCANCODE_SPACE, /* 58 */ SDL_SCANCODE_CAPSLOCK, /* 59 */ SDL_SCANCODE_F1, /* 60 */ SDL_SCANCODE_F2, /* 61 */ SDL_SCANCODE_F3, /* 62 */ SDL_SCANCODE_F4, /* 63 */ SDL_SCANCODE_F5, /* 64 */ SDL_SCANCODE_F6, /* 65 */ SDL_SCANCODE_F7, /* 66 */ SDL_SCANCODE_F8, /* 67 */ SDL_SCANCODE_F9, /* 68 */ SDL_SCANCODE_F10, /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 70 */ SDL_SCANCODE_SCROLLLOCK, /* 71 */ SDL_SCANCODE_KP_7, /* 72 */ SDL_SCANCODE_KP_8, /* 73 */ SDL_SCANCODE_KP_9, /* 74 */ SDL_SCANCODE_KP_MINUS, /* 75 */ SDL_SCANCODE_KP_4, /* 76 */ SDL_SCANCODE_KP_5, /* 77 */ SDL_SCANCODE_KP_6, /* 78 */ SDL_SCANCODE_KP_PLUS, /* 79 */ SDL_SCANCODE_KP_1, /* 80 */ SDL_SCANCODE_KP_2, /* 81 */ SDL_SCANCODE_KP_3, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_PERIOD, /* 84 */ SDL_SCANCODE_SYSREQ, /* 85 */ SDL_SCANCODE_MODE, /* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* 87 */ SDL_SCANCODE_F11, /* 88 */ SDL_SCANCODE_F12, /* 89 */ SDL_SCANCODE_HOME, /* 90 */ SDL_SCANCODE_UP, /* 91 */ SDL_SCANCODE_PAGEUP, /* 92 */ SDL_SCANCODE_LEFT, /* 93 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* on PowerBook G4 / KEY_Begin */ /* 94 */ SDL_SCANCODE_RIGHT, /* 95 */ SDL_SCANCODE_END, /* 96 */ SDL_SCANCODE_DOWN, /* 97 */ SDL_SCANCODE_PAGEDOWN, /* 98 */ SDL_SCANCODE_INSERT, /* 99 */ SDL_SCANCODE_DELETE, /* 100 */ SDL_SCANCODE_KP_ENTER, /* 101 */ SDL_SCANCODE_RCTRL, /* 102 */ SDL_SCANCODE_PAUSE, /* 103 */ SDL_SCANCODE_PRINTSCREEN, /* 104 */ SDL_SCANCODE_KP_DIVIDE, /* 105 */ SDL_SCANCODE_RALT, /* 106 */ SDL_SCANCODE_UNKNOWN, /* BREAK */ /* 107 */ SDL_SCANCODE_LGUI, /* 108 */ SDL_SCANCODE_RGUI, /* 109 */ SDL_SCANCODE_APPLICATION, /* 110 */ SDL_SCANCODE_F13, /* 111 */ SDL_SCANCODE_F14, /* 112 */ SDL_SCANCODE_F15, /* 113 */ SDL_SCANCODE_F16, /* 114 */ SDL_SCANCODE_F17, /* 115 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */ /* 116 */ SDL_SCANCODE_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDL_SCANCODE_* for it is */ /* 117 */ SDL_SCANCODE_UNKNOWN, /* 118 */ SDL_SCANCODE_KP_EQUALS, /* 119 */ SDL_SCANCODE_UNKNOWN, /* 120 */ SDL_SCANCODE_UNKNOWN, /* 121 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */ /* 122 */ SDL_SCANCODE_UNKNOWN, /* 123 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */ /* 124 */ SDL_SCANCODE_UNKNOWN, /* 125 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */ /* 126 */ SDL_SCANCODE_UNKNOWN, /* 127 */ SDL_SCANCODE_UNKNOWN, /* 128 */ SDL_SCANCODE_UNKNOWN, /* 129 */ SDL_SCANCODE_UNKNOWN, /* 130 */ SDL_SCANCODE_UNKNOWN, /* 131 */ SDL_SCANCODE_UNKNOWN, /* 132 */ SDL_SCANCODE_POWER, /* 133 */ SDL_SCANCODE_MUTE, /* 134 */ SDL_SCANCODE_VOLUMEDOWN, /* 135 */ SDL_SCANCODE_VOLUMEUP, /* 136 */ SDL_SCANCODE_HELP, /* 137 */ SDL_SCANCODE_STOP, /* 138 */ SDL_SCANCODE_AGAIN, /* 139 */ SDL_SCANCODE_UNKNOWN, /* PROPS */ /* 140 */ SDL_SCANCODE_UNDO, /* 141 */ SDL_SCANCODE_UNKNOWN, /* FRONT */ /* 142 */ SDL_SCANCODE_COPY, /* 143 */ SDL_SCANCODE_UNKNOWN, /* OPEN */ /* 144 */ SDL_SCANCODE_PASTE, /* 145 */ SDL_SCANCODE_FIND, /* 146 */ SDL_SCANCODE_CUT, }; /* for wireless usb keyboard (manufacturer TRUST) without numpad. */ static const SDL_Scancode xfree86_scancode_table2[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, /* 3 */ SDL_SCANCODE_2, /* 4 */ SDL_SCANCODE_3, /* 5 */ SDL_SCANCODE_4, /* 6 */ SDL_SCANCODE_5, /* 7 */ SDL_SCANCODE_6, /* 8 */ SDL_SCANCODE_7, /* 9 */ SDL_SCANCODE_8, /* 10 */ SDL_SCANCODE_9, /* 11 */ SDL_SCANCODE_0, /* 12 */ SDL_SCANCODE_MINUS, /* 13 */ SDL_SCANCODE_EQUALS, /* 14 */ SDL_SCANCODE_BACKSPACE, /* 15 */ SDL_SCANCODE_TAB, /* 16 */ SDL_SCANCODE_Q, /* 17 */ SDL_SCANCODE_W, /* 18 */ SDL_SCANCODE_E, /* 19 */ SDL_SCANCODE_R, /* 20 */ SDL_SCANCODE_T, /* 21 */ SDL_SCANCODE_Y, /* 22 */ SDL_SCANCODE_U, /* 23 */ SDL_SCANCODE_I, /* 24 */ SDL_SCANCODE_O, /* 25 */ SDL_SCANCODE_P, /* 26 */ SDL_SCANCODE_LEFTBRACKET, /* 27 */ SDL_SCANCODE_RIGHTBRACKET, /* 28 */ SDL_SCANCODE_RETURN, /* 29 */ SDL_SCANCODE_LCTRL, /* 30 */ SDL_SCANCODE_A, /* 31 */ SDL_SCANCODE_S, /* 32 */ SDL_SCANCODE_D, /* 33 */ SDL_SCANCODE_F, /* 34 */ SDL_SCANCODE_G, /* 35 */ SDL_SCANCODE_H, /* 36 */ SDL_SCANCODE_J, /* 37 */ SDL_SCANCODE_K, /* 38 */ SDL_SCANCODE_L, /* 39 */ SDL_SCANCODE_SEMICOLON, /* 40 */ SDL_SCANCODE_APOSTROPHE, /* 41 */ SDL_SCANCODE_GRAVE, /* 42 */ SDL_SCANCODE_LSHIFT, /* 43 */ SDL_SCANCODE_BACKSLASH, /* 44 */ SDL_SCANCODE_Z, /* 45 */ SDL_SCANCODE_X, /* 46 */ SDL_SCANCODE_C, /* 47 */ SDL_SCANCODE_V, /* 48 */ SDL_SCANCODE_B, /* 49 */ SDL_SCANCODE_N, /* 50 */ SDL_SCANCODE_M, /* 51 */ SDL_SCANCODE_COMMA, /* 52 */ SDL_SCANCODE_PERIOD, /* 53 */ SDL_SCANCODE_SLASH, /* 54 */ SDL_SCANCODE_RSHIFT, /* 55 */ SDL_SCANCODE_KP_MULTIPLY, /* 56 */ SDL_SCANCODE_LALT, /* 57 */ SDL_SCANCODE_SPACE, /* 58 */ SDL_SCANCODE_CAPSLOCK, /* 59 */ SDL_SCANCODE_F1, /* 60 */ SDL_SCANCODE_F2, /* 61 */ SDL_SCANCODE_F3, /* 62 */ SDL_SCANCODE_F4, /* 63 */ SDL_SCANCODE_F5, /* 64 */ SDL_SCANCODE_F6, /* 65 */ SDL_SCANCODE_F7, /* 66 */ SDL_SCANCODE_F8, /* 67 */ SDL_SCANCODE_F9, /* 68 */ SDL_SCANCODE_F10, /* 69 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 70 */ SDL_SCANCODE_SCROLLLOCK, /* 71 */ SDL_SCANCODE_KP_7, /* 72 */ SDL_SCANCODE_KP_8, /* 73 */ SDL_SCANCODE_KP_9, /* 74 */ SDL_SCANCODE_KP_MINUS, /* 75 */ SDL_SCANCODE_KP_4, /* 76 */ SDL_SCANCODE_KP_5, /* 77 */ SDL_SCANCODE_KP_6, /* 78 */ SDL_SCANCODE_KP_PLUS, /* 79 */ SDL_SCANCODE_KP_1, /* 80 */ SDL_SCANCODE_KP_2, /* 81 */ SDL_SCANCODE_KP_3, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_PERIOD, /* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */ /* 85 */ SDL_SCANCODE_MODE, /* ???? */ /* 86 */ SDL_SCANCODE_NONUSBACKSLASH, /* 87 */ SDL_SCANCODE_F11, /* 88 */ SDL_SCANCODE_F12, /* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */ /* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */ /* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */ /* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */ /* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* Hiragana_Katakana */ /* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */ /* 95 */ SDL_SCANCODE_UNKNOWN, /* 96 */ SDL_SCANCODE_KP_ENTER, /* 97 */ SDL_SCANCODE_RCTRL, /* 98 */ SDL_SCANCODE_KP_DIVIDE, /* 99 */ SDL_SCANCODE_PRINTSCREEN, /* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */ /* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */ /* 102 */ SDL_SCANCODE_HOME, /* 103 */ SDL_SCANCODE_UP, /* 104 */ SDL_SCANCODE_PAGEUP, /* 105 */ SDL_SCANCODE_LEFT, /* 106 */ SDL_SCANCODE_RIGHT, /* 107 */ SDL_SCANCODE_END, /* 108 */ SDL_SCANCODE_DOWN, /* 109 */ SDL_SCANCODE_PAGEDOWN, /* 110 */ SDL_SCANCODE_INSERT, /* 111 */ SDL_SCANCODE_DELETE, /* 112 */ SDL_SCANCODE_UNKNOWN, /* 113 */ SDL_SCANCODE_MUTE, /* 114 */ SDL_SCANCODE_VOLUMEDOWN, /* 115 */ SDL_SCANCODE_VOLUMEUP, /* 116 */ SDL_SCANCODE_POWER, /* 117 */ SDL_SCANCODE_KP_EQUALS, /* 118 */ SDL_SCANCODE_UNKNOWN, /* plusminus */ /* 119 */ SDL_SCANCODE_PAUSE, /* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */ /* 121 */ SDL_SCANCODE_UNKNOWN, /* KP_Decimal */ /* 122 */ SDL_SCANCODE_UNKNOWN, /* Hangul */ /* 123 */ SDL_SCANCODE_UNKNOWN, /* Hangul_Hanja */ /* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */ /* 125 */ SDL_SCANCODE_LGUI, /* 126 */ SDL_SCANCODE_RGUI, /* 127 */ SDL_SCANCODE_APPLICATION, /* 128 */ SDL_SCANCODE_CANCEL, /* 129 */ SDL_SCANCODE_AGAIN, /* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */ /* 131 */ SDL_SCANCODE_UNDO, /* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */ /* 133 */ SDL_SCANCODE_COPY, /* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */ /* 135 */ SDL_SCANCODE_PASTE, /* 136 */ SDL_SCANCODE_FIND, /* 137 */ SDL_SCANCODE_CUT, /* 138 */ SDL_SCANCODE_HELP, /* 139 */ SDL_SCANCODE_UNKNOWN, /* XF86MenuKB */ /* 140 */ SDL_SCANCODE_CALCULATOR, /* 141 */ SDL_SCANCODE_UNKNOWN, /* 142 */ SDL_SCANCODE_SLEEP, /* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */ /* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */ /* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ /* 146 */ SDL_SCANCODE_UNKNOWN, /* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */ /* 148 */ SDL_SCANCODE_APP1, /* XF86Launch1 */ /* 149 */ SDL_SCANCODE_APP2, /* XF86Launch2 */ /* 150 */ SDL_SCANCODE_WWW, /* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */ /* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */ /* 153 */ SDL_SCANCODE_UNKNOWN, /* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */ /* 155 */ SDL_SCANCODE_MAIL, /* 156 */ SDL_SCANCODE_AC_BOOKMARKS, /* XF86Favorites */ /* 157 */ SDL_SCANCODE_COMPUTER, /* 158 */ SDL_SCANCODE_AC_BACK, /* 159 */ SDL_SCANCODE_AC_FORWARD, /* 160 */ SDL_SCANCODE_UNKNOWN, /* 161 */ SDL_SCANCODE_EJECT, /* 162 */ SDL_SCANCODE_EJECT, /* 163 */ SDL_SCANCODE_AUDIONEXT, /* 164 */ SDL_SCANCODE_AUDIOPLAY, /* 165 */ SDL_SCANCODE_AUDIOPREV, /* 166 */ SDL_SCANCODE_AUDIOSTOP, /* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */ /* 168 */ SDL_SCANCODE_AUDIOREWIND, /* XF86AudioRewind */ /* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */ /* 170 */ SDL_SCANCODE_UNKNOWN, /* 171 */ SDL_SCANCODE_F13, /* XF86Tools */ /* 172 */ SDL_SCANCODE_AC_HOME, /* 173 */ SDL_SCANCODE_AC_REFRESH, /* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */ /* 175 */ SDL_SCANCODE_UNKNOWN, /* 176 */ SDL_SCANCODE_UNKNOWN, /* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */ /* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */ /* 179 */ SDL_SCANCODE_UNKNOWN, /* parenleft */ /* 180 */ SDL_SCANCODE_UNKNOWN, /* parenright */ /* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */ /* 182 */ SDL_SCANCODE_AGAIN, /* 183 */ SDL_SCANCODE_F13, /* XF86Tools */ /* 184 */ SDL_SCANCODE_F14, /* XF86Launch5 */ /* 185 */ SDL_SCANCODE_F15, /* XF86Launch6 */ /* 186 */ SDL_SCANCODE_F16, /* XF86Launch7 */ /* 187 */ SDL_SCANCODE_F17, /* XF86Launch8 */ /* 188 */ SDL_SCANCODE_F18, /* XF86Launch9 */ /* 189 */ SDL_SCANCODE_F19, /* null keysym */ /* 190 */ SDL_SCANCODE_UNKNOWN, /* 191 */ SDL_SCANCODE_UNKNOWN, /* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */ /* 193 */ SDL_SCANCODE_UNKNOWN, /* 194 */ SDL_SCANCODE_UNKNOWN, /* 195 */ SDL_SCANCODE_MODE, /* 196 */ SDL_SCANCODE_UNKNOWN, /* 197 */ SDL_SCANCODE_UNKNOWN, /* 198 */ SDL_SCANCODE_UNKNOWN, /* 199 */ SDL_SCANCODE_UNKNOWN, /* 200 */ SDL_SCANCODE_AUDIOPLAY, /* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */ /* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */ /* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */ /* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */ /* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */ /* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */ /* 207 */ SDL_SCANCODE_AUDIOPLAY, /* 208 */ SDL_SCANCODE_AUDIONEXT, /* 209 */ SDL_SCANCODE_UNKNOWN, /* 210 */ SDL_SCANCODE_PRINTSCREEN, /* 211 */ SDL_SCANCODE_UNKNOWN, /* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */ /* 213 */ SDL_SCANCODE_UNKNOWN, /* 214 */ SDL_SCANCODE_UNKNOWN, /* 215 */ SDL_SCANCODE_MAIL, /* 216 */ SDL_SCANCODE_UNKNOWN, /* 217 */ SDL_SCANCODE_AC_SEARCH, /* 218 */ SDL_SCANCODE_UNKNOWN, /* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */ /* 220 */ SDL_SCANCODE_UNKNOWN, /* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */ /* 222 */ SDL_SCANCODE_UNKNOWN, /* 223 */ SDL_SCANCODE_STOP, /* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* 225 */ SDL_SCANCODE_BRIGHTNESSUP, /* 226 */ SDL_SCANCODE_MEDIASELECT, /* 227 */ SDL_SCANCODE_DISPLAYSWITCH, /* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE, /* 229 */ SDL_SCANCODE_KBDILLUMDOWN, /* 230 */ SDL_SCANCODE_KBDILLUMUP, /* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */ /* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */ /* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */ /* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */ /* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */ /* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */ /* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */ /* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */ }; /* Xvnc / Xtightvnc scancodes from xmodmap -pk */ static const SDL_Scancode xvnc_scancode_table[] = { /* 0 */ SDL_SCANCODE_LCTRL, /* 1 */ SDL_SCANCODE_RCTRL, /* 2 */ SDL_SCANCODE_LSHIFT, /* 3 */ SDL_SCANCODE_RSHIFT, /* 4 */ SDL_SCANCODE_UNKNOWN, /* Meta_L */ /* 5 */ SDL_SCANCODE_UNKNOWN, /* Meta_R */ /* 6 */ SDL_SCANCODE_LALT, /* 7 */ SDL_SCANCODE_RALT, /* 8 */ SDL_SCANCODE_SPACE, /* 9 */ SDL_SCANCODE_0, /* 10 */ SDL_SCANCODE_1, /* 11 */ SDL_SCANCODE_2, /* 12 */ SDL_SCANCODE_3, /* 13 */ SDL_SCANCODE_4, /* 14 */ SDL_SCANCODE_5, /* 15 */ SDL_SCANCODE_6, /* 16 */ SDL_SCANCODE_7, /* 17 */ SDL_SCANCODE_8, /* 18 */ SDL_SCANCODE_9, /* 19 */ SDL_SCANCODE_MINUS, /* 20 */ SDL_SCANCODE_EQUALS, /* 21 */ SDL_SCANCODE_LEFTBRACKET, /* 22 */ SDL_SCANCODE_RIGHTBRACKET, /* 23 */ SDL_SCANCODE_SEMICOLON, /* 24 */ SDL_SCANCODE_APOSTROPHE, /* 25 */ SDL_SCANCODE_GRAVE, /* 26 */ SDL_SCANCODE_COMMA, /* 27 */ SDL_SCANCODE_PERIOD, /* 28 */ SDL_SCANCODE_SLASH, /* 29 */ SDL_SCANCODE_BACKSLASH, /* 30 */ SDL_SCANCODE_A, /* 31 */ SDL_SCANCODE_B, /* 32 */ SDL_SCANCODE_C, /* 33 */ SDL_SCANCODE_D, /* 34 */ SDL_SCANCODE_E, /* 35 */ SDL_SCANCODE_F, /* 36 */ SDL_SCANCODE_G, /* 37 */ SDL_SCANCODE_H, /* 38 */ SDL_SCANCODE_I, /* 39 */ SDL_SCANCODE_J, /* 40 */ SDL_SCANCODE_K, /* 41 */ SDL_SCANCODE_L, /* 42 */ SDL_SCANCODE_M, /* 43 */ SDL_SCANCODE_N, /* 44 */ SDL_SCANCODE_O, /* 45 */ SDL_SCANCODE_P, /* 46 */ SDL_SCANCODE_Q, /* 47 */ SDL_SCANCODE_R, /* 48 */ SDL_SCANCODE_S, /* 49 */ SDL_SCANCODE_T, /* 50 */ SDL_SCANCODE_U, /* 51 */ SDL_SCANCODE_V, /* 52 */ SDL_SCANCODE_W, /* 53 */ SDL_SCANCODE_X, /* 54 */ SDL_SCANCODE_Y, /* 55 */ SDL_SCANCODE_Z, /* 56 */ SDL_SCANCODE_BACKSPACE, /* 57 */ SDL_SCANCODE_RETURN, /* 58 */ SDL_SCANCODE_TAB, /* 59 */ SDL_SCANCODE_ESCAPE, /* 60 */ SDL_SCANCODE_DELETE, /* 61 */ SDL_SCANCODE_HOME, /* 62 */ SDL_SCANCODE_END, /* 63 */ SDL_SCANCODE_PAGEUP, /* 64 */ SDL_SCANCODE_PAGEDOWN, /* 65 */ SDL_SCANCODE_UP, /* 66 */ SDL_SCANCODE_DOWN, /* 67 */ SDL_SCANCODE_LEFT, /* 68 */ SDL_SCANCODE_RIGHT, /* 69 */ SDL_SCANCODE_F1, /* 70 */ SDL_SCANCODE_F2, /* 71 */ SDL_SCANCODE_F3, /* 72 */ SDL_SCANCODE_F4, /* 73 */ SDL_SCANCODE_F5, /* 74 */ SDL_SCANCODE_F6, /* 75 */ SDL_SCANCODE_F7, /* 76 */ SDL_SCANCODE_F8, /* 77 */ SDL_SCANCODE_F9, /* 78 */ SDL_SCANCODE_F10, /* 79 */ SDL_SCANCODE_F11, /* 80 */ SDL_SCANCODE_F12, }; /* *INDENT-ON* */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_clipboardevents.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Clipboard event handling code for SDL */ #include "SDL_events.h" #include "SDL_events_c.h" #include "SDL_clipboardevents_c.h" int SDL_SendClipboardUpdate(void) { int posted; /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_CLIPBOARDUPDATE) == SDL_ENABLE) { SDL_Event event; event.type = SDL_CLIPBOARDUPDATE; posted = (SDL_PushEvent(&event) > 0); } return (posted); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_clipboardevents_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_clipboardevents_c_h_ #define SDL_clipboardevents_c_h_ extern int SDL_SendClipboardUpdate(void); #endif /* SDL_clipboardevents_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_displayevents.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Display event handling code for SDL */ #include "SDL_events.h" #include "SDL_events_c.h" int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1) { int posted; if (!display) { return 0; } switch (displayevent) { case SDL_DISPLAYEVENT_ORIENTATION: if (data1 == SDL_ORIENTATION_UNKNOWN || data1 == display->orientation) { return 0; } display->orientation = (SDL_DisplayOrientation)data1; break; } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_DISPLAYEVENT) == SDL_ENABLE) { SDL_Event event; event.type = SDL_DISPLAYEVENT; event.display.event = displayevent; event.display.display = SDL_GetIndexOfDisplay(display); event.display.data1 = data1; posted = (SDL_PushEvent(&event) > 0); } return (posted); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_displayevents_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_displayevents_c_h_ #define SDL_displayevents_c_h_ extern int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data1); #endif /* SDL_displayevents_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_dropevents.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Drag and drop event handling code for SDL */ #include "SDL_events.h" #include "SDL_events_c.h" #include "SDL_dropevents_c.h" #include "../video/SDL_sysvideo.h" /* for SDL_Window internals. */ static int SDL_SendDrop(SDL_Window *window, const SDL_EventType evtype, const char *data) { static SDL_bool app_is_dropping = SDL_FALSE; int posted = 0; /* Post the event, if desired */ if (SDL_GetEventState(evtype) == SDL_ENABLE) { const SDL_bool need_begin = window ? !window->is_dropping : !app_is_dropping; SDL_Event event; if (need_begin) { SDL_zero(event); event.type = SDL_DROPBEGIN; if (window) { event.drop.windowID = window->id; } posted = (SDL_PushEvent(&event) > 0); if (!posted) { return 0; } if (window) { window->is_dropping = SDL_TRUE; } else { app_is_dropping = SDL_TRUE; } } SDL_zero(event); event.type = evtype; event.drop.file = data ? SDL_strdup(data) : NULL; event.drop.windowID = window ? window->id : 0; posted = (SDL_PushEvent(&event) > 0); if (posted && (evtype == SDL_DROPCOMPLETE)) { if (window) { window->is_dropping = SDL_FALSE; } else { app_is_dropping = SDL_FALSE; } } } return posted; } int SDL_SendDropFile(SDL_Window *window, const char *file) { return SDL_SendDrop(window, SDL_DROPFILE, file); } int SDL_SendDropText(SDL_Window *window, const char *text) { return SDL_SendDrop(window, SDL_DROPTEXT, text); } int SDL_SendDropComplete(SDL_Window *window) { return SDL_SendDrop(window, SDL_DROPCOMPLETE, NULL); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_dropevents_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_dropevents_c_h_ #define SDL_dropevents_c_h_ extern int SDL_SendDropFile(SDL_Window *window, const char *file); extern int SDL_SendDropText(SDL_Window *window, const char *text); extern int SDL_SendDropComplete(SDL_Window *window); #endif /* SDL_dropevents_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_events.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* General event handling code for SDL */ #include "SDL.h" #include "SDL_events.h" #include "SDL_thread.h" #include "SDL_events_c.h" #include "../timer/SDL_timer_c.h" #if !SDL_JOYSTICK_DISABLED #include "../joystick/SDL_joystick_c.h" #endif #include "../video/SDL_sysvideo.h" #include "SDL_syswm.h" /*#define SDL_DEBUG_EVENTS 1*/ /* An arbitrary limit so we don't have unbounded growth */ #define SDL_MAX_QUEUED_EVENTS 65535 typedef struct SDL_EventWatcher { SDL_EventFilter callback; void *userdata; SDL_bool removed; } SDL_EventWatcher; static SDL_mutex *SDL_event_watchers_lock; static SDL_EventWatcher SDL_EventOK; static SDL_EventWatcher *SDL_event_watchers = NULL; static int SDL_event_watchers_count = 0; static SDL_bool SDL_event_watchers_dispatching = SDL_FALSE; static SDL_bool SDL_event_watchers_removed = SDL_FALSE; typedef struct { Uint32 bits[8]; } SDL_DisabledEventBlock; static SDL_DisabledEventBlock *SDL_disabled_events[256]; static Uint32 SDL_userevents = SDL_USEREVENT; /* Private data -- event queue */ typedef struct _SDL_EventEntry { SDL_Event event; SDL_SysWMmsg msg; struct _SDL_EventEntry *prev; struct _SDL_EventEntry *next; } SDL_EventEntry; typedef struct _SDL_SysWMEntry { SDL_SysWMmsg msg; struct _SDL_SysWMEntry *next; } SDL_SysWMEntry; static struct { SDL_mutex *lock; SDL_atomic_t active; SDL_atomic_t count; int max_events_seen; SDL_EventEntry *head; SDL_EventEntry *tail; SDL_EventEntry *free; SDL_SysWMEntry *wmmsg_used; SDL_SysWMEntry *wmmsg_free; } SDL_EventQ = { NULL, { 1 }, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }; #ifdef SDL_DEBUG_EVENTS /* this is to make printf() calls cleaner. */ #define uint unsigned int static void SDL_DebugPrintEvent(const SDL_Event *event) { /* !!! FIXME: This code is kinda ugly, sorry. */ printf("SDL EVENT: "); if ((event->type >= SDL_USEREVENT) && (event->type <= SDL_LASTEVENT)) { printf("SDL_USEREVENT"); if (event->type > SDL_USEREVENT) { printf("+%u", ((uint) event->type) - SDL_USEREVENT); } printf(" (timestamp=%u windowid=%u code=%d data1=%p data2=%p)", (uint) event->user.timestamp, (uint) event->user.windowID, (int) event->user.code, event->user.data1, event->user.data2); return; } switch (event->type) { #define SDL_EVENT_CASE(x) case x: printf("%s", #x); SDL_EVENT_CASE(SDL_FIRSTEVENT) printf("(THIS IS PROBABLY A BUG!)"); break; SDL_EVENT_CASE(SDL_QUIT) printf("(timestamp=%u)", (uint) event->quit.timestamp); break; SDL_EVENT_CASE(SDL_APP_TERMINATING) break; SDL_EVENT_CASE(SDL_APP_LOWMEMORY) break; SDL_EVENT_CASE(SDL_APP_WILLENTERBACKGROUND) break; SDL_EVENT_CASE(SDL_APP_DIDENTERBACKGROUND) break; SDL_EVENT_CASE(SDL_APP_WILLENTERFOREGROUND) break; SDL_EVENT_CASE(SDL_APP_DIDENTERFOREGROUND) break; SDL_EVENT_CASE(SDL_KEYMAPCHANGED) break; SDL_EVENT_CASE(SDL_CLIPBOARDUPDATE) break; SDL_EVENT_CASE(SDL_RENDER_TARGETS_RESET) break; SDL_EVENT_CASE(SDL_RENDER_DEVICE_RESET) break; #undef SDL_EVENT_CASE #define SDL_EVENT_CASE(x) case x: printf("%s ", #x); SDL_EVENT_CASE(SDL_WINDOWEVENT) printf("(timestamp=%u windowid=%u event=", (uint) event->window.timestamp, (uint) event->window.windowID); switch(event->window.event) { case SDL_WINDOWEVENT_NONE: printf("none(THIS IS PROBABLY A BUG!)"); break; #define SDL_WINDOWEVENT_CASE(x) case x: printf("%s", #x); break SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SHOWN); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIDDEN); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_EXPOSED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MOVED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESIZED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_SIZE_CHANGED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MINIMIZED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_MAXIMIZED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_RESTORED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_ENTER); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_LEAVE); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_GAINED); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_FOCUS_LOST); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_CLOSE); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_TAKE_FOCUS); SDL_WINDOWEVENT_CASE(SDL_WINDOWEVENT_HIT_TEST); #undef SDL_WINDOWEVENT_CASE default: printf("UNKNOWN(bug? fixme?)"); break; } printf(" data1=%d data2=%d)", (int) event->window.data1, (int) event->window.data2); break; SDL_EVENT_CASE(SDL_SYSWMEVENT) printf("(timestamp=%u)", (uint) event->syswm.timestamp); /* !!! FIXME: we don't delve further at the moment. */ break; #define PRINT_KEY_EVENT(event) \ printf("(timestamp=%u windowid=%u state=%s repeat=%s scancode=%u keycode=%u mod=%u)", \ (uint) event->key.timestamp, (uint) event->key.windowID, \ event->key.state == SDL_PRESSED ? "pressed" : "released", \ event->key.repeat ? "true" : "false", \ (uint) event->key.keysym.scancode, \ (uint) event->key.keysym.sym, \ (uint) event->key.keysym.mod) SDL_EVENT_CASE(SDL_KEYDOWN) PRINT_KEY_EVENT(event); break; SDL_EVENT_CASE(SDL_KEYUP) PRINT_KEY_EVENT(event); break; #undef PRINT_KEY_EVENT SDL_EVENT_CASE(SDL_TEXTEDITING) printf("(timestamp=%u windowid=%u text='%s' start=%d length=%d)", (uint) event->edit.timestamp, (uint) event->edit.windowID, event->edit.text, (int) event->edit.start, (int) event->edit.length); break; SDL_EVENT_CASE(SDL_TEXTINPUT) printf("(timestamp=%u windowid=%u text='%s')", (uint) event->text.timestamp, (uint) event->text.windowID, event->text.text); break; SDL_EVENT_CASE(SDL_MOUSEMOTION) printf("(timestamp=%u windowid=%u which=%u state=%u x=%d y=%d xrel=%d yrel=%d)", (uint) event->motion.timestamp, (uint) event->motion.windowID, (uint) event->motion.which, (uint) event->motion.state, (int) event->motion.x, (int) event->motion.y, (int) event->motion.xrel, (int) event->motion.yrel); break; #define PRINT_MBUTTON_EVENT(event) \ printf("(timestamp=%u windowid=%u which=%u button=%u state=%s clicks=%u x=%d y=%d)", \ (uint) event->button.timestamp, (uint) event->button.windowID, \ (uint) event->button.which, (uint) event->button.button, \ event->button.state == SDL_PRESSED ? "pressed" : "released", \ (uint) event->button.clicks, (int) event->button.x, (int) event->button.y) SDL_EVENT_CASE(SDL_MOUSEBUTTONDOWN) PRINT_MBUTTON_EVENT(event); break; SDL_EVENT_CASE(SDL_MOUSEBUTTONUP) PRINT_MBUTTON_EVENT(event); break; #undef PRINT_MBUTTON_EVENT SDL_EVENT_CASE(SDL_MOUSEWHEEL) printf("(timestamp=%u windowid=%u which=%u x=%d y=%d direction=%s)", (uint) event->wheel.timestamp, (uint) event->wheel.windowID, (uint) event->wheel.which, (int) event->wheel.x, (int) event->wheel.y, event->wheel.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped"); break; SDL_EVENT_CASE(SDL_JOYAXISMOTION) printf("(timestamp=%u which=%d axis=%u value=%d)", (uint) event->jaxis.timestamp, (int) event->jaxis.which, (uint) event->jaxis.axis, (int) event->jaxis.value); break; SDL_EVENT_CASE(SDL_JOYBALLMOTION) printf("(timestamp=%u which=%d ball=%u xrel=%d yrel=%d)", (uint) event->jball.timestamp, (int) event->jball.which, (uint) event->jball.ball, (int) event->jball.xrel, (int) event->jball.yrel); break; SDL_EVENT_CASE(SDL_JOYHATMOTION) printf("(timestamp=%u which=%d hat=%u value=%u)", (uint) event->jhat.timestamp, (int) event->jhat.which, (uint) event->jhat.hat, (uint) event->jhat.value); break; #define PRINT_JBUTTON_EVENT(event) \ printf("(timestamp=%u which=%d button=%u state=%s)", \ (uint) event->jbutton.timestamp, (int) event->jbutton.which, \ (uint) event->jbutton.button, event->jbutton.state == SDL_PRESSED ? "pressed" : "released") SDL_EVENT_CASE(SDL_JOYBUTTONDOWN) PRINT_JBUTTON_EVENT(event); break; SDL_EVENT_CASE(SDL_JOYBUTTONUP) PRINT_JBUTTON_EVENT(event); break; #undef PRINT_JBUTTON_EVENT #define PRINT_JOYDEV_EVENT(event) printf("(timestamp=%u which=%d)", (uint) event->jdevice.timestamp, (int) event->jdevice.which) SDL_EVENT_CASE(SDL_JOYDEVICEADDED) PRINT_JOYDEV_EVENT(event); break; SDL_EVENT_CASE(SDL_JOYDEVICEREMOVED) PRINT_JOYDEV_EVENT(event); break; #undef PRINT_JOYDEV_EVENT SDL_EVENT_CASE(SDL_CONTROLLERAXISMOTION) printf("(timestamp=%u which=%d axis=%u value=%d)", (uint) event->caxis.timestamp, (int) event->caxis.which, (uint) event->caxis.axis, (int) event->caxis.value); break; #define PRINT_CBUTTON_EVENT(event) \ printf("(timestamp=%u which=%d button=%u state=%s)", \ (uint) event->cbutton.timestamp, (int) event->cbutton.which, \ (uint) event->cbutton.button, event->cbutton.state == SDL_PRESSED ? "pressed" : "released") SDL_EVENT_CASE(SDL_CONTROLLERBUTTONDOWN) PRINT_CBUTTON_EVENT(event); break; SDL_EVENT_CASE(SDL_CONTROLLERBUTTONUP) PRINT_CBUTTON_EVENT(event); break; #undef PRINT_CBUTTON_EVENT #define PRINT_CONTROLLERDEV_EVENT(event) printf("(timestamp=%u which=%d)", (uint) event->cdevice.timestamp, (int) event->cdevice.which) SDL_EVENT_CASE(SDL_CONTROLLERDEVICEADDED) PRINT_CONTROLLERDEV_EVENT(event); break; SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMOVED) PRINT_CONTROLLERDEV_EVENT(event); break; SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) PRINT_CONTROLLERDEV_EVENT(event); break; #undef PRINT_CONTROLLERDEV_EVENT #define PRINT_FINGER_EVENT(event) \ printf("(timestamp=%u touchid=%lld fingerid=%lld x=%f y=%f dx=%f dy=%f pressure=%f)", \ (uint) event->tfinger.timestamp, (long long) event->tfinger.touchId, \ (long long) event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); break; SDL_EVENT_CASE(SDL_FINGERUP) PRINT_FINGER_EVENT(event); break; SDL_EVENT_CASE(SDL_FINGERMOTION) PRINT_FINGER_EVENT(event); break; #undef PRINT_FINGER_EVENT #define PRINT_DOLLAR_EVENT(event) \ printf("(timestamp=%u touchid=%lld gestureid=%lld numfingers=%u error=%f x=%f y=%f)", \ (uint) event->dgesture.timestamp, (long long) event->dgesture.touchId, \ (long long) event->dgesture.gestureId, (uint) event->dgesture.numFingers, \ event->dgesture.error, event->dgesture.x, event->dgesture.y); SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); break; SDL_EVENT_CASE(SDL_DOLLARRECORD) PRINT_DOLLAR_EVENT(event); break; #undef PRINT_DOLLAR_EVENT SDL_EVENT_CASE(SDL_MULTIGESTURE) printf("(timestamp=%u touchid=%lld dtheta=%f ddist=%f x=%f y=%f numfingers=%u)", (uint) event->mgesture.timestamp, (long long) event->mgesture.touchId, event->mgesture.dTheta, event->mgesture.dDist, event->mgesture.x, event->mgesture.y, (uint) event->mgesture.numFingers); break; #define PRINT_DROP_EVENT(event) printf("(file='%s' timestamp=%u windowid=%u)", event->drop.file, (uint) event->drop.timestamp, (uint) event->drop.windowID) SDL_EVENT_CASE(SDL_DROPFILE) PRINT_DROP_EVENT(event); break; SDL_EVENT_CASE(SDL_DROPTEXT) PRINT_DROP_EVENT(event); break; SDL_EVENT_CASE(SDL_DROPBEGIN) PRINT_DROP_EVENT(event); break; SDL_EVENT_CASE(SDL_DROPCOMPLETE) PRINT_DROP_EVENT(event); break; #undef PRINT_DROP_EVENT #define PRINT_AUDIODEV_EVENT(event) printf("(timestamp=%u which=%u iscapture=%s)", (uint) event->adevice.timestamp, (uint) event->adevice.which, event->adevice.iscapture ? "true" : "false"); SDL_EVENT_CASE(SDL_AUDIODEVICEADDED) PRINT_AUDIODEV_EVENT(event); break; SDL_EVENT_CASE(SDL_AUDIODEVICEREMOVED) PRINT_AUDIODEV_EVENT(event); break; #undef PRINT_AUDIODEV_EVENT #undef SDL_EVENT_CASE default: printf("UNKNOWN SDL EVENT #%u! (Bug? FIXME?)", (uint) event->type); break; } printf("\n"); } #undef uint #endif /* Public functions */ void SDL_StopEventLoop(void) { const char *report = SDL_GetHint("SDL_EVENT_QUEUE_STATISTICS"); int i; SDL_EventEntry *entry; SDL_SysWMEntry *wmmsg; if (SDL_EventQ.lock) { SDL_LockMutex(SDL_EventQ.lock); } SDL_AtomicSet(&SDL_EventQ.active, 0); if (report && SDL_atoi(report)) { SDL_Log("SDL EVENT QUEUE: Maximum events in-flight: %d\n", SDL_EventQ.max_events_seen); } /* Clean out EventQ */ for (entry = SDL_EventQ.head; entry; ) { SDL_EventEntry *next = entry->next; SDL_free(entry); entry = next; } for (entry = SDL_EventQ.free; entry; ) { SDL_EventEntry *next = entry->next; SDL_free(entry); entry = next; } for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; ) { SDL_SysWMEntry *next = wmmsg->next; SDL_free(wmmsg); wmmsg = next; } for (wmmsg = SDL_EventQ.wmmsg_free; wmmsg; ) { SDL_SysWMEntry *next = wmmsg->next; SDL_free(wmmsg); wmmsg = next; } SDL_AtomicSet(&SDL_EventQ.count, 0); SDL_EventQ.max_events_seen = 0; SDL_EventQ.head = NULL; SDL_EventQ.tail = NULL; SDL_EventQ.free = NULL; SDL_EventQ.wmmsg_used = NULL; SDL_EventQ.wmmsg_free = NULL; /* Clear disabled event state */ for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) { SDL_free(SDL_disabled_events[i]); SDL_disabled_events[i] = NULL; } if (SDL_event_watchers_lock) { SDL_DestroyMutex(SDL_event_watchers_lock); SDL_event_watchers_lock = NULL; } if (SDL_event_watchers) { SDL_free(SDL_event_watchers); SDL_event_watchers = NULL; SDL_event_watchers_count = 0; } SDL_zero(SDL_EventOK); if (SDL_EventQ.lock) { SDL_UnlockMutex(SDL_EventQ.lock); SDL_DestroyMutex(SDL_EventQ.lock); SDL_EventQ.lock = NULL; } } /* This function (and associated calls) may be called more than once */ int SDL_StartEventLoop(void) { /* We'll leave the event queue alone, since we might have gotten some important events at launch (like SDL_DROPFILE) FIXME: Does this introduce any other bugs with events at startup? */ /* Create the lock and set ourselves active */ #if !SDL_THREADS_DISABLED if (!SDL_EventQ.lock) { SDL_EventQ.lock = SDL_CreateMutex(); if (SDL_EventQ.lock == NULL) { return -1; } } if (!SDL_event_watchers_lock) { SDL_event_watchers_lock = SDL_CreateMutex(); if (SDL_event_watchers_lock == NULL) { return -1; } } #endif /* !SDL_THREADS_DISABLED */ /* Process most event types */ SDL_EventState(SDL_TEXTINPUT, SDL_DISABLE); SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE); SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE); SDL_EventState(SDL_DROPFILE, SDL_DISABLE); SDL_EventState(SDL_DROPTEXT, SDL_DISABLE); SDL_AtomicSet(&SDL_EventQ.active, 1); return 0; } /* Add an event to the event queue -- called with the queue locked */ static int SDL_AddEvent(SDL_Event * event) { SDL_EventEntry *entry; const int initial_count = SDL_AtomicGet(&SDL_EventQ.count); int final_count; if (initial_count >= SDL_MAX_QUEUED_EVENTS) { SDL_SetError("Event queue is full (%d events)", initial_count); return 0; } if (SDL_EventQ.free == NULL) { entry = (SDL_EventEntry *)SDL_malloc(sizeof(*entry)); if (!entry) { return 0; } } else { entry = SDL_EventQ.free; SDL_EventQ.free = entry->next; } #ifdef SDL_DEBUG_EVENTS SDL_DebugPrintEvent(event); #endif entry->event = *event; if (event->type == SDL_SYSWMEVENT) { entry->msg = *event->syswm.msg; entry->event.syswm.msg = &entry->msg; } if (SDL_EventQ.tail) { SDL_EventQ.tail->next = entry; entry->prev = SDL_EventQ.tail; SDL_EventQ.tail = entry; entry->next = NULL; } else { SDL_assert(!SDL_EventQ.head); SDL_EventQ.head = entry; SDL_EventQ.tail = entry; entry->prev = NULL; entry->next = NULL; } final_count = SDL_AtomicAdd(&SDL_EventQ.count, 1) + 1; if (final_count > SDL_EventQ.max_events_seen) { SDL_EventQ.max_events_seen = final_count; } return 1; } /* Remove an event from the queue -- called with the queue locked */ static void SDL_CutEvent(SDL_EventEntry *entry) { if (entry->prev) { entry->prev->next = entry->next; } if (entry->next) { entry->next->prev = entry->prev; } if (entry == SDL_EventQ.head) { SDL_assert(entry->prev == NULL); SDL_EventQ.head = entry->next; } if (entry == SDL_EventQ.tail) { SDL_assert(entry->next == NULL); SDL_EventQ.tail = entry->prev; } entry->next = SDL_EventQ.free; SDL_EventQ.free = entry; SDL_assert(SDL_AtomicGet(&SDL_EventQ.count) > 0); SDL_AtomicAdd(&SDL_EventQ.count, -1); } /* Lock the event queue, take a peep at it, and unlock it */ int SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, Uint32 minType, Uint32 maxType) { int i, used; /* Don't look after we've quit */ if (!SDL_AtomicGet(&SDL_EventQ.active)) { /* We get a few spurious events at shutdown, so don't warn then */ if (action != SDL_ADDEVENT) { SDL_SetError("The event system has been shut down"); } return (-1); } /* Lock the event queue */ used = 0; if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { if (action == SDL_ADDEVENT) { for (i = 0; i < numevents; ++i) { used += SDL_AddEvent(&events[i]); } } else { SDL_EventEntry *entry, *next; SDL_SysWMEntry *wmmsg, *wmmsg_next; Uint32 type; if (action == SDL_GETEVENT) { /* Clean out any used wmmsg data FIXME: Do we want to retain the data for some period of time? */ for (wmmsg = SDL_EventQ.wmmsg_used; wmmsg; wmmsg = wmmsg_next) { wmmsg_next = wmmsg->next; wmmsg->next = SDL_EventQ.wmmsg_free; SDL_EventQ.wmmsg_free = wmmsg; } SDL_EventQ.wmmsg_used = NULL; } for (entry = SDL_EventQ.head; entry && (!events || used < numevents); entry = next) { next = entry->next; type = entry->event.type; if (minType <= type && type <= maxType) { if (events) { events[used] = entry->event; if (entry->event.type == SDL_SYSWMEVENT) { /* We need to copy the wmmsg somewhere safe. For now we'll guarantee it's valid at least until the next call to SDL_PeepEvents() */ if (SDL_EventQ.wmmsg_free) { wmmsg = SDL_EventQ.wmmsg_free; SDL_EventQ.wmmsg_free = wmmsg->next; } else { wmmsg = (SDL_SysWMEntry *)SDL_malloc(sizeof(*wmmsg)); } wmmsg->msg = *entry->event.syswm.msg; wmmsg->next = SDL_EventQ.wmmsg_used; SDL_EventQ.wmmsg_used = wmmsg; events[used].syswm.msg = &wmmsg->msg; } if (action == SDL_GETEVENT) { SDL_CutEvent(entry); } } ++used; } } } if (SDL_EventQ.lock) { SDL_UnlockMutex(SDL_EventQ.lock); } } else { return SDL_SetError("Couldn't lock event queue"); } return (used); } SDL_bool SDL_HasEvent(Uint32 type) { return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type) > 0); } SDL_bool SDL_HasEvents(Uint32 minType, Uint32 maxType) { return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0); } void SDL_FlushEvent(Uint32 type) { SDL_FlushEvents(type, type); } void SDL_FlushEvents(Uint32 minType, Uint32 maxType) { /* !!! FIXME: we need to manually SDL_free() the strings in TEXTINPUT and drag'n'drop events if we're flushing them without passing them to the app, but I don't know if this is the right place to do that. */ /* Don't look after we've quit */ if (!SDL_AtomicGet(&SDL_EventQ.active)) { return; } /* Make sure the events are current */ #if 0 /* Actually, we can't do this since we might be flushing while processing a resize event, and calling this might trigger further resize events. */ SDL_PumpEvents(); #endif /* Lock the event queue */ if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { SDL_EventEntry *entry, *next; Uint32 type; for (entry = SDL_EventQ.head; entry; entry = next) { next = entry->next; type = entry->event.type; if (minType <= type && type <= maxType) { SDL_CutEvent(entry); } } if (SDL_EventQ.lock) { SDL_UnlockMutex(SDL_EventQ.lock); } } } /* Run the system dependent event loops */ void SDL_PumpEvents(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); /* Get events from the video subsystem */ if (_this) { _this->PumpEvents(_this); } #if !SDL_JOYSTICK_DISABLED /* Check for joystick state change */ if ((!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] || SDL_JoystickEventState(SDL_QUERY))) { SDL_JoystickUpdate(); } #endif #if !SDL_SENSOR_DISABLED /* Check for sensor state change */ if (!SDL_disabled_events[SDL_SENSORUPDATE >> 8]) { SDL_SensorUpdate(); } #endif SDL_SendPendingQuit(); /* in case we had a signal handler fire, etc. */ } /* Public functions */ int SDL_PollEvent(SDL_Event * event) { return SDL_WaitEventTimeout(event, 0); } int SDL_WaitEvent(SDL_Event * event) { return SDL_WaitEventTimeout(event, -1); } int SDL_WaitEventTimeout(SDL_Event * event, int timeout) { Uint32 expiration = 0; if (timeout > 0) expiration = SDL_GetTicks() + timeout; for (;;) { SDL_PumpEvents(); switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) { case -1: return 0; case 0: if (timeout == 0) { /* Polling and no events, just return */ return 0; } if (timeout > 0 && SDL_TICKS_PASSED(SDL_GetTicks(), expiration)) { /* Timeout expired and no events */ return 0; } SDL_Delay(10); break; default: /* Has events */ return 1; } } } int SDL_PushEvent(SDL_Event * event) { event->common.timestamp = SDL_GetTicks(); if (SDL_EventOK.callback || SDL_event_watchers_count > 0) { if (!SDL_event_watchers_lock || SDL_LockMutex(SDL_event_watchers_lock) == 0) { if (SDL_EventOK.callback && !SDL_EventOK.callback(SDL_EventOK.userdata, event)) { if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } return 0; } if (SDL_event_watchers_count > 0) { /* Make sure we only dispatch the current watcher list */ int i, event_watchers_count = SDL_event_watchers_count; SDL_event_watchers_dispatching = SDL_TRUE; for (i = 0; i < event_watchers_count; ++i) { if (!SDL_event_watchers[i].removed) { SDL_event_watchers[i].callback(SDL_event_watchers[i].userdata, event); } } SDL_event_watchers_dispatching = SDL_FALSE; if (SDL_event_watchers_removed) { for (i = SDL_event_watchers_count; i--; ) { if (SDL_event_watchers[i].removed) { --SDL_event_watchers_count; if (i < SDL_event_watchers_count) { SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i+1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); } } } SDL_event_watchers_removed = SDL_FALSE; } } if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } } } if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) { return -1; } SDL_GestureProcessEvent(event); return 1; } void SDL_SetEventFilter(SDL_EventFilter filter, void *userdata) { if (!SDL_event_watchers_lock || SDL_LockMutex(SDL_event_watchers_lock) == 0) { /* Set filter and discard pending events */ SDL_EventOK.callback = filter; SDL_EventOK.userdata = userdata; SDL_FlushEvents(SDL_FIRSTEVENT, SDL_LASTEVENT); if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } } } SDL_bool SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) { SDL_EventWatcher event_ok; if (!SDL_event_watchers_lock || SDL_LockMutex(SDL_event_watchers_lock) == 0) { event_ok = SDL_EventOK; if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } } else { SDL_zero(event_ok); } if (filter) { *filter = event_ok.callback; } if (userdata) { *userdata = event_ok.userdata; } return event_ok.callback ? SDL_TRUE : SDL_FALSE; } void SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) { if (!SDL_event_watchers_lock || SDL_LockMutex(SDL_event_watchers_lock) == 0) { SDL_EventWatcher *event_watchers; event_watchers = SDL_realloc(SDL_event_watchers, (SDL_event_watchers_count + 1) * sizeof(*event_watchers)); if (event_watchers) { SDL_EventWatcher *watcher; SDL_event_watchers = event_watchers; watcher = &SDL_event_watchers[SDL_event_watchers_count]; watcher->callback = filter; watcher->userdata = userdata; watcher->removed = SDL_FALSE; ++SDL_event_watchers_count; } if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } } } void SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) { if (!SDL_event_watchers_lock || SDL_LockMutex(SDL_event_watchers_lock) == 0) { int i; for (i = 0; i < SDL_event_watchers_count; ++i) { if (SDL_event_watchers[i].callback == filter && SDL_event_watchers[i].userdata == userdata) { if (SDL_event_watchers_dispatching) { SDL_event_watchers[i].removed = SDL_TRUE; SDL_event_watchers_removed = SDL_TRUE; } else { --SDL_event_watchers_count; if (i < SDL_event_watchers_count) { SDL_memmove(&SDL_event_watchers[i], &SDL_event_watchers[i+1], (SDL_event_watchers_count - i) * sizeof(SDL_event_watchers[i])); } } break; } } if (SDL_event_watchers_lock) { SDL_UnlockMutex(SDL_event_watchers_lock); } } } void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) { if (!SDL_EventQ.lock || SDL_LockMutex(SDL_EventQ.lock) == 0) { SDL_EventEntry *entry, *next; for (entry = SDL_EventQ.head; entry; entry = next) { next = entry->next; if (!filter(userdata, &entry->event)) { SDL_CutEvent(entry); } } if (SDL_EventQ.lock) { SDL_UnlockMutex(SDL_EventQ.lock); } } } Uint8 SDL_EventState(Uint32 type, int state) { const SDL_bool isdnd = ((state == SDL_DISABLE) || (state == SDL_ENABLE)) && ((type == SDL_DROPFILE) || (type == SDL_DROPTEXT)); Uint8 current_state; Uint8 hi = ((type >> 8) & 0xff); Uint8 lo = (type & 0xff); if (SDL_disabled_events[hi] && (SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) { current_state = SDL_DISABLE; } else { current_state = SDL_ENABLE; } if (state != current_state) { switch (state) { case SDL_DISABLE: /* Disable this event type and discard pending events */ if (!SDL_disabled_events[hi]) { SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock)); if (!SDL_disabled_events[hi]) { /* Out of memory, nothing we can do... */ break; } } SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31)); SDL_FlushEvent(type); break; case SDL_ENABLE: SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31)); break; default: /* Querying state... */ break; } } /* turn off drag'n'drop support if we've disabled the events. This might change some UI details at the OS level. */ if (isdnd) { SDL_ToggleDragAndDropSupport(); } return current_state; } Uint32 SDL_RegisterEvents(int numevents) { Uint32 event_base; if ((numevents > 0) && (SDL_userevents+numevents <= SDL_LASTEVENT)) { event_base = SDL_userevents; SDL_userevents += numevents; } else { event_base = (Uint32)-1; } return event_base; } int SDL_SendAppEvent(SDL_EventType eventType) { int posted; posted = 0; if (SDL_GetEventState(eventType) == SDL_ENABLE) { SDL_Event event; event.type = eventType; posted = (SDL_PushEvent(&event) > 0); } return (posted); } int SDL_SendSysWMEvent(SDL_SysWMmsg * message) { int posted; posted = 0; if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { SDL_Event event; SDL_memset(&event, 0, sizeof(event)); event.type = SDL_SYSWMEVENT; event.syswm.msg = message; posted = (SDL_PushEvent(&event) > 0); } /* Update internal event state */ return (posted); } int SDL_SendKeymapChangedEvent(void) { return SDL_SendAppEvent(SDL_KEYMAPCHANGED); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_events_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Useful functions and variables from SDL_events.c */ #include "SDL_events.h" #include "SDL_thread.h" #include "../video/SDL_sysvideo.h" #include "SDL_clipboardevents_c.h" #include "SDL_displayevents_c.h" #include "SDL_dropevents_c.h" #include "SDL_gesture_c.h" #include "SDL_keyboard_c.h" #include "SDL_mouse_c.h" #include "SDL_touch_c.h" #include "SDL_windowevents_c.h" /* Start and stop the event processing loop */ extern int SDL_StartEventLoop(void); extern void SDL_StopEventLoop(void); extern void SDL_QuitInterrupt(void); extern int SDL_SendAppEvent(SDL_EventType eventType); extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message); extern int SDL_SendKeymapChangedEvent(void); extern int SDL_QuitInit(void); extern int SDL_SendQuit(void); extern void SDL_QuitQuit(void); extern void SDL_SendPendingQuit(void); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_gesture.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* General gesture handling code for SDL */ #include "SDL_events.h" #include "SDL_endian.h" #include "SDL_events_c.h" #include "SDL_gesture_c.h" /* #include <stdio.h> */ /* TODO: Replace with malloc */ #define MAXPATHSIZE 1024 #define DOLLARNPOINTS 64 #define DOLLARSIZE 256 #define ENABLE_DOLLAR #define PHI 0.618033989 typedef struct { float x,y; } SDL_FloatPoint; typedef struct { float length; int numPoints; SDL_FloatPoint p[MAXPATHSIZE]; } SDL_DollarPath; typedef struct { SDL_FloatPoint path[DOLLARNPOINTS]; unsigned long hash; } SDL_DollarTemplate; typedef struct { SDL_TouchID id; SDL_FloatPoint centroid; SDL_DollarPath dollarPath; Uint16 numDownFingers; int numDollarTemplates; SDL_DollarTemplate *dollarTemplate; SDL_bool recording; } SDL_GestureTouch; static SDL_GestureTouch *SDL_gestureTouch; static int SDL_numGestureTouches = 0; static SDL_bool recordAll; #if 0 static void PrintPath(SDL_FloatPoint *path) { int i; printf("Path:"); for (i=0; i<DOLLARNPOINTS; i++) { printf(" (%f,%f)",path[i].x,path[i].y); } printf("\n"); } #endif int SDL_RecordGesture(SDL_TouchID touchId) { int i; if (touchId < 0) recordAll = SDL_TRUE; for (i = 0; i < SDL_numGestureTouches; i++) { if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) { SDL_gestureTouch[i].recording = SDL_TRUE; if (touchId >= 0) return 1; } } return (touchId < 0); } void SDL_GestureQuit() { SDL_free(SDL_gestureTouch); SDL_gestureTouch = NULL; } static unsigned long SDL_HashDollar(SDL_FloatPoint* points) { unsigned long hash = 5381; int i; for (i = 0; i < DOLLARNPOINTS; i++) { hash = ((hash<<5) + hash) + (unsigned long)points[i].x; hash = ((hash<<5) + hash) + (unsigned long)points[i].y; } return hash; } static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) { if (dst == NULL) { return 0; } /* No Longer storing the Hash, rehash on load */ /* if (SDL_RWops.write(dst, &(templ->hash), sizeof(templ->hash), 1) != 1) return 0; */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN if (SDL_RWwrite(dst, templ->path, sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) { return 0; } #else { SDL_DollarTemplate copy = *templ; SDL_FloatPoint *p = copy.path; int i; for (i = 0; i < DOLLARNPOINTS; i++, p++) { p->x = SDL_SwapFloatLE(p->x); p->y = SDL_SwapFloatLE(p->y); } if (SDL_RWwrite(dst, copy.path, sizeof(copy.path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) { return 0; } } #endif return 1; } int SDL_SaveAllDollarTemplates(SDL_RWops *dst) { int i,j,rtrn = 0; for (i = 0; i < SDL_numGestureTouches; i++) { SDL_GestureTouch* touch = &SDL_gestureTouch[i]; for (j = 0; j < touch->numDollarTemplates; j++) { rtrn += SaveTemplate(&touch->dollarTemplate[j], dst); } } return rtrn; } int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *dst) { int i,j; for (i = 0; i < SDL_numGestureTouches; i++) { SDL_GestureTouch* touch = &SDL_gestureTouch[i]; for (j = 0; j < touch->numDollarTemplates; j++) { if (touch->dollarTemplate[j].hash == gestureId) { return SaveTemplate(&touch->dollarTemplate[j], dst); } } } return SDL_SetError("Unknown gestureId"); } /* path is an already sampled set of points Returns the index of the gesture on success, or -1 */ static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { SDL_DollarTemplate* dollarTemplate; SDL_DollarTemplate *templ; int index; index = inTouch->numDollarTemplates; dollarTemplate = (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, (index + 1) * sizeof(SDL_DollarTemplate)); if (!dollarTemplate) { return SDL_OutOfMemory(); } inTouch->dollarTemplate = dollarTemplate; templ = &inTouch->dollarTemplate[index]; SDL_memcpy(templ->path, path, DOLLARNPOINTS*sizeof(SDL_FloatPoint)); templ->hash = SDL_HashDollar(templ->path); inTouch->numDollarTemplates++; return index; } static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) { int index = -1; int i = 0; if (inTouch == NULL) { if (SDL_numGestureTouches == 0) return SDL_SetError("no gesture touch devices registered"); for (i = 0; i < SDL_numGestureTouches; i++) { inTouch = &SDL_gestureTouch[i]; index = SDL_AddDollarGesture_one(inTouch, path); if (index < 0) return -1; } /* Use the index of the last one added. */ return index; } return SDL_AddDollarGesture_one(inTouch, path); } int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { int i,loaded = 0; SDL_GestureTouch *touch = NULL; if (src == NULL) return 0; if (touchId >= 0) { for (i = 0; i < SDL_numGestureTouches; i++) { if (SDL_gestureTouch[i].id == touchId) { touch = &SDL_gestureTouch[i]; } } if (touch == NULL) { return SDL_SetError("given touch id not found"); } } while (1) { SDL_DollarTemplate templ; if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < DOLLARNPOINTS) { if (loaded == 0) { return SDL_SetError("could not read any dollar gesture from rwops"); } break; } #if SDL_BYTEORDER != SDL_LIL_ENDIAN for (i = 0; i < DOLLARNPOINTS; i++) { SDL_FloatPoint *p = &templ.path[i]; p->x = SDL_SwapFloatLE(p->x); p->y = SDL_SwapFloatLE(p->y); } #endif if (touchId >= 0) { /* printf("Adding loaded gesture to 1 touch\n"); */ if (SDL_AddDollarGesture(touch, templ.path) >= 0) loaded++; } else { /* printf("Adding to: %i touches\n",SDL_numGestureTouches); */ for (i = 0; i < SDL_numGestureTouches; i++) { touch = &SDL_gestureTouch[i]; /* printf("Adding loaded gesture to + touches\n"); */ /* TODO: What if this fails? */ SDL_AddDollarGesture(touch,templ.path); } loaded++; } } return loaded; } static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { /* SDL_FloatPoint p[DOLLARNPOINTS]; */ float dist = 0; SDL_FloatPoint p; int i; for (i = 0; i < DOLLARNPOINTS; i++) { p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang)); p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang)); dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+ (p.y-templ[i].y)*(p.y-templ[i].y))); } return dist/DOLLARNPOINTS; } static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { /*------------BEGIN DOLLAR BLACKBOX------------------ -TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT- -"http://depts.washington.edu/aimgroup/proj/dollar/" */ double ta = -M_PI/4; double tb = M_PI/4; double dt = M_PI/90; float x1 = (float)(PHI*ta + (1-PHI)*tb); float f1 = dollarDifference(points,templ,x1); float x2 = (float)((1-PHI)*ta + PHI*tb); float f2 = dollarDifference(points,templ,x2); while (SDL_fabs(ta-tb) > dt) { if (f1 < f2) { tb = x2; x2 = x1; f2 = f1; x1 = (float)(PHI*ta + (1-PHI)*tb); f1 = dollarDifference(points,templ,x1); } else { ta = x1; x1 = x2; f1 = f2; x2 = (float)((1-PHI)*ta + PHI*tb); f2 = dollarDifference(points,templ,x2); } } /* if (f1 <= f2) printf("Min angle (x1): %f\n",x1); else if (f1 > f2) printf("Min angle (x2): %f\n",x2); */ return SDL_min(f1,f2); } /* DollarPath contains raw points, plus (possibly) the calculated length */ static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { int i; float interval; float dist; int numPoints = 0; SDL_FloatPoint centroid; float xmin,xmax,ymin,ymax; float ang; float w,h; float length = path->length; /* Calculate length if it hasn't already been done */ if (length <= 0) { for (i=1;i < path->numPoints; i++) { float dx = path->p[i ].x - path->p[i-1].x; float dy = path->p[i ].y - path->p[i-1].y; length += (float)(SDL_sqrt(dx*dx+dy*dy)); } } /* Resample */ interval = length/(DOLLARNPOINTS - 1); dist = interval; centroid.x = 0;centroid.y = 0; /* printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); */ for (i = 1; i < path->numPoints; i++) { float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); /* printf("d = %f dist = %f/%f\n",d,dist,interval); */ while (dist + d > interval) { points[numPoints].x = path->p[i-1].x + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); points[numPoints].y = path->p[i-1].y + ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y); centroid.x += points[numPoints].x; centroid.y += points[numPoints].y; numPoints++; dist -= interval; } dist += d; } if (numPoints < DOLLARNPOINTS-1) { SDL_SetError("ERROR: NumPoints = %i", numPoints); return 0; } /* copy the last point */ points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; numPoints = DOLLARNPOINTS; centroid.x /= numPoints; centroid.y /= numPoints; /* printf("Centroid (%f,%f)",centroid.x,centroid.y); */ /* Rotate Points so point 0 is left of centroid and solve for the bounding box */ xmin = centroid.x; xmax = centroid.x; ymin = centroid.y; ymax = centroid.y; ang = (float)(SDL_atan2(centroid.y - points[0].y, centroid.x - points[0].x)); for (i = 0; i<numPoints; i++) { float px = points[i].x; float py = points[i].y; points[i].x = (float)((px - centroid.x)*SDL_cos(ang) - (py - centroid.y)*SDL_sin(ang) + centroid.x); points[i].y = (float)((px - centroid.x)*SDL_sin(ang) + (py - centroid.y)*SDL_cos(ang) + centroid.y); if (points[i].x < xmin) xmin = points[i].x; if (points[i].x > xmax) xmax = points[i].x; if (points[i].y < ymin) ymin = points[i].y; if (points[i].y > ymax) ymax = points[i].y; } /* Scale points to DOLLARSIZE, and translate to the origin */ w = xmax-xmin; h = ymax-ymin; for (i=0; i<numPoints; i++) { points[i].x = (points[i].x - centroid.x)*DOLLARSIZE/w; points[i].y = (points[i].y - centroid.y)*DOLLARSIZE/h; } return numPoints; } static float dollarRecognize(const SDL_DollarPath *path,int *bestTempl,SDL_GestureTouch* touch) { SDL_FloatPoint points[DOLLARNPOINTS]; int i; float bestDiff = 10000; SDL_memset(points, 0, sizeof(points)); dollarNormalize(path,points); /* PrintPath(points); */ *bestTempl = -1; for (i = 0; i < touch->numDollarTemplates; i++) { float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;} } return bestDiff; } int SDL_GestureAddTouch(SDL_TouchID touchId) { SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch, (SDL_numGestureTouches + 1) * sizeof(SDL_GestureTouch)); if (!gestureTouch) { return SDL_OutOfMemory(); } SDL_gestureTouch = gestureTouch; SDL_zero(SDL_gestureTouch[SDL_numGestureTouches]); SDL_gestureTouch[SDL_numGestureTouches].id = touchId; SDL_numGestureTouches++; return 0; } int SDL_GestureDelTouch(SDL_TouchID touchId) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { if (SDL_gestureTouch[i].id == touchId) { break; } } if (i == SDL_numGestureTouches) { /* not found */ return -1; } SDL_free(SDL_gestureTouch[i].dollarTemplate); SDL_zero(SDL_gestureTouch[i]); SDL_numGestureTouches--; SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); return 0; } static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) { int i; for (i = 0; i < SDL_numGestureTouches; i++) { /* printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); */ if (SDL_gestureTouch[i].id == id) return &SDL_gestureTouch[i]; } return NULL; } static int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) { SDL_Event event; event.mgesture.type = SDL_MULTIGESTURE; event.mgesture.touchId = touch->id; event.mgesture.x = touch->centroid.x; event.mgesture.y = touch->centroid.y; event.mgesture.dTheta = dTheta; event.mgesture.dDist = dDist; event.mgesture.numFingers = touch->numDownFingers; return SDL_PushEvent(&event) > 0; } static int SDL_SendGestureDollar(SDL_GestureTouch* touch, SDL_GestureID gestureId,float error) { SDL_Event event; event.dgesture.type = SDL_DOLLARGESTURE; event.dgesture.touchId = touch->id; event.dgesture.x = touch->centroid.x; event.dgesture.y = touch->centroid.y; event.dgesture.gestureId = gestureId; event.dgesture.error = error; /* A finger came up to trigger this event. */ event.dgesture.numFingers = touch->numDownFingers + 1; return SDL_PushEvent(&event) > 0; } static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) { SDL_Event event; event.dgesture.type = SDL_DOLLARRECORD; event.dgesture.touchId = touch->id; event.dgesture.gestureId = gestureId; return SDL_PushEvent(&event) > 0; } void SDL_GestureProcessEvent(SDL_Event* event) { float x,y; int index; int i; float pathDx, pathDy; SDL_FloatPoint lastP; SDL_FloatPoint lastCentroid; float lDist; float Dist; float dtheta; float dDist; if (event->type == SDL_FINGERMOTION || event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP) { SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); /* Shouldn't be possible */ if (inTouch == NULL) return; x = event->tfinger.x; y = event->tfinger.y; /* Finger Up */ if (event->type == SDL_FINGERUP) { SDL_FloatPoint path[DOLLARNPOINTS]; inTouch->numDownFingers--; #ifdef ENABLE_DOLLAR if (inTouch->recording) { inTouch->recording = SDL_FALSE; dollarNormalize(&inTouch->dollarPath,path); /* PrintPath(path); */ if (recordAll) { index = SDL_AddDollarGesture(NULL,path); for (i = 0; i < SDL_numGestureTouches; i++) SDL_gestureTouch[i].recording = SDL_FALSE; } else { index = SDL_AddDollarGesture(inTouch,path); } if (index >= 0) { SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash); } else { SDL_SendDollarRecord(inTouch,-1); } } else { int bestTempl; float error; error = dollarRecognize(&inTouch->dollarPath, &bestTempl,inTouch); if (bestTempl >= 0){ /* Send Event */ unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch,gestureId,error); /* printf ("%s\n",);("Dollar error: %f\n",error); */ } } #endif /* inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; */ if (inTouch->numDownFingers > 0) { inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- x)/inTouch->numDownFingers; inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)- y)/inTouch->numDownFingers; } } else if (event->type == SDL_FINGERMOTION) { float dx = event->tfinger.dx; float dy = event->tfinger.dy; #ifdef ENABLE_DOLLAR SDL_DollarPath* path = &inTouch->dollarPath; if (path->numPoints < MAXPATHSIZE) { path->p[path->numPoints].x = inTouch->centroid.x; path->p[path->numPoints].y = inTouch->centroid.y; pathDx = (path->p[path->numPoints].x-path->p[path->numPoints-1].x); pathDy = (path->p[path->numPoints].y-path->p[path->numPoints-1].y); path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy); path->numPoints++; } #endif lastP.x = x - dx; lastP.y = y - dy; lastCentroid = inTouch->centroid; inTouch->centroid.x += dx/inTouch->numDownFingers; inTouch->centroid.y += dy/inTouch->numDownFingers; /* printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); */ if (inTouch->numDownFingers > 1) { SDL_FloatPoint lv; /* Vector from centroid to last x,y position */ SDL_FloatPoint v; /* Vector from centroid to current x,y position */ /* lv = inTouch->gestureLast[j].cv; */ lv.x = lastP.x - lastCentroid.x; lv.y = lastP.y - lastCentroid.y; lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); /* printf("lDist = %f\n",lDist); */ v.x = x - inTouch->centroid.x; v.y = y - inTouch->centroid.y; /* inTouch->gestureLast[j].cv = v; */ Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); /* SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) */ /* Normalize Vectors to simplify angle calculation */ lv.x/=lDist; lv.y/=lDist; v.x/=Dist; v.y/=Dist; dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); dDist = (Dist - lDist); if (lDist == 0) {dDist = 0;dtheta = 0;} /* To avoid impossible values */ /* inTouch->gestureLast[j].dDist = dDist; inTouch->gestureLast[j].dtheta = dtheta; printf("dDist = %f, dTheta = %f\n",dDist,dtheta); gdtheta = gdtheta*.9 + dtheta*.1; gdDist = gdDist*.9 + dDist*.1 knob.r += dDist/numDownFingers; knob.ang += dtheta; printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); */ SDL_SendGestureMulti(inTouch,dtheta,dDist); } else { /* inTouch->gestureLast[j].dDist = 0; inTouch->gestureLast[j].dtheta = 0; inTouch->gestureLast[j].cv.x = 0; inTouch->gestureLast[j].cv.y = 0; */ } /* inTouch->gestureLast[j].f.p.x = x; inTouch->gestureLast[j].f.p.y = y; break; pressure? */ } else if (event->type == SDL_FINGERDOWN) { inTouch->numDownFingers++; inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+ x)/inTouch->numDownFingers; inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ y)/inTouch->numDownFingers; /* printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, inTouch->centroid.x,inTouch->centroid.y); */ #ifdef ENABLE_DOLLAR inTouch->dollarPath.length = 0; inTouch->dollarPath.p[0].x = x; inTouch->dollarPath.p[0].y = y; inTouch->dollarPath.numPoints = 1; #endif } } } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_gesture_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_gesture_c_h_ #define SDL_gesture_c_h_ extern int SDL_GestureAddTouch(SDL_TouchID touchId); extern int SDL_GestureDelTouch(SDL_TouchID touchId); extern void SDL_GestureProcessEvent(SDL_Event* event); extern void SDL_GestureQuit(void); #endif /* SDL_gesture_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_keyboard.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* General keyboard handling code for SDL */ #include "SDL_timer.h" #include "SDL_events.h" #include "SDL_events_c.h" #include "SDL_assert.h" #include "../video/SDL_sysvideo.h" /* #define DEBUG_KEYBOARD */ /* Global keyboard information */ typedef struct SDL_Keyboard SDL_Keyboard; struct SDL_Keyboard { /* Data common to all keyboards */ SDL_Window *focus; Uint16 modstate; Uint8 keystate[SDL_NUM_SCANCODES]; SDL_Keycode keymap[SDL_NUM_SCANCODES]; }; static SDL_Keyboard SDL_keyboard; static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = { 0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', SDLK_RETURN, SDLK_ESCAPE, SDLK_BACKSPACE, SDLK_TAB, SDLK_SPACE, '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5, SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_F11, SDLK_F12, SDLK_PRINTSCREEN, SDLK_SCROLLLOCK, SDLK_PAUSE, SDLK_INSERT, SDLK_HOME, SDLK_PAGEUP, SDLK_DELETE, SDLK_END, SDLK_PAGEDOWN, SDLK_RIGHT, SDLK_LEFT, SDLK_DOWN, SDLK_UP, SDLK_NUMLOCKCLEAR, SDLK_KP_DIVIDE, SDLK_KP_MULTIPLY, SDLK_KP_MINUS, SDLK_KP_PLUS, SDLK_KP_ENTER, SDLK_KP_1, SDLK_KP_2, SDLK_KP_3, SDLK_KP_4, SDLK_KP_5, SDLK_KP_6, SDLK_KP_7, SDLK_KP_8, SDLK_KP_9, SDLK_KP_0, SDLK_KP_PERIOD, 0, SDLK_APPLICATION, SDLK_POWER, SDLK_KP_EQUALS, SDLK_F13, SDLK_F14, SDLK_F15, SDLK_F16, SDLK_F17, SDLK_F18, SDLK_F19, SDLK_F20, SDLK_F21, SDLK_F22, SDLK_F23, SDLK_F24, SDLK_EXECUTE, SDLK_HELP, SDLK_MENU, SDLK_SELECT, SDLK_STOP, SDLK_AGAIN, SDLK_UNDO, SDLK_CUT, SDLK_COPY, SDLK_PASTE, SDLK_FIND, SDLK_MUTE, SDLK_VOLUMEUP, SDLK_VOLUMEDOWN, 0, 0, 0, SDLK_KP_COMMA, SDLK_KP_EQUALSAS400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDLK_ALTERASE, SDLK_SYSREQ, SDLK_CANCEL, SDLK_CLEAR, SDLK_PRIOR, SDLK_RETURN2, SDLK_SEPARATOR, SDLK_OUT, SDLK_OPER, SDLK_CLEARAGAIN, SDLK_CRSEL, SDLK_EXSEL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDLK_KP_00, SDLK_KP_000, SDLK_THOUSANDSSEPARATOR, SDLK_DECIMALSEPARATOR, SDLK_CURRENCYUNIT, SDLK_CURRENCYSUBUNIT, SDLK_KP_LEFTPAREN, SDLK_KP_RIGHTPAREN, SDLK_KP_LEFTBRACE, SDLK_KP_RIGHTBRACE, SDLK_KP_TAB, SDLK_KP_BACKSPACE, SDLK_KP_A, SDLK_KP_B, SDLK_KP_C, SDLK_KP_D, SDLK_KP_E, SDLK_KP_F, SDLK_KP_XOR, SDLK_KP_POWER, SDLK_KP_PERCENT, SDLK_KP_LESS, SDLK_KP_GREATER, SDLK_KP_AMPERSAND, SDLK_KP_DBLAMPERSAND, SDLK_KP_VERTICALBAR, SDLK_KP_DBLVERTICALBAR, SDLK_KP_COLON, SDLK_KP_HASH, SDLK_KP_SPACE, SDLK_KP_AT, SDLK_KP_EXCLAM, SDLK_KP_MEMSTORE, SDLK_KP_MEMRECALL, SDLK_KP_MEMCLEAR, SDLK_KP_MEMADD, SDLK_KP_MEMSUBTRACT, SDLK_KP_MEMMULTIPLY, SDLK_KP_MEMDIVIDE, SDLK_KP_PLUSMINUS, SDLK_KP_CLEAR, SDLK_KP_CLEARENTRY, SDLK_KP_BINARY, SDLK_KP_OCTAL, SDLK_KP_DECIMAL, SDLK_KP_HEXADECIMAL, 0, 0, SDLK_LCTRL, SDLK_LSHIFT, SDLK_LALT, SDLK_LGUI, SDLK_RCTRL, SDLK_RSHIFT, SDLK_RALT, SDLK_RGUI, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SDLK_MODE, SDLK_AUDIONEXT, SDLK_AUDIOPREV, SDLK_AUDIOSTOP, SDLK_AUDIOPLAY, SDLK_AUDIOMUTE, SDLK_MEDIASELECT, SDLK_WWW, SDLK_MAIL, SDLK_CALCULATOR, SDLK_COMPUTER, SDLK_AC_SEARCH, SDLK_AC_HOME, SDLK_AC_BACK, SDLK_AC_FORWARD, SDLK_AC_STOP, SDLK_AC_REFRESH, SDLK_AC_BOOKMARKS, SDLK_BRIGHTNESSDOWN, SDLK_BRIGHTNESSUP, SDLK_DISPLAYSWITCH, SDLK_KBDILLUMTOGGLE, SDLK_KBDILLUMDOWN, SDLK_KBDILLUMUP, SDLK_EJECT, SDLK_SLEEP, SDLK_APP1, SDLK_APP2, SDLK_AUDIOREWIND, SDLK_AUDIOFASTFORWARD, }; static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = { NULL, NULL, NULL, NULL, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Return", "Escape", "Backspace", "Tab", "Space", "-", "=", "[", "]", "\\", "#", ";", "'", "`", ",", ".", "/", "CapsLock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "PrintScreen", "ScrollLock", "Pause", "Insert", "Home", "PageUp", "Delete", "End", "PageDown", "Right", "Left", "Down", "Up", "Numlock", "Keypad /", "Keypad *", "Keypad -", "Keypad +", "Keypad Enter", "Keypad 1", "Keypad 2", "Keypad 3", "Keypad 4", "Keypad 5", "Keypad 6", "Keypad 7", "Keypad 8", "Keypad 9", "Keypad 0", "Keypad .", NULL, "Application", "Power", "Keypad =", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20", "F21", "F22", "F23", "F24", "Execute", "Help", "Menu", "Select", "Stop", "Again", "Undo", "Cut", "Copy", "Paste", "Find", "Mute", "VolumeUp", "VolumeDown", NULL, NULL, NULL, "Keypad ,", "Keypad = (AS400)", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "AltErase", "SysReq", "Cancel", "Clear", "Prior", "Return", "Separator", "Out", "Oper", "Clear / Again", "CrSel", "ExSel", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "Keypad 00", "Keypad 000", "ThousandsSeparator", "DecimalSeparator", "CurrencyUnit", "CurrencySubUnit", "Keypad (", "Keypad )", "Keypad {", "Keypad }", "Keypad Tab", "Keypad Backspace", "Keypad A", "Keypad B", "Keypad C", "Keypad D", "Keypad E", "Keypad F", "Keypad XOR", "Keypad ^", "Keypad %", "Keypad <", "Keypad >", "Keypad &", "Keypad &&", "Keypad |", "Keypad ||", "Keypad :", "Keypad #", "Keypad Space", "Keypad @", "Keypad !", "Keypad MemStore", "Keypad MemRecall", "Keypad MemClear", "Keypad MemAdd", "Keypad MemSubtract", "Keypad MemMultiply", "Keypad MemDivide", "Keypad +/-", "Keypad Clear", "Keypad ClearEntry", "Keypad Binary", "Keypad Octal", "Keypad Decimal", "Keypad Hexadecimal", NULL, NULL, "Left Ctrl", "Left Shift", "Left Alt", "Left GUI", "Right Ctrl", "Right Shift", "Right Alt", "Right GUI", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "ModeSwitch", "AudioNext", "AudioPrev", "AudioStop", "AudioPlay", "AudioMute", "MediaSelect", "WWW", "Mail", "Calculator", "Computer", "AC Search", "AC Home", "AC Back", "AC Forward", "AC Stop", "AC Refresh", "AC Bookmarks", "BrightnessDown", "BrightnessUp", "DisplaySwitch", "KBDIllumToggle", "KBDIllumDown", "KBDIllumUp", "Eject", "Sleep", "App1", "App2", "AudioRewind", "AudioFastForward", }; /* Taken from SDL_iconv() */ char * SDL_UCS4ToUTF8(Uint32 ch, char *dst) { Uint8 *p = (Uint8 *) dst; if (ch <= 0x7F) { *p = (Uint8) ch; ++dst; } else if (ch <= 0x7FF) { p[0] = 0xC0 | (Uint8) ((ch >> 6) & 0x1F); p[1] = 0x80 | (Uint8) (ch & 0x3F); dst += 2; } else if (ch <= 0xFFFF) { p[0] = 0xE0 | (Uint8) ((ch >> 12) & 0x0F); p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[2] = 0x80 | (Uint8) (ch & 0x3F); dst += 3; } else if (ch <= 0x1FFFFF) { p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07); p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[3] = 0x80 | (Uint8) (ch & 0x3F); dst += 4; } else if (ch <= 0x3FFFFFF) { p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03); p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[4] = 0x80 | (Uint8) (ch & 0x3F); dst += 5; } else { p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01); p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F); p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[5] = 0x80 | (Uint8) (ch & 0x3F); dst += 6; } return dst; } /* Public functions */ int SDL_KeyboardInit(void) { SDL_Keyboard *keyboard = &SDL_keyboard; /* Set the default keymap */ SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); return (0); } void SDL_ResetKeyboard(void) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; #ifdef DEBUG_KEYBOARD printf("Resetting keyboard\n"); #endif for (scancode = (SDL_Scancode) 0; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keystate[scancode] == SDL_PRESSED) { SDL_SendKeyboardKey(SDL_RELEASED, scancode); } } } void SDL_GetDefaultKeymap(SDL_Keycode * keymap) { SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); } void SDL_SetKeymap(int start, SDL_Keycode * keys, int length) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; if (start < 0 || start + length > SDL_NUM_SCANCODES) { return; } SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length); /* The number key scancodes always map to the number key keycodes. * On AZERTY layouts these technically are symbols, but users (and games) * always think of them and view them in UI as number keys. */ keyboard->keymap[SDL_SCANCODE_0] = SDLK_0; for (scancode = SDL_SCANCODE_1; scancode <= SDL_SCANCODE_9; ++scancode) { keyboard->keymap[scancode] = SDLK_1 + (scancode - SDL_SCANCODE_1); } } void SDL_SetScancodeName(SDL_Scancode scancode, const char *name) { SDL_scancode_names[scancode] = name; } SDL_Window * SDL_GetKeyboardFocus(void) { SDL_Keyboard *keyboard = &SDL_keyboard; return keyboard->focus; } void SDL_SetKeyboardFocus(SDL_Window * window) { SDL_Keyboard *keyboard = &SDL_keyboard; if (keyboard->focus && !window) { /* We won't get anymore keyboard messages, so reset keyboard state */ SDL_ResetKeyboard(); } /* See if the current window has lost focus */ if (keyboard->focus && keyboard->focus != window) { /* new window shouldn't think it has mouse captured. */ SDL_assert(!window || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)); /* old window must lose an existing mouse capture. */ if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) { SDL_CaptureMouse(SDL_FALSE); /* drop the capture. */ SDL_assert(!(keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE)); } SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); /* Ensures IME compositions are committed */ if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_VideoDevice *video = SDL_GetVideoDevice(); if (video && video->StopTextInput) { video->StopTextInput(video); } } } keyboard->focus = window; if (keyboard->focus) { SDL_SendWindowEvent(keyboard->focus, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { SDL_VideoDevice *video = SDL_GetVideoDevice(); if (video && video->StartTextInput) { video->StartTextInput(video); } } } } int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; SDL_Keymod modifier; SDL_Keycode keycode; Uint32 type; Uint8 repeat; if (!scancode) { return 0; } #ifdef DEBUG_KEYBOARD printf("The '%s' key has been %s\n", SDL_GetScancodeName(scancode), state == SDL_PRESSED ? "pressed" : "released"); #endif /* Figure out what type of event this is */ switch (state) { case SDL_PRESSED: type = SDL_KEYDOWN; break; case SDL_RELEASED: type = SDL_KEYUP; break; default: /* Invalid state -- bail */ return 0; } /* Drop events that don't change state */ repeat = (state && keyboard->keystate[scancode]); if (keyboard->keystate[scancode] == state && !repeat) { #if 0 printf("Keyboard event didn't change state - dropped!\n"); #endif return 0; } /* Update internal keyboard state */ keyboard->keystate[scancode] = state; keycode = keyboard->keymap[scancode]; /* Update modifiers state if applicable */ switch (keycode) { case SDLK_LCTRL: modifier = KMOD_LCTRL; break; case SDLK_RCTRL: modifier = KMOD_RCTRL; break; case SDLK_LSHIFT: modifier = KMOD_LSHIFT; break; case SDLK_RSHIFT: modifier = KMOD_RSHIFT; break; case SDLK_LALT: modifier = KMOD_LALT; break; case SDLK_RALT: modifier = KMOD_RALT; break; case SDLK_LGUI: modifier = KMOD_LGUI; break; case SDLK_RGUI: modifier = KMOD_RGUI; break; case SDLK_MODE: modifier = KMOD_MODE; break; default: modifier = KMOD_NONE; break; } if (SDL_KEYDOWN == type) { switch (keycode) { case SDLK_NUMLOCKCLEAR: keyboard->modstate ^= KMOD_NUM; break; case SDLK_CAPSLOCK: keyboard->modstate ^= KMOD_CAPS; break; default: keyboard->modstate |= modifier; break; } } else { keyboard->modstate &= ~modifier; } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(type) == SDL_ENABLE) { SDL_Event event; event.key.type = type; event.key.state = state; event.key.repeat = repeat; event.key.keysym.scancode = scancode; event.key.keysym.sym = keycode; event.key.keysym.mod = keyboard->modstate; event.key.windowID = keyboard->focus ? keyboard->focus->id : 0; posted = (SDL_PushEvent(&event) > 0); } return (posted); } int SDL_SendKeyboardText(const char *text) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; /* Don't post text events for unprintable characters */ if ((unsigned char)*text < ' ' || *text == 127) { return 0; } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_Event event; event.text.type = SDL_TEXTINPUT; event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); posted = (SDL_PushEvent(&event) > 0); } return (posted); } int SDL_SendEditingText(const char *text, int start, int length) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) { SDL_Event event; event.edit.type = SDL_TEXTEDITING; event.edit.windowID = keyboard->focus ? keyboard->focus->id : 0; event.edit.start = start; event.edit.length = length; SDL_utf8strlcpy(event.edit.text, text, SDL_arraysize(event.edit.text)); posted = (SDL_PushEvent(&event) > 0); } return (posted); } void SDL_KeyboardQuit(void) { } const Uint8 * SDL_GetKeyboardState(int *numkeys) { SDL_Keyboard *keyboard = &SDL_keyboard; if (numkeys != (int *) 0) { *numkeys = SDL_NUM_SCANCODES; } return keyboard->keystate; } SDL_Keymod SDL_GetModState(void) { SDL_Keyboard *keyboard = &SDL_keyboard; return (SDL_Keymod) keyboard->modstate; } void SDL_SetModState(SDL_Keymod modstate) { SDL_Keyboard *keyboard = &SDL_keyboard; keyboard->modstate = modstate; } /* Note that SDL_ToggleModState() is not a public API. SDL_SetModState() is. */ void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle) { SDL_Keyboard *keyboard = &SDL_keyboard; if (toggle) { keyboard->modstate |= modstate; } else { keyboard->modstate &= ~modstate; } } SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); return 0; } return keyboard->keymap[scancode]; } SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key) { SDL_Keyboard *keyboard = &SDL_keyboard; SDL_Scancode scancode; for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keymap[scancode] == key) { return scancode; } } return SDL_SCANCODE_UNKNOWN; } const char * SDL_GetScancodeName(SDL_Scancode scancode) { const char *name; if (((int)scancode) < ((int)SDL_SCANCODE_UNKNOWN) || scancode >= SDL_NUM_SCANCODES) { SDL_InvalidParamError("scancode"); return ""; } name = SDL_scancode_names[scancode]; if (name) return name; else return ""; } SDL_Scancode SDL_GetScancodeFromName(const char *name) { int i; if (!name || !*name) { SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { if (!SDL_scancode_names[i]) { continue; } if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { return (SDL_Scancode)i; } } SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } const char * SDL_GetKeyName(SDL_Keycode key) { static char name[8]; char *end; if (key & SDLK_SCANCODE_MASK) { return SDL_GetScancodeName((SDL_Scancode) (key & ~SDLK_SCANCODE_MASK)); } switch (key) { case SDLK_RETURN: return SDL_GetScancodeName(SDL_SCANCODE_RETURN); case SDLK_ESCAPE: return SDL_GetScancodeName(SDL_SCANCODE_ESCAPE); case SDLK_BACKSPACE: return SDL_GetScancodeName(SDL_SCANCODE_BACKSPACE); case SDLK_TAB: return SDL_GetScancodeName(SDL_SCANCODE_TAB); case SDLK_SPACE: return SDL_GetScancodeName(SDL_SCANCODE_SPACE); case SDLK_DELETE: return SDL_GetScancodeName(SDL_SCANCODE_DELETE); default: /* Unaccented letter keys on latin keyboards are normally labeled in upper case (and probably on others like Greek or Cyrillic too, so if you happen to know for sure, please adapt this). */ if (key >= 'a' && key <= 'z') { key -= 32; } end = SDL_UCS4ToUTF8((Uint32) key, name); *end = '\0'; return name; } } SDL_Keycode SDL_GetKeyFromName(const char *name) { SDL_Keycode key; /* Check input */ if (name == NULL) { return SDLK_UNKNOWN; } /* If it's a single UTF-8 character, then that's the keycode itself */ key = *(const unsigned char *)name; if (key >= 0xF0) { if (SDL_strlen(name) == 4) { int i = 0; key = (Uint16)(name[i]&0x07) << 18; key |= (Uint16)(name[++i]&0x3F) << 12; key |= (Uint16)(name[++i]&0x3F) << 6; key |= (Uint16)(name[++i]&0x3F); return key; } return SDLK_UNKNOWN; } else if (key >= 0xE0) { if (SDL_strlen(name) == 3) { int i = 0; key = (Uint16)(name[i]&0x0F) << 12; key |= (Uint16)(name[++i]&0x3F) << 6; key |= (Uint16)(name[++i]&0x3F); return key; } return SDLK_UNKNOWN; } else if (key >= 0xC0) { if (SDL_strlen(name) == 2) { int i = 0; key = (Uint16)(name[i]&0x1F) << 6; key |= (Uint16)(name[++i]&0x3F); return key; } return SDLK_UNKNOWN; } else { if (SDL_strlen(name) == 1) { if (key >= 'A' && key <= 'Z') { key += 32; } return key; } /* Get the scancode for this name, and the associated keycode */ return SDL_default_keymap[SDL_GetScancodeFromName(name)]; } } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_keyboard_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_keyboard_c_h_ #define SDL_keyboard_c_h_ #include "SDL_keycode.h" #include "SDL_events.h" /* Initialize the keyboard subsystem */ extern int SDL_KeyboardInit(void); /* Clear the state of the keyboard */ extern void SDL_ResetKeyboard(void); /* Get the default keymap */ extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap); /* Set the mapping of scancode to key codes */ extern void SDL_SetKeymap(int start, SDL_Keycode * keys, int length); /* Set a platform-dependent key name, overriding the default platform-agnostic name. Encoded as UTF-8. The string is not copied, thus the pointer given to this function must stay valid forever (or at least until the call to VideoQuit()). */ extern void SDL_SetScancodeName(SDL_Scancode scancode, const char *name); /* Set the keyboard focus window */ extern void SDL_SetKeyboardFocus(SDL_Window * window); /* Send a keyboard key event */ extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode); /* Send keyboard text input */ extern int SDL_SendKeyboardText(const char *text); /* Send editing text for selected range from start to end */ extern int SDL_SendEditingText(const char *text, int start, int end); /* Shutdown the keyboard subsystem */ extern void SDL_KeyboardQuit(void); /* Convert to UTF-8 */ extern char *SDL_UCS4ToUTF8(Uint32 ch, char *dst); /* Toggle on or off pieces of the keyboard mod state. */ extern void SDL_ToggleModState(const SDL_Keymod modstate, const SDL_bool toggle); #endif /* SDL_keyboard_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_mouse.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* General mouse handling code for SDL */ #include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_timer.h" #include "SDL_events.h" #include "SDL_events_c.h" #include "../video/SDL_sysvideo.h" /* #define DEBUG_MOUSE */ /* The mouse state */ static SDL_Mouse SDL_mouse; static int SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); static void SDLCALL SDL_MouseDoubleClickTimeChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { mouse->double_click_time = SDL_atoi(hint); } else { #ifdef __WIN32__ mouse->double_click_time = GetDoubleClickTime(); #else mouse->double_click_time = 500; #endif } } static void SDLCALL SDL_MouseDoubleClickRadiusChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { mouse->double_click_radius = SDL_atoi(hint); } else { mouse->double_click_radius = 32; /* 32 pixels seems about right for touch interfaces */ } } static void SDLCALL SDL_MouseNormalSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { mouse->normal_speed_scale = (float)SDL_atof(hint); } else { mouse->normal_speed_scale = 1.0f; } } static void SDLCALL SDL_MouseRelativeSpeedScaleChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && *hint) { mouse->relative_speed_scale = (float)SDL_atof(hint); } else { mouse->relative_speed_scale = 1.0f; } } static void SDLCALL SDL_TouchMouseEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_Mouse *mouse = (SDL_Mouse *)userdata; if (hint && (*hint == '0' || SDL_strcasecmp(hint, "false") == 0)) { mouse->touch_mouse_events = SDL_FALSE; } else { mouse->touch_mouse_events = SDL_TRUE; } } /* Public functions */ int SDL_MouseInit(void) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_zerop(mouse); SDL_AddHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_TIME, SDL_MouseDoubleClickTimeChanged, mouse); SDL_AddHintCallback(SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS, SDL_MouseDoubleClickRadiusChanged, mouse); SDL_AddHintCallback(SDL_HINT_MOUSE_NORMAL_SPEED_SCALE, SDL_MouseNormalSpeedScaleChanged, mouse); SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE, SDL_MouseRelativeSpeedScaleChanged, mouse); SDL_AddHintCallback(SDL_HINT_TOUCH_MOUSE_EVENTS, SDL_TouchMouseEventsChanged, mouse); mouse->cursor_shown = SDL_TRUE; return (0); } void SDL_SetDefaultCursor(SDL_Cursor * cursor) { SDL_Mouse *mouse = SDL_GetMouse(); mouse->def_cursor = cursor; if (!mouse->cur_cursor) { SDL_SetCursor(cursor); } } SDL_Mouse * SDL_GetMouse(void) { return &SDL_mouse; } SDL_Window * SDL_GetMouseFocus(void) { SDL_Mouse *mouse = SDL_GetMouse(); return mouse->focus; } #if 0 void SDL_ResetMouse(void) { SDL_Mouse *mouse = SDL_GetMouse(); Uint8 i; #ifdef DEBUG_MOUSE printf("Resetting mouse\n"); #endif for (i = 1; i <= sizeof(mouse->buttonstate)*8; ++i) { if (mouse->buttonstate & SDL_BUTTON(i)) { SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, i); } } SDL_assert(mouse->buttonstate == 0); } #endif void SDL_SetMouseFocus(SDL_Window * window) { SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->focus == window) { return; } /* Actually, this ends up being a bad idea, because most operating systems have an implicit grab when you press the mouse button down so you can drag things out of the window and then get the mouse up when it happens. So, #if 0... */ #if 0 if (mouse->focus && !window) { /* We won't get anymore mouse messages, so reset mouse state */ SDL_ResetMouse(); } #endif /* See if the current window has lost focus */ if (mouse->focus) { SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_LEAVE, 0, 0); } mouse->focus = window; mouse->has_position = SDL_FALSE; if (mouse->focus) { SDL_SendWindowEvent(mouse->focus, SDL_WINDOWEVENT_ENTER, 0, 0); } /* Update cursor visibility */ SDL_SetCursor(NULL); } /* Check to see if we need to synthesize focus events */ static SDL_bool SDL_UpdateMouseFocus(SDL_Window * window, int x, int y, Uint32 buttonstate) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool inWindow = SDL_TRUE; if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) { int w, h; SDL_GetWindowSizeInside(window, &w, &h); if (x < 0 || y < 0 || x >= w || y >= h) { inWindow = SDL_FALSE; } } /* Linux doesn't give you mouse events outside your window unless you grab the pointer. Windows doesn't give you mouse events outside your window unless you call SetCapture(). Both of these are slightly scary changes, so for now we'll punt and if the mouse leaves the window you'll lose mouse focus and reset button state. */ #ifdef SUPPORT_DRAG_OUTSIDE_WINDOW if (!inWindow && !buttonstate) { #else if (!inWindow) { #endif if (window == mouse->focus) { #ifdef DEBUG_MOUSE printf("Mouse left window, synthesizing move & focus lost event\n"); #endif SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y); SDL_SetMouseFocus(NULL); } return SDL_FALSE; } if (window != mouse->focus) { #ifdef DEBUG_MOUSE printf("Mouse entered window, synthesizing focus gain & move event\n"); #endif SDL_SetMouseFocus(window); SDL_PrivateSendMouseMotion(window, mouse->mouseID, 0, x, y); } return SDL_TRUE; } int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) { if (window && !relative) { SDL_Mouse *mouse = SDL_GetMouse(); if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) { return 0; } } return SDL_PrivateSendMouseMotion(window, mouseID, relative, x, y); } static int GetScaledMouseDelta(float scale, int value, float *accum) { if (scale != 1.0f) { *accum += scale * value; if (*accum >= 0.0f) { value = (int)SDL_floor(*accum); } else { value = (int)SDL_ceil(*accum); } *accum -= value; } return value; } static int SDL_PrivateSendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; int xrel; int yrel; if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) { return 0; } if (mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp) { int center_x = 0, center_y = 0; SDL_GetWindowSizeInside(window, &center_x, &center_y); center_x /= 2; center_y /= 2; if (x == center_x && y == center_y) { mouse->last_x = center_x; mouse->last_y = center_y; return 0; } SDL_WarpMouseInWindow(window, center_x, center_y); } if (relative) { if (mouse->relative_mode) { x = GetScaledMouseDelta(mouse->relative_speed_scale, x, &mouse->scale_accum_x); y = GetScaledMouseDelta(mouse->relative_speed_scale, y, &mouse->scale_accum_y); } else { x = GetScaledMouseDelta(mouse->normal_speed_scale, x, &mouse->scale_accum_x); y = GetScaledMouseDelta(mouse->normal_speed_scale, y, &mouse->scale_accum_y); } xrel = x; yrel = y; x = (mouse->last_x + xrel); y = (mouse->last_y + yrel); } else { xrel = x - mouse->last_x; yrel = y - mouse->last_y; } /* Drop events that don't change state */ if (!xrel && !yrel) { #ifdef DEBUG_MOUSE printf("Mouse event didn't change state - dropped!\n"); #endif return 0; } /* Ignore relative motion when first positioning the mouse */ if (!mouse->has_position) { xrel = 0; yrel = 0; mouse->has_position = SDL_TRUE; } /* Ignore relative motion positioning the first touch */ if (mouseID == SDL_TOUCH_MOUSEID && !mouse->buttonstate) { xrel = 0; yrel = 0; } /* Update internal mouse coordinates */ if (!mouse->relative_mode) { mouse->x = x; mouse->y = y; } else { mouse->x += xrel; mouse->y += yrel; } /* make sure that the pointers find themselves inside the windows, unless we have the mouse captured. */ if (window && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) { int x_max = 0, y_max = 0; /* !!! FIXME: shouldn't this be (window) instead of (mouse->focus)? */ SDL_GetWindowSizeInside(mouse->focus, &x_max, &y_max); --x_max; --y_max; if (mouse->x > x_max) { mouse->x = x_max; } if (mouse->x < 0) { mouse->x = 0; } if (mouse->y > y_max) { mouse->y = y_max; } if (mouse->y < 0) { mouse->y = 0; } } mouse->xdelta += xrel; mouse->ydelta += yrel; /* Move the mouse cursor, if needed */ if (mouse->cursor_shown && !mouse->relative_mode && mouse->MoveCursor && mouse->cur_cursor) { mouse->MoveCursor(mouse->cur_cursor); } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE) { SDL_Event event; event.motion.type = SDL_MOUSEMOTION; event.motion.windowID = mouse->focus ? mouse->focus->id : 0; event.motion.which = mouseID; event.motion.state = mouse->buttonstate; event.motion.x = mouse->x; event.motion.y = mouse->y; event.motion.xrel = xrel; event.motion.yrel = yrel; posted = (SDL_PushEvent(&event) > 0); } if (relative) { mouse->last_x = mouse->x; mouse->last_y = mouse->y; } else { /* Use unclamped values if we're getting events outside the window */ mouse->last_x = x; mouse->last_y = y; } return posted; } static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button) { if (button >= mouse->num_clickstates) { int i, count = button + 1; SDL_MouseClickState *clickstate = (SDL_MouseClickState *)SDL_realloc(mouse->clickstate, count * sizeof(*mouse->clickstate)); if (!clickstate) { return NULL; } mouse->clickstate = clickstate; for (i = mouse->num_clickstates; i < count; ++i) { SDL_zero(mouse->clickstate[i]); } mouse->num_clickstates = count; } return &mouse->clickstate[button]; } static int SDL_PrivateSendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; Uint32 type; Uint32 buttonstate = mouse->buttonstate; if (mouseID == SDL_TOUCH_MOUSEID && !mouse->touch_mouse_events) { return 0; } /* Figure out which event to perform */ switch (state) { case SDL_PRESSED: type = SDL_MOUSEBUTTONDOWN; buttonstate |= SDL_BUTTON(button); break; case SDL_RELEASED: type = SDL_MOUSEBUTTONUP; buttonstate &= ~SDL_BUTTON(button); break; default: /* Invalid state -- bail */ return 0; } /* We do this after calculating buttonstate so button presses gain focus */ if (window && state == SDL_PRESSED) { SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate); } if (buttonstate == mouse->buttonstate) { /* Ignore this event, no state change */ return 0; } mouse->buttonstate = buttonstate; if (clicks < 0) { SDL_MouseClickState *clickstate = GetMouseClickState(mouse, button); if (clickstate) { if (state == SDL_PRESSED) { Uint32 now = SDL_GetTicks(); if (SDL_TICKS_PASSED(now, clickstate->last_timestamp + mouse->double_click_time) || SDL_abs(mouse->x - clickstate->last_x) > mouse->double_click_radius || SDL_abs(mouse->y - clickstate->last_y) > mouse->double_click_radius) { clickstate->click_count = 0; } clickstate->last_timestamp = now; clickstate->last_x = mouse->x; clickstate->last_y = mouse->y; if (clickstate->click_count < 255) { ++clickstate->click_count; } } clicks = clickstate->click_count; } else { clicks = 1; } } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(type) == SDL_ENABLE) { SDL_Event event; event.type = type; event.button.windowID = mouse->focus ? mouse->focus->id : 0; event.button.which = mouseID; event.button.state = state; event.button.button = button; event.button.clicks = (Uint8) SDL_min(clicks, 255); event.button.x = mouse->x; event.button.y = mouse->y; posted = (SDL_PushEvent(&event) > 0); } /* We do this after dispatching event so button releases can lose focus */ if (window && state == SDL_RELEASED) { SDL_UpdateMouseFocus(window, mouse->x, mouse->y, buttonstate); } return posted; } int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks) { clicks = SDL_max(clicks, 0); return SDL_PrivateSendMouseButton(window, mouseID, state, button, clicks); } int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button) { return SDL_PrivateSendMouseButton(window, mouseID, state, button, -1); } int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction) { SDL_Mouse *mouse = SDL_GetMouse(); int posted; int integral_x, integral_y; if (window) { SDL_SetMouseFocus(window); } if (!x && !y) { return 0; } mouse->accumulated_wheel_x += x; if (mouse->accumulated_wheel_x > 0) { integral_x = (int)SDL_floor(mouse->accumulated_wheel_x); } else if (mouse->accumulated_wheel_x < 0) { integral_x = (int)SDL_ceil(mouse->accumulated_wheel_x); } else { integral_x = 0; } mouse->accumulated_wheel_x -= integral_x; mouse->accumulated_wheel_y += y; if (mouse->accumulated_wheel_y > 0) { integral_y = (int)SDL_floor(mouse->accumulated_wheel_y); } else if (mouse->accumulated_wheel_y < 0) { integral_y = (int)SDL_ceil(mouse->accumulated_wheel_y); } else { integral_y = 0; } mouse->accumulated_wheel_y -= integral_y; /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) { SDL_Event event; event.type = SDL_MOUSEWHEEL; event.wheel.windowID = mouse->focus ? mouse->focus->id : 0; event.wheel.which = mouseID; #if 0 /* Uncomment this when it goes in for SDL 2.1 */ event.wheel.preciseX = x; event.wheel.preciseY = y; #endif event.wheel.x = integral_x; event.wheel.y = integral_y; event.wheel.direction = (Uint32)direction; posted = (SDL_PushEvent(&event) > 0); } return posted; } void SDL_MouseQuit(void) { SDL_Cursor *cursor, *next; SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->CaptureMouse) { SDL_CaptureMouse(SDL_FALSE); } SDL_SetRelativeMouseMode(SDL_FALSE); SDL_ShowCursor(1); cursor = mouse->cursors; while (cursor) { next = cursor->next; SDL_FreeCursor(cursor); cursor = next; } mouse->cursors = NULL; if (mouse->def_cursor && mouse->FreeCursor) { mouse->FreeCursor(mouse->def_cursor); mouse->def_cursor = NULL; } if (mouse->clickstate) { SDL_free(mouse->clickstate); mouse->clickstate = NULL; } SDL_DelHintCallback(SDL_HINT_MOUSE_NORMAL_SPEED_SCALE, SDL_MouseNormalSpeedScaleChanged, mouse); SDL_DelHintCallback(SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE, SDL_MouseRelativeSpeedScaleChanged, mouse); } Uint32 SDL_GetMouseState(int *x, int *y) { SDL_Mouse *mouse = SDL_GetMouse(); if (x) { *x = mouse->x; } if (y) { *y = mouse->y; } return mouse->buttonstate; } Uint32 SDL_GetRelativeMouseState(int *x, int *y) { SDL_Mouse *mouse = SDL_GetMouse(); if (x) { *x = mouse->xdelta; } if (y) { *y = mouse->ydelta; } mouse->xdelta = 0; mouse->ydelta = 0; return mouse->buttonstate; } Uint32 SDL_GetGlobalMouseState(int *x, int *y) { SDL_Mouse *mouse = SDL_GetMouse(); int tmpx, tmpy; /* make sure these are never NULL for the backend implementations... */ if (!x) { x = &tmpx; } if (!y) { y = &tmpy; } *x = *y = 0; if (!mouse->GetGlobalMouseState) { return 0; } return mouse->GetGlobalMouseState(x, y); } void SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); if (window == NULL) { window = mouse->focus; } if (window == NULL) { return; } if (mouse->WarpMouse) { mouse->WarpMouse(window, x, y); } else { SDL_SendMouseMotion(window, mouse->mouseID, 0, x, y); } } int SDL_WarpMouseGlobal(int x, int y) { SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->WarpMouseGlobal) { return mouse->WarpMouseGlobal(x, y); } return SDL_Unsupported(); } static SDL_bool ShouldUseRelativeModeWarp(SDL_Mouse *mouse) { if (!mouse->SetRelativeMouseMode) { SDL_assert(mouse->WarpMouse); /* Need this functionality for relative mode warp implementation */ return SDL_TRUE; } return SDL_GetHintBoolean(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, SDL_FALSE); } int SDL_SetRelativeMouseMode(SDL_bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *focusWindow = SDL_GetKeyboardFocus(); if (enabled == mouse->relative_mode) { return 0; } if (enabled && focusWindow) { /* Center it in the focused window to prevent clicks from going through * to background windows. */ SDL_SetMouseFocus(focusWindow); SDL_WarpMouseInWindow(focusWindow, focusWindow->w/2, focusWindow->h/2); } /* Set the relative mode */ if (!enabled && mouse->relative_mode_warp) { mouse->relative_mode_warp = SDL_FALSE; } else if (enabled && ShouldUseRelativeModeWarp(mouse)) { mouse->relative_mode_warp = SDL_TRUE; } else if (mouse->SetRelativeMouseMode(enabled) < 0) { if (enabled) { /* Fall back to warp mode if native relative mode failed */ if (!mouse->WarpMouse) { return SDL_SetError("No relative mode implementation available"); } mouse->relative_mode_warp = SDL_TRUE; } } mouse->relative_mode = enabled; mouse->scale_accum_x = 0.0f; mouse->scale_accum_y = 0.0f; if (mouse->focus) { SDL_UpdateWindowGrab(mouse->focus); /* Put the cursor back to where the application expects it */ if (!enabled) { SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y); } } /* Flush pending mouse motion - ideally we would pump events, but that's not always safe */ SDL_FlushEvent(SDL_MOUSEMOTION); /* Update cursor visibility */ SDL_SetCursor(NULL); return 0; } SDL_bool SDL_GetRelativeMouseMode() { SDL_Mouse *mouse = SDL_GetMouse(); return mouse->relative_mode; } int SDL_CaptureMouse(SDL_bool enabled) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Window *focusWindow; SDL_bool isCaptured; if (!mouse->CaptureMouse) { return SDL_Unsupported(); } focusWindow = SDL_GetKeyboardFocus(); isCaptured = focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE); if (isCaptured == enabled) { return 0; /* already done! */ } if (enabled) { if (!focusWindow) { return SDL_SetError("No window has focus"); } else if (mouse->CaptureMouse(focusWindow) == -1) { return -1; /* CaptureMouse() should call SetError */ } focusWindow->flags |= SDL_WINDOW_MOUSE_CAPTURE; } else { if (mouse->CaptureMouse(NULL) == -1) { return -1; /* CaptureMouse() should call SetError */ } focusWindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; } return 0; } SDL_Cursor * SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y) { SDL_Surface *surface; SDL_Cursor *cursor; int x, y; Uint32 *pixel; Uint8 datab = 0, maskb = 0; const Uint32 black = 0xFF000000; const Uint32 white = 0xFFFFFFFF; const Uint32 transparent = 0x00000000; /* Make sure the width is a multiple of 8 */ w = ((w + 7) & ~7); /* Create the surface from a bitmap */ surface = SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); if (!surface) { return NULL; } for (y = 0; y < h; ++y) { pixel = (Uint32 *) ((Uint8 *) surface->pixels + y * surface->pitch); for (x = 0; x < w; ++x) { if ((x % 8) == 0) { datab = *data++; maskb = *mask++; } if (maskb & 0x80) { *pixel++ = (datab & 0x80) ? black : white; } else { *pixel++ = (datab & 0x80) ? black : transparent; } datab <<= 1; maskb <<= 1; } } cursor = SDL_CreateColorCursor(surface, hot_x, hot_y); SDL_FreeSurface(surface); return cursor; } SDL_Cursor * SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Surface *temp = NULL; SDL_Cursor *cursor; if (!surface) { SDL_SetError("Passed NULL cursor surface"); return NULL; } if (!mouse->CreateCursor) { SDL_SetError("Cursors are not currently supported"); return NULL; } /* Sanity check the hot spot */ if ((hot_x < 0) || (hot_y < 0) || (hot_x >= surface->w) || (hot_y >= surface->h)) { SDL_SetError("Cursor hot spot doesn't lie within cursor"); return NULL; } if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); if (!temp) { return NULL; } surface = temp; } cursor = mouse->CreateCursor(surface, hot_x, hot_y); if (cursor) { cursor->next = mouse->cursors; mouse->cursors = cursor; } SDL_FreeSurface(temp); return cursor; } SDL_Cursor * SDL_CreateSystemCursor(SDL_SystemCursor id) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *cursor; if (!mouse->CreateSystemCursor) { SDL_SetError("CreateSystemCursor is not currently supported"); return NULL; } cursor = mouse->CreateSystemCursor(id); if (cursor) { cursor->next = mouse->cursors; mouse->cursors = cursor; } return cursor; } /* SDL_SetCursor(NULL) can be used to force the cursor redraw, if this is desired for any reason. This is used when setting the video mode and when the SDL window gains the mouse focus. */ void SDL_SetCursor(SDL_Cursor * cursor) { SDL_Mouse *mouse = SDL_GetMouse(); /* Set the new cursor */ if (cursor) { /* Make sure the cursor is still valid for this mouse */ if (cursor != mouse->def_cursor) { SDL_Cursor *found; for (found = mouse->cursors; found; found = found->next) { if (found == cursor) { break; } } if (!found) { SDL_SetError("Cursor not associated with the current mouse"); return; } } mouse->cur_cursor = cursor; } else { if (mouse->focus) { cursor = mouse->cur_cursor; } else { cursor = mouse->def_cursor; } } if (cursor && mouse->cursor_shown && !mouse->relative_mode) { if (mouse->ShowCursor) { mouse->ShowCursor(cursor); } } else { if (mouse->ShowCursor) { mouse->ShowCursor(NULL); } } } SDL_Cursor * SDL_GetCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); if (!mouse) { return NULL; } return mouse->cur_cursor; } SDL_Cursor * SDL_GetDefaultCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); if (!mouse) { return NULL; } return mouse->def_cursor; } void SDL_FreeCursor(SDL_Cursor * cursor) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; if (!cursor) { return; } if (cursor == mouse->def_cursor) { return; } if (cursor == mouse->cur_cursor) { SDL_SetCursor(mouse->def_cursor); } for (prev = NULL, curr = mouse->cursors; curr; prev = curr, curr = curr->next) { if (curr == cursor) { if (prev) { prev->next = curr->next; } else { mouse->cursors = curr->next; } if (mouse->FreeCursor) { mouse->FreeCursor(curr); } return; } } } int SDL_ShowCursor(int toggle) { SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; if (!mouse) { return 0; } shown = mouse->cursor_shown; if (toggle >= 0) { if (toggle) { mouse->cursor_shown = SDL_TRUE; } else { mouse->cursor_shown = SDL_FALSE; } if (mouse->cursor_shown != shown) { SDL_SetCursor(NULL); } } return shown; } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_mouse_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_mouse_c_h_ #define SDL_mouse_c_h_ #include "SDL_mouse.h" typedef Uint32 SDL_MouseID; struct SDL_Cursor { struct SDL_Cursor *next; void *driverdata; }; typedef struct { int last_x, last_y; Uint32 last_timestamp; Uint8 click_count; } SDL_MouseClickState; typedef struct { /* Create a cursor from a surface */ SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); /* Create a system cursor */ SDL_Cursor *(*CreateSystemCursor) (SDL_SystemCursor id); /* Show the specified cursor, or hide if cursor is NULL */ int (*ShowCursor) (SDL_Cursor * cursor); /* This is called when a mouse motion event occurs */ void (*MoveCursor) (SDL_Cursor * cursor); /* Free a window manager cursor */ void (*FreeCursor) (SDL_Cursor * cursor); /* Warp the mouse to (x,y) within a window */ void (*WarpMouse) (SDL_Window * window, int x, int y); /* Warp the mouse to (x,y) in screen space */ int (*WarpMouseGlobal) (int x, int y); /* Set relative mode */ int (*SetRelativeMouseMode) (SDL_bool enabled); /* Set mouse capture */ int (*CaptureMouse) (SDL_Window * window); /* Get absolute mouse coordinates. (x) and (y) are never NULL and set to zero before call. */ Uint32 (*GetGlobalMouseState) (int *x, int *y); /* Data common to all mice */ SDL_MouseID mouseID; SDL_Window *focus; int x; int y; int xdelta; int ydelta; int last_x, last_y; /* the last reported x and y coordinates */ float accumulated_wheel_x; float accumulated_wheel_y; Uint32 buttonstate; SDL_bool has_position; SDL_bool relative_mode; SDL_bool relative_mode_warp; float normal_speed_scale; float relative_speed_scale; float scale_accum_x; float scale_accum_y; Uint32 double_click_time; int double_click_radius; SDL_bool touch_mouse_events; /* Data for double-click tracking */ int num_clickstates; SDL_MouseClickState *clickstate; SDL_Cursor *cursors; SDL_Cursor *def_cursor; SDL_Cursor *cur_cursor; SDL_bool cursor_shown; /* Driver-dependent data. */ void *driverdata; } SDL_Mouse; /* Initialize the mouse subsystem */ extern int SDL_MouseInit(void); /* Get the mouse state structure */ SDL_Mouse *SDL_GetMouse(void); /* Set the default mouse cursor */ extern void SDL_SetDefaultCursor(SDL_Cursor * cursor); /* Set the mouse focus window */ extern void SDL_SetMouseFocus(SDL_Window * window); /* Send a mouse motion event */ extern int SDL_SendMouseMotion(SDL_Window * window, SDL_MouseID mouseID, int relative, int x, int y); /* Send a mouse button event */ extern int SDL_SendMouseButton(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button); /* Send a mouse button event with a click count */ extern int SDL_SendMouseButtonClicks(SDL_Window * window, SDL_MouseID mouseID, Uint8 state, Uint8 button, int clicks); /* Send a mouse wheel event */ extern int SDL_SendMouseWheel(SDL_Window * window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction); /* Shutdown the mouse subsystem */ extern void SDL_MouseQuit(void); #endif /* SDL_mouse_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_quit.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #include "SDL_hints.h" #include "SDL_assert.h" /* General quit handling code for SDL */ #ifdef HAVE_SIGNAL_H #include <signal.h> #endif #include "SDL_events.h" #include "SDL_events_c.h" static SDL_bool disable_signals = SDL_FALSE; static SDL_bool send_quit_pending = SDL_FALSE; #ifdef HAVE_SIGNAL_H static void SDL_HandleSIG(int sig) { /* Reset the signal handler */ signal(sig, SDL_HandleSIG); /* Send a quit event next time the event loop pumps. */ /* We can't send it in signal handler; malloc() might be interrupted! */ send_quit_pending = SDL_TRUE; } #endif /* HAVE_SIGNAL_H */ /* Public functions */ static int SDL_QuitInit_Internal(void) { #ifdef HAVE_SIGACTION struct sigaction action; sigaction(SIGINT, NULL, &action); #ifdef HAVE_SA_SIGACTION if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) { #else if ( action.sa_handler == SIG_DFL ) { #endif action.sa_handler = SDL_HandleSIG; sigaction(SIGINT, &action, NULL); } sigaction(SIGTERM, NULL, &action); #ifdef HAVE_SA_SIGACTION if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) { #else if ( action.sa_handler == SIG_DFL ) { #endif action.sa_handler = SDL_HandleSIG; sigaction(SIGTERM, &action, NULL); } #elif HAVE_SIGNAL_H void (*ohandler) (int); /* Both SIGINT and SIGTERM are translated into quit interrupts */ ohandler = signal(SIGINT, SDL_HandleSIG); if (ohandler != SIG_DFL) signal(SIGINT, ohandler); ohandler = signal(SIGTERM, SDL_HandleSIG); if (ohandler != SIG_DFL) signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ /* That's it! */ return 0; } int SDL_QuitInit(void) { if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { return SDL_QuitInit_Internal(); } return 0; } static void SDL_QuitQuit_Internal(void) { #ifdef HAVE_SIGACTION struct sigaction action; sigaction(SIGINT, NULL, &action); if ( action.sa_handler == SDL_HandleSIG ) { action.sa_handler = SIG_DFL; sigaction(SIGINT, &action, NULL); } sigaction(SIGTERM, NULL, &action); if ( action.sa_handler == SDL_HandleSIG ) { action.sa_handler = SIG_DFL; sigaction(SIGTERM, &action, NULL); } #elif HAVE_SIGNAL_H void (*ohandler) (int); ohandler = signal(SIGINT, SIG_DFL); if (ohandler != SDL_HandleSIG) signal(SIGINT, ohandler); ohandler = signal(SIGTERM, SIG_DFL); if (ohandler != SDL_HandleSIG) signal(SIGTERM, ohandler); #endif /* HAVE_SIGNAL_H */ } void SDL_QuitQuit(void) { if (!disable_signals) { SDL_QuitQuit_Internal(); } } /* This function returns 1 if it's okay to close the application window */ int SDL_SendQuit(void) { send_quit_pending = SDL_FALSE; return SDL_SendAppEvent(SDL_QUIT); } void SDL_SendPendingQuit(void) { if (send_quit_pending) { SDL_SendQuit(); SDL_assert(!send_quit_pending); } } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_sysevents.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #include "../video/SDL_sysvideo.h" /* Useful functions and variables from SDL_sysevents.c */ #if defined(__HAIKU__) /* The Haiku event loops run in a separate thread */ #define MUST_THREAD_EVENTS #endif #ifdef __WIN32__ /* Windows doesn't allow a separate event thread */ #define CANT_THREAD_EVENTS #endif /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_touch.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* General touch handling code for SDL */ #include "SDL_assert.h" #include "SDL_events.h" #include "SDL_events_c.h" #include "../video/SDL_sysvideo.h" static int SDL_num_touch = 0; static SDL_Touch **SDL_touchDevices = NULL; /* Public functions */ int SDL_TouchInit(void) { return (0); } int SDL_GetNumTouchDevices(void) { return SDL_num_touch; } SDL_TouchID SDL_GetTouchDevice(int index) { if (index < 0 || index >= SDL_num_touch) { SDL_SetError("Unknown touch device index %d", index); return 0; } return SDL_touchDevices[index]->id; } static int SDL_GetTouchIndex(SDL_TouchID id) { int index; SDL_Touch *touch; for (index = 0; index < SDL_num_touch; ++index) { touch = SDL_touchDevices[index]; if (touch->id == id) { return index; } } return -1; } SDL_Touch * SDL_GetTouch(SDL_TouchID id) { int index = SDL_GetTouchIndex(id); if (index < 0 || index >= SDL_num_touch) { if (SDL_GetVideoDevice()->ResetTouch != NULL) { SDL_SetError("Unknown touch id %d, resetting", (int) id); (SDL_GetVideoDevice()->ResetTouch)(SDL_GetVideoDevice()); } else { SDL_SetError("Unknown touch device id %d, cannot reset", (int) id); } return NULL; } return SDL_touchDevices[index]; } static int SDL_GetFingerIndex(const SDL_Touch * touch, SDL_FingerID fingerid) { int index; for (index = 0; index < touch->num_fingers; ++index) { if (touch->fingers[index]->id == fingerid) { return index; } } return -1; } static SDL_Finger * SDL_GetFinger(const SDL_Touch * touch, SDL_FingerID id) { int index = SDL_GetFingerIndex(touch, id); if (index < 0 || index >= touch->num_fingers) { return NULL; } return touch->fingers[index]; } int SDL_GetNumTouchFingers(SDL_TouchID touchID) { SDL_Touch *touch = SDL_GetTouch(touchID); if (touch) { return touch->num_fingers; } return 0; } SDL_Finger * SDL_GetTouchFinger(SDL_TouchID touchID, int index) { SDL_Touch *touch = SDL_GetTouch(touchID); if (!touch) { return NULL; } if (index < 0 || index >= touch->num_fingers) { SDL_SetError("Unknown touch finger"); return NULL; } return touch->fingers[index]; } int SDL_AddTouch(SDL_TouchID touchID, const char *name) { SDL_Touch **touchDevices; int index; index = SDL_GetTouchIndex(touchID); if (index >= 0) { return index; } /* Add the touch to the list of touch */ touchDevices = (SDL_Touch **) SDL_realloc(SDL_touchDevices, (SDL_num_touch + 1) * sizeof(*touchDevices)); if (!touchDevices) { return SDL_OutOfMemory(); } SDL_touchDevices = touchDevices; index = SDL_num_touch; SDL_touchDevices[index] = (SDL_Touch *) SDL_malloc(sizeof(*SDL_touchDevices[index])); if (!SDL_touchDevices[index]) { return SDL_OutOfMemory(); } /* Added touch to list */ ++SDL_num_touch; /* we're setting the touch properties */ SDL_touchDevices[index]->id = touchID; SDL_touchDevices[index]->num_fingers = 0; SDL_touchDevices[index]->max_fingers = 0; SDL_touchDevices[index]->fingers = NULL; /* Record this touch device for gestures */ /* We could do this on the fly in the gesture code if we wanted */ SDL_GestureAddTouch(touchID); return index; } static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float y, float pressure) { SDL_Finger *finger; if (touch->num_fingers == touch->max_fingers) { SDL_Finger **new_fingers; new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers+1)*sizeof(*touch->fingers)); if (!new_fingers) { return SDL_OutOfMemory(); } touch->fingers = new_fingers; touch->fingers[touch->max_fingers] = (SDL_Finger *)SDL_malloc(sizeof(*finger)); if (!touch->fingers[touch->max_fingers]) { return SDL_OutOfMemory(); } touch->max_fingers++; } finger = touch->fingers[touch->num_fingers++]; finger->id = fingerid; finger->x = x; finger->y = y; finger->pressure = pressure; return 0; } static int SDL_DelFinger(SDL_Touch* touch, SDL_FingerID fingerid) { SDL_Finger *temp; int index = SDL_GetFingerIndex(touch, fingerid); if (index < 0) { return -1; } touch->num_fingers--; temp = touch->fingers[index]; touch->fingers[index] = touch->fingers[touch->num_fingers]; touch->fingers[touch->num_fingers] = temp; return 0; } int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure) { int posted; SDL_Finger *finger; SDL_Touch* touch = SDL_GetTouch(id); if (!touch) { return -1; } finger = SDL_GetFinger(touch, fingerid); if (down) { if (finger) { /* This finger is already down */ return 0; } if (SDL_AddFinger(touch, fingerid, x, y, pressure) < 0) { return 0; } posted = 0; if (SDL_GetEventState(SDL_FINGERDOWN) == SDL_ENABLE) { SDL_Event event; event.tfinger.type = SDL_FINGERDOWN; event.tfinger.touchId = id; event.tfinger.fingerId = fingerid; event.tfinger.x = x; event.tfinger.y = y; event.tfinger.dx = 0; event.tfinger.dy = 0; event.tfinger.pressure = pressure; posted = (SDL_PushEvent(&event) > 0); } } else { if (!finger) { /* This finger is already up */ return 0; } posted = 0; if (SDL_GetEventState(SDL_FINGERUP) == SDL_ENABLE) { SDL_Event event; event.tfinger.type = SDL_FINGERUP; event.tfinger.touchId = id; event.tfinger.fingerId = fingerid; /* I don't trust the coordinates passed on fingerUp */ event.tfinger.x = finger->x; event.tfinger.y = finger->y; event.tfinger.dx = 0; event.tfinger.dy = 0; event.tfinger.pressure = pressure; posted = (SDL_PushEvent(&event) > 0); } SDL_DelFinger(touch, fingerid); } return posted; } int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure) { SDL_Touch *touch; SDL_Finger *finger; int posted; float xrel, yrel, prel; touch = SDL_GetTouch(id); if (!touch) { return -1; } finger = SDL_GetFinger(touch,fingerid); if (!finger) { return SDL_SendTouch(id, fingerid, SDL_TRUE, x, y, pressure); } xrel = x - finger->x; yrel = y - finger->y; prel = pressure - finger->pressure; /* Drop events that don't change state */ if (!xrel && !yrel && !prel) { #if 0 printf("Touch event didn't change state - dropped!\n"); #endif return 0; } /* Update internal touch coordinates */ finger->x = x; finger->y = y; finger->pressure = pressure; /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_FINGERMOTION) == SDL_ENABLE) { SDL_Event event; event.tfinger.type = SDL_FINGERMOTION; event.tfinger.touchId = id; event.tfinger.fingerId = fingerid; event.tfinger.x = x; event.tfinger.y = y; event.tfinger.dx = xrel; event.tfinger.dy = yrel; event.tfinger.pressure = pressure; posted = (SDL_PushEvent(&event) > 0); } return posted; } void SDL_DelTouch(SDL_TouchID id) { int i; int index = SDL_GetTouchIndex(id); SDL_Touch *touch = SDL_GetTouch(id); if (!touch) { return; } for (i = 0; i < touch->max_fingers; ++i) { SDL_free(touch->fingers[i]); } SDL_free(touch->fingers); SDL_free(touch); SDL_num_touch--; SDL_touchDevices[index] = SDL_touchDevices[SDL_num_touch]; /* Delete this touch device for gestures */ SDL_GestureDelTouch(id); } void SDL_TouchQuit(void) { int i; for (i = SDL_num_touch; i--; ) { SDL_DelTouch(SDL_touchDevices[i]->id); } SDL_assert(SDL_num_touch == 0); SDL_free(SDL_touchDevices); SDL_touchDevices = NULL; SDL_GestureQuit(); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_touch_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #include "../../include/SDL_touch.h" #ifndef SDL_touch_c_h_ #define SDL_touch_c_h_ typedef struct SDL_Touch { SDL_TouchID id; int num_fingers; int max_fingers; SDL_Finger** fingers; } SDL_Touch; /* Initialize the touch subsystem */ extern int SDL_TouchInit(void); /* Add a touch, returning the index of the touch, or -1 if there was an error. */ extern int SDL_AddTouch(SDL_TouchID id, const char *name); /* Get the touch with a given id */ extern SDL_Touch *SDL_GetTouch(SDL_TouchID id); /* Send a touch down/up event for a touch */ extern int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_bool down, float x, float y, float pressure); /* Send a touch motion event for a touch */ extern int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, float x, float y, float pressure); /* Remove a touch */ extern void SDL_DelTouch(SDL_TouchID id); /* Shutdown the touch subsystem */ extern void SDL_TouchQuit(void); #endif /* SDL_touch_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_windowevents.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Window event handling code for SDL */ #include "SDL_events.h" #include "SDL_events_c.h" #include "SDL_mouse_c.h" static int SDLCALL RemovePendingResizedEvents(void * userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_RESIZED && event->window.windowID == new_event->window.windowID) { /* We're about to post a new size event, drop the old one */ return 0; } return 1; } static int SDLCALL RemovePendingSizeChangedEvents(void * userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED && event->window.windowID == new_event->window.windowID) { /* We're about to post a new size event, drop the old one */ return 0; } return 1; } static int SDLCALL RemovePendingMoveEvents(void * userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_MOVED && event->window.windowID == new_event->window.windowID) { /* We're about to post a new move event, drop the old one */ return 0; } return 1; } static int SDLCALL RemovePendingExposedEvents(void * userdata, SDL_Event *event) { SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_EXPOSED && event->window.windowID == new_event->window.windowID) { /* We're about to post a new exposed event, drop the old one */ return 0; } return 1; } int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2) { int posted; if (!window) { return 0; } switch (windowevent) { case SDL_WINDOWEVENT_SHOWN: if (window->flags & SDL_WINDOW_SHOWN) { return 0; } window->flags &= ~SDL_WINDOW_HIDDEN; window->flags |= SDL_WINDOW_SHOWN; SDL_OnWindowShown(window); break; case SDL_WINDOWEVENT_HIDDEN: if (!(window->flags & SDL_WINDOW_SHOWN)) { return 0; } window->flags &= ~SDL_WINDOW_SHOWN; window->flags |= SDL_WINDOW_HIDDEN; SDL_OnWindowHidden(window); break; case SDL_WINDOWEVENT_MOVED: if (SDL_WINDOWPOS_ISUNDEFINED(data1) || SDL_WINDOWPOS_ISUNDEFINED(data2)) { return 0; } if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { window->windowed.x = data1; window->windowed.y = data2; } if (data1 == window->x && data2 == window->y) { return 0; } window->x = data1; window->y = data2; break; case SDL_WINDOWEVENT_RESIZED: if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { window->windowed.w = data1; window->windowed.h = data2; } if (data1 == window->w && data2 == window->h) { return 0; } window->w = data1; window->h = data2; SDL_OnWindowResized(window); break; case SDL_WINDOWEVENT_MINIMIZED: if (window->flags & SDL_WINDOW_MINIMIZED) { return 0; } window->flags &= ~SDL_WINDOW_MAXIMIZED; window->flags |= SDL_WINDOW_MINIMIZED; SDL_OnWindowMinimized(window); break; case SDL_WINDOWEVENT_MAXIMIZED: if (window->flags & SDL_WINDOW_MAXIMIZED) { return 0; } window->flags &= ~SDL_WINDOW_MINIMIZED; window->flags |= SDL_WINDOW_MAXIMIZED; break; case SDL_WINDOWEVENT_RESTORED: if (!(window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { return 0; } window->flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED); SDL_OnWindowRestored(window); break; case SDL_WINDOWEVENT_ENTER: if (window->flags & SDL_WINDOW_MOUSE_FOCUS) { return 0; } window->flags |= SDL_WINDOW_MOUSE_FOCUS; SDL_OnWindowEnter(window); break; case SDL_WINDOWEVENT_LEAVE: if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) { return 0; } window->flags &= ~SDL_WINDOW_MOUSE_FOCUS; SDL_OnWindowLeave(window); break; case SDL_WINDOWEVENT_FOCUS_GAINED: if (window->flags & SDL_WINDOW_INPUT_FOCUS) { return 0; } window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_OnWindowFocusGained(window); break; case SDL_WINDOWEVENT_FOCUS_LOST: if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { return 0; } window->flags &= ~SDL_WINDOW_INPUT_FOCUS; SDL_OnWindowFocusLost(window); break; } /* Post the event, if desired */ posted = 0; if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) { SDL_Event event; event.type = SDL_WINDOWEVENT; event.window.event = windowevent; event.window.data1 = data1; event.window.data2 = data2; event.window.windowID = window->id; /* Fixes queue overflow with resize events that aren't processed */ if (windowevent == SDL_WINDOWEVENT_RESIZED) { SDL_FilterEvents(RemovePendingResizedEvents, &event); } if (windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) { SDL_FilterEvents(RemovePendingSizeChangedEvents, &event); } if (windowevent == SDL_WINDOWEVENT_MOVED) { SDL_FilterEvents(RemovePendingMoveEvents, &event); } if (windowevent == SDL_WINDOWEVENT_EXPOSED) { SDL_FilterEvents(RemovePendingExposedEvents, &event); } posted = (SDL_PushEvent(&event) > 0); } if (windowevent == SDL_WINDOWEVENT_CLOSE) { if ( !window->prev && !window->next ) { /* This is the last window in the list so send the SDL_QUIT event */ SDL_SendQuit(); } } return (posted); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\events\SDL_windowevents_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_windowevents_c_h_ #define SDL_windowevents_c_h_ extern int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2); #endif /* SDL_windowevents_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\file\SDL_rwops.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ /* We won't get fseeko64 on QNX if _LARGEFILE64_SOURCE is defined, but the configure script knows the C runtime has it and enables it. */ #ifndef __QNXNTO__ /* Need this so Linux systems define fseek64o, ftell64o and off64_t */ #define _LARGEFILE64_SOURCE #endif #include "../SDL_internal.h" #if defined(__WIN32__) #include "../core/windows/SDL_windows.h" #endif #ifdef HAVE_STDIO_H #include <stdio.h> #endif #ifdef HAVE_LIMITS_H #include <limits.h> #endif /* This file provides a general interface for SDL to read and write data sources. It can easily be extended to files, memory, etc. */ #include "SDL_endian.h" #include "SDL_rwops.h" #ifdef __APPLE__ #include "cocoa/SDL_rwopsbundlesupport.h" #endif /* __APPLE__ */ #ifdef __ANDROID__ #include "../core/android/SDL_android.h" #include "SDL_system.h" #endif #if __NACL__ #include "nacl_io/nacl_io.h" #endif #ifdef __WIN32__ /* Functions to read/write Win32 API file pointers */ #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF #endif #define READAHEAD_BUFFER_SIZE 1024 static int SDLCALL windows_file_open(SDL_RWops * context, const char *filename, const char *mode) { UINT old_error_mode; HANDLE h; DWORD r_right, w_right; DWORD must_exist, truncate; int a_mode; if (!context) return -1; /* failed (invalid call) */ context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ context->hidden.windowsio.buffer.data = NULL; context->hidden.windowsio.buffer.size = 0; context->hidden.windowsio.buffer.left = 0; /* "r" = reading, file must exist */ /* "w" = writing, truncate existing, file may not exist */ /* "r+"= reading or writing, file must exist */ /* "a" = writing, append file may not exist */ /* "a+"= append + read, file may not exist */ /* "w+" = read, write, truncate. file may not exist */ must_exist = (SDL_strchr(mode, 'r') != NULL) ? OPEN_EXISTING : 0; truncate = (SDL_strchr(mode, 'w') != NULL) ? CREATE_ALWAYS : 0; r_right = (SDL_strchr(mode, '+') != NULL || must_exist) ? GENERIC_READ : 0; a_mode = (SDL_strchr(mode, 'a') != NULL) ? OPEN_ALWAYS : 0; w_right = (a_mode || SDL_strchr(mode, '+') || truncate) ? GENERIC_WRITE : 0; if (!r_right && !w_right) /* inconsistent mode */ return -1; /* failed (invalid call) */ context->hidden.windowsio.buffer.data = (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); if (!context->hidden.windowsio.buffer.data) { return SDL_OutOfMemory(); } /* Do not open a dialog box if failure */ old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); { LPTSTR tstr = WIN_UTF8ToString(filename); h = CreateFile(tstr, (w_right | r_right), (w_right) ? 0 : FILE_SHARE_READ, NULL, (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, NULL); SDL_free(tstr); } /* restore old behavior */ SetErrorMode(old_error_mode); if (h == INVALID_HANDLE_VALUE) { SDL_free(context->hidden.windowsio.buffer.data); context->hidden.windowsio.buffer.data = NULL; SDL_SetError("Couldn't open %s", filename); return -2; /* failed (CreateFile) */ } context->hidden.windowsio.h = h; context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE; return 0; /* ok */ } static Sint64 SDLCALL windows_file_size(SDL_RWops * context) { LARGE_INTEGER size; if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_size: invalid context/file not opened"); } if (!GetFileSizeEx(context->hidden.windowsio.h, &size)) { return WIN_SetError("windows_file_size"); } return size.QuadPart; } static Sint64 SDLCALL windows_file_seek(SDL_RWops * context, Sint64 offset, int whence) { DWORD windowswhence; LARGE_INTEGER windowsoffset; if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_seek: invalid context/file not opened"); } /* FIXME: We may be able to satisfy the seek within buffered data */ if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) { offset -= (long)context->hidden.windowsio.buffer.left; } context->hidden.windowsio.buffer.left = 0; switch (whence) { case RW_SEEK_SET: windowswhence = FILE_BEGIN; break; case RW_SEEK_CUR: windowswhence = FILE_CURRENT; break; case RW_SEEK_END: windowswhence = FILE_END; break; default: return SDL_SetError("windows_file_seek: Unknown value for 'whence'"); } windowsoffset.QuadPart = offset; if (!SetFilePointerEx(context->hidden.windowsio.h, windowsoffset, &windowsoffset, windowswhence)) { return WIN_SetError("windows_file_seek"); } return windowsoffset.QuadPart; } static size_t SDLCALL windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) { size_t total_need; size_t total_read = 0; size_t read_ahead; DWORD byte_read; total_need = size * maxnum; if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) return 0; if (context->hidden.windowsio.buffer.left > 0) { void *data = (char *) context->hidden.windowsio.buffer.data + context->hidden.windowsio.buffer.size - context->hidden.windowsio.buffer.left; read_ahead = SDL_min(total_need, context->hidden.windowsio.buffer.left); SDL_memcpy(ptr, data, read_ahead); context->hidden.windowsio.buffer.left -= read_ahead; if (read_ahead == total_need) { return maxnum; } ptr = (char *) ptr + read_ahead; total_need -= read_ahead; total_read += read_ahead; } if (total_need < READAHEAD_BUFFER_SIZE) { if (!ReadFile (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } read_ahead = SDL_min(total_need, (int) byte_read); SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead); context->hidden.windowsio.buffer.size = byte_read; context->hidden.windowsio.buffer.left = byte_read - read_ahead; total_read += read_ahead; } else { if (!ReadFile (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } total_read += byte_read; } return (total_read / size); } static size_t SDLCALL windows_file_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) { size_t total_bytes; DWORD byte_written; size_t nwritten; total_bytes = size * num; if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || total_bytes <= 0 || !size) return 0; if (context->hidden.windowsio.buffer.left) { SetFilePointer(context->hidden.windowsio.h, -(LONG)context->hidden.windowsio.buffer.left, NULL, FILE_CURRENT); context->hidden.windowsio.buffer.left = 0; } /* if in append mode, we must go to the EOF before write */ if (context->hidden.windowsio.append) { if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) == INVALID_SET_FILE_POINTER) { SDL_Error(SDL_EFWRITE); return 0; } } if (!WriteFile (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { SDL_Error(SDL_EFWRITE); return 0; } nwritten = byte_written / size; return nwritten; } static int SDLCALL windows_file_close(SDL_RWops * context) { if (context) { if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) { CloseHandle(context->hidden.windowsio.h); context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ } SDL_free(context->hidden.windowsio.buffer.data); context->hidden.windowsio.buffer.data = NULL; SDL_FreeRW(context); } return 0; } #endif /* __WIN32__ */ #ifdef HAVE_STDIO_H #ifdef HAVE_FOPEN64 #define fopen fopen64 #endif #ifdef HAVE_FSEEKO64 #define fseek_off_t off64_t #define fseek fseeko64 #define ftell ftello64 #elif defined(HAVE_FSEEKO) #if defined(OFF_MIN) && defined(OFF_MAX) #define FSEEK_OFF_MIN OFF_MIN #define FSEEK_OFF_MAX OFF_MAX #elif defined(HAVE_LIMITS_H) /* POSIX doesn't specify the minimum and maximum macros for off_t so * we have to improvise and dance around implementation-defined * behavior. This may fail if the off_t type has padding bits or * is not a two's-complement representation. The compilers will detect * and eliminate the dead code if off_t has 64 bits. */ #define FSEEK_OFF_MAX (((((off_t)1 << (sizeof(off_t) * CHAR_BIT - 2)) - 1) << 1) + 1) #define FSEEK_OFF_MIN (-(FSEEK_OFF_MAX) - 1) #endif #define fseek_off_t off_t #define fseek fseeko #define ftell ftello #elif defined(HAVE__FSEEKI64) #define fseek_off_t __int64 #define fseek _fseeki64 #define ftell _ftelli64 #else #ifdef HAVE_LIMITS_H #define FSEEK_OFF_MIN LONG_MIN #define FSEEK_OFF_MAX LONG_MAX #endif #define fseek_off_t long #endif /* Functions to read/write stdio file pointers */ static Sint64 SDLCALL stdio_size(SDL_RWops * context) { Sint64 pos, size; pos = SDL_RWseek(context, 0, RW_SEEK_CUR); if (pos < 0) { return -1; } size = SDL_RWseek(context, 0, RW_SEEK_END); SDL_RWseek(context, pos, RW_SEEK_SET); return size; } static Sint64 SDLCALL stdio_seek(SDL_RWops * context, Sint64 offset, int whence) { #if defined(FSEEK_OFF_MIN) && defined(FSEEK_OFF_MAX) if (offset < (Sint64)(FSEEK_OFF_MIN) || offset > (Sint64)(FSEEK_OFF_MAX)) { return SDL_SetError("Seek offset out of range"); } #endif if (fseek(context->hidden.stdio.fp, (fseek_off_t)offset, whence) == 0) { Sint64 pos = ftell(context->hidden.stdio.fp); if (pos < 0) { return SDL_SetError("Couldn't get stream offset"); } return pos; } return SDL_Error(SDL_EFSEEK); } static size_t SDLCALL stdio_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) { size_t nread; nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); if (nread == 0 && ferror(context->hidden.stdio.fp)) { SDL_Error(SDL_EFREAD); } return nread; } static size_t SDLCALL stdio_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) { size_t nwrote; nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp); if (nwrote == 0 && ferror(context->hidden.stdio.fp)) { SDL_Error(SDL_EFWRITE); } return nwrote; } static int SDLCALL stdio_close(SDL_RWops * context) { int status = 0; if (context) { if (context->hidden.stdio.autoclose) { /* WARNING: Check the return value here! */ if (fclose(context->hidden.stdio.fp) != 0) { status = SDL_Error(SDL_EFWRITE); } } SDL_FreeRW(context); } return status; } #endif /* !HAVE_STDIO_H */ /* Functions to read/write memory pointers */ static Sint64 SDLCALL mem_size(SDL_RWops * context) { return (Sint64)(context->hidden.mem.stop - context->hidden.mem.base); } static Sint64 SDLCALL mem_seek(SDL_RWops * context, Sint64 offset, int whence) { Uint8 *newpos; switch (whence) { case RW_SEEK_SET: newpos = context->hidden.mem.base + offset; break; case RW_SEEK_CUR: newpos = context->hidden.mem.here + offset; break; case RW_SEEK_END: newpos = context->hidden.mem.stop + offset; break; default: return SDL_SetError("Unknown value for 'whence'"); } if (newpos < context->hidden.mem.base) { newpos = context->hidden.mem.base; } if (newpos > context->hidden.mem.stop) { newpos = context->hidden.mem.stop; } context->hidden.mem.here = newpos; return (Sint64)(context->hidden.mem.here - context->hidden.mem.base); } static size_t SDLCALL mem_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) { size_t total_bytes; size_t mem_available; total_bytes = (maxnum * size); if ((maxnum <= 0) || (size <= 0) || ((total_bytes / maxnum) != (size_t) size)) { return 0; } mem_available = (context->hidden.mem.stop - context->hidden.mem.here); if (total_bytes > mem_available) { total_bytes = mem_available; } SDL_memcpy(ptr, context->hidden.mem.here, total_bytes); context->hidden.mem.here += total_bytes; return (total_bytes / size); } static size_t SDLCALL mem_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) { if ((context->hidden.mem.here + (num * size)) > context->hidden.mem.stop) { num = (context->hidden.mem.stop - context->hidden.mem.here) / size; } SDL_memcpy(context->hidden.mem.here, ptr, num * size); context->hidden.mem.here += num * size; return num; } static size_t SDLCALL mem_writeconst(SDL_RWops * context, const void *ptr, size_t size, size_t num) { SDL_SetError("Can't write to read-only memory"); return 0; } static int SDLCALL mem_close(SDL_RWops * context) { if (context) { SDL_FreeRW(context); } return 0; } /* Functions to create SDL_RWops structures from various data sources */ SDL_RWops * SDL_RWFromFile(const char *file, const char *mode) { SDL_RWops *rwops = NULL; if (!file || !*file || !mode || !*mode) { SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } #if defined(__ANDROID__) #ifdef HAVE_STDIO_H /* Try to open the file on the filesystem first */ if (*file == '/') { FILE *fp = fopen(file, mode); if (fp) { return SDL_RWFromFP(fp, 1); } } else { /* Try opening it from internal storage if it's a relative path */ char *path; FILE *fp; path = SDL_stack_alloc(char, PATH_MAX); if (path) { SDL_snprintf(path, PATH_MAX, "%s/%s", SDL_AndroidGetInternalStoragePath(), file); fp = fopen(path, mode); SDL_stack_free(path); if (fp) { return SDL_RWFromFP(fp, 1); } } } #endif /* HAVE_STDIO_H */ /* Try to open the file from the asset system */ rwops = SDL_AllocRW(); if (!rwops) return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ if (Android_JNI_FileOpen(rwops, file, mode) < 0) { SDL_FreeRW(rwops); return NULL; } rwops->size = Android_JNI_FileSize; rwops->seek = Android_JNI_FileSeek; rwops->read = Android_JNI_FileRead; rwops->write = Android_JNI_FileWrite; rwops->close = Android_JNI_FileClose; rwops->type = SDL_RWOPS_JNIFILE; #elif defined(__WIN32__) rwops = SDL_AllocRW(); if (!rwops) return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ if (windows_file_open(rwops, file, mode) < 0) { SDL_FreeRW(rwops); return NULL; } rwops->size = windows_file_size; rwops->seek = windows_file_seek; rwops->read = windows_file_read; rwops->write = windows_file_write; rwops->close = windows_file_close; rwops->type = SDL_RWOPS_WINFILE; #elif HAVE_STDIO_H { #ifdef __APPLE__ FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); #elif __WINRT__ FILE *fp = NULL; fopen_s(&fp, file, mode); #else FILE *fp = fopen(file, mode); #endif if (fp == NULL) { SDL_SetError("Couldn't open %s", file); } else { rwops = SDL_RWFromFP(fp, 1); } } #else SDL_SetError("SDL not compiled with stdio support"); #endif /* !HAVE_STDIO_H */ return rwops; } #ifdef HAVE_STDIO_H SDL_RWops * SDL_RWFromFP(FILE * fp, SDL_bool autoclose) { SDL_RWops *rwops = NULL; rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->size = stdio_size; rwops->seek = stdio_seek; rwops->read = stdio_read; rwops->write = stdio_write; rwops->close = stdio_close; rwops->hidden.stdio.fp = fp; rwops->hidden.stdio.autoclose = autoclose; rwops->type = SDL_RWOPS_STDFILE; } return rwops; } #else SDL_RWops * SDL_RWFromFP(void * fp, SDL_bool autoclose) { SDL_SetError("SDL not compiled with stdio support"); return NULL; } #endif /* HAVE_STDIO_H */ SDL_RWops * SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops = NULL; if (!mem) { SDL_InvalidParamError("mem"); return rwops; } if (!size) { SDL_InvalidParamError("size"); return rwops; } rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; rwops->write = mem_write; rwops->close = mem_close; rwops->hidden.mem.base = (Uint8 *) mem; rwops->hidden.mem.here = rwops->hidden.mem.base; rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY; } return rwops; } SDL_RWops * SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops = NULL; if (!mem) { SDL_InvalidParamError("mem"); return rwops; } if (!size) { SDL_InvalidParamError("size"); return rwops; } rwops = SDL_AllocRW(); if (rwops != NULL) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; rwops->write = mem_writeconst; rwops->close = mem_close; rwops->hidden.mem.base = (Uint8 *) mem; rwops->hidden.mem.here = rwops->hidden.mem.base; rwops->hidden.mem.stop = rwops->hidden.mem.base + size; rwops->type = SDL_RWOPS_MEMORY_RO; } return rwops; } SDL_RWops * SDL_AllocRW(void) { SDL_RWops *area; area = (SDL_RWops *) SDL_malloc(sizeof *area); if (area == NULL) { SDL_OutOfMemory(); } else { area->type = SDL_RWOPS_UNKNOWN; } return area; } void SDL_FreeRW(SDL_RWops * area) { SDL_free(area); } /* Load all the data from an SDL data stream */ void * SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, int freesrc) { const int FILE_CHUNK_SIZE = 1024; Sint64 size; size_t size_read, size_total; void *data = NULL, *newdata; if (!src) { SDL_InvalidParamError("src"); return NULL; } size = SDL_RWsize(src); if (size < 0) { size = FILE_CHUNK_SIZE; } data = SDL_malloc((size_t)(size + 1)); size_total = 0; for (;;) { if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) { size = (size_total + FILE_CHUNK_SIZE); newdata = SDL_realloc(data, (size_t)(size + 1)); if (!newdata) { SDL_free(data); data = NULL; SDL_OutOfMemory(); goto done; } data = newdata; } size_read = SDL_RWread(src, (char *)data+size_total, 1, (size_t)(size-size_total)); if (size_read == 0) { break; } size_total += size_read; } if (datasize) { *datasize = size_total; } ((char *)data)[size_total] = '\0'; done: if (freesrc && src) { SDL_RWclose(src); } return data; } /* Functions for dynamically reading and writing endian-specific values */ Uint8 SDL_ReadU8(SDL_RWops * src) { Uint8 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return value; } Uint16 SDL_ReadLE16(SDL_RWops * src) { Uint16 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapLE16(value); } Uint16 SDL_ReadBE16(SDL_RWops * src) { Uint16 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapBE16(value); } Uint32 SDL_ReadLE32(SDL_RWops * src) { Uint32 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapLE32(value); } Uint32 SDL_ReadBE32(SDL_RWops * src) { Uint32 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapBE32(value); } Uint64 SDL_ReadLE64(SDL_RWops * src) { Uint64 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapLE64(value); } Uint64 SDL_ReadBE64(SDL_RWops * src) { Uint64 value = 0; SDL_RWread(src, &value, sizeof (value), 1); return SDL_SwapBE64(value); } size_t SDL_WriteU8(SDL_RWops * dst, Uint8 value) { return SDL_RWwrite(dst, &value, sizeof (value), 1); } size_t SDL_WriteLE16(SDL_RWops * dst, Uint16 value) { const Uint16 swapped = SDL_SwapLE16(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE16(SDL_RWops * dst, Uint16 value) { const Uint16 swapped = SDL_SwapBE16(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteLE32(SDL_RWops * dst, Uint32 value) { const Uint32 swapped = SDL_SwapLE32(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE32(SDL_RWops * dst, Uint32 value) { const Uint32 swapped = SDL_SwapBE32(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteLE64(SDL_RWops * dst, Uint64 value) { const Uint64 swapped = SDL_SwapLE64(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } size_t SDL_WriteBE64(SDL_RWops * dst, Uint64 value) { const Uint64 swapped = SDL_SwapBE64(value); return SDL_RWwrite(dst, &swapped, sizeof (swapped), 1); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\file
D://workCode//uploadProject\awtk\3rd\SDL\src\file\cocoa\SDL_rwopsbundlesupport.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifdef __APPLE__ #include <stdio.h> #ifndef SDL_rwopsbundlesupport_h #define SDL_rwopsbundlesupport_h FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode); #endif #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\android\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_FILESYSTEM_ANDROID /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ #include <unistd.h> #include "SDL_error.h" #include "SDL_filesystem.h" #include "SDL_system.h" char * SDL_GetBasePath(void) { /* The current working directory is / on Android */ SDL_Unsupported(); return NULL; } char * SDL_GetPrefPath(const char *org, const char *app) { const char *path = SDL_AndroidGetInternalStoragePath(); if (path) { size_t pathlen = SDL_strlen(path)+2; char *fullpath = (char *)SDL_malloc(pathlen); if (!fullpath) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(fullpath, pathlen, "%s/", path); return fullpath; } return NULL; } #endif /* SDL_FILESYSTEM_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\dummy\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if defined(SDL_FILESYSTEM_DUMMY) || defined(SDL_FILESYSTEM_DISABLED) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ #include "SDL_error.h" #include "SDL_filesystem.h" char * SDL_GetBasePath(void) { SDL_Unsupported(); return NULL; } char * SDL_GetPrefPath(const char *org, const char *app) { SDL_Unsupported(); return NULL; } #endif /* SDL_FILESYSTEM_DUMMY || SDL_FILESYSTEM_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\emscripten\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_FILESYSTEM_EMSCRIPTEN /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ #include <errno.h> #include <sys/stat.h> #include "SDL_error.h" #include "SDL_filesystem.h" #include <emscripten/emscripten.h> char * SDL_GetBasePath(void) { char *retval = "/"; return SDL_strdup(retval); } char * SDL_GetPrefPath(const char *org, const char *app) { const char *append = "/libsdl/"; char *retval; size_t len = 0; if (!app) { SDL_InvalidParamError("app"); return NULL; } if (!org) { org = ""; } len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); return NULL; } if (*org) { SDL_snprintf(retval, len, "%s%s/%s/", append, org, app); } else { SDL_snprintf(retval, len, "%s%s/", append, app); } if (mkdir(retval, 0700) != 0 && errno != EEXIST) { SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; } return retval; } #endif /* SDL_FILESYSTEM_EMSCRIPTEN */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\nacl\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_error.h" #include "SDL_filesystem.h" #ifdef SDL_FILESYSTEM_NACL char * SDL_GetBasePath(void) { SDL_Unsupported(); return NULL; } char * SDL_GetPrefPath(const char *org, const char *app) { SDL_Unsupported(); return NULL; } #endif /* SDL_FILESYSTEM_NACL */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\unix\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_FILESYSTEM_UNIX /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ #include <errno.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <limits.h> #include <fcntl.h> #if defined(__FREEBSD__) || defined(__OPENBSD__) #include <sys/sysctl.h> #endif #include "SDL_error.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" #include "SDL_rwops.h" /* QNX's /proc/self/exefile is a text file and not a symlink. */ #if !defined(__QNXNTO__) static char * readSymLink(const char *path) { char *retval = NULL; ssize_t len = 64; ssize_t rc = -1; while (1) { char *ptr = (char *) SDL_realloc(retval, (size_t) len); if (ptr == NULL) { SDL_OutOfMemory(); break; } retval = ptr; rc = readlink(path, retval, len); if (rc == -1) { break; /* not a symlink, i/o error, etc. */ } else if (rc < len) { retval[rc] = '\0'; /* readlink doesn't null-terminate. */ return retval; /* we're good to go. */ } len *= 2; /* grow buffer, try again. */ } SDL_free(retval); return NULL; } #endif char * SDL_GetBasePath(void) { char *retval = NULL; #if defined(__FREEBSD__) char fullpath[PATH_MAX]; size_t buflen = sizeof (fullpath); const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); if (!retval) { SDL_OutOfMemory(); return NULL; } } #endif #if defined(__OPENBSD__) char **retvalargs; size_t len; const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { retvalargs = SDL_malloc(len); if (!retvalargs) { SDL_OutOfMemory(); return NULL; } sysctl(mib, 4, retvalargs, &len, NULL, 0); retval = SDL_malloc(PATH_MAX + 1); if (retval) realpath(retvalargs[0], retval); SDL_free(retvalargs); } #endif #if defined(__SOLARIS__) const char *path = getexecname(); if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ retval = SDL_strdup(path); if (!retval) { SDL_OutOfMemory(); return NULL; } } #endif /* is a Linux-style /proc filesystem available? */ if (!retval && (access("/proc", F_OK) == 0)) { /* !!! FIXME: after 2.0.6 ships, let's delete this code and just use the /proc/%llu version. There's no reason to have two copies of this plus all the #ifdefs. --ryan. */ #if defined(__FREEBSD__) retval = readSymLink("/proc/curproc/file"); #elif defined(__NETBSD__) retval = readSymLink("/proc/curproc/exe"); #elif defined(__QNXNTO__) retval = SDL_LoadFile("/proc/self/exefile", NULL); #else retval = readSymLink("/proc/self/exe"); /* linux. */ if (retval == NULL) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; const int rc = (int) SDL_snprintf(path, sizeof(path), "/proc/%llu/exe", (unsigned long long) getpid()); if ( (rc > 0) && (rc < sizeof(path)) ) { retval = readSymLink(path); } } #endif } /* If we had access to argv[0] here, we could check it for a path, or troll through $PATH looking for it, too. */ if (retval != NULL) { /* chop off filename. */ char *ptr = SDL_strrchr(retval, '/'); if (ptr != NULL) { *(ptr+1) = '\0'; } else { /* shouldn't happen, but just in case... */ SDL_free(retval); retval = NULL; } } if (retval != NULL) { /* try to shrink buffer... */ char *ptr = (char *) SDL_realloc(retval, strlen(retval) + 1); if (ptr != NULL) retval = ptr; /* oh well if it failed. */ } return retval; } char * SDL_GetPrefPath(const char *org, const char *app) { /* * We use XDG's base directory spec, even if you're not on Linux. * This isn't strictly correct, but the results are relatively sane * in any case. * * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html */ const char *envr = SDL_getenv("XDG_DATA_HOME"); const char *append; char *retval = NULL; char *ptr = NULL; size_t len = 0; if (!app) { SDL_InvalidParamError("app"); return NULL; } if (!org) { org = ""; } if (!envr) { /* You end up with "$HOME/.local/share/Game Name 2" */ envr = SDL_getenv("HOME"); if (!envr) { /* we could take heroic measures with /etc/passwd, but oh well. */ SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; } append = "/.local/share/"; } else { append = "/"; } len = SDL_strlen(envr); if (envr[len - 1] == '/') append += 1; len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *) SDL_malloc(len); if (!retval) { SDL_OutOfMemory(); return NULL; } if (*org) { SDL_snprintf(retval, len, "%s%s%s/%s/", envr, append, org, app); } else { SDL_snprintf(retval, len, "%s%s%s/", envr, append, app); } for (ptr = retval+1; *ptr; ptr++) { if (*ptr == '/') { *ptr = '\0'; if (mkdir(retval, 0700) != 0 && errno != EEXIST) goto error; *ptr = '/'; } } if (mkdir(retval, 0700) != 0 && errno != EEXIST) { error: SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; } return retval; } #endif /* SDL_FILESYSTEM_UNIX */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem
D://workCode//uploadProject\awtk\3rd\SDL\src\filesystem\windows\SDL_sysfilesystem.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_FILESYSTEM_WINDOWS /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* System dependent filesystem routines */ #include "../../core/windows/SDL_windows.h" #include <shlobj.h> #include "SDL_assert.h" #include "SDL_error.h" #include "SDL_stdinc.h" #include "SDL_filesystem.h" char * SDL_GetBasePath(void) { typedef DWORD (WINAPI *GetModuleFileNameExW_t)(HANDLE, HMODULE, LPWSTR, DWORD); GetModuleFileNameExW_t pGetModuleFileNameExW; DWORD buflen = 128; WCHAR *path = NULL; HANDLE psapi = LoadLibrary(L"psapi.dll"); char *retval = NULL; DWORD len = 0; int i; if (!psapi) { WIN_SetError("Couldn't load psapi.dll"); return NULL; } pGetModuleFileNameExW = (GetModuleFileNameExW_t)GetProcAddress(psapi, "GetModuleFileNameExW"); if (!pGetModuleFileNameExW) { WIN_SetError("Couldn't find GetModuleFileNameExW"); FreeLibrary(psapi); return NULL; } while (SDL_TRUE) { void *ptr = SDL_realloc(path, buflen * sizeof (WCHAR)); if (!ptr) { SDL_free(path); FreeLibrary(psapi); SDL_OutOfMemory(); return NULL; } path = (WCHAR *) ptr; len = pGetModuleFileNameExW(GetCurrentProcess(), NULL, path, buflen); if (len != buflen) { break; } /* buffer too small? Try again. */ buflen *= 2; } FreeLibrary(psapi); if (len == 0) { SDL_free(path); WIN_SetError("Couldn't locate our .exe"); return NULL; } for (i = len-1; i > 0; i--) { if (path[i] == '\\') { break; } } SDL_assert(i > 0); /* Should have been an absolute path. */ path[i+1] = '\0'; /* chop off filename. */ retval = WIN_StringToUTF8(path); SDL_free(path); return retval; } char * SDL_GetPrefPath(const char *org, const char *app) { /* * Vista and later has a new API for this, but SHGetFolderPath works there, * and apparently just wraps the new API. This is the new way to do it: * * SHGetKnownFolderPath(FOLDERID_RoamingAppData, KF_FLAG_CREATE, * NULL, &wszPath); */ WCHAR path[MAX_PATH]; char *retval = NULL; WCHAR* worg = NULL; WCHAR* wapp = NULL; size_t new_wpath_len = 0; BOOL api_result = FALSE; if (!app) { SDL_InvalidParamError("app"); return NULL; } if (!org) { org = ""; } if (!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { WIN_SetError("Couldn't locate our prefpath"); return NULL; } worg = WIN_UTF8ToString(org); if (worg == NULL) { SDL_OutOfMemory(); return NULL; } wapp = WIN_UTF8ToString(app); if (wapp == NULL) { SDL_free(worg); SDL_OutOfMemory(); return NULL; } new_wpath_len = lstrlenW(worg) + lstrlenW(wapp) + lstrlenW(path) + 3; if ((new_wpath_len + 1) > MAX_PATH) { SDL_free(worg); SDL_free(wapp); WIN_SetError("Path too long."); return NULL; } if (*worg) { lstrcatW(path, L"\\"); lstrcatW(path, worg); } SDL_free(worg); api_result = CreateDirectoryW(path, NULL); if (api_result == FALSE) { if (GetLastError() != ERROR_ALREADY_EXISTS) { SDL_free(wapp); WIN_SetError("Couldn't create a prefpath."); return NULL; } } lstrcatW(path, L"\\"); lstrcatW(path, wapp); SDL_free(wapp); api_result = CreateDirectoryW(path, NULL); if (api_result == FALSE) { if (GetLastError() != ERROR_ALREADY_EXISTS) { WIN_SetError("Couldn't create a prefpath."); return NULL; } } lstrcatW(path, L"\\"); retval = WIN_StringToUTF8(path); return retval; } #endif /* SDL_FILESYSTEM_WINDOWS */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\SDL_haptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #include "SDL_syshaptic.h" #include "SDL_haptic_c.h" #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */ #include "SDL_assert.h" /* Global for SDL_windowshaptic.c */ SDL_Haptic *SDL_haptics = NULL; /* * Initializes the Haptic devices. */ int SDL_HapticInit(void) { int status; status = SDL_SYS_HapticInit(); if (status >= 0) { status = 0; } return status; } /* * Checks to see if the haptic device is valid */ static int ValidHaptic(SDL_Haptic * haptic) { int valid; SDL_Haptic *hapticlist; valid = 0; if (haptic != NULL) { hapticlist = SDL_haptics; while ( hapticlist ) { if (hapticlist == haptic) { valid = 1; break; } hapticlist = hapticlist->next; } } /* Create the error here. */ if (valid == 0) { SDL_SetError("Haptic: Invalid haptic device identifier"); } return valid; } /* * Returns the number of available devices. */ int SDL_NumHaptics(void) { return SDL_SYS_NumHaptics(); } /* * Gets the name of a Haptic device by index. */ const char * SDL_HapticName(int device_index) { if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", SDL_NumHaptics()); return NULL; } return SDL_SYS_HapticName(device_index); } /* * Opens a Haptic device. */ SDL_Haptic * SDL_HapticOpen(int device_index) { SDL_Haptic *haptic; SDL_Haptic *hapticlist; if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", SDL_NumHaptics()); return NULL; } hapticlist = SDL_haptics; /* If the haptic is already open, return it * TODO: Should we create haptic instance IDs like the Joystick API? */ while ( hapticlist ) { if (device_index == hapticlist->index) { haptic = hapticlist; ++haptic->ref_count; return haptic; } hapticlist = hapticlist->next; } /* Create the haptic device */ haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic)); if (haptic == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize the haptic device */ SDL_memset(haptic, 0, (sizeof *haptic)); haptic->rumble_id = -1; haptic->index = device_index; if (SDL_SYS_HapticOpen(haptic) < 0) { SDL_free(haptic); return NULL; } /* Add haptic to list */ ++haptic->ref_count; /* Link the haptic in the list */ haptic->next = SDL_haptics; SDL_haptics = haptic; /* Disable autocenter and set gain to max. */ if (haptic->supported & SDL_HAPTIC_GAIN) SDL_HapticSetGain(haptic, 100); if (haptic->supported & SDL_HAPTIC_AUTOCENTER) SDL_HapticSetAutocenter(haptic, 0); return haptic; } /* * Returns 1 if the device has been opened. */ int SDL_HapticOpened(int device_index) { int opened; SDL_Haptic *hapticlist; /* Make sure it's valid. */ if ((device_index < 0) || (device_index >= SDL_NumHaptics())) { SDL_SetError("Haptic: There are %d haptic devices available", SDL_NumHaptics()); return 0; } opened = 0; hapticlist = SDL_haptics; /* TODO Should this use an instance ID? */ while ( hapticlist ) { if (hapticlist->index == (Uint8) device_index) { opened = 1; break; } hapticlist = hapticlist->next; } return opened; } /* * Returns the index to a haptic device. */ int SDL_HapticIndex(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } return haptic->index; } /* * Returns SDL_TRUE if mouse is haptic, SDL_FALSE if it isn't. */ int SDL_MouseIsHaptic(void) { if (SDL_SYS_HapticMouse() < 0) return SDL_FALSE; return SDL_TRUE; } /* * Returns the haptic device if mouse is haptic or NULL elsewise. */ SDL_Haptic * SDL_HapticOpenFromMouse(void) { int device_index; device_index = SDL_SYS_HapticMouse(); if (device_index < 0) { SDL_SetError("Haptic: Mouse isn't a haptic device."); return NULL; } return SDL_HapticOpen(device_index); } /* * Returns SDL_TRUE if joystick has haptic features. */ int SDL_JoystickIsHaptic(SDL_Joystick * joystick) { int ret; /* Must be a valid joystick */ if (!SDL_PrivateJoystickValid(joystick)) { return -1; } ret = SDL_SYS_JoystickIsHaptic(joystick); if (ret > 0) return SDL_TRUE; else if (ret == 0) return SDL_FALSE; else return -1; } /* * Opens a haptic device from a joystick. */ SDL_Haptic * SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) { SDL_Haptic *haptic; SDL_Haptic *hapticlist; /* Make sure there is room. */ if (SDL_NumHaptics() <= 0) { SDL_SetError("Haptic: There are %d haptic devices available", SDL_NumHaptics()); return NULL; } /* Must be a valid joystick */ if (!SDL_PrivateJoystickValid(joystick)) { SDL_SetError("Haptic: Joystick isn't valid."); return NULL; } /* Joystick must be haptic */ if (SDL_SYS_JoystickIsHaptic(joystick) <= 0) { SDL_SetError("Haptic: Joystick isn't a haptic device."); return NULL; } hapticlist = SDL_haptics; /* Check to see if joystick's haptic is already open */ while ( hapticlist ) { if (SDL_SYS_JoystickSameHaptic(hapticlist, joystick)) { haptic = hapticlist; ++haptic->ref_count; return haptic; } hapticlist = hapticlist->next; } /* Create the haptic device */ haptic = (SDL_Haptic *) SDL_malloc((sizeof *haptic)); if (haptic == NULL) { SDL_OutOfMemory(); return NULL; } /* Initialize the haptic device */ SDL_memset(haptic, 0, sizeof(SDL_Haptic)); haptic->rumble_id = -1; if (SDL_SYS_HapticOpenFromJoystick(haptic, joystick) < 0) { SDL_SetError("Haptic: SDL_SYS_HapticOpenFromJoystick failed."); SDL_free(haptic); return NULL; } /* Add haptic to list */ ++haptic->ref_count; /* Link the haptic in the list */ haptic->next = SDL_haptics; SDL_haptics = haptic; return haptic; } /* * Closes a SDL_Haptic device. */ void SDL_HapticClose(SDL_Haptic * haptic) { int i; SDL_Haptic *hapticlist; SDL_Haptic *hapticlistprev; /* Must be valid */ if (!ValidHaptic(haptic)) { return; } /* Check if it's still in use */ if (--haptic->ref_count > 0) { return; } /* Close it, properly removing effects if needed */ for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect != NULL) { SDL_HapticDestroyEffect(haptic, i); } } SDL_SYS_HapticClose(haptic); /* Remove from the list */ hapticlist = SDL_haptics; hapticlistprev = NULL; while ( hapticlist ) { if (haptic == hapticlist) { if ( hapticlistprev ) { /* unlink this entry */ hapticlistprev->next = hapticlist->next; } else { SDL_haptics = haptic->next; } break; } hapticlistprev = hapticlist; hapticlist = hapticlist->next; } /* Free */ SDL_free(haptic); } /* * Cleans up after the subsystem. */ void SDL_HapticQuit(void) { SDL_SYS_HapticQuit(); SDL_assert(SDL_haptics == NULL); SDL_haptics = NULL; } /* * Returns the number of effects a haptic device has. */ int SDL_HapticNumEffects(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } return haptic->neffects; } /* * Returns the number of effects a haptic device can play. */ int SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } return haptic->nplaying; } /* * Returns supported effects by the device. */ unsigned int SDL_HapticQuery(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return 0; /* same as if no effects were supported */ } return haptic->supported; } /* * Returns the number of axis on the device. */ int SDL_HapticNumAxes(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } return haptic->naxes; } /* * Checks to see if the device can support the effect. */ int SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect) { if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & effect->type) != 0) return SDL_TRUE; return SDL_FALSE; } /* * Creates a new haptic effect. */ int SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect) { int i; /* Check for device validity. */ if (!ValidHaptic(haptic)) { return -1; } /* Check to see if effect is supported */ if (SDL_HapticEffectSupported(haptic, effect) == SDL_FALSE) { return SDL_SetError("Haptic: Effect not supported by haptic device."); } /* See if there's a free slot */ for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect == NULL) { /* Now let the backend create the real effect */ if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) != 0) { return -1; /* Backend failed to create effect */ } SDL_memcpy(&haptic->effects[i].effect, effect, sizeof(SDL_HapticEffect)); return i; } } return SDL_SetError("Haptic: Device has no free space left."); } /* * Checks to see if an effect is valid. */ static int ValidEffect(SDL_Haptic * haptic, int effect) { if ((effect < 0) || (effect >= haptic->neffects)) { SDL_SetError("Haptic: Invalid effect identifier."); return 0; } return 1; } /* * Updates an effect. */ int SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } /* Can't change type dynamically. */ if (data->type != haptic->effects[effect].effect.type) { return SDL_SetError("Haptic: Updating effect type is illegal."); } /* Updates the effect */ if (SDL_SYS_HapticUpdateEffect(haptic, &haptic->effects[effect], data) < 0) { return -1; } SDL_memcpy(&haptic->effects[effect].effect, data, sizeof(SDL_HapticEffect)); return 0; } /* * Runs the haptic effect on the device. */ int SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } /* Run the effect */ if (SDL_SYS_HapticRunEffect(haptic, &haptic->effects[effect], iterations) < 0) { return -1; } return 0; } /* * Stops the haptic effect on the device. */ int SDL_HapticStopEffect(SDL_Haptic * haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } /* Stop the effect */ if (SDL_SYS_HapticStopEffect(haptic, &haptic->effects[effect]) < 0) { return -1; } return 0; } /* * Gets rid of a haptic effect. */ void SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return; } /* Not allocated */ if (haptic->effects[effect].hweffect == NULL) { return; } SDL_SYS_HapticDestroyEffect(haptic, &haptic->effects[effect]); } /* * Gets the status of a haptic effect. */ int SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect) { if (!ValidHaptic(haptic) || !ValidEffect(haptic, effect)) { return -1; } if ((haptic->supported & SDL_HAPTIC_STATUS) == 0) { return SDL_SetError("Haptic: Device does not support status queries."); } return SDL_SYS_HapticGetEffectStatus(haptic, &haptic->effects[effect]); } /* * Sets the global gain of the device. */ int SDL_HapticSetGain(SDL_Haptic * haptic, int gain) { const char *env; int real_gain, max_gain; if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & SDL_HAPTIC_GAIN) == 0) { return SDL_SetError("Haptic: Device does not support setting gain."); } if ((gain < 0) || (gain > 100)) { return SDL_SetError("Haptic: Gain must be between 0 and 100."); } /* We use the envvar to get the maximum gain. */ env = SDL_getenv("SDL_HAPTIC_GAIN_MAX"); if (env != NULL) { max_gain = SDL_atoi(env); /* Check for sanity. */ if (max_gain < 0) max_gain = 0; else if (max_gain > 100) max_gain = 100; /* We'll scale it linearly with SDL_HAPTIC_GAIN_MAX */ real_gain = (gain * max_gain) / 100; } else { real_gain = gain; } if (SDL_SYS_HapticSetGain(haptic, real_gain) < 0) { return -1; } return 0; } /* * Makes the device autocenter, 0 disables. */ int SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & SDL_HAPTIC_AUTOCENTER) == 0) { return SDL_SetError("Haptic: Device does not support setting autocenter."); } if ((autocenter < 0) || (autocenter > 100)) { return SDL_SetError("Haptic: Autocenter must be between 0 and 100."); } if (SDL_SYS_HapticSetAutocenter(haptic, autocenter) < 0) { return -1; } return 0; } /* * Pauses the haptic device. */ int SDL_HapticPause(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) { return SDL_SetError("Haptic: Device does not support setting pausing."); } return SDL_SYS_HapticPause(haptic); } /* * Unpauses the haptic device. */ int SDL_HapticUnpause(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } if ((haptic->supported & SDL_HAPTIC_PAUSE) == 0) { return 0; /* Not going to be paused, so we pretend it's unpaused. */ } return SDL_SYS_HapticUnpause(haptic); } /* * Stops all the currently playing effects. */ int SDL_HapticStopAll(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } return SDL_SYS_HapticStopAll(haptic); } /* * Checks to see if rumble is supported. */ int SDL_HapticRumbleSupported(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } /* Most things can use SINE, but XInput only has LEFTRIGHT. */ return ((haptic->supported & (SDL_HAPTIC_SINE|SDL_HAPTIC_LEFTRIGHT)) != 0); } /* * Initializes the haptic device for simple rumble playback. */ int SDL_HapticRumbleInit(SDL_Haptic * haptic) { SDL_HapticEffect *efx = &haptic->rumble_effect; if (!ValidHaptic(haptic)) { return -1; } /* Already allocated. */ if (haptic->rumble_id >= 0) { return 0; } SDL_zerop(efx); if (haptic->supported & SDL_HAPTIC_SINE) { efx->type = SDL_HAPTIC_SINE; efx->periodic.direction.type = SDL_HAPTIC_CARTESIAN; efx->periodic.period = 1000; efx->periodic.magnitude = 0x4000; efx->periodic.length = 5000; efx->periodic.attack_length = 0; efx->periodic.fade_length = 0; } else if (haptic->supported & SDL_HAPTIC_LEFTRIGHT) { /* XInput? */ efx->type = SDL_HAPTIC_LEFTRIGHT; efx->leftright.length = 5000; efx->leftright.large_magnitude = 0x4000; efx->leftright.small_magnitude = 0x4000; } else { return SDL_SetError("Device doesn't support rumble"); } haptic->rumble_id = SDL_HapticNewEffect(haptic, &haptic->rumble_effect); if (haptic->rumble_id >= 0) { return 0; } return -1; } /* * Runs simple rumble on a haptic device */ int SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length) { SDL_HapticEffect *efx; Sint16 magnitude; if (!ValidHaptic(haptic)) { return -1; } if (haptic->rumble_id < 0) { return SDL_SetError("Haptic: Rumble effect not initialized on haptic device"); } /* Clamp strength. */ if (strength > 1.0f) { strength = 1.0f; } else if (strength < 0.0f) { strength = 0.0f; } magnitude = (Sint16)(32767.0f*strength); efx = &haptic->rumble_effect; if (efx->type == SDL_HAPTIC_SINE) { efx->periodic.magnitude = magnitude; efx->periodic.length = length; } else if (efx->type == SDL_HAPTIC_LEFTRIGHT) { efx->leftright.small_magnitude = efx->leftright.large_magnitude = magnitude; efx->leftright.length = length; } else { SDL_assert(0 && "This should have been caught elsewhere"); } if (SDL_HapticUpdateEffect(haptic, haptic->rumble_id, &haptic->rumble_effect) < 0) { return -1; } return SDL_HapticRunEffect(haptic, haptic->rumble_id, 1); } /* * Stops the simple rumble on a haptic device. */ int SDL_HapticRumbleStop(SDL_Haptic * haptic) { if (!ValidHaptic(haptic)) { return -1; } if (haptic->rumble_id < 0) { return SDL_SetError("Haptic: Rumble effect not initialized on haptic device"); } return SDL_HapticStopEffect(haptic, haptic->rumble_id); } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\SDL_haptic_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ extern int SDL_HapticInit(void); extern void SDL_HapticQuit(void); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\SDL_syshaptic.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_syshaptic_h_ #define SDL_syshaptic_h_ #include "SDL_haptic.h" struct haptic_effect { SDL_HapticEffect effect; /* The current event */ struct haptic_hweffect *hweffect; /* The hardware behind the event */ }; /* * The real SDL_Haptic struct. */ struct _SDL_Haptic { Uint8 index; /* Stores index it is attached to */ struct haptic_effect *effects; /* Allocated effects */ int neffects; /* Maximum amount of effects */ int nplaying; /* Maximum amount of effects to play at the same time */ unsigned int supported; /* Supported effects */ int naxes; /* Number of axes on the device. */ struct haptic_hwdata *hwdata; /* Driver dependent */ int ref_count; /* Count for multiple opens */ int rumble_id; /* ID of rumble effect for simple rumble API. */ SDL_HapticEffect rumble_effect; /* Rumble effect. */ struct _SDL_Haptic *next; /* pointer to next haptic we have allocated */ }; /* * Scans the system for haptic devices. * * Returns number of devices on success, -1 on error. */ extern int SDL_SYS_HapticInit(void); /* Function to return the number of haptic devices plugged in right now */ extern int SDL_SYS_NumHaptics(void); /* * Gets the device dependent name of the haptic device */ extern const char *SDL_SYS_HapticName(int index); /* * Opens the haptic device for usage. The haptic device should have * the index value set previously. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticOpen(SDL_Haptic * haptic); /* * Returns the index of the haptic core pointer or -1 if none is found. */ int SDL_SYS_HapticMouse(void); /* * Checks to see if the joystick has haptic capabilities. * * Returns >0 if haptic capabilities are detected, 0 if haptic * capabilities aren't detected and -1 on error. */ extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick); /* * Opens the haptic device for usage using the same device as * the joystick. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick); /* * Checks to see if haptic device and joystick device are the same. * * Returns 1 if they are the same, 0 if they aren't. */ extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick); /* * Closes a haptic device after usage. */ extern void SDL_SYS_HapticClose(SDL_Haptic * haptic); /* * Performs a cleanup on the haptic subsystem. */ extern void SDL_SYS_HapticQuit(void); /* * Creates a new haptic effect on the haptic device using base * as a template for the effect. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); /* * Updates the haptic effect on the haptic device using data * as a template. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data); /* * Runs the effect on the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations); /* * Stops the effect on the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect); /* * Cleanups up the effect on the haptic device. */ extern void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect); /* * Queries the device for the status of effect. * * Returns 0 if device is stopped, >0 if device is playing and * -1 on error. */ extern int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect); /* * Sets the global gain of the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain); /* * Sets the autocenter feature of the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); /* * Pauses the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticPause(SDL_Haptic * haptic); /* * Unpauses the haptic device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticUnpause(SDL_Haptic * haptic); /* * Stops all the currently playing haptic effects on the device. * * Returns 0 on success, -1 on error. */ extern int SDL_SYS_HapticStopAll(SDL_Haptic * haptic); #endif /* SDL_syshaptic_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\android\SDL_syshaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_HAPTIC_ANDROID #include "SDL_assert.h" #include "SDL_timer.h" #include "SDL_syshaptic_c.h" #include "../SDL_syshaptic.h" #include "SDL_haptic.h" #include "../../core/android/SDL_android.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/android/SDL_sysjoystick_c.h" /* For joystick hwdata */ typedef struct SDL_hapticlist_item { int device_id; char *name; SDL_Haptic *haptic; struct SDL_hapticlist_item *next; } SDL_hapticlist_item; static SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; int SDL_SYS_HapticInit(void) { /* Support for device connect/disconnect is API >= 16 only, * so we poll every three seconds * Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html */ static Uint32 timeout = 0; if (SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { timeout = SDL_GetTicks() + 3000; Android_JNI_PollHapticDevices(); } return (numhaptics); } int SDL_SYS_NumHaptics(void) { return (numhaptics); } static SDL_hapticlist_item * HapticByOrder(int index) { SDL_hapticlist_item *item = SDL_hapticlist; if ((index < 0) || (index >= numhaptics)) { return NULL; } while (index > 0) { SDL_assert(item != NULL); --index; item = item->next; } return item; } static SDL_hapticlist_item * HapticByDevId (int device_id) { SDL_hapticlist_item *item; for (item = SDL_hapticlist; item != NULL; item = item->next) { if (device_id == item->device_id) { /*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/ return item; } } return NULL; } const char * SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item = HapticByOrder(index); if (item == NULL ) { SDL_SetError("No such device"); return NULL; } return item->name; } static SDL_hapticlist_item * OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) { if (item == NULL ) { SDL_SetError("No such device"); return NULL; } if (item->haptic != NULL) { SDL_SetError("Haptic already opened"); return NULL; } haptic->hwdata = (struct haptic_hwdata *)item; item->haptic = haptic; haptic->supported = SDL_HAPTIC_LEFTRIGHT; haptic->neffects = 1; haptic->nplaying = haptic->neffects; haptic->effects = (struct haptic_effect *)SDL_malloc (sizeof (struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { SDL_OutOfMemory(); return NULL; } SDL_memset(haptic->effects, 0, sizeof (struct haptic_effect) * haptic->neffects); return item; } static SDL_hapticlist_item * OpenHapticByOrder(SDL_Haptic *haptic, int index) { return OpenHaptic (haptic, HapticByOrder(index)); } static SDL_hapticlist_item * OpenHapticByDevId(SDL_Haptic *haptic, int device_id) { return OpenHaptic (haptic, HapticByDevId(device_id)); } int SDL_SYS_HapticOpen(SDL_Haptic *haptic) { return (OpenHapticByOrder(haptic, haptic->index) == NULL ? -1 : 0); } int SDL_SYS_HapticMouse(void) { return 0; } int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { SDL_hapticlist_item *item; item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id); return (item != NULL) ? 1 : 0; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) { return (OpenHapticByDevId(haptic, ((joystick_hwdata *)joystick->hwdata)->device_id) == NULL ? -1 : 0); } int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { return (((SDL_hapticlist_item *)haptic->hwdata)->device_id == ((joystick_hwdata *)joystick->hwdata)->device_id ? 1 : 0); } void SDL_SYS_HapticClose(SDL_Haptic * haptic) { ((SDL_hapticlist_item *)haptic->hwdata)->haptic = NULL; haptic->hwdata = NULL; return; } void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item = NULL; SDL_hapticlist_item *next = NULL; for (item = SDL_hapticlist; item; item = next) { next = item->next; SDL_free(item); } SDL_hapticlist = SDL_hapticlist_tail = NULL; numhaptics = 0; return; } int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { return 0; } int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { return 0; } int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { Android_JNI_HapticRun (((SDL_hapticlist_item *)haptic->hwdata)->device_id, effect->effect.leftright.length); return 0; } int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { Android_JNI_HapticStop (((SDL_hapticlist_item *)haptic->hwdata)->device_id); return 0; } void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { return; } int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { return 0; } int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) { return 0; } int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { return 0; } int SDL_SYS_HapticPause(SDL_Haptic * haptic) { return 0; } int SDL_SYS_HapticUnpause(SDL_Haptic * haptic) { return 0; } int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { return 0; } int Android_AddHaptic(int device_id, const char *name) { SDL_hapticlist_item *item; item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item)); if (item == NULL) { return -1; } item->device_id = device_id; item->name = SDL_strdup (name); if (item->name == NULL) { SDL_free (item); return -1; } if (SDL_hapticlist_tail == NULL) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; SDL_hapticlist_tail = item; } ++numhaptics; return numhaptics; } int Android_RemoveHaptic(int device_id) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; for (item = SDL_hapticlist; item != NULL; item = item->next) { /* found it, remove it. */ if (device_id == item->device_id) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); SDL_hapticlist = item->next; } if (item == SDL_hapticlist_tail) { SDL_hapticlist_tail = prev; } /* Need to decrement the haptic count */ --numhaptics; /* !!! TODO: Send a haptic remove event? */ SDL_free(item->name); SDL_free(item); return retval; } prev = item; } return -1; } #endif /* SDL_HAPTIC_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\android\SDL_syshaptic_c.h
#include "SDL_config.h" #ifdef SDL_HAPTIC_ANDROID extern int Android_AddHaptic(int device_id, const char *name); extern int Android_RemoveHaptic(int device_id); #endif /* SDL_HAPTIC_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\darwin\SDL_syshaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_HAPTIC_IOKIT #include "SDL_assert.h" #include "SDL_stdinc.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/darwin/SDL_sysjoystick_c.h" /* For joystick hwdata */ #include "SDL_syshaptic_c.h" #include <IOKit/IOKitLib.h> #include <IOKit/hid/IOHIDKeys.h> #include <IOKit/hid/IOHIDUsageTables.h> #include <ForceFeedback/ForceFeedback.h> #include <ForceFeedback/ForceFeedbackConstants.h> #ifndef IO_OBJECT_NULL #define IO_OBJECT_NULL ((io_service_t)0) #endif /* * List of available haptic devices. */ typedef struct SDL_hapticlist_item { char name[256]; /* Name of the device. */ io_service_t dev; /* Node we use to create the device. */ SDL_Haptic *haptic; /* Haptic currently associated with it. */ /* Usage pages for determining if it's a mouse or not. */ long usage; long usagePage; struct SDL_hapticlist_item *next; } SDL_hapticlist_item; /* * Haptic system hardware data. */ struct haptic_hwdata { FFDeviceObjectReference device; /* Hardware device. */ UInt8 axes[3]; }; /* * Haptic system effect data. */ struct haptic_hweffect { FFEffectObjectReference ref; /* Reference. */ struct FFEFFECT effect; /* Hardware effect. */ }; /* * Prototypes. */ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type); static int HIDGetDeviceProduct(io_service_t dev, char *name); static SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = -1; /* * Like strerror but for force feedback errors. */ static const char * FFStrError(unsigned int err) { switch (err) { case FFERR_DEVICEFULL: return "device full"; /* This should be valid, but for some reason isn't defined... */ /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: return "device paused"; case FFERR_DEVICERELEASED: return "device released"; case FFERR_EFFECTPLAYING: return "effect playing"; case FFERR_EFFECTTYPEMISMATCH: return "effect type mismatch"; case FFERR_EFFECTTYPENOTSUPPORTED: return "effect type not supported"; case FFERR_GENERIC: return "undetermined error"; case FFERR_HASEFFECTS: return "device has effects"; case FFERR_INCOMPLETEEFFECT: return "incomplete effect"; case FFERR_INTERNAL: return "internal fault"; case FFERR_INVALIDDOWNLOADID: return "invalid download id"; case FFERR_INVALIDPARAM: return "invalid parameter"; case FFERR_MOREDATA: return "more data"; case FFERR_NOINTERFACE: return "interface not supported"; case FFERR_NOTDOWNLOADED: return "effect is not downloaded"; case FFERR_NOTINITIALIZED: return "object has not been initialized"; case FFERR_OUTOFMEMORY: return "out of memory"; case FFERR_UNPLUGGED: return "device is unplugged"; case FFERR_UNSUPPORTED: return "function call unsupported"; case FFERR_UNSUPPORTEDAXIS: return "axis unsupported"; default: return "unknown error"; } } /* * Initializes the haptic subsystem. */ int SDL_SYS_HapticInit(void) { IOReturn result; io_iterator_t iter; CFDictionaryRef match; io_service_t device; if (numhaptics != -1) { return SDL_SetError("Haptic subsystem already initialized!"); } numhaptics = 0; /* Get HID devices. */ match = IOServiceMatching(kIOHIDDeviceKey); if (match == NULL) { return SDL_SetError("Haptic: Failed to get IOServiceMatching."); } /* Now search I/O Registry for matching devices. */ result = IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iter); if (result != kIOReturnSuccess) { return SDL_SetError("Haptic: Couldn't create a HID object iterator."); } /* IOServiceGetMatchingServices consumes dictionary. */ if (!IOIteratorIsValid(iter)) { /* No iterator. */ return 0; } while ((device = IOIteratorNext(iter)) != IO_OBJECT_NULL) { MacHaptic_MaybeAddDevice(device); /* always release as the AddDevice will retain IF it's a forcefeedback device */ IOObjectRelease(device); } IOObjectRelease(iter); return numhaptics; } int SDL_SYS_NumHaptics(void) { return numhaptics; } static SDL_hapticlist_item * HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; if ((device_index < 0) || (device_index >= numhaptics)) { return NULL; } while (device_index > 0) { SDL_assert(item != NULL); --device_index; item = item->next; } return item; } int MacHaptic_MaybeAddDevice( io_object_t device ) { IOReturn result; CFMutableDictionaryRef hidProperties; CFTypeRef refCF; SDL_hapticlist_item *item; if (numhaptics == -1) { return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ } /* Check for force feedback. */ if (FFIsForceFeedback(device) != FF_OK) { return -1; } /* Make sure we don't already have it */ for (item = SDL_hapticlist; item ; item = item->next) { if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { /* Already added */ return -1; } } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); if (item == NULL) { return SDL_SetError("Could not allocate haptic storage"); } /* retain it as we are going to keep it around a while */ IOObjectRetain(device); /* Set basic device data. */ HIDGetDeviceProduct(device, item->name); item->dev = device; /* Set usage pages. */ hidProperties = 0; refCF = 0; result = IORegistryEntryCreateCFProperties(device, &hidProperties, kCFAllocatorDefault, kNilOptions); if ((result == KERN_SUCCESS) && hidProperties) { refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsagePageKey)); if (refCF) { if (!CFNumberGetValue(refCF, kCFNumberLongType, &item->usagePage)) { SDL_SetError("Haptic: Receiving device's usage page."); } refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDPrimaryUsageKey)); if (refCF) { if (!CFNumberGetValue(refCF, kCFNumberLongType, &item->usage)) { SDL_SetError("Haptic: Receiving device's usage."); } } } CFRelease(hidProperties); } if (SDL_hapticlist_tail == NULL) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; SDL_hapticlist_tail = item; } /* Device has been added. */ ++numhaptics; return numhaptics; } int MacHaptic_MaybeRemoveDevice( io_object_t device ) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; if (numhaptics == -1) { return -1; /* not initialized. ignore this. */ } for (item = SDL_hapticlist; item != NULL; item = item->next) { /* found it, remove it. */ if (IOObjectIsEqualTo((io_object_t) item->dev, device)) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); SDL_hapticlist = item->next; } if (item == SDL_hapticlist_tail) { SDL_hapticlist_tail = prev; } /* Need to decrement the haptic count */ --numhaptics; /* !!! TODO: Send a haptic remove event? */ IOObjectRelease(item->dev); SDL_free(item); return retval; } prev = item; } return -1; } /* * Return the name of a haptic device, does not need to be opened. */ const char * SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item; item = HapticByDevIndex(index); return item->name; } /* * Gets the device's product name. */ static int HIDGetDeviceProduct(io_service_t dev, char *name) { CFMutableDictionaryRef hidProperties, usbProperties; io_registry_entry_t parent1, parent2; kern_return_t ret; hidProperties = usbProperties = 0; ret = IORegistryEntryCreateCFProperties(dev, &hidProperties, kCFAllocatorDefault, kNilOptions); if ((ret != KERN_SUCCESS) || !hidProperties) { return SDL_SetError("Haptic: Unable to create CFProperties."); } /* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also * get dictionary for USB properties: step up two levels and get CF dictionary for USB properties */ if ((KERN_SUCCESS == IORegistryEntryGetParentEntry(dev, kIOServicePlane, &parent1)) && (KERN_SUCCESS == IORegistryEntryGetParentEntry(parent1, kIOServicePlane, &parent2)) && (KERN_SUCCESS == IORegistryEntryCreateCFProperties(parent2, &usbProperties, kCFAllocatorDefault, kNilOptions))) { if (usbProperties) { CFTypeRef refCF = 0; /* get device info * try hid dictionary first, if fail then go to USB dictionary */ /* Get product name */ refCF = CFDictionaryGetValue(hidProperties, CFSTR(kIOHIDProductKey)); if (!refCF) { refCF = CFDictionaryGetValue(usbProperties, CFSTR("USB Product Name")); } if (refCF) { if (!CFStringGetCString(refCF, name, 256, CFStringGetSystemEncoding())) { return SDL_SetError("Haptic: CFStringGetCString error retrieving pDevice->product."); } } CFRelease(usbProperties); } else { return SDL_SetError("Haptic: IORegistryEntryCreateCFProperties failed to create usbProperties."); } /* Release stuff. */ if (kIOReturnSuccess != IOObjectRelease(parent2)) { SDL_SetError("Haptic: IOObjectRelease error with parent2."); } if (kIOReturnSuccess != IOObjectRelease(parent1)) { SDL_SetError("Haptic: IOObjectRelease error with parent1."); } } else { return SDL_SetError("Haptic: Error getting registry entries."); } return 0; } #define FF_TEST(ff, s) \ if (features.supportedEffects & (ff)) supported |= (s) /* * Gets supported features. */ static unsigned int GetSupportedFeatures(SDL_Haptic * haptic) { HRESULT ret; FFDeviceObjectReference device; FFCAPABILITIES features; unsigned int supported; Uint32 val; device = haptic->hwdata->device; ret = FFDeviceGetForceFeedbackCapabilities(device, &features); if (ret != FF_OK) { return SDL_SetError("Haptic: Unable to get device's supported features."); } supported = 0; /* Get maximum effects. */ haptic->neffects = features.storageCapacity; haptic->nplaying = features.playbackCapacity; /* Test for effects. */ FF_TEST(FFCAP_ET_CONSTANTFORCE, SDL_HAPTIC_CONSTANT); FF_TEST(FFCAP_ET_RAMPFORCE, SDL_HAPTIC_RAMP); /* !!! FIXME: put this back when we have more bits in 2.1 */ /* FF_TEST(FFCAP_ET_SQUARE, SDL_HAPTIC_SQUARE); */ FF_TEST(FFCAP_ET_SINE, SDL_HAPTIC_SINE); FF_TEST(FFCAP_ET_TRIANGLE, SDL_HAPTIC_TRIANGLE); FF_TEST(FFCAP_ET_SAWTOOTHUP, SDL_HAPTIC_SAWTOOTHUP); FF_TEST(FFCAP_ET_SAWTOOTHDOWN, SDL_HAPTIC_SAWTOOTHDOWN); FF_TEST(FFCAP_ET_SPRING, SDL_HAPTIC_SPRING); FF_TEST(FFCAP_ET_DAMPER, SDL_HAPTIC_DAMPER); FF_TEST(FFCAP_ET_INERTIA, SDL_HAPTIC_INERTIA); FF_TEST(FFCAP_ET_FRICTION, SDL_HAPTIC_FRICTION); FF_TEST(FFCAP_ET_CUSTOMFORCE, SDL_HAPTIC_CUSTOM); /* Check if supports gain. */ ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_FFGAIN, &val, sizeof(val)); if (ret == FF_OK) { supported |= SDL_HAPTIC_GAIN; } else if (ret != FFERR_UNSUPPORTED) { return SDL_SetError("Haptic: Unable to get if device supports gain: %s.", FFStrError(ret)); } /* Checks if supports autocenter. */ ret = FFDeviceGetForceFeedbackProperty(device, FFPROP_AUTOCENTER, &val, sizeof(val)); if (ret == FF_OK) { supported |= SDL_HAPTIC_AUTOCENTER; } else if (ret != FFERR_UNSUPPORTED) { return SDL_SetError ("Haptic: Unable to get if device supports autocenter: %s.", FFStrError(ret)); } /* Check for axes, we have an artificial limit on axes */ haptic->naxes = ((features.numFfAxes) > 3) ? 3 : features.numFfAxes; /* Actually store the axes we want to use */ SDL_memcpy(haptic->hwdata->axes, features.ffAxes, haptic->naxes * sizeof(Uint8)); /* Always supported features. */ supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; haptic->supported = supported; return 0; } /* * Opens the haptic device from the file descriptor. */ static int SDL_SYS_HapticOpenFromService(SDL_Haptic * haptic, io_service_t service) { HRESULT ret; int ret2; /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); if (haptic->hwdata == NULL) { SDL_OutOfMemory(); goto creat_err; } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); /* Open the device */ ret = FFCreateDevice(service, &haptic->hwdata->device); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to create device from service: %s.", FFStrError(ret)); goto creat_err; } /* Get supported features. */ ret2 = GetSupportedFeatures(haptic); if (ret2 < 0) { goto open_err; } /* Reset and then enable actuators. */ ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_RESET); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to reset device: %s.", FFStrError(ret)); goto open_err; } ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_SETACTUATORSON); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to enable actuators: %s.", FFStrError(ret)); goto open_err; } /* Allocate effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { SDL_OutOfMemory(); goto open_err; } /* Clear the memory */ SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; /* Error handling */ open_err: FFReleaseDevice(haptic->hwdata->device); creat_err: if (haptic->hwdata != NULL) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } return -1; } /* * Opens a haptic device for usage. */ int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { SDL_hapticlist_item *item; item = HapticByDevIndex(haptic->index); return SDL_SYS_HapticOpenFromService(haptic, item->dev); } /* * Opens a haptic device from first mouse it finds for usage. */ int SDL_SYS_HapticMouse(void) { int device_index = 0; SDL_hapticlist_item *item; for (item = SDL_hapticlist; item; item = item->next) { if ((item->usagePage == kHIDPage_GenericDesktop) && (item->usage == kHIDUsage_GD_Mouse)) { return device_index; } ++device_index; } return -1; } /* * Checks to see if a joystick has haptic features. */ int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) { if (joystick->hwdata->ffservice != 0) { return SDL_TRUE; } return SDL_FALSE; } /* * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device), joystick->hwdata->ffservice)) { return 1; } return 0; } /* * Opens a SDL_Haptic from a SDL_Joystick. */ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { int device_index = 0; SDL_hapticlist_item *item; for (item = SDL_hapticlist; item; item = item->next) { if (IOObjectIsEqualTo((io_object_t) item->dev, joystick->hwdata->ffservice)) { haptic->index = device_index; break; } ++device_index; } return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice); } /* * Closes the haptic device. */ void SDL_SYS_HapticClose(SDL_Haptic * haptic) { if (haptic->hwdata) { /* Free Effects. */ SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; /* Clean up */ FFReleaseDevice(haptic->hwdata->device); /* Free */ SDL_free(haptic->hwdata); haptic->hwdata = NULL; } } /* * Clean up after system specific haptic stuff */ void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item; SDL_hapticlist_item *next = NULL; for (item = SDL_hapticlist; item; item = next) { next = item->next; /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ /* Free the io_service_t */ IOObjectRelease(item->dev); SDL_free(item); } numhaptics = -1; SDL_hapticlist = NULL; SDL_hapticlist_tail = NULL; } /* * Converts an SDL trigger button to an FFEFFECT trigger button. */ static DWORD FFGetTriggerButton(Uint16 button) { DWORD dwTriggerButton; dwTriggerButton = FFEB_NOTRIGGER; if (button != 0) { dwTriggerButton = FFJOFS_BUTTON(button - 1); } return dwTriggerButton; } /* * Sets the direction. */ static int SDL_SYS_SetDirection(FFEFFECT * effect, SDL_HapticDirection * dir, int naxes) { LONG *rglDir; /* Handle no axes a part. */ if (naxes == 0) { effect->dwFlags |= FFEFF_SPHERICAL; /* Set as default. */ effect->rglDirection = NULL; return 0; } /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); if (rglDir == NULL) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); effect->rglDirection = rglDir; switch (dir->type) { case SDL_HAPTIC_POLAR: effect->dwFlags |= FFEFF_POLAR; rglDir[0] = dir->dir[0]; return 0; case SDL_HAPTIC_CARTESIAN: effect->dwFlags |= FFEFF_CARTESIAN; rglDir[0] = dir->dir[0]; if (naxes > 1) { rglDir[1] = dir->dir[1]; } if (naxes > 2) { rglDir[2] = dir->dir[2]; } return 0; case SDL_HAPTIC_SPHERICAL: effect->dwFlags |= FFEFF_SPHERICAL; rglDir[0] = dir->dir[0]; if (naxes > 1) { rglDir[1] = dir->dir[1]; } if (naxes > 2) { rglDir[2] = dir->dir[2]; } return 0; default: return SDL_SetError("Haptic: Unknown direction type."); } } /* Clamps and converts. */ #define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) /* Just converts. */ #define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the FFEFFECT from a SDL_HapticEffect. */ static int SDL_SYS_ToFFEFFECT(SDL_Haptic * haptic, FFEFFECT * dest, SDL_HapticEffect * src) { int i; FFCONSTANTFORCE *constant = NULL; FFPERIODIC *periodic = NULL; FFCONDITION *condition = NULL; /* Actually an array of conditions - one per axis. */ FFRAMPFORCE *ramp = NULL; FFCUSTOMFORCE *custom = NULL; FFENVELOPE *envelope = NULL; SDL_HapticConstant *hap_constant = NULL; SDL_HapticPeriodic *hap_periodic = NULL; SDL_HapticCondition *hap_condition = NULL; SDL_HapticRamp *hap_ramp = NULL; SDL_HapticCustom *hap_custom = NULL; DWORD *axes = NULL; /* Set global stuff. */ SDL_memset(dest, 0, sizeof(FFEFFECT)); dest->dwSize = sizeof(FFEFFECT); /* Set the structure size. */ dest->dwSamplePeriod = 0; /* Not used by us. */ dest->dwGain = 10000; /* Gain is set globally, not locally. */ dest->dwFlags = FFEFF_OBJECTOFFSETS; /* Seems obligatory. */ /* Envelope. */ envelope = SDL_malloc(sizeof(FFENVELOPE)); if (envelope == NULL) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(FFENVELOPE)); dest->lpEnvelope = envelope; envelope->dwSize = sizeof(FFENVELOPE); /* Always should be this. */ /* Axes. */ dest->cAxes = haptic->naxes; if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); if (axes == NULL) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ if (dest->cAxes > 1) { axes[1] = haptic->hwdata->axes[1]; } if (dest->cAxes > 2) { axes[2] = haptic->hwdata->axes[2]; } dest->rgdwAxes = axes; } /* The big type handling switch, even bigger then Linux's version. */ switch (src->type) { case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(FFCONSTANTFORCE)); if (constant == NULL) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE)); /* Specifics */ constant->lMagnitude = CONVERT(hap_constant->level); dest->cbTypeSpecificParams = sizeof(FFCONSTANTFORCE); dest->lpvTypeSpecificParams = constant; /* Generics */ dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_constant->button); dest->dwTriggerRepeatInterval = hap_constant->interval; dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level); envelope->dwAttackTime = hap_constant->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level); envelope->dwFadeTime = hap_constant->fade_length * 1000; } break; case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(FFPERIODIC)); if (periodic == NULL) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(FFPERIODIC)); /* Specifics */ periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); periodic->dwPhase = (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(FFPERIODIC); dest->lpvTypeSpecificParams = periodic; /* Generics */ dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_periodic->button); dest->dwTriggerRepeatInterval = hap_periodic->interval; dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level); envelope->dwAttackTime = hap_periodic->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level); envelope->dwFadeTime = hap_periodic->fade_length * 1000; } break; case SDL_HAPTIC_SPRING: case SDL_HAPTIC_DAMPER: case SDL_HAPTIC_INERTIA: case SDL_HAPTIC_FRICTION: hap_condition = &src->condition; if (dest->cAxes > 0) { condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes); if (condition == NULL) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(FFCONDITION)); /* Specifics */ for (i = 0; i < dest->cAxes; i++) { condition[i].lOffset = CONVERT(hap_condition->center[i]); condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]); condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); condition[i].dwPositiveSaturation = CCONVERT(hap_condition->right_sat[i] / 2); condition[i].dwNegativeSaturation = CCONVERT(hap_condition->left_sat[i] / 2); condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2); } } dest->cbTypeSpecificParams = sizeof(FFCONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; /* Generics */ dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_condition->button); dest->dwTriggerRepeatInterval = hap_condition->interval; dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } /* Envelope - Not actually supported by most CONDITION implementations. */ SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; break; case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(FFRAMPFORCE)); if (ramp == NULL) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(FFRAMPFORCE)); /* Specifics */ ramp->lStart = CONVERT(hap_ramp->start); ramp->lEnd = CONVERT(hap_ramp->end); dest->cbTypeSpecificParams = sizeof(FFRAMPFORCE); dest->lpvTypeSpecificParams = ramp; /* Generics */ dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_ramp->button); dest->dwTriggerRepeatInterval = hap_ramp->interval; dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level); envelope->dwAttackTime = hap_ramp->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level); envelope->dwFadeTime = hap_ramp->fade_length * 1000; } break; case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(FFCUSTOMFORCE)); if (custom == NULL) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE)); /* Specifics */ custom->cChannels = hap_custom->channels; custom->dwSamplePeriod = hap_custom->period * 1000; custom->cSamples = hap_custom->samples; custom->rglForceData = SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels); for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ custom->rglForceData[i] = CCONVERT(hap_custom->data[i]); } dest->cbTypeSpecificParams = sizeof(FFCUSTOMFORCE); dest->lpvTypeSpecificParams = custom; /* Generics */ dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ dest->dwTriggerButton = FFGetTriggerButton(hap_custom->button); dest->dwTriggerRepeatInterval = hap_custom->interval; dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(envelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level); envelope->dwAttackTime = hap_custom->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level); envelope->dwFadeTime = hap_custom->fade_length * 1000; } break; default: return SDL_SetError("Haptic: Unknown effect type."); } return 0; } /* * Frees an FFEFFECT allocated by SDL_SYS_ToFFEFFECT. */ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type) { FFCUSTOMFORCE *custom; SDL_free(effect->lpEnvelope); effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (FFCUSTOMFORCE *) effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; } SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } SDL_free(effect->rglDirection); effect->rglDirection = NULL; } /* * Gets the effect type from the generic SDL haptic effect wrapper. */ CFUUIDRef SDL_SYS_HapticEffectType(Uint16 type) { switch (type) { case SDL_HAPTIC_CONSTANT: return kFFEffectType_ConstantForce_ID; case SDL_HAPTIC_RAMP: return kFFEffectType_RampForce_ID; /* !!! FIXME: put this back when we have more bits in 2.1 */ /* case SDL_HAPTIC_SQUARE: return kFFEffectType_Square_ID; */ case SDL_HAPTIC_SINE: return kFFEffectType_Sine_ID; case SDL_HAPTIC_TRIANGLE: return kFFEffectType_Triangle_ID; case SDL_HAPTIC_SAWTOOTHUP: return kFFEffectType_SawtoothUp_ID; case SDL_HAPTIC_SAWTOOTHDOWN: return kFFEffectType_SawtoothDown_ID; case SDL_HAPTIC_SPRING: return kFFEffectType_Spring_ID; case SDL_HAPTIC_DAMPER: return kFFEffectType_Damper_ID; case SDL_HAPTIC_INERTIA: return kFFEffectType_Inertia_ID; case SDL_HAPTIC_FRICTION: return kFFEffectType_Friction_ID; case SDL_HAPTIC_CUSTOM: return kFFEffectType_CustomForce_ID; default: SDL_SetError("Haptic: Unknown effect type."); return NULL; } } /* * Creates a new haptic effect. */ int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { HRESULT ret; CFUUIDRef type; /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); if (effect->hweffect == NULL) { SDL_OutOfMemory(); goto err_hweffect; } /* Get the type. */ type = SDL_SYS_HapticEffectType(base->type); if (type == NULL) { goto err_hweffect; } /* Get the effect. */ if (SDL_SYS_ToFFEFFECT(haptic, &effect->hweffect->effect, base) < 0) { goto err_effectdone; } /* Create the actual effect. */ ret = FFDeviceCreateEffect(haptic->hwdata->device, type, &effect->hweffect->effect, &effect->hweffect->ref); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to create effect: %s.", FFStrError(ret)); goto err_effectdone; } return 0; err_effectdone: SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type); err_hweffect: SDL_free(effect->hweffect); effect->hweffect = NULL; return -1; } /* * Updates an effect. */ int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { HRESULT ret; FFEffectParameterFlag flags; FFEFFECT temp; /* Get the effect. */ SDL_memset(&temp, 0, sizeof(FFEFFECT)); if (SDL_SYS_ToFFEFFECT(haptic, &temp, data) < 0) { goto err_update; } /* Set the flags. Might be worthwhile to diff temp with loaded effect and * only change those parameters. */ flags = FFEP_DIRECTION | FFEP_DURATION | FFEP_ENVELOPE | FFEP_STARTDELAY | FFEP_TRIGGERBUTTON | FFEP_TRIGGERREPEATINTERVAL | FFEP_TYPESPECIFICPARAMS; /* Create the actual effect. */ ret = FFEffectSetParameters(effect->hweffect->ref, &temp, flags); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to update effect: %s.", FFStrError(ret)); goto err_update; } /* Copy it over. */ SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, data->type); SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(FFEFFECT)); return 0; err_update: SDL_SYS_HapticFreeFFEFFECT(&temp, data->type); return -1; } /* * Runs an effect. */ int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { HRESULT ret; Uint32 iter; /* Check if it's infinite. */ if (iterations == SDL_HAPTIC_INFINITY) { iter = FF_INFINITE; } else iter = iterations; /* Run the effect. */ ret = FFEffectStart(effect->hweffect->ref, iter, 0); if (ret != FF_OK) { return SDL_SetError("Haptic: Unable to run the effect: %s.", FFStrError(ret)); } return 0; } /* * Stops an effect. */ int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; ret = FFEffectStop(effect->hweffect->ref); if (ret != FF_OK) { return SDL_SetError("Haptic: Unable to stop the effect: %s.", FFStrError(ret)); } return 0; } /* * Frees the effect. */ void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; ret = FFDeviceReleaseEffect(haptic->hwdata->device, effect->hweffect->ref); if (ret != FF_OK) { SDL_SetError("Haptic: Error removing the effect from the device: %s.", FFStrError(ret)); } SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, effect->effect.type); SDL_free(effect->hweffect); effect->hweffect = NULL; } /* * Gets the status of a haptic effect. */ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; FFEffectStatusFlag status; ret = FFEffectGetEffectStatus(effect->hweffect->ref, &status); if (ret != FF_OK) { SDL_SetError("Haptic: Unable to get effect status: %s.", FFStrError(ret)); return -1; } if (status == 0) { return SDL_FALSE; } return SDL_TRUE; /* Assume it's playing or emulated. */ } /* * Sets the gain. */ int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) { HRESULT ret; Uint32 val; val = gain * 100; /* Mac OS X uses 0 to 10,000 */ ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, FFPROP_FFGAIN, &val); if (ret != FF_OK) { return SDL_SetError("Haptic: Error setting gain: %s.", FFStrError(ret)); } return 0; } /* * Sets the autocentering. */ int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { HRESULT ret; Uint32 val; /* Mac OS X only has 0 (off) and 1 (on) */ if (autocenter == 0) { val = 0; } else { val = 1; } ret = FFDeviceSetForceFeedbackProperty(haptic->hwdata->device, FFPROP_AUTOCENTER, &val); if (ret != FF_OK) { return SDL_SetError("Haptic: Error setting autocenter: %s.", FFStrError(ret)); } return 0; } /* * Pauses the device. */ int SDL_SYS_HapticPause(SDL_Haptic * haptic) { HRESULT ret; ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_PAUSE); if (ret != FF_OK) { return SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret)); } return 0; } /* * Unpauses the device. */ int SDL_SYS_HapticUnpause(SDL_Haptic * haptic) { HRESULT ret; ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_CONTINUE); if (ret != FF_OK) { return SDL_SetError("Haptic: Error pausing device: %s.", FFStrError(ret)); } return 0; } /* * Stops all currently playing effects. */ int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { HRESULT ret; ret = FFDeviceSendForceFeedbackCommand(haptic->hwdata->device, FFSFFC_STOPALL); if (ret != FF_OK) { return SDL_SetError("Haptic: Error stopping device: %s.", FFStrError(ret)); } return 0; } #endif /* SDL_HAPTIC_IOKIT */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\darwin\SDL_syshaptic_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ extern int MacHaptic_MaybeAddDevice( io_object_t device ); extern int MacHaptic_MaybeRemoveDevice( io_object_t device ); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\dummy\SDL_syshaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if defined(SDL_HAPTIC_DUMMY) || defined(SDL_HAPTIC_DISABLED) #include "SDL_haptic.h" #include "../SDL_syshaptic.h" static int SDL_SYS_LogicError(void) { return SDL_SetError("Logic error: No haptic devices available."); } int SDL_SYS_HapticInit(void) { return 0; } int SDL_SYS_NumHaptics(void) { return 0; } const char * SDL_SYS_HapticName(int index) { SDL_SYS_LogicError(); return NULL; } int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticMouse(void) { return -1; } int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) { return 0; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { return SDL_SYS_LogicError(); } int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { return 0; } void SDL_SYS_HapticClose(SDL_Haptic * haptic) { return; } void SDL_SYS_HapticQuit(void) { return; } int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_SYS_LogicError(); } void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { SDL_SYS_LogicError(); return; } int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticPause(SDL_Haptic * haptic) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticUnpause(SDL_Haptic * haptic) { return SDL_SYS_LogicError(); } int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { return SDL_SYS_LogicError(); } #endif /* SDL_HAPTIC_DUMMY || SDL_HAPTIC_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\linux\SDL_syshaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_HAPTIC_LINUX #include "SDL_assert.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/linux/SDL_sysjoystick_c.h" /* For joystick hwdata */ #include "../../core/linux/SDL_udev.h" #include <unistd.h> /* close */ #include <linux/input.h> /* Force feedback linux stuff. */ #include <fcntl.h> /* O_RDWR */ #include <limits.h> /* INT_MAX */ #include <errno.h> /* errno, strerror */ #include <math.h> /* atan2 */ #include <sys/stat.h> /* stat */ /* Just in case. */ #ifndef M_PI # define M_PI 3.14159265358979323846 #endif #define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */ static int MaybeAddDevice(const char *path); #if SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char *path); static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); #endif /* SDL_USE_LIBUDEV */ /* * List of available haptic devices. */ typedef struct SDL_hapticlist_item { char *fname; /* Dev path name (like /dev/input/event1) */ SDL_Haptic *haptic; /* Associated haptic. */ dev_t dev_num; struct SDL_hapticlist_item *next; } SDL_hapticlist_item; /* * Haptic system hardware data. */ struct haptic_hwdata { int fd; /* File descriptor of the device. */ char *fname; /* Points to the name in SDL_hapticlist. */ }; /* * Haptic system effect data. */ struct haptic_hweffect { struct ff_effect effect; /* The linux kernel effect structure. */ }; static SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; #define test_bit(nr, addr) \ (((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0) #define EV_TEST(ev,f) \ if (test_bit((ev), features)) ret |= (f); /* * Test whether a device has haptic properties. * Returns available properties or 0 if there are none. */ static int EV_IsHaptic(int fd) { unsigned int ret; unsigned long features[1 + FF_MAX / sizeof(unsigned long)]; /* Ask device for what it has. */ ret = 0; if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(features)), features) < 0) { return SDL_SetError("Haptic: Unable to get device's features: %s", strerror(errno)); } /* Convert supported features to SDL_HAPTIC platform-neutral features. */ EV_TEST(FF_CONSTANT, SDL_HAPTIC_CONSTANT); EV_TEST(FF_SINE, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ /* EV_TEST(FF_SQUARE, SDL_HAPTIC_SQUARE); */ EV_TEST(FF_TRIANGLE, SDL_HAPTIC_TRIANGLE); EV_TEST(FF_SAW_UP, SDL_HAPTIC_SAWTOOTHUP); EV_TEST(FF_SAW_DOWN, SDL_HAPTIC_SAWTOOTHDOWN); EV_TEST(FF_RAMP, SDL_HAPTIC_RAMP); EV_TEST(FF_SPRING, SDL_HAPTIC_SPRING); EV_TEST(FF_FRICTION, SDL_HAPTIC_FRICTION); EV_TEST(FF_DAMPER, SDL_HAPTIC_DAMPER); EV_TEST(FF_INERTIA, SDL_HAPTIC_INERTIA); EV_TEST(FF_CUSTOM, SDL_HAPTIC_CUSTOM); EV_TEST(FF_GAIN, SDL_HAPTIC_GAIN); EV_TEST(FF_AUTOCENTER, SDL_HAPTIC_AUTOCENTER); EV_TEST(FF_RUMBLE, SDL_HAPTIC_LEFTRIGHT); /* Return what it supports. */ return ret; } /* * Tests whether a device is a mouse or not. */ static int EV_IsMouse(int fd) { unsigned long argp[40]; /* Ask for supported features. */ if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(argp)), argp) < 0) { return -1; } /* Currently we only test for BTN_MOUSE which can give fake positives. */ if (test_bit(BTN_MOUSE, argp) != 0) { return 1; } return 0; } /* * Initializes the haptic subsystem by finding available devices. */ int SDL_SYS_HapticInit(void) { const char joydev_pattern[] = "/dev/input/event%d"; char path[PATH_MAX]; int i, j; /* * Limit amount of checks to MAX_HAPTICS since we may or may not have * permission to some or all devices. */ i = 0; for (j = 0; j < MAX_HAPTICS; ++j) { snprintf(path, PATH_MAX, joydev_pattern, i++); MaybeAddDevice(path); } #if SDL_USE_LIBUDEV if (SDL_UDEV_Init() < 0) { return SDL_SetError("Could not initialize UDEV"); } if ( SDL_UDEV_AddCallback(haptic_udev_callback) < 0) { SDL_UDEV_Quit(); return SDL_SetError("Could not setup haptic <-> udev callback"); } /* Force a scan to build the initial device list */ SDL_UDEV_Scan(); #endif /* SDL_USE_LIBUDEV */ return numhaptics; } int SDL_SYS_NumHaptics(void) { return numhaptics; } static SDL_hapticlist_item * HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; if ((device_index < 0) || (device_index >= numhaptics)) { return NULL; } while (device_index > 0) { SDL_assert(item != NULL); --device_index; item = item->next; } return item; } #if SDL_USE_LIBUDEV static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { return; } switch( udev_type ) { case SDL_UDEV_DEVICEADDED: MaybeAddDevice(devpath); break; case SDL_UDEV_DEVICEREMOVED: MaybeRemoveDevice(devpath); break; default: break; } } #endif /* SDL_USE_LIBUDEV */ static int MaybeAddDevice(const char *path) { struct stat sb; int fd; int success; SDL_hapticlist_item *item; if (path == NULL) { return -1; } /* check to see if file exists */ if (stat(path, &sb) != 0) { return -1; } /* check for duplicates */ for (item = SDL_hapticlist; item != NULL; item = item->next) { if (item->dev_num == sb.st_rdev) { return -1; /* duplicate. */ } } /* try to open */ fd = open(path, O_RDWR, 0); if (fd < 0) { return -1; } #ifdef DEBUG_INPUT_EVENTS printf("Checking %s\n", path); #endif /* see if it works */ success = EV_IsHaptic(fd); close(fd); if (success <= 0) { return -1; } item = (SDL_hapticlist_item *) SDL_calloc(1, sizeof (SDL_hapticlist_item)); if (item == NULL) { return -1; } item->fname = SDL_strdup(path); if (item->fname == NULL) { SDL_free(item); return -1; } item->dev_num = sb.st_rdev; /* TODO: should we add instance IDs? */ if (SDL_hapticlist_tail == NULL) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; SDL_hapticlist_tail = item; } ++numhaptics; /* !!! TODO: Send a haptic add event? */ return numhaptics; } #if SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char* path) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; if (path == NULL) { return -1; } for (item = SDL_hapticlist; item != NULL; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->fname) == 0) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); SDL_hapticlist = item->next; } if (item == SDL_hapticlist_tail) { SDL_hapticlist_tail = prev; } /* Need to decrement the haptic count */ --numhaptics; /* !!! TODO: Send a haptic remove event? */ SDL_free(item->fname); SDL_free(item); return retval; } prev = item; } return -1; } #endif /* SDL_USE_LIBUDEV */ /* * Gets the name from a file descriptor. */ static const char * SDL_SYS_HapticNameFromFD(int fd) { static char namebuf[128]; /* We use the evdev name ioctl. */ if (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) { return NULL; } return namebuf; } /* * Return the name of a haptic device, does not need to be opened. */ const char * SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item; int fd; const char *name; item = HapticByDevIndex(index); /* Open the haptic device. */ name = NULL; fd = open(item->fname, O_RDONLY, 0); if (fd >= 0) { name = SDL_SYS_HapticNameFromFD(fd); if (name == NULL) { /* No name found, return device character device */ name = item->fname; } close(fd); } return name; } /* * Opens the haptic device from the file descriptor. */ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic * haptic, int fd) { /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); if (haptic->hwdata == NULL) { SDL_OutOfMemory(); goto open_err; } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); /* Set the data. */ haptic->hwdata->fd = fd; haptic->supported = EV_IsHaptic(fd); haptic->naxes = 2; /* Hardcoded for now, not sure if it's possible to find out. */ /* Set the effects */ if (ioctl(fd, EVIOCGEFFECTS, &haptic->neffects) < 0) { SDL_SetError("Haptic: Unable to query device memory: %s", strerror(errno)); goto open_err; } haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { SDL_OutOfMemory(); goto open_err; } /* Clear the memory */ SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; /* Error handling */ open_err: close(fd); if (haptic->hwdata != NULL) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } return -1; } /* * Opens a haptic device for usage. */ int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { int fd; int ret; SDL_hapticlist_item *item; item = HapticByDevIndex(haptic->index); /* Open the character device */ fd = open(item->fname, O_RDWR, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", item->fname, strerror(errno)); } /* Try to create the haptic. */ ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */ if (ret < 0) { return -1; } /* Set the fname. */ haptic->hwdata->fname = SDL_strdup( item->fname ); return 0; } /* * Opens a haptic device from first mouse it finds for usage. */ int SDL_SYS_HapticMouse(void) { int fd; int device_index = 0; SDL_hapticlist_item *item; for (item = SDL_hapticlist; item; item = item->next) { /* Open the device. */ fd = open(item->fname, O_RDWR, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", item->fname, strerror(errno)); } /* Is it a mouse? */ if (EV_IsMouse(fd)) { close(fd); return device_index; } close(fd); ++device_index; } return -1; } /* * Checks to see if a joystick has haptic features. */ int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) { return EV_IsHaptic(joystick->hwdata->fd); } /* * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { /* We are assuming Linux is using evdev which should trump the old * joystick methods. */ if (SDL_strcmp(joystick->hwdata->fname, haptic->hwdata->fname) == 0) { return 1; } return 0; } /* * Opens a SDL_Haptic from a SDL_Joystick. */ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { int device_index = 0; int fd; int ret; SDL_hapticlist_item *item; /* Find the joystick in the haptic list. */ for (item = SDL_hapticlist; item; item = item->next) { if (SDL_strcmp(item->fname, joystick->hwdata->fname) == 0) { break; } ++device_index; } haptic->index = device_index; if (device_index >= MAX_HAPTICS) { return SDL_SetError("Haptic: Joystick doesn't have Haptic capabilities"); } fd = open(joystick->hwdata->fname, O_RDWR, 0); if (fd < 0) { return SDL_SetError("Haptic: Unable to open %s: %s", joystick->hwdata->fname, strerror(errno)); } ret = SDL_SYS_HapticOpenFromFD(haptic, fd); /* Already closes on error. */ if (ret < 0) { return -1; } haptic->hwdata->fname = SDL_strdup( joystick->hwdata->fname ); return 0; } /* * Closes the haptic device. */ void SDL_SYS_HapticClose(SDL_Haptic * haptic) { if (haptic->hwdata) { /* Free effects. */ SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; /* Clean up */ close(haptic->hwdata->fd); /* Free */ SDL_free(haptic->hwdata->fname); SDL_free(haptic->hwdata); haptic->hwdata = NULL; } /* Clear the rest. */ SDL_memset(haptic, 0, sizeof(SDL_Haptic)); } /* * Clean up after system specific haptic stuff */ void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item = NULL; SDL_hapticlist_item *next = NULL; for (item = SDL_hapticlist; item; item = next) { next = item->next; /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ SDL_free(item->fname); SDL_free(item); } #if SDL_USE_LIBUDEV SDL_UDEV_DelCallback(haptic_udev_callback); SDL_UDEV_Quit(); #endif /* SDL_USE_LIBUDEV */ numhaptics = 0; SDL_hapticlist = NULL; SDL_hapticlist_tail = NULL; } /* * Converts an SDL button to a ff_trigger button. */ static Uint16 SDL_SYS_ToButton(Uint16 button) { Uint16 ff_button; ff_button = 0; /* * Not sure what the proper syntax is because this actually isn't implemented * in the current kernel from what I've seen (2.6.26). */ if (button != 0) { ff_button = BTN_GAMEPAD + button - 1; } return ff_button; } /* * Initializes the ff_effect usable direction from a SDL_HapticDirection. */ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection * src) { Uint32 tmp; switch (src->type) { case SDL_HAPTIC_POLAR: /* Linux directions start from south. (and range from 0 to 0xFFFF) Quoting include/linux/input.h, line 926: Direction of the effect is encoded as follows: 0 deg -> 0x0000 (down) 90 deg -> 0x4000 (left) 180 deg -> 0x8000 (up) 270 deg -> 0xC000 (right) The force pulls into the direction specified by Linux directions, i.e. the opposite convention of SDL directions. */ tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; break; case SDL_HAPTIC_SPHERICAL: /* We convert to polar, because that's the only supported direction on Linux. The first value of a spherical direction is practically the same as a Polar direction, except that we have to add 90 degrees. It is the angle from EAST {1,0} towards SOUTH {0,1}. --> add 9000 --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ tmp = ((src->dir[0]) + 9000) % 36000; /* Convert to polars */ tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; break; case SDL_HAPTIC_CARTESIAN: if (!src->dir[1]) *dest = (src->dir[0] >= 0 ? 0x4000 : 0xC000); else if (!src->dir[0]) *dest = (src->dir[1] >= 0 ? 0x8000 : 0); else { float f = SDL_atan2(src->dir[1], src->dir[0]); /* Ideally we'd use fixed point math instead of floats... */ /* atan2 takes the parameters: Y-axis-value and X-axis-value (in that order) - Y-axis-value is the second coordinate (from center to SOUTH) - X-axis-value is the first coordinate (from center to EAST) We add 36000, because atan2 also returns negative values. Then we practically have the first spherical value. Therefore we proceed as in case SDL_HAPTIC_SPHERICAL and add another 9000 to get the polar value. --> add 45000 in total --> finally convert to [0,0xFFFF] as in case SDL_HAPTIC_POLAR. */ tmp = (((Sint32) (f * 18000. / M_PI)) + 45000) % 36000; tmp = (tmp * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16) tmp; } break; default: return SDL_SetError("Haptic: Unsupported direction type."); } return 0; } #define CLAMP(x) (((x) > 32767) ? 32767 : x) /* * Initializes the Linux effect struct from a haptic_effect. * Values above 32767 (for unsigned) are unspecified so we must clamp. */ static int SDL_SYS_ToFFEffect(struct ff_effect *dest, SDL_HapticEffect * src) { SDL_HapticConstant *constant; SDL_HapticPeriodic *periodic; SDL_HapticCondition *condition; SDL_HapticRamp *ramp; SDL_HapticLeftRight *leftright; /* Clear up */ SDL_memset(dest, 0, sizeof(struct ff_effect)); switch (src->type) { case SDL_HAPTIC_CONSTANT: constant = &src->constant; /* Header */ dest->type = FF_CONSTANT; if (SDL_SYS_ToDirection(&dest->direction, &constant->direction) == -1) return -1; /* Replay */ dest->replay.length = (constant->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(constant->length); dest->replay.delay = CLAMP(constant->delay); /* Trigger */ dest->trigger.button = SDL_SYS_ToButton(constant->button); dest->trigger.interval = CLAMP(constant->interval); /* Constant */ dest->u.constant.level = constant->level; /* Envelope */ dest->u.constant.envelope.attack_length = CLAMP(constant->attack_length); dest->u.constant.envelope.attack_level = CLAMP(constant->attack_level); dest->u.constant.envelope.fade_length = CLAMP(constant->fade_length); dest->u.constant.envelope.fade_level = CLAMP(constant->fade_level); break; case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: periodic = &src->periodic; /* Header */ dest->type = FF_PERIODIC; if (SDL_SYS_ToDirection(&dest->direction, &periodic->direction) == -1) return -1; /* Replay */ dest->replay.length = (periodic->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(periodic->length); dest->replay.delay = CLAMP(periodic->delay); /* Trigger */ dest->trigger.button = SDL_SYS_ToButton(periodic->button); dest->trigger.interval = CLAMP(periodic->interval); /* Periodic */ if (periodic->type == SDL_HAPTIC_SINE) dest->u.periodic.waveform = FF_SINE; /* !!! FIXME: put this back when we have more bits in 2.1 */ /* else if (periodic->type == SDL_HAPTIC_SQUARE) dest->u.periodic.waveform = FF_SQUARE; */ else if (periodic->type == SDL_HAPTIC_TRIANGLE) dest->u.periodic.waveform = FF_TRIANGLE; else if (periodic->type == SDL_HAPTIC_SAWTOOTHUP) dest->u.periodic.waveform = FF_SAW_UP; else if (periodic->type == SDL_HAPTIC_SAWTOOTHDOWN) dest->u.periodic.waveform = FF_SAW_DOWN; dest->u.periodic.period = CLAMP(periodic->period); dest->u.periodic.magnitude = periodic->magnitude; dest->u.periodic.offset = periodic->offset; /* Linux phase is defined in interval "[0x0000, 0x10000[", corresponds with "[0deg, 360deg[" phase shift. */ dest->u.periodic.phase = ((Uint32)periodic->phase * 0x10000U) / 36000; /* Envelope */ dest->u.periodic.envelope.attack_length = CLAMP(periodic->attack_length); dest->u.periodic.envelope.attack_level = CLAMP(periodic->attack_level); dest->u.periodic.envelope.fade_length = CLAMP(periodic->fade_length); dest->u.periodic.envelope.fade_level = CLAMP(periodic->fade_level); break; case SDL_HAPTIC_SPRING: case SDL_HAPTIC_DAMPER: case SDL_HAPTIC_INERTIA: case SDL_HAPTIC_FRICTION: condition = &src->condition; /* Header */ if (condition->type == SDL_HAPTIC_SPRING) dest->type = FF_SPRING; else if (condition->type == SDL_HAPTIC_DAMPER) dest->type = FF_DAMPER; else if (condition->type == SDL_HAPTIC_INERTIA) dest->type = FF_INERTIA; else if (condition->type == SDL_HAPTIC_FRICTION) dest->type = FF_FRICTION; dest->direction = 0; /* Handled by the condition-specifics. */ /* Replay */ dest->replay.length = (condition->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(condition->length); dest->replay.delay = CLAMP(condition->delay); /* Trigger */ dest->trigger.button = SDL_SYS_ToButton(condition->button); dest->trigger.interval = CLAMP(condition->interval); /* Condition */ /* X axis */ dest->u.condition[0].right_saturation = condition->right_sat[0]; dest->u.condition[0].left_saturation = condition->left_sat[0]; dest->u.condition[0].right_coeff = condition->right_coeff[0]; dest->u.condition[0].left_coeff = condition->left_coeff[0]; dest->u.condition[0].deadband = condition->deadband[0]; dest->u.condition[0].center = condition->center[0]; /* Y axis */ dest->u.condition[1].right_saturation = condition->right_sat[1]; dest->u.condition[1].left_saturation = condition->left_sat[1]; dest->u.condition[1].right_coeff = condition->right_coeff[1]; dest->u.condition[1].left_coeff = condition->left_coeff[1]; dest->u.condition[1].deadband = condition->deadband[1]; dest->u.condition[1].center = condition->center[1]; /* * There is no envelope in the linux force feedback api for conditions. */ break; case SDL_HAPTIC_RAMP: ramp = &src->ramp; /* Header */ dest->type = FF_RAMP; if (SDL_SYS_ToDirection(&dest->direction, &ramp->direction) == -1) return -1; /* Replay */ dest->replay.length = (ramp->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(ramp->length); dest->replay.delay = CLAMP(ramp->delay); /* Trigger */ dest->trigger.button = SDL_SYS_ToButton(ramp->button); dest->trigger.interval = CLAMP(ramp->interval); /* Ramp */ dest->u.ramp.start_level = ramp->start; dest->u.ramp.end_level = ramp->end; /* Envelope */ dest->u.ramp.envelope.attack_length = CLAMP(ramp->attack_length); dest->u.ramp.envelope.attack_level = CLAMP(ramp->attack_level); dest->u.ramp.envelope.fade_length = CLAMP(ramp->fade_length); dest->u.ramp.envelope.fade_level = CLAMP(ramp->fade_level); break; case SDL_HAPTIC_LEFTRIGHT: leftright = &src->leftright; /* Header */ dest->type = FF_RUMBLE; dest->direction = 0; /* Replay */ dest->replay.length = (leftright->length == SDL_HAPTIC_INFINITY) ? 0 : CLAMP(leftright->length); /* Trigger */ dest->trigger.button = 0; dest->trigger.interval = 0; /* Rumble */ dest->u.rumble.strong_magnitude = leftright->large_magnitude; dest->u.rumble.weak_magnitude = leftright->small_magnitude; break; default: return SDL_SetError("Haptic: Unknown effect type."); } return 0; } /* * Creates a new haptic effect. */ int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { struct ff_effect *linux_effect; /* Allocate the hardware effect */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); if (effect->hweffect == NULL) { return SDL_OutOfMemory(); } /* Prepare the ff_effect */ linux_effect = &effect->hweffect->effect; if (SDL_SYS_ToFFEffect(linux_effect, base) != 0) { goto new_effect_err; } linux_effect->id = -1; /* Have the kernel give it an id */ /* Upload the effect */ if (ioctl(haptic->hwdata->fd, EVIOCSFF, linux_effect) < 0) { SDL_SetError("Haptic: Error uploading effect to the device: %s", strerror(errno)); goto new_effect_err; } return 0; new_effect_err: SDL_free(effect->hweffect); effect->hweffect = NULL; return -1; } /* * Updates an effect. * * Note: Dynamically updating the direction can in some cases force * the effect to restart and run once. */ int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { struct ff_effect linux_effect; /* Create the new effect */ if (SDL_SYS_ToFFEffect(&linux_effect, data) != 0) { return -1; } linux_effect.id = effect->hweffect->effect.id; /* See if it can be uploaded. */ if (ioctl(haptic->hwdata->fd, EVIOCSFF, &linux_effect) < 0) { return SDL_SetError("Haptic: Error updating the effect: %s", strerror(errno)); } /* Copy the new effect into memory. */ SDL_memcpy(&effect->hweffect->effect, &linux_effect, sizeof(struct ff_effect)); return effect->hweffect->effect.id; } /* * Runs an effect. */ int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { struct input_event run; /* Prepare to run the effect */ run.type = EV_FF; run.code = effect->hweffect->effect.id; /* We don't actually have infinity here, so we just do INT_MAX which is pretty damn close. */ run.value = (iterations > INT_MAX) ? INT_MAX : iterations; if (write(haptic->hwdata->fd, (const void *) &run, sizeof(run)) < 0) { return SDL_SetError("Haptic: Unable to run the effect: %s", strerror(errno)); } return 0; } /* * Stops an effect. */ int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { struct input_event stop; stop.type = EV_FF; stop.code = effect->hweffect->effect.id; stop.value = 0; if (write(haptic->hwdata->fd, (const void *) &stop, sizeof(stop)) < 0) { return SDL_SetError("Haptic: Unable to stop the effect: %s", strerror(errno)); } return 0; } /* * Frees the effect. */ void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { if (ioctl(haptic->hwdata->fd, EVIOCRMFF, effect->hweffect->effect.id) < 0) { SDL_SetError("Haptic: Error removing the effect from the device: %s", strerror(errno)); } SDL_free(effect->hweffect); effect->hweffect = NULL; } /* * Gets the status of a haptic effect. */ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { #if 0 /* Not supported atm. */ struct input_event ie; ie.type = EV_FF; ie.type = EV_FF_STATUS; ie.code = effect->hweffect->effect.id; if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) { return SDL_SetError("Haptic: Error getting device status."); } return 0; #endif return -1; } /* * Sets the gain. */ int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) { struct input_event ie; ie.type = EV_FF; ie.code = FF_GAIN; ie.value = (0xFFFFUL * gain) / 100; if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) { return SDL_SetError("Haptic: Error setting gain: %s", strerror(errno)); } return 0; } /* * Sets the autocentering. */ int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { struct input_event ie; ie.type = EV_FF; ie.code = FF_AUTOCENTER; ie.value = (0xFFFFUL * autocenter) / 100; if (write(haptic->hwdata->fd, &ie, sizeof(ie)) < 0) { return SDL_SetError("Haptic: Error setting autocenter: %s", strerror(errno)); } return 0; } /* * Pausing is not supported atm by linux. */ int SDL_SYS_HapticPause(SDL_Haptic * haptic) { return -1; } /* * Unpausing is not supported atm by linux. */ int SDL_SYS_HapticUnpause(SDL_Haptic * haptic) { return -1; } /* * Stops all the currently playing effects. */ int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { int i, ret; /* Linux does not support this natively so we have to loop. */ for (i = 0; i < haptic->neffects; i++) { if (haptic->effects[i].hweffect != NULL) { ret = SDL_SYS_HapticStopEffect(haptic, &haptic->effects[i]); if (ret < 0) { return SDL_SetError ("Haptic: Error while trying to stop all playing effects."); } } } return 0; } #endif /* SDL_HAPTIC_LINUX */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_dinputhaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_error.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #if SDL_HAPTIC_DINPUT #include "SDL_stdinc.h" #include "SDL_timer.h" #include "SDL_windowshaptic_c.h" #include "SDL_dinputhaptic_c.h" #include "../../joystick/windows/SDL_windowsjoystick_c.h" /* * External stuff. */ extern HWND SDL_HelperWindow; /* * Internal stuff. */ static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT8 dinput = NULL; /* * Like SDL_SetError but for DX error codes. */ static int DI_SetError(const char *str, HRESULT err) { /* SDL_SetError("Haptic: %s - %s: %s", str, DXGetErrorString8A(err), DXGetErrorDescription8A(err)); */ return SDL_SetError("Haptic error %s", str); } /* * Callback to find the haptic devices. */ static BOOL CALLBACK EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { (void) pContext; SDL_DINPUT_MaybeAddDevice(pdidInstance); return DIENUM_CONTINUE; /* continue enumerating */ } int SDL_DINPUT_HapticInit(void) { HRESULT ret; HINSTANCE instance; if (dinput != NULL) { /* Already open. */ return SDL_SetError("Haptic: SubSystem already open."); } ret = WIN_CoInitialize(); if (FAILED(ret)) { return DI_SetError("Coinitialize", ret); } coinitialized = SDL_TRUE; ret = CoCreateInstance(&CLSID_DirectInput8, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput8, (LPVOID)& dinput); if (FAILED(ret)) { SDL_SYS_HapticQuit(); return DI_SetError("CoCreateInstance", ret); } /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); if (instance == NULL) { SDL_SYS_HapticQuit(); return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); } ret = IDirectInput8_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(ret)) { SDL_SYS_HapticQuit(); return DI_SetError("Initializing DirectInput device", ret); } /* Look for haptic devices. */ ret = IDirectInput8_EnumDevices(dinput, 0, EnumHapticsCallback, NULL, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY); if (FAILED(ret)) { SDL_SYS_HapticQuit(); return DI_SetError("Enumerating DirectInput devices", ret); } return 0; } int SDL_DINPUT_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) { HRESULT ret; LPDIRECTINPUTDEVICE8 device; const DWORD needflags = DIDC_ATTACHED | DIDC_FORCEFEEDBACK; DIDEVCAPS capabilities; SDL_hapticlist_item *item = NULL; if (dinput == NULL) { return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ } /* Make sure we don't already have it */ for (item = SDL_hapticlist; item; item = item->next) { if ((!item->bXInputHaptic) && (SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0)) { return -1; /* Already added */ } } /* Open the device */ ret = IDirectInput8_CreateDevice(dinput, &pdidInstance->guidInstance, &device, NULL); if (FAILED(ret)) { /* DI_SetError("Creating DirectInput device",ret); */ return -1; } /* Get capabilities. */ SDL_zero(capabilities); capabilities.dwSize = sizeof(DIDEVCAPS); ret = IDirectInputDevice8_GetCapabilities(device, &capabilities); IDirectInputDevice8_Release(device); if (FAILED(ret)) { /* DI_SetError("Getting device capabilities",ret); */ return -1; } if ((capabilities.dwFlags & needflags) != needflags) { return -1; /* not a device we can use. */ } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); if (item == NULL) { return SDL_OutOfMemory(); } item->name = WIN_StringToUTF8(pdidInstance->tszProductName); if (!item->name) { SDL_free(item); return -1; } /* Copy the instance over, useful for creating devices. */ SDL_memcpy(&item->instance, pdidInstance, sizeof(DIDEVICEINSTANCE)); SDL_memcpy(&item->capabilities, &capabilities, sizeof(capabilities)); return SDL_SYS_AddHapticDevice(item); } int SDL_DINPUT_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; if (dinput == NULL) { return -1; /* not initialized, ignore this. */ } for (item = SDL_hapticlist; item != NULL; item = item->next) { if (!item->bXInputHaptic && SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); } prev = item; } return -1; } /* * Callback to get supported axes. */ static BOOL CALLBACK DI_DeviceObjectCallback(LPCDIDEVICEOBJECTINSTANCE dev, LPVOID pvRef) { SDL_Haptic *haptic = (SDL_Haptic *) pvRef; if ((dev->dwType & DIDFT_AXIS) && (dev->dwFlags & DIDOI_FFACTUATOR)) { const GUID *guid = &dev->guidType; DWORD offset = 0; if (WIN_IsEqualGUID(guid, &GUID_XAxis)) { offset = DIJOFS_X; } else if (WIN_IsEqualGUID(guid, &GUID_YAxis)) { offset = DIJOFS_Y; } else if (WIN_IsEqualGUID(guid, &GUID_ZAxis)) { offset = DIJOFS_Z; } else if (WIN_IsEqualGUID(guid, &GUID_RxAxis)) { offset = DIJOFS_RX; } else if (WIN_IsEqualGUID(guid, &GUID_RyAxis)) { offset = DIJOFS_RY; } else if (WIN_IsEqualGUID(guid, &GUID_RzAxis)) { offset = DIJOFS_RZ; } else { return DIENUM_CONTINUE; /* can't use this, go on. */ } haptic->hwdata->axes[haptic->naxes] = offset; haptic->naxes++; /* Currently using the artificial limit of 3 axes. */ if (haptic->naxes >= 3) { return DIENUM_STOP; } } return DIENUM_CONTINUE; } /* * Callback to get all supported effects. */ #define EFFECT_TEST(e,s) \ if (WIN_IsEqualGUID(&pei->guid, &(e))) \ haptic->supported |= (s) static BOOL CALLBACK DI_EffectCallback(LPCDIEFFECTINFO pei, LPVOID pv) { /* Prepare the haptic device. */ SDL_Haptic *haptic = (SDL_Haptic *) pv; /* Get supported. */ EFFECT_TEST(GUID_Spring, SDL_HAPTIC_SPRING); EFFECT_TEST(GUID_Damper, SDL_HAPTIC_DAMPER); EFFECT_TEST(GUID_Inertia, SDL_HAPTIC_INERTIA); EFFECT_TEST(GUID_Friction, SDL_HAPTIC_FRICTION); EFFECT_TEST(GUID_ConstantForce, SDL_HAPTIC_CONSTANT); EFFECT_TEST(GUID_CustomForce, SDL_HAPTIC_CUSTOM); EFFECT_TEST(GUID_Sine, SDL_HAPTIC_SINE); /* !!! FIXME: put this back when we have more bits in 2.1 */ /* EFFECT_TEST(GUID_Square, SDL_HAPTIC_SQUARE); */ EFFECT_TEST(GUID_Triangle, SDL_HAPTIC_TRIANGLE); EFFECT_TEST(GUID_SawtoothUp, SDL_HAPTIC_SAWTOOTHUP); EFFECT_TEST(GUID_SawtoothDown, SDL_HAPTIC_SAWTOOTHDOWN); EFFECT_TEST(GUID_RampForce, SDL_HAPTIC_RAMP); /* Check for more. */ return DIENUM_CONTINUE; } /* * Opens the haptic device. * * Steps: * - Set cooperative level. * - Set data format. * - Acquire exclusiveness. * - Reset actuators. * - Get supported features. */ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic * haptic, LPDIRECTINPUTDEVICE8 device8, SDL_bool is_joystick) { HRESULT ret; DIPROPDWORD dipdw; /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); if (haptic->hwdata == NULL) { return SDL_OutOfMemory(); } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); /* We'll use the device8 from now on. */ haptic->hwdata->device = device8; haptic->hwdata->is_joystick = is_joystick; /* !!! FIXME: opening a haptic device here first will make an attempt to !!! FIXME: SDL_JoystickOpen() that same device fail later, since we !!! FIXME: have it open in exclusive mode. But this will allow !!! FIXME: SDL_JoystickOpen() followed by SDL_HapticOpenFromJoystick() !!! FIXME: to work, and that's probably the common case. Still, !!! FIXME: ideally, We need to unify the opening code. */ if (!is_joystick) { /* if is_joystick, we already set this up elsewhere. */ /* Grab it exclusively to use force feedback stuff. */ ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device, SDL_HelperWindow, DISCL_EXCLUSIVE | DISCL_BACKGROUND); if (FAILED(ret)) { DI_SetError("Setting cooperative level to exclusive", ret); goto acquire_err; } /* Set data format. */ ret = IDirectInputDevice8_SetDataFormat(haptic->hwdata->device, &SDL_c_dfDIJoystick2); if (FAILED(ret)) { DI_SetError("Setting data format", ret); goto acquire_err; } /* Acquire the device. */ ret = IDirectInputDevice8_Acquire(haptic->hwdata->device); if (FAILED(ret)) { DI_SetError("Acquiring DirectInput device", ret); goto acquire_err; } } /* Get number of axes. */ ret = IDirectInputDevice8_EnumObjects(haptic->hwdata->device, DI_DeviceObjectCallback, haptic, DIDFT_AXIS); if (FAILED(ret)) { DI_SetError("Getting device axes", ret); goto acquire_err; } /* Reset all actuators - just in case. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_RESET); if (FAILED(ret)) { DI_SetError("Resetting device", ret); goto acquire_err; } /* Enabling actuators. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_SETACTUATORSON); if (FAILED(ret)) { DI_SetError("Enabling actuators", ret); goto acquire_err; } /* Get supported effects. */ ret = IDirectInputDevice8_EnumEffects(haptic->hwdata->device, DI_EffectCallback, haptic, DIEFT_ALL); if (FAILED(ret)) { DI_SetError("Enumerating supported effects", ret); goto acquire_err; } if (haptic->supported == 0) { /* Error since device supports nothing. */ SDL_SetError("Haptic: Internal error on finding supported effects."); goto acquire_err; } /* Check autogain and autocenter. */ dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = 10000; ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_FFGAIN, &dipdw.diph); if (!FAILED(ret)) { /* Gain is supported. */ haptic->supported |= SDL_HAPTIC_GAIN; } dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = DIPROPAUTOCENTER_OFF; ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_AUTOCENTER, &dipdw.diph); if (!FAILED(ret)) { /* Autocenter is supported. */ haptic->supported |= SDL_HAPTIC_AUTOCENTER; } /* Status is always supported. */ haptic->supported |= SDL_HAPTIC_STATUS | SDL_HAPTIC_PAUSE; /* Check maximum effects. */ haptic->neffects = 128; /* This is not actually supported as thus under windows, there is no way to tell the number of EFFECTS that a device can hold, so we'll just use a "random" number instead and put warnings in SDL_haptic.h */ haptic->nplaying = 128; /* Even more impossible to get this then neffects. */ /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { SDL_OutOfMemory(); goto acquire_err; } /* Clear the memory */ SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); return 0; /* Error handling */ acquire_err: IDirectInputDevice8_Unacquire(haptic->hwdata->device); return -1; } int SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) { HRESULT ret; LPDIRECTINPUTDEVICE8 device; LPDIRECTINPUTDEVICE8 device8; /* Open the device */ ret = IDirectInput8_CreateDevice(dinput, &item->instance.guidInstance, &device, NULL); if (FAILED(ret)) { DI_SetError("Creating DirectInput device", ret); return -1; } /* Now get the IDirectInputDevice8 interface, instead. */ ret = IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8, (LPVOID *)&device8); /* Done with the temporary one now. */ IDirectInputDevice8_Release(device); if (FAILED(ret)) { DI_SetError("Querying DirectInput interface", ret); return -1; } if (SDL_DINPUT_HapticOpenFromDevice(haptic, device8, SDL_FALSE) < 0) { IDirectInputDevice8_Release(device8); return -1; } return 0; } int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { HRESULT ret; DIDEVICEINSTANCE hap_instance, joy_instance; hap_instance.dwSize = sizeof(DIDEVICEINSTANCE); joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); /* Get the device instances. */ ret = IDirectInputDevice8_GetDeviceInfo(haptic->hwdata->device, &hap_instance); if (FAILED(ret)) { return 0; } ret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice, &joy_instance); if (FAILED(ret)) { return 0; } return WIN_IsEqualGUID(&hap_instance.guidInstance, &joy_instance.guidInstance); } int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { SDL_hapticlist_item *item; int index = 0; HRESULT ret; DIDEVICEINSTANCE joy_instance; joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); ret = IDirectInputDevice8_GetDeviceInfo(joystick->hwdata->InputDevice, &joy_instance); if (FAILED(ret)) { return -1; } /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ for (item = SDL_hapticlist; item != NULL; item = item->next) { if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) { haptic->index = index; return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE); } ++index; } SDL_SetError("Couldn't find joystick in haptic device list"); return -1; } void SDL_DINPUT_HapticClose(SDL_Haptic * haptic) { IDirectInputDevice8_Unacquire(haptic->hwdata->device); /* Only release if isn't grabbed by a joystick. */ if (haptic->hwdata->is_joystick == 0) { IDirectInputDevice8_Release(haptic->hwdata->device); } } void SDL_DINPUT_HapticQuit(void) { if (dinput != NULL) { IDirectInput8_Release(dinput); dinput = NULL; } if (coinitialized) { WIN_CoUninitialize(); coinitialized = SDL_FALSE; } } /* * Converts an SDL trigger button to an DIEFFECT trigger button. */ static DWORD DIGetTriggerButton(Uint16 button) { DWORD dwTriggerButton; dwTriggerButton = DIEB_NOTRIGGER; if (button != 0) { dwTriggerButton = DIJOFS_BUTTON(button - 1); } return dwTriggerButton; } /* * Sets the direction. */ static int SDL_SYS_SetDirection(DIEFFECT * effect, SDL_HapticDirection * dir, int naxes) { LONG *rglDir; /* Handle no axes a part. */ if (naxes == 0) { effect->dwFlags |= DIEFF_SPHERICAL; /* Set as default. */ effect->rglDirection = NULL; return 0; } /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); if (rglDir == NULL) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); effect->rglDirection = rglDir; switch (dir->type) { case SDL_HAPTIC_POLAR: effect->dwFlags |= DIEFF_POLAR; rglDir[0] = dir->dir[0]; return 0; case SDL_HAPTIC_CARTESIAN: effect->dwFlags |= DIEFF_CARTESIAN; rglDir[0] = dir->dir[0]; if (naxes > 1) rglDir[1] = dir->dir[1]; if (naxes > 2) rglDir[2] = dir->dir[2]; return 0; case SDL_HAPTIC_SPHERICAL: effect->dwFlags |= DIEFF_SPHERICAL; rglDir[0] = dir->dir[0]; if (naxes > 1) rglDir[1] = dir->dir[1]; if (naxes > 2) rglDir[2] = dir->dir[2]; return 0; default: return SDL_SetError("Haptic: Unknown direction type."); } } /* Clamps and converts. */ #define CCONVERT(x) (((x) > 0x7FFF) ? 10000 : ((x)*10000) / 0x7FFF) /* Just converts. */ #define CONVERT(x) (((x)*10000) / 0x7FFF) /* * Creates the DIEFFECT from a SDL_HapticEffect. */ static int SDL_SYS_ToDIEFFECT(SDL_Haptic * haptic, DIEFFECT * dest, SDL_HapticEffect * src) { int i; DICONSTANTFORCE *constant; DIPERIODIC *periodic; DICONDITION *condition; /* Actually an array of conditions - one per axis. */ DIRAMPFORCE *ramp; DICUSTOMFORCE *custom; DIENVELOPE *envelope; SDL_HapticConstant *hap_constant; SDL_HapticPeriodic *hap_periodic; SDL_HapticCondition *hap_condition; SDL_HapticRamp *hap_ramp; SDL_HapticCustom *hap_custom; DWORD *axes; /* Set global stuff. */ SDL_memset(dest, 0, sizeof(DIEFFECT)); dest->dwSize = sizeof(DIEFFECT); /* Set the structure size. */ dest->dwSamplePeriod = 0; /* Not used by us. */ dest->dwGain = 10000; /* Gain is set globally, not locally. */ dest->dwFlags = DIEFF_OBJECTOFFSETS; /* Seems obligatory. */ /* Envelope. */ envelope = SDL_malloc(sizeof(DIENVELOPE)); if (envelope == NULL) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(DIENVELOPE)); dest->lpEnvelope = envelope; envelope->dwSize = sizeof(DIENVELOPE); /* Always should be this. */ /* Axes. */ dest->cAxes = haptic->naxes; if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); if (axes == NULL) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ if (dest->cAxes > 1) { axes[1] = haptic->hwdata->axes[1]; } if (dest->cAxes > 2) { axes[2] = haptic->hwdata->axes[2]; } dest->rgdwAxes = axes; } /* The big type handling switch, even bigger than Linux's version. */ switch (src->type) { case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(DICONSTANTFORCE)); if (constant == NULL) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(DICONSTANTFORCE)); /* Specifics */ constant->lMagnitude = CONVERT(hap_constant->level); dest->cbTypeSpecificParams = sizeof(DICONSTANTFORCE); dest->lpvTypeSpecificParams = constant; /* Generics */ dest->dwDuration = hap_constant->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_constant->button); dest->dwTriggerRepeatInterval = hap_constant->interval; dest->dwStartDelay = hap_constant->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_constant->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_constant->attack_length == 0) && (hap_constant->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_constant->attack_level); envelope->dwAttackTime = hap_constant->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_constant->fade_level); envelope->dwFadeTime = hap_constant->fade_length * 1000; } break; case SDL_HAPTIC_SINE: /* !!! FIXME: put this back when we have more bits in 2.1 */ /* case SDL_HAPTIC_SQUARE: */ case SDL_HAPTIC_TRIANGLE: case SDL_HAPTIC_SAWTOOTHUP: case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(DIPERIODIC)); if (periodic == NULL) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(DIPERIODIC)); /* Specifics */ periodic->dwMagnitude = CONVERT(SDL_abs(hap_periodic->magnitude)); periodic->lOffset = CONVERT(hap_periodic->offset); periodic->dwPhase = (hap_periodic->phase + (hap_periodic->magnitude < 0 ? 18000 : 0)) % 36000; periodic->dwPeriod = hap_periodic->period * 1000; dest->cbTypeSpecificParams = sizeof(DIPERIODIC); dest->lpvTypeSpecificParams = periodic; /* Generics */ dest->dwDuration = hap_periodic->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_periodic->button); dest->dwTriggerRepeatInterval = hap_periodic->interval; dest->dwStartDelay = hap_periodic->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_periodic->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_periodic->attack_length == 0) && (hap_periodic->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_periodic->attack_level); envelope->dwAttackTime = hap_periodic->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_periodic->fade_level); envelope->dwFadeTime = hap_periodic->fade_length * 1000; } break; case SDL_HAPTIC_SPRING: case SDL_HAPTIC_DAMPER: case SDL_HAPTIC_INERTIA: case SDL_HAPTIC_FRICTION: hap_condition = &src->condition; condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes); if (condition == NULL) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(DICONDITION)); /* Specifics */ for (i = 0; i < (int) dest->cAxes; i++) { condition[i].lOffset = CONVERT(hap_condition->center[i]); condition[i].lPositiveCoefficient = CONVERT(hap_condition->right_coeff[i]); condition[i].lNegativeCoefficient = CONVERT(hap_condition->left_coeff[i]); condition[i].dwPositiveSaturation = CCONVERT(hap_condition->right_sat[i] / 2); condition[i].dwNegativeSaturation = CCONVERT(hap_condition->left_sat[i] / 2); condition[i].lDeadBand = CCONVERT(hap_condition->deadband[i] / 2); } dest->cbTypeSpecificParams = sizeof(DICONDITION) * dest->cAxes; dest->lpvTypeSpecificParams = condition; /* Generics */ dest->dwDuration = hap_condition->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_condition->button); dest->dwTriggerRepeatInterval = hap_condition->interval; dest->dwStartDelay = hap_condition->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_condition->direction, dest->cAxes) < 0) { return -1; } /* Envelope - Not actually supported by most CONDITION implementations. */ SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; break; case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(DIRAMPFORCE)); if (ramp == NULL) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(DIRAMPFORCE)); /* Specifics */ ramp->lStart = CONVERT(hap_ramp->start); ramp->lEnd = CONVERT(hap_ramp->end); dest->cbTypeSpecificParams = sizeof(DIRAMPFORCE); dest->lpvTypeSpecificParams = ramp; /* Generics */ dest->dwDuration = hap_ramp->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_ramp->button); dest->dwTriggerRepeatInterval = hap_ramp->interval; dest->dwStartDelay = hap_ramp->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_ramp->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_ramp->attack_length == 0) && (hap_ramp->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_ramp->attack_level); envelope->dwAttackTime = hap_ramp->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_ramp->fade_level); envelope->dwFadeTime = hap_ramp->fade_length * 1000; } break; case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(DICUSTOMFORCE)); if (custom == NULL) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(DICUSTOMFORCE)); /* Specifics */ custom->cChannels = hap_custom->channels; custom->dwSamplePeriod = hap_custom->period * 1000; custom->cSamples = hap_custom->samples; custom->rglForceData = SDL_malloc(sizeof(LONG) * custom->cSamples * custom->cChannels); for (i = 0; i < hap_custom->samples * hap_custom->channels; i++) { /* Copy data. */ custom->rglForceData[i] = CCONVERT(hap_custom->data[i]); } dest->cbTypeSpecificParams = sizeof(DICUSTOMFORCE); dest->lpvTypeSpecificParams = custom; /* Generics */ dest->dwDuration = hap_custom->length * 1000; /* In microseconds. */ dest->dwTriggerButton = DIGetTriggerButton(hap_custom->button); dest->dwTriggerRepeatInterval = hap_custom->interval; dest->dwStartDelay = hap_custom->delay * 1000; /* In microseconds. */ /* Direction. */ if (SDL_SYS_SetDirection(dest, &hap_custom->direction, dest->cAxes) < 0) { return -1; } /* Envelope */ if ((hap_custom->attack_length == 0) && (hap_custom->fade_length == 0)) { SDL_free(dest->lpEnvelope); dest->lpEnvelope = NULL; } else { envelope->dwAttackLevel = CCONVERT(hap_custom->attack_level); envelope->dwAttackTime = hap_custom->attack_length * 1000; envelope->dwFadeLevel = CCONVERT(hap_custom->fade_level); envelope->dwFadeTime = hap_custom->fade_length * 1000; } break; default: return SDL_SetError("Haptic: Unknown effect type."); } return 0; } /* * Frees an DIEFFECT allocated by SDL_SYS_ToDIEFFECT. */ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type) { DICUSTOMFORCE *custom; SDL_free(effect->lpEnvelope); effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; if (effect->lpvTypeSpecificParams != NULL) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); custom->rglForceData = NULL; } SDL_free(effect->lpvTypeSpecificParams); effect->lpvTypeSpecificParams = NULL; } SDL_free(effect->rglDirection); effect->rglDirection = NULL; } /* * Gets the effect type from the generic SDL haptic effect wrapper. */ static REFGUID SDL_SYS_HapticEffectType(SDL_HapticEffect * effect) { switch (effect->type) { case SDL_HAPTIC_CONSTANT: return &GUID_ConstantForce; case SDL_HAPTIC_RAMP: return &GUID_RampForce; /* !!! FIXME: put this back when we have more bits in 2.1 */ /* case SDL_HAPTIC_SQUARE: return &GUID_Square; */ case SDL_HAPTIC_SINE: return &GUID_Sine; case SDL_HAPTIC_TRIANGLE: return &GUID_Triangle; case SDL_HAPTIC_SAWTOOTHUP: return &GUID_SawtoothUp; case SDL_HAPTIC_SAWTOOTHDOWN: return &GUID_SawtoothDown; case SDL_HAPTIC_SPRING: return &GUID_Spring; case SDL_HAPTIC_DAMPER: return &GUID_Damper; case SDL_HAPTIC_INERTIA: return &GUID_Inertia; case SDL_HAPTIC_FRICTION: return &GUID_Friction; case SDL_HAPTIC_CUSTOM: return &GUID_CustomForce; default: return NULL; } } int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { HRESULT ret; REFGUID type = SDL_SYS_HapticEffectType(base); if (type == NULL) { SDL_SetError("Haptic: Unknown effect type."); return -1; } /* Get the effect. */ if (SDL_SYS_ToDIEFFECT(haptic, &effect->hweffect->effect, base) < 0) { goto err_effectdone; } /* Create the actual effect. */ ret = IDirectInputDevice8_CreateEffect(haptic->hwdata->device, type, &effect->hweffect->effect, &effect->hweffect->ref, NULL); if (FAILED(ret)) { DI_SetError("Unable to create effect", ret); goto err_effectdone; } return 0; err_effectdone: SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type); return -1; } int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { HRESULT ret; DWORD flags; DIEFFECT temp; /* Get the effect. */ SDL_memset(&temp, 0, sizeof(DIEFFECT)); if (SDL_SYS_ToDIEFFECT(haptic, &temp, data) < 0) { goto err_update; } /* Set the flags. Might be worthwhile to diff temp with loaded effect and * only change those parameters. */ flags = DIEP_DIRECTION | DIEP_DURATION | DIEP_ENVELOPE | DIEP_STARTDELAY | DIEP_TRIGGERBUTTON | DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS; /* Create the actual effect. */ ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); if (ret == DIERR_NOTEXCLUSIVEACQUIRED) { IDirectInputDevice8_Unacquire(haptic->hwdata->device); ret = IDirectInputDevice8_SetCooperativeLevel(haptic->hwdata->device, SDL_HelperWindow, DISCL_EXCLUSIVE | DISCL_BACKGROUND); if (SUCCEEDED(ret)) { ret = DIERR_NOTACQUIRED; } } if (ret == DIERR_INPUTLOST || ret == DIERR_NOTACQUIRED) { ret = IDirectInputDevice8_Acquire(haptic->hwdata->device); if (SUCCEEDED(ret)) { ret = IDirectInputEffect_SetParameters(effect->hweffect->ref, &temp, flags); } } if (FAILED(ret)) { DI_SetError("Unable to update effect", ret); goto err_update; } /* Copy it over. */ SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, data->type); SDL_memcpy(&effect->hweffect->effect, &temp, sizeof(DIEFFECT)); return 0; err_update: SDL_SYS_HapticFreeDIEFFECT(&temp, data->type); return -1; } int SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { HRESULT ret; DWORD iter; /* Check if it's infinite. */ if (iterations == SDL_HAPTIC_INFINITY) { iter = INFINITE; } else { iter = iterations; } /* Run the effect. */ ret = IDirectInputEffect_Start(effect->hweffect->ref, iter, 0); if (FAILED(ret)) { return DI_SetError("Running the effect", ret); } return 0; } int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; ret = IDirectInputEffect_Stop(effect->hweffect->ref); if (FAILED(ret)) { return DI_SetError("Unable to stop effect", ret); } return 0; } void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; ret = IDirectInputEffect_Unload(effect->hweffect->ref); if (FAILED(ret)) { DI_SetError("Removing effect from the device", ret); } SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, effect->effect.type); } int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { HRESULT ret; DWORD status; ret = IDirectInputEffect_GetEffectStatus(effect->hweffect->ref, &status); if (FAILED(ret)) { return DI_SetError("Getting effect status", ret); } if (status == 0) return SDL_FALSE; return SDL_TRUE; } int SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) { HRESULT ret; DIPROPDWORD dipdw; /* Create the weird structure thingy. */ dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = gain * 100; /* 0 to 10,000 */ /* Try to set the autocenter. */ ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_FFGAIN, &dipdw.diph); if (FAILED(ret)) { return DI_SetError("Setting gain", ret); } return 0; } int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { HRESULT ret; DIPROPDWORD dipdw; /* Create the weird structure thingy. */ dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = (autocenter == 0) ? DIPROPAUTOCENTER_OFF : DIPROPAUTOCENTER_ON; /* Try to set the autocenter. */ ret = IDirectInputDevice8_SetProperty(haptic->hwdata->device, DIPROP_AUTOCENTER, &dipdw.diph); if (FAILED(ret)) { return DI_SetError("Setting autocenter", ret); } return 0; } int SDL_DINPUT_HapticPause(SDL_Haptic * haptic) { HRESULT ret; /* Pause the device. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_PAUSE); if (FAILED(ret)) { return DI_SetError("Pausing the device", ret); } return 0; } int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic) { HRESULT ret; /* Unpause the device. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_CONTINUE); if (FAILED(ret)) { return DI_SetError("Pausing the device", ret); } return 0; } int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic) { HRESULT ret; /* Try to stop the effects. */ ret = IDirectInputDevice8_SendForceFeedbackCommand(haptic->hwdata->device, DISFFC_STOPALL); if (FAILED(ret)) { return DI_SetError("Stopping the device", ret); } return 0; } #else /* !SDL_HAPTIC_DINPUT */ typedef struct DIDEVICEINSTANCE DIDEVICEINSTANCE; typedef struct SDL_hapticlist_item SDL_hapticlist_item; int SDL_DINPUT_HapticInit(void) { return 0; } int SDL_DINPUT_MaybeAddDevice(const DIDEVICEINSTANCE * pdidInstance) { return SDL_Unsupported(); } int SDL_DINPUT_MaybeRemoveDevice(const DIDEVICEINSTANCE * pdidInstance) { return SDL_Unsupported(); } int SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) { return SDL_Unsupported(); } int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { return SDL_Unsupported(); } int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { return SDL_Unsupported(); } void SDL_DINPUT_HapticClose(SDL_Haptic * haptic) { } void SDL_DINPUT_HapticQuit(void) { } int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { return SDL_Unsupported(); } int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { return SDL_Unsupported(); } int SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { return SDL_Unsupported(); } int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { } int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } int SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) { return SDL_Unsupported(); } int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { return SDL_Unsupported(); } int SDL_DINPUT_HapticPause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic) { return SDL_Unsupported(); } #endif /* SDL_HAPTIC_DINPUT */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_dinputhaptic_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_haptic.h" #include "SDL_windowshaptic_c.h" extern int SDL_DINPUT_HapticInit(void); extern int SDL_DINPUT_MaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance); extern int SDL_DINPUT_MaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance); extern int SDL_DINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item); extern int SDL_DINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick); extern int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick); extern void SDL_DINPUT_HapticClose(SDL_Haptic * haptic); extern void SDL_DINPUT_HapticQuit(void); extern int SDL_DINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); extern int SDL_DINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data); extern int SDL_DINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations); extern int SDL_DINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect); extern void SDL_DINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect); extern int SDL_DINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect); extern int SDL_DINPUT_HapticSetGain(SDL_Haptic * haptic, int gain); extern int SDL_DINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); extern int SDL_DINPUT_HapticPause(SDL_Haptic * haptic); extern int SDL_DINPUT_HapticUnpause(SDL_Haptic * haptic); extern int SDL_DINPUT_HapticStopAll(SDL_Haptic * haptic); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_windowshaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT #include "SDL_assert.h" #include "SDL_thread.h" #include "SDL_mutex.h" #include "SDL_timer.h" #include "SDL_hints.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ #include "../../joystick/windows/SDL_windowsjoystick_c.h" /* For joystick hwdata */ #include "../../joystick/windows/SDL_xinputjoystick_c.h" /* For xinput rumble */ #include "SDL_windowshaptic_c.h" #include "SDL_dinputhaptic_c.h" #include "SDL_xinputhaptic_c.h" /* * Internal stuff. */ SDL_hapticlist_item *SDL_hapticlist = NULL; static SDL_hapticlist_item *SDL_hapticlist_tail = NULL; static int numhaptics = 0; /* * Initializes the haptic subsystem. */ int SDL_SYS_HapticInit(void) { if (SDL_DINPUT_HapticInit() < 0) { return -1; } if (SDL_XINPUT_HapticInit() < 0) { return -1; } return numhaptics; } int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) { if (SDL_hapticlist_tail == NULL) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; SDL_hapticlist_tail = item; } /* Device has been added. */ ++numhaptics; return numhaptics; } int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) { const int retval = item->haptic ? item->haptic->index : -1; if (prev != NULL) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); SDL_hapticlist = item->next; } if (item == SDL_hapticlist_tail) { SDL_hapticlist_tail = prev; } --numhaptics; /* !!! TODO: Send a haptic remove event? */ SDL_free(item); return retval; } int SDL_SYS_NumHaptics(void) { return numhaptics; } static SDL_hapticlist_item * HapticByDevIndex(int device_index) { SDL_hapticlist_item *item = SDL_hapticlist; if ((device_index < 0) || (device_index >= numhaptics)) { return NULL; } while (device_index > 0) { SDL_assert(item != NULL); --device_index; item = item->next; } return item; } /* * Return the name of a haptic device, does not need to be opened. */ const char * SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item = HapticByDevIndex(index); return item->name; } /* * Opens a haptic device for usage. */ int SDL_SYS_HapticOpen(SDL_Haptic * haptic) { SDL_hapticlist_item *item = HapticByDevIndex(haptic->index); if (item->bXInputHaptic) { return SDL_XINPUT_HapticOpen(haptic, item); } else { return SDL_DINPUT_HapticOpen(haptic, item); } } /* * Opens a haptic device from first mouse it finds for usage. */ int SDL_SYS_HapticMouse(void) { #if SDL_HAPTIC_DINPUT SDL_hapticlist_item *item; int index = 0; /* Grab the first mouse haptic device we find. */ for (item = SDL_hapticlist; item != NULL; item = item->next) { if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) { return index; } ++index; } #endif /* SDL_HAPTIC_DINPUT */ return -1; } /* * Checks to see if a joystick has haptic features. */ int SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { return 0; } #if SDL_HAPTIC_XINPUT if (joystick->hwdata->bXInputHaptic) { return 1; } #endif #if SDL_HAPTIC_DINPUT if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { return 1; } #endif return 0; } /* * Checks to see if the haptic device and joystick are in reality the same. */ int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { return 0; } if (joystick->hwdata->bXInputHaptic != haptic->hwdata->bXInputHaptic) { return 0; /* one is XInput, one is not; not the same device. */ } else if (joystick->hwdata->bXInputHaptic) { return SDL_XINPUT_JoystickSameHaptic(haptic, joystick); } else { return SDL_DINPUT_JoystickSameHaptic(haptic, joystick); } } /* * Opens a SDL_Haptic from a SDL_Joystick. */ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { SDL_assert(joystick->driver == &SDL_WINDOWS_JoystickDriver); if (joystick->hwdata->bXInputDevice) { return SDL_XINPUT_HapticOpenFromJoystick(haptic, joystick); } else { return SDL_DINPUT_HapticOpenFromJoystick(haptic, joystick); } } /* * Closes the haptic device. */ void SDL_SYS_HapticClose(SDL_Haptic * haptic) { if (haptic->hwdata) { /* Free effects. */ SDL_free(haptic->effects); haptic->effects = NULL; haptic->neffects = 0; /* Clean up */ if (haptic->hwdata->bXInputHaptic) { SDL_XINPUT_HapticClose(haptic); } else { SDL_DINPUT_HapticClose(haptic); } /* Free */ SDL_free(haptic->hwdata); haptic->hwdata = NULL; } } /* * Clean up after system specific haptic stuff */ void SDL_SYS_HapticQuit(void) { SDL_hapticlist_item *item; SDL_hapticlist_item *next = NULL; SDL_Haptic *hapticitem = NULL; extern SDL_Haptic *SDL_haptics; for (hapticitem = SDL_haptics; hapticitem; hapticitem = hapticitem->next) { if ((hapticitem->hwdata->bXInputHaptic) && (hapticitem->hwdata->thread)) { /* we _have_ to stop the thread before we free the XInput DLL! */ SDL_AtomicSet(&hapticitem->hwdata->stopThread, 1); SDL_WaitThread(hapticitem->hwdata->thread, NULL); hapticitem->hwdata->thread = NULL; } } for (item = SDL_hapticlist; item; item = next) { /* Opened and not closed haptics are leaked, this is on purpose. * Close your haptic devices after usage. */ /* !!! FIXME: (...is leaking on purpose a good idea?) - No, of course not. */ next = item->next; SDL_free(item->name); SDL_free(item); } SDL_XINPUT_HapticQuit(); SDL_DINPUT_HapticQuit(); numhaptics = 0; SDL_hapticlist = NULL; SDL_hapticlist_tail = NULL; } /* * Creates a new haptic effect. */ int SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { int result; /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); if (effect->hweffect == NULL) { SDL_OutOfMemory(); return -1; } SDL_zerop(effect->hweffect); if (haptic->hwdata->bXInputHaptic) { result = SDL_XINPUT_HapticNewEffect(haptic, effect, base); } else { result = SDL_DINPUT_HapticNewEffect(haptic, effect, base); } if (result < 0) { SDL_free(effect->hweffect); effect->hweffect = NULL; } return result; } /* * Updates an effect. */ int SDL_SYS_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticUpdateEffect(haptic, effect, data); } else { return SDL_DINPUT_HapticUpdateEffect(haptic, effect, data); } } /* * Runs an effect. */ int SDL_SYS_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticRunEffect(haptic, effect, iterations); } else { return SDL_DINPUT_HapticRunEffect(haptic, effect, iterations); } } /* * Stops an effect. */ int SDL_SYS_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticStopEffect(haptic, effect); } else { return SDL_DINPUT_HapticStopEffect(haptic, effect); } } /* * Frees the effect. */ void SDL_SYS_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { SDL_XINPUT_HapticDestroyEffect(haptic, effect); } else { SDL_DINPUT_HapticDestroyEffect(haptic, effect); } SDL_free(effect->hweffect); effect->hweffect = NULL; } /* * Gets the status of a haptic effect. */ int SDL_SYS_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticGetEffectStatus(haptic, effect); } else { return SDL_DINPUT_HapticGetEffectStatus(haptic, effect); } } /* * Sets the gain. */ int SDL_SYS_HapticSetGain(SDL_Haptic * haptic, int gain) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticSetGain(haptic, gain); } else { return SDL_DINPUT_HapticSetGain(haptic, gain); } } /* * Sets the autocentering. */ int SDL_SYS_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticSetAutocenter(haptic, autocenter); } else { return SDL_DINPUT_HapticSetAutocenter(haptic, autocenter); } } /* * Pauses the device. */ int SDL_SYS_HapticPause(SDL_Haptic * haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticPause(haptic); } else { return SDL_DINPUT_HapticPause(haptic); } } /* * Pauses the device. */ int SDL_SYS_HapticUnpause(SDL_Haptic * haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticUnpause(haptic); } else { return SDL_DINPUT_HapticUnpause(haptic); } } /* * Stops all the playing effects on the device. */ int SDL_SYS_HapticStopAll(SDL_Haptic * haptic) { if (haptic->hwdata->bXInputHaptic) { return SDL_XINPUT_HapticStopAll(haptic); } else { return SDL_DINPUT_HapticStopAll(haptic); } } #endif /* SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_windowshaptic_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_windowshaptic_c_h_ #define SDL_windowshaptic_c_h_ #include "SDL_thread.h" #include "../SDL_syshaptic.h" #include "../../core/windows/SDL_directx.h" #include "../../core/windows/SDL_xinput.h" /* * Haptic system hardware data. */ struct haptic_hwdata { #if SDL_HAPTIC_DINPUT LPDIRECTINPUTDEVICE8 device; #endif DWORD axes[3]; /* Axes to use. */ SDL_bool is_joystick; /* Device is loaded as joystick. */ Uint8 bXInputHaptic; /* Supports force feedback via XInput. */ Uint8 userid; /* XInput userid index for this joystick */ SDL_Thread *thread; SDL_mutex *mutex; Uint32 stopTicks; SDL_atomic_t stopThread; }; /* * Haptic system effect data. */ struct haptic_hweffect { #if SDL_HAPTIC_DINPUT DIEFFECT effect; LPDIRECTINPUTEFFECT ref; #endif #if SDL_HAPTIC_XINPUT XINPUT_VIBRATION vibration; #endif }; /* * List of available haptic devices. */ typedef struct SDL_hapticlist_item { char *name; SDL_Haptic *haptic; #if SDL_HAPTIC_DINPUT DIDEVICEINSTANCE instance; DIDEVCAPS capabilities; #endif SDL_bool bXInputHaptic; /* Supports force feedback via XInput. */ Uint8 userid; /* XInput userid index for this joystick */ struct SDL_hapticlist_item *next; } SDL_hapticlist_item; extern SDL_hapticlist_item *SDL_hapticlist; extern int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item); extern int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item); #endif /* SDL_windowshaptic_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_xinputhaptic.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_error.h" #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #if SDL_HAPTIC_XINPUT #include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_timer.h" #include "SDL_windowshaptic_c.h" #include "SDL_xinputhaptic_c.h" #include "../../core/windows/SDL_xinput.h" #include "../../joystick/windows/SDL_windowsjoystick_c.h" #include "../../thread/SDL_systhread.h" /* * Internal stuff. */ static SDL_bool loaded_xinput = SDL_FALSE; int SDL_XINPUT_HapticInit(void) { if (SDL_GetHintBoolean(SDL_HINT_XINPUT_ENABLED, SDL_TRUE)) { loaded_xinput = (WIN_LoadXInputDLL() == 0); } if (loaded_xinput) { DWORD i; for (i = 0; i < XUSER_MAX_COUNT; i++) { SDL_XINPUT_MaybeAddDevice(i); } } return 0; } int SDL_XINPUT_MaybeAddDevice(const DWORD dwUserid) { const Uint8 userid = (Uint8)dwUserid; SDL_hapticlist_item *item; XINPUT_VIBRATION state; if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) { return -1; } /* Make sure we don't already have it */ for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { return -1; /* Already added */ } } SDL_zero(state); if (XINPUTSETSTATE(dwUserid, &state) != ERROR_SUCCESS) { return -1; /* no force feedback on this device. */ } item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item)); if (item == NULL) { return SDL_OutOfMemory(); } SDL_zerop(item); /* !!! FIXME: I'm not bothering to query for a real name right now (can we even?) */ { char buf[64]; SDL_snprintf(buf, sizeof(buf), "XInput Controller #%u", (unsigned int)(userid + 1)); item->name = SDL_strdup(buf); } if (!item->name) { SDL_free(item); return -1; } /* Copy the instance over, useful for creating devices. */ item->bXInputHaptic = SDL_TRUE; item->userid = userid; return SDL_SYS_AddHapticDevice(item); } int SDL_XINPUT_MaybeRemoveDevice(const DWORD dwUserid) { const Uint8 userid = (Uint8)dwUserid; SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; if ((!loaded_xinput) || (dwUserid >= XUSER_MAX_COUNT)) { return -1; } for (item = SDL_hapticlist; item != NULL; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); } prev = item; } return -1; } /* !!! FIXME: this is a hack, remove this later. */ /* Since XInput doesn't offer a way to vibrate for X time, we hook into * SDL_PumpEvents() to check if it's time to stop vibrating with some * frequency. * In practice, this works for 99% of use cases. But in an ideal world, * we do this in a separate thread so that: * - we aren't bound to when the app chooses to pump the event queue. * - we aren't adding more polling to the event queue * - we can emulate all the haptic effects correctly (start on a delay, * mix multiple effects, etc). * * Mostly, this is here to get rumbling to work, and all the other features * are absent in the XInput path for now. :( */ static int SDLCALL SDL_RunXInputHaptic(void *arg) { struct haptic_hwdata *hwdata = (struct haptic_hwdata *) arg; while (!SDL_AtomicGet(&hwdata->stopThread)) { SDL_Delay(50); SDL_LockMutex(hwdata->mutex); /* If we're currently running and need to stop... */ if (hwdata->stopTicks) { if ((hwdata->stopTicks != SDL_HAPTIC_INFINITY) && SDL_TICKS_PASSED(SDL_GetTicks(), hwdata->stopTicks)) { XINPUT_VIBRATION vibration = { 0, 0 }; hwdata->stopTicks = 0; XINPUTSETSTATE(hwdata->userid, &vibration); } } SDL_UnlockMutex(hwdata->mutex); } return 0; } static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 userid) { char threadName[32]; XINPUT_VIBRATION vibration = { 0, 0 }; /* stop any current vibration */ XINPUTSETSTATE(userid, &vibration); haptic->supported = SDL_HAPTIC_LEFTRIGHT; haptic->neffects = 1; haptic->nplaying = 1; /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); if (haptic->effects == NULL) { return SDL_OutOfMemory(); } /* Clear the memory */ SDL_memset(haptic->effects, 0, sizeof(struct haptic_effect) * haptic->neffects); haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); if (haptic->hwdata == NULL) { SDL_free(haptic->effects); haptic->effects = NULL; return SDL_OutOfMemory(); } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); haptic->hwdata->bXInputHaptic = 1; haptic->hwdata->userid = userid; haptic->hwdata->mutex = SDL_CreateMutex(); if (haptic->hwdata->mutex == NULL) { SDL_free(haptic->effects); SDL_free(haptic->hwdata); haptic->effects = NULL; return SDL_SetError("Couldn't create XInput haptic mutex"); } SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", (int)userid); haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata); if (haptic->hwdata->thread == NULL) { SDL_DestroyMutex(haptic->hwdata->mutex); SDL_free(haptic->effects); SDL_free(haptic->hwdata); haptic->effects = NULL; return SDL_SetError("Couldn't create XInput haptic thread"); } return 0; } int SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) { return SDL_XINPUT_HapticOpenFromUserIndex(haptic, item->userid); } int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { return (haptic->hwdata->userid == joystick->hwdata->userid); } int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { SDL_hapticlist_item *item; int index = 0; /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ for (item = SDL_hapticlist; item != NULL; item = item->next) { if (item->bXInputHaptic && item->userid == joystick->hwdata->userid) { haptic->index = index; return SDL_XINPUT_HapticOpenFromUserIndex(haptic, joystick->hwdata->userid); } ++index; } SDL_SetError("Couldn't find joystick in haptic device list"); return -1; } void SDL_XINPUT_HapticClose(SDL_Haptic * haptic) { SDL_AtomicSet(&haptic->hwdata->stopThread, 1); SDL_WaitThread(haptic->hwdata->thread, NULL); SDL_DestroyMutex(haptic->hwdata->mutex); } void SDL_XINPUT_HapticQuit(void) { if (loaded_xinput) { WIN_UnloadXInputDLL(); loaded_xinput = SDL_FALSE; } } int SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { SDL_assert(base->type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ return SDL_XINPUT_HapticUpdateEffect(haptic, effect, base); } int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { XINPUT_VIBRATION *vib = &effect->hweffect->vibration; SDL_assert(data->type == SDL_HAPTIC_LEFTRIGHT); /* SDL_HapticEffect has max magnitude of 32767, XInput expects 65535 max, so multiply */ vib->wLeftMotorSpeed = data->leftright.large_magnitude * 2; vib->wRightMotorSpeed = data->leftright.small_magnitude * 2; SDL_LockMutex(haptic->hwdata->mutex); if (haptic->hwdata->stopTicks) { /* running right now? Update it. */ XINPUTSETSTATE(haptic->hwdata->userid, vib); } SDL_UnlockMutex(haptic->hwdata->mutex); return 0; } int SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { XINPUT_VIBRATION *vib = &effect->hweffect->vibration; SDL_assert(effect->effect.type == SDL_HAPTIC_LEFTRIGHT); /* should catch this at higher level */ SDL_LockMutex(haptic->hwdata->mutex); if (effect->effect.leftright.length == SDL_HAPTIC_INFINITY || iterations == SDL_HAPTIC_INFINITY) { haptic->hwdata->stopTicks = SDL_HAPTIC_INFINITY; } else if ((!effect->effect.leftright.length) || (!iterations)) { /* do nothing. Effect runs for zero milliseconds. */ } else { haptic->hwdata->stopTicks = SDL_GetTicks() + (effect->effect.leftright.length * iterations); if ((haptic->hwdata->stopTicks == SDL_HAPTIC_INFINITY) || (haptic->hwdata->stopTicks == 0)) { haptic->hwdata->stopTicks = 1; /* fix edge cases. */ } } SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, vib) == ERROR_SUCCESS) ? 0 : -1; } int SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { XINPUT_VIBRATION vibration = { 0, 0 }; SDL_LockMutex(haptic->hwdata->mutex); haptic->hwdata->stopTicks = 0; SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1; } void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { SDL_XINPUT_HapticStopEffect(haptic, effect); } int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } int SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) { return SDL_Unsupported(); } int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { return SDL_Unsupported(); } int SDL_XINPUT_HapticPause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) { XINPUT_VIBRATION vibration = { 0, 0 }; SDL_LockMutex(haptic->hwdata->mutex); haptic->hwdata->stopTicks = 0; SDL_UnlockMutex(haptic->hwdata->mutex); return (XINPUTSETSTATE(haptic->hwdata->userid, &vibration) == ERROR_SUCCESS) ? 0 : -1; } #else /* !SDL_HAPTIC_XINPUT */ #include "../../core/windows/SDL_windows.h" typedef struct SDL_hapticlist_item SDL_hapticlist_item; int SDL_XINPUT_HapticInit(void) { return 0; } int SDL_XINPUT_MaybeAddDevice(const DWORD dwUserid) { return SDL_Unsupported(); } int SDL_XINPUT_MaybeRemoveDevice(const DWORD dwUserid) { return SDL_Unsupported(); } int SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item) { return SDL_Unsupported(); } int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { return SDL_Unsupported(); } int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { return SDL_Unsupported(); } void SDL_XINPUT_HapticClose(SDL_Haptic * haptic) { } void SDL_XINPUT_HapticQuit(void) { } int SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base) { return SDL_Unsupported(); } int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data) { return SDL_Unsupported(); } int SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations) { return SDL_Unsupported(); } int SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect) { } int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect) { return SDL_Unsupported(); } int SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain) { return SDL_Unsupported(); } int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter) { return SDL_Unsupported(); } int SDL_XINPUT_HapticPause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic) { return SDL_Unsupported(); } int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic) { return SDL_Unsupported(); } #endif /* SDL_HAPTIC_XINPUT */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic
D://workCode//uploadProject\awtk\3rd\SDL\src\haptic\windows\SDL_xinputhaptic_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #include "SDL_haptic.h" #include "SDL_windowshaptic_c.h" extern int SDL_XINPUT_HapticInit(void); extern int SDL_XINPUT_MaybeAddDevice(const DWORD dwUserid); extern int SDL_XINPUT_MaybeRemoveDevice(const DWORD dwUserid); extern int SDL_XINPUT_HapticOpen(SDL_Haptic * haptic, SDL_hapticlist_item *item); extern int SDL_XINPUT_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick); extern int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick); extern void SDL_XINPUT_HapticClose(SDL_Haptic * haptic); extern void SDL_XINPUT_HapticQuit(void); extern int SDL_XINPUT_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * base); extern int SDL_XINPUT_HapticUpdateEffect(SDL_Haptic * haptic, struct haptic_effect *effect, SDL_HapticEffect * data); extern int SDL_XINPUT_HapticRunEffect(SDL_Haptic * haptic, struct haptic_effect *effect, Uint32 iterations); extern int SDL_XINPUT_HapticStopEffect(SDL_Haptic * haptic, struct haptic_effect *effect); extern void SDL_XINPUT_HapticDestroyEffect(SDL_Haptic * haptic, struct haptic_effect *effect); extern int SDL_XINPUT_HapticGetEffectStatus(SDL_Haptic * haptic, struct haptic_effect *effect); extern int SDL_XINPUT_HapticSetGain(SDL_Haptic * haptic, int gain); extern int SDL_XINPUT_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); extern int SDL_XINPUT_HapticPause(SDL_Haptic * haptic); extern int SDL_XINPUT_HapticUnpause(SDL_Haptic * haptic); extern int SDL_XINPUT_HapticStopAll(SDL_Haptic * haptic); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\hidapi\hidapi.h
/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ /** @file * @defgroup API hidapi API */ #ifndef HIDAPI_H__ #define HIDAPI_H__ #include <wchar.h> #if defined(_WIN32) && !defined(NAMESPACE) && (0) /* SDL: don't export hidapi syms */ #define HID_API_EXPORT __declspec(dllexport) #define HID_API_CALL #else #define HID_API_EXPORT /**< API export macro */ #define HID_API_CALL /**< API call macro */ #endif #define HID_API_EXPORT_CALL HID_API_EXPORT HID_API_CALL /**< API export and call macro*/ #if defined(__cplusplus) && !defined(NAMESPACE) extern "C" { #endif #ifdef NAMESPACE namespace NAMESPACE { #endif struct hid_device_; typedef struct hid_device_ hid_device; /**< opaque hidapi structure */ /** hidapi info structure */ struct hid_device_info { /** Platform-specific device path */ char *path; /** Device Vendor ID */ unsigned short vendor_id; /** Device Product ID */ unsigned short product_id; /** Serial Number */ wchar_t *serial_number; /** Device Release Number in binary-coded decimal, also known as Device Version Number */ unsigned short release_number; /** Manufacturer String */ wchar_t *manufacturer_string; /** Product string */ wchar_t *product_string; /** Usage Page for this Device/Interface (Windows/Mac only). */ unsigned short usage_page; /** Usage for this Device/Interface (Windows/Mac only).*/ unsigned short usage; /** The USB interface which this logical device represents. Valid on both Linux implementations in all cases, and valid on the Windows implementation only if the device contains more than one interface. */ int interface_number; /** Pointer to the next device */ struct hid_device_info *next; }; /** @brief Initialize the HIDAPI library. This function initializes the HIDAPI library. Calling it is not strictly necessary, as it will be called automatically by hid_enumerate() and any of the hid_open_*() functions if it is needed. This function should be called at the beginning of execution however, if there is a chance of HIDAPI handles being opened by different threads simultaneously. @ingroup API @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_init(void); /** @brief Finalize the HIDAPI library. This function frees all of the static data associated with HIDAPI. It should be called at the end of execution to avoid memory leaks. @ingroup API @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_exit(void); /** @brief Enumerate the HID Devices. This function returns a linked list of all the HID devices attached to the system which match vendor_id and product_id. If @p vendor_id is set to 0 then any vendor matches. If @p product_id is set to 0 then any product matches. If @p vendor_id and @p product_id are both set to 0, then all HID devices will be returned. @ingroup API @param vendor_id The Vendor ID (VID) of the types of device to open. @param product_id The Product ID (PID) of the types of device to open. @returns This function returns a pointer to a linked list of type struct #hid_device, containing information about the HID devices attached to the system, or NULL in the case of failure. Free this linked list by calling hid_free_enumeration(). */ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id); /** @brief Free an enumeration Linked List This function frees a linked list created by hid_enumerate(). @ingroup API @param devs Pointer to a list of struct_device returned from hid_enumerate(). */ void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs); /** @brief Open a HID device using a Vendor ID (VID), Product ID (PID) and optionally a serial number. If @p serial_number is NULL, the first device with the specified VID and PID is opened. @ingroup API @param vendor_id The Vendor ID (VID) of the device to open. @param product_id The Product ID (PID) of the device to open. @param serial_number The Serial Number of the device to open (Optionally NULL). @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number); /** @brief Open a HID device by its path name. The path name be determined by calling hid_enumerate(), or a platform-specific path name can be used (eg: /dev/hidraw0 on Linux). @ingroup API @param path The path name of the device to open @returns This function returns a pointer to a #hid_device object on success or NULL on failure. */ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bExclusive /* = false */); /** @brief Write an Output report to a HID device. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_write() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_write(), the Report ID (or 0x0, for devices with a single report), followed by the report data (16 bytes). In this example, the length passed in would be 17. hid_write() will send the data on the first OUT endpoint, if one exists. If it does not, it will send the data through the Control Endpoint (Endpoint 0). @ingroup API @param device A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send. @returns This function returns the actual number of bytes written and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length); /** @brief Read an Input report from a HID device with timeout. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @param milliseconds timeout in milliseconds or -1 for blocking wait. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read within the timeout period, this function returns 0. */ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds); /** @brief Read an Input report from a HID device. Input reports are returned to the host through the INTERRUPT IN endpoint. The first byte will contain the Report number if the device uses numbered reports. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for the report number. @returns This function returns the actual number of bytes read and -1 on error. If no packet was available to be read and the handle is in non-blocking mode, this function returns 0. */ int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length); /** @brief Set the device handle to be non-blocking. In non-blocking mode calls to hid_read() will return immediately with a value of 0 if there is no data to be read. In blocking mode, hid_read() will wait (block) until there is data to read before returning. Nonblocking can be turned on and off at any time. @ingroup API @param device A device handle returned from hid_open(). @param nonblock enable or not the nonblocking reads - 1 to enable nonblocking - 0 to disable nonblocking. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock); /** @brief Send a Feature report to the device. Feature reports are sent over the Control endpoint as a Set_Report transfer. The first byte of @p data[] must contain the Report ID. For devices which only support a single report, this must be set to 0x0. The remaining bytes contain the report data. Since the Report ID is mandatory, calls to hid_send_feature_report() will always contain one more byte than the report contains. For example, if a hid report is 16 bytes long, 17 bytes must be passed to hid_send_feature_report(): the Report ID (or 0x0, for devices which do not use numbered reports), followed by the report data (16 bytes). In this example, the length passed in would be 17. @ingroup API @param device A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send, including the report number. @returns This function returns the actual number of bytes written and -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length); /** @brief Get a feature report from a HID device. Set the first byte of @p data[] to the Report ID of the report to be read. Make sure to allow space for this extra byte in @p data[]. Upon return, the first byte will still contain the Report ID, and the report data will start in data[1]. @ingroup API @param device A device handle returned from hid_open(). @param data A buffer to put the read data into, including the Report ID. Set the first byte of @p data[] to the Report ID of the report to be read, or set it to zero if your device does not use numbered reports. @param length The number of bytes to read, including an extra byte for the report ID. The buffer can be longer than the actual report. @returns This function returns the number of bytes read plus one for the report ID (which is still in the first byte), or -1 on error. */ int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length); /** @brief Close a HID device. @ingroup API @param device A device handle returned from hid_open(). */ void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device); /** @brief Get The Manufacturer String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get The Product String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get The Serial Number String from a HID device. @ingroup API @param device A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen); /** @brief Get a string from a HID device, based on its string index. @ingroup API @param device A device handle returned from hid_open(). @param string_index The index of the string to get. @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen); /** @brief Get a string describing the last error which occurred. @ingroup API @param device A device handle returned from hid_open(). @returns This function returns a string containing the last error which occurred or NULL if none has occurred. */ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device); #if defined(__cplusplus) && !defined(NAMESPACE) } #endif #ifdef NAMESPACE } #endif #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\libusb\hid.c
/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Linux Version - 6/2/2010 Libusb Version - 8/13/2010 FreeBSD Version - 11/1/2011 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ #ifndef _GNU_SOURCE #define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */ #endif /* C */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <locale.h> #include <errno.h> /* Unix */ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/utsname.h> #include <fcntl.h> #include <pthread.h> #include <wchar.h> /* GNU / LibUSB */ #include <libusb.h> #ifndef __ANDROID__ #include <iconv.h> #endif #include "hidapi.h" #ifdef NAMESPACE namespace NAMESPACE { #endif #ifdef __ANDROID__ /* Barrier implementation because Android/Bionic don't have pthread_barrier. This implementation came from Brent Priddy and was posted on StackOverflow. It is used with his permission. */ typedef int pthread_barrierattr_t; typedef struct pthread_barrier { pthread_mutex_t mutex; pthread_cond_t cond; int count; int trip_count; } pthread_barrier_t; static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) { if(count == 0) { errno = EINVAL; return -1; } if(pthread_mutex_init(&barrier->mutex, 0) < 0) { return -1; } if(pthread_cond_init(&barrier->cond, 0) < 0) { pthread_mutex_destroy(&barrier->mutex); return -1; } barrier->trip_count = count; barrier->count = 0; return 0; } static int pthread_barrier_destroy(pthread_barrier_t *barrier) { pthread_cond_destroy(&barrier->cond); pthread_mutex_destroy(&barrier->mutex); return 0; } static int pthread_barrier_wait(pthread_barrier_t *barrier) { pthread_mutex_lock(&barrier->mutex); ++(barrier->count); if(barrier->count >= barrier->trip_count) { barrier->count = 0; pthread_cond_broadcast(&barrier->cond); pthread_mutex_unlock(&barrier->mutex); return 1; } else { pthread_cond_wait(&barrier->cond, &(barrier->mutex)); pthread_mutex_unlock(&barrier->mutex); return 0; } } #endif #if defined(__cplusplus) && !defined(NAMESPACE) extern "C" { #endif #ifdef DEBUG_PRINTF #define LOG(...) fprintf(stderr, __VA_ARGS__) #else #define LOG(...) do {} while (0) #endif #ifndef __FreeBSD__ #define DETACH_KERNEL_DRIVER #endif /* Uncomment to enable the retrieval of Usage and Usage Page in hid_enumerate(). Warning, on platforms different from FreeBSD this is very invasive as it requires the detach and re-attach of the kernel driver. See comments inside hid_enumerate(). libusb HIDAPI programs are encouraged to use the interface number instead to differentiate between interfaces on a composite HID device. */ /*#define INVASIVE_GET_USAGE*/ /* Linked List of input reports received from the device. */ struct input_report { uint8_t *data; size_t len; struct input_report *next; }; struct hid_device_ { /* Handle to the actual device. */ libusb_device_handle *device_handle; /* Endpoint information */ int input_endpoint; int output_endpoint; int input_ep_max_packet_size; /* The interface number of the HID */ int interface; /* Indexes of Strings */ int manufacturer_index; int product_index; int serial_index; /* Whether blocking reads are used */ int blocking; /* boolean */ /* Read thread objects */ pthread_t thread; pthread_mutex_t mutex; /* Protects input_reports */ pthread_cond_t condition; pthread_barrier_t barrier; /* Ensures correct startup sequence */ int shutdown_thread; int cancelled; struct libusb_transfer *transfer; /* List of received input reports. */ struct input_report *input_reports; }; static libusb_context *usb_context = NULL; uint16_t get_usb_code_for_current_locale(void); static int return_data(hid_device *dev, unsigned char *data, size_t length); static hid_device *new_hid_device(void) { hid_device *dev = (hid_device *)calloc(1, sizeof(hid_device)); dev->blocking = 1; pthread_mutex_init(&dev->mutex, NULL); pthread_cond_init(&dev->condition, NULL); pthread_barrier_init(&dev->barrier, NULL, 2); return dev; } static void free_hid_device(hid_device *dev) { /* Clean up the thread objects */ pthread_barrier_destroy(&dev->barrier); pthread_cond_destroy(&dev->condition); pthread_mutex_destroy(&dev->mutex); /* Free the device itself */ free(dev); } #if 0 /*TODO: Implement this funciton on hidapi/libusb.. */ static void register_error(hid_device *device, const char *op) { } #endif #ifdef INVASIVE_GET_USAGE /* Get bytes from a HID Report Descriptor. Only call with a num_bytes of 0, 1, 2, or 4. */ static uint32_t get_bytes(uint8_t *rpt, size_t len, size_t num_bytes, size_t cur) { /* Return if there aren't enough bytes. */ if (cur + num_bytes >= len) return 0; if (num_bytes == 0) return 0; else if (num_bytes == 1) { return rpt[cur+1]; } else if (num_bytes == 2) { return (rpt[cur+2] * 256 + rpt[cur+1]); } else if (num_bytes == 4) { return (rpt[cur+4] * 0x01000000 + rpt[cur+3] * 0x00010000 + rpt[cur+2] * 0x00000100 + rpt[cur+1] * 0x00000001); } else return 0; } /* Retrieves the device's Usage Page and Usage from the report descriptor. The algorithm is simple, as it just returns the first Usage and Usage Page that it finds in the descriptor. The return value is 0 on success and -1 on failure. */ static int get_usage(uint8_t *report_descriptor, size_t size, unsigned short *usage_page, unsigned short *usage) { unsigned int i = 0; int size_code; int data_len, key_size; int usage_found = 0, usage_page_found = 0; while (i < size) { int key = report_descriptor[i]; int key_cmd = key & 0xfc; //printf("key: %02hhx\n", key); if ((key & 0xf0) == 0xf0) { /* This is a Long Item. The next byte contains the length of the data section (value) for this key. See the HID specification, version 1.11, section 6.2.2.3, titled "Long Items." */ if (i+1 < size) data_len = report_descriptor[i+1]; else data_len = 0; /* malformed report */ key_size = 3; } else { /* This is a Short Item. The bottom two bits of the key contain the size code for the data section (value) for this key. Refer to the HID specification, version 1.11, section 6.2.2.2, titled "Short Items." */ size_code = key & 0x3; switch (size_code) { case 0: case 1: case 2: data_len = size_code; break; case 3: data_len = 4; break; default: /* Can't ever happen since size_code is & 0x3 */ data_len = 0; break; }; key_size = 1; } if (key_cmd == 0x4) { *usage_page = get_bytes(report_descriptor, size, data_len, i); usage_page_found = 1; //printf("Usage Page: %x\n", (uint32_t)*usage_page); } if (key_cmd == 0x8) { *usage = get_bytes(report_descriptor, size, data_len, i); usage_found = 1; //printf("Usage: %x\n", (uint32_t)*usage); } if (usage_page_found && usage_found) return 0; /* success */ /* Skip over this key and it's associated data */ i += data_len + key_size; } return -1; /* failure */ } #endif /* INVASIVE_GET_USAGE */ #if defined(__FreeBSD__) && __FreeBSD__ < 10 /* The libusb version included in FreeBSD < 10 doesn't have this function. In mainline libusb, it's inlined in libusb.h. This function will bear a striking resemblance to that one, because there's about one way to code it. Note that the data parameter is Unicode in UTF-16LE encoding. Return value is the number of bytes in data, or LIBUSB_ERROR_*. */ static inline int libusb_get_string_descriptor(libusb_device_handle *dev, uint8_t descriptor_index, uint16_t lang_id, unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN | 0x0, /* Endpoint 0 IN */ LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | descriptor_index, lang_id, data, (uint16_t) length, 1000); } #endif /* Get the first language the device says it reports. This comes from USB string #0. */ static uint16_t get_first_language(libusb_device_handle *dev) { uint16_t buf[32]; int len; /* Get the string from libusb. */ len = libusb_get_string_descriptor(dev, 0x0, /* String ID */ 0x0, /* Language */ (unsigned char*)buf, sizeof(buf)); if (len < 4) return 0x0; return buf[1]; /* First two bytes are len and descriptor type. */ } static int is_language_supported(libusb_device_handle *dev, uint16_t lang) { uint16_t buf[32]; int len; int i; /* Get the string from libusb. */ len = libusb_get_string_descriptor(dev, 0x0, /* String ID */ 0x0, /* Language */ (unsigned char*)buf, sizeof(buf)); if (len < 4) return 0x0; len /= 2; /* language IDs are two-bytes each. */ /* Start at index 1 because there are two bytes of protocol data. */ for (i = 1; i < len; i++) { if (buf[i] == lang) return 1; } return 0; } /* This function returns a newly allocated wide string containing the USB device string numbered by the index. The returned string must be freed by using free(). */ static wchar_t *get_usb_string(libusb_device_handle *dev, uint8_t idx) { char buf[512]; int len; wchar_t *str = NULL; #ifndef __ANDROID__ /* we don't use iconv on Android */ wchar_t wbuf[256]; /* iconv variables */ iconv_t ic; size_t inbytes; size_t outbytes; size_t res; #ifdef __FreeBSD__ const char *inptr; #else char *inptr; #endif char *outptr; #endif /* Determine which language to use. */ uint16_t lang; lang = get_usb_code_for_current_locale(); if (!is_language_supported(dev, lang)) lang = get_first_language(dev); /* Get the string from libusb. */ len = libusb_get_string_descriptor(dev, idx, lang, (unsigned char*)buf, sizeof(buf)); if (len < 0) return NULL; #ifdef __ANDROID__ /* Bionic does not have iconv support nor wcsdup() function, so it has to be done manually. The following code will only work for code points that can be represented as a single UTF-16 character, and will incorrectly convert any code points which require more than one UTF-16 character. Skip over the first character (2-bytes). */ len -= 2; str = malloc((len / 2 + 1) * sizeof(wchar_t)); int i; for (i = 0; i < len / 2; i++) { str[i] = buf[i * 2 + 2] | (buf[i * 2 + 3] << 8); } str[len / 2] = 0x00000000; #else /* buf does not need to be explicitly NULL-terminated because it is only passed into iconv() which does not need it. */ /* Initialize iconv. */ ic = iconv_open("WCHAR_T", "UTF-16LE"); if (ic == (iconv_t)-1) { LOG("iconv_open() failed\n"); return NULL; } /* Convert to native wchar_t (UTF-32 on glibc/BSD systems). Skip the first character (2-bytes). */ inptr = buf+2; inbytes = len-2; outptr = (char*) wbuf; outbytes = sizeof(wbuf); res = iconv(ic, &inptr, &inbytes, &outptr, &outbytes); if (res == (size_t)-1) { LOG("iconv() failed\n"); goto err; } /* Write the terminating NULL. */ wbuf[sizeof(wbuf)/sizeof(wbuf[0])-1] = 0x00000000; if (outbytes >= sizeof(wbuf[0])) *((wchar_t*)outptr) = 0x00000000; /* Allocate and copy the string. */ str = wcsdup(wbuf); err: iconv_close(ic); #endif return str; } static char *make_path(libusb_device *dev, int interface_number) { char str[64]; snprintf(str, sizeof(str), "%04x:%04x:%02x", libusb_get_bus_number(dev), libusb_get_device_address(dev), interface_number); str[sizeof(str)-1] = '\0'; return strdup(str); } int HID_API_EXPORT hid_init(void) { if (!usb_context) { const char *locale; /* Init Libusb */ if (libusb_init(&usb_context)) return -1; /* Set the locale if it's not set. */ locale = setlocale(LC_CTYPE, NULL); if (!locale) setlocale(LC_CTYPE, ""); } return 0; } int HID_API_EXPORT hid_exit(void) { if (usb_context) { libusb_exit(usb_context); usb_context = NULL; } return 0; } static int is_xbox360(unsigned short vendor_id, const struct libusb_interface_descriptor *intf_desc) { static const int XB360_IFACE_SUBCLASS = 93; static const int XB360_IFACE_PROTOCOL = 1; /* Wired only */ static const int SUPPORTED_VENDORS[] = { 0x0079, /* GPD Win 2 */ 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x046d, /* Logitech */ 0x056e, /* Elecom */ 0x06a3, /* Saitek */ 0x0738, /* Mad Catz */ 0x07ff, /* Mad Catz */ 0x0e6f, /* Unknown */ 0x0f0d, /* Hori */ 0x11c9, /* Nacon */ 0x12ab, /* Unknown */ 0x1430, /* RedOctane */ 0x146b, /* BigBen */ 0x1532, /* Razer Sabertooth */ 0x15e4, /* Numark */ 0x162e, /* Joytech */ 0x1689, /* Razer Onza */ 0x1bad, /* Harmonix */ 0x24c6, /* PowerA */ }; if (intf_desc->bInterfaceNumber == 0 && intf_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC && intf_desc->bInterfaceSubClass == XB360_IFACE_SUBCLASS && intf_desc->bInterfaceProtocol == XB360_IFACE_PROTOCOL) { int i; for (i = 0; i < sizeof(SUPPORTED_VENDORS)/sizeof(SUPPORTED_VENDORS[0]); ++i) { if (vendor_id == SUPPORTED_VENDORS[i]) { return 1; } } } return 0; } static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_descriptor *intf_desc) { static const int XB1_IFACE_SUBCLASS = 71; static const int XB1_IFACE_PROTOCOL = 208; static const int SUPPORTED_VENDORS[] = { 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ 0x0e6f, /* Unknown */ 0x0f0d, /* Hori */ 0x1532, /* Razer Wildcat */ 0x24c6, /* PowerA */ }; if (intf_desc->bInterfaceNumber == 0 && intf_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC && intf_desc->bInterfaceSubClass == XB1_IFACE_SUBCLASS && intf_desc->bInterfaceProtocol == XB1_IFACE_PROTOCOL) { int i; for (i = 0; i < sizeof(SUPPORTED_VENDORS)/sizeof(SUPPORTED_VENDORS[0]); ++i) { if (vendor_id == SUPPORTED_VENDORS[i]) { return 1; } } } return 0; } static int should_enumerate_interface(unsigned short vendor_id, const struct libusb_interface_descriptor *intf_desc) { if (intf_desc->bInterfaceClass == LIBUSB_CLASS_HID) return 1; /* Also enumerate Xbox 360 controllers */ if (is_xbox360(vendor_id, intf_desc)) { /* hid_write() to Xbox 360 controllers doesn't seem to work on Linux: - xpad 1-2:1.0: xpad_try_sending_next_out_packet - usb_submit_urb failed with result -2 Xbox 360 controller support is good on Linux anyway, so we'll ignore this for now. return 1; */ } /* Also enumerate Xbox One controllers */ if (is_xboxone(vendor_id, intf_desc)) return 1; return 0; } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) { libusb_device **devs; libusb_device *dev; libusb_device_handle *handle; ssize_t num_devs; int i = 0; struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; if(hid_init() < 0) return NULL; num_devs = libusb_get_device_list(usb_context, &devs); if (num_devs < 0) return NULL; while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; struct libusb_config_descriptor *conf_desc = NULL; int j, k; int interface_num = 0; int res = libusb_get_device_descriptor(dev, &desc); unsigned short dev_vid = desc.idVendor; unsigned short dev_pid = desc.idProduct; res = libusb_get_active_config_descriptor(dev, &conf_desc); if (res < 0) libusb_get_config_descriptor(dev, 0, &conf_desc); if (conf_desc) { for (j = 0; j < conf_desc->bNumInterfaces; j++) { const struct libusb_interface *intf = &conf_desc->interface[j]; for (k = 0; k < intf->num_altsetting; k++) { const struct libusb_interface_descriptor *intf_desc; intf_desc = &intf->altsetting[k]; if (should_enumerate_interface(dev_vid, intf_desc)) { interface_num = intf_desc->bInterfaceNumber; /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 || vendor_id == dev_vid) && (product_id == 0x0 || product_id == dev_pid)) { struct hid_device_info *tmp; /* VID/PID match. Create the record. */ tmp = (struct hid_device_info *)calloc(1, sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; /* Fill out the record */ cur_dev->next = NULL; cur_dev->path = make_path(dev, interface_num); res = libusb_open(dev, &handle); if (res >= 0) { /* Serial Number */ if (desc.iSerialNumber > 0) cur_dev->serial_number = get_usb_string(handle, desc.iSerialNumber); /* Manufacturer and Product strings */ if (desc.iManufacturer > 0) cur_dev->manufacturer_string = get_usb_string(handle, desc.iManufacturer); if (desc.iProduct > 0) cur_dev->product_string = get_usb_string(handle, desc.iProduct); #ifdef INVASIVE_GET_USAGE { /* This section is removed because it is too invasive on the system. Getting a Usage Page and Usage requires parsing the HID Report descriptor. Getting a HID Report descriptor involves claiming the interface. Claiming the interface involves detaching the kernel driver. Detaching the kernel driver is hard on the system because it will unclaim interfaces (if another app has them claimed) and the re-attachment of the driver will sometimes change /dev entry names. It is for these reasons that this section is #if 0. For composite devices, use the interface field in the hid_device_info struct to distinguish between interfaces. */ unsigned char data[256]; #ifdef DETACH_KERNEL_DRIVER int detached = 0; /* Usage Page and Usage */ res = libusb_kernel_driver_active(handle, interface_num); if (res == 1) { res = libusb_detach_kernel_driver(handle, interface_num); if (res < 0) LOG("Couldn't detach kernel driver, even though a kernel driver was attached."); else detached = 1; } #endif res = libusb_claim_interface(handle, interface_num); if (res >= 0) { /* Get the HID Report Descriptor. */ res = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN|LIBUSB_RECIPIENT_INTERFACE, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_REPORT << 8)|interface_num, 0, data, sizeof(data), 5000); if (res >= 0) { unsigned short page=0, usage=0; /* Parse the usage and usage page out of the report descriptor. */ get_usage(data, res, &page, &usage); cur_dev->usage_page = page; cur_dev->usage = usage; } else LOG("libusb_control_transfer() for getting the HID report failed with %d\n", res); /* Release the interface */ res = libusb_release_interface(handle, interface_num); if (res < 0) LOG("Can't release the interface.\n"); } else LOG("Can't claim interface %d\n", res); #ifdef DETACH_KERNEL_DRIVER /* Re-attach kernel driver if necessary. */ if (detached) { res = libusb_attach_kernel_driver(handle, interface_num); if (res < 0) LOG("Couldn't re-attach kernel driver.\n"); } #endif } #endif /* INVASIVE_GET_USAGE */ libusb_close(handle); } /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Release Number */ cur_dev->release_number = desc.bcdDevice; /* Interface Number */ cur_dev->interface_number = interface_num; } } } /* altsettings */ } /* interfaces */ libusb_free_config_descriptor(conf_desc); } } libusb_free_device_list(devs, 1); return root; } void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) { struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device *handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (cur_dev->serial_number && wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open, 0); } hid_free_enumeration(devs); return handle; } static void read_callback(struct libusb_transfer *transfer) { hid_device *dev = (hid_device *)transfer->user_data; int res; if (transfer->status == LIBUSB_TRANSFER_COMPLETED) { struct input_report *rpt = (struct input_report *)malloc(sizeof(*rpt)); rpt->data = (uint8_t *)malloc(transfer->actual_length); memcpy(rpt->data, transfer->buffer, transfer->actual_length); rpt->len = transfer->actual_length; rpt->next = NULL; pthread_mutex_lock(&dev->mutex); /* Attach the new report object to the end of the list. */ if (dev->input_reports == NULL) { /* The list is empty. Put it at the root. */ dev->input_reports = rpt; pthread_cond_signal(&dev->condition); } else { /* Find the end of the list and attach. */ struct input_report *cur = dev->input_reports; int num_queued = 0; while (cur->next != NULL) { cur = cur->next; num_queued++; } cur->next = rpt; /* Pop one off if we've reached 30 in the queue. This way we don't grow forever if the user never reads anything from the device. */ if (num_queued > 30) { return_data(dev, NULL, 0); } } pthread_mutex_unlock(&dev->mutex); } else if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { dev->shutdown_thread = 1; dev->cancelled = 1; return; } else if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { dev->shutdown_thread = 1; dev->cancelled = 1; return; } else if (transfer->status == LIBUSB_TRANSFER_TIMED_OUT) { //LOG("Timeout (normal)\n"); } else { LOG("Unknown transfer code: %d\n", transfer->status); } /* Re-submit the transfer object. */ res = libusb_submit_transfer(transfer); if (res != 0) { LOG("Unable to submit URB. libusb error code: %d\n", res); dev->shutdown_thread = 1; dev->cancelled = 1; } } static void *read_thread(void *param) { hid_device *dev = (hid_device *)param; unsigned char *buf; const size_t length = dev->input_ep_max_packet_size; /* Set up the transfer object. */ buf = (unsigned char *)malloc(length); dev->transfer = libusb_alloc_transfer(0); libusb_fill_interrupt_transfer(dev->transfer, dev->device_handle, dev->input_endpoint, buf, length, read_callback, dev, 5000/*timeout*/); /* Make the first submission. Further submissions are made from inside read_callback() */ libusb_submit_transfer(dev->transfer); /* Notify the main thread that the read thread is up and running. */ pthread_barrier_wait(&dev->barrier); /* Handle all the events. */ while (!dev->shutdown_thread) { int res; res = libusb_handle_events(usb_context); if (res < 0) { /* There was an error. */ LOG("read_thread(): libusb reports error # %d\n", res); /* Break out of this loop only on fatal error.*/ if (res != LIBUSB_ERROR_BUSY && res != LIBUSB_ERROR_TIMEOUT && res != LIBUSB_ERROR_OVERFLOW && res != LIBUSB_ERROR_INTERRUPTED) { break; } } } /* Cancel any transfer that may be pending. This call will fail if no transfers are pending, but that's OK. */ libusb_cancel_transfer(dev->transfer); while (!dev->cancelled) libusb_handle_events_completed(usb_context, &dev->cancelled); /* Now that the read thread is stopping, Wake any threads which are waiting on data (in hid_read_timeout()). Do this under a mutex to make sure that a thread which is about to go to sleep waiting on the condition actually will go to sleep before the condition is signaled. */ pthread_mutex_lock(&dev->mutex); pthread_cond_broadcast(&dev->condition); pthread_mutex_unlock(&dev->mutex); /* The dev->transfer->buffer and dev->transfer objects are cleaned up in hid_close(). They are not cleaned up here because this thread could end either due to a disconnect or due to a user call to hid_close(). In both cases the objects can be safely cleaned up after the call to pthread_join() (in hid_close()), but since hid_close() calls libusb_cancel_transfer(), on these objects, they can not be cleaned up here. */ return NULL; } hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive) { hid_device *dev = NULL; libusb_device **devs; libusb_device *usb_dev; int res; int d = 0; int good_open = 0; if(hid_init() < 0) return NULL; dev = new_hid_device(); libusb_get_device_list(usb_context, &devs); while ((usb_dev = devs[d++]) != NULL) { struct libusb_device_descriptor desc; struct libusb_config_descriptor *conf_desc = NULL; int i,j,k; libusb_get_device_descriptor(usb_dev, &desc); if (libusb_get_active_config_descriptor(usb_dev, &conf_desc) < 0) continue; for (j = 0; j < conf_desc->bNumInterfaces; j++) { const struct libusb_interface *intf = &conf_desc->interface[j]; for (k = 0; k < intf->num_altsetting; k++) { const struct libusb_interface_descriptor *intf_desc; intf_desc = &intf->altsetting[k]; if (should_enumerate_interface(desc.idVendor, intf_desc)) { char *dev_path = make_path(usb_dev, intf_desc->bInterfaceNumber); if (!strcmp(dev_path, path)) { /* Matched Paths. Open this device */ /* OPEN HERE */ res = libusb_open(usb_dev, &dev->device_handle); if (res < 0) { LOG("can't open device\n"); free(dev_path); break; } good_open = 1; #ifdef DETACH_KERNEL_DRIVER /* Detach the kernel driver, but only if the device is managed by the kernel */ if (libusb_kernel_driver_active(dev->device_handle, intf_desc->bInterfaceNumber) == 1) { res = libusb_detach_kernel_driver(dev->device_handle, intf_desc->bInterfaceNumber); if (res < 0) { libusb_close(dev->device_handle); LOG("Unable to detach Kernel Driver\n"); free(dev_path); good_open = 0; break; } } #endif res = libusb_claim_interface(dev->device_handle, intf_desc->bInterfaceNumber); if (res < 0) { LOG("can't claim interface %d: %d\n", intf_desc->bInterfaceNumber, res); free(dev_path); libusb_close(dev->device_handle); good_open = 0; break; } /* Store off the string descriptor indexes */ dev->manufacturer_index = desc.iManufacturer; dev->product_index = desc.iProduct; dev->serial_index = desc.iSerialNumber; /* Store off the interface number */ dev->interface = intf_desc->bInterfaceNumber; /* Find the INPUT and OUTPUT endpoints. An OUTPUT endpoint is not required. */ for (i = 0; i < intf_desc->bNumEndpoints; i++) { const struct libusb_endpoint_descriptor *ep = &intf_desc->endpoint[i]; /* Determine the type and direction of this endpoint. */ int is_interrupt = (ep->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_INTERRUPT; int is_output = (ep->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT; int is_input = (ep->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN; /* Decide whether to use it for input or output. */ if (dev->input_endpoint == 0 && is_interrupt && is_input) { /* Use this endpoint for INPUT */ dev->input_endpoint = ep->bEndpointAddress; dev->input_ep_max_packet_size = ep->wMaxPacketSize; } if (dev->output_endpoint == 0 && is_interrupt && is_output) { /* Use this endpoint for OUTPUT */ dev->output_endpoint = ep->bEndpointAddress; } } pthread_create(&dev->thread, NULL, read_thread, dev); /* Wait here for the read thread to be initialized. */ pthread_barrier_wait(&dev->barrier); } free(dev_path); } } } libusb_free_config_descriptor(conf_desc); } libusb_free_device_list(devs, 1); /* If we have a good handle, return it. */ if (good_open) { return dev; } else { /* Unable to open any devices. */ free_hid_device(dev); return NULL; } } int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) { int res; int report_number = data[0]; int skipped_report_id = 0; if (report_number == 0x0) { data++; length--; skipped_report_id = 1; } if (dev->output_endpoint <= 0) { /* No interrupt out endpoint. Use the Control Endpoint */ res = libusb_control_transfer(dev->device_handle, LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_OUT, 0x09/*HID Set_Report*/, (2/*HID output*/ << 8) | report_number, dev->interface, (unsigned char *)data, length, 1000/*timeout millis*/); if (res < 0) return -1; if (skipped_report_id) length++; return length; } else { /* Use the interrupt out endpoint */ int actual_length; res = libusb_interrupt_transfer(dev->device_handle, dev->output_endpoint, (unsigned char*)data, length, &actual_length, 1000); if (res < 0) return -1; if (skipped_report_id) actual_length++; return actual_length; } } /* Helper function, to simplify hid_read(). This should be called with dev->mutex locked. */ static int return_data(hid_device *dev, unsigned char *data, size_t length) { /* Copy the data out of the linked list item (rpt) into the return buffer (data), and delete the liked list item. */ struct input_report *rpt = dev->input_reports; size_t len = (length < rpt->len)? length: rpt->len; if (data && len > 0) memcpy(data, rpt->data, len); dev->input_reports = rpt->next; free(rpt->data); free(rpt); return len; } static void cleanup_mutex(void *param) { hid_device *dev = (hid_device *)param; pthread_mutex_unlock(&dev->mutex); } int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { int bytes_read = -1; #if 0 int transferred; int res = libusb_interrupt_transfer(dev->device_handle, dev->input_endpoint, data, length, &transferred, 5000); LOG("transferred: %d\n", transferred); return transferred; #endif pthread_mutex_lock(&dev->mutex); pthread_cleanup_push(&cleanup_mutex, dev); /* There's an input report queued up. Return it. */ if (dev->input_reports) { /* Return the first one */ bytes_read = return_data(dev, data, length); goto ret; } if (dev->shutdown_thread) { /* This means the device has been disconnected. An error code of -1 should be returned. */ bytes_read = -1; goto ret; } if (milliseconds == -1) { /* Blocking */ while (!dev->input_reports && !dev->shutdown_thread) { pthread_cond_wait(&dev->condition, &dev->mutex); } if (dev->input_reports) { bytes_read = return_data(dev, data, length); } } else if (milliseconds > 0) { /* Non-blocking, but called with timeout. */ int res; struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); ts.tv_sec += milliseconds / 1000; ts.tv_nsec += (milliseconds % 1000) * 1000000; if (ts.tv_nsec >= 1000000000L) { ts.tv_sec++; ts.tv_nsec -= 1000000000L; } while (!dev->input_reports && !dev->shutdown_thread) { res = pthread_cond_timedwait(&dev->condition, &dev->mutex, &ts); if (res == 0) { if (dev->input_reports) { bytes_read = return_data(dev, data, length); break; } /* If we're here, there was a spurious wake up or the read thread was shutdown. Run the loop again (ie: don't break). */ } else if (res == ETIMEDOUT) { /* Timed out. */ bytes_read = 0; break; } else { /* Error. */ bytes_read = -1; break; } } } else { /* Purely non-blocking */ bytes_read = 0; } ret: pthread_mutex_unlock(&dev->mutex); pthread_cleanup_pop(0); return bytes_read; } int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, dev->blocking ? -1 : 0); } int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { dev->blocking = !nonblock; return 0; } int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { int res = -1; int skipped_report_id = 0; int report_number = data[0]; if (report_number == 0x0) { data++; length--; skipped_report_id = 1; } res = libusb_control_transfer(dev->device_handle, LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_OUT, 0x09/*HID set_report*/, (3/*HID feature*/ << 8) | report_number, dev->interface, (unsigned char *)data, length, 1000/*timeout millis*/); if (res < 0) return -1; /* Account for the report ID */ if (skipped_report_id) length++; return length; } int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { int res = -1; int skipped_report_id = 0; int report_number = data[0]; if (report_number == 0x0) { /* Offset the return buffer by 1, so that the report ID will remain in byte 0. */ data++; length--; skipped_report_id = 1; } res = libusb_control_transfer(dev->device_handle, LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE|LIBUSB_ENDPOINT_IN, 0x01/*HID get_report*/, (3/*HID feature*/ << 8) | report_number, dev->interface, (unsigned char *)data, length, 1000/*timeout millis*/); if (res < 0) return -1; if (skipped_report_id) res++; return res; } void HID_API_EXPORT hid_close(hid_device *dev) { if (!dev) return; /* Cause read_thread() to stop. */ dev->shutdown_thread = 1; libusb_cancel_transfer(dev->transfer); /* Wait for read_thread() to end. */ pthread_join(dev->thread, NULL); /* Clean up the Transfer objects allocated in read_thread(). */ free(dev->transfer->buffer); libusb_free_transfer(dev->transfer); /* release the interface */ libusb_release_interface(dev->device_handle, dev->interface); /* Close the handle */ libusb_close(dev->device_handle); /* Clear out the queue of received reports. */ pthread_mutex_lock(&dev->mutex); while (dev->input_reports) { return_data(dev, NULL, 0); } pthread_mutex_unlock(&dev->mutex); free_hid_device(dev); } int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { return hid_get_indexed_string(dev, dev->manufacturer_index, string, maxlen); } int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { return hid_get_indexed_string(dev, dev->product_index, string, maxlen); } int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { return hid_get_indexed_string(dev, dev->serial_index, string, maxlen); } int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { wchar_t *str; str = get_usb_string(dev->device_handle, string_index); if (str) { wcsncpy(string, str, maxlen); string[maxlen-1] = L'\0'; free(str); return 0; } else return -1; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { return NULL; } struct lang_map_entry { const char *name; const char *string_code; uint16_t usb_code; }; #define LANG(name,code,usb_code) { name, code, usb_code } static struct lang_map_entry lang_map[] = { LANG("Afrikaans", "af", 0x0436), LANG("Albanian", "sq", 0x041C), LANG("Arabic - United Arab Emirates", "ar_ae", 0x3801), LANG("Arabic - Bahrain", "ar_bh", 0x3C01), LANG("Arabic - Algeria", "ar_dz", 0x1401), LANG("Arabic - Egypt", "ar_eg", 0x0C01), LANG("Arabic - Iraq", "ar_iq", 0x0801), LANG("Arabic - Jordan", "ar_jo", 0x2C01), LANG("Arabic - Kuwait", "ar_kw", 0x3401), LANG("Arabic - Lebanon", "ar_lb", 0x3001), LANG("Arabic - Libya", "ar_ly", 0x1001), LANG("Arabic - Morocco", "ar_ma", 0x1801), LANG("Arabic - Oman", "ar_om", 0x2001), LANG("Arabic - Qatar", "ar_qa", 0x4001), LANG("Arabic - Saudi Arabia", "ar_sa", 0x0401), LANG("Arabic - Syria", "ar_sy", 0x2801), LANG("Arabic - Tunisia", "ar_tn", 0x1C01), LANG("Arabic - Yemen", "ar_ye", 0x2401), LANG("Armenian", "hy", 0x042B), LANG("Azeri - Latin", "az_az", 0x042C), LANG("Azeri - Cyrillic", "az_az", 0x082C), LANG("Basque", "eu", 0x042D), LANG("Belarusian", "be", 0x0423), LANG("Bulgarian", "bg", 0x0402), LANG("Catalan", "ca", 0x0403), LANG("Chinese - China", "zh_cn", 0x0804), LANG("Chinese - Hong Kong SAR", "zh_hk", 0x0C04), LANG("Chinese - Macau SAR", "zh_mo", 0x1404), LANG("Chinese - Singapore", "zh_sg", 0x1004), LANG("Chinese - Taiwan", "zh_tw", 0x0404), LANG("Croatian", "hr", 0x041A), LANG("Czech", "cs", 0x0405), LANG("Danish", "da", 0x0406), LANG("Dutch - Netherlands", "nl_nl", 0x0413), LANG("Dutch - Belgium", "nl_be", 0x0813), LANG("English - Australia", "en_au", 0x0C09), LANG("English - Belize", "en_bz", 0x2809), LANG("English - Canada", "en_ca", 0x1009), LANG("English - Caribbean", "en_cb", 0x2409), LANG("English - Ireland", "en_ie", 0x1809), LANG("English - Jamaica", "en_jm", 0x2009), LANG("English - New Zealand", "en_nz", 0x1409), LANG("English - Phillippines", "en_ph", 0x3409), LANG("English - Southern Africa", "en_za", 0x1C09), LANG("English - Trinidad", "en_tt", 0x2C09), LANG("English - Great Britain", "en_gb", 0x0809), LANG("English - United States", "en_us", 0x0409), LANG("Estonian", "et", 0x0425), LANG("Farsi", "fa", 0x0429), LANG("Finnish", "fi", 0x040B), LANG("Faroese", "fo", 0x0438), LANG("French - France", "fr_fr", 0x040C), LANG("French - Belgium", "fr_be", 0x080C), LANG("French - Canada", "fr_ca", 0x0C0C), LANG("French - Luxembourg", "fr_lu", 0x140C), LANG("French - Switzerland", "fr_ch", 0x100C), LANG("Gaelic - Ireland", "gd_ie", 0x083C), LANG("Gaelic - Scotland", "gd", 0x043C), LANG("German - Germany", "de_de", 0x0407), LANG("German - Austria", "de_at", 0x0C07), LANG("German - Liechtenstein", "de_li", 0x1407), LANG("German - Luxembourg", "de_lu", 0x1007), LANG("German - Switzerland", "de_ch", 0x0807), LANG("Greek", "el", 0x0408), LANG("Hebrew", "he", 0x040D), LANG("Hindi", "hi", 0x0439), LANG("Hungarian", "hu", 0x040E), LANG("Icelandic", "is", 0x040F), LANG("Indonesian", "id", 0x0421), LANG("Italian - Italy", "it_it", 0x0410), LANG("Italian - Switzerland", "it_ch", 0x0810), LANG("Japanese", "ja", 0x0411), LANG("Korean", "ko", 0x0412), LANG("Latvian", "lv", 0x0426), LANG("Lithuanian", "lt", 0x0427), LANG("F.Y.R.O. Macedonia", "mk", 0x042F), LANG("Malay - Malaysia", "ms_my", 0x043E), LANG("Malay – Brunei", "ms_bn", 0x083E), LANG("Maltese", "mt", 0x043A), LANG("Marathi", "mr", 0x044E), LANG("Norwegian - Bokml", "no_no", 0x0414), LANG("Norwegian - Nynorsk", "no_no", 0x0814), LANG("Polish", "pl", 0x0415), LANG("Portuguese - Portugal", "pt_pt", 0x0816), LANG("Portuguese - Brazil", "pt_br", 0x0416), LANG("Raeto-Romance", "rm", 0x0417), LANG("Romanian - Romania", "ro", 0x0418), LANG("Romanian - Republic of Moldova", "ro_mo", 0x0818), LANG("Russian", "ru", 0x0419), LANG("Russian - Republic of Moldova", "ru_mo", 0x0819), LANG("Sanskrit", "sa", 0x044F), LANG("Serbian - Cyrillic", "sr_sp", 0x0C1A), LANG("Serbian - Latin", "sr_sp", 0x081A), LANG("Setsuana", "tn", 0x0432), LANG("Slovenian", "sl", 0x0424), LANG("Slovak", "sk", 0x041B), LANG("Sorbian", "sb", 0x042E), LANG("Spanish - Spain (Traditional)", "es_es", 0x040A), LANG("Spanish - Argentina", "es_ar", 0x2C0A), LANG("Spanish - Bolivia", "es_bo", 0x400A), LANG("Spanish - Chile", "es_cl", 0x340A), LANG("Spanish - Colombia", "es_co", 0x240A), LANG("Spanish - Costa Rica", "es_cr", 0x140A), LANG("Spanish - Dominican Republic", "es_do", 0x1C0A), LANG("Spanish - Ecuador", "es_ec", 0x300A), LANG("Spanish - Guatemala", "es_gt", 0x100A), LANG("Spanish - Honduras", "es_hn", 0x480A), LANG("Spanish - Mexico", "es_mx", 0x080A), LANG("Spanish - Nicaragua", "es_ni", 0x4C0A), LANG("Spanish - Panama", "es_pa", 0x180A), LANG("Spanish - Peru", "es_pe", 0x280A), LANG("Spanish - Puerto Rico", "es_pr", 0x500A), LANG("Spanish - Paraguay", "es_py", 0x3C0A), LANG("Spanish - El Salvador", "es_sv", 0x440A), LANG("Spanish - Uruguay", "es_uy", 0x380A), LANG("Spanish - Venezuela", "es_ve", 0x200A), LANG("Southern Sotho", "st", 0x0430), LANG("Swahili", "sw", 0x0441), LANG("Swedish - Sweden", "sv_se", 0x041D), LANG("Swedish - Finland", "sv_fi", 0x081D), LANG("Tamil", "ta", 0x0449), LANG("Tatar", "tt", 0X0444), LANG("Thai", "th", 0x041E), LANG("Turkish", "tr", 0x041F), LANG("Tsonga", "ts", 0x0431), LANG("Ukrainian", "uk", 0x0422), LANG("Urdu", "ur", 0x0420), LANG("Uzbek - Cyrillic", "uz_uz", 0x0843), LANG("Uzbek – Latin", "uz_uz", 0x0443), LANG("Vietnamese", "vi", 0x042A), LANG("Xhosa", "xh", 0x0434), LANG("Yiddish", "yi", 0x043D), LANG("Zulu", "zu", 0x0435), LANG(NULL, NULL, 0x0), }; uint16_t get_usb_code_for_current_locale(void) { char *locale; char search_string[64]; char *ptr; struct lang_map_entry *lang; /* Get the current locale. */ locale = setlocale(0, NULL); if (!locale) return 0x0; /* Make a copy of the current locale string. */ strncpy(search_string, locale, sizeof(search_string)); search_string[sizeof(search_string)-1] = '\0'; /* Chop off the encoding part, and make it lower case. */ ptr = search_string; while (*ptr) { *ptr = tolower(*ptr); if (*ptr == '.') { *ptr = '\0'; break; } ptr++; } /* Find the entry which matches the string code of our locale. */ lang = lang_map; while (lang->string_code) { if (!strcmp(lang->string_code, search_string)) { return lang->usb_code; } lang++; } /* There was no match. Find with just the language only. */ /* Chop off the variant. Chop it off at the '_'. */ ptr = search_string; while (*ptr) { *ptr = tolower(*ptr); if (*ptr == '_') { *ptr = '\0'; break; } ptr++; } #if 0 /* TODO: Do we need this? */ /* Find the entry which matches the string code of our language. */ lang = lang_map; while (lang->string_code) { if (!strcmp(lang->string_code, search_string)) { return lang->usb_code; } lang++; } #endif /* Found nothing. */ return 0x0; } #if defined(__cplusplus) && !defined(NAMESPACE) } #endif #ifdef NAMESPACE } #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\linux\hid.c
/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Linux Version - 6/2/2009 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ #ifndef _GNU_SOURCE #define _GNU_SOURCE /* needed for wcsdup() before glibc 2.10 */ #endif /* C */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <locale.h> #include <errno.h> /* Unix */ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/utsname.h> #include <fcntl.h> #include <poll.h> /* Linux */ #include <linux/hidraw.h> #include <linux/version.h> #include <linux/input.h> #include <libudev.h> #include "hidapi.h" #ifdef NAMESPACE namespace NAMESPACE { #endif /* Definitions from linux/hidraw.h. Since these are new, some distros may not have header files which contain them. */ #ifndef HIDIOCSFEATURE #define HIDIOCSFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x06, len) #endif #ifndef HIDIOCGFEATURE #define HIDIOCGFEATURE(len) _IOC(_IOC_WRITE|_IOC_READ, 'H', 0x07, len) #endif /* USB HID device property names */ const char *device_string_names[] = { "manufacturer", "product", "serial", }; /* Symbolic names for the properties above */ enum device_string_id { DEVICE_STRING_MANUFACTURER, DEVICE_STRING_PRODUCT, DEVICE_STRING_SERIAL, DEVICE_STRING_COUNT, }; struct hid_device_ { int device_handle; int blocking; int uses_numbered_reports; int is_bluetooth; }; static __u32 kernel_version = 0; static __u32 detect_kernel_version(void) { struct utsname name; int major, minor, release; int ret; uname(&name); ret = sscanf(name.release, "%d.%d.%d", &major, &minor, &release); if (ret == 3) { return KERNEL_VERSION(major, minor, release); } ret = sscanf(name.release, "%d.%d", &major, &minor); if (ret == 2) { return KERNEL_VERSION(major, minor, 0); } printf("Couldn't determine kernel version from version string \"%s\"\n", name.release); return 0; } static hid_device *new_hid_device(void) { hid_device *dev = (hid_device *)calloc(1, sizeof(hid_device)); dev->device_handle = -1; dev->blocking = 1; dev->uses_numbered_reports = 0; dev->is_bluetooth = 0; return dev; } /* The caller must free the returned string with free(). */ static wchar_t *utf8_to_wchar_t(const char *utf8) { wchar_t *ret = NULL; if (utf8) { size_t wlen = mbstowcs(NULL, utf8, 0); if ((size_t) -1 == wlen) { return wcsdup(L""); } ret = (wchar_t *)calloc(wlen+1, sizeof(wchar_t)); mbstowcs(ret, utf8, wlen+1); ret[wlen] = 0x0000; } return ret; } /* Get an attribute value from a udev_device and return it as a whar_t string. The returned string must be freed with free() when done.*/ static wchar_t *copy_udev_string(struct udev_device *dev, const char *udev_name) { return utf8_to_wchar_t(udev_device_get_sysattr_value(dev, udev_name)); } /* uses_numbered_reports() returns 1 if report_descriptor describes a device which contains numbered reports. */ static int uses_numbered_reports(__u8 *report_descriptor, __u32 size) { unsigned int i = 0; int size_code; int data_len, key_size; while (i < size) { int key = report_descriptor[i]; /* Check for the Report ID key */ if (key == 0x85/*Report ID*/) { /* This device has a Report ID, which means it uses numbered reports. */ return 1; } //printf("key: %02hhx\n", key); if ((key & 0xf0) == 0xf0) { /* This is a Long Item. The next byte contains the length of the data section (value) for this key. See the HID specification, version 1.11, section 6.2.2.3, titled "Long Items." */ if (i+1 < size) data_len = report_descriptor[i+1]; else data_len = 0; /* malformed report */ key_size = 3; } else { /* This is a Short Item. The bottom two bits of the key contain the size code for the data section (value) for this key. Refer to the HID specification, version 1.11, section 6.2.2.2, titled "Short Items." */ size_code = key & 0x3; switch (size_code) { case 0: case 1: case 2: data_len = size_code; break; case 3: data_len = 4; break; default: /* Can't ever happen since size_code is & 0x3 */ data_len = 0; break; }; key_size = 1; } /* Skip over this key and it's associated data */ i += data_len + key_size; } /* Didn't find a Report ID key. Device doesn't use numbered reports. */ return 0; } /* * The caller is responsible for free()ing the (newly-allocated) character * strings pointed to by serial_number_utf8 and product_name_utf8 after use. */ static int parse_uevent_info(const char *uevent, int *bus_type, unsigned short *vendor_id, unsigned short *product_id, char **serial_number_utf8, char **product_name_utf8) { char *tmp = strdup(uevent); char *saveptr = NULL; char *line; char *key; char *value; int found_id = 0; int found_serial = 0; int found_name = 0; line = strtok_r(tmp, "\n", &saveptr); while (line != NULL) { /* line: "KEY=value" */ key = line; value = strchr(line, '='); if (!value) { goto next_line; } *value = '\0'; value++; if (strcmp(key, "HID_ID") == 0) { /** * type vendor product * HID_ID=0003:000005AC:00008242 **/ int ret = sscanf(value, "%x:%hx:%hx", bus_type, vendor_id, product_id); if (ret == 3) { found_id = 1; } } else if (strcmp(key, "HID_NAME") == 0) { /* The caller has to free the product name */ *product_name_utf8 = strdup(value); found_name = 1; } else if (strcmp(key, "HID_UNIQ") == 0) { /* The caller has to free the serial number */ *serial_number_utf8 = strdup(value); found_serial = 1; } next_line: line = strtok_r(NULL, "\n", &saveptr); } free(tmp); return (found_id && found_name && found_serial); } static int is_bluetooth(hid_device *dev) { struct udev *udev; struct udev_device *udev_dev, *hid_dev; struct stat s; int ret = -1; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); return -1; } /* Get the dev_t (major/minor numbers) from the file handle. */ ret = fstat(dev->device_handle, &s); if (-1 == ret) { udev_unref(udev); return ret; } /* Open a udev device from the dev_t. 'c' means character device. */ udev_dev = udev_device_new_from_devnum(udev, 'c', s.st_rdev); if (udev_dev) { hid_dev = udev_device_get_parent_with_subsystem_devtype( udev_dev, "hid", NULL); if (hid_dev) { unsigned short dev_vid; unsigned short dev_pid; int bus_type; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; ret = parse_uevent_info( udev_device_get_sysattr_value(hid_dev, "uevent"), &bus_type, &dev_vid, &dev_pid, &serial_number_utf8, &product_name_utf8); free(serial_number_utf8); free(product_name_utf8); ret = (bus_type == BUS_BLUETOOTH); /* hid_dev doesn't need to be (and can't be) unref'd. I'm not sure why, but it'll throw double-free() errors. */ } udev_device_unref(udev_dev); } udev_unref(udev); return ret; } static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t *string, size_t maxlen) { struct udev *udev; struct udev_device *udev_dev, *parent, *hid_dev; struct stat s; int ret = -1; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; char *tmp; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); return -1; } /* Get the dev_t (major/minor numbers) from the file handle. */ ret = fstat(dev->device_handle, &s); if (-1 == ret) { udev_unref(udev); return ret; } /* Open a udev device from the dev_t. 'c' means character device. */ udev_dev = udev_device_new_from_devnum(udev, 'c', s.st_rdev); if (udev_dev) { hid_dev = udev_device_get_parent_with_subsystem_devtype( udev_dev, "hid", NULL); if (hid_dev) { unsigned short dev_vid; unsigned short dev_pid; int bus_type; size_t retm; ret = parse_uevent_info( udev_device_get_sysattr_value(hid_dev, "uevent"), &bus_type, &dev_vid, &dev_pid, &serial_number_utf8, &product_name_utf8); if (bus_type == BUS_BLUETOOTH) { switch (key) { case DEVICE_STRING_MANUFACTURER: wcsncpy(string, L"", maxlen); ret = 0; break; case DEVICE_STRING_PRODUCT: retm = mbstowcs(string, product_name_utf8, maxlen); ret = (retm == (size_t)-1)? -1: 0; break; case DEVICE_STRING_SERIAL: /* Bluetooth serial numbers are often the bluetooth device address and we want that with the colons stripped out, which is the correct serial number for PS4 controllers */ while ((tmp = strchr(serial_number_utf8, ':')) != NULL) { memmove(tmp, tmp+1, strlen(tmp)); } retm = mbstowcs(string, serial_number_utf8, maxlen); ret = (retm == (size_t)-1)? -1: 0; break; case DEVICE_STRING_COUNT: default: ret = -1; break; } } else { /* This is a USB device. Find its parent USB Device node. */ parent = udev_device_get_parent_with_subsystem_devtype( udev_dev, "usb", "usb_device"); if (parent) { const char *str; const char *key_str = NULL; if (key >= 0 && key < DEVICE_STRING_COUNT) { key_str = device_string_names[key]; } else { ret = -1; goto end; } str = udev_device_get_sysattr_value(parent, key_str); if (str) { /* Convert the string from UTF-8 to wchar_t */ retm = mbstowcs(string, str, maxlen); ret = (retm == (size_t)-1)? -1: 0; goto end; } } } } } end: free(serial_number_utf8); free(product_name_utf8); udev_device_unref(udev_dev); /* parent and hid_dev don't need to be (and can't be) unref'd. I'm not sure why, but they'll throw double-free() errors. */ udev_unref(udev); return ret; } int HID_API_EXPORT hid_init(void) { const char *locale; /* Set the locale if it's not set. */ locale = setlocale(LC_CTYPE, NULL); if (!locale) setlocale(LC_CTYPE, ""); kernel_version = detect_kernel_version(); return 0; } int HID_API_EXPORT hid_exit(void) { /* Nothing to do for this in the Linux/hidraw implementation. */ return 0; } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; struct hid_device_info *prev_dev = NULL; /* previous device */ hid_init(); /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); return NULL; } /* Create a list of the devices in the 'hidraw' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item, see if it matches the vid/pid, and if so create a udev_device record for it */ udev_list_entry_foreach(dev_list_entry, devices) { const char *sysfs_path; const char *dev_path; const char *str; struct udev_device *raw_dev; /* The device's hidraw udev node. */ struct udev_device *hid_dev; /* The device's HID udev node. */ struct udev_device *usb_dev; /* The device's USB udev node. */ struct udev_device *intf_dev; /* The device's interface (in the USB sense). */ unsigned short dev_vid; unsigned short dev_pid; char *serial_number_utf8 = NULL; char *product_name_utf8 = NULL; int bus_type; int result; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ sysfs_path = udev_list_entry_get_name(dev_list_entry); raw_dev = udev_device_new_from_syspath(udev, sysfs_path); dev_path = udev_device_get_devnode(raw_dev); hid_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "hid", NULL); if (!hid_dev) { /* Unable to find parent hid device. */ goto next; } result = parse_uevent_info( udev_device_get_sysattr_value(hid_dev, "uevent"), &bus_type, &dev_vid, &dev_pid, &serial_number_utf8, &product_name_utf8); if (!result) { /* parse_uevent_info() failed for at least one field. */ goto next; } if (bus_type != BUS_USB && bus_type != BUS_BLUETOOTH) { /* We only know how to handle USB and BT devices. */ goto next; } if (access(dev_path, R_OK|W_OK) != 0) { /* We can't open this device, ignore it */ goto next; } /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 || vendor_id == dev_vid) && (product_id == 0x0 || product_id == dev_pid)) { struct hid_device_info *tmp; /* VID/PID match. Create the record. */ tmp = (struct hid_device_info *)malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } prev_dev = cur_dev; cur_dev = tmp; /* Fill out the record */ cur_dev->next = NULL; cur_dev->path = dev_path? strdup(dev_path): NULL; /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Serial Number */ cur_dev->serial_number = utf8_to_wchar_t(serial_number_utf8); /* Release Number */ cur_dev->release_number = 0x0; /* Interface Number */ cur_dev->interface_number = -1; switch (bus_type) { case BUS_USB: /* The device pointed to by raw_dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it. */ usb_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "usb", "usb_device"); if (!usb_dev) { /* Free this device */ free(cur_dev->serial_number); free(cur_dev->path); free(cur_dev); /* Take it off the device list. */ if (prev_dev) { prev_dev->next = NULL; cur_dev = prev_dev; } else { cur_dev = root = NULL; } goto next; } /* Manufacturer and Product strings */ cur_dev->manufacturer_string = copy_udev_string(usb_dev, device_string_names[DEVICE_STRING_MANUFACTURER]); cur_dev->product_string = copy_udev_string(usb_dev, device_string_names[DEVICE_STRING_PRODUCT]); /* Release Number */ str = udev_device_get_sysattr_value(usb_dev, "bcdDevice"); cur_dev->release_number = (str)? strtol(str, NULL, 16): 0x0; /* Get a handle to the interface's udev node. */ intf_dev = udev_device_get_parent_with_subsystem_devtype( raw_dev, "usb", "usb_interface"); if (intf_dev) { str = udev_device_get_sysattr_value(intf_dev, "bInterfaceNumber"); cur_dev->interface_number = (str)? strtol(str, NULL, 16): -1; } break; case BUS_BLUETOOTH: /* Manufacturer and Product strings */ cur_dev->manufacturer_string = wcsdup(L""); cur_dev->product_string = utf8_to_wchar_t(product_name_utf8); break; default: /* Unknown device type - this should never happen, as we * check for USB and Bluetooth devices above */ break; } } next: free(serial_number_utf8); free(product_name_utf8); udev_device_unref(raw_dev); /* hid_dev, usb_dev and intf_dev don't need to be (and can't be) unref()d. It will cause a double-free() error. I'm not sure why. */ } /* Free the enumerator and udev objects. */ udev_enumerate_unref(enumerate); udev_unref(udev); return root; } void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) { struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device *handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open, 0); } hid_free_enumeration(devs); return handle; } hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive) { hid_device *dev = NULL; hid_init(); dev = new_hid_device(); /* OPEN HERE */ dev->device_handle = open(path, O_RDWR); /* If we have a good handle, return it. */ if (dev->device_handle > 0) { /* Get the report descriptor */ int res, desc_size = 0; struct hidraw_report_descriptor rpt_desc; memset(&rpt_desc, 0x0, sizeof(rpt_desc)); /* Get Report Descriptor Size */ res = ioctl(dev->device_handle, HIDIOCGRDESCSIZE, &desc_size); if (res < 0) perror("HIDIOCGRDESCSIZE"); /* Get Report Descriptor */ rpt_desc.size = desc_size; res = ioctl(dev->device_handle, HIDIOCGRDESC, &rpt_desc); if (res < 0) { perror("HIDIOCGRDESC"); } else { /* Determine if this device uses numbered reports. */ dev->uses_numbered_reports = uses_numbered_reports(rpt_desc.value, rpt_desc.size); } dev->is_bluetooth = (is_bluetooth(dev) == 1); return dev; } else { /* Unable to open any devices. */ free(dev); return NULL; } } int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) { int bytes_written; bytes_written = write(dev->device_handle, data, length); return bytes_written; } int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { int bytes_read; if (milliseconds >= 0) { /* Milliseconds is either 0 (non-blocking) or > 0 (contains a valid timeout). In both cases we want to call poll() and wait for data to arrive. Don't rely on non-blocking operation (O_NONBLOCK) since some kernels don't seem to properly report device disconnection through read() when in non-blocking mode. */ int ret; struct pollfd fds; fds.fd = dev->device_handle; fds.events = POLLIN; fds.revents = 0; ret = poll(&fds, 1, milliseconds); if (ret == -1 || ret == 0) { /* Error or timeout */ return ret; } else { /* Check for errors on the file descriptor. This will indicate a device disconnection. */ if (fds.revents & (POLLERR | POLLHUP | POLLNVAL)) return -1; } } bytes_read = read(dev->device_handle, data, length); if (bytes_read < 0 && (errno == EAGAIN || errno == EINPROGRESS)) bytes_read = 0; if (bytes_read >= 0 && kernel_version != 0 && kernel_version < KERNEL_VERSION(2,6,34) && dev->uses_numbered_reports) { /* Work around a kernel bug. Chop off the first byte. */ memmove(data, data+1, bytes_read); bytes_read--; } return bytes_read; } int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { /* Do all non-blocking in userspace using poll(), since it looks like there's a bug in the kernel in some versions where read() will not return -1 on disconnection of the USB device */ dev->blocking = !nonblock; return 0; /* Success */ } int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { int res; res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data); if (res < 0) perror("ioctl (SFEATURE)"); return res; } int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { int res; /* It looks like HIDIOCGFEATURE() on Bluetooth devices doesn't return the report number */ if (dev->is_bluetooth) { data[1] = data[0]; ++data; --length; } res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data); if (res < 0) perror("ioctl (GFEATURE)"); else if (dev->is_bluetooth) ++res; return res; } void HID_API_EXPORT hid_close(hid_device *dev) { if (!dev) return; close(dev->device_handle); free(dev); } int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_MANUFACTURER, string, maxlen); } int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_PRODUCT, string, maxlen); } int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_device_string(dev, DEVICE_STRING_SERIAL, string, maxlen); } int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { return -1; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { return NULL; } #ifdef NAMESPACE } #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\mac\hid.c
/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 2010-07-03 Copyright 2010, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ /* See Apple Technical Note TN2187 for details on IOHidManager. */ #include <IOKit/hid/IOHIDManager.h> #include <IOKit/hid/IOHIDKeys.h> #include <CoreFoundation/CoreFoundation.h> #include <wchar.h> #include <locale.h> #include <pthread.h> #include <sys/time.h> #include <unistd.h> #include "hidapi.h" /* Barrier implementation because Mac OSX doesn't have pthread_barrier. It also doesn't have clock_gettime(). So much for POSIX and SUSv2. This implementation came from Brent Priddy and was posted on StackOverflow. It is used with his permission. */ typedef int pthread_barrierattr_t; typedef struct pthread_barrier { pthread_mutex_t mutex; pthread_cond_t cond; int count; int trip_count; } pthread_barrier_t; static int pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned int count) { if(count == 0) { errno = EINVAL; return -1; } if(pthread_mutex_init(&barrier->mutex, 0) < 0) { return -1; } if(pthread_cond_init(&barrier->cond, 0) < 0) { pthread_mutex_destroy(&barrier->mutex); return -1; } barrier->trip_count = count; barrier->count = 0; return 0; } static int pthread_barrier_destroy(pthread_barrier_t *barrier) { pthread_cond_destroy(&barrier->cond); pthread_mutex_destroy(&barrier->mutex); return 0; } static int pthread_barrier_wait(pthread_barrier_t *barrier) { pthread_mutex_lock(&barrier->mutex); ++(barrier->count); if(barrier->count >= barrier->trip_count) { barrier->count = 0; pthread_cond_broadcast(&barrier->cond); pthread_mutex_unlock(&barrier->mutex); return 1; } else { pthread_cond_wait(&barrier->cond, &(barrier->mutex)); pthread_mutex_unlock(&barrier->mutex); return 0; } } static int return_data(hid_device *dev, unsigned char *data, size_t length); /* Linked List of input reports received from the device. */ struct input_report { uint8_t *data; size_t len; struct input_report *next; }; struct hid_device_ { IOHIDDeviceRef device_handle; int blocking; int uses_numbered_reports; int disconnected; CFStringRef run_loop_mode; CFRunLoopRef run_loop; CFRunLoopSourceRef source; uint8_t *input_report_buf; CFIndex max_input_report_len; struct input_report *input_reports; pthread_t thread; pthread_mutex_t mutex; /* Protects input_reports */ pthread_cond_t condition; pthread_barrier_t barrier; /* Ensures correct startup sequence */ pthread_barrier_t shutdown_barrier; /* Ensures correct shutdown sequence */ int shutdown_thread; hid_device *next; }; /* Static list of all the devices open. This way when a device gets disconnected, its hid_device structure can be marked as disconnected from hid_device_removal_callback(). */ static hid_device *device_list = NULL; static pthread_mutex_t device_list_mutex = PTHREAD_MUTEX_INITIALIZER; static hid_device *new_hid_device(void) { hid_device *dev = (hid_device*)calloc(1, sizeof(hid_device)); dev->device_handle = NULL; dev->blocking = 1; dev->uses_numbered_reports = 0; dev->disconnected = 0; dev->run_loop_mode = NULL; dev->run_loop = NULL; dev->source = NULL; dev->input_report_buf = NULL; dev->input_reports = NULL; dev->shutdown_thread = 0; dev->next = NULL; /* Thread objects */ pthread_mutex_init(&dev->mutex, NULL); pthread_cond_init(&dev->condition, NULL); pthread_barrier_init(&dev->barrier, NULL, 2); pthread_barrier_init(&dev->shutdown_barrier, NULL, 2); /* Add the new record to the device_list. */ pthread_mutex_lock(&device_list_mutex); if (!device_list) device_list = dev; else { hid_device *d = device_list; while (d) { if (!d->next) { d->next = dev; break; } d = d->next; } } pthread_mutex_unlock(&device_list_mutex); return dev; } static void free_hid_device(hid_device *dev) { if (!dev) return; /* Delete any input reports still left over. */ struct input_report *rpt = dev->input_reports; while (rpt) { struct input_report *next = rpt->next; free(rpt->data); free(rpt); rpt = next; } /* Free the string and the report buffer. The check for NULL is necessary here as CFRelease() doesn't handle NULL like free() and others do. */ if (dev->run_loop_mode) CFRelease(dev->run_loop_mode); if (dev->source) CFRelease(dev->source); free(dev->input_report_buf); /* Clean up the thread objects */ pthread_barrier_destroy(&dev->shutdown_barrier); pthread_barrier_destroy(&dev->barrier); pthread_cond_destroy(&dev->condition); pthread_mutex_destroy(&dev->mutex); /* Remove it from the device list. */ pthread_mutex_lock(&device_list_mutex); hid_device *d = device_list; if (d == dev) { device_list = d->next; } else { while (d) { if (d->next == dev) { d->next = d->next->next; break; } d = d->next; } } pthread_mutex_unlock(&device_list_mutex); /* Free the structure itself. */ free(dev); } static IOHIDManagerRef hid_mgr = 0x0; #if 0 static void register_error(hid_device *device, const char *op) { } #endif static int32_t get_int_property(IOHIDDeviceRef device, CFStringRef key) { CFTypeRef ref; int32_t value; ref = IOHIDDeviceGetProperty(device, key); if (ref) { if (CFGetTypeID(ref) == CFNumberGetTypeID()) { CFNumberGetValue((CFNumberRef) ref, kCFNumberSInt32Type, &value); return value; } } return 0; } static unsigned short get_vendor_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDVendorIDKey)); } static unsigned short get_product_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDProductIDKey)); } static int32_t get_max_report_length(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDMaxInputReportSizeKey)); } static int get_string_property(IOHIDDeviceRef device, CFStringRef prop, wchar_t *buf, size_t len) { CFStringRef str; if (!len) return 0; str = (CFStringRef)IOHIDDeviceGetProperty(device, prop); buf[0] = 0; if (str) { len --; CFIndex str_len = CFStringGetLength(str); CFRange range; range.location = 0; range.length = (str_len > len)? len: str_len; CFIndex used_buf_len; CFIndex chars_copied; chars_copied = CFStringGetBytes(str, range, kCFStringEncodingUTF32LE, (char)'?', FALSE, (UInt8*)buf, len, &used_buf_len); buf[chars_copied] = 0; return (int)chars_copied; } else return 0; } static int get_string_property_utf8(IOHIDDeviceRef device, CFStringRef prop, char *buf, size_t len) { CFStringRef str; if (!len) return 0; str = (CFStringRef)IOHIDDeviceGetProperty(device, prop); buf[0] = 0; if (str) { len--; CFIndex str_len = CFStringGetLength(str); CFRange range; range.location = 0; range.length = (str_len > len)? len: str_len; CFIndex used_buf_len; CFIndex chars_copied; chars_copied = CFStringGetBytes(str, range, kCFStringEncodingUTF8, (char)'?', FALSE, (UInt8*)buf, len, &used_buf_len); buf[chars_copied] = 0; return (int)used_buf_len; } else return 0; } static int get_serial_number(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDSerialNumberKey), buf, len); } static int get_manufacturer_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDManufacturerKey), buf, len); } static int get_product_string(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDProductKey), buf, len); } /* Implementation of wcsdup() for Mac. */ static wchar_t *dup_wcs(const wchar_t *s) { size_t len = wcslen(s); wchar_t *ret = (wchar_t *)malloc((len+1)*sizeof(wchar_t)); wcscpy(ret, s); return ret; } static int make_path(IOHIDDeviceRef device, char *buf, size_t len) { int res; unsigned short vid, pid; char transport[32]; buf[0] = '\0'; res = get_string_property_utf8( device, CFSTR(kIOHIDTransportKey), transport, sizeof(transport)); if (!res) return -1; vid = get_vendor_id(device); pid = get_product_id(device); res = snprintf(buf, len, "%s_%04hx_%04hx_%p", transport, vid, pid, device); buf[len-1] = '\0'; return res+1; } /* Initialize the IOHIDManager. Return 0 for success and -1 for failure. */ static int init_hid_manager(void) { /* Initialize all the HID Manager Objects */ hid_mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (hid_mgr) { IOHIDManagerSetDeviceMatching(hid_mgr, NULL); IOHIDManagerScheduleWithRunLoop(hid_mgr, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode); return 0; } return -1; } /* Initialize the IOHIDManager if necessary. This is the public function, and it is safe to call this function repeatedly. Return 0 for success and -1 for failure. */ int HID_API_EXPORT hid_init(void) { if (!hid_mgr) { return init_hid_manager(); } /* Already initialized. */ return 0; } int HID_API_EXPORT hid_exit(void) { if (hid_mgr) { /* Close the HID manager. */ IOHIDManagerClose(hid_mgr, kIOHIDOptionsTypeNone); CFRelease(hid_mgr); hid_mgr = NULL; } return 0; } static void process_pending_events() { SInt32 res; do { res = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.001, FALSE); } while(res != kCFRunLoopRunFinished && res != kCFRunLoopRunTimedOut); } struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, unsigned short product_id) { struct hid_device_info *root = NULL; // return object struct hid_device_info *cur_dev = NULL; CFIndex num_devices; int i; setlocale(LC_ALL,""); /* Set up the HID Manager if it hasn't been done */ if (hid_init() < 0) return NULL; /* give the IOHIDManager a chance to update itself */ process_pending_events(); /* Get a list of the Devices */ CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); if (!device_set) return NULL; /* Convert the list into a C array so we can iterate easily. */ num_devices = CFSetGetCount(device_set); if (!num_devices) { CFRelease(device_set); return NULL; } IOHIDDeviceRef *device_array = (IOHIDDeviceRef*)calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); /* Iterate over each device, making an entry for it. */ for (i = 0; i < num_devices; i++) { unsigned short dev_vid; unsigned short dev_pid; #define BUF_LEN 256 wchar_t buf[BUF_LEN]; char cbuf[BUF_LEN]; IOHIDDeviceRef dev = device_array[i]; if (!dev) { continue; } dev_vid = get_vendor_id(dev); dev_pid = get_product_id(dev); /* Check the VID/PID against the arguments */ if ((vendor_id == 0x0 && product_id == 0x0) || (vendor_id == dev_vid && product_id == dev_pid)) { struct hid_device_info *tmp; size_t len; /* VID/PID match. Create the record. */ tmp = (struct hid_device_info *)malloc(sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; // Get the Usage Page and Usage for this device. cur_dev->usage_page = get_int_property(dev, CFSTR(kIOHIDPrimaryUsagePageKey)); cur_dev->usage = get_int_property(dev, CFSTR(kIOHIDPrimaryUsageKey)); /* Fill out the record */ cur_dev->next = NULL; len = make_path(dev, cbuf, sizeof(cbuf)); cur_dev->path = strdup(cbuf); /* Serial Number */ get_serial_number(dev, buf, BUF_LEN); cur_dev->serial_number = dup_wcs(buf); /* Manufacturer and Product strings */ get_manufacturer_string(dev, buf, BUF_LEN); cur_dev->manufacturer_string = dup_wcs(buf); get_product_string(dev, buf, BUF_LEN); cur_dev->product_string = dup_wcs(buf); /* VID/PID */ cur_dev->vendor_id = dev_vid; cur_dev->product_id = dev_pid; /* Release Number */ cur_dev->release_number = get_int_property(dev, CFSTR(kIOHIDVersionNumberKey)); /* Interface Number (Unsupported on Mac)*/ cur_dev->interface_number = -1; } } free(device_array); CFRelease(device_set); return root; } void HID_API_EXPORT hid_free_enumeration(struct hid_device_info *devs) { /* This function is identical to the Linux version. Platform independent. */ struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } hid_device * HID_API_EXPORT hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { /* This function is identical to the Linux version. Platform independent. */ struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device * handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open, 0); } hid_free_enumeration(devs); return handle; } static void hid_device_removal_callback(void *context, IOReturn result, void *sender, IOHIDDeviceRef dev_ref) { /* Stop the Run Loop for this device. */ pthread_mutex_lock(&device_list_mutex); hid_device *d = device_list; while (d) { if (d->device_handle == dev_ref) { d->disconnected = 1; CFRunLoopStop(d->run_loop); } d = d->next; } pthread_mutex_unlock(&device_list_mutex); } /* The Run Loop calls this function for each input report received. This function puts the data into a linked list to be picked up by hid_read(). */ static void hid_report_callback(void *context, IOReturn result, void *sender, IOHIDReportType report_type, uint32_t report_id, uint8_t *report, CFIndex report_length) { struct input_report *rpt; hid_device *dev = (hid_device *)context; /* Make a new Input Report object */ rpt = (struct input_report *)calloc(1, sizeof(struct input_report)); rpt->data = (uint8_t *)calloc(1, report_length); memcpy(rpt->data, report, report_length); rpt->len = report_length; rpt->next = NULL; /* Lock this section */ pthread_mutex_lock(&dev->mutex); /* Attach the new report object to the end of the list. */ if (dev->input_reports == NULL) { /* The list is empty. Put it at the root. */ dev->input_reports = rpt; } else { /* Find the end of the list and attach. */ struct input_report *cur = dev->input_reports; int num_queued = 0; while (cur->next != NULL) { cur = cur->next; num_queued++; } cur->next = rpt; /* Pop one off if we've reached 30 in the queue. This way we don't grow forever if the user never reads anything from the device. */ if (num_queued > 30) { return_data(dev, NULL, 0); } } /* Signal a waiting thread that there is data. */ pthread_cond_signal(&dev->condition); /* Unlock */ pthread_mutex_unlock(&dev->mutex); } /* This gets called when the read_thred's run loop gets signaled by hid_close(), and serves to stop the read_thread's run loop. */ static void perform_signal_callback(void *context) { hid_device *dev = (hid_device *)context; CFRunLoopStop(dev->run_loop); //TODO: CFRunLoopGetCurrent() } static void *read_thread(void *param) { hid_device *dev = (hid_device *)param; /* Move the device's run loop to this thread. */ IOHIDDeviceScheduleWithRunLoop(dev->device_handle, CFRunLoopGetCurrent(), dev->run_loop_mode); /* Create the RunLoopSource which is used to signal the event loop to stop when hid_close() is called. */ CFRunLoopSourceContext ctx; memset(&ctx, 0, sizeof(ctx)); ctx.version = 0; ctx.info = dev; ctx.perform = &perform_signal_callback; dev->source = CFRunLoopSourceCreate(kCFAllocatorDefault, 0/*order*/, &ctx); CFRunLoopAddSource(CFRunLoopGetCurrent(), dev->source, dev->run_loop_mode); /* Store off the Run Loop so it can be stopped from hid_close() and on device disconnection. */ dev->run_loop = CFRunLoopGetCurrent(); /* Notify the main thread that the read thread is up and running. */ pthread_barrier_wait(&dev->barrier); /* Run the Event Loop. CFRunLoopRunInMode() will dispatch HID input reports into the hid_report_callback(). */ SInt32 code; while (!dev->shutdown_thread && !dev->disconnected) { code = CFRunLoopRunInMode(dev->run_loop_mode, 1000/*sec*/, FALSE); /* Return if the device has been disconnected */ if (code == kCFRunLoopRunFinished) { dev->disconnected = 1; break; } /* Break if The Run Loop returns Finished or Stopped. */ if (code != kCFRunLoopRunTimedOut && code != kCFRunLoopRunHandledSource) { /* There was some kind of error. Setting shutdown seems to make sense, but there may be something else more appropriate */ dev->shutdown_thread = 1; break; } } /* Now that the read thread is stopping, Wake any threads which are waiting on data (in hid_read_timeout()). Do this under a mutex to make sure that a thread which is about to go to sleep waiting on the condition acutally will go to sleep before the condition is signaled. */ pthread_mutex_lock(&dev->mutex); pthread_cond_broadcast(&dev->condition); pthread_mutex_unlock(&dev->mutex); /* Wait here until hid_close() is called and makes it past the call to CFRunLoopWakeUp(). This thread still needs to be valid when that function is called on the other thread. */ pthread_barrier_wait(&dev->shutdown_barrier); return NULL; } hid_device * HID_API_EXPORT hid_open_path(const char *path, int bExclusive) { int i; hid_device *dev = NULL; CFIndex num_devices; dev = new_hid_device(); /* Set up the HID Manager if it hasn't been done */ if (hid_init() < 0) return NULL; /* give the IOHIDManager a chance to update itself */ process_pending_events(); CFSetRef device_set = IOHIDManagerCopyDevices(hid_mgr); num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = (IOHIDDeviceRef *)calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); for (i = 0; i < num_devices; i++) { char cbuf[BUF_LEN]; size_t len; IOHIDDeviceRef os_dev = device_array[i]; len = make_path(os_dev, cbuf, sizeof(cbuf)); if (!strcmp(cbuf, path)) { // Matched Paths. Open this Device. IOReturn ret = IOHIDDeviceOpen(os_dev, kIOHIDOptionsTypeNone); if (ret == kIOReturnSuccess) { char str[32]; free(device_array); CFRelease(device_set); dev->device_handle = os_dev; /* Create the buffers for receiving data */ dev->max_input_report_len = (CFIndex) get_max_report_length(os_dev); dev->input_report_buf = (uint8_t *)calloc(dev->max_input_report_len, sizeof(uint8_t)); /* Create the Run Loop Mode for this device. printing the reference seems to work. */ sprintf(str, "HIDAPI_%p", os_dev); dev->run_loop_mode = CFStringCreateWithCString(NULL, str, kCFStringEncodingASCII); /* Attach the device to a Run Loop */ IOHIDDeviceRegisterInputReportCallback( os_dev, dev->input_report_buf, dev->max_input_report_len, &hid_report_callback, dev); IOHIDManagerRegisterDeviceRemovalCallback(hid_mgr, hid_device_removal_callback, NULL); /* Start the read thread */ pthread_create(&dev->thread, NULL, read_thread, dev); /* Wait here for the read thread to be initialized. */ pthread_barrier_wait(&dev->barrier); return dev; } else { goto return_error; } } } return_error: free(device_array); CFRelease(device_set); free_hid_device(dev); return NULL; } static int set_report(hid_device *dev, IOHIDReportType type, const unsigned char *data, size_t length) { const char *pass_through_magic = "MAGIC0"; size_t pass_through_magic_length = strlen(pass_through_magic); unsigned char report_id = data[0]; const unsigned char *data_to_send; size_t length_to_send; IOReturn res; /* Return if the device has been disconnected. */ if (dev->disconnected) return -1; if (report_id == 0x0) { /* Not using numbered Reports. Don't send the report number. */ data_to_send = data+1; length_to_send = length-1; } else if (length > 6 && memcmp(data, pass_through_magic, pass_through_magic_length) == 0) { report_id = data[pass_through_magic_length]; data_to_send = data+pass_through_magic_length; length_to_send = length-pass_through_magic_length; } else { /* Using numbered Reports. Send the Report Number */ data_to_send = data; length_to_send = length; } if (!dev->disconnected) { res = IOHIDDeviceSetReport(dev->device_handle, type, report_id, /* Report ID*/ data_to_send, length_to_send); if (res == kIOReturnSuccess) { return (int)length; } else if (res == kIOReturnUnsupported) { /*printf("kIOReturnUnsupported\n");*/ return -1; } else { /*printf("0x%x\n", res);*/ return -1; } } return -1; } int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t length) { return set_report(dev, kIOHIDReportTypeOutput, data, length); } /* Helper function, so that this isn't duplicated in hid_read(). */ static int return_data(hid_device *dev, unsigned char *data, size_t length) { /* Copy the data out of the linked list item (rpt) into the return buffer (data), and delete the liked list item. */ struct input_report *rpt = dev->input_reports; size_t len = (length < rpt->len)? length: rpt->len; memcpy(data, rpt->data, len); dev->input_reports = rpt->next; free(rpt->data); free(rpt); return (int)len; } static int cond_wait(const hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex) { while (!dev->input_reports) { int res = pthread_cond_wait(cond, mutex); if (res != 0) return res; /* A res of 0 means we may have been signaled or it may be a spurious wakeup. Check to see that there's acutally data in the queue before returning, and if not, go back to sleep. See the pthread_cond_timedwait() man page for details. */ if (dev->shutdown_thread || dev->disconnected) return -1; } return 0; } static int cond_timedwait(const hid_device *dev, pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) { while (!dev->input_reports) { int res = pthread_cond_timedwait(cond, mutex, abstime); if (res != 0) return res; /* A res of 0 means we may have been signaled or it may be a spurious wakeup. Check to see that there's acutally data in the queue before returning, and if not, go back to sleep. See the pthread_cond_timedwait() man page for details. */ if (dev->shutdown_thread || dev->disconnected) return -1; } return 0; } int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { int bytes_read = -1; /* Lock the access to the report list. */ pthread_mutex_lock(&dev->mutex); /* There's an input report queued up. Return it. */ if (dev->input_reports) { /* Return the first one */ bytes_read = return_data(dev, data, length); goto ret; } /* Return if the device has been disconnected. */ if (dev->disconnected) { bytes_read = -1; goto ret; } if (dev->shutdown_thread) { /* This means the device has been closed (or there has been an error. An error code of -1 should be returned. */ bytes_read = -1; goto ret; } /* There is no data. Go to sleep and wait for data. */ if (milliseconds == -1) { /* Blocking */ int res; res = cond_wait(dev, &dev->condition, &dev->mutex); if (res == 0) bytes_read = return_data(dev, data, length); else { /* There was an error, or a device disconnection. */ bytes_read = -1; } } else if (milliseconds > 0) { /* Non-blocking, but called with timeout. */ int res; struct timespec ts; struct timeval tv; gettimeofday(&tv, NULL); TIMEVAL_TO_TIMESPEC(&tv, &ts); ts.tv_sec += milliseconds / 1000; ts.tv_nsec += (milliseconds % 1000) * 1000000; if (ts.tv_nsec >= 1000000000L) { ts.tv_sec++; ts.tv_nsec -= 1000000000L; } res = cond_timedwait(dev, &dev->condition, &dev->mutex, &ts); if (res == 0) bytes_read = return_data(dev, data, length); else if (res == ETIMEDOUT) bytes_read = 0; else bytes_read = -1; } else { /* Purely non-blocking */ bytes_read = 0; } ret: /* Unlock */ pthread_mutex_unlock(&dev->mutex); return bytes_read; } int HID_API_EXPORT hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { /* All Nonblocking operation is handled by the library. */ dev->blocking = !nonblock; return 0; } int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { return set_report(dev, kIOHIDReportTypeFeature, data, length); } int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { CFIndex len = length; IOReturn res; /* Return if the device has been unplugged. */ if (dev->disconnected) return -1; int skipped_report_id = 0; int report_number = data[0]; if (report_number == 0x0) { /* Offset the return buffer by 1, so that the report ID will remain in byte 0. */ data++; len--; skipped_report_id = 1; } res = IOHIDDeviceGetReport(dev->device_handle, kIOHIDReportTypeFeature, report_number, /* Report ID */ data, &len); if (res != kIOReturnSuccess) return -1; if (skipped_report_id) len++; return (int)len; } void HID_API_EXPORT hid_close(hid_device *dev) { if (!dev) return; /* Disconnect the report callback before close. */ if (!dev->disconnected) { IOHIDDeviceRegisterInputReportCallback( dev->device_handle, dev->input_report_buf, dev->max_input_report_len, NULL, dev); IOHIDManagerRegisterDeviceRemovalCallback(hid_mgr, NULL, dev); IOHIDDeviceUnscheduleFromRunLoop(dev->device_handle, dev->run_loop, dev->run_loop_mode); IOHIDDeviceScheduleWithRunLoop(dev->device_handle, CFRunLoopGetMain(), kCFRunLoopDefaultMode); } /* Cause read_thread() to stop. */ dev->shutdown_thread = 1; /* Wake up the run thread's event loop so that the thread can exit. */ CFRunLoopSourceSignal(dev->source); CFRunLoopWakeUp(dev->run_loop); /* Notify the read thread that it can shut down now. */ pthread_barrier_wait(&dev->shutdown_barrier); /* Wait for read_thread() to end. */ pthread_join(dev->thread, NULL); /* Close the OS handle to the device, but only if it's not been unplugged. If it's been unplugged, then calling IOHIDDeviceClose() will crash. */ if (!dev->disconnected) { IOHIDDeviceClose(dev->device_handle, kIOHIDOptionsTypeNone); } /* Clear out the queue of received reports. */ pthread_mutex_lock(&dev->mutex); while (dev->input_reports) { return_data(dev, NULL, 0); } pthread_mutex_unlock(&dev->mutex); free_hid_device(dev); } int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_manufacturer_string(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_product_string(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { return get_serial_number(dev->device_handle, string, maxlen); } int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { // TODO: return 0; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { // TODO: return NULL; } #if 0 static int32_t get_location_id(IOHIDDeviceRef device) { return get_int_property(device, CFSTR(kIOHIDLocationIDKey)); } static int32_t get_usage(IOHIDDeviceRef device) { int32_t res; res = get_int_property(device, CFSTR(kIOHIDDeviceUsageKey)); if (!res) res = get_int_property(device, CFSTR(kIOHIDPrimaryUsageKey)); return res; } static int32_t get_usage_page(IOHIDDeviceRef device) { int32_t res; res = get_int_property(device, CFSTR(kIOHIDDeviceUsagePageKey)); if (!res) res = get_int_property(device, CFSTR(kIOHIDPrimaryUsagePageKey)); return res; } static int get_transport(IOHIDDeviceRef device, wchar_t *buf, size_t len) { return get_string_property(device, CFSTR(kIOHIDTransportKey), buf, len); } int main(void) { IOHIDManagerRef mgr; int i; mgr = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); IOHIDManagerSetDeviceMatching(mgr, NULL); IOHIDManagerOpen(mgr, kIOHIDOptionsTypeNone); CFSetRef device_set = IOHIDManagerCopyDevices(mgr); CFIndex num_devices = CFSetGetCount(device_set); IOHIDDeviceRef *device_array = calloc(num_devices, sizeof(IOHIDDeviceRef)); CFSetGetValues(device_set, (const void **) device_array); setlocale(LC_ALL, ""); for (i = 0; i < num_devices; i++) { IOHIDDeviceRef dev = device_array[i]; printf("Device: %p\n", dev); printf(" %04hx %04hx\n", get_vendor_id(dev), get_product_id(dev)); wchar_t serial[256], buf[256]; char cbuf[256]; get_serial_number(dev, serial, 256); printf(" Serial: %ls\n", serial); printf(" Loc: %ld\n", get_location_id(dev)); get_transport(dev, buf, 256); printf(" Trans: %ls\n", buf); make_path(dev, cbuf, 256); printf(" Path: %s\n", cbuf); } return 0; } #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\testgui\mac_support.h
/******************************* Mac support for HID Test GUI Alan Ott Signal 11 Software *******************************/ #ifndef MAC_SUPPORT_H__ #define MAC_SUPPORT_H__ extern "C" { void init_apple_message_system(); void check_apple_events(); } #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi
D://workCode//uploadProject\awtk\3rd\SDL\src\hidapi\windows\hid.c
/******************************************************* HIDAPI - Multi-Platform library for communication with HID devices. Alan Ott Signal 11 Software 8/22/2009 Copyright 2009, All Rights Reserved. At the discretion of the user of this library, this software may be licensed under the terms of the GNU General Public License v3, a BSD-Style license, or the original HIDAPI license as outlined in the LICENSE.txt, LICENSE-gpl3.txt, LICENSE-bsd.txt, and LICENSE-orig.txt files located at the root of the source distribution. These files may also be found in the public source code repository located at: http://github.com/signal11/hidapi . ********************************************************/ #include <windows.h> #ifndef _NTDEF_ typedef LONG NTSTATUS; #endif #ifdef __MINGW32__ #include <ntdef.h> #include <winbase.h> #endif #ifdef __CYGWIN__ #include <ntdef.h> #define _wcsdup wcsdup #endif /* SDL C runtime functions */ #include "SDL_stdinc.h" #define calloc SDL_calloc #define free SDL_free #define malloc SDL_malloc #define memcpy SDL_memcpy #define memset SDL_memset #define strcmp SDL_strcmp #define strlen SDL_strlen #define strncpy SDL_strlcpy #define strstr SDL_strstr #define strtol SDL_strtol #define wcscmp SDL_wcscmp #define _wcsdup SDL_wcsdup /* The maximum number of characters that can be passed into the HidD_Get*String() functions without it failing.*/ #define MAX_STRING_WCHARS 0xFFF /*#define HIDAPI_USE_DDK*/ #ifdef __cplusplus extern "C" { #endif #include <setupapi.h> #include <winioctl.h> #ifdef HIDAPI_USE_DDK #include <hidsdi.h> #endif /* Copied from inc/ddk/hidclass.h, part of the Windows DDK. */ #define HID_OUT_CTL_CODE(id) \ CTL_CODE(FILE_DEVICE_KEYBOARD, (id), METHOD_OUT_DIRECT, FILE_ANY_ACCESS) #define IOCTL_HID_GET_FEATURE HID_OUT_CTL_CODE(100) #ifdef __cplusplus } /* extern "C" */ #endif #include <stdio.h> #include <stdlib.h> #include "../hidapi/hidapi.h" #undef MIN #define MIN(x,y) ((x) < (y)? (x): (y)) #ifdef _MSC_VER /* Thanks Microsoft, but I know how to use strncpy(). */ #pragma warning(disable:4996) #endif #ifdef __cplusplus extern "C" { #endif #ifndef HIDAPI_USE_DDK /* Since we're not building with the DDK, and the HID header files aren't part of the SDK, we have to define all this stuff here. In lookup_functions(), the function pointers defined below are set. */ typedef struct _HIDD_ATTRIBUTES{ ULONG Size; USHORT VendorID; USHORT ProductID; USHORT VersionNumber; } HIDD_ATTRIBUTES, *PHIDD_ATTRIBUTES; typedef USHORT USAGE; typedef struct _HIDP_CAPS { USAGE Usage; USAGE UsagePage; USHORT InputReportByteLength; USHORT OutputReportByteLength; USHORT FeatureReportByteLength; USHORT Reserved[17]; USHORT fields_not_used_by_hidapi[10]; } HIDP_CAPS, *PHIDP_CAPS; typedef void* PHIDP_PREPARSED_DATA; #define HIDP_STATUS_SUCCESS 0x110000 typedef BOOLEAN (__stdcall *HidD_GetAttributes_)(HANDLE device, PHIDD_ATTRIBUTES attrib); typedef BOOLEAN (__stdcall *HidD_GetSerialNumberString_)(HANDLE device, PVOID buffer, ULONG buffer_len); typedef BOOLEAN (__stdcall *HidD_GetManufacturerString_)(HANDLE handle, PVOID buffer, ULONG buffer_len); typedef BOOLEAN (__stdcall *HidD_GetProductString_)(HANDLE handle, PVOID buffer, ULONG buffer_len); typedef BOOLEAN (__stdcall *HidD_SetFeature_)(HANDLE handle, PVOID data, ULONG length); typedef BOOLEAN (__stdcall *HidD_GetFeature_)(HANDLE handle, PVOID data, ULONG length); typedef BOOLEAN (__stdcall *HidD_GetIndexedString_)(HANDLE handle, ULONG string_index, PVOID buffer, ULONG buffer_len); typedef BOOLEAN (__stdcall *HidD_GetPreparsedData_)(HANDLE handle, PHIDP_PREPARSED_DATA *preparsed_data); typedef BOOLEAN (__stdcall *HidD_FreePreparsedData_)(PHIDP_PREPARSED_DATA preparsed_data); typedef NTSTATUS (__stdcall *HidP_GetCaps_)(PHIDP_PREPARSED_DATA preparsed_data, HIDP_CAPS *caps); typedef BOOLEAN (__stdcall *HidD_SetNumInputBuffers_)(HANDLE handle, ULONG number_buffers); typedef BOOLEAN(__stdcall *HidD_SetOutputReport_ )(HANDLE handle, PVOID buffer, ULONG buffer_len); static HidD_GetAttributes_ HidD_GetAttributes; static HidD_GetSerialNumberString_ HidD_GetSerialNumberString; static HidD_GetManufacturerString_ HidD_GetManufacturerString; static HidD_GetProductString_ HidD_GetProductString; static HidD_SetFeature_ HidD_SetFeature; static HidD_GetFeature_ HidD_GetFeature; static HidD_GetIndexedString_ HidD_GetIndexedString; static HidD_GetPreparsedData_ HidD_GetPreparsedData; static HidD_FreePreparsedData_ HidD_FreePreparsedData; static HidP_GetCaps_ HidP_GetCaps; static HidD_SetNumInputBuffers_ HidD_SetNumInputBuffers; static HidD_SetOutputReport_ HidD_SetOutputReport; static HMODULE lib_handle = NULL; static BOOLEAN initialized = FALSE; #endif /* HIDAPI_USE_DDK */ struct hid_device_ { HANDLE device_handle; BOOL blocking; USHORT output_report_length; size_t input_report_length; void *last_error_str; DWORD last_error_num; BOOL read_pending; char *read_buf; OVERLAPPED ol; }; static hid_device *new_hid_device() { hid_device *dev = (hid_device*) calloc(1, sizeof(hid_device)); dev->device_handle = INVALID_HANDLE_VALUE; dev->blocking = TRUE; dev->output_report_length = 0; dev->input_report_length = 0; dev->last_error_str = NULL; dev->last_error_num = 0; dev->read_pending = FALSE; dev->read_buf = NULL; memset(&dev->ol, 0, sizeof(dev->ol)); dev->ol.hEvent = CreateEvent(NULL, FALSE, FALSE /*initial state f=nonsignaled*/, NULL); return dev; } static void free_hid_device(hid_device *dev) { CloseHandle(dev->ol.hEvent); CloseHandle(dev->device_handle); LocalFree(dev->last_error_str); free(dev->read_buf); free(dev); } static void register_error(hid_device *device, const char *op) { WCHAR *ptr, *msg; DWORD count = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&msg, 0/*sz*/, NULL); if (!count) return; /* Get rid of the CR and LF that FormatMessage() sticks at the end of the message. Thanks Microsoft! */ ptr = msg; while (*ptr) { if (*ptr == '\r') { *ptr = 0x0000; break; } ptr++; } /* Store the message off in the Device entry so that the hid_error() function can pick it up. */ LocalFree(device->last_error_str); device->last_error_str = msg; } #ifndef HIDAPI_USE_DDK static int lookup_functions() { lib_handle = LoadLibraryA("hid.dll"); if (lib_handle) { #define RESOLVE(x) x = (x##_)GetProcAddress(lib_handle, #x); if (!x) return -1; RESOLVE(HidD_GetAttributes); RESOLVE(HidD_GetSerialNumberString); RESOLVE(HidD_GetManufacturerString); RESOLVE(HidD_GetProductString); RESOLVE(HidD_SetFeature); RESOLVE(HidD_GetFeature); RESOLVE(HidD_GetIndexedString); RESOLVE(HidD_GetPreparsedData); RESOLVE(HidD_FreePreparsedData); RESOLVE(HidP_GetCaps); RESOLVE(HidD_SetNumInputBuffers); RESOLVE(HidD_SetOutputReport); #undef RESOLVE } else return -1; return 0; } #endif static HANDLE open_device(const char *path, BOOL enumerate, BOOL bExclusive ) { HANDLE handle; // Opening with access 0 causes keyboards to stop responding in some system configurations // http://steamcommunity.com/discussions/forum/1/1843493219428923893 // Thanks to co-wie (Ka-wei Low <kawei@mac.com>) for help narrowing down the problem on his system //DWORD desired_access = (enumerate)? 0: (GENERIC_WRITE | GENERIC_READ); DWORD desired_access = ( GENERIC_WRITE | GENERIC_READ ); DWORD share_mode = bExclusive ? 0 : ( FILE_SHARE_READ | FILE_SHARE_WRITE ); handle = CreateFileA(path, desired_access, share_mode, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED,/*FILE_ATTRIBUTE_NORMAL,*/ 0); return handle; } int HID_API_EXPORT hid_init(void) { #ifndef HIDAPI_USE_DDK if (!initialized) { if (lookup_functions() < 0) { hid_exit(); return -1; } initialized = TRUE; } #endif return 0; } int HID_API_EXPORT hid_exit(void) { #ifndef HIDAPI_USE_DDK if (lib_handle) FreeLibrary(lib_handle); lib_handle = NULL; initialized = FALSE; #endif return 0; } struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id) { BOOL res; struct hid_device_info *root = NULL; /* return object */ struct hid_device_info *cur_dev = NULL; /* Windows objects for interacting with the driver. */ GUID InterfaceClassGuid = {0x4d1e55b2, 0xf16f, 0x11cf, {0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30} }; SP_DEVINFO_DATA devinfo_data; SP_DEVICE_INTERFACE_DATA device_interface_data; SP_DEVICE_INTERFACE_DETAIL_DATA_A *device_interface_detail_data = NULL; HDEVINFO device_info_set = INVALID_HANDLE_VALUE; int device_index = 0; int i; if (hid_init() < 0) return NULL; /* Initialize the Windows objects. */ memset(&devinfo_data, 0x0, sizeof(devinfo_data)); devinfo_data.cbSize = sizeof(SP_DEVINFO_DATA); device_interface_data.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA); /* Get information for all the devices belonging to the HID class. */ device_info_set = SetupDiGetClassDevsA(&InterfaceClassGuid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); /* Iterate over each device in the HID class, looking for the right one. */ for (;;) { HANDLE write_handle = INVALID_HANDLE_VALUE; DWORD required_size = 0; HIDD_ATTRIBUTES attrib; res = SetupDiEnumDeviceInterfaces(device_info_set, NULL, &InterfaceClassGuid, device_index, &device_interface_data); if (!res) { /* A return of FALSE from this function means that there are no more devices. */ break; } /* Call with 0-sized detail size, and let the function tell us how long the detail struct needs to be. The size is put in &required_size. */ res = SetupDiGetDeviceInterfaceDetailA(device_info_set, &device_interface_data, NULL, 0, &required_size, NULL); /* Allocate a long enough structure for device_interface_detail_data. */ device_interface_detail_data = (SP_DEVICE_INTERFACE_DETAIL_DATA_A*) malloc(required_size); device_interface_detail_data->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); /* Get the detailed data for this device. The detail data gives us the device path for this device, which is then passed into CreateFile() to get a handle to the device. */ res = SetupDiGetDeviceInterfaceDetailA(device_info_set, &device_interface_data, device_interface_detail_data, required_size, NULL, NULL); if (!res) { /* register_error(dev, "Unable to call SetupDiGetDeviceInterfaceDetail"); Continue to the next device. */ goto cont; } /* Make sure this device is of Setup Class "HIDClass" and has a driver bound to it. */ for (i = 0; ; i++) { char driver_name[256]; /* Populate devinfo_data. This function will return failure when there are no more interfaces left. */ res = SetupDiEnumDeviceInfo(device_info_set, i, &devinfo_data); if (!res) goto cont; res = SetupDiGetDeviceRegistryPropertyA(device_info_set, &devinfo_data, SPDRP_CLASS, NULL, (PBYTE)driver_name, sizeof(driver_name), NULL); if (!res) goto cont; if (strcmp(driver_name, "HIDClass") == 0) { /* See if there's a driver bound. */ res = SetupDiGetDeviceRegistryPropertyA(device_info_set, &devinfo_data, SPDRP_DRIVER, NULL, (PBYTE)driver_name, sizeof(driver_name), NULL); if (res) break; } } //wprintf(L"HandleName: %s\n", device_interface_detail_data->DevicePath); /* Open a handle to the device */ write_handle = open_device(device_interface_detail_data->DevicePath, TRUE, FALSE); /* Check validity of write_handle. */ if (write_handle == INVALID_HANDLE_VALUE) { /* Unable to open the device. */ //register_error(dev, "CreateFile"); goto cont_close; } /* Get the Vendor ID and Product ID for this device. */ attrib.Size = sizeof(HIDD_ATTRIBUTES); HidD_GetAttributes(write_handle, &attrib); //wprintf(L"Product/Vendor: %x %x\n", attrib.ProductID, attrib.VendorID); /* Check the VID/PID to see if we should add this device to the enumeration list. */ if ((vendor_id == 0x0 || attrib.VendorID == vendor_id) && (product_id == 0x0 || attrib.ProductID == product_id)) { #define WSTR_LEN 512 const char *str; struct hid_device_info *tmp; PHIDP_PREPARSED_DATA pp_data = NULL; HIDP_CAPS caps; BOOLEAN hidp_res; NTSTATUS nt_res; wchar_t wstr[WSTR_LEN]; /* TODO: Determine Size */ size_t len; /* VID/PID match. Create the record. */ tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info)); if (cur_dev) { cur_dev->next = tmp; } else { root = tmp; } cur_dev = tmp; /* Get the Usage Page and Usage for this device. */ hidp_res = HidD_GetPreparsedData(write_handle, &pp_data); if (hidp_res) { nt_res = HidP_GetCaps(pp_data, &caps); if (nt_res == HIDP_STATUS_SUCCESS) { cur_dev->usage_page = caps.UsagePage; cur_dev->usage = caps.Usage; } HidD_FreePreparsedData(pp_data); } /* Fill out the record */ cur_dev->next = NULL; str = device_interface_detail_data->DevicePath; if (str) { len = strlen(str); cur_dev->path = (char*) calloc(len+1, sizeof(char)); strncpy(cur_dev->path, str, len+1); cur_dev->path[len] = '\0'; } else cur_dev->path = NULL; /* Serial Number */ hidp_res = HidD_GetSerialNumberString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (hidp_res) { cur_dev->serial_number = _wcsdup(wstr); } /* Manufacturer String */ hidp_res = HidD_GetManufacturerString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (hidp_res) { cur_dev->manufacturer_string = _wcsdup(wstr); } /* Product String */ hidp_res = HidD_GetProductString(write_handle, wstr, sizeof(wstr)); wstr[WSTR_LEN-1] = 0x0000; if (hidp_res) { cur_dev->product_string = _wcsdup(wstr); } /* VID/PID */ cur_dev->vendor_id = attrib.VendorID; cur_dev->product_id = attrib.ProductID; /* Release Number */ cur_dev->release_number = attrib.VersionNumber; /* Interface Number. It can sometimes be parsed out of the path on Windows if a device has multiple interfaces. See http://msdn.microsoft.com/en-us/windows/hardware/gg487473 or search for "Hardware IDs for HID Devices" at MSDN. If it's not in the path, it's set to -1. */ cur_dev->interface_number = -1; if (cur_dev->path) { char *interface_component = strstr(cur_dev->path, "&mi_"); if (interface_component) { char *hex_str = interface_component + 4; char *endptr = NULL; cur_dev->interface_number = strtol(hex_str, &endptr, 16); if (endptr == hex_str) { /* The parsing failed. Set interface_number to -1. */ cur_dev->interface_number = -1; } } } } cont_close: CloseHandle(write_handle); cont: /* We no longer need the detail data. It can be freed */ free(device_interface_detail_data); device_index++; } /* Close the device information handle. */ SetupDiDestroyDeviceInfoList(device_info_set); return root; } void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs) { /* TODO: Merge this with the Linux version. This function is platform-independent. */ struct hid_device_info *d = devs; while (d) { struct hid_device_info *next = d->next; free(d->path); free(d->serial_number); free(d->manufacturer_string); free(d->product_string); free(d); d = next; } } HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { /* TODO: Merge this functions with the Linux version. This function should be platform independent. */ struct hid_device_info *devs, *cur_dev; const char *path_to_open = NULL; hid_device *handle = NULL; devs = hid_enumerate(vendor_id, product_id); cur_dev = devs; while (cur_dev) { if (cur_dev->vendor_id == vendor_id && cur_dev->product_id == product_id) { if (serial_number) { if (wcscmp(serial_number, cur_dev->serial_number) == 0) { path_to_open = cur_dev->path; break; } } else { path_to_open = cur_dev->path; break; } } cur_dev = cur_dev->next; } if (path_to_open) { /* Open the device */ handle = hid_open_path(path_to_open, 0); } hid_free_enumeration(devs); return handle; } HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bExclusive) { hid_device *dev; HIDP_CAPS caps; PHIDP_PREPARSED_DATA pp_data = NULL; BOOLEAN res; NTSTATUS nt_res; if (hid_init() < 0) { return NULL; } dev = new_hid_device(); /* Open a handle to the device */ dev->device_handle = open_device(path, FALSE, bExclusive); /* Check validity of write_handle. */ if (dev->device_handle == INVALID_HANDLE_VALUE) { /* Unable to open the device. */ register_error(dev, "CreateFile"); goto err; } /* Set the Input Report buffer size to 64 reports. */ res = HidD_SetNumInputBuffers(dev->device_handle, 64); if (!res) { register_error(dev, "HidD_SetNumInputBuffers"); goto err; } /* Get the Input Report length for the device. */ res = HidD_GetPreparsedData(dev->device_handle, &pp_data); if (!res) { register_error(dev, "HidD_GetPreparsedData"); goto err; } nt_res = HidP_GetCaps(pp_data, &caps); if (nt_res != HIDP_STATUS_SUCCESS) { register_error(dev, "HidP_GetCaps"); goto err_pp_data; } dev->output_report_length = caps.OutputReportByteLength; dev->input_report_length = caps.InputReportByteLength; HidD_FreePreparsedData(pp_data); dev->read_buf = (char*) malloc(dev->input_report_length); return dev; err_pp_data: HidD_FreePreparsedData(pp_data); err: free_hid_device(dev); return NULL; } int HID_API_EXPORT HID_API_CALL hid_write_output_report(hid_device *dev, const unsigned char *data, size_t length) { BOOL res; res = HidD_SetOutputReport(dev->device_handle, (void *)data, (ULONG)length); if (res) return (int)length; else return -1; } int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length) { DWORD bytes_written; BOOL res; size_t stashed_length = length; OVERLAPPED ol; unsigned char *buf; memset(&ol, 0, sizeof(ol)); /* Make sure the right number of bytes are passed to WriteFile. Windows expects the number of bytes which are in the _longest_ report (plus one for the report number) bytes even if the data is a report which is shorter than that. Windows gives us this value in caps.OutputReportByteLength. If a user passes in fewer bytes than this, create a temporary buffer which is the proper size. */ if (length >= dev->output_report_length) { /* The user passed the right number of bytes. Use the buffer as-is. */ buf = (unsigned char *) data; } else { /* Create a temporary buffer and copy the user's data into it, padding the rest with zeros. */ buf = (unsigned char *) malloc(dev->output_report_length); memcpy(buf, data, length); memset(buf + length, 0, dev->output_report_length - length); length = dev->output_report_length; } if (length > 512) { return hid_write_output_report( dev, data, stashed_length ); } else { res = WriteFile( dev->device_handle, buf, ( DWORD ) length, NULL, &ol ); if (!res) { if (GetLastError() != ERROR_IO_PENDING) { /* WriteFile() failed. Return error. */ register_error(dev, "WriteFile"); bytes_written = (DWORD) -1; goto end_of_function; } } /* Wait here until the write is done. This makes hid_write() synchronous. */ res = GetOverlappedResult(dev->device_handle, &ol, &bytes_written, TRUE/*wait*/); if (!res) { /* The Write operation failed. */ register_error(dev, "WriteFile"); bytes_written = (DWORD) -1; goto end_of_function; } } end_of_function: if (buf != data) free(buf); return bytes_written; } int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { DWORD bytes_read = 0; size_t copy_len = 0; BOOL res; /* Copy the handle for convenience. */ HANDLE ev = dev->ol.hEvent; if (!dev->read_pending) { /* Start an Overlapped I/O read. */ dev->read_pending = TRUE; memset(dev->read_buf, 0, dev->input_report_length); ResetEvent(ev); res = ReadFile(dev->device_handle, dev->read_buf, (DWORD)dev->input_report_length, &bytes_read, &dev->ol); if (!res) { if (GetLastError() != ERROR_IO_PENDING) { /* ReadFile() has failed. Clean up and return error. */ CancelIo(dev->device_handle); dev->read_pending = FALSE; goto end_of_function; } } } if (milliseconds >= 0) { /* See if there is any data yet. */ res = WaitForSingleObject(ev, milliseconds); if (res != WAIT_OBJECT_0) { /* There was no data this time. Return zero bytes available, but leave the Overlapped I/O running. */ return 0; } } /* Either WaitForSingleObject() told us that ReadFile has completed, or we are in non-blocking mode. Get the number of bytes read. The actual data has been copied to the data[] array which was passed to ReadFile(). */ res = GetOverlappedResult(dev->device_handle, &dev->ol, &bytes_read, TRUE/*wait*/); /* Set pending back to false, even if GetOverlappedResult() returned error. */ dev->read_pending = FALSE; if (res && bytes_read > 0) { if (dev->read_buf[0] == 0x0) { /* If report numbers aren't being used, but Windows sticks a report number (0x0) on the beginning of the report anyway. To make this work like the other platforms, and to make it work more like the HID spec, we'll skip over this byte. */ bytes_read--; copy_len = length > bytes_read ? bytes_read : length; memcpy(data, dev->read_buf+1, copy_len); } else { /* Copy the whole buffer, report number and all. */ copy_len = length > bytes_read ? bytes_read : length; memcpy(data, dev->read_buf, copy_len); } } end_of_function: if (!res) { register_error(dev, "GetOverlappedResult"); return -1; } return (int)copy_len; } int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length) { return hid_read_timeout(dev, data, length, (dev->blocking)? -1: 0); } int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock) { dev->blocking = !nonblock; return 0; /* Success */ } int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { BOOL res = HidD_SetFeature(dev->device_handle, (PVOID)data, (ULONG)length); if (!res) { register_error(dev, "HidD_SetFeature"); return -1; } return (int)length; } int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length) { BOOL res; #if 0 res = HidD_GetFeature(dev->device_handle, (PVOID)data, (ULONG)length); if (!res) { register_error(dev, "HidD_GetFeature"); return -1; } return 0; /* HidD_GetFeature() doesn't give us an actual length, unfortunately */ #else DWORD bytes_returned; OVERLAPPED ol; memset(&ol, 0, sizeof(ol)); res = DeviceIoControl(dev->device_handle, IOCTL_HID_GET_FEATURE, data, (DWORD)length, data, (DWORD)length, &bytes_returned, &ol); if (!res) { if (GetLastError() != ERROR_IO_PENDING) { /* DeviceIoControl() failed. Return error. */ register_error(dev, "Send Feature Report DeviceIoControl"); return -1; } } /* Wait here until the write is done. This makes hid_get_feature_report() synchronous. */ res = GetOverlappedResult(dev->device_handle, &ol, &bytes_returned, TRUE/*wait*/); if (!res) { /* The operation failed. */ register_error(dev, "Send Feature Report GetOverLappedResult"); return -1; } /* bytes_returned does not include the first byte which contains the report ID. The data buffer actually contains one more byte than bytes_returned. */ bytes_returned++; return bytes_returned; #endif } void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev) { if (!dev) return; CancelIo(dev->device_handle); free_hid_device(dev); } int HID_API_EXPORT_CALL HID_API_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen) { BOOL res; res = HidD_GetManufacturerString(dev->device_handle, string, (ULONG)(sizeof(wchar_t) * MIN(maxlen, MAX_STRING_WCHARS))); if (!res) { register_error(dev, "HidD_GetManufacturerString"); return -1; } return 0; } int HID_API_EXPORT_CALL HID_API_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen) { BOOL res; res = HidD_GetProductString(dev->device_handle, string, (ULONG)(sizeof(wchar_t) * MIN(maxlen, MAX_STRING_WCHARS))); if (!res) { register_error(dev, "HidD_GetProductString"); return -1; } return 0; } int HID_API_EXPORT_CALL HID_API_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen) { BOOL res; res = HidD_GetSerialNumberString(dev->device_handle, string, (ULONG)(sizeof(wchar_t) * MIN(maxlen, MAX_STRING_WCHARS))); if (!res) { register_error(dev, "HidD_GetSerialNumberString"); return -1; } return 0; } int HID_API_EXPORT_CALL HID_API_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen) { BOOL res; res = HidD_GetIndexedString(dev->device_handle, string_index, string, (ULONG)(sizeof(wchar_t) * MIN(maxlen, MAX_STRING_WCHARS))); if (!res) { register_error(dev, "HidD_GetIndexedString"); return -1; } return 0; } HID_API_EXPORT const wchar_t * HID_API_CALL hid_error(hid_device *dev) { return (wchar_t*)dev->last_error_str; } /*#define PICPGM*/ /*#define S11*/ #define P32 #ifdef S11 unsigned short VendorID = 0xa0a0; unsigned short ProductID = 0x0001; #endif #ifdef P32 unsigned short VendorID = 0x04d8; unsigned short ProductID = 0x3f; #endif #ifdef PICPGM unsigned short VendorID = 0x04d8; unsigned short ProductID = 0x0033; #endif #if 0 int __cdecl main(int argc, char* argv[]) { int res; unsigned char buf[65]; UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); /* Set up the command buffer. */ memset(buf,0x00,sizeof(buf)); buf[0] = 0; buf[1] = 0x81; /* Open the device. */ int handle = open(VendorID, ProductID, L"12345"); if (handle < 0) printf("unable to open device\n"); /* Toggle LED (cmd 0x80) */ buf[1] = 0x80; res = write(handle, buf, 65); if (res < 0) printf("Unable to write()\n"); /* Request state (cmd 0x81) */ buf[1] = 0x81; write(handle, buf, 65); if (res < 0) printf("Unable to write() (2)\n"); /* Read requested state */ read(handle, buf, 65); if (res < 0) printf("Unable to read()\n"); /* Print out the returned buffer. */ for (int i = 0; i < 4; i++) printf("buf[%d]: %d\n", i, buf[i]); return 0; } #endif #ifdef __cplusplus } /* extern "C" */ #endif
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\controller_type.h
/* Copyright (C) Valve Corporation This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef CONTROLLER_TYPE_H #define CONTROLLER_TYPE_H #ifdef _WIN32 #pragma once #endif #ifndef __cplusplus #include <stdbool.h> #define inline SDL_INLINE #endif //----------------------------------------------------------------------------- // Purpose: Steam Controller models // WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN A DATABASE //----------------------------------------------------------------------------- typedef enum { k_eControllerType_None = -1, k_eControllerType_Unknown = 0, // Steam Controllers k_eControllerType_UnknownSteamController = 1, k_eControllerType_SteamController = 2, k_eControllerType_SteamControllerV2 = 3, // Other Controllers k_eControllerType_UnknownNonSteamController = 30, k_eControllerType_XBox360Controller = 31, k_eControllerType_XBoxOneController = 32, k_eControllerType_PS3Controller = 33, k_eControllerType_PS4Controller = 34, k_eControllerType_WiiController = 35, k_eControllerType_AppleController = 36, k_eControllerType_AndroidController = 37, k_eControllerType_SwitchProController = 38, k_eControllerType_SwitchJoyConLeft = 39, k_eControllerType_SwitchJoyConRight = 40, k_eControllerType_SwitchJoyConPair = 41, k_eControllerType_SwitchInputOnlyController = 42, k_eControllerType_MobileTouch = 43, k_eControllerType_LastController, // Don't add game controllers below this enumeration - this enumeration can change value // Keyboards and Mice k_eControllertype_GenericKeyboard = 400, k_eControllertype_GenericMouse = 800, } EControllerType; static inline bool BIsSteamController( EControllerType eType ) { return ( eType == k_eControllerType_SteamController || eType == k_eControllerType_SteamControllerV2 ); } #define MAKE_CONTROLLER_ID( nVID, nPID ) (unsigned int)( nVID << 16 | nPID ) typedef struct { unsigned int m_unDeviceID; EControllerType m_eControllerType; } ControllerDescription_t; static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0079, 0x18d4 ), k_eControllerType_XBox360Controller }, // GPD Win 2 X-Box Controller { MAKE_CONTROLLER_ID( 0x044f, 0xb326 ), k_eControllerType_XBox360Controller }, // Thrustmaster Gamepad GP XID { MAKE_CONTROLLER_ID( 0x045e, 0x028e ), k_eControllerType_XBox360Controller }, // Microsoft X-Box 360 pad { MAKE_CONTROLLER_ID( 0x045e, 0x028f ), k_eControllerType_XBox360Controller }, // Microsoft X-Box 360 pad v2 { MAKE_CONTROLLER_ID( 0x045e, 0x0291 ), k_eControllerType_XBox360Controller }, // Xbox 360 Wireless Receiver (XBOX) { MAKE_CONTROLLER_ID( 0x045e, 0x02a0 ), k_eControllerType_XBox360Controller }, // Microsoft X-Box 360 Big Button IR { MAKE_CONTROLLER_ID( 0x045e, 0x02a1 ), k_eControllerType_XBox360Controller }, // Microsoft X-Box 360 pad { MAKE_CONTROLLER_ID( 0x045e, 0x02d1 ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One pad { MAKE_CONTROLLER_ID( 0x045e, 0x02dd ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One pad (Firmware 2015) { MAKE_CONTROLLER_ID( 0x045e, 0x02e0 ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One S pad (Bluetooth) { MAKE_CONTROLLER_ID( 0x045e, 0x02e3 ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One Elite pad { MAKE_CONTROLLER_ID( 0x045e, 0x02ea ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One S pad { MAKE_CONTROLLER_ID( 0x045e, 0x02fd ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One S pad (Bluetooth) { MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController }, // Microsoft X-Box One Elite pad { MAKE_CONTROLLER_ID( 0x045e, 0x0719 ), k_eControllerType_XBox360Controller }, // Xbox 360 Wireless Receiver { MAKE_CONTROLLER_ID( 0x046d, 0xc21d ), k_eControllerType_XBox360Controller }, // Logitech Gamepad F310 { MAKE_CONTROLLER_ID( 0x046d, 0xc21e ), k_eControllerType_XBox360Controller }, // Logitech Gamepad F510 { MAKE_CONTROLLER_ID( 0x046d, 0xc21f ), k_eControllerType_XBox360Controller }, // Logitech Gamepad F710 { MAKE_CONTROLLER_ID( 0x046d, 0xc242 ), k_eControllerType_XBox360Controller }, // Logitech Chillstream Controller { MAKE_CONTROLLER_ID( 0x054c, 0x0268 ), k_eControllerType_PS3Controller }, // Sony PS3 Controller { MAKE_CONTROLLER_ID( 0x0925, 0x0005 ), k_eControllerType_PS3Controller }, // Sony PS3 Controller { MAKE_CONTROLLER_ID( 0x8888, 0x0308 ), k_eControllerType_PS3Controller }, // Sony PS3 Controller { MAKE_CONTROLLER_ID( 0x1a34, 0x0836 ), k_eControllerType_PS3Controller }, // Afterglow ps3 { MAKE_CONTROLLER_ID( 0x0f0d, 0x006e ), k_eControllerType_PS3Controller }, // HORI horipad4 ps3 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0066 ), k_eControllerType_PS3Controller }, // HORI horipad4 ps4 { MAKE_CONTROLLER_ID( 0x0f0d, 0x005f ), k_eControllerType_PS3Controller }, // HORI Fighting commander ps3 { MAKE_CONTROLLER_ID( 0x0f0d, 0x005e ), k_eControllerType_PS3Controller }, // HORI Fighting commander ps4 //{ MAKE_CONTROLLER_ID( 0x0738, 0x3250 ), k_eControllerType_PS3Controller }, // madcats fightpad pro ps3 already in ps4 list.. does this work?? { MAKE_CONTROLLER_ID( 0x0738, 0x8250 ), k_eControllerType_PS3Controller }, // madcats fightpad pro ps4 { MAKE_CONTROLLER_ID( 0x0079, 0x181a ), k_eControllerType_PS3Controller }, // Venom Arcade Stick { MAKE_CONTROLLER_ID( 0x0079, 0x0006 ), k_eControllerType_PS3Controller }, // PC Twin Shock Controller - looks like a DS3 but the face buttons are 1-4 instead of symbols { MAKE_CONTROLLER_ID( 0x0079, 0x1844 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x8888, 0x0308 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x2563, 0x0575 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x0810, 0x0001 ), k_eControllerType_PS3Controller }, // actually ps2 - maybe break out later { MAKE_CONTROLLER_ID( 0x0810, 0x0003 ), k_eControllerType_PS3Controller }, // actually ps2 - maybe break out later { MAKE_CONTROLLER_ID( 0x2563, 0x0523 ), k_eControllerType_PS3Controller }, // Digiflip GP006 { MAKE_CONTROLLER_ID( 0x11ff, 0x3331 ), k_eControllerType_PS3Controller }, // SRXJ-PH2400 { MAKE_CONTROLLER_ID( 0x20bc, 0x5500 ), k_eControllerType_PS3Controller }, // ShanWan PS3 { MAKE_CONTROLLER_ID( 0x05b8, 0x1004 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x146b, 0x0603 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x044f, 0xb315 ), k_eControllerType_PS3Controller }, // Firestorm Dual Analog 3 { MAKE_CONTROLLER_ID( 0x0925, 0x8888 ), k_eControllerType_PS3Controller }, // Actually ps2 -maybe break out later Lakeview Research WiseGroup Ltd, MP-8866 Dual Joypad { MAKE_CONTROLLER_ID( 0x0f0d, 0x004d ), k_eControllerType_PS3Controller }, // Horipad 3 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0009 ), k_eControllerType_PS3Controller }, // HORI BDA GP1 { MAKE_CONTROLLER_ID( 0x0e8f, 0x0008 ), k_eControllerType_PS3Controller }, // Green Asia { MAKE_CONTROLLER_ID( 0x0f0d, 0x006a ), k_eControllerType_PS3Controller }, // Real Arcade Pro 4 { MAKE_CONTROLLER_ID( 0x0e6f, 0x011e ), k_eControllerType_PS3Controller }, // Rock Candy PS4 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0214 ), k_eControllerType_PS3Controller }, // afterglow ps3 { MAKE_CONTROLLER_ID( 0x0925, 0x8866 ), k_eControllerType_PS3Controller }, // PS2 maybe break out later { MAKE_CONTROLLER_ID( 0x0e8f, 0x310d ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x2c22, 0x2003 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x056e, 0x2013 ), k_eControllerType_PS3Controller }, // JC-U4113SBK { MAKE_CONTROLLER_ID( 0x0738, 0x8838 ), k_eControllerType_PS3Controller }, // Madcatz Fightstick Pro { MAKE_CONTROLLER_ID( 0x1a34, 0x0836 ), k_eControllerType_PS3Controller }, // Afterglow PS3 { MAKE_CONTROLLER_ID( 0x0f30, 0x1100 ), k_eControllerType_PS3Controller }, // Quanba Q1 fight stick { MAKE_CONTROLLER_ID( 0x1345, 0x6005 ), k_eControllerType_PS3Controller }, // ps2 maybe break out later { MAKE_CONTROLLER_ID( 0x0f0d, 0x0087 ), k_eControllerType_PS3Controller }, // HORI fighting mini stick { MAKE_CONTROLLER_ID( 0x146b, 0x5500 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x20d6, 0xca6d ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x25f0, 0xc121 ), k_eControllerType_PS3Controller }, // { MAKE_CONTROLLER_ID( 0x8380, 0x0003 ), k_eControllerType_PS3Controller }, // BTP 2163 { MAKE_CONTROLLER_ID( 0x1345, 0x1000 ), k_eControllerType_PS3Controller }, // PS2 ACME GA-D5 { MAKE_CONTROLLER_ID( 0x0e8f, 0x3075 ), k_eControllerType_PS3Controller }, // SpeedLink Strike FX { MAKE_CONTROLLER_ID( 0x0e6f, 0x0128 ), k_eControllerType_PS3Controller }, // Rock Candy PS3 { MAKE_CONTROLLER_ID( 0x2c22, 0x2000 ), k_eControllerType_PS3Controller }, // Quanba Drone { MAKE_CONTROLLER_ID( 0x06a3, 0xf622 ), k_eControllerType_PS3Controller }, // Cyborg V3 { MAKE_CONTROLLER_ID( 0x044f, 0xd007 ), k_eControllerType_PS3Controller }, // Thrustmaster wireless 3-1 { MAKE_CONTROLLER_ID( 0x25f0, 0x83c3 ), k_eControllerType_PS3Controller }, // gioteck vx2 { MAKE_CONTROLLER_ID( 0x05b8, 0x1006 ), k_eControllerType_PS3Controller }, // JC-U3412SBK { MAKE_CONTROLLER_ID( 0x20d6, 0x576d ), k_eControllerType_PS3Controller }, // Power A PS3 { MAKE_CONTROLLER_ID( 0x0e6f, 0x6302 ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x056e, 0x200f ), k_eControllerType_PS3Controller }, // From SDL { MAKE_CONTROLLER_ID( 0x0e6f, 0x1314 ), k_eControllerType_PS3Controller }, // PDP Afterglow Wireless PS3 controller { MAKE_CONTROLLER_ID( 0x054c, 0x05c4 ), k_eControllerType_PS4Controller }, // Sony PS4 Controller { MAKE_CONTROLLER_ID( 0x054c, 0x09cc ), k_eControllerType_PS4Controller }, // Sony PS4 Slim Controller { MAKE_CONTROLLER_ID( 0x054c, 0x0ba0 ), k_eControllerType_PS4Controller }, // Sony PS4 Controller (Wireless dongle) { MAKE_CONTROLLER_ID( 0x0f0d, 0x008a ), k_eControllerType_PS4Controller }, // HORI Real Arcade Pro 4 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0055 ), k_eControllerType_PS4Controller }, // HORIPAD 4 FPS { MAKE_CONTROLLER_ID( 0x0f0d, 0x0066 ), k_eControllerType_PS4Controller }, // HORIPAD 4 FPS Plus { MAKE_CONTROLLER_ID( 0x0738, 0x8384 ), k_eControllerType_PS4Controller }, // Mad Catz FightStick TE S+ PS4 { MAKE_CONTROLLER_ID( 0x0738, 0x8250 ), k_eControllerType_PS4Controller }, // Mad Catz FightPad Pro PS4 { MAKE_CONTROLLER_ID( 0x0C12, 0x0E10 ), k_eControllerType_PS4Controller }, // Armor Armor 3 Pad PS4 { MAKE_CONTROLLER_ID( 0x0C12, 0x1CF6 ), k_eControllerType_PS4Controller }, // EMIO PS4 Elite Controller { MAKE_CONTROLLER_ID( 0x1532, 0x1000 ), k_eControllerType_PS4Controller }, // Razer Raiju PS4 Controller { MAKE_CONTROLLER_ID( 0x1532, 0X0401 ), k_eControllerType_PS4Controller }, // Razer Panthera PS4 Controller { MAKE_CONTROLLER_ID( 0x054c, 0x05c5 ), k_eControllerType_PS4Controller }, // STRIKEPAD PS4 Grip Add-on { MAKE_CONTROLLER_ID( 0x146b, 0x0d01 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller - has gyro { MAKE_CONTROLLER_ID( 0x146b, 0x0d02 ), k_eControllerType_PS4Controller }, // Nacon Revolution Pro Controller v2 - has gyro { MAKE_CONTROLLER_ID( 0x0f0d, 0x00a0 ), k_eControllerType_PS4Controller }, // HORI TAC4 mousething { MAKE_CONTROLLER_ID( 0x0f0d, 0x009c ), k_eControllerType_PS4Controller }, // HORI TAC PRO mousething { MAKE_CONTROLLER_ID( 0x0c12, 0x0ef6 ), k_eControllerType_PS4Controller }, // Hitbox Arcade Stick { MAKE_CONTROLLER_ID( 0x0079, 0x181b ), k_eControllerType_PS4Controller }, // Venom Arcade Stick - XXX:this may not work and may need to be called a ps3 controller { MAKE_CONTROLLER_ID( 0x0738, 0x3250 ), k_eControllerType_PS4Controller }, // Mad Catz FightPad PRO - controller shaped with 6 face buttons { MAKE_CONTROLLER_ID( 0x0f0d, 0x00ee ), k_eControllerType_PS4Controller }, // Hori mini wired https://www.playstation.com/en-us/explore/accessories/gaming-controllers/mini-wired-gamepad/ { MAKE_CONTROLLER_ID( 0x0738, 0x8481 ), k_eControllerType_PS4Controller }, // Mad Catz FightStick TE 2+ PS4 { MAKE_CONTROLLER_ID( 0x0738, 0x8480 ), k_eControllerType_PS4Controller }, // Mad Catz FightStick TE 2 PS4 { MAKE_CONTROLLER_ID( 0x7545, 0x0104 ), k_eControllerType_PS4Controller }, // Armor 3 or Level Up Cobra - At least one variant has gyro { MAKE_CONTROLLER_ID( 0x0c12, 0x0e15 ), k_eControllerType_PS4Controller }, // Game:Pad 4 { MAKE_CONTROLLER_ID( 0x11c0, 0x4001 ), k_eControllerType_PS4Controller }, // "PS4 Fun Controller" added from user log { MAKE_CONTROLLER_ID( 0x1532, 0x1007 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Tournament edition USB- untested and added for razer { MAKE_CONTROLLER_ID( 0x1532, 0x100A ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Tournament edition BT - untested and added for razer { MAKE_CONTROLLER_ID( 0x1532, 0x1004 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Ultimate USB - untested and added for razer { MAKE_CONTROLLER_ID( 0x1532, 0x1009 ), k_eControllerType_PS4Controller }, // Razer Raiju 2 Ultimate BT - untested and added for razer { MAKE_CONTROLLER_ID( 0x1532, 0x1008 ), k_eControllerType_PS4Controller }, // Razer Panthera Evo Fightstick - untested and added for razer { MAKE_CONTROLLER_ID( 0x056e, 0x2004 ), k_eControllerType_XBox360Controller }, // Elecom JC-U3613M { MAKE_CONTROLLER_ID( 0x06a3, 0xf51a ), k_eControllerType_XBox360Controller }, // Saitek P3600 { MAKE_CONTROLLER_ID( 0x0738, 0x4716 ), k_eControllerType_XBox360Controller }, // Mad Catz Wired Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x0738, 0x4718 ), k_eControllerType_XBox360Controller }, // Mad Catz Street Fighter IV FightStick SE { MAKE_CONTROLLER_ID( 0x0738, 0x4726 ), k_eControllerType_XBox360Controller }, // Mad Catz Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x0738, 0x4728 ), k_eControllerType_XBox360Controller }, // Mad Catz Street Fighter IV FightPad { MAKE_CONTROLLER_ID( 0x0738, 0x4736 ), k_eControllerType_XBox360Controller }, // Mad Catz MicroCon Gamepad { MAKE_CONTROLLER_ID( 0x0738, 0x4738 ), k_eControllerType_XBox360Controller }, // Mad Catz Wired Xbox 360 Controller (SFIV) { MAKE_CONTROLLER_ID( 0x0738, 0x4740 ), k_eControllerType_XBox360Controller }, // Mad Catz Beat Pad { MAKE_CONTROLLER_ID( 0x0738, 0x4a01 ), k_eControllerType_XBoxOneController }, // Mad Catz FightStick TE 2 { MAKE_CONTROLLER_ID( 0x0738, 0xb726 ), k_eControllerType_XBox360Controller }, // Mad Catz Xbox controller - MW2 { MAKE_CONTROLLER_ID( 0x0738, 0xbeef ), k_eControllerType_XBox360Controller }, // Mad Catz JOYTECH NEO SE Advanced GamePad { MAKE_CONTROLLER_ID( 0x0738, 0xcb02 ), k_eControllerType_XBox360Controller }, // Saitek Cyborg Rumble Pad - PC/Xbox 360 { MAKE_CONTROLLER_ID( 0x0738, 0xcb03 ), k_eControllerType_XBox360Controller }, // Saitek P3200 Rumble Pad - PC/Xbox 360 { MAKE_CONTROLLER_ID( 0x0738, 0xf738 ), k_eControllerType_XBox360Controller }, // Super SFIV FightStick TE S { MAKE_CONTROLLER_ID( 0x0955, 0xb400 ), k_eControllerType_XBox360Controller }, // NVIDIA Shield streaming controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0105 ), k_eControllerType_XBox360Controller }, // HSM3 Xbox360 dancepad { MAKE_CONTROLLER_ID( 0x0e6f, 0x0113 ), k_eControllerType_XBox360Controller }, // Afterglow AX.1 Gamepad for Xbox 360 { MAKE_CONTROLLER_ID( 0x0e6f, 0x011f ), k_eControllerType_XBox360Controller }, // Rock Candy Gamepad Wired Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0131 ), k_eControllerType_XBox360Controller }, // PDP EA Sports Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0133 ), k_eControllerType_XBox360Controller }, // Xbox 360 Wired Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0139 ), k_eControllerType_XBoxOneController }, // Afterglow Prismatic Wired Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x013a ), k_eControllerType_XBoxOneController }, // PDP Xbox One Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0146 ), k_eControllerType_XBoxOneController }, // Rock Candy Wired Controller for Xbox One { MAKE_CONTROLLER_ID( 0x0e6f, 0x0147 ), k_eControllerType_XBoxOneController }, // PDP Marvel Xbox One Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x015c ), k_eControllerType_XBoxOneController }, // PDP Xbox One Arcade Stick { MAKE_CONTROLLER_ID( 0x0e6f, 0x0161 ), k_eControllerType_XBoxOneController }, // PDP Xbox One Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0162 ), k_eControllerType_XBoxOneController }, // PDP Xbox One Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0163 ), k_eControllerType_XBoxOneController }, // PDP Xbox One Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0164 ), k_eControllerType_XBoxOneController }, // PDP Battlefield One { MAKE_CONTROLLER_ID( 0x0e6f, 0x0165 ), k_eControllerType_XBoxOneController }, // PDP Titanfall 2 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0201 ), k_eControllerType_XBox360Controller }, // Pelican PL-3601 'TSZ' Wired Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0213 ), k_eControllerType_XBox360Controller }, // Afterglow Gamepad for Xbox 360 { MAKE_CONTROLLER_ID( 0x0e6f, 0x021f ), k_eControllerType_XBox360Controller }, // Rock Candy Gamepad for Xbox 360 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0246 ), k_eControllerType_XBoxOneController }, // Rock Candy Gamepad for Xbox One 2015 { MAKE_CONTROLLER_ID( 0x0e6f, 0x02a0 ), k_eControllerType_XBox360Controller }, // Counterfeit 360Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0301 ), k_eControllerType_XBox360Controller }, // Logic3 Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0346 ), k_eControllerType_XBoxOneController }, // Rock Candy Gamepad for Xbox One 2016 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0401 ), k_eControllerType_XBox360Controller }, // Logic3 Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0413 ), k_eControllerType_XBox360Controller }, // Afterglow AX.1 Gamepad for Xbox 360 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0501 ), k_eControllerType_XBox360Controller }, // PDP Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0xf501 ), k_eControllerType_XBox360Controller }, // Counterfeit 360 Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0xf900 ), k_eControllerType_XBox360Controller }, // PDP Afterglow AX.1 { MAKE_CONTROLLER_ID( 0x0f0d, 0x000a ), k_eControllerType_XBox360Controller }, // Hori Co. DOA4 FightStick { MAKE_CONTROLLER_ID( 0x0f0d, 0x000c ), k_eControllerType_XBox360Controller }, // Hori PadEX Turbo { MAKE_CONTROLLER_ID( 0x0f0d, 0x000d ), k_eControllerType_XBox360Controller }, // Hori Fighting Stick EX2 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0016 ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro.EX { MAKE_CONTROLLER_ID( 0x0f0d, 0x001b ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro VX { MAKE_CONTROLLER_ID( 0x0f0d, 0x0063 ), k_eControllerType_XBoxOneController }, // Hori Real Arcade Pro Hayabusa (USA) Xbox One { MAKE_CONTROLLER_ID( 0x0f0d, 0x0067 ), k_eControllerType_XBoxOneController }, // HORIPAD ONE { MAKE_CONTROLLER_ID( 0x0f0d, 0x0078 ), k_eControllerType_XBoxOneController }, // Hori Real Arcade Pro V Kai Xbox One { MAKE_CONTROLLER_ID( 0x0f0d, 0x008c ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro 4 { MAKE_CONTROLLER_ID( 0x11c9, 0x55f0 ), k_eControllerType_XBox360Controller }, // Nacon GC-100XF { MAKE_CONTROLLER_ID( 0x12ab, 0x0004 ), k_eControllerType_XBox360Controller }, // Honey Bee Xbox360 dancepad { MAKE_CONTROLLER_ID( 0x12ab, 0x0301 ), k_eControllerType_XBox360Controller }, // PDP AFTERGLOW AX.1 { MAKE_CONTROLLER_ID( 0x12ab, 0x0303 ), k_eControllerType_XBox360Controller }, // Mortal Kombat Klassic FightStick { MAKE_CONTROLLER_ID( 0x1430, 0x02a0 ), k_eControllerType_XBox360Controller }, // RedOctane Controller Adapter { MAKE_CONTROLLER_ID( 0x1430, 0x4748 ), k_eControllerType_XBox360Controller }, // RedOctane Guitar Hero X-plorer { MAKE_CONTROLLER_ID( 0x1430, 0xf801 ), k_eControllerType_XBox360Controller }, // RedOctane Controller { MAKE_CONTROLLER_ID( 0x146b, 0x0601 ), k_eControllerType_XBox360Controller }, // BigBen Interactive XBOX 360 Controller { MAKE_CONTROLLER_ID( 0x1532, 0x0037 ), k_eControllerType_XBox360Controller }, // Razer Sabertooth { MAKE_CONTROLLER_ID( 0x1532, 0x0a00 ), k_eControllerType_XBoxOneController }, // Razer Atrox Arcade Stick { MAKE_CONTROLLER_ID( 0x1532, 0x0a03 ), k_eControllerType_XBoxOneController }, // Razer Wildcat { MAKE_CONTROLLER_ID( 0x15e4, 0x3f00 ), k_eControllerType_XBox360Controller }, // Power A Mini Pro Elite { MAKE_CONTROLLER_ID( 0x15e4, 0x3f0a ), k_eControllerType_XBox360Controller }, // Xbox Airflo wired controller { MAKE_CONTROLLER_ID( 0x15e4, 0x3f10 ), k_eControllerType_XBox360Controller }, // Batarang Xbox 360 controller { MAKE_CONTROLLER_ID( 0x162e, 0xbeef ), k_eControllerType_XBox360Controller }, // Joytech Neo-Se Take2 { MAKE_CONTROLLER_ID( 0x1689, 0xfd00 ), k_eControllerType_XBox360Controller }, // Razer Onza Tournament Edition { MAKE_CONTROLLER_ID( 0x1689, 0xfd01 ), k_eControllerType_XBox360Controller }, // Razer Onza Classic Edition { MAKE_CONTROLLER_ID( 0x1689, 0xfe00 ), k_eControllerType_XBox360Controller }, // Razer Sabertooth { MAKE_CONTROLLER_ID( 0x1bad, 0x0002 ), k_eControllerType_XBox360Controller }, // Harmonix Rock Band Guitar { MAKE_CONTROLLER_ID( 0x1bad, 0x0003 ), k_eControllerType_XBox360Controller }, // Harmonix Rock Band Drumkit { MAKE_CONTROLLER_ID( 0x1bad, 0xf016 ), k_eControllerType_XBox360Controller }, // Mad Catz Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x1bad, 0xf018 ), k_eControllerType_XBox360Controller }, // Mad Catz Street Fighter IV SE Fighting Stick { MAKE_CONTROLLER_ID( 0x1bad, 0xf019 ), k_eControllerType_XBox360Controller }, // Mad Catz Brawlstick for Xbox 360 { MAKE_CONTROLLER_ID( 0x1bad, 0xf021 ), k_eControllerType_XBox360Controller }, // Mad Cats Ghost Recon FS GamePad { MAKE_CONTROLLER_ID( 0x1bad, 0xf023 ), k_eControllerType_XBox360Controller }, // MLG Pro Circuit Controller (Xbox) { MAKE_CONTROLLER_ID( 0x1bad, 0xf025 ), k_eControllerType_XBox360Controller }, // Mad Catz Call Of Duty { MAKE_CONTROLLER_ID( 0x1bad, 0xf027 ), k_eControllerType_XBox360Controller }, // Mad Catz FPS Pro { MAKE_CONTROLLER_ID( 0x1bad, 0xf028 ), k_eControllerType_XBox360Controller }, // Street Fighter IV FightPad { MAKE_CONTROLLER_ID( 0x1bad, 0xf02e ), k_eControllerType_XBox360Controller }, // Mad Catz Fightpad { MAKE_CONTROLLER_ID( 0x1bad, 0xf036 ), k_eControllerType_XBox360Controller }, // Mad Catz MicroCon GamePad Pro { MAKE_CONTROLLER_ID( 0x1bad, 0xf038 ), k_eControllerType_XBox360Controller }, // Street Fighter IV FightStick TE { MAKE_CONTROLLER_ID( 0x1bad, 0xf039 ), k_eControllerType_XBox360Controller }, // Mad Catz MvC2 TE { MAKE_CONTROLLER_ID( 0x1bad, 0xf03a ), k_eControllerType_XBox360Controller }, // Mad Catz SFxT Fightstick Pro { MAKE_CONTROLLER_ID( 0x1bad, 0xf03d ), k_eControllerType_XBox360Controller }, // Street Fighter IV Arcade Stick TE - Chun Li { MAKE_CONTROLLER_ID( 0x1bad, 0xf03e ), k_eControllerType_XBox360Controller }, // Mad Catz MLG FightStick TE { MAKE_CONTROLLER_ID( 0x1bad, 0xf03f ), k_eControllerType_XBox360Controller }, // Mad Catz FightStick SoulCaliber { MAKE_CONTROLLER_ID( 0x1bad, 0xf042 ), k_eControllerType_XBox360Controller }, // Mad Catz FightStick TES+ { MAKE_CONTROLLER_ID( 0x1bad, 0xf080 ), k_eControllerType_XBox360Controller }, // Mad Catz FightStick TE2 { MAKE_CONTROLLER_ID( 0x1bad, 0xf501 ), k_eControllerType_XBox360Controller }, // HoriPad EX2 Turbo { MAKE_CONTROLLER_ID( 0x1bad, 0xf502 ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro.VX SA { MAKE_CONTROLLER_ID( 0x1bad, 0xf503 ), k_eControllerType_XBox360Controller }, // Hori Fighting Stick VX { MAKE_CONTROLLER_ID( 0x1bad, 0xf504 ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro. EX { MAKE_CONTROLLER_ID( 0x1bad, 0xf505 ), k_eControllerType_XBox360Controller }, // Hori Fighting Stick EX2B { MAKE_CONTROLLER_ID( 0x1bad, 0xf506 ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro.EX Premium VLX { MAKE_CONTROLLER_ID( 0x1bad, 0xf900 ), k_eControllerType_XBox360Controller }, // Harmonix Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x1bad, 0xf901 ), k_eControllerType_XBox360Controller }, // Gamestop Xbox 360 Controller { MAKE_CONTROLLER_ID( 0x1bad, 0xf902 ), k_eControllerType_XBox360Controller }, // Mad Catz Gamepad2 { MAKE_CONTROLLER_ID( 0x1bad, 0xf903 ), k_eControllerType_XBox360Controller }, // Tron Xbox 360 controller { MAKE_CONTROLLER_ID( 0x1bad, 0xf904 ), k_eControllerType_XBox360Controller }, // PDP Versus Fighting Pad { MAKE_CONTROLLER_ID( 0x1bad, 0xf906 ), k_eControllerType_XBox360Controller }, // MortalKombat FightStick { MAKE_CONTROLLER_ID( 0x1bad, 0xfa01 ), k_eControllerType_XBox360Controller }, // MadCatz GamePad { MAKE_CONTROLLER_ID( 0x1bad, 0xfd00 ), k_eControllerType_XBox360Controller }, // Razer Onza TE { MAKE_CONTROLLER_ID( 0x1bad, 0xfd01 ), k_eControllerType_XBox360Controller }, // Razer Onza { MAKE_CONTROLLER_ID( 0x24c6, 0x5000 ), k_eControllerType_XBox360Controller }, // Razer Atrox Arcade Stick { MAKE_CONTROLLER_ID( 0x24c6, 0x5300 ), k_eControllerType_XBox360Controller }, // PowerA MINI PROEX Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x5303 ), k_eControllerType_XBox360Controller }, // Xbox Airflo wired controller { MAKE_CONTROLLER_ID( 0x24c6, 0x530a ), k_eControllerType_XBox360Controller }, // Xbox 360 Pro EX Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x531a ), k_eControllerType_XBox360Controller }, // PowerA Pro Ex { MAKE_CONTROLLER_ID( 0x24c6, 0x5397 ), k_eControllerType_XBox360Controller }, // FUS1ON Tournament Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x541a ), k_eControllerType_XBoxOneController }, // PowerA Xbox One Mini Wired Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x542a ), k_eControllerType_XBoxOneController }, // Xbox ONE spectra { MAKE_CONTROLLER_ID( 0x24c6, 0x543a ), k_eControllerType_XBoxOneController }, // PowerA Xbox One wired controller { MAKE_CONTROLLER_ID( 0x24c6, 0x5500 ), k_eControllerType_XBox360Controller }, // Hori XBOX 360 EX 2 with Turbo { MAKE_CONTROLLER_ID( 0x24c6, 0x5501 ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro VX-SA { MAKE_CONTROLLER_ID( 0x24c6, 0x5502 ), k_eControllerType_XBox360Controller }, // Hori Fighting Stick VX Alt { MAKE_CONTROLLER_ID( 0x24c6, 0x5503 ), k_eControllerType_XBox360Controller }, // Hori Fighting Edge { MAKE_CONTROLLER_ID( 0x24c6, 0x5506 ), k_eControllerType_XBox360Controller }, // Hori SOULCALIBUR V Stick { MAKE_CONTROLLER_ID( 0x24c6, 0x5510 ), k_eControllerType_XBox360Controller }, // Hori Fighting Commander ONE { MAKE_CONTROLLER_ID( 0x24c6, 0x550d ), k_eControllerType_XBox360Controller }, // Hori GEM Xbox controller { MAKE_CONTROLLER_ID( 0x24c6, 0x550e ), k_eControllerType_XBox360Controller }, // Hori Real Arcade Pro V Kai 360 { MAKE_CONTROLLER_ID( 0x24c6, 0x551a ), k_eControllerType_XBoxOneController }, // PowerA FUSION Pro Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x561a ), k_eControllerType_XBoxOneController }, // PowerA FUSION Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x5b00 ), k_eControllerType_XBox360Controller }, // ThrustMaster Ferrari Italia 458 Racing Wheel { MAKE_CONTROLLER_ID( 0x24c6, 0x5b02 ), k_eControllerType_XBox360Controller }, // Thrustmaster, Inc. GPX Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x5b03 ), k_eControllerType_XBox360Controller }, // Thrustmaster Ferrari 458 Racing Wheel { MAKE_CONTROLLER_ID( 0x24c6, 0x5d04 ), k_eControllerType_XBox360Controller }, // Razer Sabertooth { MAKE_CONTROLLER_ID( 0x24c6, 0xfafa ), k_eControllerType_XBox360Controller }, // Aplay Controller { MAKE_CONTROLLER_ID( 0x24c6, 0xfafb ), k_eControllerType_XBox360Controller }, // Aplay Controller { MAKE_CONTROLLER_ID( 0x24c6, 0xfafc ), k_eControllerType_XBox360Controller }, // Afterglow Gamepad 1 { MAKE_CONTROLLER_ID( 0x24c6, 0xfafe ), k_eControllerType_XBox360Controller }, // Rock Candy Gamepad for Xbox 360 { MAKE_CONTROLLER_ID( 0x24c6, 0xfafd ), k_eControllerType_XBox360Controller }, // Afterglow Gamepad 3 // These have been added via Minidump for unrecognized Xinput controller assert { MAKE_CONTROLLER_ID( 0x0000, 0x0000 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x045e, 0x02a2 ), k_eControllerType_XBox360Controller }, // Unknown Controller - Microsoft VID { MAKE_CONTROLLER_ID( 0x0e6f, 0x1414 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x1314 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x0159 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x24c6, 0xfaff ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x0086 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x006d ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00a4 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x1832 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x187f ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x1883 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x03eb, 0xff01 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x2c22, 0x2303 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0c12, 0x0ef8 ), k_eControllerType_XBox360Controller }, // Homemade fightstick based on brook pcb (with XInput driver??) { MAKE_CONTROLLER_ID( 0x046d, 0x1000 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x1345, 0x6006 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x056e, 0x2012 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x146b, 0x0602 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00ae ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x146b, 0x0603 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x056e, 0x2013 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x046d, 0x0401 ), k_eControllerType_XBox360Controller }, // logitech xinput { MAKE_CONTROLLER_ID( 0x046d, 0x0301 ), k_eControllerType_XBox360Controller }, // logitech xinput { MAKE_CONTROLLER_ID( 0x046d, 0xcaa3 ), k_eControllerType_XBox360Controller }, // logitech xinput { MAKE_CONTROLLER_ID( 0x046d, 0xc261 ), k_eControllerType_XBox360Controller }, // logitech xinput { MAKE_CONTROLLER_ID( 0x046d, 0x0291 ), k_eControllerType_XBox360Controller }, // logitech xinput { MAKE_CONTROLLER_ID( 0x0079, 0x18d3 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00b1 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0001, 0x0001 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x1345, 0x6005 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x188e ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x18d4 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x2c22, 0x2003 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00b1 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x187c ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x189c ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x0079, 0x1874 ), k_eControllerType_XBox360Controller }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x1038, 0xb360 ), k_eControllerType_XBox360Controller }, // SteelSeries Nimbus/Stratus XL //{ MAKE_CONTROLLER_ID( 0x1949, 0x0402 ), /*android*/ }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x05ac, 0x0001 ), k_eControllerType_AppleController }, // MFI Extended Gamepad (generic entry for iOS/tvOS) { MAKE_CONTROLLER_ID( 0x05ac, 0x0002 ), k_eControllerType_AppleController }, // MFI Standard Gamepad (generic entry for iOS/tvOS) // We currently don't support using a pair of Switch Joy-Con's as a single // controller and we don't want to support using them individually for the // time being, so these should be disabled until one of the above is true // { MAKE_CONTROLLER_ID( 0x057e, 0x2006 ), k_eControllerType_SwitchJoyConLeft }, // Nintendo Switch Joy-Con (Left) // { MAKE_CONTROLLER_ID( 0x057e, 0x2007 ), k_eControllerType_SwitchJoyConRight }, // Nintendo Switch Joy-Con (Right) // This same controller ID is spoofed by many 3rd-party Switch controllers. // The ones we currently know of are: // * Any 8bitdo controller with Switch support // * ORTZ Gaming Wireless Pro Controller // * ZhiXu Gamepad Wireless // * Sunwaytek Wireless Motion Controller for Nintendo Switch { MAKE_CONTROLLER_ID( 0x057e, 0x2009 ), k_eControllerType_SwitchProController }, // Nintendo Switch Pro Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00c1 ), k_eControllerType_SwitchInputOnlyController }, // HORIPAD for Nintendo Switch { MAKE_CONTROLLER_ID( 0x20d6, 0xa711 ), k_eControllerType_SwitchInputOnlyController }, // PowerA Wired Controller Plus { MAKE_CONTROLLER_ID( 0x0f0d, 0x0092 ), k_eControllerType_SwitchInputOnlyController }, // HORI Pokken Tournament DX Pro Pad // Valve products - don't add to public list { MAKE_CONTROLLER_ID( 0x0000, 0x11fb ), k_eControllerType_MobileTouch }, // Streaming mobile touch virtual controls { MAKE_CONTROLLER_ID( 0x28de, 0x1101 ), k_eControllerType_SteamController }, // Valve Legacy Steam Controller (CHELL) { MAKE_CONTROLLER_ID( 0x28de, 0x1102 ), k_eControllerType_SteamController }, // Valve wired Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1105 ), k_eControllerType_SteamControllerV2 }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1106 ), k_eControllerType_SteamControllerV2 }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1142 ), k_eControllerType_SteamController }, // Valve wireless Steam Controller { MAKE_CONTROLLER_ID( 0x28de, 0x1201 ), k_eControllerType_SteamController }, // Valve wired Steam Controller (HEADCRAB) }; #if 0 /* these are currently unused, so #if 0'd out to prevent compiler warnings for now */ static inline const ControllerDescription_t * GetControllerArray( int* nLength /* Out */) { *nLength = sizeof( arrControllers ) / sizeof( arrControllers[0] ); return arrControllers; } #endif static inline EControllerType GuessControllerType( int nVID, int nPID ) { unsigned int unDeviceID = MAKE_CONTROLLER_ID( nVID, nPID ); int iIndex; for ( iIndex = 0; iIndex < sizeof( arrControllers ) / sizeof( arrControllers[0] ); ++iIndex ) { if ( unDeviceID == arrControllers[ iIndex ].m_unDeviceID ) { return arrControllers[ iIndex ].m_eControllerType; } } #undef MAKE_CONTROLLER_ID return k_eControllerType_UnknownNonSteamController; } #endif // CONSTANTS_H
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\SDL_gamecontroller.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* This is the game controller API for Simple DirectMedia Layer */ #include "SDL_events.h" #include "SDL_assert.h" #include "SDL_hints.h" #include "SDL_timer.h" #include "SDL_sysjoystick.h" #include "SDL_joystick_c.h" #include "SDL_gamecontrollerdb.h" #if !SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif #if defined(__ANDROID__) #include "SDL_system.h" #endif /* Many controllers turn the center button into an instantaneous button press */ #define SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS 250 #define SDL_CONTROLLER_PLATFORM_FIELD "platform:" /* a list of currently opened game controllers */ static SDL_GameController *SDL_gamecontrollers = NULL; typedef struct { SDL_GameControllerBindType inputType; union { int button; struct { int axis; int axis_min; int axis_max; } axis; struct { int hat; int hat_mask; } hat; } input; SDL_GameControllerBindType outputType; union { SDL_GameControllerButton button; struct { SDL_GameControllerAxis axis; int axis_min; int axis_max; } axis; } output; } SDL_ExtendedGameControllerBind; /* our hard coded list of mapping support */ typedef enum { SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT, SDL_CONTROLLER_MAPPING_PRIORITY_API, SDL_CONTROLLER_MAPPING_PRIORITY_USER, } SDL_ControllerMappingPriority; typedef struct _ControllerMapping_t { SDL_JoystickGUID guid; char *name; char *mapping; SDL_ControllerMappingPriority priority; struct _ControllerMapping_t *next; } ControllerMapping_t; static SDL_JoystickGUID s_zeroGUID; static ControllerMapping_t *s_pSupportedControllers = NULL; static ControllerMapping_t *s_pDefaultMapping = NULL; static ControllerMapping_t *s_pHIDAPIMapping = NULL; static ControllerMapping_t *s_pXInputMapping = NULL; /* The SDL game controller structure */ struct _SDL_GameController { SDL_Joystick *joystick; /* underlying joystick device */ int ref_count; SDL_JoystickGUID guid; const char *name; int num_bindings; SDL_ExtendedGameControllerBind *bindings; SDL_ExtendedGameControllerBind **last_match_axis; Uint8 *last_hat_mask; Uint32 guide_button_down; struct _SDL_GameController *next; /* pointer to next game controller we have allocated */ }; typedef struct { int num_entries; int max_entries; Uint32 *entries; } SDL_vidpid_list; static SDL_vidpid_list SDL_allowed_controllers; static SDL_vidpid_list SDL_ignored_controllers; static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) { Uint32 entry; char *spot; char *file = NULL; list->num_entries = 0; if (hint && *hint == '@') { spot = file = (char *)SDL_LoadFile(hint+1, NULL); } else { spot = (char *)hint; } if (!spot) { return; } while ((spot = SDL_strstr(spot, "0x")) != NULL) { entry = (Uint16)SDL_strtol(spot, &spot, 0); entry <<= 16; spot = SDL_strstr(spot, "0x"); if (!spot) { break; } entry |= (Uint16)SDL_strtol(spot, &spot, 0); if (list->num_entries == list->max_entries) { int max_entries = list->max_entries + 16; Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries*sizeof(*list->entries)); if (entries == NULL) { /* Out of memory, go with what we have already */ break; } list->entries = entries; list->max_entries = max_entries; } list->entries[list->num_entries++] = entry; } if (file) { SDL_free(file); } } static void SDLCALL SDL_GameControllerIgnoreDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_LoadVIDPIDListFromHint(hint, &SDL_ignored_controllers); } static void SDLCALL SDL_GameControllerIgnoreDevicesExceptChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_LoadVIDPIDListFromHint(hint, &SDL_allowed_controllers); } static int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value); static int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state); /* * If there is an existing add event in the queue, it needs to be modified * to have the right value for which, because the number of controllers in * the system is now one less. */ static void UpdateEventsForDeviceRemoval() { int i, num_events; SDL_Event *events; num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEADDED); if (num_events <= 0) { return; } events = SDL_stack_alloc(SDL_Event, num_events); if (!events) { return; } num_events = SDL_PeepEvents(events, num_events, SDL_GETEVENT, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEADDED); for (i = 0; i < num_events; ++i) { --events[i].cdevice.which; } SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0); SDL_stack_free(events); } static SDL_bool HasSameOutput(SDL_ExtendedGameControllerBind *a, SDL_ExtendedGameControllerBind *b) { if (a->outputType != b->outputType) { return SDL_FALSE; } if (a->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) { return (a->output.axis.axis == b->output.axis.axis); } else { return (a->output.button == b->output.button); } } static void ResetOutput(SDL_GameController *gamecontroller, SDL_ExtendedGameControllerBind *bind) { if (bind->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) { SDL_PrivateGameControllerAxis(gamecontroller, bind->output.axis.axis, 0); } else { SDL_PrivateGameControllerButton(gamecontroller, bind->output.button, SDL_RELEASED); } } static void HandleJoystickAxis(SDL_GameController *gamecontroller, int axis, int value) { int i; SDL_ExtendedGameControllerBind *last_match = gamecontroller->last_match_axis[axis]; SDL_ExtendedGameControllerBind *match = NULL; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS && axis == binding->input.axis.axis) { if (binding->input.axis.axis_min < binding->input.axis.axis_max) { if (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max) { match = binding; break; } } else { if (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min) { match = binding; break; } } } } if (last_match && (!match || !HasSameOutput(last_match, match))) { /* Clear the last input that this axis generated */ ResetOutput(gamecontroller, last_match); } if (match) { if (match->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) { if (match->input.axis.axis_min != match->output.axis.axis_min || match->input.axis.axis_max != match->output.axis.axis_max) { float normalized_value = (float)(value - match->input.axis.axis_min) / (match->input.axis.axis_max - match->input.axis.axis_min); value = match->output.axis.axis_min + (int)(normalized_value * (match->output.axis.axis_max - match->output.axis.axis_min)); } SDL_PrivateGameControllerAxis(gamecontroller, match->output.axis.axis, (Sint16)value); } else { Uint8 state; int threshold = match->input.axis.axis_min + (match->input.axis.axis_max - match->input.axis.axis_min) / 2; if (match->input.axis.axis_max < match->input.axis.axis_min) { state = (value <= threshold) ? SDL_PRESSED : SDL_RELEASED; } else { state = (value >= threshold) ? SDL_PRESSED : SDL_RELEASED; } SDL_PrivateGameControllerButton(gamecontroller, match->output.button, state); } } gamecontroller->last_match_axis[axis] = match; } static void HandleJoystickButton(SDL_GameController *gamecontroller, int button, Uint8 state) { int i; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON && button == binding->input.button) { if (binding->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) { int value = state ? binding->output.axis.axis_max : binding->output.axis.axis_min; SDL_PrivateGameControllerAxis(gamecontroller, binding->output.axis.axis, (Sint16)value); } else { SDL_PrivateGameControllerButton(gamecontroller, binding->output.button, state); } break; } } } static void HandleJoystickHat(SDL_GameController *gamecontroller, int hat, Uint8 value) { int i; Uint8 last_mask = gamecontroller->last_hat_mask[hat]; Uint8 changed_mask = (last_mask ^ value); for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT && hat == binding->input.hat.hat) { if ((changed_mask & binding->input.hat.hat_mask) != 0) { if (value & binding->input.hat.hat_mask) { if (binding->outputType == SDL_CONTROLLER_BINDTYPE_AXIS) { SDL_PrivateGameControllerAxis(gamecontroller, binding->output.axis.axis, (Sint16)binding->output.axis.axis_max); } else { SDL_PrivateGameControllerButton(gamecontroller, binding->output.button, SDL_PRESSED); } } else { ResetOutput(gamecontroller, binding); } } } } gamecontroller->last_hat_mask[hat] = value; } /* * Event filter to fire controller events from joystick ones */ static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event * event) { switch(event->type) { case SDL_JOYAXISMOTION: { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { if (controllerlist->joystick->instance_id == event->jaxis.which) { HandleJoystickAxis(controllerlist, event->jaxis.axis, event->jaxis.value); break; } controllerlist = controllerlist->next; } } break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { if (controllerlist->joystick->instance_id == event->jbutton.which) { HandleJoystickButton(controllerlist, event->jbutton.button, event->jbutton.state); break; } controllerlist = controllerlist->next; } } break; case SDL_JOYHATMOTION: { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { if (controllerlist->joystick->instance_id == event->jhat.which) { HandleJoystickHat(controllerlist, event->jhat.hat, event->jhat.value); break; } controllerlist = controllerlist->next; } } break; case SDL_JOYDEVICEADDED: { if (SDL_IsGameController(event->jdevice.which)) { SDL_Event deviceevent; deviceevent.type = SDL_CONTROLLERDEVICEADDED; deviceevent.cdevice.which = event->jdevice.which; SDL_PushEvent(&deviceevent); } } break; case SDL_JOYDEVICEREMOVED: { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { if (controllerlist->joystick->instance_id == event->jdevice.which) { SDL_Event deviceevent; deviceevent.type = SDL_CONTROLLERDEVICEREMOVED; deviceevent.cdevice.which = event->jdevice.which; SDL_PushEvent(&deviceevent); UpdateEventsForDeviceRemoval(); break; } controllerlist = controllerlist->next; } } break; default: break; } return 1; } /* * Helper function to scan the mappings database for a controller with the specified GUID */ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *guid, SDL_bool exact_match) { ControllerMapping_t *pSupportedController = s_pSupportedControllers; while (pSupportedController) { if (SDL_memcmp(guid, &pSupportedController->guid, sizeof(*guid)) == 0) { return pSupportedController; } pSupportedController = pSupportedController->next; } if (!exact_match) { if (SDL_IsJoystickHIDAPI(*guid)) { /* This is a HIDAPI device */ return s_pHIDAPIMapping; } #if SDL_JOYSTICK_XINPUT if (SDL_IsJoystickXInput(*guid)) { /* This is an XInput device */ return s_pXInputMapping; } #endif } return NULL; } static const char* map_StringForControllerAxis[] = { "leftx", "lefty", "rightx", "righty", "lefttrigger", "righttrigger", NULL }; /* * convert a string to its enum equivalent */ SDL_GameControllerAxis SDL_GameControllerGetAxisFromString(const char *pchString) { int entry; if (pchString && (*pchString == '+' || *pchString == '-')) { ++pchString; } if (!pchString || !pchString[0]) { return SDL_CONTROLLER_AXIS_INVALID; } for (entry = 0; map_StringForControllerAxis[entry]; ++entry) { if (!SDL_strcasecmp(pchString, map_StringForControllerAxis[entry])) return (SDL_GameControllerAxis) entry; } return SDL_CONTROLLER_AXIS_INVALID; } /* * convert an enum to its string equivalent */ const char* SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis) { if (axis > SDL_CONTROLLER_AXIS_INVALID && axis < SDL_CONTROLLER_AXIS_MAX) { return map_StringForControllerAxis[axis]; } return NULL; } static const char* map_StringForControllerButton[] = { "a", "b", "x", "y", "back", "guide", "start", "leftstick", "rightstick", "leftshoulder", "rightshoulder", "dpup", "dpdown", "dpleft", "dpright", NULL }; /* * convert a string to its enum equivalent */ SDL_GameControllerButton SDL_GameControllerGetButtonFromString(const char *pchString) { int entry; if (!pchString || !pchString[0]) return SDL_CONTROLLER_BUTTON_INVALID; for (entry = 0; map_StringForControllerButton[entry]; ++entry) { if (SDL_strcasecmp(pchString, map_StringForControllerButton[entry]) == 0) return (SDL_GameControllerButton) entry; } return SDL_CONTROLLER_BUTTON_INVALID; } /* * convert an enum to its string equivalent */ const char* SDL_GameControllerGetStringForButton(SDL_GameControllerButton axis) { if (axis > SDL_CONTROLLER_BUTTON_INVALID && axis < SDL_CONTROLLER_BUTTON_MAX) { return map_StringForControllerButton[axis]; } return NULL; } /* * given a controller button name and a joystick name update our mapping structure with it */ static void SDL_PrivateGameControllerParseElement(SDL_GameController *gamecontroller, const char *szGameButton, const char *szJoystickButton) { SDL_ExtendedGameControllerBind bind; SDL_GameControllerButton button; SDL_GameControllerAxis axis; SDL_bool invert_input = SDL_FALSE; char half_axis_input = 0; char half_axis_output = 0; if (*szGameButton == '+' || *szGameButton == '-') { half_axis_output = *szGameButton++; } axis = SDL_GameControllerGetAxisFromString(szGameButton); button = SDL_GameControllerGetButtonFromString(szGameButton); if (axis != SDL_CONTROLLER_AXIS_INVALID) { bind.outputType = SDL_CONTROLLER_BINDTYPE_AXIS; bind.output.axis.axis = axis; if (axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT || axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) { bind.output.axis.axis_min = 0; bind.output.axis.axis_max = SDL_JOYSTICK_AXIS_MAX; } else { if (half_axis_output == '+') { bind.output.axis.axis_min = 0; bind.output.axis.axis_max = SDL_JOYSTICK_AXIS_MAX; } else if (half_axis_output == '-') { bind.output.axis.axis_min = 0; bind.output.axis.axis_max = SDL_JOYSTICK_AXIS_MIN; } else { bind.output.axis.axis_min = SDL_JOYSTICK_AXIS_MIN; bind.output.axis.axis_max = SDL_JOYSTICK_AXIS_MAX; } } } else if (button != SDL_CONTROLLER_BUTTON_INVALID) { bind.outputType = SDL_CONTROLLER_BINDTYPE_BUTTON; bind.output.button = button; } else { SDL_SetError("Unexpected controller element %s", szGameButton); return; } if (*szJoystickButton == '+' || *szJoystickButton == '-') { half_axis_input = *szJoystickButton++; } if (szJoystickButton[SDL_strlen(szJoystickButton) - 1] == '~') { invert_input = SDL_TRUE; } if (szJoystickButton[0] == 'a' && SDL_isdigit(szJoystickButton[1])) { bind.inputType = SDL_CONTROLLER_BINDTYPE_AXIS; bind.input.axis.axis = SDL_atoi(&szJoystickButton[1]); if (half_axis_input == '+') { bind.input.axis.axis_min = 0; bind.input.axis.axis_max = SDL_JOYSTICK_AXIS_MAX; } else if (half_axis_input == '-') { bind.input.axis.axis_min = 0; bind.input.axis.axis_max = SDL_JOYSTICK_AXIS_MIN; } else { bind.input.axis.axis_min = SDL_JOYSTICK_AXIS_MIN; bind.input.axis.axis_max = SDL_JOYSTICK_AXIS_MAX; } if (invert_input) { int tmp = bind.input.axis.axis_min; bind.input.axis.axis_min = bind.input.axis.axis_max; bind.input.axis.axis_max = tmp; } } else if (szJoystickButton[0] == 'b' && SDL_isdigit(szJoystickButton[1])) { bind.inputType = SDL_CONTROLLER_BINDTYPE_BUTTON; bind.input.button = SDL_atoi(&szJoystickButton[1]); } else if (szJoystickButton[0] == 'h' && SDL_isdigit(szJoystickButton[1]) && szJoystickButton[2] == '.' && SDL_isdigit(szJoystickButton[3])) { int hat = SDL_atoi(&szJoystickButton[1]); int mask = SDL_atoi(&szJoystickButton[3]); bind.inputType = SDL_CONTROLLER_BINDTYPE_HAT; bind.input.hat.hat = hat; bind.input.hat.hat_mask = mask; } else { SDL_SetError("Unexpected joystick element: %s", szJoystickButton); return; } ++gamecontroller->num_bindings; gamecontroller->bindings = (SDL_ExtendedGameControllerBind *)SDL_realloc(gamecontroller->bindings, gamecontroller->num_bindings * sizeof(*gamecontroller->bindings)); if (!gamecontroller->bindings) { gamecontroller->num_bindings = 0; SDL_OutOfMemory(); return; } gamecontroller->bindings[gamecontroller->num_bindings - 1] = bind; } /* * given a controller mapping string update our mapping object */ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameController *gamecontroller, const char *pchString) { char szGameButton[20]; char szJoystickButton[20]; SDL_bool bGameButton = SDL_TRUE; int i = 0; const char *pchPos = pchString; SDL_zero(szGameButton); SDL_zero(szJoystickButton); while (pchPos && *pchPos) { if (*pchPos == ':') { i = 0; bGameButton = SDL_FALSE; } else if (*pchPos == ' ') { } else if (*pchPos == ',') { i = 0; bGameButton = SDL_TRUE; SDL_PrivateGameControllerParseElement(gamecontroller, szGameButton, szJoystickButton); SDL_zero(szGameButton); SDL_zero(szJoystickButton); } else if (bGameButton) { if (i >= sizeof(szGameButton)) { SDL_SetError("Button name too large: %s", szGameButton); return; } szGameButton[i] = *pchPos; i++; } else { if (i >= sizeof(szJoystickButton)) { SDL_SetError("Joystick button name too large: %s", szJoystickButton); return; } szJoystickButton[i] = *pchPos; i++; } pchPos++; } SDL_PrivateGameControllerParseElement(gamecontroller, szGameButton, szJoystickButton); } /* * Make a new button mapping struct */ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, SDL_JoystickGUID guid, const char *pchName, const char *pchMapping) { int i; gamecontroller->guid = guid; gamecontroller->name = pchName; gamecontroller->num_bindings = 0; SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); SDL_PrivateGameControllerParseControllerConfigString(gamecontroller, pchMapping); /* Set the zero point for triggers */ for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS && binding->outputType == SDL_CONTROLLER_BINDTYPE_AXIS && (binding->output.axis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT || binding->output.axis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT)) { if (binding->input.axis.axis < gamecontroller->joystick->naxes) { gamecontroller->joystick->axes[binding->input.axis.axis].value = gamecontroller->joystick->axes[binding->input.axis.axis].zero = (Sint16)binding->input.axis.axis_min; } } } } /* * grab the guid string from a mapping string */ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) { const char *pFirstComma = SDL_strchr(pMapping, ','); if (pFirstComma) { char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1); if (!pchGUID) { SDL_OutOfMemory(); return NULL; } SDL_memcpy(pchGUID, pMapping, pFirstComma - pMapping); pchGUID[pFirstComma - pMapping] = '\0'; /* Convert old style GUIDs to the new style in 2.0.5 */ #if __WIN32__ if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[20], "504944564944", 12) == 0) { SDL_memcpy(&pchGUID[20], "000000000000", 12); SDL_memcpy(&pchGUID[16], &pchGUID[4], 4); SDL_memcpy(&pchGUID[8], &pchGUID[0], 4); SDL_memcpy(&pchGUID[0], "03000000", 8); } #elif __MACOSX__ if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[4], "000000000000", 12) == 0 && SDL_memcmp(&pchGUID[20], "000000000000", 12) == 0) { SDL_memcpy(&pchGUID[20], "000000000000", 12); SDL_memcpy(&pchGUID[8], &pchGUID[0], 4); SDL_memcpy(&pchGUID[0], "03000000", 8); } #endif return pchGUID; } return NULL; } /* * grab the name string from a mapping string */ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping) { const char *pFirstComma, *pSecondComma; char *pchName; pFirstComma = SDL_strchr(pMapping, ','); if (!pFirstComma) return NULL; pSecondComma = SDL_strchr(pFirstComma + 1, ','); if (!pSecondComma) return NULL; pchName = SDL_malloc(pSecondComma - pFirstComma); if (!pchName) { SDL_OutOfMemory(); return NULL; } SDL_memcpy(pchName, pFirstComma + 1, pSecondComma - pFirstComma); pchName[pSecondComma - pFirstComma - 1] = 0; return pchName; } /* * grab the button mapping string from a mapping string */ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMapping) { const char *pFirstComma, *pSecondComma; pFirstComma = SDL_strchr(pMapping, ','); if (!pFirstComma) return NULL; pSecondComma = SDL_strchr(pFirstComma + 1, ','); if (!pSecondComma) return NULL; return SDL_strdup(pSecondComma + 1); /* mapping is everything after the 3rd comma */ } /* * Helper function to refresh a mapping */ static void SDL_PrivateGameControllerRefreshMapping(ControllerMapping_t *pControllerMapping) { SDL_GameController *gamecontrollerlist = SDL_gamecontrollers; while (gamecontrollerlist) { if (!SDL_memcmp(&gamecontrollerlist->guid, &pControllerMapping->guid, sizeof(pControllerMapping->guid))) { SDL_Event event; event.type = SDL_CONTROLLERDEVICEREMAPPED; event.cdevice.which = gamecontrollerlist->joystick->instance_id; SDL_PushEvent(&event); /* Not really threadsafe. Should this lock access within SDL_GameControllerEventWatcher? */ SDL_PrivateLoadButtonMapping(gamecontrollerlist, pControllerMapping->guid, pControllerMapping->name, pControllerMapping->mapping); } gamecontrollerlist = gamecontrollerlist->next; } } /* * Helper function to add a mapping for a guid */ static ControllerMapping_t * SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority) { char *pchName; char *pchMapping; ControllerMapping_t *pControllerMapping; pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString); if (!pchName) { SDL_SetError("Couldn't parse name from %s", mappingString); return NULL; } pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString); if (!pchMapping) { SDL_free(pchName); SDL_SetError("Couldn't parse %s", mappingString); return NULL; } pControllerMapping = SDL_PrivateGetControllerMappingForGUID(&jGUID, SDL_TRUE); if (pControllerMapping) { /* Only overwrite the mapping if the priority is the same or higher. */ if (pControllerMapping->priority <= priority) { /* Update existing mapping */ SDL_free(pControllerMapping->name); pControllerMapping->name = pchName; SDL_free(pControllerMapping->mapping); pControllerMapping->mapping = pchMapping; pControllerMapping->priority = priority; /* refresh open controllers */ SDL_PrivateGameControllerRefreshMapping(pControllerMapping); } else { SDL_free(pchName); SDL_free(pchMapping); } *existing = SDL_TRUE; } else { pControllerMapping = SDL_malloc(sizeof(*pControllerMapping)); if (!pControllerMapping) { SDL_free(pchName); SDL_free(pchMapping); SDL_OutOfMemory(); return NULL; } pControllerMapping->guid = jGUID; pControllerMapping->name = pchName; pControllerMapping->mapping = pchMapping; pControllerMapping->next = NULL; pControllerMapping->priority = priority; if (s_pSupportedControllers) { /* Add the mapping to the end of the list */ ControllerMapping_t *pCurrMapping, *pPrevMapping; for ( pPrevMapping = s_pSupportedControllers, pCurrMapping = pPrevMapping->next; pCurrMapping; pPrevMapping = pCurrMapping, pCurrMapping = pCurrMapping->next ) { continue; } pPrevMapping->next = pControllerMapping; } else { s_pSupportedControllers = pControllerMapping; } *existing = SDL_FALSE; } return pControllerMapping; } #ifdef __ANDROID__ /* * Helper function to guess at a mapping based on the elements reported for this controller */ static ControllerMapping_t *SDL_CreateMappingForAndroidController(const char *name, SDL_JoystickGUID guid) { SDL_bool existing; char name_string[128]; char mapping_string[1024]; int button_mask; int axis_mask; button_mask = SDL_SwapLE16(*(Uint16*)(&guid.data[sizeof(guid.data)-4])); axis_mask = SDL_SwapLE16(*(Uint16*)(&guid.data[sizeof(guid.data)-2])); if (!button_mask && !axis_mask) { /* Accelerometer, shouldn't have a game controller mapping */ return NULL; } /* Remove any commas in the name */ SDL_strlcpy(name_string, name, sizeof(name_string)); { char *spot; for (spot = name_string; *spot; ++spot) { if (*spot == ',') { *spot = ' '; } } } SDL_snprintf(mapping_string, sizeof(mapping_string), "none,%s,", name_string); if (button_mask & (1 << SDL_CONTROLLER_BUTTON_A)) { SDL_strlcat(mapping_string, "a:b0,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_B)) { SDL_strlcat(mapping_string, "b:b1,", sizeof(mapping_string)); } else if (button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) { /* Use the back button as "B" for easy UI navigation with TV remotes */ SDL_strlcat(mapping_string, "b:b4,", sizeof(mapping_string)); button_mask &= ~(1 << SDL_CONTROLLER_BUTTON_BACK); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_X)) { SDL_strlcat(mapping_string, "x:b2,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_Y)) { SDL_strlcat(mapping_string, "y:b3,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) { SDL_strlcat(mapping_string, "back:b4,", sizeof(mapping_string)); } #if 0 /* The guide button generally isn't functional (or acts as a home button) on most Android controllers */ if (button_mask & (1 << SDL_CONTROLLER_BUTTON_GUIDE)) { SDL_strlcat(mapping_string, "guide:b5,", sizeof(mapping_string)); #if 0 /* Actually this will be done in Steam */ } else if (button_mask & (1 << SDL_CONTROLLER_BUTTON_START)) { /* The guide button doesn't exist, use the start button instead, so you can do Steam guide button chords and open the Steam overlay. */ SDL_strlcat(mapping_string, "guide:b6,", sizeof(mapping_string)); button_mask &= ~(1 << SDL_CONTROLLER_BUTTON_START); #endif } #endif if (button_mask & (1 << SDL_CONTROLLER_BUTTON_START)) { SDL_strlcat(mapping_string, "start:b6,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_LEFTSTICK)) { SDL_strlcat(mapping_string, "leftstick:b7,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_RIGHTSTICK)) { SDL_strlcat(mapping_string, "rightstick:b8,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_LEFTSHOULDER)) { SDL_strlcat(mapping_string, "leftshoulder:b9,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_RIGHTSHOULDER)) { SDL_strlcat(mapping_string, "rightshoulder:b10,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_DPAD_UP)) { SDL_strlcat(mapping_string, "dpup:b11,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_DPAD_DOWN)) { SDL_strlcat(mapping_string, "dpdown:b12,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_DPAD_LEFT)) { SDL_strlcat(mapping_string, "dpleft:b13,", sizeof(mapping_string)); } if (button_mask & (1 << SDL_CONTROLLER_BUTTON_DPAD_RIGHT)) { SDL_strlcat(mapping_string, "dpright:b14,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_LEFTX)) { SDL_strlcat(mapping_string, "leftx:a0,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_LEFTY)) { SDL_strlcat(mapping_string, "lefty:a1,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_RIGHTX)) { SDL_strlcat(mapping_string, "rightx:a2,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_RIGHTY)) { SDL_strlcat(mapping_string, "righty:a3,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_TRIGGERLEFT)) { SDL_strlcat(mapping_string, "lefttrigger:a4,", sizeof(mapping_string)); } if (axis_mask & (1 << SDL_CONTROLLER_AXIS_TRIGGERRIGHT)) { SDL_strlcat(mapping_string, "righttrigger:a5,", sizeof(mapping_string)); } return SDL_PrivateAddMappingForGUID(guid, mapping_string, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); } #endif /* __ANDROID__ */ /* * Helper function to determine pre-calculated offset to certain joystick mappings */ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const char *name, SDL_JoystickGUID guid) { ControllerMapping_t *mapping; mapping = SDL_PrivateGetControllerMappingForGUID(&guid, SDL_FALSE); #ifdef __LINUX__ if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ SDL_bool existing; mapping = SDL_PrivateAddMappingForGUID(guid, "none,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); } } #endif /* __LINUX__ */ if (!mapping && name) { if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box") || SDL_strstr(name, "XBOX")) { mapping = s_pXInputMapping; } } #ifdef __ANDROID__ if (!mapping && name && !SDL_IsJoystickHIDAPI(guid)) { mapping = SDL_CreateMappingForAndroidController(name, guid); } #endif if (!mapping) { mapping = s_pDefaultMapping; } return mapping; } static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) { const char *name; SDL_JoystickGUID guid; ControllerMapping_t *mapping; SDL_LockJoysticks(); if ((device_index < 0) || (device_index >= SDL_NumJoysticks())) { SDL_SetError("There are %d joysticks available", SDL_NumJoysticks()); SDL_UnlockJoysticks(); return (NULL); } name = SDL_JoystickNameForIndex(device_index); guid = SDL_JoystickGetDeviceGUID(device_index); mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); SDL_UnlockJoysticks(); return mapping; } /* * Add or update an entry into the Mappings Database */ int SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw) { const char *platform = SDL_GetPlatform(); int controllers = 0; char *buf, *line, *line_end, *tmp, *comma, line_platform[64]; size_t db_size, platform_len; if (rw == NULL) { return SDL_SetError("Invalid RWops"); } db_size = (size_t)SDL_RWsize(rw); buf = (char *)SDL_malloc(db_size + 1); if (buf == NULL) { if (freerw) { SDL_RWclose(rw); } return SDL_SetError("Could not allocate space to read DB into memory"); } if (SDL_RWread(rw, buf, db_size, 1) != 1) { if (freerw) { SDL_RWclose(rw); } SDL_free(buf); return SDL_SetError("Could not read DB"); } if (freerw) { SDL_RWclose(rw); } buf[db_size] = '\0'; line = buf; while (line < buf + db_size) { line_end = SDL_strchr(line, '\n'); if (line_end != NULL) { *line_end = '\0'; } else { line_end = buf + db_size; } /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_CONTROLLER_PLATFORM_FIELD); if (tmp != NULL) { tmp += SDL_strlen(SDL_CONTROLLER_PLATFORM_FIELD); comma = SDL_strchr(tmp, ','); if (comma != NULL) { platform_len = comma - tmp + 1; if (platform_len + 1 < SDL_arraysize(line_platform)) { SDL_strlcpy(line_platform, tmp, platform_len); if (SDL_strncasecmp(line_platform, platform, platform_len) == 0 && SDL_GameControllerAddMapping(line) > 0) { controllers++; } } } } line = line_end + 1; } SDL_free(buf); return controllers; } /* * Add or update an entry into the Mappings Database with a priority */ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_ControllerMappingPriority priority) { char *pchGUID; SDL_JoystickGUID jGUID; SDL_bool is_default_mapping = SDL_FALSE; SDL_bool is_hidapi_mapping = SDL_FALSE; SDL_bool is_xinput_mapping = SDL_FALSE; SDL_bool existing = SDL_FALSE; ControllerMapping_t *pControllerMapping; if (!mappingString) { return SDL_InvalidParamError("mappingString"); } pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString); if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } if (!SDL_strcasecmp(pchGUID, "default")) { is_default_mapping = SDL_TRUE; } else if (!SDL_strcasecmp(pchGUID, "hidapi")) { is_hidapi_mapping = SDL_TRUE; } else if (!SDL_strcasecmp(pchGUID, "xinput")) { is_xinput_mapping = SDL_TRUE; } jGUID = SDL_JoystickGetGUIDFromString(pchGUID); SDL_free(pchGUID); pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); if (!pControllerMapping) { return -1; } if (existing) { return 0; } else { if (is_default_mapping) { s_pDefaultMapping = pControllerMapping; } else if (is_hidapi_mapping) { s_pHIDAPIMapping = pControllerMapping; } else if (is_xinput_mapping) { s_pXInputMapping = pControllerMapping; } return 1; } } /* * Add or update an entry into the Mappings Database */ int SDL_GameControllerAddMapping(const char *mappingString) { return SDL_PrivateGameControllerAddMapping(mappingString, SDL_CONTROLLER_MAPPING_PRIORITY_API); } /* * Get the number of mappings installed */ int SDL_GameControllerNumMappings(void) { int num_mappings = 0; ControllerMapping_t *mapping; for (mapping = s_pSupportedControllers; mapping; mapping = mapping->next) { if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) { continue; } ++num_mappings; } return num_mappings; } /* * Get the mapping at a particular index. */ char * SDL_GameControllerMappingForIndex(int mapping_index) { ControllerMapping_t *mapping; for (mapping = s_pSupportedControllers; mapping; mapping = mapping->next) { if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) { continue; } if (mapping_index == 0) { char *pMappingString; char pchGUID[33]; size_t needed; SDL_JoystickGetGUIDString(mapping->guid, pchGUID, sizeof(pchGUID)); /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; pMappingString = SDL_malloc(needed); if (!pMappingString) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); return pMappingString; } --mapping_index; } return NULL; } /* * Get the mapping string for this GUID */ char * SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid) { char *pMappingString = NULL; ControllerMapping_t *mapping = SDL_PrivateGetControllerMappingForGUID(&guid, SDL_FALSE); if (mapping) { char pchGUID[33]; size_t needed; SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; pMappingString = SDL_malloc(needed); if (!pMappingString) { SDL_OutOfMemory(); return NULL; } SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } return pMappingString; } /* * Get the mapping string for this device */ char * SDL_GameControllerMapping(SDL_GameController * gamecontroller) { if (!gamecontroller) { return NULL; } return SDL_GameControllerMappingForGUID(gamecontroller->guid); } static void SDL_GameControllerLoadHints() { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG); if (hint && hint[0]) { size_t nchHints = SDL_strlen(hint); char *pUserMappings = SDL_malloc(nchHints + 1); char *pTempMappings = pUserMappings; SDL_memcpy(pUserMappings, hint, nchHints); pUserMappings[nchHints] = '\0'; while (pUserMappings) { char *pchNewLine = NULL; pchNewLine = SDL_strchr(pUserMappings, '\n'); if (pchNewLine) *pchNewLine = '\0'; SDL_PrivateGameControllerAddMapping(pUserMappings, SDL_CONTROLLER_MAPPING_PRIORITY_USER); if (pchNewLine) { pUserMappings = pchNewLine + 1; } else { pUserMappings = NULL; } } SDL_free(pTempMappings); } } /* * Fill the given buffer with the expected controller mapping filepath. * Usually this will just be CONTROLLER_MAPPING_FILE, but for Android, * we want to get the internal storage path. */ static SDL_bool SDL_GetControllerMappingFilePath(char *path, size_t size) { #ifdef CONTROLLER_MAPPING_FILE #define STRING(X) SDL_STRINGIFY_ARG(X) return SDL_strlcpy(path, STRING(CONTROLLER_MAPPING_FILE), size) < size; #elif defined(__ANDROID__) return SDL_snprintf(path, size, "%s/controller_map.txt", SDL_AndroidGetInternalStoragePath()) < size; #else return SDL_FALSE; #endif } /* * Initialize the game controller system, mostly load our DB of controller config mappings */ int SDL_GameControllerInitMappings(void) { char szControllerMapPath[1024]; int i = 0; const char *pMappingString = NULL; pMappingString = s_ControllerMappings[i]; while (pMappingString) { SDL_PrivateGameControllerAddMapping(pMappingString, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); i++; pMappingString = s_ControllerMappings[i]; } if (SDL_GetControllerMappingFilePath(szControllerMapPath, sizeof(szControllerMapPath))) { SDL_GameControllerAddMappingsFromFile(szControllerMapPath); } /* load in any user supplied config */ SDL_GameControllerLoadHints(); SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, SDL_GameControllerIgnoreDevicesChanged, NULL); SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, SDL_GameControllerIgnoreDevicesExceptChanged, NULL); return (0); } int SDL_GameControllerInit(void) { int i; /* watch for joy events and fire controller ones if needed */ SDL_AddEventWatch(SDL_GameControllerEventWatcher, NULL); /* Send added events for controllers currently attached */ for (i = 0; i < SDL_NumJoysticks(); ++i) { if (SDL_IsGameController(i)) { SDL_Event deviceevent; deviceevent.type = SDL_CONTROLLERDEVICEADDED; deviceevent.cdevice.which = i; SDL_PushEvent(&deviceevent); } } return (0); } /* * Get the implementation dependent name of a controller */ const char * SDL_GameControllerNameForIndex(int device_index) { ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); if (pSupportedController) { if (SDL_strcmp(pSupportedController->name, "*") == 0) { return SDL_JoystickNameForIndex(device_index); } else { return pSupportedController->name; } } return NULL; } /** * Get the mapping of a game controller. * This can be called before any controllers are opened. * If no mapping can be found, this function returns NULL. */ char * SDL_GameControllerMappingForDeviceIndex(int joystick_index) { char *pMappingString = NULL; ControllerMapping_t *mapping; SDL_LockJoysticks(); mapping = SDL_PrivateGetControllerMapping(joystick_index); if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; guid = SDL_JoystickGetDeviceGUID(joystick_index); SDL_JoystickGetGUIDString(guid, pchGUID, sizeof(pchGUID)); /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; pMappingString = SDL_malloc(needed); if (!pMappingString) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; } SDL_snprintf(pMappingString, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } SDL_UnlockJoysticks(); return pMappingString; } /* * Return 1 if the joystick with this name and GUID is a supported controller */ SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid) { ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); if (pSupportedController) { return SDL_TRUE; } return SDL_FALSE; } /* * Return 1 if the joystick at this device index is a supported controller */ SDL_bool SDL_IsGameController(int device_index) { ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index); if (pSupportedController) { return SDL_TRUE; } return SDL_FALSE; } /* * Return 1 if the game controller should be ignored by SDL */ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid) { int i; Uint16 vendor; Uint16 product; Uint16 version; Uint32 vidpid; if (SDL_allowed_controllers.num_entries == 0 && SDL_ignored_controllers.num_entries == 0) { return SDL_FALSE; } SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version); if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) { /* We shouldn't ignore Steam's virtual gamepad since it's using the hints to filter out the real controllers so it can remap input for the virtual controller */ SDL_bool bSteamVirtualGamepad = SDL_FALSE; #if defined(__LINUX__) bSteamVirtualGamepad = (vendor == 0x28DE && product == 0x11FF); #elif defined(__MACOSX__) bSteamVirtualGamepad = (vendor == 0x045E && product == 0x028E && version == 1); #elif defined(__WIN32__) /* We can't tell on Windows, but Steam will block others in input hooks */ bSteamVirtualGamepad = SDL_TRUE; #endif if (bSteamVirtualGamepad) { return SDL_FALSE; } } vidpid = MAKE_VIDPID(vendor, product); if (SDL_allowed_controllers.num_entries > 0) { for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) { if (vidpid == SDL_allowed_controllers.entries[i]) { return SDL_FALSE; } } return SDL_TRUE; } else { for (i = 0; i < SDL_ignored_controllers.num_entries; ++i) { if (vidpid == SDL_ignored_controllers.entries[i]) { return SDL_TRUE; } } return SDL_FALSE; } } /* * Open a controller for use - the index passed as an argument refers to * the N'th controller on the system. This index is the value which will * identify this controller in future controller events. * * This function returns a controller identifier, or NULL if an error occurred. */ SDL_GameController * SDL_GameControllerOpen(int device_index) { SDL_JoystickID instance_id; SDL_GameController *gamecontroller; SDL_GameController *gamecontrollerlist; ControllerMapping_t *pSupportedController = NULL; SDL_LockJoysticks(); gamecontrollerlist = SDL_gamecontrollers; /* If the controller is already open, return it */ instance_id = SDL_JoystickGetDeviceInstanceID(device_index); while (gamecontrollerlist) { if (instance_id == gamecontrollerlist->joystick->instance_id) { gamecontroller = gamecontrollerlist; ++gamecontroller->ref_count; SDL_UnlockJoysticks(); return (gamecontroller); } gamecontrollerlist = gamecontrollerlist->next; } /* Find a controller mapping */ pSupportedController = SDL_PrivateGetControllerMapping(device_index); if (!pSupportedController) { SDL_SetError("Couldn't find mapping for device (%d)", device_index); SDL_UnlockJoysticks(); return NULL; } /* Create and initialize the controller */ gamecontroller = (SDL_GameController *) SDL_calloc(1, sizeof(*gamecontroller)); if (gamecontroller == NULL) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; } gamecontroller->joystick = SDL_JoystickOpen(device_index); if (!gamecontroller->joystick) { SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; } if (gamecontroller->joystick->naxes) { gamecontroller->last_match_axis = (SDL_ExtendedGameControllerBind **)SDL_calloc(gamecontroller->joystick->naxes, sizeof(*gamecontroller->last_match_axis)); if (!gamecontroller->last_match_axis) { SDL_OutOfMemory(); SDL_JoystickClose(gamecontroller->joystick); SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; } } if (gamecontroller->joystick->nhats) { gamecontroller->last_hat_mask = (Uint8 *)SDL_calloc(gamecontroller->joystick->nhats, sizeof(*gamecontroller->last_hat_mask)); if (!gamecontroller->last_hat_mask) { SDL_OutOfMemory(); SDL_JoystickClose(gamecontroller->joystick); SDL_free(gamecontroller->last_match_axis); SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; } } SDL_PrivateLoadButtonMapping(gamecontroller, pSupportedController->guid, pSupportedController->name, pSupportedController->mapping); /* Add the controller to list */ ++gamecontroller->ref_count; /* Link the controller in the list */ gamecontroller->next = SDL_gamecontrollers; SDL_gamecontrollers = gamecontroller; SDL_UnlockJoysticks(); return (gamecontroller); } /* * Manually pump for controller updates. */ void SDL_GameControllerUpdate(void) { /* Just for API completeness; the joystick API does all the work. */ SDL_JoystickUpdate(); } /* * Get the current state of an axis control on a controller */ Sint16 SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis) { int i; if (!gamecontroller) return 0; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->outputType == SDL_CONTROLLER_BINDTYPE_AXIS && binding->output.axis.axis == axis) { int value = 0; SDL_bool valid_input_range; SDL_bool valid_output_range; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS) { value = SDL_JoystickGetAxis(gamecontroller->joystick, binding->input.axis.axis); if (binding->input.axis.axis_min < binding->input.axis.axis_max) { valid_input_range = (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max); } else { valid_input_range = (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min); } if (valid_input_range) { if (binding->input.axis.axis_min != binding->output.axis.axis_min || binding->input.axis.axis_max != binding->output.axis.axis_max) { float normalized_value = (float)(value - binding->input.axis.axis_min) / (binding->input.axis.axis_max - binding->input.axis.axis_min); value = binding->output.axis.axis_min + (int)(normalized_value * (binding->output.axis.axis_max - binding->output.axis.axis_min)); } } } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) { value = SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button); if (value == SDL_PRESSED) { value = binding->output.axis.axis_max; } } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) { int hat_mask = SDL_JoystickGetHat(gamecontroller->joystick, binding->input.hat.hat); if (hat_mask & binding->input.hat.hat_mask) { value = binding->output.axis.axis_max; } } if (binding->output.axis.axis_min < binding->output.axis.axis_max) { valid_output_range = (value >= binding->output.axis.axis_min && value <= binding->output.axis.axis_max); } else { valid_output_range = (value >= binding->output.axis.axis_max && value <= binding->output.axis.axis_min); } /* If the value is zero, there might be another binding that makes it non-zero */ if (value != 0 && valid_output_range) { return (Sint16)value; } } } return 0; } /* * Get the current state of a button on a controller */ Uint8 SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button) { int i; if (!gamecontroller) return 0; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->outputType == SDL_CONTROLLER_BINDTYPE_BUTTON && binding->output.button == button) { if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS) { SDL_bool valid_input_range; int value = SDL_JoystickGetAxis(gamecontroller->joystick, binding->input.axis.axis); int threshold = binding->input.axis.axis_min + (binding->input.axis.axis_max - binding->input.axis.axis_min) / 2; if (binding->input.axis.axis_min < binding->input.axis.axis_max) { valid_input_range = (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max); if (valid_input_range) { return (value >= threshold) ? SDL_PRESSED : SDL_RELEASED; } } else { valid_input_range = (value >= binding->input.axis.axis_max && value <= binding->input.axis.axis_min); if (valid_input_range) { return (value <= threshold) ? SDL_PRESSED : SDL_RELEASED; } } } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) { return SDL_JoystickGetButton(gamecontroller->joystick, binding->input.button); } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) { int hat_mask = SDL_JoystickGetHat(gamecontroller->joystick, binding->input.hat.hat); return (hat_mask & binding->input.hat.hat_mask) ? SDL_PRESSED : SDL_RELEASED; } } } return SDL_RELEASED; } const char * SDL_GameControllerName(SDL_GameController * gamecontroller) { if (!gamecontroller) return NULL; if (SDL_strcmp(gamecontroller->name, "*") == 0) { return SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller)); } else { return gamecontroller->name; } } Uint16 SDL_GameControllerGetVendor(SDL_GameController * gamecontroller) { return SDL_JoystickGetVendor(SDL_GameControllerGetJoystick(gamecontroller)); } Uint16 SDL_GameControllerGetProduct(SDL_GameController * gamecontroller) { return SDL_JoystickGetProduct(SDL_GameControllerGetJoystick(gamecontroller)); } Uint16 SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller) { return SDL_JoystickGetProductVersion(SDL_GameControllerGetJoystick(gamecontroller)); } /* * Return if the controller in question is currently attached to the system, * \return 0 if not plugged in, 1 if still present. */ SDL_bool SDL_GameControllerGetAttached(SDL_GameController * gamecontroller) { if (!gamecontroller) return SDL_FALSE; return SDL_JoystickGetAttached(gamecontroller->joystick); } /* * Get the joystick for this controller */ SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller) { if (!gamecontroller) return NULL; return gamecontroller->joystick; } /* * Find the SDL_GameController that owns this instance id */ SDL_GameController * SDL_GameControllerFromInstanceID(SDL_JoystickID joyid) { SDL_GameController *gamecontroller; SDL_LockJoysticks(); gamecontroller = SDL_gamecontrollers; while (gamecontroller) { if (gamecontroller->joystick->instance_id == joyid) { SDL_UnlockJoysticks(); return gamecontroller; } gamecontroller = gamecontroller->next; } SDL_UnlockJoysticks(); return NULL; } /* * Get the SDL joystick layer binding for this controller axis mapping */ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis) { int i; SDL_GameControllerButtonBind bind; SDL_zero(bind); if (!gamecontroller || axis == SDL_CONTROLLER_AXIS_INVALID) return bind; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->outputType == SDL_CONTROLLER_BINDTYPE_AXIS && binding->output.axis.axis == axis) { bind.bindType = binding->inputType; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS) { /* FIXME: There might be multiple axes bound now that we have axis ranges... */ bind.value.axis = binding->input.axis.axis; } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) { bind.value.button = binding->input.button; } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) { bind.value.hat.hat = binding->input.hat.hat; bind.value.hat.hat_mask = binding->input.hat.hat_mask; } break; } } return bind; } /* * Get the SDL joystick layer binding for this controller button mapping */ SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button) { int i; SDL_GameControllerButtonBind bind; SDL_zero(bind); if (!gamecontroller || button == SDL_CONTROLLER_BUTTON_INVALID) return bind; for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; if (binding->outputType == SDL_CONTROLLER_BINDTYPE_BUTTON && binding->output.button == button) { bind.bindType = binding->inputType; if (binding->inputType == SDL_CONTROLLER_BINDTYPE_AXIS) { bind.value.axis = binding->input.axis.axis; } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_BUTTON) { bind.value.button = binding->input.button; } else if (binding->inputType == SDL_CONTROLLER_BINDTYPE_HAT) { bind.value.hat.hat = binding->input.hat.hat; bind.value.hat.hat_mask = binding->input.hat.hat_mask; } break; } } return bind; } int SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { return SDL_JoystickRumble(SDL_GameControllerGetJoystick(gamecontroller), low_frequency_rumble, high_frequency_rumble, duration_ms); } void SDL_GameControllerClose(SDL_GameController * gamecontroller) { SDL_GameController *gamecontrollerlist, *gamecontrollerlistprev; if (!gamecontroller) return; SDL_LockJoysticks(); /* First decrement ref count */ if (--gamecontroller->ref_count > 0) { SDL_UnlockJoysticks(); return; } SDL_JoystickClose(gamecontroller->joystick); gamecontrollerlist = SDL_gamecontrollers; gamecontrollerlistprev = NULL; while (gamecontrollerlist) { if (gamecontroller == gamecontrollerlist) { if (gamecontrollerlistprev) { /* unlink this entry */ gamecontrollerlistprev->next = gamecontrollerlist->next; } else { SDL_gamecontrollers = gamecontroller->next; } break; } gamecontrollerlistprev = gamecontrollerlist; gamecontrollerlist = gamecontrollerlist->next; } SDL_free(gamecontroller->bindings); SDL_free(gamecontroller->last_match_axis); SDL_free(gamecontroller->last_hat_mask); SDL_free(gamecontroller); SDL_UnlockJoysticks(); } /* * Quit the controller subsystem */ void SDL_GameControllerQuit(void) { SDL_LockJoysticks(); while (SDL_gamecontrollers) { SDL_gamecontrollers->ref_count = 1; SDL_GameControllerClose(SDL_gamecontrollers); } SDL_UnlockJoysticks(); } void SDL_GameControllerQuitMappings(void) { ControllerMapping_t *pControllerMap; while (s_pSupportedControllers) { pControllerMap = s_pSupportedControllers; s_pSupportedControllers = s_pSupportedControllers->next; SDL_free(pControllerMap->name); SDL_free(pControllerMap->mapping); SDL_free(pControllerMap); } SDL_DelEventWatch(SDL_GameControllerEventWatcher, NULL); SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, SDL_GameControllerIgnoreDevicesChanged, NULL); SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, SDL_GameControllerIgnoreDevicesExceptChanged, NULL); if (SDL_allowed_controllers.entries) { SDL_free(SDL_allowed_controllers.entries); SDL_zero(SDL_allowed_controllers); } if (SDL_ignored_controllers.entries) { SDL_free(SDL_ignored_controllers.entries); SDL_zero(SDL_ignored_controllers); } } /* * Event filter to transform joystick events into appropriate game controller ones */ static int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value) { int posted; /* translate the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_CONTROLLERAXISMOTION) == SDL_ENABLE) { SDL_Event event; event.type = SDL_CONTROLLERAXISMOTION; event.caxis.which = gamecontroller->joystick->instance_id; event.caxis.axis = axis; event.caxis.value = value; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return (posted); } /* * Event filter to transform joystick events into appropriate game controller ones */ static int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state) { int posted; #if !SDL_EVENTS_DISABLED SDL_Event event; if (button == SDL_CONTROLLER_BUTTON_INVALID) return (0); switch (state) { case SDL_PRESSED: event.type = SDL_CONTROLLERBUTTONDOWN; break; case SDL_RELEASED: event.type = SDL_CONTROLLERBUTTONUP; break; default: /* Invalid state -- bail */ return (0); } #endif /* !SDL_EVENTS_DISABLED */ if (button == SDL_CONTROLLER_BUTTON_GUIDE) { Uint32 now = SDL_GetTicks(); if (state == SDL_PRESSED) { gamecontroller->guide_button_down = now; if (gamecontroller->joystick->delayed_guide_button) { /* Skip duplicate press */ return (0); } } else { if (!SDL_TICKS_PASSED(now, gamecontroller->guide_button_down+SDL_MINIMUM_GUIDE_BUTTON_DELAY_MS) && !gamecontroller->joystick->force_recentering) { gamecontroller->joystick->delayed_guide_button = SDL_TRUE; return (0); } gamecontroller->joystick->delayed_guide_button = SDL_FALSE; } } /* translate the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.cbutton.which = gamecontroller->joystick->instance_id; event.cbutton.button = button; event.cbutton.state = state; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return (posted); } /* * Turn off controller events */ int SDL_GameControllerEventState(int state) { #if SDL_EVENTS_DISABLED return SDL_IGNORE; #else const Uint32 event_list[] = { SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED, }; unsigned int i; switch (state) { case SDL_QUERY: state = SDL_IGNORE; for (i = 0; i < SDL_arraysize(event_list); ++i) { state = SDL_EventState(event_list[i], SDL_QUERY); if (state == SDL_ENABLE) { break; } } break; default: for (i = 0; i < SDL_arraysize(event_list); ++i) { SDL_EventState(event_list[i], state); } break; } return (state); #endif /* SDL_EVENTS_DISABLED */ } void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick) { SDL_GameController *controllerlist = SDL_gamecontrollers; while (controllerlist) { if (controllerlist->joystick == joystick) { SDL_PrivateGameControllerButton(controllerlist, SDL_CONTROLLER_BUTTON_GUIDE, SDL_RELEASED); break; } controllerlist = controllerlist->next; } } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\SDL_gamecontrollerdb.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Default mappings we support The easiest way to generate a new mapping is to start Steam in Big Picture mode, configure your joystick and then look in config/config.vdf in your Steam installation directory for the "SDL_GamepadBind" entry. Alternatively, you can use the app located in test/controllermap */ static const char *s_ControllerMappings [] = { #if SDL_JOYSTICK_XINPUT "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", #endif #if SDL_JOYSTICK_DINPUT "03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,", "03000000022000000090000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,", "03000000203800000900000000000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,", "03000000c82d00000060000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,", "03000000c82d00000061000000000000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,", "03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,", "03000000a00500003232000000000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,", "03000000c82d00002038000000000000,8bitdo,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,", "030000008f0e00001200000000000000,Acme GA-02,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,", "03000000fa190000f0ff000000000000,Acteck AGJ-3200,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00000263000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00001101000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00001401000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00001402000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00001901000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00001a01000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d62000001d57000000000000,Airflo PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d81d00000b00000000000000,BUFFALO BSGP1601 Series ,a:b5,b:b3,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b13,x:b4,y:b2,", "03000000d6200000e557000000000000,Batarang,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000c01100001352000000000000,Battalife Joystick,a:b6,b:b7,back:b2,leftshoulder:b0,leftx:a0,lefty:a1,rightshoulder:b1,start:b3,x:b4,y:b5,", "030000006f0e00003201000000000000,Battlefield 4 PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000bc2000006012000000000000,Betop 2126F,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000bc2000000055000000000000,Betop BFM Gamepad,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000bc2000006312000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000bc2000006412000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000c01100000555000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000c01100000655000000000000,Betop Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000790000000700000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "03000000808300000300000000000000,Betop Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "030000006b1400000055000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000006b1400000103000000000000,Bigben PS3 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,", "0300000066f700000500000000000000,BrutalLegendTest,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,", "03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,", "03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000451300000830000000000000,Defender Game Racer X7,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,", "030000006f0e00003001000000000000,EA SPORTS PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000341a00000108000000000000,EXEQ RF USB Gamepad 8206,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000008f0e00000f31000000000000,EXEQ,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,", "03000000b80500000410000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,", "03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,", "03000000852100000201000000000000,FF-GP1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00008500000000000000,Fighting Commander 2016 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00008400000000000000,Fighting Commander 5,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00008700000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00008800000000000000,Fighting Stick mini 4,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,", "78696e70757403000000000000000000,Fightstick TES,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,", "03000000790000000600000000000000,G-Shark GS-GP702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000790000002201000000000000,Game Controller for PC,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "0300000066f700000100000000000000,Game VIB Joystick,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,start:b11,x:b0,y:b1,", "03000000280400000140000000000000,GamePad Pro USB,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000ac0500003d03000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000ac0500004d04000000000000,GameSir,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000260900002625000000000000,Gamecube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,lefttrigger:a4,leftx:a0,lefty:a1,righttrigger:a5,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "030000005c1a00003330000000000000,Genius MaxFire Grandias 12V,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,", "030000008305000031b0000000000000,Genius Maxfire Blaze 3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000451300000010000000000000,Genius Maxfire Grandias 12,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000008305000009a0000000000000,Genius,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000f025000021c1000000000000,Gioteck PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000f0250000c383000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000f0250000c483000000000000,Gioteck VX2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000f0250000c283000000000000,Gioteck,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000632500002605000000000000,HJD-X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "030000000d0f00006e00000000000000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00006600000000000000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f0000ee00000000000000,HORIPAD mini4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000250900000017000000000000,HRAP2 on PS/SS/N64 Joypad to USB BOX,a:b2,b:b1,back:b9,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b8,x:b3,y:b0,", "03000000341a00000302000000000000,Hama Scorpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00004900000000000000,Hatsune Miku Sho Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d81400000862000000000000,HitBox Edition Cthulhu+,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,", "030000000d0f00005f00000000000000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005e00000000000000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00004000000000000000,Hori Fighting Stick Mini 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b4,rightshoulder:b7,righttrigger:b6,start:b9,x:b0,y:b3,", "030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,", "030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000ac0500002c02000000000000,IPEGA,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b8,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000b50700001403000000000000,Impact Black,a:b2,b:b3,back:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "03000000491900000204000000000000,Ipega PG-9023,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "030000006e0500000520000000000000,JC-P301U,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,", "030000006e0500000320000000000000,JC-U3613M (DInput),a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,", "030000006e0500000720000000000000,JC-W01U,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b1,", "03000000790000000200000000000000,King PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "030000006d040000d1ca000000000000,Logitech ChillStream,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d040000d2ca000000000000,Logitech Cordless Precision,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000011c2000000000000,Logitech Cordless Wingman,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b5,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b2,righttrigger:b7,rightx:a3,righty:a4,x:b4,", "030000006d04000016c2000000000000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ "03000000380700008081000000000000,MADCATZ SFV Arcade FightStick Alpha PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700006382000000000000,MLG GamePad PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000250900006688000000000000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "03000000380700006652000000000000,Mad Catz C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,", "03000000380700005032000000000000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700005082000000000000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700008433000000000000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008483000000000000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700008134000000000000,Mad Catz FightStick TE2+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b7,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b4,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008184000000000000,Mad Catz FightStick TE2+ PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,leftstick:b10,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b4,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700006252000000000000,Mad Catz Micro C.T.R.L.R,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,", "03000000380700008034000000000000,Mad Catz TE2 PS3 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008084000000000000,Mad Catz TE2 PS4 Fightstick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700001888000000000000,MadCatz SFIV FightStick PS3,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b5,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b4,righttrigger:b6,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000380700008532000000000000,Madcatz Arcade Fightstick TE S PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700003888000000000000,Madcatz Arcade Fightstick TE S+ PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000002a0600001024000000000000,Matricom,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "03000000250900000128000000000000,Mayflash Arcade Stick,a:b1,b:b2,back:b8,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b5,y:b6,", "03000000790000004318000000000000,Mayflash GameCube Controller Adapter,a:b1,b:b2,back:b0,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b0,leftshoulder:b4,leftstick:b0,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b0,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", "03000000790000004418000000000000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", "030000008f0e00001030000000000000,Mayflash USB Adapter for original Sega Saturn controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b5,rightshoulder:b2,righttrigger:b7,start:b9,x:b3,y:b4,", "0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,", "03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000efbe0000edfe000000000000,Monect Virtual Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b0,", "030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,", "03000000152000000182000000000000,NGDS,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,", "030000004b120000014d000000000000,NYKO AIRFLO,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:a3,leftstick:a0,lefttrigger:b6,rightshoulder:b5,rightstick:a2,righttrigger:b7,start:b9,x:b2,y:b3,", "03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,", "030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,", "03000000d62000006d57000000000000,OPP PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000362800000100000000000000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a3,righty:a4,x:b1,y:b2,", "03000000782300000a10000000000000,Onlive Wireless Controller,a:b15,b:b14,back:b7,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b11,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b13,y:b12,", "030000006b14000001a1000000000000,Orange Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,", "03000000120c0000f60e000000000000,P4 Wired Gamepad,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b7,rightshoulder:b4,righttrigger:b6,start:b9,x:b0,y:b3,", "03000000632500002306000000000000,PS Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000e30500009605000000000000,PS to USB convert cable,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "03000000100800000100000000000000,PS1 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "030000008f0e00007530000000000000,PS1 Controller,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b1,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000100800000300000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,", "03000000250900008888000000000000,PS2 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "03000000666600006706000000000000,PS2 Controller,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,", "030000006b1400000303000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000009d0d00001330000000000000,PS2 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000250900000500000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,", "030000004c0500006802000000000000,PS3 Controller,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b10,lefttrigger:a3~,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:a4~,rightx:a2,righty:a5,start:b8,x:b3,y:b0,", "03000000632500007505000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,", "030000008f0e00001431000000000000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000003807000056a8000000000000,PS3 RF pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000100000008200000000000000,PS360+ v1.66,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:h0.4,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000004c050000a00b000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000cc09000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000d62000006dca000000000000,PowerA Pro Ex,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d62000009557000000000000,Pro Elite PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d62000009f31000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000d6200000c757000000000000,Pro Ex mini PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000020000000000000,QANBA DRONE ARCADE JOYSTICK,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,", "03000000300f00000011000000000000,QanBa Arcade JoyStick 1008,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b10,x:b0,y:b3,", "03000000300f00001611000000000000,QanBa Arcade JoyStick 4018,a:b1,b:b2,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b8,x:b0,y:b3,", "03000000300f00001210000000000000,QanBa Joystick Plus,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b2,y:b3,", "03000000341a00000104000000000000,QanBa Joystick Q4RAF,a:b5,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b0,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b3,righttrigger:b7,start:b9,x:b1,y:b2,", "03000000222c00000223000000000000,Qanba Obsidian Arcade Joystick PS3 Mode,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000023000000000000,Qanba Obsidian Arcade Joystick PS4 Mode,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00001100000000000000,REAL ARCADE PRO.3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00007000000000000000,REAL ARCADE PRO.4 VLX,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,rightshoulder:b5,rightstick:b11,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00002200000000000000,REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000321500000204000000000000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000321500000104000000000000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00006a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00006b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00008a00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00008b00000000000000,Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005b00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00005c00000000000000,Real Arcade Pro.V4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "0300000000f000000300000000000000,RetroUSB.com RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,", "0300000000f00000f100000000000000,RetroUSB.com Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,", "03000000790000001100000000000000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,", "030000006b140000010d000000000000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000006f0e00001e01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00002801000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00002f01000000000000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,", "03000000341a00000908000000000000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000790000001c18000000000000,STK-7024X,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,", "03000000a306000023f6000000000000,Saitek Cyborg V.1 Game pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000a30600001af5000000000000,Saitek Cyborg,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,", "03000000300f00001201000000000000,Saitek Dual Analog Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "03000000a30600000cff000000000000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,x:b0,y:b1,", "03000000a30600000c04000000000000,Saitek P2900,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,", "03000000300f00001001000000000000,Saitek P480 Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,", "03000000a30600000b04000000000000,Saitek P990,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b3,", "03000000a30600002106000000000000,Saitek PS1000,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000a306000020f6000000000000,Saitek PS2700,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,", "030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,", "030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000c01100000591000000000000,Speedlink Torid,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000381000001814000000000000,SteelSeries Stratus XL,a:b0,b:b1,back:b18,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b19,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b2,y:b3,", "03000000110100001914000000000000,SteelSeries,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:,leftstick:b13,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:,rightstick:b14,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000d620000011a7000000000000,Switch,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000004f04000007d0000000000000,T Mini Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000fa1900000706000000000000,Team 5,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000b50700001203000000000000,Techmobility X6-38V,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "030000004f04000015b3000000000000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,", "030000004f04000023b3000000000000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004f04000004b3000000000000,Thrustmaster Firestorm Dual Power 3,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,", "030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,", "03000000666600000488000000000000,TigerGame PS/PS2 Game Controller Adapter,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "03000000d62000006000000000000000,Tournament PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000005f140000c501000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000b80500000210000000000000,Trust Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000d90400000200000000000000,TwinShock PS2,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000300f00000701000000000000,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000632500002305000000000000,USB Vibration Joystick (BM),a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000341a00002308000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000005509000000b4000000000000,USB gamepad,a:b10,b:b11,back:b5,dpdown:b1,dpleft:b2,dpright:b3,dpup:b0,guide:b14,leftshoulder:b8,leftstick:b6,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,rightstick:b7,righttrigger:a5,rightx:a2,righty:a3,start:b4,x:b12,y:b13,", "030000006b1400000203000000000000,USB gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000790000000a00000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b3,y:b0,", "03000000f0250000c183000000000000,USB gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000ff1100004133000000000000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a4,righty:a2,start:b9,x:b3,y:b0,", "03000000790000001b18000000000000,Venom Arcade Joystick,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000450c00002043000000000000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000341a00000608000000000000,Xeox,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000172700004431000000000000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a7,rightx:a2,righty:a5,start:b11,x:b3,y:b4,", "03000000790000004f18000000000000,ZD-T Android,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000d81d00000f00000000000000,iBUFFALO BSGP1204 Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000d81d00001000000000000000,iBUFFALO BSGP1204P Series,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000830500006020000000000000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,", "030000004f04000003d0000000000000,run'n'drive,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b7,leftshoulder:a3,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:a4,rightstick:b11,righttrigger:b5,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000101c0000171c000000000000,uRage Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", #endif #if defined(__MACOSX__) "03000000022000000090000001000000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "03000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,", "03000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,", "03000000a00500003232000009010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,", "030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000260900008888000088020000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,", "03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000790000000600000000000000,G-Shark GP-702,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000ad1b000001f9000000000000,Gamestop BB-070 X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000000d0f00005f00000000000000,HORI Fighting Commander 4 PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005e00000000000000,HORI Fighting Commander 4 PS4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00004d00000000000000,HORI Gem Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00006e00000000010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00006600000000010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00006600000000000000,HORIPAD FPS PLUS 4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00005f00000000010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005e00000000010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000008f0e00001330000011010000,HuiJia SNES Controller,a:b4,b:b2,back:b16,dpdown:+a2,dpleft:-a0,dpright:+a0,dpup:-a2,leftshoulder:b12,rightshoulder:b14,start:b18,x:b6,y:b0,", "030000006d04000016c2000000020000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000016c2000000030000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000016c2000014040000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ "030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */ "03000000d8140000cecf000000000000,MC Cthulhu,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000380700005032000000010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700005082000000010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700008433000000010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008483000000010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000790000004418000000010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", "0300000025090000e803000000000000,Mayflash Wii Classic Controller,a:b1,b:b0,back:b8,dpdown:b13,dpleft:b12,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,", "03000000790000000018000000000000,Mayflash WiiU Pro Game Controller Adapter (DInput),a:b4,b:b8,back:b32,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b16,leftstick:b40,lefttrigger:b24,leftx:a0,lefty:a4,rightshoulder:b20,rightstick:b44,righttrigger:b28,rightx:a8,righty:a12,start:b36,x:b0,y:b12,", "030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,", "030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c050000a00b000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000008f0e00000300000000000000,Piranha xtreme,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "030000008916000000fd000000000000,Razer Onza TE,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "03000000321500000204000000010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000321500000104000000010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000321500000010000000010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "0300000032150000030a000000000000,Razer Wildcat,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "03000000790000001100000000000000,Retrolink Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a3,lefty:a4,rightshoulder:b5,start:b9,x:b3,y:b0,", "03000000790000001100000006010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a4,dpleft:-a3,dpright:+a3,dpup:-a4,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,", "030000006b140000010d000000010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,", "03000000b40400000a01000000000000,Sega Saturn USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,", "03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,", "030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,", "03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,", "03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,", "03000000110100001714000000000000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,", "03000000110100001714000020010000,SteelSeries Stratus XL,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,start:b12,x:b2,y:b3,", "030000004f04000015b3000000000000,Thrustmaster Dual Analog 3.2,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,", "030000004f04000000b3000000000000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,", "03000000bd12000015d0000000000000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,", "03000000bd12000015d0000000010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,", "03000000100800000100000000000000,Twin USB Joystick,a:b4,b:b2,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b12,leftstick:b20,lefttrigger:b8,leftx:a0,lefty:a2,rightshoulder:b14,rightstick:b22,righttrigger:b10,rightx:a6,righty:a4,start:b18,x:b6,y:b0,", "050000005769696d6f74652028303000,Wii Remote,a:b4,b:b5,back:b7,dpdown:b3,dpleft:b0,dpright:b1,dpup:b2,guide:b8,leftshoulder:b11,lefttrigger:b12,leftx:a0,lefty:a1,start:b6,x:b10,y:b9,", "050000005769696d6f74652028313800,Wii U Pro Controller,a:b16,b:b15,back:b7,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b8,leftshoulder:b19,leftstick:b23,lefttrigger:b21,leftx:a0,lefty:a1,rightshoulder:b20,rightstick:b24,righttrigger:b22,rightx:a2,righty:a3,start:b6,x:b18,y:b17,", "030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "03000000c6240000045d000000000000,Xbox 360 Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000005e040000d102000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000005e040000dd02000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000005e040000e302000000000000,Xbox One Wired Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000005e040000e002000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000e002000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000ea02000000000000,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "030000005e040000fd02000003090000,Xbox Wireless Controller,a:b0,b:b1,back:b16,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,", "03000000120c0000100e000000010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000830500006020000000010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,", "03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,", #endif #if defined(__LINUX__) "03000000c82d00000190000011010000,8Bitdo NES30 Pro 8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "03000000022000000090000011010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "05000000203800000900000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "05000000c82d00002038000000010000,8Bitdo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "05000000c82d00000061000000010000,8Bitdo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,", "05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,", "05000000c82d00003028000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,", "05000000a00500003232000001000000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,", "05000000a00500003232000008010000,8Bitdo Zero GamePad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,", "05000000050b00000045000031000000,ASUS Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b10,x:b2,y:b3,", "030000006f0e00003901000020060000,Afterglow Controller for Xbox One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006f0e00003901000000430000,Afterglow Prismatic Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000b40400000a01000000010000,CYPRESS USB Gamepad,a:b0,b:b1,back:b5,guide:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b8,x:b3,y:b4,", "03000000e82000006058000001010000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000260900008888000000010000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a5,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,", "03000000a306000022f6000011010000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,", "030000006f0e00003001000001010000,EA Sports PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "0300000079000000d418000000010000,GPD Win 2 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0500000047532067616d657061640000,GS gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", "03000000bc2000000055000011010000,GameSir G3w,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000006f0e00000104000000010000,Gamestop Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:a0,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:a3,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000280400000140000000010000,Gravis GamePad Pro USB ,a:b1,b:b2,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000008f0e00000610000000010000,GreenAsia Electronics 4Axes 12Keys GamePad ,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,", "030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,", "03000000c9110000f055000011010000,HJC Game GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000000d0f00001000000011010000,HORI CO. LTD. FIGHTING STICK 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00002200000011010000,HORI CO. LTD. REAL ARCADE Pro.V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "030000000d0f00006a00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00006b00000011010000,HORI CO. LTD. Real Arcade Pro.4,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00006e00000011010000,HORIPAD 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00006600000011010000,HORIPAD 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000000d0f00006700000001010000,HORIPAD ONE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "06000000adde0000efbe000002010000,Hidromancer Game Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000d81400000862000011010000,HitBox (PS3/PC) Analog Mode,a:b1,b:b2,back:b8,guide:b9,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b12,x:b0,y:b3,", "030000000d0f00005f00000011010000,Hori Fighting Commander 4 (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000000d0f00005e00000011010000,Hori Fighting Commander 4 (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000008f0e00001330000010010000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,", "03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,", "030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,", "03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "030000006f0e00000103000000020000,Logic3 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000016c2000010010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000016c2000011010000,Logitech Dual Action,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d04000015c2000010010000,Logitech Logitech Extreme 3D,a:b0,b:b4,back:b6,guide:b8,leftshoulder:b9,leftstick:h0.8,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:h0.2,start:b7,x:b2,y:b5,", "030000006d04000018c2000010010000,Logitech RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b5,leftshoulder:b6,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b10,rightx:a3,righty:a4,start:b8,x:b3,y:b4,", "03000000250900006688000000010000,MP-8866 Super Dual Box,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "05000000380700006652000025010000,Mad Catz C.T.R.L.R ,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700005032000011010000,Mad Catz FightPad PRO (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700005082000011010000,Mad Catz FightPad PRO (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700008433000011010000,Mad Catz FightStick TE S+ (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008483000011010000,Mad Catz FightStick TE S+ (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000ad1b00002ef0000090040000,Mad Catz Fightpad SFxT,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,start:b7,x:b2,y:b3,", "03000000380700003847000090040000,Mad Catz Wired Xbox 360 Controller (SFIV),a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000380700001647000010040000,Mad Catz Wired Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000ad1b000016f0000090040000,Mad Catz Xbox 360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000380700008034000011010000,Mad Catz fightstick (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700008084000011010000,Mad Catz fightstick (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000380700001888000010010000,MadCatz PC USB Wired Stick 8818,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000380700003888000010010000,MadCatz PC USB Wired Stick 8838,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:a0,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000790000004418000010010000,Mayflash GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", "03000000780000000600000010010000,Microntek USB Joystick,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,", "030000005e0400000e00000000010000,Microsoft SideWinder,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,rightshoulder:b7,start:b8,x:b3,y:b4,", "030000005e0400008e02000004010000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000062230000,Microsoft X-Box 360 pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000d102000003020000,Microsoft X-Box One pad v2,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", "030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", "05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,", "03000000550900001072000011010000,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b13,leftshoulder:b4,leftstick:b8,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "03000000451300000830000010010000,NYKO CORE,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000007e0500000920000001000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "050000007e0500003003000001000000,Nintendo Wii Remote Pro Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b2,", "05000000010000000100000003000000,Nintendo Wiimote,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000000d0500000308000010010000,Nostromo n45 Dual Analog Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,", "05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,", "05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,", "030000005e0400000202000000010000,Old Xbox pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", "03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "030000006f0e00006401000001010000,PDP Battlefield One,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000ff1100004133000010010000,PS2 Controller,a:b2,b:b1,back:b8,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b3,y:b0,", "03000000341a00003608000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000004c0500006802000010010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c0500006802000010810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c0500006802000011810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "030000006f0e00001402000011010000,PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000008f0e00000300000010010000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "050000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:a12,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:a13,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "050000004c0500006802000000800000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "050000004c0500006802000000810000,PS3 Controller,a:b0,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b16,dpup:b13,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "05000000504c415953544154494f4e00,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "060000004c0500006802000000010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c050000a00b000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000a00b000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "030000004c050000c405000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000c405000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "030000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000cc09000011010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004c050000cc09000011810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "050000004c050000c405000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000004c050000c405000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "050000004c050000cc09000000010000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000004c050000cc09000000810000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "050000004c050000cc09000001800000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b3,y:b2,", "03000000c62400000053000000010000,PowerA,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,", "030000008916000001fd000024010000,Razer Onza Classic Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000008916000000fd000024010000,Razer Onza Tournament Edition,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000321500000204000011010000,Razer Panthera (PS3),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000321500000104000011010000,Razer Panthera (PS4),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000321500000010000011010000,Razer RAIJU,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000008916000000fe000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000c6240000045d000024010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000c6240000045d000025010000,Razer Sabertooth,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "0300000032150000030a000001010000,Razer Wildcat,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0300000000f000000300000000010000,RetroPad,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,", "03000000790000001100000010010000,Retrolink SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,", "030000006b140000010d000011010000,Revolution Pro Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000006f0e00001e01000011010000,Rock Candy PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006f0e00004601000001010000,Rock Candy Xbox One Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006f0e00001f01000000010000,Rock Candy,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000632500007505000010010000,SHANWAN PS3/PC Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000341a00000908000010010000,SL-6566,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000a30600000cff000010010000,Saitek P2500 Force Rumble Pad,a:b2,b:b3,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,", "03000000a30600000c04000011010000,Saitek P2900 Wireless Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b12,x:b0,y:b3,", "03000000a30600000901000000010000,Saitek P880,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a3,righty:a2,x:b0,y:b1,", "03000000a30600000b04000000010000,Saitek P990 Dual Analog Pad,a:b1,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b8,x:b0,y:b3,", "03000000a306000018f5000010010000,Saitek PLC Saitek P3200 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b0,y:b3,", "03000000c01600008704000011010000,Serial/Keyboard/Mouse/Joystick,a:b12,b:b10,back:b4,dpdown:b2,dpleft:b3,dpright:b1,dpup:b0,leftshoulder:b9,leftstick:b14,lefttrigger:b6,leftx:a1,lefty:a0,rightshoulder:b8,rightstick:b15,righttrigger:b7,rightx:a2,righty:a3,start:b5,x:b13,y:b11,", "03000000f025000021c1000010010000,ShanWan Gioteck PS3 Wired Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000632500002305000010010000,ShanWan USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "030000005e0400008e02000020200000,SpeedLink XEOX Pro Analog Gamepad pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000073050000,Speedlink TORID Wireless Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000de2800000112000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de2800000211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de2800004211000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "05000000de2800000212000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de280000ff11000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000ad1b000038f0000090040000,Street Fighter IV FightStick TE,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,back:b9,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b3,y:b0,", "0300000000f00000f100000000010000,Super RetroPort,a:b1,b:b5,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b0,y:b4,", "030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,", "030000004f04000015b3000010010000,Thrustmaster Dual Analog 4,a:b0,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b1,y:b3,", "030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b11,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b12,righttrigger:b7,rightx:a2,righty:a3,start:b10,x:b1,y:b3,", "030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000bd12000015d0000010010000,Tomee SNES USB Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b9,x:b3,y:b0,", "03000000d814000007cd000011010000,Toodles 2008 Chimp PC/PS3,a:b0,b:b1,back:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b3,y:b2,", "03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000100800000300000010010000,USB Gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000790000001100000000010000,USB Gamepad1,a:b2,b:b1,back:b8,dpdown:a0,dpleft:a1,dpright:a2,dpup:a4,start:b9,", "03000000790000000600000007010000,USB gamepad,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a3,righty:a4,start:b9,x:b3,y:b0,", "05000000ac0500003232000001000000,VR-BOX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a3,righty:a2,start:b9,x:b2,y:b3,", "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,", "030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "050000005e040000fd02000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b15,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b16,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "05000000172700004431000029010000,XiaoMi Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b20,leftshoulder:b6,leftstick:b13,lefttrigger:a7,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a6,rightx:a2,righty:a5,start:b11,x:b3,y:b4,", "03000000c0160000e105000001010000,Xin-Mo Xin-Mo Dual Arcade,a:b4,b:b3,back:b6,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b9,leftshoulder:b2,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b1,y:b0,", "03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,", "030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,", "03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,", "050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000b50700001503000010010000,impact,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "030000009b2800000300000001010000,raphnet.net 4nes4snes v1.5,a:b0,b:b4,back:b2,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b3,x:b1,y:b5,", #endif #if defined(__ANDROID__) "05000000d6020000e5890000dfff3f00,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,", "05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005509000003720000cf7f3f00,NVIDIA Controller v01.01,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005509000010720000ffff3f00,NVIDIA Controller v01.03,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,", /* Extremely slow in Bluetooth mode on Android */ "050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", "050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", "050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,", "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,", "050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005e04000091020000ff073f00,Xbox Wireless Controller,a:b0,b:b1,back:b4,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,", /* The DPAD doesn't seem to work on this controller on Android TV? */ #endif #if defined(SDL_JOYSTICK_MFI) "05000000ac0500000100000000006d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,", "05000000ac0500000200000000006d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,", "05000000ac0500000300000000006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,", "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", #endif #if defined(SDL_JOYSTICK_EMSCRIPTEN) "default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", #endif "hidapi,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", NULL }; /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\SDL_joystick.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* This is the joystick API for Simple DirectMedia Layer */ #include "SDL.h" #include "SDL_atomic.h" #include "SDL_events.h" #include "SDL_sysjoystick.h" #include "SDL_assert.h" #include "SDL_hints.h" #if !SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif #include "../video/SDL_sysvideo.h" /* This is included in only one place because it has a large static list of controllers */ #include "controller_type.h" #ifdef __WIN32__ /* Needed for checking for input remapping programs */ #include "../core/windows/SDL_windows.h" #undef UNICODE /* We want ASCII functions */ #include <tlhelp32.h> #endif static SDL_JoystickDriver *SDL_joystick_drivers[] = { #if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) &SDL_WINDOWS_JoystickDriver, #endif #ifdef SDL_JOYSTICK_LINUX &SDL_LINUX_JoystickDriver, #endif #ifdef SDL_JOYSTICK_IOKIT &SDL_DARWIN_JoystickDriver, #endif #if defined(__IPHONEOS__) || defined(__TVOS__) &SDL_IOS_JoystickDriver, #endif #ifdef SDL_JOYSTICK_ANDROID &SDL_ANDROID_JoystickDriver, #endif #ifdef SDL_JOYSTICK_EMSCRIPTEN &SDL_EMSCRIPTEN_JoystickDriver, #endif #ifdef SDL_JOYSTICK_HAIKU &SDL_HAIKU_JoystickDriver, #endif #ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */ &SDL_BSD_JoystickDriver, #endif #ifdef SDL_JOYSTICK_HIDAPI &SDL_HIDAPI_JoystickDriver, #endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif }; static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; static SDL_Joystick *SDL_joysticks = NULL; static SDL_bool SDL_updating_joystick = SDL_FALSE; static SDL_mutex *SDL_joystick_lock = NULL; /* This needs to support recursive locks */ static SDL_atomic_t SDL_next_joystick_instance_id; void SDL_LockJoysticks(void) { if (SDL_joystick_lock) { SDL_LockMutex(SDL_joystick_lock); } } void SDL_UnlockJoysticks(void) { if (SDL_joystick_lock) { SDL_UnlockMutex(SDL_joystick_lock); } } static void SDLCALL SDL_JoystickAllowBackgroundEventsChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { if (hint && *hint == '1') { SDL_joystick_allows_background_events = SDL_TRUE; } else { SDL_joystick_allows_background_events = SDL_FALSE; } } int SDL_JoystickInit(void) { int i, status; SDL_GameControllerInitMappings(); /* Create the joystick list lock */ if (!SDL_joystick_lock) { SDL_joystick_lock = SDL_CreateMutex(); } /* See if we should allow joystick events while in the background */ SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); #if !SDL_EVENTS_DISABLED if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { return -1; } #endif /* !SDL_EVENTS_DISABLED */ status = -1; for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { if (SDL_joystick_drivers[i]->Init() >= 0) { status = 0; } } return status; } /* * Count the number of joysticks attached to the system */ int SDL_NumJoysticks(void) { int i, total_joysticks = 0; SDL_LockJoysticks(); for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { total_joysticks += SDL_joystick_drivers[i]->GetCount(); } SDL_UnlockJoysticks(); return total_joysticks; } /* * Return the next available joystick instance ID * This may be called by drivers from multiple threads, unprotected by any locks */ SDL_JoystickID SDL_GetNextJoystickInstanceID() { return SDL_AtomicIncRef(&SDL_next_joystick_instance_id); } /* * Get the driver and device index for an API device index * This should be called while the joystick lock is held, to prevent another thread from updating the list */ SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriver **driver, int *driver_index) { int i, num_joysticks, total_joysticks = 0; if (device_index >= 0) { for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { num_joysticks = SDL_joystick_drivers[i]->GetCount(); if (device_index < num_joysticks) { *driver = SDL_joystick_drivers[i]; *driver_index = device_index; return SDL_TRUE; } device_index -= num_joysticks; total_joysticks += num_joysticks; } } SDL_SetError("There are %d joysticks available", total_joysticks); return SDL_FALSE; } /* * Perform any needed fixups for joystick names */ static const char * SDL_FixupJoystickName(const char *name) { if (name) { const char *skip_prefix = "NVIDIA Corporation "; if (SDL_strncmp(name, skip_prefix, SDL_strlen(skip_prefix)) == 0) { name += SDL_strlen(skip_prefix); } } return name; } /* * Get the implementation dependent name of a joystick */ const char * SDL_JoystickNameForIndex(int device_index) { SDL_JoystickDriver *driver; const char *name = NULL; SDL_LockJoysticks(); if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { name = SDL_FixupJoystickName(driver->GetDeviceName(device_index)); } SDL_UnlockJoysticks(); /* FIXME: Really we should reference count this name so it doesn't go away after unlock */ return name; } /* * Return true if this joystick is known to have all axes centered at zero * This isn't generally needed unless the joystick never generates an initial axis value near zero, * e.g. it's emulating axes with digital buttons */ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) { static Uint32 zero_centered_joysticks[] = { MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */ MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */ }; int i; Uint32 id = MAKE_VIDPID(SDL_JoystickGetVendor(joystick), SDL_JoystickGetProduct(joystick)); /*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/ if (joystick->naxes == 2) { /* Assume D-pad or thumbstick style axes are centered at 0 */ return SDL_TRUE; } for (i = 0; i < SDL_arraysize(zero_centered_joysticks); ++i) { if (id == zero_centered_joysticks[i]) { return SDL_TRUE; } } return SDL_FALSE; } /* * Open a joystick for use - the index passed as an argument refers to * the N'th joystick on the system. This index is the value which will * identify this joystick in future joystick events. * * This function returns a joystick identifier, or NULL if an error occurred. */ SDL_Joystick * SDL_JoystickOpen(int device_index) { SDL_JoystickDriver *driver; SDL_JoystickID instance_id; SDL_Joystick *joystick; SDL_Joystick *joysticklist; const char *joystickname = NULL; SDL_LockJoysticks(); if (!SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { SDL_UnlockJoysticks(); return NULL; } joysticklist = SDL_joysticks; /* If the joystick is already open, return it * it is important that we have a single joystick * for each instance id */ instance_id = driver->GetDeviceInstanceID(device_index); while (joysticklist) { if (instance_id == joysticklist->instance_id) { joystick = joysticklist; ++joystick->ref_count; SDL_UnlockJoysticks(); return joystick; } joysticklist = joysticklist->next; } /* Create and initialize the joystick */ joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1); if (joystick == NULL) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; } joystick->driver = driver; joystick->instance_id = instance_id; joystick->attached = SDL_TRUE; if (driver->Open(joystick, device_index) < 0) { SDL_free(joystick); SDL_UnlockJoysticks(); return NULL; } joystickname = driver->GetDeviceName(device_index); if (joystickname) { joystick->name = SDL_strdup(joystickname); } else { joystick->name = NULL; } joystick->guid = driver->GetDeviceGUID(device_index); if (joystick->naxes > 0) { joystick->axes = (SDL_JoystickAxisInfo *) SDL_calloc(joystick->naxes, sizeof(SDL_JoystickAxisInfo)); } if (joystick->nhats > 0) { joystick->hats = (Uint8 *) SDL_calloc(joystick->nhats, sizeof(Uint8)); } if (joystick->nballs > 0) { joystick->balls = (struct balldelta *) SDL_calloc(joystick->nballs, sizeof(*joystick->balls)); } if (joystick->nbuttons > 0) { joystick->buttons = (Uint8 *) SDL_calloc(joystick->nbuttons, sizeof(Uint8)); } if (((joystick->naxes > 0) && !joystick->axes) || ((joystick->nhats > 0) && !joystick->hats) || ((joystick->nballs > 0) && !joystick->balls) || ((joystick->nbuttons > 0) && !joystick->buttons)) { SDL_OutOfMemory(); SDL_JoystickClose(joystick); SDL_UnlockJoysticks(); return NULL; } joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; /* If this joystick is known to have all zero centered axes, skip the auto-centering code */ if (SDL_JoystickAxesCenteredAtZero(joystick)) { int i; for (i = 0; i < joystick->naxes; ++i) { joystick->axes[i].has_initial_value = SDL_TRUE; } } joystick->is_game_controller = SDL_IsGameController(device_index); /* Add joystick to list */ ++joystick->ref_count; /* Link the joystick in the list */ joystick->next = SDL_joysticks; SDL_joysticks = joystick; SDL_UnlockJoysticks(); driver->Update(joystick); return joystick; } /* * Checks to make sure the joystick is valid. */ int SDL_PrivateJoystickValid(SDL_Joystick * joystick) { int valid; if (joystick == NULL) { SDL_SetError("Joystick hasn't been opened yet"); valid = 0; } else { valid = 1; } return valid; } /* * Get the number of multi-dimensional axis controls on a joystick */ int SDL_JoystickNumAxes(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->naxes; } /* * Get the number of hats on a joystick */ int SDL_JoystickNumHats(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->nhats; } /* * Get the number of trackballs on a joystick */ int SDL_JoystickNumBalls(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->nballs; } /* * Get the number of buttons on a joystick */ int SDL_JoystickNumButtons(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->nbuttons; } /* * Get the current state of an axis control on a joystick */ Sint16 SDL_JoystickGetAxis(SDL_Joystick * joystick, int axis) { Sint16 state; if (!SDL_PrivateJoystickValid(joystick)) { return 0; } if (axis < joystick->naxes) { state = joystick->axes[axis].value; } else { SDL_SetError("Joystick only has %d axes", joystick->naxes); state = 0; } return state; } /* * Get the initial state of an axis control on a joystick */ SDL_bool SDL_JoystickGetAxisInitialState(SDL_Joystick * joystick, int axis, Sint16 *state) { if (!SDL_PrivateJoystickValid(joystick)) { return SDL_FALSE; } if (axis >= joystick->naxes) { SDL_SetError("Joystick only has %d axes", joystick->naxes); return SDL_FALSE; } if (state) { *state = joystick->axes[axis].initial_value; } return joystick->axes[axis].has_initial_value; } /* * Get the current state of a hat on a joystick */ Uint8 SDL_JoystickGetHat(SDL_Joystick * joystick, int hat) { Uint8 state; if (!SDL_PrivateJoystickValid(joystick)) { return 0; } if (hat < joystick->nhats) { state = joystick->hats[hat]; } else { SDL_SetError("Joystick only has %d hats", joystick->nhats); state = 0; } return state; } /* * Get the ball axis change since the last poll */ int SDL_JoystickGetBall(SDL_Joystick * joystick, int ball, int *dx, int *dy) { int retval; if (!SDL_PrivateJoystickValid(joystick)) { return -1; } retval = 0; if (ball < joystick->nballs) { if (dx) { *dx = joystick->balls[ball].dx; } if (dy) { *dy = joystick->balls[ball].dy; } joystick->balls[ball].dx = 0; joystick->balls[ball].dy = 0; } else { return SDL_SetError("Joystick only has %d balls", joystick->nballs); } return retval; } /* * Get the current state of a button on a joystick */ Uint8 SDL_JoystickGetButton(SDL_Joystick * joystick, int button) { Uint8 state; if (!SDL_PrivateJoystickValid(joystick)) { return 0; } if (button < joystick->nbuttons) { state = joystick->buttons[button]; } else { SDL_SetError("Joystick only has %d buttons", joystick->nbuttons); state = 0; } return state; } /* * Return if the joystick in question is currently attached to the system, * \return SDL_FALSE if not plugged in, SDL_TRUE if still present. */ SDL_bool SDL_JoystickGetAttached(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return SDL_FALSE; } return joystick->attached; } /* * Get the instance id for this opened joystick */ SDL_JoystickID SDL_JoystickInstanceID(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->instance_id; } /* * Find the SDL_Joystick that owns this instance id */ SDL_Joystick * SDL_JoystickFromInstanceID(SDL_JoystickID joyid) { SDL_Joystick *joystick; SDL_LockJoysticks(); for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->instance_id == joyid) { break; } } SDL_UnlockJoysticks(); return joystick; } /* * Get the friendly name of this joystick */ const char * SDL_JoystickName(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return NULL; } return SDL_FixupJoystickName(joystick->name); } int SDL_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { if (!SDL_PrivateJoystickValid(joystick)) { return -1; } return joystick->driver->Rumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); } /* * Close a joystick previously opened with SDL_JoystickOpen() */ void SDL_JoystickClose(SDL_Joystick * joystick) { SDL_Joystick *joysticklist; SDL_Joystick *joysticklistprev; if (!SDL_PrivateJoystickValid(joystick)) { return; } SDL_LockJoysticks(); /* First decrement ref count */ if (--joystick->ref_count > 0) { SDL_UnlockJoysticks(); return; } if (SDL_updating_joystick) { SDL_UnlockJoysticks(); return; } joystick->driver->Close(joystick); joystick->hwdata = NULL; joysticklist = SDL_joysticks; joysticklistprev = NULL; while (joysticklist) { if (joystick == joysticklist) { if (joysticklistprev) { /* unlink this entry */ joysticklistprev->next = joysticklist->next; } else { SDL_joysticks = joystick->next; } break; } joysticklistprev = joysticklist; joysticklist = joysticklist->next; } SDL_free(joystick->name); /* Free the data associated with this joystick */ SDL_free(joystick->axes); SDL_free(joystick->hats); SDL_free(joystick->balls); SDL_free(joystick->buttons); SDL_free(joystick); SDL_UnlockJoysticks(); } void SDL_JoystickQuit(void) { int i; /* Make sure we're not getting called in the middle of updating joysticks */ SDL_assert(!SDL_updating_joystick); SDL_LockJoysticks(); /* Stop the event polling */ while (SDL_joysticks) { SDL_joysticks->ref_count = 1; SDL_JoystickClose(SDL_joysticks); } /* Quit the joystick setup */ for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { SDL_joystick_drivers[i]->Quit(); } SDL_UnlockJoysticks(); #if !SDL_EVENTS_DISABLED SDL_QuitSubSystem(SDL_INIT_EVENTS); #endif SDL_DelHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); if (SDL_joystick_lock) { SDL_DestroyMutex(SDL_joystick_lock); SDL_joystick_lock = NULL; } SDL_GameControllerQuitMappings(); } static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent() { if (SDL_joystick_allows_background_events) { return SDL_FALSE; } if (SDL_HasWindows() && SDL_GetKeyboardFocus() == NULL) { /* We have windows but we don't have focus, ignore the event. */ return SDL_TRUE; } return SDL_FALSE; } /* These are global for SDL_sysjoystick.c and SDL_events.c */ void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance) { #if !SDL_EVENTS_DISABLED SDL_Event event; int device_index; device_index = SDL_JoystickGetDeviceIndexFromInstanceID(device_instance); if (device_index < 0) { return; } event.type = SDL_JOYDEVICEADDED; if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.jdevice.which = device_index; SDL_PushEvent(&event); } #endif /* !SDL_EVENTS_DISABLED */ } /* * If there is an existing add event in the queue, it needs to be modified * to have the right value for which, because the number of controllers in * the system is now one less. */ static void UpdateEventsForDeviceRemoval() { int i, num_events; SDL_Event *events; num_events = SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED); if (num_events <= 0) { return; } events = SDL_stack_alloc(SDL_Event, num_events); if (!events) { return; } num_events = SDL_PeepEvents(events, num_events, SDL_GETEVENT, SDL_JOYDEVICEADDED, SDL_JOYDEVICEADDED); for (i = 0; i < num_events; ++i) { --events[i].jdevice.which; } SDL_PeepEvents(events, num_events, SDL_ADDEVENT, 0, 0); SDL_stack_free(events); } void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance) { SDL_Joystick *joystick; #if !SDL_EVENTS_DISABLED SDL_Event event; event.type = SDL_JOYDEVICEREMOVED; if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.jdevice.which = device_instance; SDL_PushEvent(&event); } UpdateEventsForDeviceRemoval(); #endif /* !SDL_EVENTS_DISABLED */ /* Mark this joystick as no longer attached */ for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->instance_id == device_instance) { joystick->attached = SDL_FALSE; joystick->force_recentering = SDL_TRUE; break; } } } int SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value) { int posted; /* Make sure we're not getting garbage or duplicate events */ if (axis >= joystick->naxes) { return 0; } if (!joystick->axes[axis].has_initial_value) { joystick->axes[axis].initial_value = value; joystick->axes[axis].value = value; joystick->axes[axis].zero = value; joystick->axes[axis].has_initial_value = SDL_TRUE; } if (value == joystick->axes[axis].value) { return 0; } if (!joystick->axes[axis].sent_initial_value) { /* Make sure we don't send motion until there's real activity on this axis */ const int MAX_ALLOWED_JITTER = SDL_JOYSTICK_AXIS_MAX / 80; /* ShanWan PS3 controller needed 96 */ if (SDL_abs(value - joystick->axes[axis].value) <= MAX_ALLOWED_JITTER) { return 0; } joystick->axes[axis].sent_initial_value = SDL_TRUE; joystick->axes[axis].value = value; /* Just so we pass the check above */ SDL_PrivateJoystickAxis(joystick, axis, joystick->axes[axis].initial_value); } /* We ignore events if we don't have keyboard focus, except for centering * events. */ if (SDL_PrivateJoystickShouldIgnoreEvent()) { if ((value > joystick->axes[axis].zero && value >= joystick->axes[axis].value) || (value < joystick->axes[axis].zero && value <= joystick->axes[axis].value)) { return 0; } } /* Update internal joystick state */ joystick->axes[axis].value = value; /* Post the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) { SDL_Event event; event.type = SDL_JOYAXISMOTION; event.jaxis.which = joystick->instance_id; event.jaxis.axis = axis; event.jaxis.value = value; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return posted; } int SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value) { int posted; /* Make sure we're not getting garbage or duplicate events */ if (hat >= joystick->nhats) { return 0; } if (value == joystick->hats[hat]) { return 0; } /* We ignore events if we don't have keyboard focus, except for centering * events. */ if (SDL_PrivateJoystickShouldIgnoreEvent()) { if (value != SDL_HAT_CENTERED) { return 0; } } /* Update internal joystick state */ joystick->hats[hat] = value; /* Post the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) { SDL_Event event; event.jhat.type = SDL_JOYHATMOTION; event.jhat.which = joystick->instance_id; event.jhat.hat = hat; event.jhat.value = value; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return posted; } int SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball, Sint16 xrel, Sint16 yrel) { int posted; /* Make sure we're not getting garbage events */ if (ball >= joystick->nballs) { return 0; } /* We ignore events if we don't have keyboard focus. */ if (SDL_PrivateJoystickShouldIgnoreEvent()) { return 0; } /* Update internal mouse state */ joystick->balls[ball].dx += xrel; joystick->balls[ball].dy += yrel; /* Post the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYBALLMOTION) == SDL_ENABLE) { SDL_Event event; event.jball.type = SDL_JOYBALLMOTION; event.jball.which = joystick->instance_id; event.jball.ball = ball; event.jball.xrel = xrel; event.jball.yrel = yrel; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return posted; } int SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state) { int posted; #if !SDL_EVENTS_DISABLED SDL_Event event; switch (state) { case SDL_PRESSED: event.type = SDL_JOYBUTTONDOWN; break; case SDL_RELEASED: event.type = SDL_JOYBUTTONUP; break; default: /* Invalid state -- bail */ return 0; } #endif /* !SDL_EVENTS_DISABLED */ /* Make sure we're not getting garbage or duplicate events */ if (button >= joystick->nbuttons) { return 0; } if (state == joystick->buttons[button]) { return 0; } /* We ignore events if we don't have keyboard focus, except for button * release. */ if (SDL_PrivateJoystickShouldIgnoreEvent()) { if (state == SDL_PRESSED) { return 0; } } /* Update internal joystick state */ joystick->buttons[button] = state; /* Post the event, if desired */ posted = 0; #if !SDL_EVENTS_DISABLED if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.jbutton.which = joystick->instance_id; event.jbutton.button = button; event.jbutton.state = state; posted = SDL_PushEvent(&event) == 1; } #endif /* !SDL_EVENTS_DISABLED */ return posted; } void SDL_JoystickUpdate(void) { int i; SDL_Joystick *joystick; SDL_LockJoysticks(); if (SDL_updating_joystick) { /* The joysticks are already being updated */ SDL_UnlockJoysticks(); return; } SDL_updating_joystick = SDL_TRUE; /* Make sure the list is unlocked while dispatching events to prevent application deadlocks */ SDL_UnlockJoysticks(); for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->attached) { joystick->driver->Update(joystick); if (joystick->delayed_guide_button) { SDL_GameControllerHandleDelayedGuideButton(joystick); } } if (joystick->force_recentering) { /* Tell the app that everything is centered/unpressed... */ for (i = 0; i < joystick->naxes; i++) { if (joystick->axes[i].has_initial_value) { SDL_PrivateJoystickAxis(joystick, i, joystick->axes[i].zero); } } for (i = 0; i < joystick->nbuttons; i++) { SDL_PrivateJoystickButton(joystick, i, 0); } for (i = 0; i < joystick->nhats; i++) { SDL_PrivateJoystickHat(joystick, i, SDL_HAT_CENTERED); } joystick->force_recentering = SDL_FALSE; } } SDL_LockJoysticks(); SDL_updating_joystick = SDL_FALSE; /* If any joysticks were closed while updating, free them here */ for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { if (joystick->ref_count <= 0) { SDL_JoystickClose(joystick); } } /* this needs to happen AFTER walking the joystick list above, so that any dangling hardware data from removed devices can be free'd */ for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { SDL_joystick_drivers[i]->Detect(); } SDL_UnlockJoysticks(); } int SDL_JoystickEventState(int state) { #if SDL_EVENTS_DISABLED return SDL_DISABLE; #else const Uint32 event_list[] = { SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION, SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED }; unsigned int i; switch (state) { case SDL_QUERY: state = SDL_DISABLE; for (i = 0; i < SDL_arraysize(event_list); ++i) { state = SDL_EventState(event_list[i], SDL_QUERY); if (state == SDL_ENABLE) { break; } } break; default: for (i = 0; i < SDL_arraysize(event_list); ++i) { SDL_EventState(event_list[i], state); } break; } return state; #endif /* SDL_EVENTS_DISABLED */ } void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version) { Uint16 *guid16 = (Uint16 *)guid.data; /* If the GUID fits the form of BUS 0000 VENDOR 0000 PRODUCT 0000, return the data */ if (/* guid16[0] is device bus type */ guid16[1] == 0x0000 && /* guid16[2] is vendor ID */ guid16[3] == 0x0000 && /* guid16[4] is product ID */ guid16[5] == 0x0000 /* guid16[6] is product version */ ) { if (vendor) { *vendor = guid16[2]; } if (product) { *product = guid16[4]; } if (version) { *version = guid16[6]; } } else { if (vendor) { *vendor = 0; } if (product) { *product = 0; } if (version) { *version = 0; } } } SDL_bool SDL_IsJoystickPS4(Uint16 vendor, Uint16 product) { return (GuessControllerType(vendor, product) == k_eControllerType_PS4Controller); } SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor, Uint16 product) { return (GuessControllerType(vendor, product) == k_eControllerType_SwitchProController); } SDL_bool SDL_IsJoystickSteamController(Uint16 vendor, Uint16 product) { return BIsSteamController(GuessControllerType(vendor, product)) ? SDL_TRUE : SDL_FALSE; } SDL_bool SDL_IsJoystickXbox360(Uint16 vendor, Uint16 product) { /* Filter out some bogus values here */ if (vendor == 0x0000 && product == 0x0000) { return SDL_FALSE; } if (vendor == 0x0001 && product == 0x0001) { return SDL_FALSE; } return (GuessControllerType(vendor, product) == k_eControllerType_XBox360Controller); } SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor, Uint16 product) { return (GuessControllerType(vendor, product) == k_eControllerType_XBoxOneController); } SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid) { return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE; } SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid) { return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE; } static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) { static Uint32 wheel_joysticks[] = { MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */ MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */ MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */ MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */ MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */ MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */ MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */ MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */ MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */ MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */ MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ }; int i; for (i = 0; i < SDL_arraysize(wheel_joysticks); ++i) { if (vidpid == wheel_joysticks[i]) { return SDL_TRUE; } } return SDL_FALSE; } static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid) { static Uint32 flightstick_joysticks[] = { MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */ MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */ }; int i; for (i = 0; i < SDL_arraysize(flightstick_joysticks); ++i) { if (vidpid == flightstick_joysticks[i]) { return SDL_TRUE; } } return SDL_FALSE; } static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid) { static Uint32 throttle_joysticks[] = { MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */ MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */ }; int i; for (i = 0; i < SDL_arraysize(throttle_joysticks); ++i) { if (vidpid == throttle_joysticks[i]) { return SDL_TRUE; } } return SDL_FALSE; } static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) { Uint16 vendor; Uint16 product; Uint32 vidpid; if (SDL_IsJoystickXInput(guid)) { /* XInput GUID, get the type based on the XInput device subtype */ switch (guid.data[15]) { case 0x01: /* XINPUT_DEVSUBTYPE_GAMEPAD */ return SDL_JOYSTICK_TYPE_GAMECONTROLLER; case 0x02: /* XINPUT_DEVSUBTYPE_WHEEL */ return SDL_JOYSTICK_TYPE_WHEEL; case 0x03: /* XINPUT_DEVSUBTYPE_ARCADE_STICK */ return SDL_JOYSTICK_TYPE_ARCADE_STICK; case 0x04: /* XINPUT_DEVSUBTYPE_FLIGHT_STICK */ return SDL_JOYSTICK_TYPE_FLIGHT_STICK; case 0x05: /* XINPUT_DEVSUBTYPE_DANCE_PAD */ return SDL_JOYSTICK_TYPE_DANCE_PAD; case 0x06: /* XINPUT_DEVSUBTYPE_GUITAR */ case 0x07: /* XINPUT_DEVSUBTYPE_GUITAR_ALTERNATE */ case 0x0B: /* XINPUT_DEVSUBTYPE_GUITAR_BASS */ return SDL_JOYSTICK_TYPE_GUITAR; case 0x08: /* XINPUT_DEVSUBTYPE_DRUM_KIT */ return SDL_JOYSTICK_TYPE_DRUM_KIT; case 0x13: /* XINPUT_DEVSUBTYPE_ARCADE_PAD */ return SDL_JOYSTICK_TYPE_ARCADE_PAD; default: return SDL_JOYSTICK_TYPE_UNKNOWN; } } SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); vidpid = MAKE_VIDPID(vendor, product); if (SDL_IsJoystickProductWheel(vidpid)) { return SDL_JOYSTICK_TYPE_WHEEL; } if (SDL_IsJoystickProductFlightStick(vidpid)) { return SDL_JOYSTICK_TYPE_FLIGHT_STICK; } if (SDL_IsJoystickProductThrottle(vidpid)) { return SDL_JOYSTICK_TYPE_THROTTLE; } if (GuessControllerType(vendor, product) != k_eControllerType_UnknownNonSteamController) { return SDL_JOYSTICK_TYPE_GAMECONTROLLER; } return SDL_JOYSTICK_TYPE_UNKNOWN; } static SDL_bool SDL_IsPS4RemapperRunning(void) { #ifdef __WIN32__ const char *mapper_processes[] = { "DS4Windows.exe", "InputMapper.exe", }; int i; PROCESSENTRY32 pe32; SDL_bool found = SDL_FALSE; /* Take a snapshot of all processes in the system */ HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap != INVALID_HANDLE_VALUE) { pe32.dwSize = sizeof(PROCESSENTRY32); if (Process32First(hProcessSnap, &pe32)) { do { for (i = 0; i < SDL_arraysize(mapper_processes); ++i) { if (SDL_strcasecmp(pe32.szExeFile, mapper_processes[i]) == 0) { found = SDL_TRUE; } } } while (Process32Next(hProcessSnap, &pe32) && !found); } CloseHandle(hProcessSnap); } return found; #else return SDL_FALSE; #endif } SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid) { Uint16 vendor; Uint16 product; SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); if (SDL_IsJoystickPS4(vendor, product) && SDL_IsPS4RemapperRunning()) { return SDL_TRUE; } if (SDL_IsGameControllerNameAndGUID(name, guid) && SDL_ShouldIgnoreGameController(name, guid)) { return SDL_TRUE; } return SDL_FALSE; } /* return the guid for this index */ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index) { SDL_JoystickDriver *driver; SDL_JoystickGUID guid; SDL_LockJoysticks(); if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { guid = driver->GetDeviceGUID(device_index); } else { SDL_zero(guid); } SDL_UnlockJoysticks(); return guid; } Uint16 SDL_JoystickGetDeviceVendor(int device_index) { Uint16 vendor; SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL); return vendor; } Uint16 SDL_JoystickGetDeviceProduct(int device_index) { Uint16 product; SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL); return product; } Uint16 SDL_JoystickGetDeviceProductVersion(int device_index) { Uint16 version; SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version); return version; } SDL_JoystickType SDL_JoystickGetDeviceType(int device_index) { SDL_JoystickType type; SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); type = SDL_GetJoystickGUIDType(guid); if (type == SDL_JOYSTICK_TYPE_UNKNOWN) { if (SDL_IsGameController(device_index)) { type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; } } return type; } SDL_JoystickID SDL_JoystickGetDeviceInstanceID(int device_index) { SDL_JoystickDriver *driver; SDL_JoystickID instance_id = -1; SDL_LockJoysticks(); if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { instance_id = driver->GetDeviceInstanceID(device_index); } SDL_UnlockJoysticks(); return instance_id; } int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id) { int i, num_joysticks, device_index = -1; SDL_LockJoysticks(); num_joysticks = SDL_NumJoysticks(); for (i = 0; i < num_joysticks; ++i) { if (SDL_JoystickGetDeviceInstanceID(i) == instance_id) { device_index = i; break; } } SDL_UnlockJoysticks(); return device_index; } SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { SDL_JoystickGUID emptyGUID; SDL_zero(emptyGUID); return emptyGUID; } return joystick->guid; } Uint16 SDL_JoystickGetVendor(SDL_Joystick * joystick) { Uint16 vendor; SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL); return vendor; } Uint16 SDL_JoystickGetProduct(SDL_Joystick * joystick) { Uint16 product; SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL); return product; } Uint16 SDL_JoystickGetProductVersion(SDL_Joystick * joystick) { Uint16 version; SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version); return version; } SDL_JoystickType SDL_JoystickGetType(SDL_Joystick * joystick) { SDL_JoystickType type; SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); type = SDL_GetJoystickGUIDType(guid); if (type == SDL_JOYSTICK_TYPE_UNKNOWN) { if (joystick && joystick->is_game_controller) { type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; } } return type; } /* convert the guid to a printable string */ void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID) { static const char k_rgchHexToASCII[] = "0123456789abcdef"; int i; if ((pszGUID == NULL) || (cbGUID <= 0)) { return; } for (i = 0; i < sizeof(guid.data) && i < (cbGUID-1)/2; i++) { /* each input byte writes 2 ascii chars, and might write a null byte. */ /* If we don't have room for next input byte, stop */ unsigned char c = guid.data[i]; *pszGUID++ = k_rgchHexToASCII[c >> 4]; *pszGUID++ = k_rgchHexToASCII[c & 0x0F]; } *pszGUID = '\0'; } /*----------------------------------------------------------------------------- * Purpose: Returns the 4 bit nibble for a hex character * Input : c - * Output : unsigned char *-----------------------------------------------------------------------------*/ static unsigned char nibble(char c) { if ((c >= '0') && (c <= '9')) { return (unsigned char)(c - '0'); } if ((c >= 'A') && (c <= 'F')) { return (unsigned char)(c - 'A' + 0x0a); } if ((c >= 'a') && (c <= 'f')) { return (unsigned char)(c - 'a' + 0x0a); } /* received an invalid character, and no real way to return an error */ /* AssertMsg1(false, "Q_nibble invalid hex character '%c' ", c); */ return 0; } /* convert the string version of a joystick guid to the struct */ SDL_JoystickGUID SDL_JoystickGetGUIDFromString(const char *pchGUID) { SDL_JoystickGUID guid; int maxoutputbytes= sizeof(guid); size_t len = SDL_strlen(pchGUID); Uint8 *p; size_t i; /* Make sure it's even */ len = (len) & ~0x1; SDL_memset(&guid, 0x00, sizeof(guid)); p = (Uint8 *)&guid; for (i = 0; (i < len) && ((p - (Uint8 *)&guid) < maxoutputbytes); i+=2, p++) { *p = (nibble(pchGUID[i]) << 4) | nibble(pchGUID[i+1]); } return guid; } /* update the power level for this joystick */ void SDL_PrivateJoystickBatteryLevel(SDL_Joystick * joystick, SDL_JoystickPowerLevel ePowerLevel) { joystick->epowerlevel = ePowerLevel; } /* return its power level */ SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick) { if (!SDL_PrivateJoystickValid(joystick)) { return SDL_JOYSTICK_POWER_UNKNOWN; } return joystick->epowerlevel; } /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\SDL_joystick_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" /* Useful functions and variables from SDL_joystick.c */ #include "SDL_joystick.h" struct _SDL_JoystickDriver; /* Initialization and shutdown functions */ extern int SDL_JoystickInit(void); extern void SDL_JoystickQuit(void); /* Function to get the next available joystick instance ID */ extern SDL_JoystickID SDL_GetNextJoystickInstanceID(void); /* Initialization and shutdown functions */ extern int SDL_GameControllerInitMappings(void); extern void SDL_GameControllerQuitMappings(void); extern int SDL_GameControllerInit(void); extern void SDL_GameControllerQuit(void); /* Function to get the joystick driver and device index for an API device index */ extern SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, struct _SDL_JoystickDriver **driver, int *driver_index); /* Function to return the device index for a joystick ID, or -1 if not found */ extern int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id); /* Function to extract information from an SDL joystick GUID */ extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version); /* Function to return whether a joystick is a PS4 controller */ extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is a Nintendo Switch Pro controller */ extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is a Steam Controller */ extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is an Xbox 360 controller */ extern SDL_bool SDL_IsJoystickXbox360(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is an Xbox One controller */ extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick guid comes from the XInput driver */ extern SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid); /* Function to return whether a joystick guid comes from the HIDAPI driver */ extern SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid); /* Function to return whether a joystick should be ignored */ extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid); /* Function to return whether a joystick name and GUID is a game controller */ extern SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid); /* Function to return whether a game controller should be ignored */ extern SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid); /* Handle delayed guide button on a game controller */ extern void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick); /* Internal event queueing functions */ extern void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance); extern void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance); extern int SDL_PrivateJoystickAxis(SDL_Joystick * joystick, Uint8 axis, Sint16 value); extern int SDL_PrivateJoystickBall(SDL_Joystick * joystick, Uint8 ball, Sint16 xrel, Sint16 yrel); extern int SDL_PrivateJoystickHat(SDL_Joystick * joystick, Uint8 hat, Uint8 value); extern int SDL_PrivateJoystickButton(SDL_Joystick * joystick, Uint8 button, Uint8 state); extern void SDL_PrivateJoystickBatteryLevel(SDL_Joystick * joystick, SDL_JoystickPowerLevel ePowerLevel); /* Internal sanity checking functions */ extern int SDL_PrivateJoystickValid(SDL_Joystick * joystick); /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\SDL_sysjoystick.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../SDL_internal.h" #ifndef SDL_sysjoystick_h_ #define SDL_sysjoystick_h_ /* This is the system specific header for the SDL joystick API */ #include "SDL_joystick.h" #include "SDL_joystick_c.h" /* The SDL joystick structure */ typedef struct _SDL_JoystickAxisInfo { Sint16 initial_value; /* Initial axis state */ Sint16 value; /* Current axis state */ Sint16 zero; /* Zero point on the axis (-32768 for triggers) */ SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */ SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */ } SDL_JoystickAxisInfo; struct _SDL_Joystick { SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */ char *name; /* Joystick name - system dependent */ SDL_JoystickGUID guid; /* Joystick guid */ int naxes; /* Number of axis controls on the joystick */ SDL_JoystickAxisInfo *axes; int nhats; /* Number of hats on the joystick */ Uint8 *hats; /* Current hat states */ int nballs; /* Number of trackballs on the joystick */ struct balldelta { int dx; int dy; } *balls; /* Current ball motion deltas */ int nbuttons; /* Number of buttons on the joystick */ Uint8 *buttons; /* Current button states */ SDL_bool attached; SDL_bool is_game_controller; SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */ SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */ SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */ struct _SDL_JoystickDriver *driver; struct joystick_hwdata *hwdata; /* Driver dependent information */ int ref_count; /* Reference count for multiple opens */ struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */ }; #if defined(__IPHONEOS__) || defined(__ANDROID__) #define HAVE_STEAMCONTROLLERS #define USE_STEAMCONTROLLER_HIDAPI #elif defined(__LINUX__) #define HAVE_STEAMCONTROLLERS #define USE_STEAMCONTROLLER_LINUX #endif /* Device bus definitions */ #define SDL_HARDWARE_BUS_USB 0x03 #define SDL_HARDWARE_BUS_BLUETOOTH 0x05 /* Macro to combine a USB vendor ID and product ID into a single Uint32 value */ #define MAKE_VIDPID(VID, PID) (((Uint32)(VID))<<16|(PID)) typedef struct _SDL_JoystickDriver { /* Function to scan the system for joysticks. * Joystick 0 should be the system default joystick. * This function should return 0, or -1 on an unrecoverable error. */ int (*Init)(void); /* Function to return the number of joystick devices plugged in right now */ int (*GetCount)(void); /* Function to cause any queued joystick insertions to be processed */ void (*Detect)(void); /* Function to get the device-dependent name of a joystick */ const char *(*GetDeviceName)(int device_index); /* Function to return the stable GUID for a plugged in device */ SDL_JoystickGUID (*GetDeviceGUID)(int device_index); /* Function to get the current instance id of the joystick located at device_index */ SDL_JoystickID (*GetDeviceInstanceID)(int device_index); /* Function to open a joystick for use. The joystick to open is specified by the device index. This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ int (*Open)(SDL_Joystick * joystick, int device_index); /* Rumble functionality */ int (*Rumble)(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); /* Function to update the state of a joystick - called as a device poll. * This function shouldn't update the joystick structure directly, * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ void (*Update)(SDL_Joystick * joystick); /* Function to close a joystick after use */ void (*Close)(SDL_Joystick * joystick); /* Function to perform any system-specific joystick related cleanup */ void (*Quit)(void); } SDL_JoystickDriver; /* The available joystick drivers */ extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; extern SDL_JoystickDriver SDL_BSD_JoystickDriver; extern SDL_JoystickDriver SDL_DARWIN_JoystickDriver; extern SDL_JoystickDriver SDL_DUMMY_JoystickDriver; extern SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver; extern SDL_JoystickDriver SDL_HAIKU_JoystickDriver; extern SDL_JoystickDriver SDL_HIDAPI_JoystickDriver; extern SDL_JoystickDriver SDL_IOS_JoystickDriver; extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver; #endif /* SDL_sysjoystick_h_ */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\android\SDL_sysjoystick.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_JOYSTICK_ANDROID #include <stdio.h> /* For the definition of NULL */ #include "SDL_error.h" #include "SDL_events.h" #include "SDL_joystick.h" #include "SDL_hints.h" #include "SDL_assert.h" #include "SDL_timer.h" #include "SDL_log.h" #include "SDL_sysjoystick_c.h" #include "../SDL_joystick_c.h" #include "../../events/SDL_keyboard_c.h" #include "../../core/android/SDL_android.h" #include "../hidapi/SDL_hidapijoystick_c.h" #include "android/keycodes.h" /* As of platform android-14, android/keycodes.h is missing these defines */ #ifndef AKEYCODE_BUTTON_1 #define AKEYCODE_BUTTON_1 188 #define AKEYCODE_BUTTON_2 189 #define AKEYCODE_BUTTON_3 190 #define AKEYCODE_BUTTON_4 191 #define AKEYCODE_BUTTON_5 192 #define AKEYCODE_BUTTON_6 193 #define AKEYCODE_BUTTON_7 194 #define AKEYCODE_BUTTON_8 195 #define AKEYCODE_BUTTON_9 196 #define AKEYCODE_BUTTON_10 197 #define AKEYCODE_BUTTON_11 198 #define AKEYCODE_BUTTON_12 199 #define AKEYCODE_BUTTON_13 200 #define AKEYCODE_BUTTON_14 201 #define AKEYCODE_BUTTON_15 202 #define AKEYCODE_BUTTON_16 203 #endif #define ANDROID_ACCELEROMETER_NAME "Android Accelerometer" #define ANDROID_ACCELEROMETER_DEVICE_ID INT_MIN #define ANDROID_MAX_NBUTTONS 36 static SDL_joylist_item * JoystickByDeviceId(int device_id); static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL; static int numjoysticks = 0; /* Public domain CRC implementation adapted from: http://home.thep.lu.se/~bjorn/crc/crc32_simple.c */ static Uint32 crc32_for_byte(Uint32 r) { int i; for(i = 0; i < 8; ++i) { r = (r & 1? 0: (Uint32)0xEDB88320L) ^ r >> 1; } return r ^ (Uint32)0xFF000000L; } static Uint32 crc32(const void *data, int count) { Uint32 crc = 0; int i; for(i = 0; i < count; ++i) { crc = crc32_for_byte((Uint8)crc ^ ((const Uint8*)data)[i]) ^ crc >> 8; } return crc; } /* Function to convert Android keyCodes into SDL ones. * This code manipulation is done to get a sequential list of codes. * FIXME: This is only suited for the case where we use a fixed number of buttons determined by ANDROID_MAX_NBUTTONS */ static int keycode_to_SDL(int keycode) { /* FIXME: If this function gets too unwieldy in the future, replace with a lookup table */ int button = 0; switch (keycode) { /* Some gamepad buttons (API 9) */ case AKEYCODE_BUTTON_A: button = SDL_CONTROLLER_BUTTON_A; break; case AKEYCODE_BUTTON_B: button = SDL_CONTROLLER_BUTTON_B; break; case AKEYCODE_BUTTON_X: button = SDL_CONTROLLER_BUTTON_X; break; case AKEYCODE_BUTTON_Y: button = SDL_CONTROLLER_BUTTON_Y; break; case AKEYCODE_BUTTON_L1: button = SDL_CONTROLLER_BUTTON_LEFTSHOULDER; break; case AKEYCODE_BUTTON_R1: button = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER; break; case AKEYCODE_BUTTON_THUMBL: button = SDL_CONTROLLER_BUTTON_LEFTSTICK; break; case AKEYCODE_BUTTON_THUMBR: button = SDL_CONTROLLER_BUTTON_RIGHTSTICK; break; case AKEYCODE_BUTTON_START: button = SDL_CONTROLLER_BUTTON_START; break; case AKEYCODE_BACK: case AKEYCODE_BUTTON_SELECT: button = SDL_CONTROLLER_BUTTON_BACK; break; case AKEYCODE_BUTTON_MODE: button = SDL_CONTROLLER_BUTTON_GUIDE; break; case AKEYCODE_BUTTON_L2: button = SDL_CONTROLLER_BUTTON_MAX; /* Not supported by GameController */ break; case AKEYCODE_BUTTON_R2: button = SDL_CONTROLLER_BUTTON_MAX+1; /* Not supported by GameController */ break; case AKEYCODE_BUTTON_C: button = SDL_CONTROLLER_BUTTON_MAX+2; /* Not supported by GameController */ break; case AKEYCODE_BUTTON_Z: button = SDL_CONTROLLER_BUTTON_MAX+3; /* Not supported by GameController */ break; /* D-Pad key codes (API 1) */ case AKEYCODE_DPAD_UP: button = SDL_CONTROLLER_BUTTON_DPAD_UP; break; case AKEYCODE_DPAD_DOWN: button = SDL_CONTROLLER_BUTTON_DPAD_DOWN; break; case AKEYCODE_DPAD_LEFT: button = SDL_CONTROLLER_BUTTON_DPAD_LEFT; break; case AKEYCODE_DPAD_RIGHT: button = SDL_CONTROLLER_BUTTON_DPAD_RIGHT; break; case AKEYCODE_DPAD_CENTER: /* This is handled better by applications as the A button */ /*button = SDL_CONTROLLER_BUTTON_MAX+4;*/ /* Not supported by GameController */ button = SDL_CONTROLLER_BUTTON_A; break; /* More gamepad buttons (API 12), these get mapped to 20...35*/ case AKEYCODE_BUTTON_1: case AKEYCODE_BUTTON_2: case AKEYCODE_BUTTON_3: case AKEYCODE_BUTTON_4: case AKEYCODE_BUTTON_5: case AKEYCODE_BUTTON_6: case AKEYCODE_BUTTON_7: case AKEYCODE_BUTTON_8: case AKEYCODE_BUTTON_9: case AKEYCODE_BUTTON_10: case AKEYCODE_BUTTON_11: case AKEYCODE_BUTTON_12: case AKEYCODE_BUTTON_13: case AKEYCODE_BUTTON_14: case AKEYCODE_BUTTON_15: case AKEYCODE_BUTTON_16: button = keycode - AKEYCODE_BUTTON_1 + SDL_CONTROLLER_BUTTON_MAX + 5; break; default: return -1; /* break; -Wunreachable-code-break */ } /* This is here in case future generations, probably with six fingers per hand, * happily add new cases up above and forget to update the max number of buttons. */ SDL_assert(button < ANDROID_MAX_NBUTTONS); return button; } static SDL_Scancode button_to_scancode(int button) { switch (button) { case SDL_CONTROLLER_BUTTON_A: return SDL_SCANCODE_RETURN; case SDL_CONTROLLER_BUTTON_B: return SDL_SCANCODE_ESCAPE; case SDL_CONTROLLER_BUTTON_BACK: return SDL_SCANCODE_ESCAPE; case SDL_CONTROLLER_BUTTON_DPAD_UP: return SDL_SCANCODE_UP; case SDL_CONTROLLER_BUTTON_DPAD_DOWN: return SDL_SCANCODE_DOWN; case SDL_CONTROLLER_BUTTON_DPAD_LEFT: return SDL_SCANCODE_LEFT; case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: return SDL_SCANCODE_RIGHT; } /* Unsupported button */ return SDL_SCANCODE_UNKNOWN; } int Android_OnPadDown(int device_id, int keycode) { SDL_joylist_item *item; int button = keycode_to_SDL(keycode); if (button >= 0) { item = JoystickByDeviceId(device_id); if (item && item->joystick) { SDL_PrivateJoystickButton(item->joystick, button, SDL_PRESSED); } else { SDL_SendKeyboardKey(SDL_PRESSED, button_to_scancode(button)); } return 0; } return -1; } int Android_OnPadUp(int device_id, int keycode) { SDL_joylist_item *item; int button = keycode_to_SDL(keycode); if (button >= 0) { item = JoystickByDeviceId(device_id); if (item && item->joystick) { SDL_PrivateJoystickButton(item->joystick, button, SDL_RELEASED); } else { SDL_SendKeyboardKey(SDL_RELEASED, button_to_scancode(button)); } return 0; } return -1; } int Android_OnJoy(int device_id, int axis, float value) { /* Android gives joy info normalized as [-1.0, 1.0] or [0.0, 1.0] */ SDL_joylist_item *item = JoystickByDeviceId(device_id); if (item && item->joystick) { SDL_PrivateJoystickAxis(item->joystick, axis, (Sint16) (32767.*value)); } return 0; } int Android_OnHat(int device_id, int hat_id, int x, int y) { const int DPAD_UP_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_UP); const int DPAD_DOWN_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_DOWN); const int DPAD_LEFT_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_LEFT); const int DPAD_RIGHT_MASK = (1 << SDL_CONTROLLER_BUTTON_DPAD_RIGHT); if (x >= -1 && x <= 1 && y >= -1 && y <= 1) { SDL_joylist_item *item = JoystickByDeviceId(device_id); if (item && item->joystick) { int dpad_state = 0; int dpad_delta; if (x < 0) { dpad_state |= DPAD_LEFT_MASK; } else if (x > 0) { dpad_state |= DPAD_RIGHT_MASK; } if (y < 0) { dpad_state |= DPAD_UP_MASK; } else if (y > 0) { dpad_state |= DPAD_DOWN_MASK; } dpad_delta = (dpad_state ^ item->dpad_state); if (dpad_delta) { if (dpad_delta & DPAD_UP_MASK) { SDL_PrivateJoystickButton(item->joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (dpad_state & DPAD_UP_MASK) ? SDL_PRESSED : SDL_RELEASED); } if (dpad_delta & DPAD_DOWN_MASK) { SDL_PrivateJoystickButton(item->joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, (dpad_state & DPAD_DOWN_MASK) ? SDL_PRESSED : SDL_RELEASED); } if (dpad_delta & DPAD_LEFT_MASK) { SDL_PrivateJoystickButton(item->joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (dpad_state & DPAD_LEFT_MASK) ? SDL_PRESSED : SDL_RELEASED); } if (dpad_delta & DPAD_RIGHT_MASK) { SDL_PrivateJoystickButton(item->joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (dpad_state & DPAD_RIGHT_MASK) ? SDL_PRESSED : SDL_RELEASED); } item->dpad_state = dpad_state; } } return 0; } return -1; } int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs) { SDL_joylist_item *item; SDL_JoystickGUID guid; Uint16 *guid16 = (Uint16 *)guid.data; int i; int axis_mask; if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { /* Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input */ if (naxes < 2 && nhats < 1) { return -1; } } if (JoystickByDeviceId(device_id) != NULL || name == NULL) { return -1; } #ifdef SDL_JOYSTICK_HIDAPI if (HIDAPI_IsDevicePresent(vendor_id, product_id, 0)) { /* The HIDAPI driver is taking care of this device */ return -1; } #endif #ifdef DEBUG_JOYSTICK SDL_Log("Joystick: %s, descriptor %s, vendor = 0x%.4x, product = 0x%.4x, %d axes, %d hats\n", name, desc, vendor_id, product_id, naxes, nhats); #endif /* Add the available buttons and axes The axis mask should probably come from Java where there is more information about the axes... */ axis_mask = 0; if (!is_accelerometer) { if (naxes >= 2) { axis_mask |= ((1 << SDL_CONTROLLER_AXIS_LEFTX) | (1 << SDL_CONTROLLER_AXIS_LEFTY)); } if (naxes >= 4) { axis_mask |= ((1 << SDL_CONTROLLER_AXIS_RIGHTX) | (1 << SDL_CONTROLLER_AXIS_RIGHTY)); } if (naxes >= 6) { axis_mask |= ((1 << SDL_CONTROLLER_AXIS_TRIGGERLEFT) | (1 << SDL_CONTROLLER_AXIS_TRIGGERRIGHT)); } } if (nhats > 0) { /* Hat is translated into DPAD buttons */ button_mask |= ((1 << SDL_CONTROLLER_BUTTON_DPAD_UP) | (1 << SDL_CONTROLLER_BUTTON_DPAD_DOWN) | (1 << SDL_CONTROLLER_BUTTON_DPAD_LEFT) | (1 << SDL_CONTROLLER_BUTTON_DPAD_RIGHT)); nhats = 0; } SDL_memset(guid.data, 0, sizeof(guid.data)); /* We only need 16 bits for each of these; space them out to fill 128. */ /* Byteswap so devices get same GUID on little/big endian platforms. */ *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH); *guid16++ = 0; if (vendor_id && product_id) { *guid16++ = SDL_SwapLE16(vendor_id); *guid16++ = 0; *guid16++ = SDL_SwapLE16(product_id); *guid16++ = 0; } else { Uint32 crc = crc32(desc, SDL_strlen(desc)); SDL_memcpy(guid16, desc, SDL_min(2*sizeof(*guid16), SDL_strlen(desc))); guid16 += 2; *(Uint32 *)guid16 = SDL_SwapLE32(crc); guid16 += 2; } *guid16++ = SDL_SwapLE16(button_mask); *guid16++ = SDL_SwapLE16(axis_mask); item = (SDL_joylist_item *) SDL_malloc(sizeof (SDL_joylist_item)); if (item == NULL) { return -1; } SDL_zerop(item); item->guid = guid; item->device_id = device_id; item->name = SDL_strdup(name); if (item->name == NULL) { SDL_free(item); return -1; } item->is_accelerometer = is_accelerometer; if (button_mask == 0xFFFFFFFF) { item->nbuttons = ANDROID_MAX_NBUTTONS; } else { for (i = 0; i < sizeof(button_mask)*8; ++i) { if (button_mask & (1 << i)) { item->nbuttons = i+1; } } } item->naxes = naxes; item->nhats = nhats; item->nballs = nballs; item->device_instance = SDL_GetNextJoystickInstanceID(); if (SDL_joylist_tail == NULL) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; SDL_joylist_tail = item; } /* Need to increment the joystick count before we post the event */ ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); #ifdef DEBUG_JOYSTICK SDL_Log("Added joystick %s with device_id %d", name, device_id); #endif return numjoysticks; } int Android_RemoveJoystick(int device_id) { SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ while (item != NULL) { if (item->device_id == device_id) { break; } prev = item; item = item->next; } if (item == NULL) { return -1; } if (item->joystick) { item->joystick->hwdata = NULL; } if (prev != NULL) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); SDL_joylist = item->next; } if (item == SDL_joylist_tail) { SDL_joylist_tail = prev; } /* Need to decrement the joystick count before we post the event */ --numjoysticks; SDL_PrivateJoystickRemoved(item->device_instance); #ifdef DEBUG_JOYSTICK SDL_Log("Removed joystick with device_id %d", device_id); #endif SDL_free(item->name); SDL_free(item); return numjoysticks; } static void ANDROID_JoystickDetect(); static int ANDROID_JoystickInit(void) { ANDROID_JoystickDetect(); if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE)) { /* Default behavior, accelerometer as joystick */ Android_AddJoystick(ANDROID_ACCELEROMETER_DEVICE_ID, ANDROID_ACCELEROMETER_NAME, ANDROID_ACCELEROMETER_NAME, 0, 0, SDL_TRUE, 0, 3, 0, 0); } return 0; } static int ANDROID_JoystickGetCount(void) { return numjoysticks; } static void ANDROID_JoystickDetect(void) { /* Support for device connect/disconnect is API >= 16 only, * so we poll every three seconds * Ref: http://developer.android.com/reference/android/hardware/input/InputManager.InputDeviceListener.html */ static Uint32 timeout = 0; if (!timeout || SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { timeout = SDL_GetTicks() + 3000; Android_JNI_PollInputDevices(); } } static SDL_joylist_item * JoystickByDevIndex(int device_index) { SDL_joylist_item *item = SDL_joylist; if ((device_index < 0) || (device_index >= numjoysticks)) { return NULL; } while (device_index > 0) { SDL_assert(item != NULL); device_index--; item = item->next; } return item; } static SDL_joylist_item * JoystickByDeviceId(int device_id) { SDL_joylist_item *item = SDL_joylist; while (item != NULL) { if (item->device_id == device_id) { return item; } item = item->next; } /* Joystick not found, try adding it */ ANDROID_JoystickDetect(); while (item != NULL) { if (item->device_id == device_id) { return item; } item = item->next; } return NULL; } static const char * ANDROID_JoystickGetDeviceName(int device_index) { return JoystickByDevIndex(device_index)->name; } static SDL_JoystickGUID ANDROID_JoystickGetDeviceGUID(int device_index) { return JoystickByDevIndex(device_index)->guid; } static SDL_JoystickID ANDROID_JoystickGetDeviceInstanceID(int device_index) { return JoystickByDevIndex(device_index)->device_instance; } static int ANDROID_JoystickOpen(SDL_Joystick * joystick, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); if (item == NULL) { return SDL_SetError("No such device"); } if (item->joystick != NULL) { return SDL_SetError("Joystick already opened"); } joystick->instance_id = item->device_instance; joystick->hwdata = (struct joystick_hwdata *) item; item->joystick = joystick; joystick->nhats = item->nhats; joystick->nballs = item->nballs; joystick->nbuttons = item->nbuttons; joystick->naxes = item->naxes; return (0); } static int ANDROID_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { return SDL_Unsupported(); } static void ANDROID_JoystickUpdate(SDL_Joystick * joystick) { SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; if (item == NULL) { return; } if (item->is_accelerometer) { int i; Sint16 value; float values[3]; if (Android_JNI_GetAccelerometerValues(values)) { for (i = 0; i < 3; i++) { if (values[i] > 1.0f) { values[i] = 1.0f; } else if (values[i] < -1.0f) { values[i] = -1.0f; } value = (Sint16)(values[i] * 32767.0f); SDL_PrivateJoystickAxis(item->joystick, i, value); } } } } static void ANDROID_JoystickClose(SDL_Joystick * joystick) { SDL_joylist_item *item = (SDL_joylist_item *) joystick->hwdata; if (item) { item->joystick = NULL; } } static void ANDROID_JoystickQuit(void) { /* We don't have any way to scan for joysticks at init, so don't wipe the list * of joysticks here in case this is a reinit. */ #if 0 SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; for (item = SDL_joylist; item; item = next) { next = item->next; SDL_free(item->name); SDL_free(item); } SDL_joylist = SDL_joylist_tail = NULL; numjoysticks = 0; #endif /* 0 */ } SDL_JoystickDriver SDL_ANDROID_JoystickDriver = { ANDROID_JoystickInit, ANDROID_JoystickGetCount, ANDROID_JoystickDetect, ANDROID_JoystickGetDeviceName, ANDROID_JoystickGetDeviceGUID, ANDROID_JoystickGetDeviceInstanceID, ANDROID_JoystickOpen, ANDROID_JoystickRumble, ANDROID_JoystickUpdate, ANDROID_JoystickClose, ANDROID_JoystickQuit, }; #endif /* SDL_JOYSTICK_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\android\SDL_sysjoystick_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_JOYSTICK_ANDROID #ifndef SDL_sysjoystick_c_h_ #define SDL_sysjoystick_c_h_ #include "../SDL_sysjoystick.h" extern int Android_OnPadDown(int device_id, int keycode); extern int Android_OnPadUp(int device_id, int keycode); extern int Android_OnJoy(int device_id, int axisnum, float value); extern int Android_OnHat(int device_id, int hat_id, int x, int y); extern int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, SDL_bool is_accelerometer, int button_mask, int naxes, int nhats, int nballs); extern int Android_RemoveJoystick(int device_id); /* A linked list of available joysticks */ typedef struct SDL_joylist_item { int device_instance; int device_id; /* Android's device id */ char *name; /* "SideWinder 3D Pro" or whatever */ SDL_JoystickGUID guid; SDL_bool is_accelerometer; SDL_Joystick *joystick; int nbuttons, naxes, nhats, nballs; int dpad_state; struct SDL_joylist_item *next; } SDL_joylist_item; typedef SDL_joylist_item joystick_hwdata; #endif /* SDL_sysjoystick_c_h_ */ #endif /* SDL_JOYSTICK_ANDROID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\bsd\SDL_sysjoystick.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_JOYSTICK_USBHID /* * Joystick driver for the uhid(4) interface found in OpenBSD, * NetBSD and FreeBSD. * * Maintainer: <vedge at csoft.org> */ #include <sys/param.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #ifndef __FreeBSD_kernel_version #define __FreeBSD_kernel_version __FreeBSD_version #endif #if defined(HAVE_USB_H) #include <usb.h> #endif #ifdef __DragonFly__ #include <bus/usb/usb.h> #include <bus/usb/usbhid.h> #else #include <dev/usb/usb.h> #include <dev/usb/usbhid.h> #endif #if defined(HAVE_USBHID_H) #include <usbhid.h> #elif defined(HAVE_LIBUSB_H) #include <libusb.h> #elif defined(HAVE_LIBUSBHID_H) #include <libusbhid.h> #endif #if defined(__FREEBSD__) || defined(__FreeBSD_kernel__) #ifndef __DragonFly__ #include <osreldate.h> #endif #if __FreeBSD_kernel_version > 800063 #include <dev/usb/usb_ioctl.h> #endif #include <sys/joystick.h> #endif #if SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H #include <machine/joystick.h> #endif #include "SDL_joystick.h" #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" #define MAX_UHID_JOYS 64 #define MAX_JOY_JOYS 2 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) struct report { #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) void *buf; /* Buffer */ #elif defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) struct usb_gen_descriptor *buf; /* Buffer */ #else struct usb_ctl_report *buf; /* Buffer */ #endif size_t size; /* Buffer size */ int rid; /* Report ID */ enum { SREPORT_UNINIT, SREPORT_CLEAN, SREPORT_DIRTY } status; }; static struct { int uhid_report; hid_kind_t kind; const char *name; } const repinfo[] = { {UHID_INPUT_REPORT, hid_input, "input"}, {UHID_OUTPUT_REPORT, hid_output, "output"}, {UHID_FEATURE_REPORT, hid_feature, "feature"} }; enum { REPORT_INPUT = 0, REPORT_OUTPUT = 1, REPORT_FEATURE = 2 }; enum { JOYAXE_X, JOYAXE_Y, JOYAXE_Z, JOYAXE_SLIDER, JOYAXE_WHEEL, JOYAXE_RX, JOYAXE_RY, JOYAXE_RZ, JOYAXE_count }; struct joystick_hwdata { int fd; char *path; enum { BSDJOY_UHID, /* uhid(4) */ BSDJOY_JOY /* joy(4) */ } type; struct report_desc *repdesc; struct report inreport; int axis_map[JOYAXE_count]; /* map present JOYAXE_* to 0,1,.. */ }; static char *joynames[MAX_JOYS]; static char *joydevnames[MAX_JOYS]; static int report_alloc(struct report *, struct report_desc *, int); static void report_free(struct report *); #if defined(USBHID_UCR_DATA) || (defined(__FreeBSD_kernel__) && __FreeBSD_kernel_version <= 800063) #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000)) #define REP_BUF_DATA(rep) ((rep)->buf) #elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) #define REP_BUF_DATA(rep) ((rep)->buf->ugd_data) #else #define REP_BUF_DATA(rep) ((rep)->buf->data) #endif static int numjoysticks = 0; static int BSD_JoystickOpen(SDL_Joystick * joy, int device_index); static void BSD_JoystickClose(SDL_Joystick * joy); static int BSD_JoystickInit(void) { char s[16]; int i, fd; numjoysticks = 0; SDL_memset(joynames, 0, sizeof(joynames)); SDL_memset(joydevnames, 0, sizeof(joydevnames)); for (i = 0; i < MAX_UHID_JOYS; i++) { SDL_Joystick nj; SDL_snprintf(s, SDL_arraysize(s), "/dev/uhid%d", i); joynames[numjoysticks] = SDL_strdup(s); if (BSD_JoystickOpen(&nj, numjoysticks) == 0) { BSD_JoystickClose(&nj); numjoysticks++; } else { SDL_free(joynames[numjoysticks]); joynames[numjoysticks] = NULL; } } for (i = 0; i < MAX_JOY_JOYS; i++) { SDL_snprintf(s, SDL_arraysize(s), "/dev/joy%d", i); fd = open(s, O_RDONLY); if (fd != -1) { joynames[numjoysticks++] = SDL_strdup(s); close(fd); } } /* Read the default USB HID usage table. */ hid_init(NULL); return (numjoysticks); } static int BSD_JoystickGetCount(void) { return numjoysticks; } static void BSD_JoystickDetect(void) { } static const char * BSD_JoystickGetDeviceName(int device_index) { if (joydevnames[device_index] != NULL) { return (joydevnames[device_index]); } return (joynames[device_index]); } /* Function to perform the mapping from device index to the instance id for this index */ static SDL_JoystickID BSD_JoystickGetDeviceInstanceID(int device_index) { return device_index; } static int usage_to_joyaxe(unsigned usage) { int joyaxe; switch (usage) { case HUG_X: joyaxe = JOYAXE_X; break; case HUG_Y: joyaxe = JOYAXE_Y; break; case HUG_Z: joyaxe = JOYAXE_Z; break; case HUG_SLIDER: joyaxe = JOYAXE_SLIDER; break; case HUG_WHEEL: joyaxe = JOYAXE_WHEEL; break; case HUG_RX: joyaxe = JOYAXE_RX; break; case HUG_RY: joyaxe = JOYAXE_RY; break; case HUG_RZ: joyaxe = JOYAXE_RZ; break; default: joyaxe = -1; } return joyaxe; } static unsigned hatval_to_sdl(Sint32 hatval) { static const unsigned hat_dir_map[8] = { SDL_HAT_UP, SDL_HAT_RIGHTUP, SDL_HAT_RIGHT, SDL_HAT_RIGHTDOWN, SDL_HAT_DOWN, SDL_HAT_LEFTDOWN, SDL_HAT_LEFT, SDL_HAT_LEFTUP }; unsigned result; if ((hatval & 7) == hatval) result = hat_dir_map[hatval]; else result = SDL_HAT_CENTERED; return result; } static int BSD_JoystickOpen(SDL_Joystick * joy, int device_index) { char *path = joynames[device_index]; struct joystick_hwdata *hw; struct hid_item hitem; struct hid_data *hdata; struct report *rep = NULL; int fd; int i; fd = open(path, O_RDONLY); if (fd == -1) { return SDL_SetError("%s: %s", path, strerror(errno)); } joy->instance_id = device_index; hw = (struct joystick_hwdata *) SDL_malloc(sizeof(struct joystick_hwdata)); if (hw == NULL) { close(fd); return SDL_OutOfMemory(); } joy->hwdata = hw; hw->fd = fd; hw->path = SDL_strdup(path); if (!SDL_strncmp(path, "/dev/joy", 8)) { hw->type = BSDJOY_JOY; joy->naxes = 2; joy->nbuttons = 2; joy->nhats = 0; joy->nballs = 0; joydevnames[device_index] = SDL_strdup("Gameport joystick"); goto usbend; } else { hw->type = BSDJOY_UHID; } { int ax; for (ax = 0; ax < JOYAXE_count; ax++) hw->axis_map[ax] = -1; } hw->repdesc = hid_get_report_desc(fd); if (hw->repdesc == NULL) { SDL_SetError("%s: USB_GET_REPORT_DESC: %s", hw->path, strerror(errno)); goto usberr; } rep = &hw->inreport; #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) || defined(__FreeBSD_kernel__) rep->rid = hid_get_report_id(fd); if (rep->rid < 0) { #else if (ioctl(fd, USB_GET_REPORT_ID, &rep->rid) < 0) { #endif rep->rid = -1; /* XXX */ } #if defined(__NetBSD__) usb_device_descriptor_t udd; struct usb_string_desc usd; if (ioctl(fd, USB_GET_DEVICE_DESC, &udd) == -1) goto desc_failed; /* Get default language */ usd.usd_string_index = USB_LANGUAGE_TABLE; usd.usd_language_id = 0; if (ioctl(fd, USB_GET_STRING_DESC, &usd) == -1 || usd.usd_desc.bLength < 4) { usd.usd_language_id = 0; } else { usd.usd_language_id = UGETW(usd.usd_desc.bString[0]); } usd.usd_string_index = udd.iProduct; if (ioctl(fd, USB_GET_STRING_DESC, &usd) == 0) { char str[128]; char *new_name = NULL; int i; for (i = 0; i < (usd.usd_desc.bLength >> 1) - 1 && i < sizeof(str) - 1; i++) { str[i] = UGETW(usd.usd_desc.bString[i]); } str[i] = '\0'; asprintf(&new_name, "%s @ %s", str, path); if (new_name != NULL) { SDL_free(joydevnames[numjoysticks]); joydevnames[numjoysticks] = new_name; } } desc_failed: #endif if (report_alloc(rep, hw->repdesc, REPORT_INPUT) < 0) { goto usberr; } if (rep->size <= 0) { SDL_SetError("%s: Input report descriptor has invalid length", hw->path); goto usberr; } #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) hdata = hid_start_parse(hw->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); #endif if (hdata == NULL) { SDL_SetError("%s: Cannot start HID parser", hw->path); goto usberr; } joy->naxes = 0; joy->nbuttons = 0; joy->nhats = 0; joy->nballs = 0; for (i = 0; i < JOYAXE_count; i++) hw->axis_map[i] = -1; while (hid_get_item(hdata, &hitem) > 0) { char *sp; const char *s; switch (hitem.kind) { case hid_collection: switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: switch (HID_USAGE(hitem.usage)) { case HUG_JOYSTICK: case HUG_GAME_PAD: s = hid_usage_in_page(hitem.usage); sp = SDL_malloc(SDL_strlen(s) + 5); SDL_snprintf(sp, SDL_strlen(s) + 5, "%s (%d)", s, device_index); joydevnames[device_index] = sp; } } break; case hid_input: switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: { unsigned usage = HID_USAGE(hitem.usage); int joyaxe = usage_to_joyaxe(usage); if (joyaxe >= 0) { hw->axis_map[joyaxe] = 1; } else if (usage == HUG_HAT_SWITCH) { joy->nhats++; } break; } case HUP_BUTTON: joy->nbuttons++; break; default: break; } break; default: break; } } hid_end_parse(hdata); for (i = 0; i < JOYAXE_count; i++) if (hw->axis_map[i] > 0) hw->axis_map[i] = joy->naxes++; if (joy->naxes == 0 && joy->nbuttons == 0 && joy->nhats == 0 && joy->nballs == 0) { SDL_SetError("%s: Not a joystick, ignoring", hw->path); goto usberr; } usbend: /* The poll blocks the event thread. */ fcntl(fd, F_SETFL, O_NONBLOCK); #ifdef __NetBSD__ /* Flush pending events */ if (rep) { while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) ; } #endif return (0); usberr: close(hw->fd); SDL_free(hw->path); SDL_free(hw); return (-1); } static void BSD_JoystickUpdate(SDL_Joystick * joy) { struct hid_item hitem; struct hid_data *hdata; struct report *rep; int nbutton, naxe = -1; Sint32 v; #if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) struct joystick gameport; static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; if (joy->hwdata->type == BSDJOY_JOY) { while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) { if (abs(x - gameport.x) > 8) { x = gameport.x; if (x < xmin) { xmin = x; } if (x > xmax) { xmax = x; } if (xmin == xmax) { xmin--; xmax++; } v = (Sint32) x; v -= (xmax + xmin + 1) / 2; v *= 32768 / ((xmax - xmin + 1) / 2); SDL_PrivateJoystickAxis(joy, 0, v); } if (abs(y - gameport.y) > 8) { y = gameport.y; if (y < ymin) { ymin = y; } if (y > ymax) { ymax = y; } if (ymin == ymax) { ymin--; ymax++; } v = (Sint32) y; v -= (ymax + ymin + 1) / 2; v *= 32768 / ((ymax - ymin + 1) / 2); SDL_PrivateJoystickAxis(joy, 1, v); } SDL_PrivateJoystickButton(joy, 0, gameport.b1); SDL_PrivateJoystickButton(joy, 1, gameport.b2); } return; } #endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ rep = &joy->hwdata->inreport; while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) { #if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__) hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid); #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif if (hdata == NULL) { /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ continue; } for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) { switch (hitem.kind) { case hid_input: switch (HID_PAGE(hitem.usage)) { case HUP_GENERIC_DESKTOP: { unsigned usage = HID_USAGE(hitem.usage); int joyaxe = usage_to_joyaxe(usage); if (joyaxe >= 0) { naxe = joy->hwdata->axis_map[joyaxe]; /* scaleaxe */ v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); v -= (hitem.logical_maximum + hitem.logical_minimum + 1) / 2; v *= 32768 / ((hitem.logical_maximum - hitem.logical_minimum + 1) / 2); SDL_PrivateJoystickAxis(joy, naxe, v); } else if (usage == HUG_HAT_SWITCH) { v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); SDL_PrivateJoystickHat(joy, 0, hatval_to_sdl(v) - hitem.logical_minimum); } break; } case HUP_BUTTON: v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem); SDL_PrivateJoystickButton(joy, nbutton, v); nbutton++; break; default: continue; } break; default: break; } } hid_end_parse(hdata); } } /* Function to close a joystick after use */ static void BSD_JoystickClose(SDL_Joystick * joy) { if (SDL_strncmp(joy->hwdata->path, "/dev/joy", 8)) { report_free(&joy->hwdata->inreport); hid_dispose_report_desc(joy->hwdata->repdesc); } close(joy->hwdata->fd); SDL_free(joy->hwdata->path); SDL_free(joy->hwdata); } static void BSD_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYS; i++) { SDL_free(joynames[i]); SDL_free(joydevnames[i]); } return; } static SDL_JoystickGUID BSD_JoystickGetDeviceGUID( int device_index ) { SDL_JoystickGUID guid; /* the GUID is just the first 16 chars of the name for now */ const char *name = BSD_JoystickGetDeviceName( device_index ); SDL_zero( guid ); SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); return guid; } static int report_alloc(struct report *r, struct report_desc *rd, int repind) { int len; #ifdef __DragonFly__ len = hid_report_size(rd, r->rid, repinfo[repind].kind); #elif __FREEBSD__ # if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) # if (__FreeBSD_kernel_version <= 500111) len = hid_report_size(rd, r->rid, repinfo[repind].kind); # else len = hid_report_size(rd, repinfo[repind].kind, r->rid); # endif # else len = hid_report_size(rd, repinfo[repind].kind, &r->rid); # endif #else # ifdef USBHID_NEW len = hid_report_size(rd, repinfo[repind].kind, r->rid); # else len = hid_report_size(rd, repinfo[repind].kind, &r->rid); # endif #endif if (len < 0) { return SDL_SetError("Negative HID report size"); } r->size = len; if (r->size > 0) { #if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 900000) r->buf = SDL_malloc(r->size); #else r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + r->size); #endif if (r->buf == NULL) { return SDL_OutOfMemory(); } } else { r->buf = NULL; } r->status = SREPORT_CLEAN; return 0; } static void report_free(struct report *r) { SDL_free(r->buf); r->status = SREPORT_UNINIT; } static int BSD_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { return SDL_Unsupported(); } SDL_JoystickDriver SDL_BSD_JoystickDriver = { BSD_JoystickInit, BSD_JoystickGetCount, BSD_JoystickDetect, BSD_JoystickGetDeviceName, BSD_JoystickGetDeviceGUID, BSD_JoystickGetDeviceInstanceID, BSD_JoystickOpen, BSD_JoystickRumble, BSD_JoystickUpdate, BSD_JoystickClose, BSD_JoystickQuit, }; #endif /* SDL_JOYSTICK_USBHID */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\darwin\SDL_sysjoystick.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifdef SDL_JOYSTICK_IOKIT #include "SDL_events.h" #include "SDL_joystick.h" #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" #include "SDL_sysjoystick_c.h" #include "../hidapi/SDL_hidapijoystick_c.h" #include "../../haptic/darwin/SDL_syshaptic_c.h" /* For haptic hot plugging */ #define SDL_JOYSTICK_RUNLOOP_MODE CFSTR("SDLJoystick") #define CONVERT_MAGNITUDE(x) (((x)*10000) / 0x7FFF) /* The base object of the HID Manager API */ static IOHIDManagerRef hidman = NULL; /* Linked list of all available devices */ static recDevice *gpDeviceList = NULL; void FreeRumbleEffectData(FFEFFECT *effect) { if (!effect) { return; } SDL_free(effect->rgdwAxes); SDL_free(effect->rglDirection); SDL_free(effect->lpvTypeSpecificParams); SDL_free(effect); } FFEFFECT *CreateRumbleEffectData(Sint16 magnitude, Uint32 duration_ms) { FFEFFECT *effect; FFPERIODIC *periodic; /* Create the effect */ effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect)); if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); effect->dwGain = 10000; effect->dwFlags = FFEFF_OBJECTOFFSETS; effect->dwDuration = duration_ms * 1000; /* In microseconds. */ effect->dwTriggerButton = FFEB_NOTRIGGER; effect->cAxes = 2; effect->rgdwAxes = (DWORD *)SDL_calloc(effect->cAxes, sizeof(DWORD)); if (!effect->rgdwAxes) { FreeRumbleEffectData(effect); return NULL; } effect->rglDirection = (LONG *)SDL_calloc(effect->cAxes, sizeof(LONG)); if (!effect->rglDirection) { FreeRumbleEffectData(effect); return NULL; } effect->dwFlags |= FFEFF_CARTESIAN; periodic = (FFPERIODIC *)SDL_calloc(1, sizeof(*periodic)); if (!periodic) { FreeRumbleEffectData(effect); return NULL; } periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude); periodic->dwPeriod = 1000000; effect->cbTypeSpecificParams = sizeof(*periodic); effect->lpvTypeSpecificParams = periodic; return effect; } static recDevice *GetDeviceForIndex(int device_index) { recDevice *device = gpDeviceList; while (device) { if (!device->removed) { if (device_index == 0) break; --device_index; } device = device->pNext; } return device; } static void FreeElementList(recElement *pElement) { while (pElement) { recElement *pElementNext = pElement->pNext; SDL_free(pElement); pElement = pElementNext; } } static recDevice * FreeDevice(recDevice *removeDevice) { recDevice *pDeviceNext = NULL; if (removeDevice) { if (removeDevice->deviceRef) { IOHIDDeviceUnscheduleFromRunLoop(removeDevice->deviceRef, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); removeDevice->deviceRef = NULL; } /* save next device prior to disposing of this device */ pDeviceNext = removeDevice->pNext; if ( gpDeviceList == removeDevice ) { gpDeviceList = pDeviceNext; } else { recDevice *device = gpDeviceList; while (device->pNext != removeDevice) { device = device->pNext; } device->pNext = pDeviceNext; } removeDevice->pNext = NULL; /* free element lists */ FreeElementList(removeDevice->firstAxis); FreeElementList(removeDevice->firstButton); FreeElementList(removeDevice->firstHat); SDL_free(removeDevice); } return pDeviceNext; } static SDL_bool GetHIDElementState(recDevice *pDevice, recElement *pElement, SInt32 *pValue) { SInt32 value = 0; int returnValue = SDL_FALSE; if (pDevice && pElement) { IOHIDValueRef valueRef; if (IOHIDDeviceGetValue(pDevice->deviceRef, pElement->elementRef, &valueRef) == kIOReturnSuccess) { value = (SInt32) IOHIDValueGetIntegerValue(valueRef); /* record min and max for auto calibration */ if (value < pElement->minReport) { pElement->minReport = value; } if (value > pElement->maxReport) { pElement->maxReport = value; } *pValue = value; returnValue = SDL_TRUE; } } return returnValue; } static SDL_bool GetHIDScaledCalibratedState(recDevice * pDevice, recElement * pElement, SInt32 min, SInt32 max, SInt32 *pValue) { const float deviceScale = max - min; const float readScale = pElement->maxReport - pElement->minReport; int returnValue = SDL_FALSE; if (GetHIDElementState(pDevice, pElement, pValue)) { if (readScale == 0) { returnValue = SDL_TRUE; /* no scaling at all */ } else { *pValue = ((*pValue - pElement->minReport) * deviceScale / readScale) + min; returnValue = SDL_TRUE; } } return returnValue; } static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) { recDevice *device = (recDevice *) ctx; device->removed = SDL_TRUE; device->deviceRef = NULL; // deviceRef was invalidated due to the remove if (device->ffeffect_ref) { FFDeviceReleaseEffect(device->ffdevice, device->ffeffect_ref); device->ffeffect_ref = NULL; } if (device->ffeffect) { FreeRumbleEffectData(device->ffeffect); device->ffeffect = NULL; } if (device->ffdevice) { FFReleaseDevice(device->ffdevice); device->ffdevice = NULL; device->ff_initialized = SDL_FALSE; } #if SDL_HAPTIC_IOKIT MacHaptic_MaybeRemoveDevice(device->ffservice); #endif SDL_PrivateJoystickRemoved(device->instance_id); } static void AddHIDElement(const void *value, void *parameter); /* Call AddHIDElement() on all elements in an array of IOHIDElementRefs */ static void AddHIDElements(CFArrayRef array, recDevice *pDevice) { const CFRange range = { 0, CFArrayGetCount(array) }; CFArrayApplyFunction(array, range, AddHIDElement, pDevice); } static SDL_bool ElementAlreadyAdded(const IOHIDElementCookie cookie, const recElement *listitem) { while (listitem) { if (listitem->cookie == cookie) { return SDL_TRUE; } listitem = listitem->pNext; } return SDL_FALSE; } /* See if we care about this HID element, and if so, note it in our recDevice. */ static void AddHIDElement(const void *value, void *parameter) { recDevice *pDevice = (recDevice *) parameter; IOHIDElementRef refElement = (IOHIDElementRef) value; const CFTypeID elementTypeID = refElement ? CFGetTypeID(refElement) : 0; if (refElement && (elementTypeID == IOHIDElementGetTypeID())) { const IOHIDElementCookie cookie = IOHIDElementGetCookie(refElement); const uint32_t usagePage = IOHIDElementGetUsagePage(refElement); const uint32_t usage = IOHIDElementGetUsage(refElement); recElement *element = NULL; recElement **headElement = NULL; /* look at types of interest */ switch (IOHIDElementGetType(refElement)) { case kIOHIDElementTypeInput_Misc: case kIOHIDElementTypeInput_Button: case kIOHIDElementTypeInput_Axis: { switch (usagePage) { /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ case kHIDPage_GenericDesktop: switch (usage) { case kHIDUsage_GD_X: case kHIDUsage_GD_Y: case kHIDUsage_GD_Z: case kHIDUsage_GD_Rx: case kHIDUsage_GD_Ry: case kHIDUsage_GD_Rz: case kHIDUsage_GD_Slider: case kHIDUsage_GD_Dial: case kHIDUsage_GD_Wheel: if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { element = (recElement *) SDL_calloc(1, sizeof (recElement)); if (element) { pDevice->axes++; headElement = &(pDevice->firstAxis); } } break; case kHIDUsage_GD_Hatswitch: if (!ElementAlreadyAdded(cookie, pDevice->firstHat)) { element = (recElement *) SDL_calloc(1, sizeof (recElement)); if (element) { pDevice->hats++; headElement = &(pDevice->firstHat); } } break; case kHIDUsage_GD_DPadUp: case kHIDUsage_GD_DPadDown: case kHIDUsage_GD_DPadRight: case kHIDUsage_GD_DPadLeft: case kHIDUsage_GD_Start: case kHIDUsage_GD_Select: case kHIDUsage_GD_SystemMainMenu: if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { element = (recElement *) SDL_calloc(1, sizeof (recElement)); if (element) { pDevice->buttons++; headElement = &(pDevice->firstButton); } } break; } break; case kHIDPage_Simulation: switch (usage) { case kHIDUsage_Sim_Rudder: case kHIDUsage_Sim_Throttle: case kHIDUsage_Sim_Accelerator: case kHIDUsage_Sim_Brake: if (!ElementAlreadyAdded(cookie, pDevice->firstAxis)) { element = (recElement *) SDL_calloc(1, sizeof (recElement)); if (element) { pDevice->axes++; headElement = &(pDevice->firstAxis); } } break; default: break; } break; case kHIDPage_Button: case kHIDPage_Consumer: /* e.g. 'pause' button on Steelseries MFi gamepads. */ if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) { element = (recElement *) SDL_calloc(1, sizeof (recElement)); if (element) { pDevice->buttons++; headElement = &(pDevice->firstButton); } } break; default: break; } } break; case kIOHIDElementTypeCollection: { CFArrayRef array = IOHIDElementGetChildren(refElement); if (array) { AddHIDElements(array, pDevice); } } break; default: break; } if (element && headElement) { /* add to list */ recElement *elementPrevious = NULL; recElement *elementCurrent = *headElement; while (elementCurrent && usage >= elementCurrent->usage) { elementPrevious = elementCurrent; elementCurrent = elementCurrent->pNext; } if (elementPrevious) { elementPrevious->pNext = element; } else { *headElement = element; } element->elementRef = refElement; element->usagePage = usagePage; element->usage = usage; element->pNext = elementCurrent; element->minReport = element->min = (SInt32) IOHIDElementGetLogicalMin(refElement); element->maxReport = element->max = (SInt32) IOHIDElementGetLogicalMax(refElement); element->cookie = IOHIDElementGetCookie(refElement); pDevice->elements++; } } } static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) { Sint32 vendor = 0; Sint32 product = 0; Sint32 version = 0; CFTypeRef refCF = NULL; CFArrayRef array = NULL; Uint16 *guid16 = (Uint16 *)pDevice->guid.data; /* get usage page and usage */ refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usagePage); } if (pDevice->usagePage != kHIDPage_GenericDesktop) { return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsageKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->usage); } if ((pDevice->usage != kHIDUsage_GD_Joystick && pDevice->usage != kHIDUsage_GD_GamePad && pDevice->usage != kHIDUsage_GD_MultiAxisController)) { return SDL_FALSE; /* Filter device list to non-keyboard/mouse stuff */ } pDevice->deviceRef = hidDevice; /* get device name */ refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductKey)); if (!refCF) { /* Maybe we can't get "AwesomeJoystick2000", but we can get "Logitech"? */ refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDManufacturerKey)); } if ((!refCF) || (!CFStringGetCString(refCF, pDevice->product, sizeof (pDevice->product), kCFStringEncodingUTF8))) { SDL_strlcpy(pDevice->product, "Unidentified joystick", sizeof (pDevice->product)); } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &vendor); } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &product); } refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVersionNumberKey)); if (refCF) { CFNumberGetValue(refCF, kCFNumberSInt32Type, &version); } #ifdef SDL_JOYSTICK_HIDAPI if (HIDAPI_IsDevicePresent(vendor, product, version)) { /* The HIDAPI driver is taking care of this device */ return 0; } #endif SDL_memset(pDevice->guid.data, 0, sizeof(pDevice->guid.data)); if (vendor && product) { *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB); *guid16++ = 0; *guid16++ = SDL_SwapLE16((Uint16)vendor); *guid16++ = 0; *guid16++ = SDL_SwapLE16((Uint16)product); *guid16++ = 0; *guid16++ = SDL_SwapLE16((Uint16)version); *guid16++ = 0; } else { *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_BLUETOOTH); *guid16++ = 0; SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4); } array = IOHIDDeviceCopyMatchingElements(hidDevice, NULL, kIOHIDOptionsTypeNone); if (array) { AddHIDElements(array, pDevice); CFRelease(array); } return SDL_TRUE; } static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) { recDevice *i; for (i = gpDeviceList; i != NULL; i = i->pNext) { if (i->deviceRef == ioHIDDeviceObject) { return SDL_TRUE; } } return SDL_FALSE; } static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender, IOHIDDeviceRef ioHIDDeviceObject) { recDevice *device; int device_index = 0; io_service_t ioservice; if (res != kIOReturnSuccess) { return; } if (JoystickAlreadyKnown(ioHIDDeviceObject)) { return; /* IOKit sent us a duplicate. */ } device = (recDevice *) SDL_calloc(1, sizeof(recDevice)); if (!device) { SDL_OutOfMemory(); return; } if (!GetDeviceInfo(ioHIDDeviceObject, device)) { SDL_free(device); return; /* not a device we care about, probably. */ } if (SDL_ShouldIgnoreJoystick(device->product, device->guid)) { SDL_free(device); return; } /* Get notified when this device is disconnected. */ IOHIDDeviceRegisterRemovalCallback(ioHIDDeviceObject, JoystickDeviceWasRemovedCallback, device); IOHIDDeviceScheduleWithRunLoop(ioHIDDeviceObject, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); /* Allocate an instance ID for this device */ device->instance_id = SDL_GetNextJoystickInstanceID(); /* We have to do some storage of the io_service_t for SDL_HapticOpenFromJoystick */ ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { device->ffservice = ioservice; #if SDL_HAPTIC_IOKIT MacHaptic_MaybeAddDevice(ioservice); #endif } /* Add device to the end of the list */ if ( !gpDeviceList ) { gpDeviceList = device; } else { recDevice *curdevice; curdevice = gpDeviceList; while ( curdevice->pNext ) { ++device_index; curdevice = curdevice->pNext; } curdevice->pNext = device; ++device_index; /* bump by one since we counted by pNext. */ } SDL_PrivateJoystickAdded(device->instance_id); } static SDL_bool ConfigHIDManager(CFArrayRef matchingArray) { CFRunLoopRef runloop = CFRunLoopGetCurrent(); if (IOHIDManagerOpen(hidman, kIOHIDOptionsTypeNone) != kIOReturnSuccess) { return SDL_FALSE; } IOHIDManagerSetDeviceMatchingMultiple(hidman, matchingArray); IOHIDManagerRegisterDeviceMatchingCallback(hidman, JoystickDeviceWasAddedCallback, NULL); IOHIDManagerScheduleWithRunLoop(hidman, runloop, SDL_JOYSTICK_RUNLOOP_MODE); while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { /* no-op. Callback fires once per existing device. */ } /* future hotplug events will come through SDL_JOYSTICK_RUNLOOP_MODE now. */ return SDL_TRUE; /* good to go. */ } static CFDictionaryRef CreateHIDDeviceMatchDictionary(const UInt32 page, const UInt32 usage, int *okay) { CFDictionaryRef retval = NULL; CFNumberRef pageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page); CFNumberRef usageNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage); const void *keys[2] = { (void *) CFSTR(kIOHIDDeviceUsagePageKey), (void *) CFSTR(kIOHIDDeviceUsageKey) }; const void *vals[2] = { (void *) pageNumRef, (void *) usageNumRef }; if (pageNumRef && usageNumRef) { retval = CFDictionaryCreate(kCFAllocatorDefault, keys, vals, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } if (pageNumRef) { CFRelease(pageNumRef); } if (usageNumRef) { CFRelease(usageNumRef); } if (!retval) { *okay = 0; } return retval; } static SDL_bool CreateHIDManager(void) { SDL_bool retval = SDL_FALSE; int okay = 1; const void *vals[] = { (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick, &okay), (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad, &okay), (void *) CreateHIDDeviceMatchDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController, &okay), }; const size_t numElements = SDL_arraysize(vals); CFArrayRef array = okay ? CFArrayCreate(kCFAllocatorDefault, vals, numElements, &kCFTypeArrayCallBacks) : NULL; size_t i; for (i = 0; i < numElements; i++) { if (vals[i]) { CFRelease((CFTypeRef) vals[i]); } } if (array) { hidman = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone); if (hidman != NULL) { retval = ConfigHIDManager(array); } CFRelease(array); } return retval; } static int DARWIN_JoystickInit(void) { if (gpDeviceList) { return SDL_SetError("Joystick: Device list already inited."); } if (!CreateHIDManager()) { return SDL_SetError("Joystick: Couldn't initialize HID Manager"); } return 0; } static int DARWIN_JoystickGetCount(void) { recDevice *device = gpDeviceList; int nJoySticks = 0; while (device) { if (!device->removed) { nJoySticks++; } device = device->pNext; } return nJoySticks; } static void DARWIN_JoystickDetect(void) { recDevice *device = gpDeviceList; while (device) { if (device->removed) { device = FreeDevice(device); } else { device = device->pNext; } } /* run this after the checks above so we don't set device->removed and delete the device before DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE,0,TRUE) == kCFRunLoopRunHandledSource) { /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ } } /* Function to get the device-dependent name of a joystick */ const char * DARWIN_JoystickGetDeviceName(int device_index) { recDevice *device = GetDeviceForIndex(device_index); return device ? device->product : "UNKNOWN"; } static SDL_JoystickGUID DARWIN_JoystickGetDeviceGUID( int device_index ) { recDevice *device = GetDeviceForIndex(device_index); SDL_JoystickGUID guid; if (device) { guid = device->guid; } else { SDL_zero(guid); } return guid; } static SDL_JoystickID DARWIN_JoystickGetDeviceInstanceID(int device_index) { recDevice *device = GetDeviceForIndex(device_index); return device ? device->instance_id : 0; } static int DARWIN_JoystickOpen(SDL_Joystick * joystick, int device_index) { recDevice *device = GetDeviceForIndex(device_index); joystick->instance_id = device->instance_id; joystick->hwdata = device; joystick->name = device->product; joystick->naxes = device->axes; joystick->nhats = device->hats; joystick->nballs = 0; joystick->nbuttons = device->buttons; return 0; } /* * Like strerror but for force feedback errors. */ static const char * FFStrError(unsigned int err) { switch (err) { case FFERR_DEVICEFULL: return "device full"; /* This should be valid, but for some reason isn't defined... */ /* case FFERR_DEVICENOTREG: return "device not registered"; */ case FFERR_DEVICEPAUSED: return "device paused"; case FFERR_DEVICERELEASED: return "device released"; case FFERR_EFFECTPLAYING: return "effect playing"; case FFERR_EFFECTTYPEMISMATCH: return "effect type mismatch"; case FFERR_EFFECTTYPENOTSUPPORTED: return "effect type not supported"; case FFERR_GENERIC: return "undetermined error"; case FFERR_HASEFFECTS: return "device has effects"; case FFERR_INCOMPLETEEFFECT: return "incomplete effect"; case FFERR_INTERNAL: return "internal fault"; case FFERR_INVALIDDOWNLOADID: return "invalid download id"; case FFERR_INVALIDPARAM: return "invalid parameter"; case FFERR_MOREDATA: return "more data"; case FFERR_NOINTERFACE: return "interface not supported"; case FFERR_NOTDOWNLOADED: return "effect is not downloaded"; case FFERR_NOTINITIALIZED: return "object has not been initialized"; case FFERR_OUTOFMEMORY: return "out of memory"; case FFERR_UNPLUGGED: return "device is unplugged"; case FFERR_UNSUPPORTED: return "function call unsupported"; case FFERR_UNSUPPORTEDAXIS: return "axis unsupported"; default: return "unknown error"; } } static int DARWIN_JoystickInitRumble(recDevice *device, Sint16 magnitude, Uint32 duration_ms) { HRESULT result; if (!device->ffdevice) { result = FFCreateDevice(device->ffservice, &device->ffdevice); if (result != FF_OK) { return SDL_SetError("Unable to create force feedback device from service: %s", FFStrError(result)); } } /* Reset and then enable actuators */ result = FFDeviceSendForceFeedbackCommand(device->ffdevice, FFSFFC_RESET); if (result != FF_OK) { return SDL_SetError("Unable to reset force feedback device: %s", FFStrError(result)); } result = FFDeviceSendForceFeedbackCommand(device->ffdevice, FFSFFC_SETACTUATORSON); if (result != FF_OK) { return SDL_SetError("Unable to enable force feedback actuators: %s", FFStrError(result)); } /* Create the effect */ device->ffeffect = CreateRumbleEffectData(magnitude, duration_ms); if (!device->ffeffect) { return SDL_OutOfMemory(); } result = FFDeviceCreateEffect(device->ffdevice, kFFEffectType_Sine_ID, device->ffeffect, &device->ffeffect_ref); if (result != FF_OK) { return SDL_SetError("Haptic: Unable to create effect: %s", FFStrError(result)); } return 0; } static int DARWIN_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { HRESULT result; recDevice *device = joystick->hwdata; /* Scale and average the two rumble strengths */ Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); if (!device->ffservice) { return SDL_Unsupported(); } if (device->ff_initialized) { FFPERIODIC *periodic = ((FFPERIODIC *)device->ffeffect->lpvTypeSpecificParams); device->ffeffect->dwDuration = duration_ms * 1000; /* In microseconds. */ periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude); result = FFEffectSetParameters(device->ffeffect_ref, device->ffeffect, (FFEP_DURATION | FFEP_TYPESPECIFICPARAMS)); if (result != FF_OK) { return SDL_SetError("Unable to update rumble effect: %s", FFStrError(result)); } } else { if (DARWIN_JoystickInitRumble(device, magnitude, duration_ms) < 0) { return -1; } device->ff_initialized = SDL_TRUE; } result = FFEffectStart(device->ffeffect_ref, 1, 0); if (result != FF_OK) { return SDL_SetError("Unable to run the rumble effect: %s", FFStrError(result)); } return 0; } static void DARWIN_JoystickUpdate(SDL_Joystick * joystick) { recDevice *device = joystick->hwdata; recElement *element; SInt32 value, range; int i; if (!device) { return; } if (device->removed) { /* device was unplugged; ignore it. */ if (joystick->hwdata) { joystick->force_recentering = SDL_TRUE; joystick->hwdata = NULL; } return; } element = device->firstAxis; i = 0; int goodRead = SDL_FALSE; while (element) { goodRead = GetHIDScaledCalibratedState(device, element, -32768, 32767, &value); if (goodRead) { SDL_PrivateJoystickAxis(joystick, i, value); } element = element->pNext; ++i; } element = device->firstButton; i = 0; while (element) { goodRead = GetHIDElementState(device, element, &value); if (goodRead) { if (value > 1) { /* handle pressure-sensitive buttons */ value = 1; } SDL_PrivateJoystickButton(joystick, i, value); } element = element->pNext; ++i; } element = device->firstHat; i = 0; while (element) { Uint8 pos = 0; range = (element->max - element->min + 1); goodRead = GetHIDElementState(device, element, &value); if (goodRead) { value -= element->min; if (range == 4) { /* 4 position hatswitch - scale up value */ value *= 2; } else if (range != 8) { /* Neither a 4 nor 8 positions - fall back to default position (centered) */ value = -1; } switch (value) { case 0: pos = SDL_HAT_UP; break; case 1: pos = SDL_HAT_RIGHTUP; break; case 2: pos = SDL_HAT_RIGHT; break; case 3: pos = SDL_HAT_RIGHTDOWN; break; case 4: pos = SDL_HAT_DOWN; break; case 5: pos = SDL_HAT_LEFTDOWN; break; case 6: pos = SDL_HAT_LEFT; break; case 7: pos = SDL_HAT_LEFTUP; break; default: /* Every other value is mapped to center. We do that because some * joysticks use 8 and some 15 for this value, and apparently * there are even more variants out there - so we try to be generous. */ pos = SDL_HAT_CENTERED; break; } SDL_PrivateJoystickHat(joystick, i, pos); } element = element->pNext; ++i; } } static void DARWIN_JoystickClose(SDL_Joystick * joystick) { } static void DARWIN_JoystickQuit(void) { while (FreeDevice(gpDeviceList)) { /* spin */ } if (hidman) { IOHIDManagerUnscheduleFromRunLoop(hidman, CFRunLoopGetCurrent(), SDL_JOYSTICK_RUNLOOP_MODE); IOHIDManagerClose(hidman, kIOHIDOptionsTypeNone); CFRelease(hidman); hidman = NULL; } } SDL_JoystickDriver SDL_DARWIN_JoystickDriver = { DARWIN_JoystickInit, DARWIN_JoystickGetCount, DARWIN_JoystickDetect, DARWIN_JoystickGetDeviceName, DARWIN_JoystickGetDeviceGUID, DARWIN_JoystickGetDeviceInstanceID, DARWIN_JoystickOpen, DARWIN_JoystickRumble, DARWIN_JoystickUpdate, DARWIN_JoystickClose, DARWIN_JoystickQuit, }; #endif /* SDL_JOYSTICK_IOKIT */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\darwin\SDL_sysjoystick_c.h
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #ifndef SDL_JOYSTICK_IOKIT_H #define SDL_JOYSTICK_IOKIT_H #include <IOKit/hid/IOHIDLib.h> #include <ForceFeedback/ForceFeedback.h> #include <ForceFeedback/ForceFeedbackConstants.h> struct recElement { IOHIDElementRef elementRef; IOHIDElementCookie cookie; uint32_t usagePage, usage; /* HID usage */ SInt32 min; /* reported min value possible */ SInt32 max; /* reported max value possible */ /* runtime variables used for auto-calibration */ SInt32 minReport; /* min returned value */ SInt32 maxReport; /* max returned value */ struct recElement *pNext; /* next element in list */ }; typedef struct recElement recElement; struct joystick_hwdata { IOHIDDeviceRef deviceRef; /* HIDManager device handle */ io_service_t ffservice; /* Interface for force feedback, 0 = no ff */ FFDeviceObjectReference ffdevice; FFEFFECT *ffeffect; FFEffectObjectReference ffeffect_ref; SDL_bool ff_initialized; char product[256]; /* name of product */ uint32_t usage; /* usage page from IOUSBHID Parser.h which defines general usage */ uint32_t usagePage; /* usage within above page from IOUSBHID Parser.h which defines specific usage */ int axes; /* number of axis (calculated, not reported by device) */ int buttons; /* number of buttons (calculated, not reported by device) */ int hats; /* number of hat switches (calculated, not reported by device) */ int elements; /* number of total elements (should be total of above) (calculated, not reported by device) */ recElement *firstAxis; recElement *firstButton; recElement *firstHat; SDL_bool removed; int instance_id; SDL_JoystickGUID guid; struct joystick_hwdata *pNext; /* next device */ }; typedef struct joystick_hwdata recDevice; #endif /* SDL_JOYSTICK_IOKIT_H */ /* vi: set ts=4 sw=4 expandtab: */
0
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick
D://workCode//uploadProject\awtk\3rd\SDL\src\joystick\dummy\SDL_sysjoystick.c
/* Simple DirectMedia Layer Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "../../SDL_internal.h" #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) /* This is the dummy implementation of the SDL joystick API */ #include "SDL_joystick.h" #include "../SDL_sysjoystick.h" #include "../SDL_joystick_c.h" static int DUMMY_JoystickInit(void) { return 0; } static int DUMMY_JoystickGetCount(void) { return 0; } static void DUMMY_JoystickDetect(void) { } static const char * DUMMY_JoystickGetDeviceName(int device_index) { return NULL; } static SDL_JoystickGUID DUMMY_JoystickGetDeviceGUID(int device_index) { SDL_JoystickGUID guid; SDL_zero(guid); return guid; } static SDL_JoystickID DUMMY_JoystickGetDeviceInstanceID(int device_index) { return -1; } static int DUMMY_JoystickOpen(SDL_Joystick * joystick, int device_index) { return SDL_SetError("Logic error: No joysticks available"); } static int DUMMY_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms) { return SDL_Unsupported(); } static void DUMMY_JoystickUpdate(SDL_Joystick * joystick) { } static void DUMMY_JoystickClose(SDL_Joystick * joystick) { } static void DUMMY_JoystickQuit(void) { } SDL_JoystickDriver SDL_DUMMY_JoystickDriver = { DUMMY_JoystickInit, DUMMY_JoystickGetCount, DUMMY_JoystickDetect, DUMMY_JoystickGetDeviceName, DUMMY_JoystickGetDeviceGUID, DUMMY_JoystickGetDeviceInstanceID, DUMMY_JoystickOpen, DUMMY_JoystickRumble, DUMMY_JoystickUpdate, DUMMY_JoystickClose, DUMMY_JoystickQuit, }; #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */
0