QPC2 Mouse and SuperBASIC Prog

Helpful tips and guides, also new users can ask for help here.
Post Reply
qbits
Trump Card
Posts: 171
Joined: Sun Dec 11, 2016 3:32 pm

QPC2 Mouse and SuperBASIC Prog

Post by qbits »

This is probably covered somewhere! Hopefully…

I’m running QPC2 5 under a WIN10 set up and trying to use the mouse within a SuperBASIC Prog. In the past I recall the mouse movements being the same as cursor movements left/right/up/down (codes 192/200/208/216) and Spacebar (code 32) the left mouse button and Enter (code 10) the right mouse button.

All I get is a response from the right mouse button (code 10) and surprisingly the centre wheel with codes 209/217.

Mouse clicks on the QPC2 toolbar and menus are OK.

QBITS


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: QPC2 Mouse and SuperBASIC Prog

Post by tofro »

qbits wrote:This is probably covered somewhere! Hopefully…

I’m running QPC2 5 under a WIN10 set up and trying to use the mouse within a SuperBASIC Prog. In the past I recall the mouse movements being the same as cursor movements left/right/up/down (codes 192/200/208/216) and Spacebar (code 32) the left mouse button and Enter (code 10) the right mouse button.

All I get is a response from the right mouse button (code 10) and surprisingly the centre wheel with codes 209/217.

Mouse clicks on the QPC2 toolbar and menus are OK.

QBITS
What you describe is a mouse driver that does cursor key emulation (Qimi used to do this, and I think SerMouse could be made to do it). Cursor emulation is, to my knowledge, not implemented in QPC2 (nor in any SMSQ/E computer).

If you want to use the mouse from S*Basic, you should be using the QPTR Toolkit or similar. (I think there is a hack that PEEKs the current mouse cursor position from the channel definition block(?), but I wouldn't really recommend doing that.


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QPC2 Mouse and SuperBASIC Prog

Post by pjw »

To use the mouse from BASIC you need extra toolkits. Qptr is the original pointer toolkit. Its a hard swallow and will probably change your life forever. EasyPointer is, as the name suggests, somewhat easier to get to grips with, not least of all because much of the hard work of creating and then managing menus, sprites and the like is done in a more graphical rather than textual way.

If you mainly want to stick with the old way of doing things, but want to add a little spice here and there, ie use the Pointer Interface only and avoiding the Window Manager, you could do worse than use some of the commands found at Knoware.no-toolkits-Pointer Environment. There are free-standing commands to read and set the pointer, set the Outline (for Qdos users), etc.

Even so, youre unlikely to get away without reading up on some aspects of the PE. No doubt, someone will pipe up with the best place to start, if anyone needs to know. (I write this without prejudice to how much you already know or dont know of the matter; there may be others reading this who could use the info..)


Per
dont be happy. worry
- ?
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: QPC2 Mouse and SuperBASIC Prog

Post by tofro »

If it's only about reading the pointer position and mouse buttons, both QPTR and EasyPtr are relatively easy to handle.

QPTR:

Code: Select all

1000 win% = 0 : xabs% = 0 : yabs% = 0 : ret% = 16 OR 32
1010 OUTLN 256,202,256,0;1
1020 REPeat Loop
1030 RPTR #win%,xabs%,yabs%,term%,swnum%,xrel%,yrel%,bt$
1040 PRINT #win%; xabs%, yabs%: REM note pointer position in absolute screen coordinates!
1050 END REPeat Loop
The "Termination vector" is in this example is set to "Pointer in Window OR Pointer outside window", thus RPTR returns immediately (you can set it to various other conditions) and sets the pointer position and button values in xabs% and yabs% accordingly.

EasyPtr is very similar: Here you'd do it like that:

Code: Select all

1000 win% = 0 : xabs% = 0 : yabs% = 0 : ret% = 16 OR 32
1010 OUTL
1020 REPeat Loop
1030 RDPTR win%, ret%, xabs%, yabs%
1040 PRINT win%; xabs%, yabs% : REM note absolute screen coordinates
1050 END REPeat Loop


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
pjw
QL Wafer Drive
Posts: 1286
Joined: Fri Jul 11, 2014 8:44 am
Location: Norway
Contact:

Re: QPC2 Mouse and SuperBASIC Prog

Post by pjw »

Thanks for raining on my picnic ;) So heres me blowing my own trumpet:

