Mercurial > sdl-ios-xcode
comparison src/joystick/linux/SDL_sysjoystick.c @ 2735:204be4fc2726
Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 27 Aug 2008 15:10:03 +0000 |
parents | 0906692aa6a4 |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
2734:dd25eabe441c | 2735:204be4fc2726 |
---|---|
87 */ | 87 */ |
88 | 88 |
89 static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = { | 89 static struct joystick_logical_mapping mp88xx_1_logical_axismap[] = { |
90 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5} | 90 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5} |
91 }; | 91 }; |
92 | |
92 static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = { | 93 static struct joystick_logical_mapping mp88xx_1_logical_buttonmap[] = { |
93 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, | 94 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, |
94 {0, 9}, {0, 10}, {0, 11} | 95 {0, 9}, {0, 10}, {0, 11} |
95 }; | 96 }; |
96 | 97 |
97 static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = { | 98 static struct joystick_logical_mapping mp88xx_2_logical_axismap[] = { |
98 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, | 99 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, |
99 {1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5} | 100 {1, 2}, {1, 3}, {0, 4}, {0, 5}, {1, 4}, {1, 5} |
100 }; | 101 }; |
102 | |
101 static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = { | 103 static struct joystick_logical_mapping mp88xx_2_logical_buttonmap[] = { |
102 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, | 104 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, |
103 {0, 9}, {0, 10}, {0, 11}, | 105 {0, 9}, {0, 10}, {0, 11}, |
104 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, | 106 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, |
105 {1, 9}, {1, 10}, {1, 11} | 107 {1, 9}, {1, 10}, {1, 11} |
108 static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = { | 110 static struct joystick_logical_mapping mp88xx_3_logical_axismap[] = { |
109 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, | 111 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, |
110 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, | 112 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, |
111 {0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5} | 113 {0, 4}, {0, 5}, {1, 4}, {1, 5}, {2, 4}, {2, 5} |
112 }; | 114 }; |
115 | |
113 static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = { | 116 static struct joystick_logical_mapping mp88xx_3_logical_buttonmap[] = { |
114 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, | 117 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, |
115 {0, 9}, {0, 10}, {0, 11}, | 118 {0, 9}, {0, 10}, {0, 11}, |
116 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, | 119 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, |
117 {1, 9}, {1, 10}, {1, 11}, | 120 {1, 9}, {1, 10}, {1, 11}, |
123 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, | 126 {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {0, 3}, |
124 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, | 127 {1, 2}, {1, 3}, {2, 0}, {2, 1}, {2, 2}, {2, 3}, |
125 {3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5}, | 128 {3, 0}, {3, 1}, {3, 2}, {3, 3}, {0, 4}, {0, 5}, |
126 {1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5} | 129 {1, 4}, {1, 5}, {2, 4}, {2, 5}, {3, 4}, {3, 5} |
127 }; | 130 }; |
131 | |
128 static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = { | 132 static struct joystick_logical_mapping mp88xx_4_logical_buttonmap[] = { |
129 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, | 133 {0, 0}, {0, 1}, {0, 2}, {0, 3}, {0, 4}, {0, 5}, {0, 6}, {0, 7}, {0, 8}, |
130 {0, 9}, {0, 10}, {0, 11}, | 134 {0, 9}, {0, 10}, {0, 11}, |
131 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, | 135 {1, 0}, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, |
132 {1, 9}, {1, 10}, {1, 11}, | 136 {1, 9}, {1, 10}, {1, 11}, |
145 }; | 149 }; |
146 | 150 |
147 static struct joystick_logical_layout mp88xx_1_logical_layout[] = { | 151 static struct joystick_logical_layout mp88xx_1_logical_layout[] = { |
148 {6, 0, 0, 12} | 152 {6, 0, 0, 12} |
149 }; | 153 }; |
154 | |
150 static struct joystick_logical_layout mp88xx_2_logical_layout[] = { | 155 static struct joystick_logical_layout mp88xx_2_logical_layout[] = { |
151 {6, 0, 0, 12}, | 156 {6, 0, 0, 12}, |
152 {6, 0, 0, 12} | 157 {6, 0, 0, 12} |
153 }; | 158 }; |
159 | |
154 static struct joystick_logical_layout mp88xx_3_logical_layout[] = { | 160 static struct joystick_logical_layout mp88xx_3_logical_layout[] = { |
155 {6, 0, 0, 12}, | 161 {6, 0, 0, 12}, |
156 {6, 0, 0, 12}, | 162 {6, 0, 0, 12}, |
157 {6, 0, 0, 12} | 163 {6, 0, 0, 12} |
158 }; | 164 }; |
165 | |
159 static struct joystick_logical_layout mp88xx_4_logical_layout[] = { | 166 static struct joystick_logical_layout mp88xx_4_logical_layout[] = { |
160 {6, 0, 0, 12}, | 167 {6, 0, 0, 12}, |
161 {6, 0, 0, 12}, | 168 {6, 0, 0, 12}, |
162 {6, 0, 0, 12}, | 169 {6, 0, 0, 12}, |
163 {6, 0, 0, 12} | 170 {6, 0, 0, 12} |
951 hat = hats->nthing; | 958 hat = hats->nthing; |
952 } | 959 } |
953 #endif /* USE_LOGICAL_JOYSTICKS */ | 960 #endif /* USE_LOGICAL_JOYSTICKS */ |
954 | 961 |
955 SDL_PrivateJoystickHat(stick, hat, | 962 SDL_PrivateJoystickHat(stick, hat, |
956 position_map[the_hat->axis[1]][the_hat-> | 963 position_map[the_hat-> |
957 axis[0]]); | 964 axis[1]][the_hat->axis[0]]); |
958 } | 965 } |
959 } | 966 } |
960 | 967 |
961 static __inline__ void | 968 static __inline__ void |
962 HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) | 969 HandleBall(SDL_Joystick * stick, Uint8 ball, int axis, int value) |
1083 case EV_KEY: | 1090 case EV_KEY: |
1084 if (code >= BTN_MISC) { | 1091 if (code >= BTN_MISC) { |
1085 code -= BTN_MISC; | 1092 code -= BTN_MISC; |
1086 #ifndef NO_LOGICAL_JOYSTICKS | 1093 #ifndef NO_LOGICAL_JOYSTICKS |
1087 if (!LogicalJoystickButton(joystick, | 1094 if (!LogicalJoystickButton(joystick, |
1088 joystick->hwdata-> | 1095 joystick-> |
1089 key_map[code], | 1096 hwdata->key_map[code], |
1090 events[i].value)) | 1097 events[i].value)) |
1091 #endif | 1098 #endif |
1092 SDL_PrivateJoystickButton(joystick, | 1099 SDL_PrivateJoystickButton(joystick, |
1093 joystick->hwdata-> | 1100 joystick-> |
1094 key_map[code], | 1101 hwdata->key_map[code], |
1095 events[i].value); | 1102 events[i].value); |
1096 } | 1103 } |
1097 break; | 1104 break; |
1098 case EV_ABS: | 1105 case EV_ABS: |
1099 switch (code) { | 1106 switch (code) { |
1111 default: | 1118 default: |
1112 events[i].value = | 1119 events[i].value = |
1113 EV_AxisCorrect(joystick, code, events[i].value); | 1120 EV_AxisCorrect(joystick, code, events[i].value); |
1114 #ifndef NO_LOGICAL_JOYSTICKS | 1121 #ifndef NO_LOGICAL_JOYSTICKS |
1115 if (!LogicalJoystickAxis(joystick, | 1122 if (!LogicalJoystickAxis(joystick, |
1116 joystick->hwdata-> | 1123 joystick->hwdata->abs_map[code], |
1117 abs_map[code], events[i].value)) | 1124 events[i].value)) |
1118 #endif | 1125 #endif |
1119 SDL_PrivateJoystickAxis(joystick, | 1126 SDL_PrivateJoystickAxis(joystick, |
1120 joystick->hwdata-> | 1127 joystick-> |
1121 abs_map[code], | 1128 hwdata->abs_map[code], |
1122 events[i].value); | 1129 events[i].value); |
1123 break; | 1130 break; |
1124 } | 1131 } |
1125 break; | 1132 break; |
1126 case EV_REL: | 1133 case EV_REL: |