Subversion Repositories eduke32

Rev

Rev 7985 | Rev 8003 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7985 Rev 7986
Line 41... Line 41...
41
41
42
static controlaxismaptype CONTROL_MouseAxesMap[MAXMOUSEAXES];  // maps physical axes onto virtual ones
42
static controlaxismaptype CONTROL_MouseAxesMap[MAXMOUSEAXES];  // maps physical axes onto virtual ones
43
static controlaxistype    CONTROL_MouseAxes[MAXMOUSEAXES];     // physical axes
43
static controlaxistype    CONTROL_MouseAxes[MAXMOUSEAXES];     // physical axes
44
static controlaxistype    CONTROL_LastMouseAxes[MAXMOUSEAXES];
44
static controlaxistype    CONTROL_LastMouseAxes[MAXMOUSEAXES];
45
static int32_t            CONTROL_MouseAxesScale[MAXMOUSEAXES];
45
static int32_t            CONTROL_MouseAxesScale[MAXMOUSEAXES];
-
 
46
static int8_t             CONTROL_MouseAxesInvert[MAXMOUSEAXES];
46
47
47
static controlaxismaptype CONTROL_JoyAxesMap[MAXJOYAXES];
48
static controlaxismaptype CONTROL_JoyAxesMap[MAXJOYAXES];
48
static controlaxistype    CONTROL_JoyAxes[MAXJOYAXES];
49
static controlaxistype    CONTROL_JoyAxes[MAXJOYAXES];
49
static controlaxistype    CONTROL_LastJoyAxes[MAXJOYAXES];
50
static controlaxistype    CONTROL_LastJoyAxes[MAXJOYAXES];
50
static int32_t            CONTROL_JoyAxesScale[MAXJOYAXES];
51
static int32_t            CONTROL_JoyAxesScale[MAXJOYAXES];
-
 
52
static int8_t             CONTROL_JoyAxesInvert[MAXJOYAXES];
51
53
52
static controlbuttontype CONTROL_MouseButtonMapping[MAXMOUSEBUTTONS];
54
static controlbuttontype CONTROL_MouseButtonMapping[MAXMOUSEBUTTONS];
53
55
54
static int32_t CONTROL_MouseButtonClicked[MAXMOUSEBUTTONS];
56
static int32_t CONTROL_MouseButtonClicked[MAXMOUSEBUTTONS];
55
static int32_t CONTROL_MouseButtonClickedState[MAXMOUSEBUTTONS];
57
static int32_t CONTROL_MouseButtonClickedState[MAXMOUSEBUTTONS];
Line 365... Line 367...
365
    }
367
    }
366
368
367
    set[whichaxis] = axisscale;
369
    set[whichaxis] = axisscale;
368
}
370
}
369
371
-
 
372
void CONTROL_SetAnalogAxisInvert(int32_t whichaxis, int32_t invert, controldevice device)
-
 
373
{
-
 
374
    int8_t * set;
-
 
375
-
 
376
    switch (device)
-
 
377
    {
-
 
378
    case controldevice_mouse:
-
 
379
        if ((unsigned) whichaxis >= (unsigned) MAXMOUSEAXES)
-
 
380
        {
-
 
381
            //Error("CONTROL_SetAnalogAxisInvert: axis %d out of valid range for %d mouse axes.",
-
 
382
            //          whichaxis, MAXMOUSEAXES);
-
 
383
            return;
-
 
384
        }
-
 
385
-
 
386
        set = CONTROL_MouseAxesInvert;
-
 
387
        break;
-
 
388
-
 
389
    case controldevice_joystick:
-
 
390
        if ((unsigned) whichaxis >= (unsigned) MAXJOYAXES)
-
 
391
        {
-
 
392
            //Error("CONTROL_SetAnalogAxisInvert: axis %d out of valid range for %d joystick axes.",
-
 
393
            //          whichaxis, MAXJOYAXES);
-
 
394
            return;
-
 
395
        }
-
 
396
-
 
397
        set = CONTROL_JoyAxesInvert;
-
 
398
        break;
-
 
399
-
 
400
    default:
-
 
401
        //Error("CONTROL_SetAnalogAxisInvert: invalid controller device type");
-
 
402
        return;
-
 
403
    }
-
 
404
-
 
405
    set[whichaxis] = invert;
-
 
406
}
-
 
