Volume keys TO NORMAL mouse keys

x64 Replacement/Alternative to Microsoft's IntelliMouse application.
Forum rules
Please read the forum rules before posting for the first time.
The more information you can provide, the quicker and more accurately someone can help.
NOTE: To reduce spam, new users can not post links, files or images until they have at least 4 posts.
Post Reply
ADhAEhAFh
New User
Posts: 4
Joined: Sat Aug 01, 2020 11:42 am

Volume keys TO NORMAL mouse keys

Post by ADhAEhAFh »

XMBC Version: 2.19.2
Windows Version: 7 SP1 32-bit / Vista SP2 32-bit
Mouse Information (brand/model): SteelSeries Sensei 310
Relevant Computer Information (CPU, RAM etc): i3-2120; 4Gb / Centrino Duo T8100; 4Gb / AMD E1 [1.0 GHz (!!!)]; 2Gb
Did the problem occur after an upgrade of XMBC? (If so, from what version?): never
Did the problem occur after a Windows update/upgrade? (If so, from what version?): never
How long have you used XMBC?: never
What language and keyboard layout do you use in Windows?: doesn't matter

Remap 0xAD, 0xAE and 0xAF (APPCOMMAND_VOLUME_*keys*) _TO_ 0xC3, 0xC4, 0xC5 (Unreal Tournament 2 Mouse6, Mouse7 and Mouse8):

Code: Select all

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,??,??,20,e0,??,??,2e,e0,  ??,??,30,e0,00,00,00,00
It only affects the PS/2 (notebook) KEYBOARD, not external/wireless or a mouse!
If you know, how to do it without a program, I would glad to remap all of it and will never use this program at all, as before.

Yes, I don't want to handle the volume — I want to remove this feature from the Windows at all, because these volume keys can not be reassigned in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AppKey\ *8*, *9* and *10* subkeys!

P.S. Sensei 310 have 8 buttons, and can assign its buttons to Button6, Button7 and Button8, but UT doesn't response them. I already wrote the feedback to SteelSeries, but they…
cannot promise it will be implemented.
User avatar
phil
Site Admin
Posts: 7627
Joined: Sun Apr 06, 2003 11:12 pm

Re: Volume keys TO NORMAL mouse keys

Post by phil »

XMBC can map mouse buttons to keys, but not the other way round.
Have you looked at AutoHotkey - maybe you can script this in there? Try their forums for help?
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
ADhAEhAFh
New User
Posts: 4
Joined: Sat Aug 01, 2020 11:42 am

Re: Volume keys TO NORMAL mouse keys

Post by ADhAEhAFh »

I just looking for a way to remap the commands that these mice transmit.
I had 'noname' china-mouse, that already assigned the volume keys (that I wanted to remap too), but it has another problem: sometimes it sends 'button PRESS' when I drag then release it! i.e.:
button PRESS;
mouse moving;
button PRESS (!!!);
button RELEASE

total: TWO presses, ONE release! Result: The knob/slider that I adjusted is still HEAR the mouse position!
Click this button again and again – the knob/slider still rotating/moving.
I tried to unpress the stuck knob/slider with AHK — it FAILED! Or it cannot transmit the mouse commands to the program I need! I mean, I need a program that modifies the "events" on the fly so that another program identifies these messages as coming from the same mouse (not an other source)!
No, I'll never use autohotkey anymore and never recommend it anybody!
ADhAEhAFh wrote: Sat Aug 01, 2020 12:18 pmhave 8 buttons, and can assign its buttons to Button6, Button7 and Button8
Oh, I forgot to mention (why I never use XMBC): remap simple Mouse4 and Mouse5 to different actions (or as real but different mouse buttons), apply and run UT2k4… Unreal Tournament still catches them as MOUSE4 and MOUSE5 — nothing changed!
___
P.S. The Sensei 310 sometimes (after system boot-up) has these issues:
[1] click-drag performs click-click-click-click-click… (infinity times, until release or stop dragging);
[2] The mouse cursor sticks to the bottom (e.g. in taskbar). X Axis works good, but I can't move it by Y Axis! Push the device from myself very hard — the cursor appears at a moment and immidiately sticks to the bottom;
I must re-plug the mouse to solve each of that problem.
User avatar
phil
Site Admin
Posts: 7627
Joined: Sun Apr 06, 2003 11:12 pm

Re: Volume keys TO NORMAL mouse keys

Post by phil »

Sounds like a faulty mouse to me - I don't understand how it could send multiple presses without corresponding releases. If it were a dirty button/switch contact, I would expect it s send lots of press/release/press/release combos but never press, press, press, press.... release

That is really going to screw with Windows (never mind AHK or XMBC) - which I guess is what you are seeing.
Rather than send an additional release (with AHK) you'd be better off blocking the second press - as in swallowing the message and not forward it on. That may be possible.

Unreal tournament probably uses direct input or raw input - this is much lower level and can not be blocked by XMBC. XMBC (and AHK) intercept Windows Mouse Hook messages and that's the only place you can "block" messages. If a game operates at a lower level (as many do), your screwed on that front.

AHK and XMBC are both limited by what you can do in Windows without writing your own mouse driver. The only way (that I am aware of) you could block these messages from everything (including raw/direct input) would be to write a mouse filter driver. This is technically difficult AND expensive as you need to digitally sign your driver and to do that you need to be a registered company and spend 100's of dollars a year to do so. Fine for a device manufacturer, not so fine for the hobby programmer!

So I fear you may be out of luck with this one.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
ADhAEhAFh
New User
Posts: 4
Joined: Sat Aug 01, 2020 11:42 am

(about sending Press when already pressed)

Post by ADhAEhAFh »

phil wrote: Thu Aug 06, 2020 12:17 pmhow it could send multiple presses without corresponding releases.
I think it is generated by chip (mouse internal firmware bug: maybe the chip "forgets" about the already pressed button and sends the second "press" BEFORE the "release", maybe), not by physical buttons.
phil wrote: Thu Aug 06, 2020 12:17 pmbetter off blocking the second press - as in swallowing the message and not forward it on. That may be possible.
And I would like to know, how to do this. I performed many searches for a program/driver, but got "doubleclick-blockers" only :cry: ;(the "unpress" comes many seconds later!), and yes I need a program like this:

Code: Select all

"if" no one mouse key is pressed/released at the program start ? hearing…
if catch the first "Button_1" 'press' ?
 start to 'swallowing' the 'press' of "Button_1" & hearing…
 catch the 'release' ? return;
if catch the first "Button_2" "press" ?
 start to 'swallowing' the 'press' of "Button_2" & hearing…
 catch the 'release' ? return;
if catch the 'release' of "Button_2" ?
 run a timer with "adjusted_for_button_2" & hearing…
 filter the "Button_2" 'press' & '_optionally_Release';
 timer is over ? return;
if catch the 'release' of "Button_1" ?
 run a timer with "adjusted_for_button_1" & hearing…
 filter the "Button_1" 'press' & '_optionally_Release';
 timer is over ? return;
…
I don't know how to «transcode» this logic to ASM/pas/basiC+ (don't even look at the .NET!!), and it is a pity that it can not work fine in X-MBC :\
User avatar
phil
Site Admin
Posts: 7627
Joined: Sun Apr 06, 2003 11:12 pm

Re: Volume keys TO NORMAL mouse keys

Post by phil »

XMBC uses mouse hooks. You could in theory write a hook function that performs the logic you mention, however there are several limitations with mouse hooks. XMBC is a tool to remap buttons, its not really designed to fix bad mice. The current de-bounce stuff was an attempt to help reduce the problems associated with noisy contacts on old mouse buttons, but it does not really work very well. And I don't really want to go down that route if I can help it - I don't have enough time to spend on XMBC as it is, let alone trying to fix a problem that a single user is having with a single device.

In your mouse hook, you can swallow/block the message or pass it on (dont block it). XMBC uses this to block reconfigured buttons and do something else instead.

The biggest limitation is that if anything uses directinput/rawinput to capture the mouse, then that operates at a lower level and you cant intercept/block that. This normally impacts games as they tend to be the things using direct input to reduce input latency etc.

You can write mouch hook procedures in C++ (as XMBC does), and I imagine most other languages (certainly .net - but it wont be particularly efficient as it will have to interop lots), ASM Im not familar with these days, pascal - not sure - delphi yes for sure. Look at the MS API SetLowLevelHook for information on how to install a hook procedure to filter the messages.

Ideally though you would do this in a mouse filter driver. But filter drivers are a much more complicated beast - and require signing with certificates not available to the general public (you need to be a registered company and have plenty of $$$ to spend on certificates each year!).
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
ADhAEhAFh
New User
Posts: 4
Joined: Sat Aug 01, 2020 11:42 am

