Skip to content

Commit 69ea171

Browse files
committed
Add Logitech Speed Force support
1 parent 0edf6ca commit 69ea171

6 files changed

Lines changed: 444 additions & 3 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ OGCOBJ := \
140140
cache_asm.o system.o system_alarm.o system_asm.o cond.o \
141141
gx.o gu.o gu_psasm.o audio.o cache.o decrementer.o \
142142
message.o card.o aram.o depackrnc.o decrementer_handler.o \
143-
depackrnc1.o dsp.o si.o tpl.o ipc.o ogc_crt0.o \
143+
depackrnc1.o dsp.o si.o si_steering.o tpl.o ipc.o ogc_crt0.o \
144144
console_font_8x16.o timesupp.o lock_supp.o newlibc.o usbgecko.o usbmouse.o \
145145
sbrk.o kprintf.o stm.o ios.o es.o isfs.o usb.o network_common.o \
146146
sdgecko_io.o sdgecko_buf.o gcsd.o argv.o network_wii.o wiisd.o conf.o usbstorage.o \

include/ogc/pad.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ u8 PAD_TriggerR(s32 chan);
9696
u8 PAD_AnalogA(s32 chan);
9797
u8 PAD_AnalogB(s32 chan);
9898

99+
#define PAD_Steering PAD_StickX
100+
101+
#define PAD_PedalGas PAD_AnalogA
102+
#define PAD_PedalBrake PAD_AnalogB
103+
104+
#define PAD_PaddleLeft PAD_TriggerL
105+
#define PAD_PaddleRight PAD_TriggerR
106+
99107
sampling_callback PAD_SetSamplingCallback(sampling_callback cb);
100108

101109
/*+----------------------------------------------------------------------------------------------+*/

include/ogc/si_steering.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*-------------------------------------------------------------
2+
3+
si_steering.h -- Steering wheel support
4+
5+
Copyright (C) 2017 - 2026 Extrems' Corner.org
6+
7+
This software is provided 'as-is', without any express or implied
8+
warranty. In no event will the authors be held liable for any
9+
damages arising from the use of this software.
10+
11+
Permission is granted to anyone to use this software for any
12+
purpose, including commercial applications, and to alter it and
13+
redistribute it freely, subject to the following restrictions:
14+
15+
1. The origin of this software must not be misrepresented; you
16+
must not claim that you wrote the original software. If you use
17+
this software in a product, an acknowledgment in the product
18+
documentation would be appreciated but is not required.
19+
20+
2. Altered source versions must be plainly marked as such, and
21+
must not be misrepresented as being the original software.
22+
23+
3. This notice may not be removed or altered from any source
24+
distribution.
25+
26+
-------------------------------------------------------------*/
27+
28+
#ifndef __OGC_SI_STEERING_H__
29+
#define __OGC_SI_STEERING_H__
30+
31+
#include <gctypes.h>
32+
33+
#define SI_STEERING_ERR_READY 0
34+
#define SI_STEERING_ERR_NO_CONTROLLER -1
35+
#define SI_STEERING_ERR_BUSY -2
36+
#define SI_STEERING_ERR_TRANSFER -3
37+
38+
#define SI_STEERING_STATUS_MTR_EN 0x01
39+
#define SI_STEERING_STATUS_MTR_BK 0x02
40+
#define SI_STEERING_STATUS_POWER 0x04
41+
#define SI_STEERING_STATUS_PEDAL 0x08
42+
43+
#define SI_STEERING_BUTTON_LEFT 0x0001
44+
#define SI_STEERING_BUTTON_RIGHT 0x0002
45+
#define SI_STEERING_BUTTON_DOWN 0x0004
46+
#define SI_STEERING_BUTTON_UP 0x0008
47+
#define SI_STEERING_TRIGGER_Z 0x0010
48+
#define SI_STEERING_TRIGGER_R 0x0020
49+
#define SI_STEERING_TRIGGER_L 0x0040
50+
#define SI_STEERING_BUTTON_A 0x0100
51+
#define SI_STEERING_BUTTON_B 0x0200
52+
#define SI_STEERING_BUTTON_X 0x0400
53+
#define SI_STEERING_BUTTON_Y 0x0800
54+
#define SI_STEERING_BUTTON_START 0x1000
55+
56+
#define SI_STEERING_CONTROL_BRAKE 0x000
57+
#define SI_STEERING_CONTROL_STANDBY 0x400
58+
#define SI_STEERING_CONTROL_DRIVE 0x600
59+
#define SI_STEERING_CONTROL_MASK 0x600
60+
61+
#ifdef __cplusplus
62+
extern "C" {
63+
#endif
64+
65+
typedef void (*SISteeringCallback)(s32 chan, s32 result);
66+
typedef void (*SISteeringSamplingCallback)(void);
67+
68+
typedef struct SISteeringStatus {
69+
u16 button;
70+
u8 status;
71+
s8 steering;
72+
u8 gas;
73+
u8 brake;
74+
u8 left;
75+
u8 right;
76+
s8 err;
77+
} SISteeringStatus;
78+
79+
void SI_InitSteering(void);
80+
s32 SI_ResetSteering(s32 chan);
81+
s32 SI_ResetSteeringAsync(s32 chan, SISteeringCallback callback);
82+
s32 SI_ReadSteering(s32 chan, SISteeringStatus *status);
83+
SISteeringSamplingCallback SI_SetSteeringSamplingCallback(SISteeringSamplingCallback callback);
84+
void SI_ControlSteering(s32 chan, u32 control, s32 steering);
85+
86+
#ifdef __cplusplus
87+
}
88+
#endif
89+
90+
#endif

