Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
proview
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Esteban Blanc
proview
Commits
207e02cb
Commit
207e02cb
authored
Aug 31, 2011
by
Claes Sjofors
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
USB Joystick bugfix
parent
f6072057
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
62 deletions
+59
-62
otherio/lib/rt/src/os_linux/rt_io_m_usb_joystick.c
otherio/lib/rt/src/os_linux/rt_io_m_usb_joystick.c
+59
-62
No files found.
otherio/lib/rt/src/os_linux/rt_io_m_usb_joystick.c
View file @
207e02cb
...
...
@@ -265,75 +265,72 @@ static pwr_tStatus IoCardRead( io_tCtx ctx,
int
value
;
while
(
1
)
{
while
(
read
(
local
->
fd
,
&
js
,
sizeof
(
struct
js_event
))
==
sizeof
(
struct
js_event
))
{
// printf("Event: type %d, time %d, number %d, value %d\n", js.type, js.time, js.number, js.value);
switch
(
js
.
type
)
{
case
129
:
case
1
:
/* Buttons */
idx
=
js
.
number
;
if
(
js
.
number
<
KEY_MAX
-
BTN_MISC
)
idx
=
local
->
button_map
[
js
.
number
];
else
break
;
*
(
pwr_tBoolean
*
)
cp
->
chanlist
[
idx
].
vbp
=
(
js
.
value
!=
0
);
while
(
read
(
local
->
fd
,
&
js
,
sizeof
(
struct
js_event
))
==
sizeof
(
struct
js_event
))
{
// printf("Event: type %d, time %d, number %d, value %d\n", js.type, js.time, js.number, js.value);
switch
(
js
.
type
)
{
case
129
:
case
1
:
/* Buttons */
idx
=
js
.
number
;
if
(
js
.
number
<
KEY_MAX
-
BTN_MISC
)
idx
=
local
->
button_map
[
js
.
number
];
else
break
;
case
130
:
case
2
:
{
io_sChannel
*
chanp
;
pwr_sClass_ChanAi
*
cop
;
pwr_sClass_Ai
*
sop
;
pwr_tFloat32
actvalue
;
int
ivalue
;
/* Axes */
idx
=
js
.
number
;
value
=
js
.
value
;
if
(
js
.
number
<
ABS_MAX
)
{
idx
=
local
->
axis_map
[
js
.
number
];
ivalue
=
js
.
value
;
}
else
break
;
chanp
=
&
cp
->
chanlist
[
idx
];
cop
=
(
pwr_sClass_ChanAi
*
)
chanp
->
cop
;
sop
=
(
pwr_sClass_Ai
*
)
chanp
->
sop
;
if
(
cop
->
CalculateNewCoef
)
// Request to calculate new coefficients
io_AiRangeToCoef
(
chanp
);
io_ConvertAi
(
cop
,
ivalue
,
&
actvalue
);
// Filter
if
(
sop
->
FilterType
==
1
&&
sop
->
FilterAttribute
[
0
]
>
0
&&
sop
->
FilterAttribute
[
0
]
>
ctx
->
ScanTime
)
{
actvalue
=
*
(
pwr_tFloat32
*
)
chanp
->
vbp
+
ctx
->
ScanTime
/
sop
->
FilterAttribute
[
0
]
*
(
actvalue
-
*
(
pwr_tFloat32
*
)
chanp
->
vbp
);
}
*
(
pwr_tFloat32
*
)
chanp
->
vbp
=
actvalue
;
sop
->
SigValue
=
cop
->
SigValPolyCoef1
*
ivalue
+
cop
->
SigValPolyCoef0
;
sop
->
RawValue
=
ivalue
;
break
;
*
(
pwr_tBoolean
*
)
cp
->
chanlist
[
idx
].
vbp
=
(
js
.
value
!=
0
);
break
;
case
130
:
case
2
:
{
io_sChannel
*
chanp
;
pwr_sClass_ChanAi
*
cop
;
pwr_sClass_Ai
*
sop
;
pwr_tFloat32
actvalue
;
int
ivalue
;
/* Axes */
idx
=
js
.
number
;
value
=
js
.
value
;
if
(
js
.
number
<
ABS_MAX
)
{
idx
=
local
->
axis_map
[
js
.
number
];
ivalue
=
js
.
value
;
}
else
break
;
chanp
=
&
cp
->
chanlist
[
idx
];
cop
=
(
pwr_sClass_ChanAi
*
)
chanp
->
cop
;
sop
=
(
pwr_sClass_Ai
*
)
chanp
->
sop
;
if
(
cop
->
CalculateNewCoef
)
// Request to calculate new coefficients
io_AiRangeToCoef
(
chanp
);
io_ConvertAi
(
cop
,
ivalue
,
&
actvalue
);
// Filter
if
(
sop
->
FilterType
==
1
&&
sop
->
FilterAttribute
[
0
]
>
0
&&
sop
->
FilterAttribute
[
0
]
>
ctx
->
ScanTime
)
{
actvalue
=
*
(
pwr_tFloat32
*
)
chanp
->
vbp
+
ctx
->
ScanTime
/
sop
->
FilterAttribute
[
0
]
*
(
actvalue
-
*
(
pwr_tFloat32
*
)
chanp
->
vbp
);
}
*
(
pwr_tFloat32
*
)
chanp
->
vbp
=
actvalue
;
sop
->
SigValue
=
cop
->
SigValPolyCoef1
*
ivalue
+
cop
->
SigValPolyCoef0
;
sop
->
RawValue
=
ivalue
;
break
;
}
if
(
errno
!=
EAGAIN
)
{
op
->
ErrorCount
++
;
}
}
if
(
errno
!=
EAGAIN
)
{
op
->
ErrorCount
++
;
}
if
(
op
->
ErrorCount
==
op
->
ErrorSoftLimit
)
{
errh_Warning
(
"IO Card ErrorSoftLimit reached, '%s'"
,
cp
->
Name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment