|
@@ -109,6 +109,7 @@ void la_ReadControllerAxisLimit(laController* c, int i, int Min, int Max){
|
|
|
}
|
|
|
|
|
|
int la_ControllerButtonToMap(int btn){
|
|
|
+#ifdef __linux__
|
|
|
if(btn<BTN_MISC) return -1;
|
|
|
if(btn<=BTN_GEAR_UP) return btn-BTN_MISC;
|
|
|
if(btn<BTN_DPAD_UP) return -1;
|
|
@@ -116,13 +117,22 @@ int la_ControllerButtonToMap(int btn){
|
|
|
if(btn<BTN_TRIGGER_HAPPY) return -1;
|
|
|
if(btn<=BTN_TRIGGER_HAPPY40) return BTN_GEAR_UP-BTN_MISC+1+BTN_DPAD_RIGHT-BTN_DPAD_UP+1+btn-BTN_TRIGGER_HAPPY;
|
|
|
return -1;
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ return -1;
|
|
|
+#endif
|
|
|
}
|
|
|
int la_ControllerButtonToIndex(laController* c,int btn){
|
|
|
int map=la_ControllerButtonToMap(btn); if(map<0) return -1; return c->ButtonsMap[map];
|
|
|
}
|
|
|
int la_ControllerAxisToMap(int abs){
|
|
|
+#ifdef __linux__
|
|
|
if(abs<ABS_X) return -1; if(abs>ABS_MAX) return -1;
|
|
|
return abs;
|
|
|
+#endif
|
|
|
+#ifdef _WIN32
|
|
|
+ return abs;
|
|
|
+#endif
|
|
|
}
|
|
|
int la_ControllerAxisToIndex(laController* c,int abs){
|
|
|
int map=la_ControllerAxisToMap(abs); if(map<0) return -1; return c->AxisMap[map];
|
|
@@ -278,12 +288,14 @@ int OPMOD_RemoveController(laOperator* a, laEvent* e){
|
|
|
|
|
|
void lapost_Controller(laController* c){
|
|
|
c->InternalType = la_IdentifyControllerInternalType(SSTR(c->Name));
|
|
|
+#ifdef __linux__
|
|
|
c->fd=open(SSTR(c->Path),O_RDWR | O_NONBLOCK); if(c->fd<0){ c->Error=1; }
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void* lagetraw_ControllerButtonMap(laController* c, int* r_size, int* ret_is_copy){
|
|
|
int use_size=/*sizeof(int16_t)*LA_JS_MAX_AXES*4 +*/ sizeof(u8bit)*LA_JS_MAX_BUTTONS + sizeof(u8bit)*LA_JS_MAX_AXES;
|
|
|
- char* data=malloc(use_size); char* p=data;
|
|
|
+ char* data = malloc(use_size); char* p = data; if (!data) return 0;
|
|
|
//memcpy(p,c->AxisCenterMaxes,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
|
|
|
//memcpy(p,c->AxisCenterMins,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
|
|
|
//memcpy(p,c->AxisLimitMaxes,sizeof(int16_t)*LA_JS_MAX_AXES); p+= sizeof(int16_t)*LA_JS_MAX_AXES;
|