libogc/pad.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "asm.h"
99
#include "processor.h"
1010
#include "si.h"
11+
#include "si_steering.h"
1112
#include "pad.h"
1213
#include "n64.h"
1314

@@ -874,6 +875,7 @@ u32 PAD_ScanPads(void)
874875
u32 resetBits;
875876
u32 padBit,connected;
876877
u16 state,oldstate;
878+
SISteeringStatus steering;
877879
PADStatus padstatus[PAD_CHANMAX];
878880
static N64Status n64status[PAD_CHANMAX] = {
879881
{ .err = N64_ERR_NO_CONTROLLER },
@@ -892,7 +894,6 @@ u32 PAD_ScanPads(void)
892894

893895
switch(padstatus[i].err) {
894896
case PAD_ERR_NONE:
895-
oldstate = __pad_keys[i].state;
896897
state = padstatus[i].button;
897898
__pad_keys[i].stickX = padstatus[i].stickX;
898899
__pad_keys[i].stickY = padstatus[i].stickY;
@@ -902,6 +903,8 @@ u32 PAD_ScanPads(void)
902903
__pad_keys[i].triggerR = padstatus[i].triggerR;
903904
__pad_keys[i].analogA = padstatus[i].analogA;
904905
__pad_keys[i].analogB = padstatus[i].analogB;
906+
907+
oldstate = __pad_keys[i].state;
905908
__pad_keys[i].up = ~state & oldstate;
906909
__pad_keys[i].down = state & ~oldstate;
907910
__pad_keys[i].state = state;
@@ -962,6 +965,39 @@ u32 PAD_ScanPads(void)
962965
}
963966
break;
964967

968+
case SI_GC_STEERING:
969+
SI_InitSteering();
970+
SI_ReadSteering(i,&steering);
971+
972+
switch(steering.err) {
973+
case SI_STEERING_ERR_READY:
974+
state = steering.button;
975+
__pad_keys[i].stickX = steering.steering;
976+
__pad_keys[i].triggerL = steering.left;
977+
__pad_keys[i].triggerR = steering.right;
978+
__pad_keys[i].analogA = steering.gas;
979+
__pad_keys[i].analogB = steering.brake;
980+
981+
oldstate = __pad_keys[i].state;
982+
__pad_keys[i].up = ~state & oldstate;
983+
__pad_keys[i].down = state & ~oldstate;
984+
__pad_keys[i].state = state;
985+
__pad_keys[i].chan = i;
986+
987+
connected |= (1<<i);
988+
break;
989+
990+
case SI_STEERING_ERR_NO_CONTROLLER:
991+
SI_ResetSteeringAsync(i,NULL);
992+
goto no_controller;
993+
break;
994+
995+
default:
996+
goto not_ready;
997+
break;
998+
}
999+
break;
1000+
9651001
case SI_GC_CONTROLLER:
9661002
case SI_GC_WAVEBIRD:
9671003
resetBits |= padBit;

libogc/si.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ char *SI_GetTypeString(u32 type)
736736
case SI_GC_KEYBOARD:
737737
return "Keyboard";
738738
case SI_GC_STEERING:
739-
return "Steering";
739+
return "Steering wheel";
740740
default:
741741
return "Unknown";
742742
}

0 commit comments

Comments
 (0)