Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
funkeymonkey-pyrainput
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
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
packages
funkeymonkey-pyrainput
Commits
5f1bea39
Commit
5f1bea39
authored
Jan 11, 2020
by
sebt3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added configuration for "Alt key" mapping (aka start button and second right trigger)
parent
7ac4196f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
4 deletions
+45
-4
README.md
README.md
+2
-0
pyrainput.cpp
pyrainput.cpp
+43
-4
No files found.
README.md
View file @
5f1bea39
...
...
@@ -46,6 +46,8 @@ nubs.right.x = [mouse_x|mouse_y|*mouse_btn*|scroll_x|scroll_y]
nubs.right.y = [mouse_x|mouse_y|mouse_btn|scroll_x|*scroll_y*]
nubs.left.click = [*mouse_left*|mouse_right]
nubs.right.click = [mouse_left|*mouse_right*]
altmode.start.button = [*left_alt*|right_alt]
altmode.right.trigger = [*left_alt*|right_alt]
gamepad.export = 1
keypad.export = 1
mouse.export = 1
...
...
pyrainput.cpp
View file @
5f1bea39
...
...
@@ -101,6 +101,9 @@ struct Settings {
NUB_CLICK_LEFT
,
NUB_CLICK_RIGHT
,
MOUSE_LEFT
,
MOUSE_RIGHT
};
enum
AltMode
{
LEFT_ALT
,
RIGHT_ALT
};
NubAxisMode
leftNubModeX
=
MOUSE_X
;
NubAxisMode
leftNubModeY
=
MOUSE_Y
;
...
...
@@ -108,6 +111,9 @@ struct Settings {
NubAxisMode
rightNubModeY
=
SCROLL_Y
;
NubClickMode
leftNubClickMode
=
MOUSE_LEFT
;
NubClickMode
rightNubClickMode
=
MOUSE_RIGHT
;
AltMode
startButton
=
LEFT_ALT
;
AltMode
rightTrigger
=
LEFT_ALT
;
// May be changed from any thread at any time
int
joyDeadzone
=
10
;
...
...
@@ -124,6 +130,12 @@ struct Settings {
Scripts
brightness
;
};
using
AltModeMap
=
std
::
unordered_map
<
std
::
string
,
Settings
::
AltMode
>
;
AltModeMap
const
ALT_MODES
=
{
{
"left_alt"
,
Settings
::
LEFT_ALT
},
{
"right_alt"
,
Settings
::
RIGHT_ALT
}
};
using
NubAxisModeMap
=
std
::
unordered_map
<
std
::
string
,
Settings
::
NubAxisMode
>
;
NubAxisModeMap
const
NUB_AXIS_MODES
=
{
{
"mouse_x"
,
Settings
::
MOUSE_X
},
...
...
@@ -145,6 +157,7 @@ void handleArgs(char const** argv, unsigned int argc, Settings& settings);
void
loadConfig
(
std
::
string
const
&
filename
,
Settings
&
settings
);
Settings
::
NubAxisMode
parseNubAxisMode
(
std
::
string
const
&
str
);
Settings
::
NubClickMode
parseNubClickMode
(
std
::
string
const
&
str
);
Settings
::
AltMode
parseAltMode
(
std
::
string
const
&
str
);
void
handleNubAxis
(
Settings
::
NubAxisMode
mode
,
int
value
,
Mouse
*
mouse
,
UinputDevice
*
gamepad
,
Settings
const
&
settings
);
void
handleNubClick
(
Settings
::
NubClickMode
mode
,
int
value
,
Mouse
*
mouse
,
UinputDevice
*
gamepad
,
Settings
const
&
settings
);
...
...
@@ -214,9 +227,9 @@ void init(char const** argv, unsigned int argc) {
global
.
Fn
.
pressed
=
global
.
Fn
.
left
||
global
.
Fn
.
right
;
});
//TODO: make the alt mapping configurable
global
.
behaviors
->
altmap
(
KEY_ESC
,
&
global
.
Fn
.
pressed
,
KEY_ESC
,
KEY_SYSRQ
);
global
.
behaviors
->
altmap
(
KEY_PAUSE
,
&
global
.
Fn
.
pressed
,
KEY_PAUSE
,
KEY_SCALE
);
global
.
behaviors
->
script
(
KEY_BRIGHTNESSUP
,
&
global
.
settings
.
brightness
);
global
.
behaviors
->
altmap
(
KEY_PAUSE
,
&
global
.
Fn
.
pressed
,
KEY_PAUSE
,
KEY_SCALE
);
global
.
behaviors
->
script
(
KEY_BRIGHTNESSUP
,
&
global
.
settings
.
brightness
);
//global.behaviors->altmap(KEY_BRIGHTNESSUP, &global.Fn.pressed, KEY_BRIGHTNESSUP, KEY_BRIGHTNESSDOWN);
global
.
behaviors
->
altmap
(
KEY_F11
,
&
global
.
Fn
.
pressed
,
KEY_F11
,
KEY_F12
);
global
.
behaviors
->
altmap
(
KEY_1
,
&
global
.
Fn
.
pressed
,
KEY_1
,
KEY_F1
);
...
...
@@ -349,14 +362,14 @@ void handle(input_event const& e, unsigned int role) {
case
BTN_THUMBL
:
case
BTN_THUMBR
:
if
(
role
==
ROLE_LEFT_NUB
&&
global
.
settings
.
exportMouse
)
{
std
::
cout
<<
"left nub click
\n
"
;
//
std::cout << "left nub click\n";
handleNubClick
(
global
.
settings
.
leftNubClickMode
,
e
.
value
,
global
.
mouse
,
global
.
gamepad
,
global
.
settings
);
if
(
global
.
settings
.
exportGamepad
)
{
global
.
gamepad
->
send
(
EV_KEY
,
BTN_THUMBL
,
e
.
value
);
global
.
gamepad
->
send
(
EV_SYN
,
0
,
0
);
}
}
else
if
(
role
==
ROLE_RIGHT_NUB
&&
global
.
settings
.
exportMouse
)
{
std
::
cout
<<
"right nub click
\n
"
;
//
std::cout << "right nub click\n";
handleNubClick
(
global
.
settings
.
rightNubClickMode
,
e
.
value
,
global
.
mouse
,
global
.
gamepad
,
global
.
settings
);
if
(
global
.
settings
.
exportGamepad
)
{
global
.
gamepad
->
send
(
EV_KEY
,
BTN_THUMBR
,
e
.
value
);
...
...
@@ -501,6 +514,12 @@ SettingHandlerMap const SETTING_HANDLERS = {
}
},
{
"nubs.right.click"
,
[](
std
::
string
const
&
value
,
Settings
&
settings
)
{
settings
.
rightNubClickMode
=
parseNubClickMode
(
value
);
}
},
{
"altmode.start.button"
,
[](
std
::
string
const
&
value
,
Settings
&
settings
)
{
settings
.
startButton
=
parseAltMode
(
value
);
}
},
{
"altmode.right.trigger"
,
[](
std
::
string
const
&
value
,
Settings
&
settings
)
{
settings
.
rightTrigger
=
parseAltMode
(
value
);
}
}
};
...
...
@@ -534,6 +553,15 @@ void loadConfig(std::string const& filename, Settings& settings) {
std
::
cerr
<<
"Invalid line in config file: "
<<
line
<<
std
::
endl
;
}
}
/* Apply "Alt Keys" mapping configuration */
if
(
settings
.
startButton
==
Settings
::
LEFT_ALT
)
global
.
behaviors
->
gpmap2
(
KEY_LEFTALT
,
BTN_START
,
&
global
.
Alt
.
left
,
&
global
.
Alt
);
else
global
.
behaviors
->
gpmap2
(
KEY_RIGHTALT
,
BTN_START
,
&
global
.
Alt
.
right
,
&
global
.
Alt
);
if
(
settings
.
rightTrigger
==
Settings
::
LEFT_ALT
)
global
.
behaviors
->
gpmap2
(
KEY_LEFTALT
,
BTN_TR2
,
&
global
.
Alt
.
left
,
&
global
.
Alt
);
else
global
.
behaviors
->
gpmap2
(
KEY_RIGHTALT
,
BTN_TR2
,
&
global
.
Alt
.
right
,
&
global
.
Alt
);
}
Settings
::
NubAxisMode
parseNubAxisMode
(
std
::
string
const
&
str
)
{
...
...
@@ -558,6 +586,17 @@ Settings::NubClickMode parseNubClickMode(std::string const& str) {
}
}
Settings
::
AltMode
parseAltMode
(
std
::
string
const
&
str
)
{
std
::
string
s
(
str
);
std
::
transform
(
s
.
begin
(),
s
.
end
(),
s
.
begin
(),
tolower
);
auto
iter
=
ALT_MODES
.
find
(
s
);
if
(
iter
==
ALT_MODES
.
end
())
{
return
Settings
::
LEFT_ALT
;
}
else
{
return
iter
->
second
;
}
}
void
handleNubAxis
(
Settings
::
NubAxisMode
mode
,
int
value
,
Mouse
*
mouse
,
UinputDevice
*
gamepad
,
Settings
const
&
settings
)
{
switch
(
mode
)
{
case
Settings
::
MOUSE_X
:
...
...
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