Differentiate left and right control keys

Post your Gambas programming questions here.
Post Reply
User avatar
Technopeasant
Posts: 149
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Differentiate left and right control keys

Post by Technopeasant »

Is there anyway using Key.Control to determine if it is the left or the right control key being pressed?
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
thatbruce
Posts: 227
Joined: Saturday 4th September 2021 11:29pm

Re: Differentiate left and right control keys

Post by thatbruce »

You can differentiate using Key.LeftControl and Key.RightControl
(Untested)
If Key.Control then 
    If Key.Code=Key.LeftControl then
        ' do something sinister
    Else
        ' do something dextrous
    EndIf
EndIf

Or something like that anyway.

b
User avatar
BruceSteers
Posts: 1838
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Differentiate left and right control keys

Post by BruceSteers »

I don't think it's possible.

The gambas Key.class gives same code for both control keys.

same for Shift

Only Alt keys differentiate as one if Key.AltKey and other is Key.AltGrKey
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1838
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Differentiate left and right control keys

Post by BruceSteers »

It's a shame and certainly limits game control as i discovered on my TurboSnake game.

2 users sharing a keyboard cannot use Shift or Ctrl keys :( well they can but it's dodgy
If at first you don't succeed , try doing something differently.
BruceS
User avatar
thatbruce
Posts: 227
Joined: Saturday 4th September 2021 11:29pm

Re: Differentiate left and right control keys

Post by thatbruce »

So why do the constants exist? M Minisini needs to explain.
They definitely have different scan codes (that's the low level code that's received at the OS level). I know that from a looooooooooong time ago and in a far distant galaxy.
It should be possible!
b
User avatar
BruceSteers
Posts: 1838
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Differentiate left and right control keys

Post by BruceSteers »

I'm pretty sure they don't m8. (not sure what language that is but i don't think it's gambas)

I only see Key.ControlKey constant

I know you can send with x11 Desktop.SendKey("Control_L")

but there's no way to receive

Key.Code for both control keys are the same and its Key.ControlKey
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1838
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Differentiate left and right control keys

Post by BruceSteers »

Seems you can't do it because it's not a qt key code either

the Qt Key class only uses a Key_Control
https://doc.qt.io/qt-6/qt.html#Key-enum

there are ways to do it with the QT api but gambas Key.class does not do anything unusual, it only supports what the toolkit Key class supports in respect to Control and Shift Keys :(

https://stackoverflow.com/questions/112 ... ifier-keys

No clue how to implement any of that though
If at first you don't succeed , try doing something differently.
BruceS
User avatar
Technopeasant
Posts: 149
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Differentiate left and right control keys

Post by Technopeasant »

I am making a very simplistic pinball game, so I guess I will just use control for left flipper and alt for right flipper.
Technical director,
Piga Software
http://icculus.org/piga/
Post Reply