407
370
void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device)
408
void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device)
371
{
409
{
372
    controlaxismaptype *set;
410
    controlaxismaptype *set;
373
411
374
    if (CONTROL_CheckRange(whichfunction)) whichfunction = AXISUNDEFINED;
412
    if (CONTROL_CheckRange(whichfunction)) whichfunction = AXISUNDEFINED;
Line 418... Line 456...
418
}
456
}
419
457
420
void CONTROL_ClearAssignments(void)
458
void CONTROL_ClearAssignments(void)
421
{
459
{
422
    memset(CONTROL_JoyAxes,             0,               sizeof(CONTROL_JoyAxes));
460
    memset(CONTROL_JoyAxes,             0,               sizeof(CONTROL_JoyAxes));
-
 
461
    memset(CONTROL_JoyAxesInvert,       0,               sizeof(CONTROL_JoyAxesInvert));
423
    memset(CONTROL_JoyAxesMap,          AXISUNDEFINED,   sizeof(CONTROL_JoyAxesMap));
462
    memset(CONTROL_JoyAxesMap,          AXISUNDEFINED,   sizeof(CONTROL_JoyAxesMap));
424
    memset(CONTROL_JoyButtonMapping,    BUTTONUNDEFINED, sizeof(CONTROL_JoyButtonMapping));
463
    memset(CONTROL_JoyButtonMapping,    BUTTONUNDEFINED, sizeof(CONTROL_JoyButtonMapping));
425
//    memset(CONTROL_KeyMapping,          KEYUNDEFINED,    sizeof(CONTROL_KeyMapping));
464
//    memset(CONTROL_KeyMapping,          KEYUNDEFINED,    sizeof(CONTROL_KeyMapping));
426
    memset(CONTROL_LastJoyAxes,         0,               sizeof(CONTROL_LastJoyAxes));
465
    memset(CONTROL_LastJoyAxes,         0,               sizeof(CONTROL_LastJoyAxes));
427
    memset(CONTROL_LastMouseAxes,       0,               sizeof(CONTROL_LastMouseAxes));
466
    memset(CONTROL_LastMouseAxes,       0,               sizeof(CONTROL_LastMouseAxes));
428
    memset(CONTROL_MouseAxes,           0,               sizeof(CONTROL_MouseAxes));
467
    memset(CONTROL_MouseAxes,           0,               sizeof(CONTROL_MouseAxes));
-
 
468
    memset(CONTROL_MouseAxesInvert,     0,               sizeof(CONTROL_MouseAxesInvert));
429
    memset(CONTROL_MouseAxesMap,        AXISUNDEFINED,   sizeof(CONTROL_MouseAxesMap));
469
    memset(CONTROL_MouseAxesMap,        AXISUNDEFINED,   sizeof(CONTROL_MouseAxesMap));
430
    memset(CONTROL_MouseButtonMapping,  BUTTONUNDEFINED, sizeof(CONTROL_MouseButtonMapping));
470
    memset(CONTROL_MouseButtonMapping,  BUTTONUNDEFINED, sizeof(CONTROL_MouseButtonMapping));
431
471
432
    for (int & i : CONTROL_MouseAxesScale)
472
    for (int & i : CONTROL_MouseAxesScale)
433
        i = NORMALAXISSCALE;
473
        i = NORMALAXISSCALE;
Line 568... Line 608...
568
608
569
static void CONTROL_ScaleAxis(int axis, controldevice device)
609
static void CONTROL_ScaleAxis(int axis, controldevice device)
570
{
610
{
571
    controlaxistype *set;
611
    controlaxistype *set;
572
    int32_t *scale;
612
    int32_t *scale;
-
 
613
    int8_t * invert;
573
614
574
    switch (device)
615
    switch (device)
575
    {
616
    {
576
    case controldevice_mouse:
617
    case controldevice_mouse:
577
        set = CONTROL_MouseAxes;
618
        set = CONTROL_MouseAxes;
578
        scale = CONTROL_MouseAxesScale;
619
        scale = CONTROL_MouseAxesScale;
-
 
620
        invert = CONTROL_MouseAxesInvert;
579
        break;
621
        break;
580
622
581
    case controldevice_joystick:
623
    case controldevice_joystick:
582
        set = CONTROL_JoyAxes;
624
        set = CONTROL_JoyAxes;
583
        scale = CONTROL_JoyAxesScale;
625
        scale = CONTROL_JoyAxesScale;
-
 
626
        invert = CONTROL_JoyAxesInvert;
584
        break;
627
        break;
585
628
586
    default: return;
629
    default: return;
587
    }
630
    }
588
631
-
 
632
    int const invertResult = !!invert[axis];
589
    set[axis].analog = mulscale16(set[axis].analog, scale[axis]);
633
    set[axis].analog = (mulscale16(set[axis].analog, scale[axis]) ^ -invertResult) + invertResult;
590
}
634
}
591
635
592
static void CONTROL_ApplyAxis(int axis, ControlInfo *info, controldevice device)
636
static void CONTROL_ApplyAxis(int axis, ControlInfo *info, controldevice device)
593
{
637
{
594
    controlaxistype *set;
638
    controlaxistype *set;