Code: Select all

10 JOB_NAME 'Testing'
20 OUTLN: REMark SMSQ/E or toolkit
100 tv% = 9: x% = 0: y% = 0: je% = 255: t% = 100
110 CLS
120 ev% = WAIT_EVENT(255, 0): REMark Clear out any pending events
130 REPeat lp
140  sw% = RPT%(tv% ! je%, x%, y%, t%)
150  k% = tv% DIV 256: IF k% < -1: k% = k% + 256
160  CLS
170  PRINT 'subwindow =', sw%
180  PRINT 'keypress  =', k%
190  PRINT 'x%/y% pos =', x%; '/'; y%
200  PRINT 'events    =', je% DIV 256
210  PRINT 'timeout   =', t%
220  IF k% = 27: EXIT lp
230 END REPeat lp
Uses Knoware's RPT% (376b, as opposed to Qptr's 9,620b, or EasyPointer's
15,442b.) Its all about what you want to do and who your target audience
is. I expect most high end users will have one or both of the PE toolkits
installed, in which case using one of them implies 0b overhead, but I
suspect the target audience here is somewhat less "bleeding edge", although
I may very well be wrong.


Per
dont be happy. worry
- ?
User avatar
RalfR
Aurora
Posts: 870
Joined: Fri Jun 15, 2018 8:58 pm

Re: QPC2 Mouse and SuperBASIC Prog

Post by RalfR »

tofro wrote:What you describe is a mouse driver that does cursor key emulation (Qimi used to do this....)
No, only rudimentary if you keep pressing the left button. But that doesn't really do anything for programs. Far too difficult.


4E75 7000
Silvester
Gold Card
Posts: 436
Joined: Thu Dec 12, 2013 10:14 am
Location: UK

Re: QPC2 Mouse and SuperBASIC Prog

Post by Silvester »

RalfR wrote:[No, only rudimentary if you keep pressing the left button. But that doesn't really do anything for programs. Far too difficult.
I thought I remember doing that long ago (when I tried it in SMSQmulator today it didn't work). But it was handy to quickly move cursor about in text editors (other than QD).


David
User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: QPC2 Mouse and SuperBASIC Prog

Post by mk79 »

qbits wrote:I’m running QPC2 5 under a WIN10 set up and trying to use the mouse within a SuperBASIC Prog. In the past I recall the mouse movements being the same as cursor movements left/right/up/down (codes 192/200/208/216) and Spacebar (code 32) the left mouse button and Enter (code 10) the right mouse button.

All I get is a response from the right mouse button (code 10) and surprisingly the centre wheel with codes 209/217.
The left mouse button is normally used to move the cursor (i.e. produce the cursor keys you want). However, QPC adopts the absolute coordinates from windows for a seamless integration, the cursor movement is produced from relative coordinates (earlier QPC versions did this differently and it sucked). This is why the generic cursor keys code doesn't work anymore.

The code that is produced by the middle mouse button (/wheel) can be changed using the MOUSE_STUFF command.


User avatar
RalfR
Aurora
Posts: 870
Joined: Fri Jun 15, 2018 8:58 pm

Re: QPC2 Mouse and SuperBASIC Prog

Post by RalfR »

So the function with the left button no longer works in QPC2, if I understand correctly.
It would be nice if there was such a cursor emulation (like SERmouse), the mouse moves the cursor normally. That would be nice for graphics programs without PE.


4E75 7000
Post Reply