1 /* Copyright (C) 2009 The Android Open Source Project 2 ** 3 ** This software is licensed under the terms of the GNU General Public 4 ** License version 2, as published by the Free Software Foundation, and 5 ** may be copied, distributed, and modified under those terms. 6 ** 7 ** This program is distributed in the hope that it will be useful, 8 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 9 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 ** GNU General Public License for more details. 11 */ 12 #include "android/keycode.h" 13 14 AndroidKeyCode 15 android_keycode_rotate( AndroidKeyCode code, int rotation ) 16 { 17 static const AndroidKeyCode wheel[4] = { kKeyCodeDpadUp, 18 kKeyCodeDpadRight, 19 kKeyCodeDpadDown, 20 kKeyCodeDpadLeft }; 21 22 int index; 23 24 for (index = 0; index < 4; index++) { 25 if (code == wheel[index]) { 26 index = (index + rotation) & 3; 27 code = wheel[index]; 28 break; 29 } 30 } 31 return code; 32 } 33 34