Re(turning back to topic): Volume keys TO NORMAL mouse keys

Post by ADhAEhAFh »

phil wrote: Thu Aug 06, 2020 12:17 pmUnreal tournament probably uses direct input or raw input…
phil wrote: Mon Aug 10, 2020 1:03 amThe biggest limitation is that if anything uses directinput/rawinput to capture the mouse, then that operates at a lower level and you can't intercept/block that.
Hmm, github: oblitum/Interception/
I've remapped media keys that comes from my new keyboard:
#InstallKeybdHook
Volume_Up::VK1E ;ACCEPT
Volume_Down::VK6C ;SEPARATOR
Volume_Mute::VK2F ;HELP
Media_Play_Pause::VK15 ;HANGUL mode (HANGUEL), KANA
Media_Stop::VK5F ;sleep
Media_Prev::VKDF ;OEM_8
Media_Next::VKF6 ;Attention
#InstallMouseHook
XButton1::VK95 ;OEM_FJ_LOYAyubi (Left Thumb)
XButton2::VK96 ;OEM_FJ_ROYAyubi (Right Thumb)
in UT2 all keys (including the mouse) are catched REMAPPED! :whack: (run it even unelevated)!
When "VKAA" (Search) & "VKAC" (Home) come from AHK using the mouse wheel: UT2 recognizes these keys (remapped) before then application (HKCR\search & Windows\CurrentVersion\Explorer\AppKey\7) starts (then UT2 loses a focus) — Instant release!

If XMBC can't use DirectInput actions, can AHK use it instead of VK_`?
DIMOUSE_BUTTON0 / DIMOFS_BUTTON0 (LButton), ;0x1
DIMOUSE_BUTTON1 / DIMOFS_BUTTON1 (RButton), ;0x2
DIMOUSE_BUTTON2 / DIMOFS_BUTTON2 (MButton), ;0x4
DIMOUSE_BUTTON3 / DIMOFS_BUTTON3 (XButton1), ;0x05, but in UT2: 0xC1 – both VK05 & VKC1 trigger keynumber 193=Mouse4
DIMOUSE_BUTTON4 / DIMOFS_BUTTON4 (XButton2), ;0x06, but in UT2: 0xC2 – both VK06 & VKC2 trigger keynumber 194=Mouse5
DIMOUSE_BUTTON5 / DIMOFS_BUTTON5, ;in UT2 triggered with VKC3 (keynumber 195) — Mouse6
DIMOUSE_BUTTON6 / DIMOFS_BUTTON6, ;in UT2 triggered with VKC4 (keynumber 196) — Mouse7
DIMOUSE_BUTTON7 / DIMOFS_BUTTON7, ;in UT2 triggered with VKC5 (keynumber 197) — Mouse8
but… there is no "WheelUp" & "WheelDown" — can DIMOUSE_WHEEL be horizontal scrolling too? Ok, "Wheels" can be used as:
Volume_Up::WheelUp ;in UT2 = 0xEC (VK_OEM_PA2)
Volume_Down::WheelDown ;in UT2 = 0xED (VK_OEM_PA3)
Media_Prev::WheelLeft ;UT2 can't intercept it (ignores and waits for pressing a key)
Media_Next::WheelRight ;—//—
What to do for Mouse6,7,8?
User avatar
phil
Site Admin
Posts: 7627
Joined: Sun Apr 06, 2003 11:12 pm

Re: Volume keys TO NORMAL mouse keys

Post by phil »

I'm not entirely sure if you are asking a question in there or just letting me know what you have found (thanks).

Looks like that interception thing use a driver so it will be operating at a lower level than XMBC which I guess is why it works better in games - it even mentions being used by game bots (cheats) so one of its "selling" points!.

AFAIK mouse buttons > 5 can't be hooked (via XMBC, autohotkey) as far as I know. Maybe you can see the buttons using directinput API's but you wont be able to block them... just react to them maybe.
--[ Phil ]--
--[ Administrator & XMBC Author ]--
Logitech G9/G604/M720/MX518, Microsoft Intellimouse, Trust 16341 BT Mouse
Windows 10 x64, AMD Ryzen 5900x, MSI x570 Tomahawk, 32GB DDR4,
nVidia RTX 2070s, Evo 970 1Tb NVME, 2x2TB WD Black (RAID1)
Post Reply