comparison src/joystick/linux/SDL_sysjoystick.c @ 2698:e1da92da346c gsoc2008_nds

Clean up.
author Darren Alton <dalton@stevens.edu>
date Wed, 27 Aug 2008 04:23:38 +0000
parents a5de28552be4
children
comparison
equal deleted inserted replaced
2697:c9121b04cffa 2698:e1da92da346c
89 */ 89 */
90 90
91 static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = { 91 static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = {
92 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5} 92 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}
93 }; 93 };
94
94 static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = { 95 static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = {
95 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, 96 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
96 {0, 9}, {0, 10}, {0, 11} 97 {0, 9}, {0, 10}, {0, 11}
97 }; 98 };
98 99
99 static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = { 100 static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = {
100 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, 101 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
101 {1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5} 102 {1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5}
102 }; 103 };
104
103 static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = { 105 static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = {
104 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, 106 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
105 {0, 9}, {0, 10}, {0, 11}, 107 {0, 9}, {0, 10}, {0, 11},
106 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, 108 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
107 {1, 9}, {1, 10}, {1, 11} 109 {1, 9}, {1, 10}, {1, 11}
110 static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = { 112 static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = {
111 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, 113 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
112 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, 114 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3},
113 {0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5} 115 {0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5}
114 }; 116 };
117
115 static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = { 118 static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = {
116 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, 119 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
117 {0, 9}, {0, 10}, {0, 11}, 120 {0, 9}, {0, 10}, {0, 11},
118 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, 121 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
119 {1, 9}, {1, 10}, {1, 11}, 122 {1, 9}, {1, 10}, {1, 11},
125 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, 128 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3},
126 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, 129 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3},
127 {3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5}, 130 {3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5},
128 {1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5} 131 {1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5}
129 }; 132 };
133
130 static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = { 134 static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = {
131 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, 135 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8},
132 {0, 9}, {0, 10}, {0, 11}, 136 {0, 9}, {0, 10}, {0, 11},
133 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, 137 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8},
134 {1, 9}, {1, 10}, {1, 11}, 138 {1, 9}, {1, 10}, {1, 11},
147 }; 151 };
148 152
149 static struct joystick_logical_layout mp88xx_1_logical_layout[] = { 153 static struct joystick_logical_layout mp88xx_1_logical_layout[] = {
150 {6, 0, 0, 12} 154 {6, 0, 0, 12}
151 }; 155 };
156
152 static struct joystick_logical_layout mp88xx_2_logical_layout[] = { 157 static struct joystick_logical_layout mp88xx_2_logical_layout[] = {
153 {6, 0, 0, 12}, 158 {6, 0, 0, 12},
154 {6, 0, 0, 12} 159 {6, 0, 0, 12}
155 }; 160 };
161
156 static struct joystick_logical_layout mp88xx_3_logical_layout[] = { 162 static struct joystick_logical_layout mp88xx_3_logical_layout[] = {
157 {6, 0, 0, 12}, 163 {6, 0, 0, 12},
158 {6, 0, 0, 12}, 164 {6, 0, 0, 12},
159 {6, 0, 0, 12} 165 {6, 0, 0, 12}
160 }; 166 };
167
161 static struct joystick_logical_layout mp88xx_4_logical_layout[] = { 168 static struct joystick_logical_layout mp88xx_4_logical_layout[] = {
162 {6, 0, 0, 12}, 169 {6, 0, 0, 12},
163 {6, 0, 0, 12}, 170 {6, 0, 0, 12},
164 {6, 0, 0, 12}, 171 {6, 0, 0, 12},
165 {6, 0, 0, 12} 172 {6, 0, 0, 12}
977 hat = hats->nthing; 984 hat = hats->nthing;
978 } 985 }
979 #endif /* USE_LOGICAL_JOYSTICKS */ 986 #endif /* USE_LOGICAL_JOYSTICKS */
980 987
981 SDL_PrivateJoystickHat(stick, hat, 988 SDL_PrivateJoystickHat(stick, hat,
982 position_map[the_hat->axis[1]][the_hat-> 989 position_map[the_hat->
983 axis[0]]); 990 axis[1]][the_hat->axis[0]]);
984 } 991 }
985 } 992 }
986 993
987 static __inline__ void 994 static __inline__ void
988 HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) 995 HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value)
1109 case EV_KEY: 1116 case EV_KEY:
1110 if (code >= BTN_MISC) { 1117 if (code >= BTN_MISC) {
1111 code -= BTN_MISC; 1118 code -= BTN_MISC;
1112 #ifndef NO_LOGICAL_JOYSTICKS 1119 #ifndef NO_LOGICAL_JOYSTICKS
1113 if (!LogicalJoystickButton(joystick, 1120 if (!LogicalJoystickButton(joystick,
1114 joystick->hwdata-> 1121 joystick->
1115 key_map[code], 1122 hwdata->key_map[code],
1116 events[i].value)) 1123 events[i].value))
1117 #endif 1124 #endif
1118 SDL_PrivateJoystickButton(joystick, 1125 SDL_PrivateJoystickButton(joystick,
1119 joystick->hwdata-> 1126 joystick->
1120 key_map[code], 1127 hwdata->key_map[code],
1121 events[i].value); 1128 events[i].value);
1122 } 1129 }
1123 break; 1130 break;
1124 case EV_ABS: 1131 case EV_ABS:
1125 switch (code) { 1132 switch (code) {
1137 default: 1144 default:
1138 events[i].value = 1145 events[i].value =
1139 EV_AxisCorrect(joystick, code, events[i].value); 1146 EV_AxisCorrect(joystick, code, events[i].value);
1140 #ifndef NO_LOGICAL_JOYSTICKS 1147 #ifndef NO_LOGICAL_JOYSTICKS
1141 if (!LogicalJoystickAxis(joystick, 1148 if (!LogicalJoystickAxis(joystick,
1142 joystick->hwdata-> 1149 joystick->hwdata->abs_map[code],
1143 abs_map[code], events[i].value)) 1150 events[i].value))
1144 #endif 1151 #endif
1145 SDL_PrivateJoystickAxis(joystick, 1152 SDL_PrivateJoystickAxis(joystick,
1146 joystick->hwdata-> 1153 joystick->
1147 abs_map[code], 1154 hwdata->abs_map[code],
1148 events[i].value); 1155 events[i].value);
1149 break; 1156 break;
1150 } 1157 }
1151 break; 1158 break;
1152 case EV_REL: 1159 case EV_REL: