Page MenuHome

GHOST-mac-tabletpressure.txt

Authored By
Matt Ebb (broken)
Nov 13 2013, 1:12 PM
Size
13 KB
Subscribers
None

GHOST-mac-tabletpressure.txt

Index: intern/ghost/GHOST_Types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/GHOST_Types.h,v
retrieving revision 1.12
diff -u -r1.12 GHOST_Types.h
--- intern/ghost/GHOST_Types.h 29 Mar 2005 14:27:20 -0000 1.12
+++ intern/ghost/GHOST_Types.h 21 Jul 2006 12:56:05 -0000
@@ -310,6 +310,8 @@
GHOST_TInt32 x;
/** The y-coordinate of the cursor position. */
GHOST_TInt32 y;
+ /* tablet pressure */
+ GHOST_TUns16 pressure;
} GHOST_TEventCursorData;
typedef struct {
Index: intern/ghost/intern/GHOST_EventCursor.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_EventCursor.h,v
retrieving revision 1.6
diff -u -r1.6 GHOST_EventCursor.h
--- intern/ghost/intern/GHOST_EventCursor.h 28 Dec 2002 22:26:45 -0000 1.6
+++ intern/ghost/intern/GHOST_EventCursor.h 21 Jul 2006 12:56:05 -0000
@@ -52,12 +52,14 @@
* @param type The type of this event.
* @param x The x-coordinate of the location the cursor was at at the time of the event.
* @param y The y-coordinate of the location the cursor was at at the time of the event.
+ * @param pressure Tablet pressure at the time of the event
*/
- GHOST_EventCursor(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TInt32 x, GHOST_TInt32 y)
+ GHOST_EventCursor(GHOST_TUns64 msec, GHOST_TEventType type, GHOST_IWindow* window, GHOST_TInt32 x, GHOST_TInt32 y, GHOST_TUns16 pressure)
: GHOST_Event(msec, type, window)
{
m_cursorEventData.x = x;
m_cursorEventData.y = y;
+ m_cursorEventData.pressure = pressure;
m_data = &m_cursorEventData;
}
Index: intern/ghost/intern/GHOST_SystemCarbon.cpp
===================================================================
RCS file: /cvsroot/bf-blender/blender/intern/ghost/intern/GHOST_SystemCarbon.cpp,v
retrieving revision 1.23
diff -u -r1.23 GHOST_SystemCarbon.cpp
--- intern/ghost/intern/GHOST_SystemCarbon.cpp 20 Jun 2006 20:24:07 -0000 1.23
+++ intern/ghost/intern/GHOST_SystemCarbon.cpp 21 Jul 2006 12:56:07 -0000
@@ -705,25 +705,61 @@
else {
GHOST_TEventType type = (kind == kEventMouseDown) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
EventMouseButton button;
-
+
/* Window still gets mouse up after command-H */
- if (m_windowManager->getActiveWindow()) {
+ if (m_windowManager->getActiveWindow()) {
::GetEventParameter(event, kEventParamMouseButton, typeMouseButton, NULL, sizeof(button), NULL, &button);
+
pushEvent(new GHOST_EventButton(getMilliSeconds(), type, window, convertButton(button)));
+
err = noErr;
}
}
- break;
+ break;
case kEventMouseMoved:
- case kEventMouseDragged:
+ case kEventMouseDragged:
Point mousePos;
+ TabletPointRec tabletPointRecord;
+ GHOST_TUns16 pressure;
+ UInt32 anInt32;
+
+ pressure = 0;
+
if (window) {
+ // is there an embedded tablet event inside this mouse event?
+ if(noErr == GetEventParameter(event, kEventParamTabletEventType, typeUInt32, NULL, sizeof(UInt32), NULL, (void *)&anInt32))
+ {
+ // yes there is one!
+ // Embedded tablet events can either be a proximity or pointer event.
+ if(anInt32 == kEventTabletPoint)
+ {
+ //GHOST_PRINT("Embedded pointer event!\n");
+
+ // Extract the tablet Pointer Event. If there is no Tablet Pointer data
+ // in this event, then this call will return an error. Just ignore the
+ // error and go on. This can occur when a proximity event is embedded in
+ // a mouse event and you did not check the mouse event to see which type
+ // of tablet event was embedded.
+ if(noErr == GetEventParameter(event, kEventParamTabletPointRec,
+ typeTabletPointRec, NULL,
+ sizeof(TabletPointRec),
+ NULL, (void *)&tabletPointRecord))
+ {
+ // printf("pressure: %u\n", tabletPointRecord.pressure);
+ pressure = tabletPointRecord.pressure;
+ }
+ } else {
+ // GHOST_PRINT("Embedded proximity event\n");
+ }
+
+ }
+
::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
- pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
+ pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v, pressure));
err = noErr;
}
- break;
+ break;
case kEventMouseWheelMoved:
{
Index: source/blender/include/BDR_imagepaint.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BDR_imagepaint.h,v
retrieving revision 1.1
diff -u -r1.1 BDR_imagepaint.h
--- source/blender/include/BDR_imagepaint.h 16 Sep 2005 20:17:09 -0000 1.1
+++ source/blender/include/BDR_imagepaint.h 21 Jul 2006 12:57:09 -0000
@@ -50,6 +50,9 @@
#define IMAGEPAINT_TORUS 8
#define IMAGEPAINT_TIMED 16
+#define IMAGEPAINT_PRESSURE_OPACITY 1024
+#define IMAGEPAINT_PRESSURE_SIZE 2048
+
typedef struct ImagePaintTool {
float rgba[4];
int size;
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/include/BIF_mywindow.h,v
retrieving revision 1.8
diff -u -r1.8 BIF_mywindow.h
--- source/blender/include/BIF_mywindow.h 28 Mar 2005 05:55:45 -0000 1.8
+++ source/blender/include/BIF_mywindow.h 21 Jul 2006 12:57:10 -0000
@@ -120,6 +120,7 @@
#define R_MOUSE 4
short get_mbut(void);
short get_qual(void);
+float get_pressure(void);
void getmouse(short *mval);
void warp_pointer(int x, int y);
Index: source/blender/src/drawimage.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/drawimage.c,v
retrieving revision 1.71
diff -u -r1.71 drawimage.c
--- source/blender/src/drawimage.c 6 Jul 2006 21:36:26 -0000 1.71
+++ source/blender/src/drawimage.c 21 Jul 2006 12:57:23 -0000
@@ -976,9 +976,16 @@
uiBlockBeginAlign(block);
uiDefButF(block, COL, B_VPCOLSLI, "", 979,160,230,19, tool->rgba, 0, 0, 0, 0, "");
- uiDefButF(block, NUMSLI, B_SIMANOTHING , "Opacity ", 979,140,230,19, tool->rgba+3, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
- uiDefButI(block, NUMSLI, B_SIMANOTHING , "Size ", 979,120,230,19, &tool->size, 2, 64, 0, 0, "The size of the brush");
- uiDefButF(block, NUMSLI, B_SIMANOTHING , "Fall ", 979,100,230,19, &tool->innerradius, 0.0, 1.0, 0, 0, "The fall off radius of the brush");
+ uiDefButF(block, NUMSLI, B_SIMANOTHING , "Opacity ",
+ 979, 140,130,19, tool->rgba+3, 0.0, 1.0, 0, 0, "The amount of pressure on the brush");
+ uiDefButBitS(block, TOG|BIT, IMAGEPAINT_PRESSURE_OPACITY, B_SIMABRUSHCHANGE, "Pressure",
+ 1119,140,90,19, &Gip.flag, 0, 0, 0, 0, "Affect opacity with tablet pressure");
+ uiDefButI(block, NUMSLI, B_SIMANOTHING , "Size ",
+ 979, 120,130,19, &tool->size, 2, 64, 0, 0, "The size of the brush");
+ uiDefButBitS(block, TOG|BIT, IMAGEPAINT_PRESSURE_SIZE, B_SIMABRUSHCHANGE, "Pressure",
+ 1119,120,90,19, &Gip.flag, 0, 0, 0, 0, "Affect size with tablet pressure");
+ uiDefButF(block, NUMSLI, B_SIMANOTHING , "Fall ",
+ 979, 100,230,19, &tool->innerradius, 0.0, 1.0, 0, 0, "The fall off radius of the brush");
if(Gip.current == IMAGEPAINT_BRUSH || Gip.current == IMAGEPAINT_SMEAR)
uiDefButF(block, NUMSLI, B_SIMANOTHING , "Stepsize ",979,80,230,19, &tool->timing, 1.0, 100.0, 0, 0, "Repeating Paint On %of Brush diameter");
@@ -1006,7 +1013,7 @@
uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL_DRAWING, B_SIMABRUSHCHANGE, "TD", 890,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables tool shape while drawing");
uiDefButBitS(block, TOG|BIT, IMAGEPAINT_DRAW_TOOL, B_SIMABRUSHCHANGE, "TP", 940,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables tool shape while not drawing");
#endif
- uiDefButBitS(block, TOG|BIT, IMAGEPAINT_TORUS, B_SIMABRUSHCHANGE, "Wrap", 890,1,50,19, &Gip.flag, 0, 0, 0, 0, "Enables torus wrapping");
+ uiDefButBitS(block, TOG|BIT, IMAGEPAINT_TORUS, B_SIMABRUSHCHANGE, "Wrap", 890,1,80,19, &Gip.flag, 0, 0, 0, 0, "Enables torus wrapping");
}
static void image_panel_curves_reset(void *cumap_v, void *unused)
Index: source/blender/src/editscreen.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editscreen.c,v
retrieving revision 1.135
diff -u -r1.135 editscreen.c
--- source/blender/src/editscreen.c 6 Jul 2006 12:50:48 -0000 1.135
+++ source/blender/src/editscreen.c 21 Jul 2006 12:57:46 -0000
@@ -2077,6 +2077,11 @@
winlay_process_events(0);
return window_get_mbut(mainwin);
}
+float get_pressure(void)
+{
+ winlay_process_events(0);
+ return window_get_pressure(mainwin);
+}
void add_to_mainqueue(Window *win, void *user_data, short evt, short val, char ascii)
{
Index: source/blender/src/ghostwinlay.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/ghostwinlay.c,v
retrieving revision 1.44
diff -u -r1.44 ghostwinlay.c
--- source/blender/src/ghostwinlay.c 18 Jun 2006 11:38:34 -0000 1.44
+++ source/blender/src/ghostwinlay.c 21 Jul 2006 12:57:46 -0000
@@ -87,6 +87,7 @@
int lmouse[2];
int lqual; /* (LR_SHFTKEY, LR_CTRLKEY, LR_ALTKEY, LR_COMMANDKEY) */
int lmbut; /* (L_MOUSE, M_MOUSE, R_MOUSE) */
+ float pressure; /* tablet pressure */
/* Tracks the faked mouse button, if non-zero it is
* the event number of the last faked button.
@@ -522,9 +523,14 @@
GHOST_ScreenToClient(win->ghostwin, cd->x, cd->y, &cx, &cy);
win->lmouse[0]= cx;
win->lmouse[1]= (win->size[1]-1) - cy;
+
+ /* tablet pressure gets sent along with mouse movements */
+ if (cd->pressure) win->pressure = (float)(cd->pressure) / 65535.0;
+ else win->pressure = 0.0;
window_handle(win, MOUSEX, win->lmouse[0]);
window_handle(win, MOUSEY, win->lmouse[1]);
+
}
break;
}
@@ -702,6 +708,10 @@
short window_get_mbut(Window *win) {
return win->lmbut;
+}
+
+float window_get_pressure(Window *win) {
+ return win->pressure;
}
void window_get_mouse(Window *win, short *mval) {
Index: source/blender/src/imagepaint.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/imagepaint.c,v
retrieving revision 1.5
diff -u -r1.5 imagepaint.c
--- source/blender/src/imagepaint.c 12 Jun 2006 15:28:47 -0000 1.5
+++ source/blender/src/imagepaint.c 21 Jul 2006 12:57:47 -0000
@@ -54,6 +54,7 @@
#include "DNA_space_types.h"
#include "BKE_global.h"
+#include "BKE_utildefines.h"
#include "BIF_mywindow.h"
#include "BIF_screen.h"
@@ -83,10 +84,9 @@
0, IMAGEPAINT_BRUSH
};
-static int imagepaint_init(IMG_BrushPtr **brush, IMG_CanvasPtr **canvas, IMG_CanvasPtr **clonecanvas)
+static int imagepaint_init(IMG_BrushPtr **brush, IMG_CanvasPtr **canvas, IMG_CanvasPtr **clonecanvas, ImagePaintTool *tool)
{
ImBuf *ibuf= NULL, *cloneibuf= NULL;
- ImagePaintTool *tool= &Gip.tool[Gip.current];
/* verify that we can paint */
if(!G.sima->image || !G.sima->image->ibuf || !G.sima->image->ibuf->rect)
@@ -201,8 +201,11 @@
float prevuv[2], uv[2];
int paint= 0, moved= 0, firsttouch=1 ;
ImagePaintTool *tool= &Gip.tool[Gip.current];
+ float pressure=0.0, oldpressure=0.0;
+ float oldtoolsize = tool->size;
+ float oldtoolopacity = tool->rgba[3];
- if(!imagepaint_init(&brush, &canvas, &clonecanvas))
+ if(!imagepaint_init(&brush, &canvas, &clonecanvas, tool))
return;
getmouseco_areawin(prevmval);
@@ -233,7 +236,7 @@
dmval[1]= prevmval[1] - mval[1];
d= sqrt(dmval[0]*dmval[0] + dmval[1]*dmval[1]);
- dlimit= tool->size*G.sima->zoom*tool->timing/200.0;
+ dlimit= tool->size*G.sima->zoom*tool->timing/500.0;
if (d < dlimit)
paint= 0;
@@ -243,6 +246,27 @@
/* do the actual painting */
imagepaint_compute_uvco(prevmval, prevuv);
imagepaint_compute_uvco(mval, uv);
+
+ if ((Gip.flag & IMAGEPAINT_PRESSURE_SIZE) || (Gip.flag & IMAGEPAINT_PRESSURE_OPACITY)) {
+ pressure = get_pressure();
+
+ if (pressure != oldpressure) {
+ oldtoolsize = tool->size;
+ oldtoolopacity = tool->rgba[3];
+
+ if(Gip.flag & IMAGEPAINT_PRESSURE_SIZE)
+ tool->size = tool->size * pressure;
+ if(Gip.flag & IMAGEPAINT_PRESSURE_OPACITY)
+ tool->rgba[3] = tool->rgba[3] * pressure;
+
+ imagepaint_free(brush, canvas, clonecanvas);
+ if(!imagepaint_init(&brush, &canvas, &clonecanvas, tool)) break;
+
+ tool->size = oldtoolsize;
+ tool->rgba[3] = oldtoolopacity;
+ }
+ oldpressure = pressure;
+ }
imagepaint_paint_tool(brush, canvas, clonecanvas, prevuv, uv);
Index: source/blender/src/winlay.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/winlay.h,v
retrieving revision 1.11
diff -u -r1.11 winlay.h
--- source/blender/src/winlay.h 23 Mar 2005 21:10:02 -0000 1.11
+++ source/blender/src/winlay.h 21 Jul 2006 12:58:17 -0000
@@ -56,6 +56,7 @@
short window_get_qual (Window *win);
short window_get_mbut (Window *win);
+float window_get_pressure (Window *win);
void window_get_mouse (Window *win, short *mval);
void window_get_position (Window *win, int *posx_r, int *poxy_r);

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
cd/86/74688f7543e54aa96094ce1b21c1

Event Timeline