Log In  

I don't think I've missed it anywhere, checked the values on the appropriate (and all other) stat values, etc. There doesn't seem to be a way to get the mouse wheel. This'd be awfully useful in a tool I'm writing. I'm bummed that I have to turn to the dpad/cursor keys while otherwise mousing around in my little gui.

@zep - Assuming I'm not just missing it, would you mind adding the mouse wheel as another stat? Just treat it like an axis; that seems to work better than blipping buttons, in my experience with other APIs. Just increase or decrease the stat value by one each time you get the scroll event.

Please and thanks? :)

P#44491 2017-09-23 14:22 ( Edited 2017-09-24 01:26)

Hey Felice. Unless I'm remembering wrong, I think that mousewheel up, down, and click are all bits returned along with left and right click. At least on Windows.

Maybe I'm thinking of SDL though?

P#44494 2017-09-23 14:35 ( Edited 2017-09-23 18:35)

Middle click, yes. Scroll, no.

Try this and see:

function _init()
    poke(0x5f2d,1)
end
function _update60()
    mx=stat(32)
    my=stat(33)
    mb=stat(34)
end
function _draw()
    cls()
    print(mx)
    print(my)
    print(mb)
end
P#44518 2017-09-23 21:26 ( Edited 2017-09-24 01:26)
1

Sorry for the thread necromancy. As of 2022, mousewheel is detectable.

Pico8 Wiki on mouse:

stat(36) -> number representing a mouse wheel event.

Possible values are:

  • 1 roll up
  • 0 no roll
  • -1 roll down
P#119631 2022-10-27 00:05 ( Edited 2022-10-27 00:07)

You are correct, @lorinc. While it may be common knowledge I did make a tool to demonstrate this recently.

https://www.lexaloffle.com/bbs/?tid=49070

Also put poke(0x5f2d,1) at the top of your code to activate reading the mouse and keyboard.

P#119636 2022-10-27 01:10 ( Edited 2022-10-27 01:50)

Quick note: I believe mousewheel events can have values larger than 1 if people are scrolling quickly? That's what I observed with my test cartridge, anyway.

P#119639 2022-10-27 02:23

@packbat, you are correct. I'm - not sure if this could be something useful. I guess if it is farther than -1 or +1 then you could have a unique function like bring up a menu for "quick rolling."

From this code:

poke(0x5f2d,1)
repeat
  ?stat(36)
  flip()
until forever

It appears as if it will go up to -4 or +4 with very quick rolling.

Update 10-27-22: It could be dodgy to expect an exact number for input. I would continue to use <0 and >0 as a valid value which does register a notch that can be physically felt on the mouse.

Here is a sample program to demonstrate. Run and use the mouse roller.

Cart #gikajezema-0 | 2022-10-28 | Code ▽ | Embed ▽ | No License


Examine source to see how it's done.

P#119657 2022-10-27 15:34 ( Edited 2022-10-28 01:46)

It looks like scroll wheels are actually calibrated with detents to move in discrete increments? So presumably the numbers go farther than +/-1 so that the same amount of physical rotation of the actual wheel on the actual mouse always adds up to the same amount of scroll wheel input, however quickly you move it.

P#119659 2022-10-27 16:05

[Please log in to post a comment]